diff options
Diffstat (limited to 'arch/arm/mach-mx5/board-mx51_efikamx.c')
-rw-r--r-- | arch/arm/mach-mx5/board-mx51_efikamx.c | 247 |
1 files changed, 246 insertions, 1 deletions
diff --git a/arch/arm/mach-mx5/board-mx51_efikamx.c b/arch/arm/mach-mx5/board-mx51_efikamx.c index 6e623bda3ee7..b7946f8e8d40 100644 --- a/arch/arm/mach-mx5/board-mx51_efikamx.c +++ b/arch/arm/mach-mx5/board-mx51_efikamx.c | |||
@@ -18,9 +18,13 @@ | |||
18 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/i2c.h> | 19 | #include <linux/i2c.h> |
20 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
21 | #include <linux/leds.h> | ||
22 | #include <linux/input.h> | ||
21 | #include <linux/delay.h> | 23 | #include <linux/delay.h> |
22 | #include <linux/io.h> | 24 | #include <linux/io.h> |
23 | #include <linux/fsl_devices.h> | 25 | #include <linux/fsl_devices.h> |
26 | #include <linux/spi/flash.h> | ||
27 | #include <linux/spi/spi.h> | ||
24 | 28 | ||
25 | #include <mach/common.h> | 29 | #include <mach/common.h> |
26 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
@@ -39,12 +43,81 @@ | |||
39 | 43 | ||
40 | #define MX51_USB_PLL_DIV_24_MHZ 0x01 | 44 | #define MX51_USB_PLL_DIV_24_MHZ 0x01 |
41 | 45 | ||
42 | static struct pad_desc mx51efikamx_pads[] = { | 46 | #define EFIKAMX_PCBID0 IMX_GPIO_NR(3, 16) |
47 | #define EFIKAMX_PCBID1 IMX_GPIO_NR(3, 17) | ||
48 | #define EFIKAMX_PCBID2 IMX_GPIO_NR(3, 11) | ||
49 | |||
50 | #define EFIKAMX_BLUE_LED IMX_GPIO_NR(3, 13) | ||
51 | #define EFIKAMX_GREEN_LED IMX_GPIO_NR(3, 14) | ||
52 | #define EFIKAMX_RED_LED IMX_GPIO_NR(3, 15) | ||
53 | |||
54 | #define EFIKAMX_POWER_KEY IMX_GPIO_NR(2, 31) | ||
55 | |||
56 | #define EFIKAMX_SPI_CS0 IMX_GPIO_NR(4, 24) | ||
57 | #define EFIKAMX_SPI_CS1 IMX_GPIO_NR(4, 25) | ||
58 | |||
59 | /* board 1.1 doesn't have same reset gpio */ | ||
60 | #define EFIKAMX_RESET1_1 IMX_GPIO_NR(3, 2) | ||
61 | #define EFIKAMX_RESET IMX_GPIO_NR(1, 4) | ||
62 | |||
63 | /* the pci ids pin have pull up. they're driven low according to board id */ | ||
64 | #define MX51_PAD_PCBID0 IOMUX_PAD(0x518, 0x130, 3, 0x0, 0, PAD_CTL_PUS_100K_UP) | ||
65 | #define MX51_PAD_PCBID1 IOMUX_PAD(0x51C, 0x134, 3, 0x0, 0, PAD_CTL_PUS_100K_UP) | ||
66 | #define MX51_PAD_PCBID2 IOMUX_PAD(0x504, 0x128, 3, 0x0, 0, PAD_CTL_PUS_100K_UP) | ||
67 | #define MX51_PAD_PWRKEY IOMUX_PAD(0x48c, 0x0f8, 1, 0x0, 0, PAD_CTL_PUS_100K_UP | PAD_CTL_PKE) | ||
68 | |||
69 | static iomux_v3_cfg_t mx51efikamx_pads[] = { | ||
43 | /* UART1 */ | 70 | /* UART1 */ |
44 | MX51_PAD_UART1_RXD__UART1_RXD, | 71 | MX51_PAD_UART1_RXD__UART1_RXD, |
45 | MX51_PAD_UART1_TXD__UART1_TXD, | 72 | MX51_PAD_UART1_TXD__UART1_TXD, |
46 | MX51_PAD_UART1_RTS__UART1_RTS, | 73 | MX51_PAD_UART1_RTS__UART1_RTS, |
47 | MX51_PAD_UART1_CTS__UART1_CTS, | 74 | MX51_PAD_UART1_CTS__UART1_CTS, |
75 | /* board id */ | ||
76 | MX51_PAD_PCBID0, | ||
77 | MX51_PAD_PCBID1, | ||
78 | MX51_PAD_PCBID2, | ||
79 | |||
80 | /* SD 1 */ | ||
81 | MX51_PAD_SD1_CMD__SD1_CMD, | ||
82 | MX51_PAD_SD1_CLK__SD1_CLK, | ||
83 | MX51_PAD_SD1_DATA0__SD1_DATA0, | ||
84 | MX51_PAD_SD1_DATA1__SD1_DATA1, | ||
85 | MX51_PAD_SD1_DATA2__SD1_DATA2, | ||
86 | MX51_PAD_SD1_DATA3__SD1_DATA3, | ||
87 | |||
88 | /* SD 2 */ | ||
89 | MX51_PAD_SD2_CMD__SD2_CMD, | ||
90 | MX51_PAD_SD2_CLK__SD2_CLK, | ||
91 | MX51_PAD_SD2_DATA0__SD2_DATA0, | ||
92 | MX51_PAD_SD2_DATA1__SD2_DATA1, | ||
93 | MX51_PAD_SD2_DATA2__SD2_DATA2, | ||
94 | MX51_PAD_SD2_DATA3__SD2_DATA3, | ||
95 | |||
96 | /* SD/MMC WP/CD */ | ||
97 | MX51_PAD_GPIO1_0__SD1_CD, | ||
98 | MX51_PAD_GPIO1_1__SD1_WP, | ||
99 | MX51_PAD_GPIO1_7__SD2_WP, | ||
100 | MX51_PAD_GPIO1_8__SD2_CD, | ||
101 | |||
102 | /* leds */ | ||
103 | MX51_PAD_CSI1_D9__GPIO3_13, | ||
104 | MX51_PAD_CSI1_VSYNC__GPIO3_14, | ||
105 | MX51_PAD_CSI1_HSYNC__GPIO3_15, | ||
106 | |||
107 | /* power key */ | ||
108 | MX51_PAD_PWRKEY, | ||
109 | |||
110 | /* spi */ | ||
111 | MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, | ||
112 | MX51_PAD_CSPI1_MISO__ECSPI1_MISO, | ||
113 | MX51_PAD_CSPI1_SS0__GPIO4_24, | ||
114 | MX51_PAD_CSPI1_SS1__GPIO4_25, | ||
115 | MX51_PAD_CSPI1_RDY__ECSPI1_RDY, | ||
116 | MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, | ||
117 | |||
118 | /* reset */ | ||
119 | MX51_PAD_DI1_PIN13__GPIO3_2, | ||
120 | MX51_PAD_GPIO1_4__GPIO1_4, | ||
48 | }; | 121 | }; |
49 | 122 | ||
50 | /* Serial ports */ | 123 | /* Serial ports */ |
@@ -75,6 +148,8 @@ static int initialize_otg_port(struct platform_device *pdev) | |||
75 | void __iomem *usb_base; | 148 | void __iomem *usb_base; |
76 | void __iomem *usbother_base; | 149 | void __iomem *usbother_base; |
77 | usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); | 150 | usb_base = ioremap(MX51_OTG_BASE_ADDR, SZ_4K); |
151 | if (!usb_base) | ||
152 | return -ENOMEM; | ||
78 | usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET); | 153 | usbother_base = (void __iomem *)(usb_base + MX5_USBOTHER_REGS_OFFSET); |
79 | 154 | ||
80 | /* Set the PHY clock to 19.2MHz */ | 155 | /* Set the PHY clock to 19.2MHz */ |
@@ -92,12 +167,182 @@ static struct mxc_usbh_platform_data dr_utmi_config = { | |||
92 | .flags = MXC_EHCI_INTERNAL_PHY, | 167 | .flags = MXC_EHCI_INTERNAL_PHY, |
93 | }; | 168 | }; |
94 | 169 | ||
170 | /* PCBID2 PCBID1 PCBID0 STATE | ||
171 | 1 1 1 ER1:rev1.1 | ||
172 | 1 1 0 ER2:rev1.2 | ||
173 | 1 0 1 ER3:rev1.3 | ||
174 | 1 0 0 ER4:rev1.4 | ||
175 | */ | ||
176 | static void __init mx51_efikamx_board_id(void) | ||
177 | { | ||
178 | int id; | ||
179 | |||
180 | /* things are taking time to settle */ | ||
181 | msleep(150); | ||
182 | |||
183 | gpio_request(EFIKAMX_PCBID0, "pcbid0"); | ||
184 | gpio_direction_input(EFIKAMX_PCBID0); | ||
185 | gpio_request(EFIKAMX_PCBID1, "pcbid1"); | ||
186 | gpio_direction_input(EFIKAMX_PCBID1); | ||
187 | gpio_request(EFIKAMX_PCBID2, "pcbid2"); | ||
188 | gpio_direction_input(EFIKAMX_PCBID2); | ||
189 | |||
190 | id = gpio_get_value(EFIKAMX_PCBID0); | ||
191 | id |= gpio_get_value(EFIKAMX_PCBID1) << 1; | ||
192 | id |= gpio_get_value(EFIKAMX_PCBID2) << 2; | ||
193 | |||
194 | switch (id) { | ||
195 | case 7: | ||
196 | system_rev = 0x11; | ||
197 | break; | ||
198 | case 6: | ||
199 | system_rev = 0x12; | ||
200 | break; | ||
201 | case 5: | ||
202 | system_rev = 0x13; | ||
203 | break; | ||
204 | case 4: | ||
205 | system_rev = 0x14; | ||
206 | break; | ||
207 | default: | ||
208 | system_rev = 0x10; | ||
209 | break; | ||
210 | } | ||
211 | |||
212 | if ((system_rev == 0x10) | ||
213 | || (system_rev == 0x12) | ||
214 | || (system_rev == 0x14)) { | ||
215 | printk(KERN_WARNING | ||
216 | "EfikaMX: Unsupported board revision 1.%u!\n", | ||
217 | system_rev & 0xf); | ||
218 | } | ||
219 | } | ||
220 | |||
221 | static struct gpio_led mx51_efikamx_leds[] = { | ||
222 | { | ||
223 | .name = "efikamx:green", | ||
224 | .default_trigger = "default-on", | ||
225 | .gpio = EFIKAMX_GREEN_LED, | ||
226 | }, | ||
227 | { | ||
228 | .name = "efikamx:red", | ||
229 | .default_trigger = "ide-disk", | ||
230 | .gpio = EFIKAMX_RED_LED, | ||
231 | }, | ||
232 | { | ||
233 | .name = "efikamx:blue", | ||
234 | .default_trigger = "mmc0", | ||
235 | .gpio = EFIKAMX_BLUE_LED, | ||
236 | }, | ||
237 | }; | ||
238 | |||
239 | static struct gpio_led_platform_data mx51_efikamx_leds_data = { | ||
240 | .leds = mx51_efikamx_leds, | ||
241 | .num_leds = ARRAY_SIZE(mx51_efikamx_leds), | ||
242 | }; | ||
243 | |||
244 | static struct platform_device mx51_efikamx_leds_device = { | ||
245 | .name = "leds-gpio", | ||
246 | .id = -1, | ||
247 | .dev = { | ||
248 | .platform_data = &mx51_efikamx_leds_data, | ||
249 | }, | ||
250 | }; | ||
251 | |||
252 | static struct gpio_keys_button mx51_efikamx_powerkey[] = { | ||
253 | { | ||
254 | .code = KEY_POWER, | ||
255 | .gpio = EFIKAMX_POWER_KEY, | ||
256 | .type = EV_PWR, | ||
257 | .desc = "Power Button (CM)", | ||
258 | .wakeup = 1, | ||
259 | .debounce_interval = 10, /* ms */ | ||
260 | }, | ||
261 | }; | ||
262 | |||
263 | static const struct gpio_keys_platform_data mx51_efikamx_powerkey_data __initconst = { | ||
264 | .buttons = mx51_efikamx_powerkey, | ||
265 | .nbuttons = ARRAY_SIZE(mx51_efikamx_powerkey), | ||
266 | }; | ||
267 | |||
268 | static struct mtd_partition mx51_efikamx_spi_nor_partitions[] = { | ||
269 | { | ||
270 | .name = "u-boot", | ||
271 | .offset = 0, | ||
272 | .size = SZ_256K, | ||
273 | }, | ||
274 | { | ||
275 | .name = "config", | ||
276 | .offset = MTDPART_OFS_APPEND, | ||
277 | .size = SZ_64K, | ||
278 | }, | ||
279 | }; | ||
280 | |||
281 | static struct flash_platform_data mx51_efikamx_spi_flash_data = { | ||
282 | .name = "spi_flash", | ||
283 | .parts = mx51_efikamx_spi_nor_partitions, | ||
284 | .nr_parts = ARRAY_SIZE(mx51_efikamx_spi_nor_partitions), | ||
285 | .type = "sst25vf032b", | ||
286 | }; | ||
287 | |||
288 | static struct spi_board_info mx51_efikamx_spi_board_info[] __initdata = { | ||
289 | { | ||
290 | .modalias = "m25p80", | ||
291 | .max_speed_hz = 25000000, | ||
292 | .bus_num = 0, | ||
293 | .chip_select = 1, | ||
294 | .platform_data = &mx51_efikamx_spi_flash_data, | ||
295 | .irq = -1, | ||
296 | }, | ||
297 | }; | ||
298 | |||
299 | static int mx51_efikamx_spi_cs[] = { | ||
300 | EFIKAMX_SPI_CS0, | ||
301 | EFIKAMX_SPI_CS1, | ||
302 | }; | ||
303 | |||
304 | static const struct spi_imx_master mx51_efikamx_spi_pdata __initconst = { | ||
305 | .chipselect = mx51_efikamx_spi_cs, | ||
306 | .num_chipselect = ARRAY_SIZE(mx51_efikamx_spi_cs), | ||
307 | }; | ||
308 | |||
309 | void mx51_efikamx_reset(void) | ||
310 | { | ||
311 | if (system_rev == 0x11) | ||
312 | gpio_direction_output(EFIKAMX_RESET1_1, 0); | ||
313 | else | ||
314 | gpio_direction_output(EFIKAMX_RESET, 0); | ||
315 | } | ||
316 | |||
95 | static void __init mxc_board_init(void) | 317 | static void __init mxc_board_init(void) |
96 | { | 318 | { |
97 | mxc_iomux_v3_setup_multiple_pads(mx51efikamx_pads, | 319 | mxc_iomux_v3_setup_multiple_pads(mx51efikamx_pads, |
98 | ARRAY_SIZE(mx51efikamx_pads)); | 320 | ARRAY_SIZE(mx51efikamx_pads)); |
321 | mx51_efikamx_board_id(); | ||
99 | mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config); | 322 | mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config); |
100 | mxc_init_imx_uart(); | 323 | mxc_init_imx_uart(); |
324 | imx51_add_sdhci_esdhc_imx(0, NULL); | ||
325 | |||
326 | /* on < 1.2 boards both SD controllers are used */ | ||
327 | if (system_rev < 0x12) { | ||
328 | imx51_add_sdhci_esdhc_imx(1, NULL); | ||
329 | mx51_efikamx_leds[2].default_trigger = "mmc1"; | ||
330 | } | ||
331 | |||
332 | platform_device_register(&mx51_efikamx_leds_device); | ||
333 | imx51_add_gpio_keys(&mx51_efikamx_powerkey_data); | ||
334 | |||
335 | spi_register_board_info(mx51_efikamx_spi_board_info, | ||
336 | ARRAY_SIZE(mx51_efikamx_spi_board_info)); | ||
337 | imx51_add_ecspi(0, &mx51_efikamx_spi_pdata); | ||
338 | |||
339 | if (system_rev == 0x11) { | ||
340 | gpio_request(EFIKAMX_RESET1_1, "reset"); | ||
341 | gpio_direction_output(EFIKAMX_RESET1_1, 1); | ||
342 | } else { | ||
343 | gpio_request(EFIKAMX_RESET, "reset"); | ||
344 | gpio_direction_output(EFIKAMX_RESET, 1); | ||
345 | } | ||
101 | } | 346 | } |
102 | 347 | ||
103 | static void __init mx51_efikamx_timer_init(void) | 348 | static void __init mx51_efikamx_timer_init(void) |