Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Freescale Semiconductor, Inc. |
| 3 | * Copyright 2012 Linaro Ltd. |
| 4 | * |
| 5 | * The code contained herein is licensed under the GNU General Public |
| 6 | * License. You may obtain a copy of the GNU General Public License |
| 7 | * Version 2 or later at the following locations: |
| 8 | * |
| 9 | * http://www.opensource.org/licenses/gpl-license.html |
| 10 | * http://www.gnu.org/copyleft/gpl.html |
| 11 | */ |
| 12 | |
| 13 | #include <linux/clk.h> |
| 14 | #include <linux/clkdev.h> |
Shawn Guo | 633ef4c | 2013-03-25 14:53:08 +0800 | [diff] [blame^] | 15 | #include <linux/clocksource.h> |
Shawn Guo | 44ffb78 | 2012-08-06 22:00:45 +0800 | [diff] [blame] | 16 | #include <linux/can/platform/flexcan.h> |
Shawn Guo | 2c7c2c1 | 2012-07-13 14:15:34 +0800 | [diff] [blame] | 17 | #include <linux/delay.h> |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 18 | #include <linux/err.h> |
Shawn Guo | 2c7c2c1 | 2012-07-13 14:15:34 +0800 | [diff] [blame] | 19 | #include <linux/gpio.h> |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 20 | #include <linux/init.h> |
Shawn Guo | 3143bbb | 2012-07-07 23:12:03 +0800 | [diff] [blame] | 21 | #include <linux/micrel_phy.h> |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 22 | #include <linux/mxsfb.h> |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 23 | #include <linux/of_platform.h> |
Shawn Guo | 3143bbb | 2012-07-07 23:12:03 +0800 | [diff] [blame] | 24 | #include <linux/phy.h> |
Shawn Guo | 2c7c2c1 | 2012-07-13 14:15:34 +0800 | [diff] [blame] | 25 | #include <linux/pinctrl/consumer.h> |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 26 | #include <asm/mach/arch.h> |
| 27 | #include <asm/mach/time.h> |
| 28 | #include <mach/common.h> |
Dong Aisheng | e317317 | 2012-08-01 11:20:16 +0800 | [diff] [blame] | 29 | #include <mach/digctl.h> |
Shawn Guo | 2c7c2c1 | 2012-07-13 14:15:34 +0800 | [diff] [blame] | 30 | #include <mach/mxs.h> |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 31 | |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 32 | static struct fb_videomode mx23evk_video_modes[] = { |
| 33 | { |
| 34 | .name = "Samsung-LMS430HF02", |
| 35 | .refresh = 60, |
| 36 | .xres = 480, |
| 37 | .yres = 272, |
| 38 | .pixclock = 108096, /* picosecond (9.2 MHz) */ |
| 39 | .left_margin = 15, |
| 40 | .right_margin = 8, |
| 41 | .upper_margin = 12, |
| 42 | .lower_margin = 4, |
| 43 | .hsync_len = 1, |
| 44 | .vsync_len = 1, |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 45 | }, |
| 46 | }; |
| 47 | |
| 48 | static struct fb_videomode mx28evk_video_modes[] = { |
| 49 | { |
| 50 | .name = "Seiko-43WVF1G", |
| 51 | .refresh = 60, |
| 52 | .xres = 800, |
| 53 | .yres = 480, |
| 54 | .pixclock = 29851, /* picosecond (33.5 MHz) */ |
| 55 | .left_margin = 89, |
| 56 | .right_margin = 164, |
| 57 | .upper_margin = 23, |
| 58 | .lower_margin = 10, |
| 59 | .hsync_len = 10, |
| 60 | .vsync_len = 10, |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 61 | }, |
| 62 | }; |
| 63 | |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 64 | static struct fb_videomode m28evk_video_modes[] = { |
| 65 | { |
| 66 | .name = "Ampire AM-800480R2TMQW-T01H", |
| 67 | .refresh = 60, |
| 68 | .xres = 800, |
| 69 | .yres = 480, |
| 70 | .pixclock = 30066, /* picosecond (33.26 MHz) */ |
| 71 | .left_margin = 0, |
| 72 | .right_margin = 256, |
| 73 | .upper_margin = 0, |
| 74 | .lower_margin = 45, |
| 75 | .hsync_len = 1, |
| 76 | .vsync_len = 1, |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 77 | }, |
| 78 | }; |
| 79 | |
Lauri Hintsala | d8bb823 | 2012-07-10 10:08:08 +0300 | [diff] [blame] | 80 | static struct fb_videomode apx4devkit_video_modes[] = { |
| 81 | { |
| 82 | .name = "HannStar PJ70112A", |
| 83 | .refresh = 60, |
| 84 | .xres = 800, |
| 85 | .yres = 480, |
| 86 | .pixclock = 33333, /* picosecond (30.00 MHz) */ |
| 87 | .left_margin = 88, |
| 88 | .right_margin = 40, |
| 89 | .upper_margin = 32, |
| 90 | .lower_margin = 13, |
| 91 | .hsync_len = 48, |
| 92 | .vsync_len = 3, |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 93 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
Lauri Hintsala | d8bb823 | 2012-07-10 10:08:08 +0300 | [diff] [blame] | 94 | }, |
| 95 | }; |
| 96 | |
Gwenhael Goavec-Merou | a4dabca | 2012-11-02 19:01:48 +0100 | [diff] [blame] | 97 | static struct fb_videomode apf28dev_video_modes[] = { |
| 98 | { |
| 99 | .name = "LW700", |
| 100 | .refresh = 60, |
| 101 | .xres = 800, |
| 102 | .yres = 480, |
| 103 | .pixclock = 30303, /* picosecond */ |
| 104 | .left_margin = 96, |
| 105 | .right_margin = 96, /* at least 3 & 1 */ |
| 106 | .upper_margin = 0x14, |
| 107 | .lower_margin = 0x15, |
| 108 | .hsync_len = 64, |
| 109 | .vsync_len = 4, |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 110 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, |
Gwenhael Goavec-Merou | a4dabca | 2012-11-02 19:01:48 +0100 | [diff] [blame] | 111 | }, |
| 112 | }; |
| 113 | |
Maxime Ripard | 1fe4274 | 2013-01-25 09:54:07 +0100 | [diff] [blame] | 114 | static struct fb_videomode cfa10049_video_modes[] = { |
| 115 | { |
| 116 | .name = "Himax HX8357-B", |
| 117 | .refresh = 60, |
| 118 | .xres = 320, |
| 119 | .yres = 480, |
| 120 | .pixclock = 108506, /* picosecond (9.216 MHz) */ |
| 121 | .left_margin = 2, |
| 122 | .right_margin = 2, |
| 123 | .upper_margin = 2, |
| 124 | .lower_margin = 2, |
| 125 | .hsync_len = 15, |
| 126 | .vsync_len = 15, |
Maxime Ripard | 1fe4274 | 2013-01-25 09:54:07 +0100 | [diff] [blame] | 127 | }, |
| 128 | }; |
| 129 | |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 130 | static struct mxsfb_platform_data mxsfb_pdata __initdata; |
| 131 | |
Shawn Guo | 44ffb78 | 2012-08-06 22:00:45 +0800 | [diff] [blame] | 132 | /* |
| 133 | * MX28EVK_FLEXCAN_SWITCH is shared between both flexcan controllers |
| 134 | */ |
| 135 | #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13) |
| 136 | |
| 137 | static int flexcan0_en, flexcan1_en; |
| 138 | |
| 139 | static void mx28evk_flexcan_switch(void) |
| 140 | { |
| 141 | if (flexcan0_en || flexcan1_en) |
| 142 | gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1); |
| 143 | else |
| 144 | gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0); |
| 145 | } |
| 146 | |
| 147 | static void mx28evk_flexcan0_switch(int enable) |
| 148 | { |
| 149 | flexcan0_en = enable; |
| 150 | mx28evk_flexcan_switch(); |
| 151 | } |
| 152 | |
| 153 | static void mx28evk_flexcan1_switch(int enable) |
| 154 | { |
| 155 | flexcan1_en = enable; |
| 156 | mx28evk_flexcan_switch(); |
| 157 | } |
| 158 | |
| 159 | static struct flexcan_platform_data flexcan_pdata[2]; |
| 160 | |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 161 | static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = { |
| 162 | OF_DEV_AUXDATA("fsl,imx23-lcdif", 0x80030000, NULL, &mxsfb_pdata), |
| 163 | OF_DEV_AUXDATA("fsl,imx28-lcdif", 0x80030000, NULL, &mxsfb_pdata), |
Shawn Guo | 44ffb78 | 2012-08-06 22:00:45 +0800 | [diff] [blame] | 164 | OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80032000, NULL, &flexcan_pdata[0]), |
| 165 | OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80034000, NULL, &flexcan_pdata[1]), |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 166 | { /* sentinel */ } |
| 167 | }; |
| 168 | |
Shawn Guo | 2954ff3 | 2012-05-04 21:33:42 +0800 | [diff] [blame] | 169 | static void __init imx23_timer_init(void) |
| 170 | { |
| 171 | mx23_clocks_init(); |
Shawn Guo | 633ef4c | 2013-03-25 14:53:08 +0800 | [diff] [blame^] | 172 | clocksource_of_init(); |
Shawn Guo | 2954ff3 | 2012-05-04 21:33:42 +0800 | [diff] [blame] | 173 | } |
| 174 | |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 175 | static void __init imx28_timer_init(void) |
| 176 | { |
| 177 | mx28_clocks_init(); |
Shawn Guo | 633ef4c | 2013-03-25 14:53:08 +0800 | [diff] [blame^] | 178 | clocksource_of_init(); |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 179 | } |
| 180 | |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 181 | enum mac_oui { |
| 182 | OUI_FSL, |
| 183 | OUI_DENX, |
Maxime Ripard | 8eec4b3 | 2012-10-07 10:36:28 +0800 | [diff] [blame] | 184 | OUI_CRYSTALFONTZ, |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | static void __init update_fec_mac_prop(enum mac_oui oui) |
| 188 | { |
| 189 | struct device_node *np, *from = NULL; |
Shawn Guo | fa7c865 | 2012-07-13 14:13:55 +0800 | [diff] [blame] | 190 | struct property *newmac; |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 191 | const u32 *ocotp = mxs_get_ocotp(); |
| 192 | u8 *macaddr; |
| 193 | u32 val; |
| 194 | int i; |
| 195 | |
| 196 | for (i = 0; i < 2; i++) { |
| 197 | np = of_find_compatible_node(from, NULL, "fsl,imx28-fec"); |
| 198 | if (!np) |
| 199 | return; |
Marek Vasut | 16d4770 | 2012-09-25 13:32:18 +0200 | [diff] [blame] | 200 | |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 201 | from = np; |
| 202 | |
Marek Vasut | 16d4770 | 2012-09-25 13:32:18 +0200 | [diff] [blame] | 203 | if (of_get_property(np, "local-mac-address", NULL)) |
| 204 | continue; |
| 205 | |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 206 | newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL); |
| 207 | if (!newmac) |
| 208 | return; |
| 209 | newmac->value = newmac + 1; |
| 210 | newmac->length = 6; |
| 211 | |
| 212 | newmac->name = kstrdup("local-mac-address", GFP_KERNEL); |
| 213 | if (!newmac->name) { |
| 214 | kfree(newmac); |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * OCOTP only stores the last 4 octets for each mac address, |
| 220 | * so hard-code OUI here. |
| 221 | */ |
| 222 | macaddr = newmac->value; |
| 223 | switch (oui) { |
| 224 | case OUI_FSL: |
| 225 | macaddr[0] = 0x00; |
| 226 | macaddr[1] = 0x04; |
| 227 | macaddr[2] = 0x9f; |
| 228 | break; |
| 229 | case OUI_DENX: |
| 230 | macaddr[0] = 0xc0; |
| 231 | macaddr[1] = 0xe5; |
| 232 | macaddr[2] = 0x4e; |
| 233 | break; |
Maxime Ripard | 8eec4b3 | 2012-10-07 10:36:28 +0800 | [diff] [blame] | 234 | case OUI_CRYSTALFONTZ: |
| 235 | macaddr[0] = 0x58; |
| 236 | macaddr[1] = 0xb9; |
| 237 | macaddr[2] = 0xe1; |
| 238 | break; |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 239 | } |
| 240 | val = ocotp[i]; |
| 241 | macaddr[3] = (val >> 16) & 0xff; |
| 242 | macaddr[4] = (val >> 8) & 0xff; |
| 243 | macaddr[5] = (val >> 0) & 0xff; |
| 244 | |
Nathan Fontenot | 79d1c71 | 2012-10-02 16:58:46 +0000 | [diff] [blame] | 245 | of_update_property(np, newmac); |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 249 | static void __init imx23_evk_init(void) |
| 250 | { |
| 251 | mxsfb_pdata.mode_list = mx23evk_video_modes; |
| 252 | mxsfb_pdata.mode_count = ARRAY_SIZE(mx23evk_video_modes); |
| 253 | mxsfb_pdata.default_bpp = 32; |
| 254 | mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 255 | mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT | |
| 256 | MXSFB_SYNC_DOTCLK_FAILING_ACT; |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 257 | } |
| 258 | |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 259 | static inline void enable_clk_enet_out(void) |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 260 | { |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 261 | struct clk *clk = clk_get_sys("enet_out", NULL); |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 262 | |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 263 | if (!IS_ERR(clk)) |
| 264 | clk_prepare_enable(clk); |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 265 | } |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 266 | |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 267 | static void __init imx28_evk_init(void) |
| 268 | { |
| 269 | enable_clk_enet_out(); |
Shawn Guo | 5653acc | 2012-06-19 22:38:14 +0800 | [diff] [blame] | 270 | update_fec_mac_prop(OUI_FSL); |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 271 | |
| 272 | mxsfb_pdata.mode_list = mx28evk_video_modes; |
| 273 | mxsfb_pdata.mode_count = ARRAY_SIZE(mx28evk_video_modes); |
| 274 | mxsfb_pdata.default_bpp = 32; |
| 275 | mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 276 | mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT | |
| 277 | MXSFB_SYNC_DOTCLK_FAILING_ACT; |
Dong Aisheng | e317317 | 2012-08-01 11:20:16 +0800 | [diff] [blame] | 278 | |
| 279 | mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 280 | } |
| 281 | |
Shawn Guo | 44ffb78 | 2012-08-06 22:00:45 +0800 | [diff] [blame] | 282 | static void __init imx28_evk_post_init(void) |
| 283 | { |
| 284 | if (!gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, |
| 285 | "flexcan-switch")) { |
| 286 | flexcan_pdata[0].transceiver_switch = mx28evk_flexcan0_switch; |
| 287 | flexcan_pdata[1].transceiver_switch = mx28evk_flexcan1_switch; |
| 288 | } |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 289 | } |
| 290 | |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 291 | static void __init m28evk_init(void) |
| 292 | { |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 293 | mxsfb_pdata.mode_list = m28evk_video_modes; |
| 294 | mxsfb_pdata.mode_count = ARRAY_SIZE(m28evk_video_modes); |
| 295 | mxsfb_pdata.default_bpp = 16; |
| 296 | mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 297 | mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT; |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 298 | } |
| 299 | |
Marek Vasut | 160d5f2 | 2012-11-18 22:08:29 +0100 | [diff] [blame] | 300 | static void __init sc_sps1_init(void) |
| 301 | { |
| 302 | enable_clk_enet_out(); |
| 303 | } |
| 304 | |
Shawn Guo | 3143bbb | 2012-07-07 23:12:03 +0800 | [diff] [blame] | 305 | static int apx4devkit_phy_fixup(struct phy_device *phy) |
| 306 | { |
| 307 | phy->dev_flags |= MICREL_PHY_50MHZ_CLK; |
| 308 | return 0; |
| 309 | } |
| 310 | |
| 311 | static void __init apx4devkit_init(void) |
| 312 | { |
| 313 | enable_clk_enet_out(); |
| 314 | |
| 315 | if (IS_BUILTIN(CONFIG_PHYLIB)) |
Marek Vasut | 510d573 | 2012-09-23 16:58:50 +0000 | [diff] [blame] | 316 | phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK, |
Shawn Guo | 3143bbb | 2012-07-07 23:12:03 +0800 | [diff] [blame] | 317 | apx4devkit_phy_fixup); |
Lauri Hintsala | d8bb823 | 2012-07-10 10:08:08 +0300 | [diff] [blame] | 318 | |
| 319 | mxsfb_pdata.mode_list = apx4devkit_video_modes; |
| 320 | mxsfb_pdata.mode_count = ARRAY_SIZE(apx4devkit_video_modes); |
| 321 | mxsfb_pdata.default_bpp = 32; |
| 322 | mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 323 | mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT | |
| 324 | MXSFB_SYNC_DOTCLK_FAILING_ACT; |
Shawn Guo | 3143bbb | 2012-07-07 23:12:03 +0800 | [diff] [blame] | 325 | } |
| 326 | |
Shawn Guo | 2c7c2c1 | 2012-07-13 14:15:34 +0800 | [diff] [blame] | 327 | #define ENET0_MDC__GPIO_4_0 MXS_GPIO_NR(4, 0) |
| 328 | #define ENET0_MDIO__GPIO_4_1 MXS_GPIO_NR(4, 1) |
| 329 | #define ENET0_RX_EN__GPIO_4_2 MXS_GPIO_NR(4, 2) |
| 330 | #define ENET0_RXD0__GPIO_4_3 MXS_GPIO_NR(4, 3) |
| 331 | #define ENET0_RXD1__GPIO_4_4 MXS_GPIO_NR(4, 4) |
| 332 | #define ENET0_TX_EN__GPIO_4_6 MXS_GPIO_NR(4, 6) |
| 333 | #define ENET0_TXD0__GPIO_4_7 MXS_GPIO_NR(4, 7) |
| 334 | #define ENET0_TXD1__GPIO_4_8 MXS_GPIO_NR(4, 8) |
| 335 | #define ENET_CLK__GPIO_4_16 MXS_GPIO_NR(4, 16) |
| 336 | |
| 337 | #define TX28_FEC_PHY_POWER MXS_GPIO_NR(3, 29) |
| 338 | #define TX28_FEC_PHY_RESET MXS_GPIO_NR(4, 13) |
| 339 | #define TX28_FEC_nINT MXS_GPIO_NR(4, 5) |
| 340 | |
| 341 | static const struct gpio tx28_gpios[] __initconst = { |
| 342 | { ENET0_MDC__GPIO_4_0, GPIOF_OUT_INIT_LOW, "GPIO_4_0" }, |
| 343 | { ENET0_MDIO__GPIO_4_1, GPIOF_OUT_INIT_LOW, "GPIO_4_1" }, |
| 344 | { ENET0_RX_EN__GPIO_4_2, GPIOF_OUT_INIT_LOW, "GPIO_4_2" }, |
| 345 | { ENET0_RXD0__GPIO_4_3, GPIOF_OUT_INIT_LOW, "GPIO_4_3" }, |
| 346 | { ENET0_RXD1__GPIO_4_4, GPIOF_OUT_INIT_LOW, "GPIO_4_4" }, |
| 347 | { ENET0_TX_EN__GPIO_4_6, GPIOF_OUT_INIT_LOW, "GPIO_4_6" }, |
| 348 | { ENET0_TXD0__GPIO_4_7, GPIOF_OUT_INIT_LOW, "GPIO_4_7" }, |
| 349 | { ENET0_TXD1__GPIO_4_8, GPIOF_OUT_INIT_LOW, "GPIO_4_8" }, |
| 350 | { ENET_CLK__GPIO_4_16, GPIOF_OUT_INIT_LOW, "GPIO_4_16" }, |
| 351 | { TX28_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-phy-power" }, |
| 352 | { TX28_FEC_PHY_RESET, GPIOF_OUT_INIT_LOW, "fec-phy-reset" }, |
| 353 | { TX28_FEC_nINT, GPIOF_DIR_IN, "fec-int" }, |
| 354 | }; |
| 355 | |
| 356 | static void __init tx28_post_init(void) |
| 357 | { |
| 358 | struct device_node *np; |
| 359 | struct platform_device *pdev; |
| 360 | struct pinctrl *pctl; |
| 361 | int ret; |
| 362 | |
| 363 | enable_clk_enet_out(); |
| 364 | |
| 365 | np = of_find_compatible_node(NULL, NULL, "fsl,imx28-fec"); |
| 366 | pdev = of_find_device_by_node(np); |
| 367 | if (!pdev) { |
| 368 | pr_err("%s: failed to find fec device\n", __func__); |
| 369 | return; |
| 370 | } |
| 371 | |
| 372 | pctl = pinctrl_get_select(&pdev->dev, "gpio_mode"); |
| 373 | if (IS_ERR(pctl)) { |
| 374 | pr_err("%s: failed to get pinctrl state\n", __func__); |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | ret = gpio_request_array(tx28_gpios, ARRAY_SIZE(tx28_gpios)); |
| 379 | if (ret) { |
| 380 | pr_err("%s: failed to request gpios: %d\n", __func__, ret); |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | /* Power up fec phy */ |
| 385 | gpio_set_value(TX28_FEC_PHY_POWER, 1); |
| 386 | msleep(26); /* 25ms according to data sheet */ |
| 387 | |
| 388 | /* Mode strap pins */ |
| 389 | gpio_set_value(ENET0_RX_EN__GPIO_4_2, 1); |
| 390 | gpio_set_value(ENET0_RXD0__GPIO_4_3, 1); |
| 391 | gpio_set_value(ENET0_RXD1__GPIO_4_4, 1); |
| 392 | |
| 393 | udelay(100); /* minimum assertion time for nRST */ |
| 394 | |
| 395 | /* Deasserting FEC PHY RESET */ |
| 396 | gpio_set_value(TX28_FEC_PHY_RESET, 1); |
| 397 | |
| 398 | pinctrl_put(pctl); |
| 399 | } |
| 400 | |
Maxime Ripard | 8eec4b3 | 2012-10-07 10:36:28 +0800 | [diff] [blame] | 401 | static void __init cfa10049_init(void) |
| 402 | { |
| 403 | enable_clk_enet_out(); |
| 404 | update_fec_mac_prop(OUI_CRYSTALFONTZ); |
Maxime Ripard | 4a38a85 | 2013-03-05 16:13:35 +0100 | [diff] [blame] | 405 | |
| 406 | mxsfb_pdata.mode_list = cfa10049_video_modes; |
| 407 | mxsfb_pdata.mode_count = ARRAY_SIZE(cfa10049_video_modes); |
| 408 | mxsfb_pdata.default_bpp = 32; |
| 409 | mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 410 | mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT; |
Maxime Ripard | 8eec4b3 | 2012-10-07 10:36:28 +0800 | [diff] [blame] | 411 | } |
| 412 | |
Maxime Ripard | e0f7d90 | 2013-01-26 13:40:37 +0800 | [diff] [blame] | 413 | static void __init cfa10037_init(void) |
| 414 | { |
| 415 | enable_clk_enet_out(); |
| 416 | update_fec_mac_prop(OUI_CRYSTALFONTZ); |
| 417 | } |
| 418 | |
Julien Boibessot | a957fdc | 2012-10-18 11:50:26 +0200 | [diff] [blame] | 419 | static void __init apf28_init(void) |
| 420 | { |
| 421 | enable_clk_enet_out(); |
Gwenhael Goavec-Merou | a4dabca | 2012-11-02 19:01:48 +0100 | [diff] [blame] | 422 | |
| 423 | mxsfb_pdata.mode_list = apf28dev_video_modes; |
| 424 | mxsfb_pdata.mode_count = ARRAY_SIZE(apf28dev_video_modes); |
| 425 | mxsfb_pdata.default_bpp = 16; |
| 426 | mxsfb_pdata.ld_intf_width = STMLCDIF_16BIT; |
Marek Vasut | 6a15075 | 2013-03-18 19:24:02 +0100 | [diff] [blame] | 427 | mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT | |
| 428 | MXSFB_SYNC_DOTCLK_FAILING_ACT; |
Julien Boibessot | a957fdc | 2012-10-18 11:50:26 +0200 | [diff] [blame] | 429 | } |
| 430 | |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 431 | static void __init mxs_machine_init(void) |
| 432 | { |
| 433 | if (of_machine_is_compatible("fsl,imx28-evk")) |
| 434 | imx28_evk_init(); |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 435 | else if (of_machine_is_compatible("fsl,imx23-evk")) |
| 436 | imx23_evk_init(); |
Marek Vasut | 8fa62e1 | 2012-07-07 21:21:38 +0800 | [diff] [blame] | 437 | else if (of_machine_is_compatible("denx,m28evk")) |
| 438 | m28evk_init(); |
Shawn Guo | 3143bbb | 2012-07-07 23:12:03 +0800 | [diff] [blame] | 439 | else if (of_machine_is_compatible("bluegiga,apx4devkit")) |
| 440 | apx4devkit_init(); |
Maxime Ripard | e0f7d90 | 2013-01-26 13:40:37 +0800 | [diff] [blame] | 441 | else if (of_machine_is_compatible("crystalfontz,cfa10037")) |
| 442 | cfa10037_init(); |
Maxime Ripard | 8eec4b3 | 2012-10-07 10:36:28 +0800 | [diff] [blame] | 443 | else if (of_machine_is_compatible("crystalfontz,cfa10049")) |
| 444 | cfa10049_init(); |
Julien Boibessot | a957fdc | 2012-10-18 11:50:26 +0200 | [diff] [blame] | 445 | else if (of_machine_is_compatible("armadeus,imx28-apf28")) |
| 446 | apf28_init(); |
Marek Vasut | 160d5f2 | 2012-11-18 22:08:29 +0100 | [diff] [blame] | 447 | else if (of_machine_is_compatible("schulercontrol,imx28-sps1")) |
| 448 | sc_sps1_init(); |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 449 | |
| 450 | of_platform_populate(NULL, of_default_bus_match_table, |
Shawn Guo | ab2815c | 2012-06-25 21:21:46 +0800 | [diff] [blame] | 451 | mxs_auxdata_lookup, NULL); |
Shawn Guo | 2c7c2c1 | 2012-07-13 14:15:34 +0800 | [diff] [blame] | 452 | |
| 453 | if (of_machine_is_compatible("karo,tx28")) |
| 454 | tx28_post_init(); |
Shawn Guo | 44ffb78 | 2012-08-06 22:00:45 +0800 | [diff] [blame] | 455 | |
| 456 | if (of_machine_is_compatible("fsl,imx28-evk")) |
| 457 | imx28_evk_post_init(); |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 458 | } |
| 459 | |
Shawn Guo | 2954ff3 | 2012-05-04 21:33:42 +0800 | [diff] [blame] | 460 | static const char *imx23_dt_compat[] __initdata = { |
Shawn Guo | 2954ff3 | 2012-05-04 21:33:42 +0800 | [diff] [blame] | 461 | "fsl,imx23", |
| 462 | NULL, |
| 463 | }; |
| 464 | |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 465 | static const char *imx28_dt_compat[] __initdata = { |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 466 | "fsl,imx28", |
| 467 | NULL, |
| 468 | }; |
| 469 | |
Shawn Guo | 2954ff3 | 2012-05-04 21:33:42 +0800 | [diff] [blame] | 470 | DT_MACHINE_START(IMX23, "Freescale i.MX23 (Device Tree)") |
| 471 | .map_io = mx23_map_io, |
Shawn Guo | 83a84ef | 2012-08-20 21:34:56 +0800 | [diff] [blame] | 472 | .init_irq = icoll_init_irq, |
Shawn Guo | 4e0a1b8 | 2012-08-20 10:14:56 +0800 | [diff] [blame] | 473 | .handle_irq = icoll_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 474 | .init_time = imx23_timer_init, |
Shawn Guo | 2954ff3 | 2012-05-04 21:33:42 +0800 | [diff] [blame] | 475 | .init_machine = mxs_machine_init, |
| 476 | .dt_compat = imx23_dt_compat, |
| 477 | .restart = mxs_restart, |
| 478 | MACHINE_END |
| 479 | |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 480 | DT_MACHINE_START(IMX28, "Freescale i.MX28 (Device Tree)") |
| 481 | .map_io = mx28_map_io, |
Shawn Guo | 83a84ef | 2012-08-20 21:34:56 +0800 | [diff] [blame] | 482 | .init_irq = icoll_init_irq, |
Shawn Guo | 4e0a1b8 | 2012-08-20 10:14:56 +0800 | [diff] [blame] | 483 | .handle_irq = icoll_handle_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 484 | .init_time = imx28_timer_init, |
Dong Aisheng | bc3a59c | 2012-03-31 21:26:57 +0800 | [diff] [blame] | 485 | .init_machine = mxs_machine_init, |
| 486 | .dt_compat = imx28_dt_compat, |
| 487 | .restart = mxs_restart, |
| 488 | MACHINE_END |