2 * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <linux/delay.h>
16 #include <linux/platform_device.h>
17 #include <linux/gpio.h>
18 #include <linux/leds.h>
19 #include <linux/clk.h>
20 #include <linux/i2c.h>
21 #include <linux/regulator/machine.h>
22 #include <linux/regulator/fixed.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/time.h>
28 #include <mach/common.h>
29 #include <mach/iomux-mx28.h>
30 #include <mach/digctl.h>
32 #include "devices-mx28.h"
34 #define MX28EVK_FLEXCAN_SWITCH MXS_GPIO_NR(2, 13)
35 #define MX28EVK_FEC_PHY_POWER MXS_GPIO_NR(2, 15)
36 #define MX28EVK_GPIO_LED MXS_GPIO_NR(3, 5)
37 #define MX28EVK_BL_ENABLE MXS_GPIO_NR(3, 18)
38 #define MX28EVK_LCD_ENABLE MXS_GPIO_NR(3, 30)
39 #define MX28EVK_FEC_PHY_RESET MXS_GPIO_NR(4, 13)
41 #define MX28EVK_MMC0_WRITE_PROTECT MXS_GPIO_NR(2, 12)
42 #define MX28EVK_MMC1_WRITE_PROTECT MXS_GPIO_NR(0, 28)
43 #define MX28EVK_MMC0_SLOT_POWER MXS_GPIO_NR(3, 28)
44 #define MX28EVK_MMC1_SLOT_POWER MXS_GPIO_NR(3, 29)
46 static const iomux_cfg_t mx28evk_pads
[] __initconst
= {
48 MX28_PAD_PWM0__DUART_RX
| MXS_PAD_CTRL
,
49 MX28_PAD_PWM1__DUART_TX
| MXS_PAD_CTRL
,
52 MX28_PAD_AUART0_RX__AUART0_RX
| MXS_PAD_CTRL
,
53 MX28_PAD_AUART0_TX__AUART0_TX
| MXS_PAD_CTRL
,
54 MX28_PAD_AUART0_CTS__AUART0_CTS
| MXS_PAD_CTRL
,
55 MX28_PAD_AUART0_RTS__AUART0_RTS
| MXS_PAD_CTRL
,
57 MX28_PAD_AUART3_RX__AUART3_RX
| MXS_PAD_CTRL
,
58 MX28_PAD_AUART3_TX__AUART3_TX
| MXS_PAD_CTRL
,
59 MX28_PAD_AUART3_CTS__AUART3_CTS
| MXS_PAD_CTRL
,
60 MX28_PAD_AUART3_RTS__AUART3_RTS
| MXS_PAD_CTRL
,
62 #define MXS_PAD_FEC (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP)
64 MX28_PAD_ENET0_MDC__ENET0_MDC
| MXS_PAD_FEC
,
65 MX28_PAD_ENET0_MDIO__ENET0_MDIO
| MXS_PAD_FEC
,
66 MX28_PAD_ENET0_RX_EN__ENET0_RX_EN
| MXS_PAD_FEC
,
67 MX28_PAD_ENET0_RXD0__ENET0_RXD0
| MXS_PAD_FEC
,
68 MX28_PAD_ENET0_RXD1__ENET0_RXD1
| MXS_PAD_FEC
,
69 MX28_PAD_ENET0_TX_EN__ENET0_TX_EN
| MXS_PAD_FEC
,
70 MX28_PAD_ENET0_TXD0__ENET0_TXD0
| MXS_PAD_FEC
,
71 MX28_PAD_ENET0_TXD1__ENET0_TXD1
| MXS_PAD_FEC
,
72 MX28_PAD_ENET_CLK__CLKCTRL_ENET
| MXS_PAD_FEC
,
74 MX28_PAD_ENET0_CRS__ENET1_RX_EN
| MXS_PAD_FEC
,
75 MX28_PAD_ENET0_RXD2__ENET1_RXD0
| MXS_PAD_FEC
,
76 MX28_PAD_ENET0_RXD3__ENET1_RXD1
| MXS_PAD_FEC
,
77 MX28_PAD_ENET0_COL__ENET1_TX_EN
| MXS_PAD_FEC
,
78 MX28_PAD_ENET0_TXD2__ENET1_TXD0
| MXS_PAD_FEC
,
79 MX28_PAD_ENET0_TXD3__ENET1_TXD1
| MXS_PAD_FEC
,
81 MX28_PAD_SSP1_DATA3__GPIO_2_15
| MXS_PAD_CTRL
,
83 MX28_PAD_ENET0_RX_CLK__GPIO_4_13
| MXS_PAD_CTRL
,
86 MX28_PAD_GPMI_RDY2__CAN0_TX
,
87 MX28_PAD_GPMI_RDY3__CAN0_RX
,
89 MX28_PAD_GPMI_CE2N__CAN1_TX
,
90 MX28_PAD_GPMI_CE3N__CAN1_RX
,
91 /* transceiver power control */
92 MX28_PAD_SSP1_CMD__GPIO_2_13
,
95 MX28_PAD_LCD_D00__LCD_D0
| MXS_PAD_CTRL
,
96 MX28_PAD_LCD_D01__LCD_D1
| MXS_PAD_CTRL
,
97 MX28_PAD_LCD_D02__LCD_D2
| MXS_PAD_CTRL
,
98 MX28_PAD_LCD_D03__LCD_D3
| MXS_PAD_CTRL
,
99 MX28_PAD_LCD_D04__LCD_D4
| MXS_PAD_CTRL
,
100 MX28_PAD_LCD_D05__LCD_D5
| MXS_PAD_CTRL
,
101 MX28_PAD_LCD_D06__LCD_D6
| MXS_PAD_CTRL
,
102 MX28_PAD_LCD_D07__LCD_D7
| MXS_PAD_CTRL
,
103 MX28_PAD_LCD_D08__LCD_D8
| MXS_PAD_CTRL
,
104 MX28_PAD_LCD_D09__LCD_D9
| MXS_PAD_CTRL
,
105 MX28_PAD_LCD_D10__LCD_D10
| MXS_PAD_CTRL
,
106 MX28_PAD_LCD_D11__LCD_D11
| MXS_PAD_CTRL
,
107 MX28_PAD_LCD_D12__LCD_D12
| MXS_PAD_CTRL
,
108 MX28_PAD_LCD_D13__LCD_D13
| MXS_PAD_CTRL
,
109 MX28_PAD_LCD_D14__LCD_D14
| MXS_PAD_CTRL
,
110 MX28_PAD_LCD_D15__LCD_D15
| MXS_PAD_CTRL
,
111 MX28_PAD_LCD_D16__LCD_D16
| MXS_PAD_CTRL
,
112 MX28_PAD_LCD_D17__LCD_D17
| MXS_PAD_CTRL
,
113 MX28_PAD_LCD_D18__LCD_D18
| MXS_PAD_CTRL
,
114 MX28_PAD_LCD_D19__LCD_D19
| MXS_PAD_CTRL
,
115 MX28_PAD_LCD_D20__LCD_D20
| MXS_PAD_CTRL
,
116 MX28_PAD_LCD_D21__LCD_D21
| MXS_PAD_CTRL
,
117 MX28_PAD_LCD_D22__LCD_D22
| MXS_PAD_CTRL
,
118 MX28_PAD_LCD_D23__LCD_D23
| MXS_PAD_CTRL
,
119 MX28_PAD_LCD_RD_E__LCD_VSYNC
| MXS_PAD_CTRL
,
120 MX28_PAD_LCD_WR_RWN__LCD_HSYNC
| MXS_PAD_CTRL
,
121 MX28_PAD_LCD_RS__LCD_DOTCLK
| MXS_PAD_CTRL
,
122 MX28_PAD_LCD_CS__LCD_ENABLE
| MXS_PAD_CTRL
,
123 /* LCD panel enable */
124 MX28_PAD_LCD_RESET__GPIO_3_30
| MXS_PAD_CTRL
,
125 /* backlight control */
126 MX28_PAD_PWM2__GPIO_3_18
| MXS_PAD_CTRL
,
128 MX28_PAD_SSP0_DATA0__SSP0_D0
|
129 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
130 MX28_PAD_SSP0_DATA1__SSP0_D1
|
131 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
132 MX28_PAD_SSP0_DATA2__SSP0_D2
|
133 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
134 MX28_PAD_SSP0_DATA3__SSP0_D3
|
135 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
136 MX28_PAD_SSP0_DATA4__SSP0_D4
|
137 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
138 MX28_PAD_SSP0_DATA5__SSP0_D5
|
139 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
140 MX28_PAD_SSP0_DATA6__SSP0_D6
|
141 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
142 MX28_PAD_SSP0_DATA7__SSP0_D7
|
143 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
144 MX28_PAD_SSP0_CMD__SSP0_CMD
|
145 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
146 MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT
|
147 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
148 MX28_PAD_SSP0_SCK__SSP0_SCK
|
149 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
151 MX28_PAD_SSP1_SCK__GPIO_2_12
|
152 (MXS_PAD_4MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
153 /* slot power enable */
154 MX28_PAD_PWM3__GPIO_3_28
|
155 (MXS_PAD_4MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
158 MX28_PAD_GPMI_D00__SSP1_D0
|
159 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
160 MX28_PAD_GPMI_D01__SSP1_D1
|
161 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
162 MX28_PAD_GPMI_D02__SSP1_D2
|
163 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
164 MX28_PAD_GPMI_D03__SSP1_D3
|
165 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
166 MX28_PAD_GPMI_D04__SSP1_D4
|
167 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
168 MX28_PAD_GPMI_D05__SSP1_D5
|
169 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
170 MX28_PAD_GPMI_D06__SSP1_D6
|
171 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
172 MX28_PAD_GPMI_D07__SSP1_D7
|
173 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
174 MX28_PAD_GPMI_RDY1__SSP1_CMD
|
175 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
176 MX28_PAD_GPMI_RDY0__SSP1_CARD_DETECT
|
177 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
178 MX28_PAD_GPMI_WRN__SSP1_SCK
|
179 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
181 MX28_PAD_GPMI_RESETN__GPIO_0_28
|
182 (MXS_PAD_4MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
183 /* slot power enable */
184 MX28_PAD_PWM4__GPIO_3_29
|
185 (MXS_PAD_4MA
| MXS_PAD_3V3
| MXS_PAD_NOPULL
),
188 MX28_PAD_AUART1_TX__GPIO_3_5
| MXS_PAD_CTRL
,
191 MX28_PAD_I2C0_SCL__I2C0_SCL
|
192 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
193 MX28_PAD_I2C0_SDA__I2C0_SDA
|
194 (MXS_PAD_8MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
197 MX28_PAD_SAIF0_MCLK__SAIF0_MCLK
|
198 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
199 MX28_PAD_SAIF0_LRCLK__SAIF0_LRCLK
|
200 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
201 MX28_PAD_SAIF0_BITCLK__SAIF0_BITCLK
|
202 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
203 MX28_PAD_SAIF0_SDATA0__SAIF0_SDATA0
|
204 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
205 MX28_PAD_SAIF1_SDATA0__SAIF1_SDATA0
|
206 (MXS_PAD_12MA
| MXS_PAD_3V3
| MXS_PAD_PULLUP
),
210 static const struct gpio_led mx28evk_leds
[] __initconst
= {
213 .default_trigger
= "heartbeat",
214 .gpio
= MX28EVK_GPIO_LED
,
218 static const struct gpio_led_platform_data mx28evk_led_data __initconst
= {
219 .leds
= mx28evk_leds
,
220 .num_leds
= ARRAY_SIZE(mx28evk_leds
),
224 static void __init
mx28evk_fec_reset(void)
228 /* Enable fec phy clock */
229 clk
= clk_get_sys("enet_out", NULL
);
231 clk_prepare_enable(clk
);
233 gpio_set_value(MX28EVK_FEC_PHY_RESET
, 0);
235 gpio_set_value(MX28EVK_FEC_PHY_RESET
, 1);
238 static struct fec_platform_data mx28_fec_pdata
[] __initdata
= {
241 .phy
= PHY_INTERFACE_MODE_RMII
,
244 .phy
= PHY_INTERFACE_MODE_RMII
,
248 static int __init
mx28evk_fec_get_mac(void)
252 const u32
*ocotp
= mxs_get_ocotp();
258 * OCOTP only stores the last 4 octets for each mac address,
259 * so hard-code Freescale OUI (00:04:9f) here.
261 for (i
= 0; i
< 2; i
++) {
263 mx28_fec_pdata
[i
].mac
[0] = 0x00;
264 mx28_fec_pdata
[i
].mac
[1] = 0x04;
265 mx28_fec_pdata
[i
].mac
[2] = 0x9f;
266 mx28_fec_pdata
[i
].mac
[3] = (val
>> 16) & 0xff;
267 mx28_fec_pdata
[i
].mac
[4] = (val
>> 8) & 0xff;
268 mx28_fec_pdata
[i
].mac
[5] = (val
>> 0) & 0xff;
275 * MX28EVK_FLEXCAN_SWITCH is shared between both flexcan controllers
277 static int flexcan0_en
, flexcan1_en
;
279 static void mx28evk_flexcan_switch(void)
281 if (flexcan0_en
|| flexcan1_en
)
282 gpio_set_value(MX28EVK_FLEXCAN_SWITCH
, 1);
284 gpio_set_value(MX28EVK_FLEXCAN_SWITCH
, 0);
287 static void mx28evk_flexcan0_switch(int enable
)
289 flexcan0_en
= enable
;
290 mx28evk_flexcan_switch();
293 static void mx28evk_flexcan1_switch(int enable
)
295 flexcan1_en
= enable
;
296 mx28evk_flexcan_switch();
299 static const struct flexcan_platform_data
300 mx28evk_flexcan_pdata
[] __initconst
= {
302 .transceiver_switch
= mx28evk_flexcan0_switch
,
304 .transceiver_switch
= mx28evk_flexcan1_switch
,
309 static struct fb_videomode mx28evk_video_modes
[] = {
311 .name
= "Seiko-43WVF1G",
315 .pixclock
= 29851, /* picosecond (33.5 MHz) */
322 .sync
= FB_SYNC_DATA_ENABLE_HIGH_ACT
|
323 FB_SYNC_DOTCLK_FAILING_ACT
,
327 static const struct mxsfb_platform_data mx28evk_mxsfb_pdata __initconst
= {
328 .mode_list
= mx28evk_video_modes
,
329 .mode_count
= ARRAY_SIZE(mx28evk_video_modes
),
331 .ld_intf_width
= STMLCDIF_24BIT
,
334 static struct mxs_mmc_platform_data mx28evk_mmc_pdata
[] __initdata
= {
337 .wp_gpio
= MX28EVK_MMC0_WRITE_PROTECT
,
338 .flags
= SLOTF_8_BIT_CAPABLE
,
341 .wp_gpio
= MX28EVK_MMC1_WRITE_PROTECT
,
342 .flags
= SLOTF_8_BIT_CAPABLE
,
346 static struct i2c_board_info mxs_i2c0_board_info
[] __initdata
= {
348 I2C_BOARD_INFO("sgtl5000", 0x0a),
352 #if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
353 static struct regulator_consumer_supply mx28evk_audio_consumer_supplies
[] = {
354 REGULATOR_SUPPLY("VDDA", "0-000a"),
355 REGULATOR_SUPPLY("VDDIO", "0-000a"),
358 static struct regulator_init_data mx28evk_vdd_reg_init_data
= {
363 .consumer_supplies
= mx28evk_audio_consumer_supplies
,
364 .num_consumer_supplies
= ARRAY_SIZE(mx28evk_audio_consumer_supplies
),
367 static struct fixed_voltage_config mx28evk_vdd_pdata
= {
368 .supply_name
= "board-3V3",
369 .microvolts
= 3300000,
371 .enabled_at_boot
= 1,
372 .init_data
= &mx28evk_vdd_reg_init_data
,
374 static struct platform_device mx28evk_voltage_regulator
= {
375 .name
= "reg-fixed-voltage",
379 .platform_data
= &mx28evk_vdd_pdata
,
382 static void __init
mx28evk_add_regulators(void)
384 platform_device_register(&mx28evk_voltage_regulator
);
387 static void __init
mx28evk_add_regulators(void) {}
390 static const struct gpio mx28evk_gpios
[] __initconst
= {
391 { MX28EVK_LCD_ENABLE
, GPIOF_OUT_INIT_HIGH
, "lcd-enable" },
392 { MX28EVK_BL_ENABLE
, GPIOF_OUT_INIT_HIGH
, "bl-enable" },
393 { MX28EVK_FLEXCAN_SWITCH
, GPIOF_DIR_OUT
, "flexcan-switch" },
394 { MX28EVK_MMC0_SLOT_POWER
, GPIOF_OUT_INIT_LOW
, "mmc0-slot-power" },
395 { MX28EVK_MMC1_SLOT_POWER
, GPIOF_OUT_INIT_LOW
, "mmc1-slot-power" },
396 { MX28EVK_FEC_PHY_POWER
, GPIOF_OUT_INIT_LOW
, "fec-phy-power" },
397 { MX28EVK_FEC_PHY_RESET
, GPIOF_DIR_OUT
, "fec-phy-reset" },
400 static const struct mxs_saif_platform_data
401 mx28evk_mxs_saif_pdata
[] __initconst
= {
402 /* working on EXTMSTR0 mode (saif0 master, saif1 slave) */
412 static void __init
mx28evk_init(void)
418 mxs_iomux_setup_multiple_pads(mx28evk_pads
, ARRAY_SIZE(mx28evk_pads
));
424 if (mx28evk_fec_get_mac())
425 pr_warn("%s: failed on fec mac setup\n", __func__
);
427 ret
= gpio_request_array(mx28evk_gpios
, ARRAY_SIZE(mx28evk_gpios
));
429 pr_err("One or more GPIOs failed to be requested: %d\n", ret
);
432 mx28_add_fec(0, &mx28_fec_pdata
[0]);
433 mx28_add_fec(1, &mx28_fec_pdata
[1]);
435 mx28_add_flexcan(0, &mx28evk_flexcan_pdata
[0]);
436 mx28_add_flexcan(1, &mx28evk_flexcan_pdata
[1]);
438 mx28_add_mxsfb(&mx28evk_mxsfb_pdata
);
440 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0
);
441 mx28_add_saif(0, &mx28evk_mxs_saif_pdata
[0]);
442 mx28_add_saif(1, &mx28evk_mxs_saif_pdata
[1]);
445 i2c_register_board_info(0, mxs_i2c0_board_info
,
446 ARRAY_SIZE(mxs_i2c0_board_info
));
448 mx28evk_add_regulators();
450 mxs_add_platform_device("mxs-sgtl5000", 0, NULL
, 0,
453 mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata
[0]);
454 mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata
[1]);
456 mx28_add_rtc_stmp3xxx();
458 gpio_led_register_device(0, &mx28evk_led_data
);
461 static void __init
mx28evk_timer_init(void)
466 static struct sys_timer mx28evk_timer
= {
467 .init
= mx28evk_timer_init
,
470 MACHINE_START(MX28EVK
, "Freescale MX28 EVK")
471 /* Maintainer: Freescale Semiconductor, Inc. */
472 .map_io
= mx28_map_io
,
473 .init_irq
= mx28_init_irq
,
474 .timer
= &mx28evk_timer
,
475 .init_machine
= mx28evk_init
,
476 .restart
= mxs_restart
,