blob: a6e1ccb05066580cfe5ae335d7e079bc6c658101 [file] [log] [blame]
Dong Aishengbc3a59c2012-03-31 21:26:57 +08001/*
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>
Shawn Guo3cb78252013-03-29 13:36:05 +080014#include <linux/clk/mxs.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080015#include <linux/clkdev.h>
Shawn Guo633ef4c2013-03-25 14:53:08 +080016#include <linux/clocksource.h>
Shawn Guo44ffb782012-08-06 22:00:45 +080017#include <linux/can/platform/flexcan.h>
Shawn Guo2c7c2c12012-07-13 14:15:34 +080018#include <linux/delay.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080019#include <linux/err.h>
Shawn Guo2c7c2c12012-07-13 14:15:34 +080020#include <linux/gpio.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080021#include <linux/init.h>
Shawn Guo6a8e95b2013-03-25 21:34:51 +080022#include <linux/irqchip.h>
23#include <linux/irqchip/mxs.h>
Shawn Guo3143bbb2012-07-07 23:12:03 +080024#include <linux/micrel_phy.h>
Shawn Guoab2815c2012-06-25 21:21:46 +080025#include <linux/mxsfb.h>
Shawn Guo974a9af2013-03-29 09:45:31 +080026#include <linux/of_address.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080027#include <linux/of_platform.h>
Shawn Guo3143bbb2012-07-07 23:12:03 +080028#include <linux/phy.h>
Shawn Guo2c7c2c12012-07-13 14:15:34 +080029#include <linux/pinctrl/consumer.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080030#include <asm/mach/arch.h>
Shawn Guo1f629562013-03-29 13:07:34 +080031#include <asm/mach/map.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080032#include <asm/mach/time.h>
Shawn Guo974a9af2013-03-29 09:45:31 +080033#include <asm/system_misc.h>
Dong Aishenge3173172012-08-01 11:20:16 +080034#include <mach/digctl.h>
Shawn Guo2c7c2c12012-07-13 14:15:34 +080035#include <mach/mxs.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080036
Shawn Guoab2815c2012-06-25 21:21:46 +080037static struct fb_videomode mx23evk_video_modes[] = {
38 {
39 .name = "Samsung-LMS430HF02",
40 .refresh = 60,
41 .xres = 480,
42 .yres = 272,
43 .pixclock = 108096, /* picosecond (9.2 MHz) */
44 .left_margin = 15,
45 .right_margin = 8,
46 .upper_margin = 12,
47 .lower_margin = 4,
48 .hsync_len = 1,
49 .vsync_len = 1,
Shawn Guoab2815c2012-06-25 21:21:46 +080050 },
51};
52
53static struct fb_videomode mx28evk_video_modes[] = {
54 {
55 .name = "Seiko-43WVF1G",
56 .refresh = 60,
57 .xres = 800,
58 .yres = 480,
59 .pixclock = 29851, /* picosecond (33.5 MHz) */
60 .left_margin = 89,
61 .right_margin = 164,
62 .upper_margin = 23,
63 .lower_margin = 10,
64 .hsync_len = 10,
65 .vsync_len = 10,
Shawn Guoab2815c2012-06-25 21:21:46 +080066 },
67};
68
Marek Vasut8fa62e12012-07-07 21:21:38 +080069static struct fb_videomode m28evk_video_modes[] = {
70 {
71 .name = "Ampire AM-800480R2TMQW-T01H",
72 .refresh = 60,
73 .xres = 800,
74 .yres = 480,
75 .pixclock = 30066, /* picosecond (33.26 MHz) */
76 .left_margin = 0,
77 .right_margin = 256,
78 .upper_margin = 0,
79 .lower_margin = 45,
80 .hsync_len = 1,
81 .vsync_len = 1,
Marek Vasut8fa62e12012-07-07 21:21:38 +080082 },
83};
84
Lauri Hintsalad8bb8232012-07-10 10:08:08 +030085static struct fb_videomode apx4devkit_video_modes[] = {
86 {
87 .name = "HannStar PJ70112A",
88 .refresh = 60,
89 .xres = 800,
90 .yres = 480,
91 .pixclock = 33333, /* picosecond (30.00 MHz) */
92 .left_margin = 88,
93 .right_margin = 40,
94 .upper_margin = 32,
95 .lower_margin = 13,
96 .hsync_len = 48,
97 .vsync_len = 3,
Marek Vasut6a150752013-03-18 19:24:02 +010098 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
Lauri Hintsalad8bb8232012-07-10 10:08:08 +030099 },
100};
101
Gwenhael Goavec-Meroua4dabca2012-11-02 19:01:48 +0100102static struct fb_videomode apf28dev_video_modes[] = {
103 {
104 .name = "LW700",
105 .refresh = 60,
106 .xres = 800,
107 .yres = 480,
108 .pixclock = 30303, /* picosecond */
109 .left_margin = 96,
110 .right_margin = 96, /* at least 3 & 1 */
111 .upper_margin = 0x14,
112 .lower_margin = 0x15,
113 .hsync_len = 64,
114 .vsync_len = 4,
Marek Vasut6a150752013-03-18 19:24:02 +0100115 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
Gwenhael Goavec-Meroua4dabca2012-11-02 19:01:48 +0100116 },
117};
118
Maxime Ripard1fe42742013-01-25 09:54:07 +0100119static struct fb_videomode cfa10049_video_modes[] = {
120 {
121 .name = "Himax HX8357-B",
122 .refresh = 60,
123 .xres = 320,
124 .yres = 480,
125 .pixclock = 108506, /* picosecond (9.216 MHz) */
126 .left_margin = 2,
127 .right_margin = 2,
128 .upper_margin = 2,
129 .lower_margin = 2,
130 .hsync_len = 15,
131 .vsync_len = 15,
Maxime Ripard1fe42742013-01-25 09:54:07 +0100132 },
133};
134
Shawn Guoab2815c2012-06-25 21:21:46 +0800135static struct mxsfb_platform_data mxsfb_pdata __initdata;
136
Shawn Guo44ffb782012-08-06 22:00:45 +0800137/*
138 * MX28EVK_FLEXCAN_SWITCH is shared between both flexcan controllers
139 */
140#define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
141
142static int flexcan0_en, flexcan1_en;
143
144static void mx28evk_flexcan_switch(void)
145{
146 if (flexcan0_en || flexcan1_en)
147 gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 1);
148 else
149 gpio_set_value(MX28EVK_FLEXCAN_SWITCH, 0);
150}
151
152static void mx28evk_flexcan0_switch(int enable)
153{
154 flexcan0_en = enable;
155 mx28evk_flexcan_switch();
156}
157
158static void mx28evk_flexcan1_switch(int enable)
159{
160 flexcan1_en = enable;
161 mx28evk_flexcan_switch();
162}
163
164static struct flexcan_platform_data flexcan_pdata[2];
165
Shawn Guoab2815c2012-06-25 21:21:46 +0800166static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = {
167 OF_DEV_AUXDATA("fsl,imx23-lcdif", 0x80030000, NULL, &mxsfb_pdata),
168 OF_DEV_AUXDATA("fsl,imx28-lcdif", 0x80030000, NULL, &mxsfb_pdata),
Shawn Guo44ffb782012-08-06 22:00:45 +0800169 OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80032000, NULL, &flexcan_pdata[0]),
170 OF_DEV_AUXDATA("fsl,imx28-flexcan", 0x80034000, NULL, &flexcan_pdata[1]),
Shawn Guoab2815c2012-06-25 21:21:46 +0800171 { /* sentinel */ }
172};
173
Shawn Guo1bff2d72013-03-29 13:27:55 +0800174#define OCOTP_WORD_OFFSET 0x20
175#define OCOTP_WORD_COUNT 0x20
176
177#define BM_OCOTP_CTRL_BUSY (1 << 8)
178#define BM_OCOTP_CTRL_ERROR (1 << 9)
179#define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12)
180
181static DEFINE_MUTEX(ocotp_mutex);
182static u32 ocotp_words[OCOTP_WORD_COUNT];
183
184static const u32 *mxs_get_ocotp(void)
185{
186 struct device_node *np;
187 void __iomem *ocotp_base;
188 int timeout = 0x400;
189 size_t i;
190 static int once;
191
192 if (once)
193 return ocotp_words;
194
195 np = of_find_compatible_node(NULL, NULL, "fsl,ocotp");
196 ocotp_base = of_iomap(np, 0);
197 WARN_ON(!ocotp_base);
198
199 mutex_lock(&ocotp_mutex);
200
201 /*
202 * clk_enable(hbus_clk) for ocotp can be skipped
203 * as it must be on when system is running.
204 */
205
206 /* try to clear ERROR bit */
207 __mxs_clrl(BM_OCOTP_CTRL_ERROR, ocotp_base);
208
209 /* check both BUSY and ERROR cleared */
210 while ((__raw_readl(ocotp_base) &
211 (BM_OCOTP_CTRL_BUSY | BM_OCOTP_CTRL_ERROR)) && --timeout)
212 cpu_relax();
213
214 if (unlikely(!timeout))
215 goto error_unlock;
216
217 /* open OCOTP banks for read */
218 __mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
219
220 /* approximately wait 32 hclk cycles */
221 udelay(1);
222
223 /* poll BUSY bit becoming cleared */
224 timeout = 0x400;
225 while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout)
226 cpu_relax();
227
228 if (unlikely(!timeout))
229 goto error_unlock;
230
231 for (i = 0; i < OCOTP_WORD_COUNT; i++)
232 ocotp_words[i] = __raw_readl(ocotp_base + OCOTP_WORD_OFFSET +
233 i * 0x10);
234
235 /* close banks for power saving */
236 __mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
237
238 once = 1;
239
240 mutex_unlock(&ocotp_mutex);
241
242 return ocotp_words;
243
244error_unlock:
245 mutex_unlock(&ocotp_mutex);
246 pr_err("%s: timeout in reading OCOTP\n", __func__);
247 return NULL;
248}
249
Shawn Guo5653acc2012-06-19 22:38:14 +0800250enum mac_oui {
251 OUI_FSL,
252 OUI_DENX,
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800253 OUI_CRYSTALFONTZ,
Shawn Guo5653acc2012-06-19 22:38:14 +0800254};
255
256static void __init update_fec_mac_prop(enum mac_oui oui)
257{
258 struct device_node *np, *from = NULL;
Shawn Guofa7c8652012-07-13 14:13:55 +0800259 struct property *newmac;
Shawn Guo5653acc2012-06-19 22:38:14 +0800260 const u32 *ocotp = mxs_get_ocotp();
261 u8 *macaddr;
262 u32 val;
263 int i;
264
265 for (i = 0; i < 2; i++) {
266 np = of_find_compatible_node(from, NULL, "fsl,imx28-fec");
267 if (!np)
268 return;
Marek Vasut16d47702012-09-25 13:32:18 +0200269
Shawn Guo5653acc2012-06-19 22:38:14 +0800270 from = np;
271
Marek Vasut16d47702012-09-25 13:32:18 +0200272 if (of_get_property(np, "local-mac-address", NULL))
273 continue;
274
Shawn Guo5653acc2012-06-19 22:38:14 +0800275 newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
276 if (!newmac)
277 return;
278 newmac->value = newmac + 1;
279 newmac->length = 6;
280
281 newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
282 if (!newmac->name) {
283 kfree(newmac);
284 return;
285 }
286
287 /*
288 * OCOTP only stores the last 4 octets for each mac address,
289 * so hard-code OUI here.
290 */
291 macaddr = newmac->value;
292 switch (oui) {
293 case OUI_FSL:
294 macaddr[0] = 0x00;
295 macaddr[1] = 0x04;
296 macaddr[2] = 0x9f;
297 break;
298 case OUI_DENX:
299 macaddr[0] = 0xc0;
300 macaddr[1] = 0xe5;
301 macaddr[2] = 0x4e;
302 break;
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800303 case OUI_CRYSTALFONTZ:
304 macaddr[0] = 0x58;
305 macaddr[1] = 0xb9;
306 macaddr[2] = 0xe1;
307 break;
Shawn Guo5653acc2012-06-19 22:38:14 +0800308 }
309 val = ocotp[i];
310 macaddr[3] = (val >> 16) & 0xff;
311 macaddr[4] = (val >> 8) & 0xff;
312 macaddr[5] = (val >> 0) & 0xff;
313
Nathan Fontenot79d1c712012-10-02 16:58:46 +0000314 of_update_property(np, newmac);
Shawn Guo5653acc2012-06-19 22:38:14 +0800315 }
316}
317
Shawn Guoab2815c2012-06-25 21:21:46 +0800318static void __init imx23_evk_init(void)
319{
320 mxsfb_pdata.mode_list = mx23evk_video_modes;
321 mxsfb_pdata.mode_count = ARRAY_SIZE(mx23evk_video_modes);
322 mxsfb_pdata.default_bpp = 32;
323 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
Marek Vasut6a150752013-03-18 19:24:02 +0100324 mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT |
325 MXSFB_SYNC_DOTCLK_FAILING_ACT;
Shawn Guoab2815c2012-06-25 21:21:46 +0800326}
327
Marek Vasut8fa62e12012-07-07 21:21:38 +0800328static inline void enable_clk_enet_out(void)
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800329{
Marek Vasut8fa62e12012-07-07 21:21:38 +0800330 struct clk *clk = clk_get_sys("enet_out", NULL);
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800331
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800332 if (!IS_ERR(clk))
333 clk_prepare_enable(clk);
Marek Vasut8fa62e12012-07-07 21:21:38 +0800334}
Shawn Guo5653acc2012-06-19 22:38:14 +0800335
Marek Vasut8fa62e12012-07-07 21:21:38 +0800336static void __init imx28_evk_init(void)
337{
338 enable_clk_enet_out();
Shawn Guo5653acc2012-06-19 22:38:14 +0800339 update_fec_mac_prop(OUI_FSL);
Shawn Guoab2815c2012-06-25 21:21:46 +0800340
341 mxsfb_pdata.mode_list = mx28evk_video_modes;
342 mxsfb_pdata.mode_count = ARRAY_SIZE(mx28evk_video_modes);
343 mxsfb_pdata.default_bpp = 32;
344 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
Marek Vasut6a150752013-03-18 19:24:02 +0100345 mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT |
346 MXSFB_SYNC_DOTCLK_FAILING_ACT;
Dong Aishenge3173172012-08-01 11:20:16 +0800347
348 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800349}
350
Shawn Guo44ffb782012-08-06 22:00:45 +0800351static void __init imx28_evk_post_init(void)
352{
353 if (!gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT,
354 "flexcan-switch")) {
355 flexcan_pdata[0].transceiver_switch = mx28evk_flexcan0_switch;
356 flexcan_pdata[1].transceiver_switch = mx28evk_flexcan1_switch;
357 }
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800358}
359
Marek Vasut8fa62e12012-07-07 21:21:38 +0800360static void __init m28evk_init(void)
361{
Marek Vasut8fa62e12012-07-07 21:21:38 +0800362 mxsfb_pdata.mode_list = m28evk_video_modes;
363 mxsfb_pdata.mode_count = ARRAY_SIZE(m28evk_video_modes);
364 mxsfb_pdata.default_bpp = 16;
365 mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT;
Marek Vasut6a150752013-03-18 19:24:02 +0100366 mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT;
Marek Vasut8fa62e12012-07-07 21:21:38 +0800367}
368
Marek Vasut160d5f22012-11-18 22:08:29 +0100369static void __init sc_sps1_init(void)
370{
371 enable_clk_enet_out();
372}
373
Shawn Guo3143bbb2012-07-07 23:12:03 +0800374static int apx4devkit_phy_fixup(struct phy_device *phy)
375{
376 phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
377 return 0;
378}
379
380static void __init apx4devkit_init(void)
381{
382 enable_clk_enet_out();
383
384 if (IS_BUILTIN(CONFIG_PHYLIB))
Marek Vasut510d5732012-09-23 16:58:50 +0000385 phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
Shawn Guo3143bbb2012-07-07 23:12:03 +0800386 apx4devkit_phy_fixup);
Lauri Hintsalad8bb8232012-07-10 10:08:08 +0300387
388 mxsfb_pdata.mode_list = apx4devkit_video_modes;
389 mxsfb_pdata.mode_count = ARRAY_SIZE(apx4devkit_video_modes);
390 mxsfb_pdata.default_bpp = 32;
391 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
Marek Vasut6a150752013-03-18 19:24:02 +0100392 mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT |
393 MXSFB_SYNC_DOTCLK_FAILING_ACT;
Shawn Guo3143bbb2012-07-07 23:12:03 +0800394}
395
Shawn Guo2c7c2c12012-07-13 14:15:34 +0800396#define ENET0_MDC__GPIO_4_0 MXS_GPIO_NR(4, 0)
397#define ENET0_MDIO__GPIO_4_1 MXS_GPIO_NR(4, 1)
398#define ENET0_RX_EN__GPIO_4_2 MXS_GPIO_NR(4, 2)
399#define ENET0_RXD0__GPIO_4_3 MXS_GPIO_NR(4, 3)
400#define ENET0_RXD1__GPIO_4_4 MXS_GPIO_NR(4, 4)
401#define ENET0_TX_EN__GPIO_4_6 MXS_GPIO_NR(4, 6)
402#define ENET0_TXD0__GPIO_4_7 MXS_GPIO_NR(4, 7)
403#define ENET0_TXD1__GPIO_4_8 MXS_GPIO_NR(4, 8)
404#define ENET_CLK__GPIO_4_16 MXS_GPIO_NR(4, 16)
405
406#define TX28_FEC_PHY_POWER MXS_GPIO_NR(3, 29)
407#define TX28_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
408#define TX28_FEC_nINT MXS_GPIO_NR(4, 5)
409
410static const struct gpio tx28_gpios[] __initconst = {
411 { ENET0_MDC__GPIO_4_0, GPIOF_OUT_INIT_LOW, "GPIO_4_0" },
412 { ENET0_MDIO__GPIO_4_1, GPIOF_OUT_INIT_LOW, "GPIO_4_1" },
413 { ENET0_RX_EN__GPIO_4_2, GPIOF_OUT_INIT_LOW, "GPIO_4_2" },
414 { ENET0_RXD0__GPIO_4_3, GPIOF_OUT_INIT_LOW, "GPIO_4_3" },
415 { ENET0_RXD1__GPIO_4_4, GPIOF_OUT_INIT_LOW, "GPIO_4_4" },
416 { ENET0_TX_EN__GPIO_4_6, GPIOF_OUT_INIT_LOW, "GPIO_4_6" },
417 { ENET0_TXD0__GPIO_4_7, GPIOF_OUT_INIT_LOW, "GPIO_4_7" },
418 { ENET0_TXD1__GPIO_4_8, GPIOF_OUT_INIT_LOW, "GPIO_4_8" },
419 { ENET_CLK__GPIO_4_16, GPIOF_OUT_INIT_LOW, "GPIO_4_16" },
420 { TX28_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-phy-power" },
421 { TX28_FEC_PHY_RESET, GPIOF_OUT_INIT_LOW, "fec-phy-reset" },
422 { TX28_FEC_nINT, GPIOF_DIR_IN, "fec-int" },
423};
424
425static void __init tx28_post_init(void)
426{
427 struct device_node *np;
428 struct platform_device *pdev;
429 struct pinctrl *pctl;
430 int ret;
431
432 enable_clk_enet_out();
433
434 np = of_find_compatible_node(NULL, NULL, "fsl,imx28-fec");
435 pdev = of_find_device_by_node(np);
436 if (!pdev) {
437 pr_err("%s: failed to find fec device\n", __func__);
438 return;
439 }
440
441 pctl = pinctrl_get_select(&pdev->dev, "gpio_mode");
442 if (IS_ERR(pctl)) {
443 pr_err("%s: failed to get pinctrl state\n", __func__);
444 return;
445 }
446
447 ret = gpio_request_array(tx28_gpios, ARRAY_SIZE(tx28_gpios));
448 if (ret) {
449 pr_err("%s: failed to request gpios: %d\n", __func__, ret);
450 return;
451 }
452
453 /* Power up fec phy */
454 gpio_set_value(TX28_FEC_PHY_POWER, 1);
455 msleep(26); /* 25ms according to data sheet */
456
457 /* Mode strap pins */
458 gpio_set_value(ENET0_RX_EN__GPIO_4_2, 1);
459 gpio_set_value(ENET0_RXD0__GPIO_4_3, 1);
460 gpio_set_value(ENET0_RXD1__GPIO_4_4, 1);
461
462 udelay(100); /* minimum assertion time for nRST */
463
464 /* Deasserting FEC PHY RESET */
465 gpio_set_value(TX28_FEC_PHY_RESET, 1);
466
467 pinctrl_put(pctl);
468}
469
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800470static void __init cfa10049_init(void)
471{
472 enable_clk_enet_out();
473 update_fec_mac_prop(OUI_CRYSTALFONTZ);
Maxime Ripard4a38a852013-03-05 16:13:35 +0100474
475 mxsfb_pdata.mode_list = cfa10049_video_modes;
476 mxsfb_pdata.mode_count = ARRAY_SIZE(cfa10049_video_modes);
477 mxsfb_pdata.default_bpp = 32;
478 mxsfb_pdata.ld_intf_width = STMLCDIF_18BIT;
Marek Vasut6a150752013-03-18 19:24:02 +0100479 mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT;
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800480}
481
Maxime Riparde0f7d902013-01-26 13:40:37 +0800482static void __init cfa10037_init(void)
483{
484 enable_clk_enet_out();
485 update_fec_mac_prop(OUI_CRYSTALFONTZ);
486}
487
Julien Boibessota957fdc2012-10-18 11:50:26 +0200488static void __init apf28_init(void)
489{
490 enable_clk_enet_out();
Gwenhael Goavec-Meroua4dabca2012-11-02 19:01:48 +0100491
492 mxsfb_pdata.mode_list = apf28dev_video_modes;
493 mxsfb_pdata.mode_count = ARRAY_SIZE(apf28dev_video_modes);
494 mxsfb_pdata.default_bpp = 16;
495 mxsfb_pdata.ld_intf_width = STMLCDIF_16BIT;
Marek Vasut6a150752013-03-18 19:24:02 +0100496 mxsfb_pdata.sync = MXSFB_SYNC_DATA_ENABLE_HIGH_ACT |
497 MXSFB_SYNC_DOTCLK_FAILING_ACT;
Julien Boibessota957fdc2012-10-18 11:50:26 +0200498}
499
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800500static void __init mxs_machine_init(void)
501{
502 if (of_machine_is_compatible("fsl,imx28-evk"))
503 imx28_evk_init();
Shawn Guoab2815c2012-06-25 21:21:46 +0800504 else if (of_machine_is_compatible("fsl,imx23-evk"))
505 imx23_evk_init();
Marek Vasut8fa62e12012-07-07 21:21:38 +0800506 else if (of_machine_is_compatible("denx,m28evk"))
507 m28evk_init();
Shawn Guo3143bbb2012-07-07 23:12:03 +0800508 else if (of_machine_is_compatible("bluegiga,apx4devkit"))
509 apx4devkit_init();
Maxime Riparde0f7d902013-01-26 13:40:37 +0800510 else if (of_machine_is_compatible("crystalfontz,cfa10037"))
511 cfa10037_init();
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800512 else if (of_machine_is_compatible("crystalfontz,cfa10049"))
513 cfa10049_init();
Julien Boibessota957fdc2012-10-18 11:50:26 +0200514 else if (of_machine_is_compatible("armadeus,imx28-apf28"))
515 apf28_init();
Marek Vasut160d5f22012-11-18 22:08:29 +0100516 else if (of_machine_is_compatible("schulercontrol,imx28-sps1"))
517 sc_sps1_init();
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800518
519 of_platform_populate(NULL, of_default_bus_match_table,
Shawn Guoab2815c2012-06-25 21:21:46 +0800520 mxs_auxdata_lookup, NULL);
Shawn Guo2c7c2c12012-07-13 14:15:34 +0800521
522 if (of_machine_is_compatible("karo,tx28"))
523 tx28_post_init();
Shawn Guo44ffb782012-08-06 22:00:45 +0800524
525 if (of_machine_is_compatible("fsl,imx28-evk"))
526 imx28_evk_post_init();
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800527}
528
Shawn Guo974a9af2013-03-29 09:45:31 +0800529#define MX23_CLKCTRL_RESET_OFFSET 0x120
530#define MX28_CLKCTRL_RESET_OFFSET 0x1e0
531#define MXS_CLKCTRL_RESET_CHIP (1 << 1)
532
533/*
534 * Reset the system. It is called by machine_restart().
535 */
536static void mxs_restart(char mode, const char *cmd)
537{
538 struct device_node *np;
539 void __iomem *reset_addr;
540
541 np = of_find_compatible_node(NULL, NULL, "fsl,clkctrl");
542 reset_addr = of_iomap(np, 0);
543 if (!reset_addr)
544 goto soft;
545
546 if (of_device_is_compatible(np, "fsl,imx23-clkctrl"))
547 reset_addr += MX23_CLKCTRL_RESET_OFFSET;
548 else
549 reset_addr += MX28_CLKCTRL_RESET_OFFSET;
550
551 /* reset the chip */
552 __mxs_setl(MXS_CLKCTRL_RESET_CHIP, reset_addr);
553
554 pr_err("Failed to assert the chip reset\n");
555
556 /* Delay to allow the serial port to show the message */
557 mdelay(50);
558
559soft:
560 /* We'll take a jump through zero as a poor second */
561 soft_restart(0);
562}
563
Shawn Guo39490ab2013-03-29 14:04:07 +0800564static void __init mxs_timer_init(void)
565{
566 if (of_machine_is_compatible("fsl,imx23"))
567 mx23_clocks_init();
568 else
569 mx28_clocks_init();
570 clocksource_of_init();
571}
572
573static const char *mxs_dt_compat[] __initdata = {
574 "fsl,imx28",
Shawn Guo2954ff32012-05-04 21:33:42 +0800575 "fsl,imx23",
576 NULL,
577};
578
Shawn Guo39490ab2013-03-29 14:04:07 +0800579DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
Shawn Guo1f629562013-03-29 13:07:34 +0800580 .map_io = debug_ll_io_init,
Shawn Guo6a8e95b2013-03-25 21:34:51 +0800581 .init_irq = irqchip_init,
Shawn Guo4e0a1b82012-08-20 10:14:56 +0800582 .handle_irq = icoll_handle_irq,
Shawn Guo39490ab2013-03-29 14:04:07 +0800583 .init_time = mxs_timer_init,
Shawn Guo2954ff32012-05-04 21:33:42 +0800584 .init_machine = mxs_machine_init,
Shawn Guo39490ab2013-03-29 14:04:07 +0800585 .dt_compat = mxs_dt_compat,
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800586 .restart = mxs_restart,
587MACHINE_END