blob: 17a97ba2cecfe81198752bda6afab5eef3b80b68 [file] [log] [blame]
Alberto Panizzo5e9145e2009-05-19 10:01:03 +02001/*
2 * armadillo5x0.c
3 *
4 * Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
5 * updates in http://alberdroid.blogspot.com/
6 *
7 * Based on Atmark Techno, Inc. armadillo 500 BSP 2008
8 * Based on mx31ads.c and pcm037.c Great Work!
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 * MA 02110-1301, USA.
24 */
25
26#include <linux/types.h>
27#include <linux/init.h>
28#include <linux/clk.h>
29#include <linux/platform_device.h>
30#include <linux/gpio.h>
31#include <linux/smsc911x.h>
32#include <linux/interrupt.h>
33#include <linux/irq.h>
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +020034#include <linux/mtd/physmap.h>
Alberto Panizzo0c8bad62009-06-17 15:06:30 +020035#include <linux/io.h>
Alberto Panizzoe33c0492009-10-15 19:24:51 +020036#include <linux/input.h>
Alberto Panizzo2097abc2009-10-15 19:33:24 +020037#include <linux/i2c.h>
Alberto Panizzob3aa1112010-02-26 18:36:32 +010038#include <linux/usb/otg.h>
39#include <linux/usb/ulpi.h>
40#include <linux/delay.h>
Fabio Estevam7a4302a2012-04-02 10:39:47 -030041#include <linux/regulator/machine.h>
42#include <linux/regulator/fixed.h>
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020043
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020044#include <asm/mach-types.h>
45#include <asm/mach/arch.h>
46#include <asm/mach/time.h>
47#include <asm/memory.h>
48#include <asm/mach/map.h>
49
Shawn Guoe3372472012-09-13 21:01:00 +080050#include "common.h"
Uwe Kleine-Königa2ceeef2010-06-16 12:23:11 +020051#include "devices-imx31.h"
Fabio Estevam29781fa2012-01-20 16:43:09 -020052#include "crmregs-imx3.h"
Shawn Guo641dfe82014-05-19 20:41:52 +080053#include "ehci.h"
Shawn Guo50f2de62012-09-14 14:14:45 +080054#include "hardware.h"
Shawn Guo267dd342012-09-13 13:26:00 +080055#include "iomux-mx3.h"
Shawn Guo39ef6342012-09-13 21:46:09 +080056#include "ulpi.h"
Alberto Panizzo5e9145e2009-05-19 10:01:03 +020057
58static int armadillo5x0_pins[] = {
59 /* UART1 */
60 MX31_PIN_CTS1__CTS1,
61 MX31_PIN_RTS1__RTS1,
62 MX31_PIN_TXD1__TXD1,
63 MX31_PIN_RXD1__RXD1,
64 /* UART2 */
65 MX31_PIN_CTS2__CTS2,
66 MX31_PIN_RTS2__RTS2,
67 MX31_PIN_TXD2__TXD2,
68 MX31_PIN_RXD2__RXD2,
69 /* LAN9118_IRQ */
70 IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO),
71 /* SDHC1 */
72 MX31_PIN_SD1_DATA3__SD1_DATA3,
73 MX31_PIN_SD1_DATA2__SD1_DATA2,
74 MX31_PIN_SD1_DATA1__SD1_DATA1,
75 MX31_PIN_SD1_DATA0__SD1_DATA0,
76 MX31_PIN_SD1_CLK__SD1_CLK,
77 MX31_PIN_SD1_CMD__SD1_CMD,
78 /* Framebuffer */
79 MX31_PIN_LD0__LD0,
80 MX31_PIN_LD1__LD1,
81 MX31_PIN_LD2__LD2,
82 MX31_PIN_LD3__LD3,
83 MX31_PIN_LD4__LD4,
84 MX31_PIN_LD5__LD5,
85 MX31_PIN_LD6__LD6,
86 MX31_PIN_LD7__LD7,
87 MX31_PIN_LD8__LD8,
88 MX31_PIN_LD9__LD9,
89 MX31_PIN_LD10__LD10,
90 MX31_PIN_LD11__LD11,
91 MX31_PIN_LD12__LD12,
92 MX31_PIN_LD13__LD13,
93 MX31_PIN_LD14__LD14,
94 MX31_PIN_LD15__LD15,
95 MX31_PIN_LD16__LD16,
96 MX31_PIN_LD17__LD17,
97 MX31_PIN_VSYNC3__VSYNC3,
98 MX31_PIN_HSYNC__HSYNC,
99 MX31_PIN_FPSHIFT__FPSHIFT,
100 MX31_PIN_DRDY0__DRDY0,
101 IOMUX_MODE(MX31_PIN_LCS1, IOMUX_CONFIG_GPIO), /*ADV7125_PSAVE*/
Alberto Panizzoe9a6c5d2009-10-15 19:31:07 +0200102 /* I2C2 */
103 MX31_PIN_CSPI2_MOSI__SCL,
104 MX31_PIN_CSPI2_MISO__SDA,
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100105 /* OTG */
106 MX31_PIN_USBOTG_DATA0__USBOTG_DATA0,
107 MX31_PIN_USBOTG_DATA1__USBOTG_DATA1,
108 MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,
109 MX31_PIN_USBOTG_DATA3__USBOTG_DATA3,
110 MX31_PIN_USBOTG_DATA4__USBOTG_DATA4,
111 MX31_PIN_USBOTG_DATA5__USBOTG_DATA5,
112 MX31_PIN_USBOTG_DATA6__USBOTG_DATA6,
113 MX31_PIN_USBOTG_DATA7__USBOTG_DATA7,
114 MX31_PIN_USBOTG_CLK__USBOTG_CLK,
115 MX31_PIN_USBOTG_DIR__USBOTG_DIR,
116 MX31_PIN_USBOTG_NXT__USBOTG_NXT,
117 MX31_PIN_USBOTG_STP__USBOTG_STP,
118 /* USB host 2 */
119 IOMUX_MODE(MX31_PIN_USBH2_CLK, IOMUX_CONFIG_FUNC),
120 IOMUX_MODE(MX31_PIN_USBH2_DIR, IOMUX_CONFIG_FUNC),
121 IOMUX_MODE(MX31_PIN_USBH2_NXT, IOMUX_CONFIG_FUNC),
122 IOMUX_MODE(MX31_PIN_USBH2_STP, IOMUX_CONFIG_FUNC),
123 IOMUX_MODE(MX31_PIN_USBH2_DATA0, IOMUX_CONFIG_FUNC),
124 IOMUX_MODE(MX31_PIN_USBH2_DATA1, IOMUX_CONFIG_FUNC),
125 IOMUX_MODE(MX31_PIN_STXD3, IOMUX_CONFIG_FUNC),
126 IOMUX_MODE(MX31_PIN_SRXD3, IOMUX_CONFIG_FUNC),
127 IOMUX_MODE(MX31_PIN_SCK3, IOMUX_CONFIG_FUNC),
128 IOMUX_MODE(MX31_PIN_SFS3, IOMUX_CONFIG_FUNC),
129 IOMUX_MODE(MX31_PIN_STXD6, IOMUX_CONFIG_FUNC),
130 IOMUX_MODE(MX31_PIN_SRXD6, IOMUX_CONFIG_FUNC),
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200131};
Alberto Panizzoe9a6c5d2009-10-15 19:31:07 +0200132
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100133/* USB */
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100134
135#define OTG_RESET IOMUX_TO_GPIO(MX31_PIN_STXD4)
136#define USBH2_RESET IOMUX_TO_GPIO(MX31_PIN_SCK6)
137#define USBH2_CS IOMUX_TO_GPIO(MX31_PIN_GPIO1_3)
138
139#define USB_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS | \
140 PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU)
141
142static int usbotg_init(struct platform_device *pdev)
143{
144 int err;
145
146 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA0, USB_PAD_CFG);
147 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA1, USB_PAD_CFG);
148 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA2, USB_PAD_CFG);
149 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA3, USB_PAD_CFG);
150 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA4, USB_PAD_CFG);
151 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA5, USB_PAD_CFG);
152 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA6, USB_PAD_CFG);
153 mxc_iomux_set_pad(MX31_PIN_USBOTG_DATA7, USB_PAD_CFG);
154 mxc_iomux_set_pad(MX31_PIN_USBOTG_CLK, USB_PAD_CFG);
155 mxc_iomux_set_pad(MX31_PIN_USBOTG_DIR, USB_PAD_CFG);
156 mxc_iomux_set_pad(MX31_PIN_USBOTG_NXT, USB_PAD_CFG);
157 mxc_iomux_set_pad(MX31_PIN_USBOTG_STP, USB_PAD_CFG);
158
159 /* Chip already enabled by hardware */
160 /* OTG phy reset*/
161 err = gpio_request(OTG_RESET, "USB-OTG-RESET");
162 if (err) {
163 pr_err("Failed to request the usb otg reset gpio\n");
164 return err;
165 }
166
167 err = gpio_direction_output(OTG_RESET, 1/*HIGH*/);
168 if (err) {
169 pr_err("Failed to reset the usb otg phy\n");
170 goto otg_free_reset;
171 }
172
173 gpio_set_value(OTG_RESET, 0/*LOW*/);
174 mdelay(5);
175 gpio_set_value(OTG_RESET, 1/*HIGH*/);
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100176 mdelay(10);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100177
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100178 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
179 MXC_EHCI_INTERFACE_DIFF_UNI);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100180
181otg_free_reset:
182 gpio_free(OTG_RESET);
183 return err;
184}
185
186static int usbh2_init(struct platform_device *pdev)
187{
188 int err;
189
190 mxc_iomux_set_pad(MX31_PIN_USBH2_CLK, USB_PAD_CFG);
191 mxc_iomux_set_pad(MX31_PIN_USBH2_DIR, USB_PAD_CFG);
192 mxc_iomux_set_pad(MX31_PIN_USBH2_NXT, USB_PAD_CFG);
193 mxc_iomux_set_pad(MX31_PIN_USBH2_STP, USB_PAD_CFG);
194 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA0, USB_PAD_CFG);
195 mxc_iomux_set_pad(MX31_PIN_USBH2_DATA1, USB_PAD_CFG);
196 mxc_iomux_set_pad(MX31_PIN_SRXD6, USB_PAD_CFG);
197 mxc_iomux_set_pad(MX31_PIN_STXD6, USB_PAD_CFG);
198 mxc_iomux_set_pad(MX31_PIN_SFS3, USB_PAD_CFG);
199 mxc_iomux_set_pad(MX31_PIN_SCK3, USB_PAD_CFG);
200 mxc_iomux_set_pad(MX31_PIN_SRXD3, USB_PAD_CFG);
201 mxc_iomux_set_pad(MX31_PIN_STXD3, USB_PAD_CFG);
202
203 mxc_iomux_set_gpr(MUX_PGP_UH2, true);
204
205
206 /* Enable the chip */
207 err = gpio_request(USBH2_CS, "USB-H2-CS");
208 if (err) {
209 pr_err("Failed to request the usb host 2 CS gpio\n");
210 return err;
211 }
212
213 err = gpio_direction_output(USBH2_CS, 0/*Enabled*/);
214 if (err) {
215 pr_err("Failed to drive the usb host 2 CS gpio\n");
216 goto h2_free_cs;
217 }
218
219 /* H2 phy reset*/
220 err = gpio_request(USBH2_RESET, "USB-H2-RESET");
221 if (err) {
222 pr_err("Failed to request the usb host 2 reset gpio\n");
223 goto h2_free_cs;
224 }
225
226 err = gpio_direction_output(USBH2_RESET, 1/*HIGH*/);
227 if (err) {
228 pr_err("Failed to reset the usb host 2 phy\n");
229 goto h2_free_reset;
230 }
231
232 gpio_set_value(USBH2_RESET, 0/*LOW*/);
233 mdelay(5);
234 gpio_set_value(USBH2_RESET, 1/*HIGH*/);
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100235 mdelay(10);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100236
Sascha Hauer4bd597b2011-01-03 11:30:28 +0100237 return mx31_initialize_usb_hw(pdev->id, MXC_EHCI_POWER_PINS_ENABLED |
238 MXC_EHCI_INTERFACE_DIFF_UNI);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100239
240h2_free_reset:
241 gpio_free(USBH2_RESET);
242h2_free_cs:
243 gpio_free(USBH2_CS);
244 return err;
245}
246
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100247static struct mxc_usbh_platform_data usbotg_pdata __initdata = {
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100248 .init = usbotg_init,
249 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100250};
251
Uwe Kleine-König2d58de22010-11-15 11:57:49 +0100252static struct mxc_usbh_platform_data usbh2_pdata __initdata = {
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100253 .init = usbh2_init,
254 .portsc = MXC_EHCI_MODE_ULPI | MXC_EHCI_UTMI_8BIT,
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100255};
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100256
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200257/* RTC over I2C*/
258#define ARMADILLO5X0_RTC_GPIO IOMUX_TO_GPIO(MX31_PIN_SRXD4)
259
260static struct i2c_board_info armadillo5x0_i2c_rtc = {
261 I2C_BOARD_INFO("s35390a", 0x30),
262};
263
Alberto Panizzoe33c0492009-10-15 19:24:51 +0200264/* GPIO BUTTONS */
265static struct gpio_keys_button armadillo5x0_buttons[] = {
266 {
267 .code = KEY_ENTER, /*28*/
268 .gpio = IOMUX_TO_GPIO(MX31_PIN_SCLK0),
269 .active_low = 1,
270 .desc = "menu",
271 .wakeup = 1,
272 }, {
273 .code = KEY_BACK, /*158*/
274 .gpio = IOMUX_TO_GPIO(MX31_PIN_SRST0),
275 .active_low = 1,
276 .desc = "back",
277 .wakeup = 1,
278 }
279};
280
Uwe Kleine-König53094982011-02-28 18:04:33 +0100281static const struct gpio_keys_platform_data
282 armadillo5x0_button_data __initconst = {
Alberto Panizzoe33c0492009-10-15 19:24:51 +0200283 .buttons = armadillo5x0_buttons,
284 .nbuttons = ARRAY_SIZE(armadillo5x0_buttons),
285};
286
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200287/*
288 * NAND Flash
289 */
Uwe Kleine-Königa2ceeef2010-06-16 12:23:11 +0200290static const struct mxc_nand_platform_data
291armadillo5x0_nand_board_info __initconst = {
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200292 .width = 1,
293 .hw_ecc = 1,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200294};
295
296/*
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200297 * MTD NOR Flash
298 */
299static struct mtd_partition armadillo5x0_nor_flash_partitions[] = {
300 {
301 .name = "nor.bootloader",
302 .offset = 0x00000000,
303 .size = 4*32*1024,
304 }, {
305 .name = "nor.kernel",
306 .offset = MTDPART_OFS_APPEND,
307 .size = 16*128*1024,
308 }, {
309 .name = "nor.userland",
310 .offset = MTDPART_OFS_APPEND,
311 .size = 110*128*1024,
312 }, {
313 .name = "nor.config",
314 .offset = MTDPART_OFS_APPEND,
315 .size = 1*128*1024,
316 },
317};
318
Uwe Kleine-König47ccfc32011-07-31 00:20:30 +0200319static const struct physmap_flash_data
320 armadillo5x0_nor_flash_pdata __initconst = {
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200321 .width = 2,
322 .parts = armadillo5x0_nor_flash_partitions,
323 .nr_parts = ARRAY_SIZE(armadillo5x0_nor_flash_partitions),
324};
325
Uwe Kleine-König47ccfc32011-07-31 00:20:30 +0200326static const struct resource armadillo5x0_nor_flash_resource __initconst = {
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200327 .flags = IORESOURCE_MEM,
Uwe Kleine-Königf568dd72009-12-09 11:57:21 +0100328 .start = MX31_CS0_BASE_ADDR,
329 .end = MX31_CS0_BASE_ADDR + SZ_64M - 1,
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200330};
331
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200332/*
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200333 * FB support
334 */
335static const struct fb_videomode fb_modedb[] = {
336 { /* 640x480 @ 60 Hz */
337 .name = "CRT-VGA",
338 .refresh = 60,
339 .xres = 640,
340 .yres = 480,
341 .pixclock = 39721,
342 .left_margin = 35,
343 .right_margin = 115,
344 .upper_margin = 43,
345 .lower_margin = 1,
346 .hsync_len = 10,
347 .vsync_len = 1,
348 .sync = FB_SYNC_OE_ACT_HIGH,
349 .vmode = FB_VMODE_NONINTERLACED,
350 .flag = 0,
351 }, {/* 800x600 @ 56 Hz */
352 .name = "CRT-SVGA",
353 .refresh = 56,
354 .xres = 800,
355 .yres = 600,
356 .pixclock = 30000,
357 .left_margin = 30,
358 .right_margin = 108,
359 .upper_margin = 13,
360 .lower_margin = 10,
361 .hsync_len = 10,
362 .vsync_len = 1,
363 .sync = FB_SYNC_OE_ACT_HIGH | FB_SYNC_HOR_HIGH_ACT |
364 FB_SYNC_VERT_HIGH_ACT,
365 .vmode = FB_VMODE_NONINTERLACED,
366 .flag = 0,
367 },
368};
369
Uwe Kleine-Königafa77ef2011-03-03 21:32:02 +0100370static struct mx3fb_platform_data mx3fb_pdata __initdata = {
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200371 .name = "CRT-VGA",
372 .mode = fb_modedb,
373 .num_modes = ARRAY_SIZE(fb_modedb),
374};
375
376/*
377 * SDHC 1
378 * MMC support
379 */
380static int armadillo5x0_sdhc1_get_ro(struct device *dev)
381{
382 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
383}
384
385static int armadillo5x0_sdhc1_init(struct device *dev,
386 irq_handler_t detect_irq, void *data)
387{
388 int ret;
389 int gpio_det, gpio_wp;
390
391 gpio_det = IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK);
392 gpio_wp = IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B);
393
394 ret = gpio_request(gpio_det, "sdhc-card-detect");
395 if (ret)
396 return ret;
397
398 gpio_direction_input(gpio_det);
399
400 ret = gpio_request(gpio_wp, "sdhc-write-protect");
401 if (ret)
402 goto err_gpio_free;
403
404 gpio_direction_input(gpio_wp);
405
406 /* When supported the trigger type have to be BOTH */
Shawn Guoed175342011-12-02 20:00:33 +0800407 ret = request_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)),
Michael Opdenacker4c1dd3e2013-09-04 07:04:39 +0200408 detect_irq, IRQF_TRIGGER_FALLING,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200409 "sdhc-detect", data);
410
411 if (ret)
412 goto err_gpio_free_2;
413
414 return 0;
415
416err_gpio_free_2:
417 gpio_free(gpio_wp);
418
419err_gpio_free:
420 gpio_free(gpio_det);
421
422 return ret;
423
424}
425
426static void armadillo5x0_sdhc1_exit(struct device *dev, void *data)
427{
Shawn Guoed175342011-12-02 20:00:33 +0800428 free_irq(gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK)), data);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200429 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK));
430 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B));
431}
432
Uwe Kleine-König6a697e32010-11-12 11:10:55 +0100433static const struct imxmmc_platform_data sdhc_pdata __initconst = {
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200434 .get_ro = armadillo5x0_sdhc1_get_ro,
435 .init = armadillo5x0_sdhc1_init,
436 .exit = armadillo5x0_sdhc1_exit,
437};
438
439/*
440 * SMSC 9118
441 * Network support
442 */
443static struct resource armadillo5x0_smc911x_resources[] = {
444 {
Uwe Kleine-Königf568dd72009-12-09 11:57:21 +0100445 .start = MX31_CS3_BASE_ADDR,
446 .end = MX31_CS3_BASE_ADDR + SZ_32M - 1,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200447 .flags = IORESOURCE_MEM,
448 }, {
Shawn Guoed175342011-12-02 20:00:33 +0800449 /* irq number is run-time assigned */
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200450 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
451 },
452};
453
454static struct smsc911x_platform_config smsc911x_info = {
Alberto Panizzo07299ca2009-10-15 19:29:05 +0200455 .flags = SMSC911X_USE_16BIT,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200456 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
457 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
458};
459
460static struct platform_device armadillo5x0_smc911x_device = {
461 .name = "smsc911x",
462 .id = -1,
463 .num_resources = ARRAY_SIZE(armadillo5x0_smc911x_resources),
464 .resource = armadillo5x0_smc911x_resources,
465 .dev = {
466 .platform_data = &smsc911x_info,
467 },
468};
469
470/* UART device data */
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +0200471static const struct imxuart_platform_data uart_pdata __initconst = {
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200472 .flags = IMXUART_HAVE_RTSCTS,
473};
474
475static struct platform_device *devices[] __initdata = {
476 &armadillo5x0_smc911x_device,
477};
478
Fabio Estevam7a4302a2012-04-02 10:39:47 -0300479static struct regulator_consumer_supply dummy_supplies[] = {
480 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
481 REGULATOR_SUPPLY("vddvario", "smsc911x"),
482};
483
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200484/*
485 * Perform board specific initializations
486 */
487static void __init armadillo5x0_init(void)
488{
Shawn Guob78d8e52011-06-06 00:07:55 +0800489 imx31_soc_init();
490
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200491 mxc_iomux_setup_multiple_pins(armadillo5x0_pins,
492 ARRAY_SIZE(armadillo5x0_pins), "armadillo5x0");
493
Fabio Estevam7a4302a2012-04-02 10:39:47 -0300494 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
495
Uwe Kleine-König4a9b8b02010-06-16 18:03:05 +0200496 imx31_add_imx_i2c1(NULL);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200497
498 /* Register UART */
Uwe Kleine-König16cf5c42010-06-23 11:46:16 +0200499 imx31_add_imx_uart0(&uart_pdata);
500 imx31_add_imx_uart1(&uart_pdata);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200501
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200502 /* Register FB */
Shawn Guo88289c82012-06-13 14:07:31 +0800503 imx31_add_ipu_core();
Uwe Kleine-Königafa77ef2011-03-03 21:32:02 +0100504 imx31_add_mx3_sdc_fb(&mx3fb_pdata);
Alberto Panizzoc3a9c7f2009-06-17 15:05:21 +0200505
506 /* Register NOR Flash */
Uwe Kleine-König47ccfc32011-07-31 00:20:30 +0200507 platform_device_register_resndata(NULL, "physmap-flash", -1,
508 &armadillo5x0_nor_flash_resource, 1,
509 &armadillo5x0_nor_flash_pdata,
510 sizeof(armadillo5x0_nor_flash_pdata));
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200511
512 /* Register NAND Flash */
Uwe Kleine-Königa2ceeef2010-06-16 12:23:11 +0200513 imx31_add_mxc_nand(&armadillo5x0_nand_board_info);
Alberto Panizzo0c8bad62009-06-17 15:06:30 +0200514
515 /* set NAND page size to 2k if not configured via boot mode pins */
Johannes Bergc5531382016-01-27 17:59:35 +0100516 imx_writel(imx_readl(mx3_ccm_base + MXC_CCM_RCSR) | (1 << 30),
517 mx3_ccm_base + MXC_CCM_RCSR);
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300518}
519
520static void __init armadillo5x0_late(void)
521{
522 armadillo5x0_smc911x_resources[1].start =
523 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
524 armadillo5x0_smc911x_resources[1].end =
525 gpio_to_irq(IOMUX_TO_GPIO(MX31_PIN_GPIO1_0));
526 platform_add_devices(devices, ARRAY_SIZE(devices));
527
528 imx_add_gpio_keys(&armadillo5x0_button_data);
529
530 /* SMSC9118 IRQ pin */
531 gpio_direction_input(MX31_PIN_GPIO1_0);
532
533 /* Register SDHC */
534 imx31_add_mxc_mmc(0, &sdhc_pdata);
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200535
536 /* RTC */
537 /* Get RTC IRQ and register the chip */
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300538 if (!gpio_request(ARMADILLO5X0_RTC_GPIO, "rtc")) {
539 if (!gpio_direction_input(ARMADILLO5X0_RTC_GPIO))
540 armadillo5x0_i2c_rtc.irq =
541 gpio_to_irq(ARMADILLO5X0_RTC_GPIO);
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200542 else
543 gpio_free(ARMADILLO5X0_RTC_GPIO);
544 }
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300545
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200546 if (armadillo5x0_i2c_rtc.irq == 0)
Joe Perches75fd32b2014-09-13 11:31:15 -0700547 pr_warn("armadillo5x0_init: failed to get RTC IRQ\n");
Alberto Panizzo2097abc2009-10-15 19:33:24 +0200548 i2c_register_board_info(1, &armadillo5x0_i2c_rtc, 1);
Alberto Panizzob3aa1112010-02-26 18:36:32 +0100549
550 /* USB */
Sascha Hauer48f6b092011-03-02 09:27:42 +0100551 usbotg_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
552 ULPI_OTG_DRVVBUS_EXT);
553 if (usbotg_pdata.otg)
554 imx31_add_mxc_ehci_otg(&usbotg_pdata);
555 usbh2_pdata.otg = imx_otg_ulpi_create(ULPI_OTG_DRVVBUS |
556 ULPI_OTG_DRVVBUS_EXT);
557 if (usbh2_pdata.otg)
558 imx31_add_mxc_ehci_hs(2, &usbh2_pdata);
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200559}
560
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200561static void __init armadillo5x0_timer_init(void)
562{
563 mx31_clocks_init(26000000);
564}
565
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200566MACHINE_START(ARMADILLO5X0, "Armadillo-500")
567 /* Maintainer: Alberto Panizzo */
Nicolas Pitredc8f1902011-07-05 22:38:12 -0400568 .atag_offset = 0x100,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100569 .map_io = mx31_map_io,
570 .init_early = imx31_init_early,
571 .init_irq = mx31_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700572 .init_time = armadillo5x0_timer_init,
Uwe Kleine-König97976e22011-02-07 16:35:20 +0100573 .init_machine = armadillo5x0_init,
Vladimir Zapolskiya95a9322016-09-19 04:37:20 +0300574 .init_late = armadillo5x0_late,
Russell King65ea7882011-11-06 17:12:08 +0000575 .restart = mxc_restart,
Alberto Panizzo5e9145e2009-05-19 10:01:03 +0200576MACHINE_END