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/micrel_phy.h>
20 #include <linux/mxsfb.h>
21 #include <linux/of_irq.h>
22 #include <linux/of_platform.h>
23 #include <linux/phy.h>
24 #include <asm/mach/arch.h>
25 #include <asm/mach/time.h>
26 #include <mach/common.h>
28 static struct fb_videomode mx23evk_video_modes
[] = {
30 .name
= "Samsung-LMS430HF02",
34 .pixclock
= 108096, /* picosecond (9.2 MHz) */
41 .sync
= FB_SYNC_DATA_ENABLE_HIGH_ACT
|
42 FB_SYNC_DOTCLK_FAILING_ACT
,
46 static struct fb_videomode mx28evk_video_modes
[] = {
48 .name
= "Seiko-43WVF1G",
52 .pixclock
= 29851, /* picosecond (33.5 MHz) */
59 .sync
= FB_SYNC_DATA_ENABLE_HIGH_ACT
|
60 FB_SYNC_DOTCLK_FAILING_ACT
,
64 static struct fb_videomode m28evk_video_modes
[] = {
66 .name
= "Ampire AM-800480R2TMQW-T01H",
70 .pixclock
= 30066, /* picosecond (33.26 MHz) */
77 .sync
= FB_SYNC_DATA_ENABLE_HIGH_ACT
,
81 static struct fb_videomode apx4devkit_video_modes
[] = {
83 .name
= "HannStar PJ70112A",
87 .pixclock
= 33333, /* picosecond (30.00 MHz) */
94 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
|
95 FB_SYNC_DATA_ENABLE_HIGH_ACT
|
96 FB_SYNC_DOTCLK_FAILING_ACT
,
100 static struct mxsfb_platform_data mxsfb_pdata __initdata
;
102 static struct of_dev_auxdata mxs_auxdata_lookup
[] __initdata
= {
103 OF_DEV_AUXDATA("fsl,imx23-lcdif", 0x80030000, NULL
, &mxsfb_pdata
),
104 OF_DEV_AUXDATA("fsl,imx28-lcdif", 0x80030000, NULL
, &mxsfb_pdata
),
108 static int __init
mxs_icoll_add_irq_domain(struct device_node
*np
,
109 struct device_node
*interrupt_parent
)
111 irq_domain_add_legacy(np
, 128, 0, 0, &irq_domain_simple_ops
, NULL
);
116 static int __init
mxs_gpio_add_irq_domain(struct device_node
*np
,
117 struct device_node
*interrupt_parent
)
119 static int gpio_irq_base
= MXS_GPIO_IRQ_START
;
121 irq_domain_add_legacy(np
, 32, gpio_irq_base
, 0, &irq_domain_simple_ops
, NULL
);
127 static const struct of_device_id mxs_irq_match
[] __initconst
= {
128 { .compatible
= "fsl,mxs-icoll", .data
= mxs_icoll_add_irq_domain
, },
129 { .compatible
= "fsl,mxs-gpio", .data
= mxs_gpio_add_irq_domain
, },
133 static void __init
mxs_dt_init_irq(void)
136 of_irq_init(mxs_irq_match
);
139 static void __init
imx23_timer_init(void)
144 static struct sys_timer imx23_timer
= {
145 .init
= imx23_timer_init
,
148 static void __init
imx28_timer_init(void)
153 static struct sys_timer imx28_timer
= {
154 .init
= imx28_timer_init
,
162 static void __init
update_fec_mac_prop(enum mac_oui oui
)
164 struct device_node
*np
, *from
= NULL
;
165 struct property
*newmac
;
166 const u32
*ocotp
= mxs_get_ocotp();
171 for (i
= 0; i
< 2; i
++) {
172 np
= of_find_compatible_node(from
, NULL
, "fsl,imx28-fec");
177 newmac
= kzalloc(sizeof(*newmac
) + 6, GFP_KERNEL
);
180 newmac
->value
= newmac
+ 1;
183 newmac
->name
= kstrdup("local-mac-address", GFP_KERNEL
);
190 * OCOTP only stores the last 4 octets for each mac address,
191 * so hard-code OUI here.
193 macaddr
= newmac
->value
;
207 macaddr
[3] = (val
>> 16) & 0xff;
208 macaddr
[4] = (val
>> 8) & 0xff;
209 macaddr
[5] = (val
>> 0) & 0xff;
211 prom_update_property(np
, newmac
);
215 static void __init
imx23_evk_init(void)
217 mxsfb_pdata
.mode_list
= mx23evk_video_modes
;
218 mxsfb_pdata
.mode_count
= ARRAY_SIZE(mx23evk_video_modes
);
219 mxsfb_pdata
.default_bpp
= 32;
220 mxsfb_pdata
.ld_intf_width
= STMLCDIF_24BIT
;
223 static inline void enable_clk_enet_out(void)
225 struct clk
*clk
= clk_get_sys("enet_out", NULL
);
228 clk_prepare_enable(clk
);
231 static void __init
imx28_evk_init(void)
233 enable_clk_enet_out();
234 update_fec_mac_prop(OUI_FSL
);
236 mxsfb_pdata
.mode_list
= mx28evk_video_modes
;
237 mxsfb_pdata
.mode_count
= ARRAY_SIZE(mx28evk_video_modes
);
238 mxsfb_pdata
.default_bpp
= 32;
239 mxsfb_pdata
.ld_intf_width
= STMLCDIF_24BIT
;
242 static void __init
m28evk_init(void)
244 enable_clk_enet_out();
245 update_fec_mac_prop(OUI_DENX
);
247 mxsfb_pdata
.mode_list
= m28evk_video_modes
;
248 mxsfb_pdata
.mode_count
= ARRAY_SIZE(m28evk_video_modes
);
249 mxsfb_pdata
.default_bpp
= 16;
250 mxsfb_pdata
.ld_intf_width
= STMLCDIF_18BIT
;
253 static int apx4devkit_phy_fixup(struct phy_device
*phy
)
255 phy
->dev_flags
|= MICREL_PHY_50MHZ_CLK
;
259 static void __init
apx4devkit_init(void)
261 enable_clk_enet_out();
263 if (IS_BUILTIN(CONFIG_PHYLIB
))
264 phy_register_fixup_for_uid(PHY_ID_KSZ8051
, MICREL_PHY_ID_MASK
,
265 apx4devkit_phy_fixup
);
267 mxsfb_pdata
.mode_list
= apx4devkit_video_modes
;
268 mxsfb_pdata
.mode_count
= ARRAY_SIZE(apx4devkit_video_modes
);
269 mxsfb_pdata
.default_bpp
= 32;
270 mxsfb_pdata
.ld_intf_width
= STMLCDIF_24BIT
;
273 static void __init
mxs_machine_init(void)
275 if (of_machine_is_compatible("fsl,imx28-evk"))
277 else if (of_machine_is_compatible("fsl,imx23-evk"))
279 else if (of_machine_is_compatible("denx,m28evk"))
281 else if (of_machine_is_compatible("bluegiga,apx4devkit"))
284 of_platform_populate(NULL
, of_default_bus_match_table
,
285 mxs_auxdata_lookup
, NULL
);
288 static const char *imx23_dt_compat
[] __initdata
= {
291 "olimex,imx23-olinuxino",
296 static const char *imx28_dt_compat
[] __initdata
= {
297 "bluegiga,apx4devkit",
298 "crystalfontz,cfa10036",
306 DT_MACHINE_START(IMX23
, "Freescale i.MX23 (Device Tree)")
307 .map_io
= mx23_map_io
,
308 .init_irq
= mxs_dt_init_irq
,
309 .timer
= &imx23_timer
,
310 .init_machine
= mxs_machine_init
,
311 .dt_compat
= imx23_dt_compat
,
312 .restart
= mxs_restart
,
315 DT_MACHINE_START(IMX28
, "Freescale i.MX28 (Device Tree)")
316 .map_io
= mx28_map_io
,
317 .init_irq
= mxs_dt_init_irq
,
318 .timer
= &imx28_timer
,
319 .init_machine
= mxs_machine_init
,
320 .dt_compat
= imx28_dt_compat
,
321 .restart
= mxs_restart
,