2 * Copyright 2012 Freescale Semiconductor, Inc.
3 * Copyright 2012 Linaro Ltd.
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:
9 * http://www.opensource.org/licenses/gpl-license.html
10 * http://www.gnu.org/copyleft/gpl.html
13 #include <linux/clk.h>
14 #include <linux/clkdev.h>
15 #include <linux/err.h>
16 #include <linux/init.h>
17 #include <linux/init.h>
18 #include <linux/irqdomain.h>
19 #include <linux/mxsfb.h>
20 #include <linux/of_irq.h>
21 #include <linux/of_platform.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/time.h>
24 #include <mach/common.h>
26 static struct fb_videomode mx23evk_video_modes[] = {
28 .name = "Samsung-LMS430HF02",
32 .pixclock = 108096, /* picosecond (9.2 MHz) */
39 .sync = FB_SYNC_DATA_ENABLE_HIGH_ACT |
40 FB_SYNC_DOTCLK_FAILING_ACT,
44 static struct fb_videomode mx28evk_video_modes[] = {
46 .name = "Seiko-43WVF1G",
50 .pixclock = 29851, /* picosecond (33.5 MHz) */
57 .sync = FB_SYNC_DATA_ENABLE_HIGH_ACT |
58 FB_SYNC_DOTCLK_FAILING_ACT,
62 static struct mxsfb_platform_data mxsfb_pdata __initdata;
64 static struct of_dev_auxdata mxs_auxdata_lookup[] __initdata = {
65 OF_DEV_AUXDATA("fsl,imx23-lcdif", 0x80030000, NULL, &mxsfb_pdata),
66 OF_DEV_AUXDATA("fsl,imx28-lcdif", 0x80030000, NULL, &mxsfb_pdata),
70 static int __init mxs_icoll_add_irq_domain(struct device_node *np,
71 struct device_node *interrupt_parent)
73 irq_domain_add_legacy(np, 128, 0, 0, &irq_domain_simple_ops, NULL);
78 static int __init mxs_gpio_add_irq_domain(struct device_node *np,
79 struct device_node *interrupt_parent)
81 static int gpio_irq_base = MXS_GPIO_IRQ_START;
83 irq_domain_add_legacy(np, 32, gpio_irq_base, 0, &irq_domain_simple_ops, NULL);
89 static const struct of_device_id mxs_irq_match[] __initconst = {
90 { .compatible = "fsl,mxs-icoll", .data = mxs_icoll_add_irq_domain, },
91 { .compatible = "fsl,mxs-gpio", .data = mxs_gpio_add_irq_domain, },
95 static void __init mxs_dt_init_irq(void)
98 of_irq_init(mxs_irq_match);
101 static void __init imx23_timer_init(void)
106 static struct sys_timer imx23_timer = {
107 .init = imx23_timer_init,
110 static void __init imx28_timer_init(void)
115 static struct sys_timer imx28_timer = {
116 .init = imx28_timer_init,
124 static void __init update_fec_mac_prop(enum mac_oui oui)
126 struct device_node *np, *from = NULL;
127 struct property *oldmac, *newmac;
128 const u32 *ocotp = mxs_get_ocotp();
133 for (i = 0; i < 2; i++) {
134 np = of_find_compatible_node(from, NULL, "fsl,imx28-fec");
139 newmac = kzalloc(sizeof(*newmac) + 6, GFP_KERNEL);
142 newmac->value = newmac + 1;
145 newmac->name = kstrdup("local-mac-address", GFP_KERNEL);
152 * OCOTP only stores the last 4 octets for each mac address,
153 * so hard-code OUI here.
155 macaddr = newmac->value;
169 macaddr[3] = (val >> 16) & 0xff;
170 macaddr[4] = (val >> 8) & 0xff;
171 macaddr[5] = (val >> 0) & 0xff;
173 oldmac = of_find_property(np, newmac->name, NULL);
175 prom_update_property(np, newmac, oldmac);
177 prom_add_property(np, newmac);
181 static void __init imx23_evk_init(void)
183 mxsfb_pdata.mode_list = mx23evk_video_modes;
184 mxsfb_pdata.mode_count = ARRAY_SIZE(mx23evk_video_modes);
185 mxsfb_pdata.default_bpp = 32;
186 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
189 static void __init imx28_evk_init(void)
193 /* Enable fec phy clock */
194 clk = clk_get_sys("enet_out", NULL);
196 clk_prepare_enable(clk);
198 update_fec_mac_prop(OUI_FSL);
200 mxsfb_pdata.mode_list = mx28evk_video_modes;
201 mxsfb_pdata.mode_count = ARRAY_SIZE(mx28evk_video_modes);
202 mxsfb_pdata.default_bpp = 32;
203 mxsfb_pdata.ld_intf_width = STMLCDIF_24BIT;
206 static void __init mxs_machine_init(void)
208 if (of_machine_is_compatible("fsl,imx28-evk"))
210 else if (of_machine_is_compatible("fsl,imx23-evk"))
213 of_platform_populate(NULL, of_default_bus_match_table,
214 mxs_auxdata_lookup, NULL);
217 static const char *imx23_dt_compat[] __initdata = {
219 "olimex,imx23-olinuxino",
224 static const char *imx28_dt_compat[] __initdata = {
225 "crystalfontz,cfa10036",
231 DT_MACHINE_START(IMX23, "Freescale i.MX23 (Device Tree)")
232 .map_io = mx23_map_io,
233 .init_irq = mxs_dt_init_irq,
234 .timer = &imx23_timer,
235 .init_machine = mxs_machine_init,
236 .dt_compat = imx23_dt_compat,
237 .restart = mxs_restart,
240 DT_MACHINE_START(IMX28, "Freescale i.MX28 (Device Tree)")
241 .map_io = mx28_map_io,
242 .init_irq = mxs_dt_init_irq,
243 .timer = &imx28_timer,
244 .init_machine = mxs_machine_init,
245 .dt_compat = imx28_dt_compat,
246 .restart = mxs_restart,