blob: b5a2c4a68e346d7487eef1bbefa56e568f1a0e17 [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>
Lothar Waßmann5cd86ef2013-07-31 16:07:59 +020017#include <linux/clk-provider.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/mxs.h>
Robin Holt7b6d8642013-07-08 16:01:40 -070023#include <linux/reboot.h>
Shawn Guo3143bbb2012-07-07 23:12:03 +080024#include <linux/micrel_phy.h>
Shawn Guo974a9af2013-03-29 09:45:31 +080025#include <linux/of_address.h>
Dong Aishengbc3a59c2012-03-31 21:26:57 +080026#include <linux/of_platform.h>
Shawn Guo3143bbb2012-07-07 23:12:03 +080027#include <linux/phy.h>
Shawn Guo2c7c2c12012-07-13 14:15:34 +080028#include <linux/pinctrl/consumer.h>
Fabio Estevam20463382013-06-04 10:18:45 -030029#include <linux/sys_soc.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>
Shawn Guo0b48d3a2013-03-29 13:53:11 +080034
Shawn Guo45680992013-03-29 14:41:27 +080035#include "pm.h"
36
Shawn Guo0b48d3a2013-03-29 13:53:11 +080037/* MXS DIGCTL SAIF CLKMUX */
38#define MXS_DIGCTL_SAIF_CLKMUX_DIRECT 0x0
39#define MXS_DIGCTL_SAIF_CLKMUX_CROSSINPUT 0x1
40#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0 0x2
41#define MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR1 0x3
42
Fabio Estevam20463382013-06-04 10:18:45 -030043#define HW_DIGCTL_CHIPID 0x310
44#define HW_DIGCTL_CHIPID_MASK (0xffff << 16)
45#define HW_DIGCTL_REV_MASK 0xff
46#define HW_DIGCTL_CHIPID_MX23 (0x3780 << 16)
47#define HW_DIGCTL_CHIPID_MX28 (0x2800 << 16)
48
49#define MXS_CHIP_REVISION_1_0 0x10
50#define MXS_CHIP_REVISION_1_1 0x11
51#define MXS_CHIP_REVISION_1_2 0x12
52#define MXS_CHIP_REVISION_1_3 0x13
53#define MXS_CHIP_REVISION_1_4 0x14
54#define MXS_CHIP_REV_UNKNOWN 0xff
55
Shawn Guo0b48d3a2013-03-29 13:53:11 +080056#define MXS_GPIO_NR(bank, nr) ((bank) * 32 + (nr))
57
58#define MXS_SET_ADDR 0x4
59#define MXS_CLR_ADDR 0x8
60#define MXS_TOG_ADDR 0xc
61
Fabio Estevam20463382013-06-04 10:18:45 -030062static u32 chipid;
63static u32 socid;
64
Lothar Waßmann56b7eec2013-08-05 10:51:14 +020065static void __iomem *reset_addr;
66
Shawn Guo0b48d3a2013-03-29 13:53:11 +080067static inline void __mxs_setl(u32 mask, void __iomem *reg)
68{
69 __raw_writel(mask, reg + MXS_SET_ADDR);
70}
71
72static inline void __mxs_clrl(u32 mask, void __iomem *reg)
73{
74 __raw_writel(mask, reg + MXS_CLR_ADDR);
75}
76
77static inline void __mxs_togl(u32 mask, void __iomem *reg)
78{
79 __raw_writel(mask, reg + MXS_TOG_ADDR);
80}
Dong Aishengbc3a59c2012-03-31 21:26:57 +080081
Shawn Guo1bff2d72013-03-29 13:27:55 +080082#define OCOTP_WORD_OFFSET 0x20
83#define OCOTP_WORD_COUNT 0x20
84
85#define BM_OCOTP_CTRL_BUSY (1 << 8)
86#define BM_OCOTP_CTRL_ERROR (1 << 9)
87#define BM_OCOTP_CTRL_RD_BANK_OPEN (1 << 12)
88
89static DEFINE_MUTEX(ocotp_mutex);
90static u32 ocotp_words[OCOTP_WORD_COUNT];
91
92static const u32 *mxs_get_ocotp(void)
93{
94 struct device_node *np;
95 void __iomem *ocotp_base;
96 int timeout = 0x400;
97 size_t i;
98 static int once;
99
100 if (once)
101 return ocotp_words;
102
103 np = of_find_compatible_node(NULL, NULL, "fsl,ocotp");
104 ocotp_base = of_iomap(np, 0);
105 WARN_ON(!ocotp_base);
106
107 mutex_lock(&ocotp_mutex);
108
109 /*
110 * clk_enable(hbus_clk) for ocotp can be skipped
111 * as it must be on when system is running.
112 */
113
114 /* try to clear ERROR bit */
115 __mxs_clrl(BM_OCOTP_CTRL_ERROR, ocotp_base);
116
117 /* check both BUSY and ERROR cleared */
118 while ((__raw_readl(ocotp_base) &
119 (BM_OCOTP_CTRL_BUSY | BM_OCOTP_CTRL_ERROR)) && --timeout)
120 cpu_relax();
121
122 if (unlikely(!timeout))
123 goto error_unlock;
124
125 /* open OCOTP banks for read */
126 __mxs_setl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
127
128 /* approximately wait 32 hclk cycles */
129 udelay(1);
130
131 /* poll BUSY bit becoming cleared */
132 timeout = 0x400;
133 while ((__raw_readl(ocotp_base) & BM_OCOTP_CTRL_BUSY) && --timeout)
134 cpu_relax();
135
136 if (unlikely(!timeout))
137 goto error_unlock;
138
139 for (i = 0; i < OCOTP_WORD_COUNT; i++)
140 ocotp_words[i] = __raw_readl(ocotp_base + OCOTP_WORD_OFFSET +
141 i * 0x10);
142
143 /* close banks for power saving */
144 __mxs_clrl(BM_OCOTP_CTRL_RD_BANK_OPEN, ocotp_base);
145
146 once = 1;
147
148 mutex_unlock(&ocotp_mutex);
149
150 return ocotp_words;
151
152error_unlock:
153 mutex_unlock(&ocotp_mutex);
154 pr_err("%s: timeout in reading OCOTP\n", __func__);
155 return NULL;
156}
157
Shawn Guo5653acc2012-06-19 22:38:14 +0800158enum mac_oui {
159 OUI_FSL,
160 OUI_DENX,
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800161 OUI_CRYSTALFONTZ,
Shawn Guo5653acc2012-06-19 22:38:14 +0800162};
163
164static void __init update_fec_mac_prop(enum mac_oui oui)
165{
166 struct device_node *np, *from = NULL;
Shawn Guofa7c8652012-07-13 14:13:55 +0800167 struct property *newmac;
Shawn Guo5653acc2012-06-19 22:38:14 +0800168 const u32 *ocotp = mxs_get_ocotp();
169 u8 *macaddr;
170 u32 val;
171 int i;
172
173 for (i = 0; i < 2; i++) {
174 np = of_find_compatible_node(from, NULL, "fsl,imx28-fec");
175 if (!np)
176 return;
Marek Vasut16d47702012-09-25 13:32:18 +0200177
Shawn Guo5653acc2012-06-19 22:38:14 +0800178 from = np;
179
Marek Vasut16d47702012-09-25 13:32:18 +0200180 if (of_get_property(np, "local-mac-address", NULL))
181 continue;
182
Shawn Guo5653acc2012-06-19 22:38:14 +0800183 newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
184 if (!newmac)
185 return;
186 newmac->value = newmac + 1;
187 newmac->length = 6;
188
189 newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
190 if (!newmac->name) {
191 kfree(newmac);
192 return;
193 }
194
195 /*
196 * OCOTP only stores the last 4 octets for each mac address,
197 * so hard-code OUI here.
198 */
199 macaddr = newmac->value;
200 switch (oui) {
201 case OUI_FSL:
202 macaddr[0] = 0x00;
203 macaddr[1] = 0x04;
204 macaddr[2] = 0x9f;
205 break;
206 case OUI_DENX:
207 macaddr[0] = 0xc0;
208 macaddr[1] = 0xe5;
209 macaddr[2] = 0x4e;
210 break;
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800211 case OUI_CRYSTALFONTZ:
212 macaddr[0] = 0x58;
213 macaddr[1] = 0xb9;
214 macaddr[2] = 0xe1;
215 break;
Shawn Guo5653acc2012-06-19 22:38:14 +0800216 }
217 val = ocotp[i];
218 macaddr[3] = (val >> 16) & 0xff;
219 macaddr[4] = (val >> 8) & 0xff;
220 macaddr[5] = (val >> 0) & 0xff;
221
Nathan Fontenot79d1c712012-10-02 16:58:46 +0000222 of_update_property(np, newmac);
Shawn Guo5653acc2012-06-19 22:38:14 +0800223 }
224}
225
Marek Vasut8fa62e12012-07-07 21:21:38 +0800226static inline void enable_clk_enet_out(void)
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800227{
Marek Vasut8fa62e12012-07-07 21:21:38 +0800228 struct clk *clk = clk_get_sys("enet_out", NULL);
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800229
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800230 if (!IS_ERR(clk))
231 clk_prepare_enable(clk);
Marek Vasut8fa62e12012-07-07 21:21:38 +0800232}
Shawn Guo5653acc2012-06-19 22:38:14 +0800233
Marek Vasut8fa62e12012-07-07 21:21:38 +0800234static void __init imx28_evk_init(void)
235{
Shawn Guo5653acc2012-06-19 22:38:14 +0800236 update_fec_mac_prop(OUI_FSL);
Shawn Guoab2815c2012-06-25 21:21:46 +0800237
Dong Aishenge3173172012-08-01 11:20:16 +0800238 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800239}
240
Shawn Guo3143bbb2012-07-07 23:12:03 +0800241static int apx4devkit_phy_fixup(struct phy_device *phy)
242{
243 phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
244 return 0;
245}
246
247static void __init apx4devkit_init(void)
248{
249 enable_clk_enet_out();
250
251 if (IS_BUILTIN(CONFIG_PHYLIB))
Marek Vasut510d5732012-09-23 16:58:50 +0000252 phy_register_fixup_for_uid(PHY_ID_KSZ8051, MICREL_PHY_ID_MASK,
Shawn Guo3143bbb2012-07-07 23:12:03 +0800253 apx4devkit_phy_fixup);
254}
255
Shawn Guo2c7c2c12012-07-13 14:15:34 +0800256#define ENET0_MDC__GPIO_4_0 MXS_GPIO_NR(4, 0)
257#define ENET0_MDIO__GPIO_4_1 MXS_GPIO_NR(4, 1)
258#define ENET0_RX_EN__GPIO_4_2 MXS_GPIO_NR(4, 2)
259#define ENET0_RXD0__GPIO_4_3 MXS_GPIO_NR(4, 3)
260#define ENET0_RXD1__GPIO_4_4 MXS_GPIO_NR(4, 4)
261#define ENET0_TX_EN__GPIO_4_6 MXS_GPIO_NR(4, 6)
262#define ENET0_TXD0__GPIO_4_7 MXS_GPIO_NR(4, 7)
263#define ENET0_TXD1__GPIO_4_8 MXS_GPIO_NR(4, 8)
264#define ENET_CLK__GPIO_4_16 MXS_GPIO_NR(4, 16)
265
266#define TX28_FEC_PHY_POWER MXS_GPIO_NR(3, 29)
267#define TX28_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
268#define TX28_FEC_nINT MXS_GPIO_NR(4, 5)
269
270static const struct gpio tx28_gpios[] __initconst = {
271 { ENET0_MDC__GPIO_4_0, GPIOF_OUT_INIT_LOW, "GPIO_4_0" },
272 { ENET0_MDIO__GPIO_4_1, GPIOF_OUT_INIT_LOW, "GPIO_4_1" },
273 { ENET0_RX_EN__GPIO_4_2, GPIOF_OUT_INIT_LOW, "GPIO_4_2" },
274 { ENET0_RXD0__GPIO_4_3, GPIOF_OUT_INIT_LOW, "GPIO_4_3" },
275 { ENET0_RXD1__GPIO_4_4, GPIOF_OUT_INIT_LOW, "GPIO_4_4" },
276 { ENET0_TX_EN__GPIO_4_6, GPIOF_OUT_INIT_LOW, "GPIO_4_6" },
277 { ENET0_TXD0__GPIO_4_7, GPIOF_OUT_INIT_LOW, "GPIO_4_7" },
278 { ENET0_TXD1__GPIO_4_8, GPIOF_OUT_INIT_LOW, "GPIO_4_8" },
279 { ENET_CLK__GPIO_4_16, GPIOF_OUT_INIT_LOW, "GPIO_4_16" },
280 { TX28_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-phy-power" },
281 { TX28_FEC_PHY_RESET, GPIOF_OUT_INIT_LOW, "fec-phy-reset" },
282 { TX28_FEC_nINT, GPIOF_DIR_IN, "fec-int" },
283};
284
285static void __init tx28_post_init(void)
286{
287 struct device_node *np;
288 struct platform_device *pdev;
289 struct pinctrl *pctl;
290 int ret;
291
292 enable_clk_enet_out();
293
294 np = of_find_compatible_node(NULL, NULL, "fsl,imx28-fec");
295 pdev = of_find_device_by_node(np);
296 if (!pdev) {
297 pr_err("%s: failed to find fec device\n", __func__);
298 return;
299 }
300
301 pctl = pinctrl_get_select(&pdev->dev, "gpio_mode");
302 if (IS_ERR(pctl)) {
303 pr_err("%s: failed to get pinctrl state\n", __func__);
304 return;
305 }
306
307 ret = gpio_request_array(tx28_gpios, ARRAY_SIZE(tx28_gpios));
308 if (ret) {
309 pr_err("%s: failed to request gpios: %d\n", __func__, ret);
310 return;
311 }
312
313 /* Power up fec phy */
314 gpio_set_value(TX28_FEC_PHY_POWER, 1);
315 msleep(26); /* 25ms according to data sheet */
316
317 /* Mode strap pins */
318 gpio_set_value(ENET0_RX_EN__GPIO_4_2, 1);
319 gpio_set_value(ENET0_RXD0__GPIO_4_3, 1);
320 gpio_set_value(ENET0_RXD1__GPIO_4_4, 1);
321
322 udelay(100); /* minimum assertion time for nRST */
323
324 /* Deasserting FEC PHY RESET */
325 gpio_set_value(TX28_FEC_PHY_RESET, 1);
326
327 pinctrl_put(pctl);
328}
329
Brian Lillyed138c32013-06-13 15:43:44 +0200330static void __init crystalfontz_init(void)
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800331{
Maxime Ripard8eec4b32012-10-07 10:36:28 +0800332 update_fec_mac_prop(OUI_CRYSTALFONTZ);
333}
334
Fabio Estevam20463382013-06-04 10:18:45 -0300335static const char __init *mxs_get_soc_id(void)
Maxime Riparde0f7d902013-01-26 13:40:37 +0800336{
Fabio Estevam20463382013-06-04 10:18:45 -0300337 struct device_node *np;
338 void __iomem *digctl_base;
339
340 np = of_find_compatible_node(NULL, NULL, "fsl,imx23-digctl");
341 digctl_base = of_iomap(np, 0);
342 WARN_ON(!digctl_base);
343
344 chipid = readl(digctl_base + HW_DIGCTL_CHIPID);
345 socid = chipid & HW_DIGCTL_CHIPID_MASK;
346
347 iounmap(digctl_base);
348 of_node_put(np);
349
350 switch (socid) {
351 case HW_DIGCTL_CHIPID_MX23:
352 return "i.MX23";
353 case HW_DIGCTL_CHIPID_MX28:
354 return "i.MX28";
355 default:
356 return "Unknown";
357 }
358}
359
360static u32 __init mxs_get_cpu_rev(void)
361{
362 u32 rev = chipid & HW_DIGCTL_REV_MASK;
363
364 switch (socid) {
365 case HW_DIGCTL_CHIPID_MX23:
366 switch (rev) {
367 case 0x0:
368 return MXS_CHIP_REVISION_1_0;
369 case 0x1:
370 return MXS_CHIP_REVISION_1_1;
371 case 0x2:
372 return MXS_CHIP_REVISION_1_2;
373 case 0x3:
374 return MXS_CHIP_REVISION_1_3;
375 case 0x4:
376 return MXS_CHIP_REVISION_1_4;
377 default:
378 return MXS_CHIP_REV_UNKNOWN;
379 }
380 case HW_DIGCTL_CHIPID_MX28:
381 switch (rev) {
382 case 0x0:
383 return MXS_CHIP_REVISION_1_1;
384 case 0x1:
385 return MXS_CHIP_REVISION_1_2;
386 default:
387 return MXS_CHIP_REV_UNKNOWN;
388 }
389 default:
390 return MXS_CHIP_REV_UNKNOWN;
391 }
392}
393
394static const char __init *mxs_get_revision(void)
395{
396 u32 rev = mxs_get_cpu_rev();
397
398 if (rev != MXS_CHIP_REV_UNKNOWN)
399 return kasprintf(GFP_KERNEL, "TO%d.%d", (rev >> 4) & 0xf,
400 rev & 0xf);
401 else
402 return kasprintf(GFP_KERNEL, "%s", "Unknown");
Maxime Riparde0f7d902013-01-26 13:40:37 +0800403}
404
Lothar Waßmann56b7eec2013-08-05 10:51:14 +0200405#define MX23_CLKCTRL_RESET_OFFSET 0x120
406#define MX28_CLKCTRL_RESET_OFFSET 0x1e0
407
408static int __init mxs_restart_init(void)
409{
410 struct device_node *np;
411
412 np = of_find_compatible_node(NULL, NULL, "fsl,clkctrl");
413 reset_addr = of_iomap(np, 0);
414 if (!reset_addr)
415 return -ENODEV;
416
417 if (of_device_is_compatible(np, "fsl,imx23-clkctrl"))
418 reset_addr += MX23_CLKCTRL_RESET_OFFSET;
419 else
420 reset_addr += MX28_CLKCTRL_RESET_OFFSET;
421 of_node_put(np);
422
423 return 0;
424}
425
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800426static void __init mxs_machine_init(void)
427{
Fabio Estevam20463382013-06-04 10:18:45 -0300428 struct device_node *root;
429 struct device *parent;
430 struct soc_device *soc_dev;
431 struct soc_device_attribute *soc_dev_attr;
432 int ret;
433
434 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
435 if (!soc_dev_attr)
436 return;
437
438 root = of_find_node_by_path("/");
439 ret = of_property_read_string(root, "model", &soc_dev_attr->machine);
440 if (ret)
441 return;
442
443 soc_dev_attr->family = "Freescale MXS Family";
444 soc_dev_attr->soc_id = mxs_get_soc_id();
445 soc_dev_attr->revision = mxs_get_revision();
446
447 soc_dev = soc_device_register(soc_dev_attr);
448 if (IS_ERR(soc_dev)) {
449 kfree(soc_dev_attr->revision);
450 kfree(soc_dev_attr);
451 return;
452 }
453
454 parent = soc_device_to_device(soc_dev);
455
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800456 if (of_machine_is_compatible("fsl,imx28-evk"))
457 imx28_evk_init();
Shawn Guo3143bbb2012-07-07 23:12:03 +0800458 else if (of_machine_is_compatible("bluegiga,apx4devkit"))
459 apx4devkit_init();
Brian Lillyed138c32013-06-13 15:43:44 +0200460 else if (of_machine_is_compatible("crystalfontz,cfa10037") ||
461 of_machine_is_compatible("crystalfontz,cfa10049") ||
Brian Lillyd75f3d92013-06-13 15:43:45 +0200462 of_machine_is_compatible("crystalfontz,cfa10055") ||
463 of_machine_is_compatible("crystalfontz,cfa10057"))
Brian Lillyed138c32013-06-13 15:43:44 +0200464 crystalfontz_init();
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800465
466 of_platform_populate(NULL, of_default_bus_match_table,
Linus Torvalds496322b2013-07-09 18:24:39 -0700467 NULL, parent);
Shawn Guo2c7c2c12012-07-13 14:15:34 +0800468
Lothar Waßmann56b7eec2013-08-05 10:51:14 +0200469 mxs_restart_init();
470
Shawn Guo2c7c2c12012-07-13 14:15:34 +0800471 if (of_machine_is_compatible("karo,tx28"))
472 tx28_post_init();
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800473}
474
Shawn Guo974a9af2013-03-29 09:45:31 +0800475#define MXS_CLKCTRL_RESET_CHIP (1 << 1)
476
477/*
478 * Reset the system. It is called by machine_restart().
479 */
Robin Holt7b6d8642013-07-08 16:01:40 -0700480static void mxs_restart(enum reboot_mode mode, const char *cmd)
Shawn Guo974a9af2013-03-29 09:45:31 +0800481{
Lothar Waßmann56b7eec2013-08-05 10:51:14 +0200482 if (reset_addr) {
483 /* reset the chip */
484 __mxs_setl(MXS_CLKCTRL_RESET_CHIP, reset_addr);
Shawn Guo974a9af2013-03-29 09:45:31 +0800485
Lothar Waßmann56b7eec2013-08-05 10:51:14 +0200486 pr_err("Failed to assert the chip reset\n");
Shawn Guo974a9af2013-03-29 09:45:31 +0800487
Lothar Waßmann56b7eec2013-08-05 10:51:14 +0200488 /* Delay to allow the serial port to show the message */
489 mdelay(50);
490 }
Shawn Guo974a9af2013-03-29 09:45:31 +0800491
Shawn Guo974a9af2013-03-29 09:45:31 +0800492 /* We'll take a jump through zero as a poor second */
493 soft_restart(0);
494}
495
Shawn Guo39490ab2013-03-29 14:04:07 +0800496static void __init mxs_timer_init(void)
497{
498 if (of_machine_is_compatible("fsl,imx23"))
499 mx23_clocks_init();
500 else
501 mx28_clocks_init();
Lothar Waßmann5cd86ef2013-07-31 16:07:59 +0200502 of_clk_init(NULL);
Shawn Guo39490ab2013-03-29 14:04:07 +0800503 clocksource_of_init();
504}
505
506static const char *mxs_dt_compat[] __initdata = {
507 "fsl,imx28",
Shawn Guo2954ff32012-05-04 21:33:42 +0800508 "fsl,imx23",
509 NULL,
510};
511
Shawn Guo39490ab2013-03-29 14:04:07 +0800512DT_MACHINE_START(MXS, "Freescale MXS (Device Tree)")
Shawn Guo4e0a1b82012-08-20 10:14:56 +0800513 .handle_irq = icoll_handle_irq,
Shawn Guo39490ab2013-03-29 14:04:07 +0800514 .init_time = mxs_timer_init,
Shawn Guo2954ff32012-05-04 21:33:42 +0800515 .init_machine = mxs_machine_init,
Shawn Guo45680992013-03-29 14:41:27 +0800516 .init_late = mxs_pm_init,
Shawn Guo39490ab2013-03-29 14:04:07 +0800517 .dt_compat = mxs_dt_compat,
Dong Aishengbc3a59c2012-03-31 21:26:57 +0800518 .restart = mxs_restart,
519MACHINE_END