blob: 4d9a56fb6989b7909b886ad12da13bc9d158760a [file] [log] [blame]
Thomas Gleixner16216332019-05-19 15:51:31 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Alberto Panizzo5e9145e2009-05-19 10:01:03 +02002/*
3 * armadillo5x0.c
4 *
5 * Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
6 * updates in http://alberdroid.blogspot.com/
7 *
8 * Based on Atmark Techno, Inc. armadillo 500 BSP 2008
9 * Based on mx31ads.c and pcm037.c Great Work!
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020010 */
11
12#include <linux/types.h>
13#include <linux/init.h>
14#include <linux/clk.h>
15#include <linux/platform_device.h>
16#include <linux/gpio.h>
17#include <linux/smsc911x.h>
18#include <linux/interrupt.h>
19#include <linux/irq.h>
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +020020#include <linux/mtd/physmap.h>
Alberto Panizzo0c8bad62009-06-17 15:06:30 +020021#include <linux/io.h>
Alberto Panizzoe33c0492009-10-15 19:24:51 +020022#include <linux/input.h>
Alberto Panizzo2097abc2009-10-15 19:33:24 +020023#include <linux/i2c.h>
Alberto Panizzob3aa1112010-02-26 18:36:32 +010024#include <linux/usb/otg.h>
25#include <linux/usb/ulpi.h>
26#include <linux/delay.h>
Fabio Estevam7a4302a2012-04-02 10:39:47 -030027#include <linux/regulator/machine.h>
28#include <linux/regulator/fixed.h>
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020029
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020030#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/time.h>
33#include <asm/memory.h>
34#include <asm/mach/map.h>
35
Shawn Guoe3372472012-09-13 21:01:00 +080036#include "common.h"
Uwe Kleine-Königa2ceeef2010-06-16 12:23:11 +020037#include "devices-imx31.h"
Fabio Estevam29781fa2012-01-20 16:43:09 -020038#include "crmregs-imx3.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080039#include "ehci.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080040#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080041#include "iomux-mx3.h"
Shawn Guo39ef6342012-09-13 21:46:09 +080042#include "ulpi.h"
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020043
44static int armadillo5x0_pins[] = {
45 /* UART1 */
46 MX31_PIN_CTS1__CTS1,
47 MX31_PIN_RTS1__RTS1,
48 MX31_PIN_TXD1__TXD1,
49 MX31_PIN_RXD1__RXD1,
50 /* UART2 */
51 MX31_PIN_CTS2__CTS2,
52 MX31_PIN_RTS2__RTS2,
53 MX31_PIN_TXD2__TXD2,
54 MX31_PIN_RXD2__RXD2,
55 /* LAN9118_IRQ */
56 IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO),
57 /* SDHC1 */
58 MX31_PIN_SD1_DATA3__SD1_DATA3,
59 MX31_PIN_SD1_DATA2__SD1_DATA2,
60 MX31_PIN_SD1_DATA1__SD1_DATA1,
61 MX31_PIN_SD1_DATA0__SD1_DATA0,
62 MX31_PIN_SD1_CLK__SD1_CLK,
63 MX31_PIN_SD1_CMD__SD1_CMD,
64 /* Framebuffer */
65 MX31_PIN_LD0__LD0,
66 MX31_PIN_LD1__LD1,
67 MX31_PIN_LD2__LD2,
68 MX31_PIN_LD3__LD3,
69 MX31_PIN_LD4__LD4,
70 MX31_PIN_LD5__LD5,
71 MX31_PIN_LD6__LD6,
72 MX31_PIN_LD7__LD7,
73 MX31_PIN_LD8__LD8,
74 MX31_PIN_LD9__LD9,
75 MX31_PIN_LD10__LD10,
76 MX31_PIN_LD11__LD11,
77 MX31_PIN_LD12__LD12,
78 MX31_PIN_LD13__LD13,
79 MX31_PIN_LD14__LD14,
80 MX31_PIN_LD15__LD15,
81 MX31_PIN_LD16__LD16,
82 MX31_PIN_LD17__LD17,
83 MX31_PIN_VSYNC3__VSYNC3,
84 MX31_PIN_HSYNC__HSYNC,
85 MX31_PIN_FPSHIFT__FPSHIFT,
86 MX31_PIN_DRDY0__DRDY0,
87 IOMUX_MODE(MX31_PIN_LCS1, IOMUX_CONFIG_GPIO), /*ADV7125_PSAVE*/
Alberto Panizzoe9a6c5d2009-10-15 19:31:07 +020088 /* I2C2 */
89 MX31_PIN_CSPI2_MOSI__SCL,
90 MX31_PIN_CSPI2_MISO__SDA,
Alberto Panizzob3aa1112010-02-26 18:36:32 +010091 /* OTG */
92 MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,
93 MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,
94 MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,
95 MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,
96 MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,
97 MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,
98 MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,
99 MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,
100 MX31_PIN_USBOTG_CLK__USBOTG_CLK,
101 MX31_PIN_USBOTG_DIR__USBOTG_DIR,
102 MX31_PIN_USBOTG_NXT__USBOTG_NXT,
103 MX31_PIN_USBOTG_STP__USBOTG_STP,
104 /* USB host 2 */
105 IOMUX_MODE(MX31_PIN_USBH2_CLK, IOMUX_CONFIG_FUNC),
106 IOMUX_MODE(MX31_PIN_USBH2_DIR, IOMUX_CONFIG_FUNC),
107 IOMUX_MODE(MX31_PIN_USBH2_NXT, IOMUX_CONFIG_FUNC),
108 IOMUX_MODE(MX31_PIN_USBH2_STP, IOMUX_CONFIG_FUNC),
109 IOMUX_MODE(MX31_PIN_USBH2_DATA0, IOMUX_CONFIG_FUNC),
110 IOMUX_MODE(MX31_PIN_USBH2_DATA1, IOMUX_CONFIG_FUNC),
111 IOMUX_MODE(MX31_PIN_STXD3, IOMUX_CONFIG_FUNC),
112 IOMUX_MODE(MX31_PIN_SRXD3, IOMUX_CONFIG_FUNC),
113 IOMUX_MODE(MX31_PIN_SCK3, IOMUX_CONFIG_FUNC),
114 IOMUX_MODE(MX31_PIN_SFS3, IOMUX_CONFIG_FUNC),
115 IOMUX_MODE(MX31_PIN_STXD6, IOMUX_CONFIG_FUNC),
116 IOMUX_MODE(MX31_PIN_SRXD6, IOMUX_CONFIG_FUNC),
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200117};
Alberto Panizzoe9a6c5d2009-10-15 19:31:07 +0200118
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100119/* USB */
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100120
121#define OTG_RESET IOMUX_TO_GPIO(MX31_PIN_STXD4)
122#define USBH2_RESET IOMUX_TO_GPIO(MX31_PIN_SCK6)
123#define USBH2_CS IOMUX_TO_GPIO(MX31_PIN_GPIO1_3)
124
125#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
126 PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
127
128static int usbotg_init(struct platform_device *pdev)
129{
130 int err;
131
132 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG);
133 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG);
134 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG);
135 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG);
136 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG);
137 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG);
138 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG);
139 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG);
140 mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG);
141 mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG);
142 mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG);
143 mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG);
144
145 /* Chip already enabled by hardware */
146 /* OTG phy reset*/
147 err = gpio_request(OTG_RESET, "USB-OTG-RESET");
148 if (err) {
149 pr_err("Failed to request the usb otg reset gpio\n");
150 return err;
151 }
152
153 err = gpio_direction_output(OTG_RESET, 1/*HIGH*/);
154 if (err) {
155 pr_err("Failed to reset the usb otg phy\n");
156 goto otg_free_reset;
157 }
158
159 gpio_set_value(OTG_RESET, 0/*LOW*/);
160 mdelay(5);
161 gpio_set_value(OTG_RESET, 1/*HIGH*/);
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100162 mdelay(10);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100163
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100164 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
165 MXC_EHCI_INTERFACE_DIFF_UNI);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100166
167otg_free_reset:
168 gpio_free(OTG_RESET);
169 return err;
170}
171
172static int usbh2_init(struct platform_device *pdev)
173{
174 int err;
175
176 mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
177 mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
178 mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
179 mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
180 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
181 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
182 mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
183 mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
184 mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
185 mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
186 mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
187 mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
188
189 mxc_iomux_set_gpr(MUX_PGP_UH2, true);
190
191
192 /* Enable the chip */
193 err = gpio_request(USBH2_CS, "USB-H2-CS");
194 if (err) {
195 pr_err("Failed to request the usb host 2 CS gpio\n");
196 return err;
197 }
198
199 err = gpio_direction_output(USBH2_CS, 0/*Enabled*/);
200 if (err) {
201 pr_err("Failed to drive the usb host 2 CS gpio\n");
202 goto h2_free_cs;
203 }
204
205 /* H2 phy reset*/
206 err = gpio_request(USBH2_RESET, "USB-H2-RESET");
207 if (err) {
208 pr_err("Failed to request the usb host 2 reset gpio\n");
209 goto h2_free_cs;
210 }
211
212 err = gpio_direction_output(USBH2_RESET, 1/*HIGH*/);
213 if (err) {
214 pr_err("Failed to reset the usb host 2 phy\n");
215 goto h2_free_reset;
216 }
217
218 gpio_set_value(USBH2_RESET, 0/*LOW*/);
219 mdelay(5);
220 gpio_set_value(USBH2_RESET, 1/*HIGH*/);
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100221 mdelay(10);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100222
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100223 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
224 MXC_EHCI_INTERFACE_DIFF_UNI);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100225
226h2_free_reset:
227 gpio_free(USBH2_RESET);
228h2_free_cs:
229 gpio_free(USBH2_CS);
230 return err;
231}
232
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100233static struct mxc_usbh_platform_data usbotg_pdata __initdata = {
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100234 .init = usbotg_init,
235 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100236};
237
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100238static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100239 .init = usbh2_init,
240 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100241};
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100242
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200243/* RTC over I2C*/
244#define ARMADILLO5X0_RTC_GPIO IOMUX_TO_GPIO(MX31_PIN_SRXD4)
245
246static struct i2c_board_info armadillo5x0_i2c_rtc = {
247 I2C_BOARD_INFO("s35390a", 0x30),
248};
249
Alberto Panizzoe33c0492009-10-15 19:24:51 +0200250/* GPIO BUTTONS */
251static struct gpio_keys_button armadillo5x0_buttons[] = {
252 {
253 .code = KEY_ENTER, /*28*/
254 .gpio = IOMUX_TO_GPIO(MX31_PIN_SCLK0),
255 .active_low = 1,
256 .desc = "menu",
257 .wakeup = 1,
258 }, {
259 .code = KEY_BACK, /*158*/
260 .gpio = IOMUX_TO_GPIO(MX31_PIN_SRST0),
261 .active_low = 1,
262 .desc = "back",
263 .wakeup = 1,
264 }
265};
266
Uwe Kleine-König53094982011-02-28 18:04:33 +0100267static const struct gpio_keys_platform_data
268 armadillo5x0_button_data __initconst = {
Alberto Panizzoe33c0492009-10-15 19:24:51 +0200269 .buttons = armadillo5x0_buttons,
270 .nbuttons = ARRAY_SIZE(armadillo5x0_buttons),
271};
272
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200273/*
274 * NAND Flash
275 */
Uwe Kleine-Königa2ceeef2010-06-16 12:23:11 +0200276static const struct mxc_nand_platform_data
277armadillo5x0_nand_board_info __initconst = {
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200278 .width = 1,
279 .hw_ecc = 1,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200280};
281
282/*
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200283 * MTD NOR Flash
284 */
285static struct mtd_partition armadillo5x0_nor_flash_partitions[] = {
286 {
287 .name = "nor.bootloader",
288 .offset = 0x00000000,
289 .size = 4*32*1024,
290 }, {
291 .name = "nor.kernel",
292 .offset = MTDPART_OFS_APPEND,
293 .size = 16*128*1024,
294 }, {
295 .name = "nor.userland",
296 .offset = MTDPART_OFS_APPEND,
297 .size = 110*128*1024,
298 }, {
299 .name = "nor.config",
300 .offset = MTDPART_OFS_APPEND,
301 .size = 1*128*1024,
302 },
303};
304
Uwe Kleine-König47ccfc32011-07-31 00:20:30 +0200305static const struct physmap_flash_data
306 armadillo5x0_nor_flash_pdata __initconst = {
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200307 .width = 2,
308 .parts = armadillo5x0_nor_flash_partitions,
309 .nr_parts = ARRAY_SIZE(armadillo5x0_nor_flash_partitions),
310};
311
Uwe Kleine-König47ccfc32011-07-31 00:20:30 +0200312static const struct resource armadillo5x0_nor_flash_resource __initconst = {
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200313 .flags = IORESOURCE_MEM,
Uwe Kleine-Königf568dd72009-12-09 11:57:21 +0100314 .start = MX31_CS0_BASE_ADDR,
315 .end = MX31_CS0_BASE_ADDR + SZ_64M - 1,
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200316};
317
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200318/*
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200319 * FB support
320 */
321static const struct fb_videomode fb_modedb[] = {
322 { /* 640x480 @ 60 Hz */
323 .name = "CRT-VGA",
324 .refresh = 60,
325 .xres = 640,
326 .yres = 480,
327 .pixclock = 39721,
328 .left_margin = 35,
329 .right_margin = 115,
330 .upper_margin = 43,
331 .lower_margin = 1,
332 .hsync_len = 10,
333 .vsync_len = 1,
334 .sync = FB_SYNC_OE_ACT_HIGH,
335 .vmode = FB_VMODE_NONINTERLACED,
336 .flag = 0,
337 }, {/* 800x600 @ 56 Hz */
338 .name = "CRT-SVGA",
339 .refresh = 56,
340 .xres = 800,
341 .yres = 600,
342 .pixclock = 30000,
343 .left_margin = 30,
344 .right_margin = 108,
345 .upper_margin = 13,
346 .lower_margin = 10,
347 .hsync_len = 10,
348 .vsync_len = 1,
349 .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_HOR_HIGH_ACT |
350 FB_SYNC_VERT_HIGH_ACT,
351 .vmode = FB_VMODE_NONINTERLACED,
352 .flag = 0,
353 },
354};
355
Uwe Kleine-Königafa77ef2011-03-03 21:32:02 +0100356static struct mx3fb_platform_data mx3fb_pdata __initdata = {
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200357 .name = "CRT-VGA",
358 .mode = fb_modedb,
359 .num_modes = ARRAY_SIZE(fb_modedb),
360};
361
362/*
363 * SDHC 1
364 * MMC support
365 */
366static int armadillo5x0_sdhc1_get_ro(struct device *dev)
367{
368 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
369}
370
371static int armadillo5x0_sdhc1_init(struct device *dev,
372 irq_handler_t detect_irq, void *data)
373{
374 int ret;
375 int gpio_det, gpio_wp;
376
377 gpio_det = IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK);
378 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B);
379
380 ret = gpio_request(gpio_det, "sdhc-card-detect");
381 if (ret)
382 return ret;
383
384 gpio_direction_input(gpio_det);
385
386 ret = gpio_request(gpio_wp, "sdhc-write-protect");
387 if (ret)
388 goto err_gpio_free;
389
390 gpio_direction_input(gpio_wp);
391
392 /* When supported the trigger type have to be BOTH */
Shawn Guoed175342011-12-02 20:00:33 +0800393 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)),
Michael Opdenacker4c1dd3e2013-09-04 07:04:39 +0200394 detect_irq, IRQF_TRIGGER_FALLING,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200395 "sdhc-detect", data);
396
397 if (ret)
398 goto err_gpio_free_2;
399
400 return 0;
401
402err_gpio_free_2:
403 gpio_free(gpio_wp);
404
405err_gpio_free:
406 gpio_free(gpio_det);
407
408 return ret;
409
410}
411
412static void armadillo5x0_sdhc1_exit(struct device *dev, void *data)
413{
Shawn Guoed175342011-12-02 20:00:33 +0800414 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)), data);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200415 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK));
416 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
417}
418
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100419static const struct imxmmc_platform_data sdhc_pdata __initconst = {
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200420 .get_ro = armadillo5x0_sdhc1_get_ro,
421 .init = armadillo5x0_sdhc1_init,
422 .exit = armadillo5x0_sdhc1_exit,
423};
424
425/*
426 * SMSC 9118
427 * Network support
428 */
429static struct resource armadillo5x0_smc911x_resources[] = {
430 {
Uwe Kleine-Königf568dd72009-12-09 11:57:21 +0100431 .start = MX31_CS3_BASE_ADDR,
432 .end = MX31_CS3_BASE_ADDR + SZ_32M - 1,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200433 .flags = IORESOURCE_MEM,
434 }, {
Shawn Guoed175342011-12-02 20:00:33 +0800435 /* irq number is run-time assigned */
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200436 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
437 },
438};
439
440static struct smsc911x_platform_config smsc911x_info = {
Alberto Panizzo07299ca2009-10-15 19:29:05 +0200441 .flags = SMSC911X_USE_16BIT,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200442 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
443 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
444};
445
446static struct platform_device armadillo5x0_smc911x_device = {
447 .name = "smsc911x",
448 .id = -1,
449 .num_resources = ARRAY_SIZE(armadillo5x0_smc911x_resources),
450 .resource = armadillo5x0_smc911x_resources,
451 .dev = {
452 .platform_data = &smsc911x_info,
453 },
454};
455
456/* UART device data */
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +0200457static const struct imxuart_platform_data uart_pdata __initconst = {
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200458 .flags = IMXUART_HAVE_RTSCTS,
459};
460
461static struct platform_device *devices[] __initdata = {
462 &armadillo5x0_smc911x_device,
463};
464
Fabio Estevam7a4302a2012-04-02 10:39:47 -0300465static struct regulator_consumer_supply dummy_supplies[] = {
466 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
467 REGULATOR_SUPPLY("vddvario", "smsc911x"),
468};
469
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200470/*
471 * Perform board specific initializations
472 */
473static void __init armadillo5x0_init(void)
474{
Shawn Guob78d8e52011-06-06 00:07:55 +0800475 imx31_soc_init();
476
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200477 mxc_iomux_setup_multiple_pins(armadillo5x0_pins,
478 ARRAY_SIZE(armadillo5x0_pins), "armadillo5x0");
479
Fabio Estevam7a4302a2012-04-02 10:39:47 -0300480 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
481
Uwe Kleine-König4a9b8b02010-06-16 18:03:05 +0200482 imx31_add_imx_i2c1(NULL);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200483
484 /* Register UART */
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +0200485 imx31_add_imx_uart0(&uart_pdata);
486 imx31_add_imx_uart1(&uart_pdata);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200487
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200488 /* Register FB */
Shawn Guo88289c82012-06-13 14:07:31 +0800489 imx31_add_ipu_core();
Uwe Kleine-Königafa77ef2011-03-03 21:32:02 +0100490 imx31_add_mx3_sdc_fb(&mx3fb_pdata);
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200491
492 /* Register NOR Flash */
Uwe Kleine-König47ccfc32011-07-31 00:20:30 +0200493 platform_device_register_resndata(NULL, "physmap-flash", -1,
494 &armadillo5x0_nor_flash_resource, 1,
495 &armadillo5x0_nor_flash_pdata,
496 sizeof(armadillo5x0_nor_flash_pdata));
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200497
498 /* Register NAND Flash */
Uwe Kleine-Königa2ceeef2010-06-16 12:23:11 +0200499 imx31_add_mxc_nand(&armadillo5x0_nand_board_info);
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200500
501 /* set NAND page size to 2k if not configured via boot mode pins */
Johannes Bergc5531382016-01-27 17:59:35 +0100502 imx_writel(imx_readl(mx3_ccm_base + MXC_CCM_RCSR) | (1 << 30),
503 mx3_ccm_base + MXC_CCM_RCSR);
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300504}
505
506static void __init armadillo5x0_late(void)
507{
508 armadillo5x0_smc911x_resources[1].start =
509 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
510 armadillo5x0_smc911x_resources[1].end =
511 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
512 platform_add_devices(devices, ARRAY_SIZE(devices));
513
514 imx_add_gpio_keys(&armadillo5x0_button_data);
515
516 /* SMSC9118 IRQ pin */
517 gpio_direction_input(MX31_PIN_GPIO1_0);
518
519 /* Register SDHC */
520 imx31_add_mxc_mmc(0, &sdhc_pdata);
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200521
522 /* RTC */
523 /* Get RTC IRQ and register the chip */
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300524 if (!gpio_request(ARMADILLO5X0_RTC_GPIO, "rtc")) {
525 if (!gpio_direction_input(ARMADILLO5X0_RTC_GPIO))
526 armadillo5x0_i2c_rtc.irq =
527 gpio_to_irq(ARMADILLO5X0_RTC_GPIO);
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200528 else
529 gpio_free(ARMADILLO5X0_RTC_GPIO);
530 }
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300531
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200532 if (armadillo5x0_i2c_rtc.irq == 0)
Joe Perches75fd32b2014-09-13 11:31:15 -0700533 pr_warn("armadillo5x0_init: failed to get RTC IRQ\n");
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200534 i2c_register_board_info(1, &armadillo5x0_i2c_rtc, 1);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100535
536 /* USB */
Sascha Hauer48f6b092011-03-02 09:27:42 +0100537 usbotg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
538 ULPI_OTG_DRVVBUS_EXT);
539 if (usbotg_pdata.otg)
540 imx31_add_mxc_ehci_otg(&usbotg_pdata);
541 usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
542 ULPI_OTG_DRVVBUS_EXT);
543 if (usbh2_pdata.otg)
544 imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200545}
546
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200547static void __init armadillo5x0_timer_init(void)
548{
549 mx31_clocks_init(26000000);
550}
551
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200552MACHINE_START(ARMADILLO5X0, "Armadillo-500")
553 /* Maintainer: Alberto Panizzo */
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400554 .atag_offset = 0x100,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100555 .map_io = mx31_map_io,
556 .init_early = imx31_init_early,
557 .init_irq = mx31_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700558 .init_time = armadillo5x0_timer_init,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100559 .init_machine = armadillo5x0_init,
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300560 .init_late = armadillo5x0_late,
Russell King65ea7882011-11-06 17:12:08 +0000561 .restart = mxc_restart,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200562MACHINE_END