4 * Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com>
5 * updates in http://alberdroid.blogspot.com/
7 * Based on Atmark Techno, Inc. armadillo 500 BSP 2008
8 * Based on mx31ads.c and pcm037.c Great Work!
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.
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.
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,
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>
34 #include <linux/mtd/physmap.h>
36 #include <linux/input.h>
37 #include <linux/gpio_keys.h>
38 #include <linux/i2c.h>
40 #include <mach/hardware.h>
41 #include <asm/mach-types.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/time.h>
44 #include <asm/memory.h>
45 #include <asm/mach/map.h>
47 #include <mach/common.h>
48 #include <mach/imx-uart.h>
49 #include <mach/iomux-mx3.h>
50 #include <mach/board-armadillo5x0.h>
53 #include <mach/mx3fb.h>
54 #include <mach/mxc_nand.h>
59 static int armadillo5x0_pins
[] = {
71 IOMUX_MODE(MX31_PIN_GPIO1_0
, IOMUX_CONFIG_GPIO
),
73 MX31_PIN_SD1_DATA3__SD1_DATA3
,
74 MX31_PIN_SD1_DATA2__SD1_DATA2
,
75 MX31_PIN_SD1_DATA1__SD1_DATA1
,
76 MX31_PIN_SD1_DATA0__SD1_DATA0
,
77 MX31_PIN_SD1_CLK__SD1_CLK
,
78 MX31_PIN_SD1_CMD__SD1_CMD
,
98 MX31_PIN_VSYNC3__VSYNC3
,
99 MX31_PIN_HSYNC__HSYNC
,
100 MX31_PIN_FPSHIFT__FPSHIFT
,
101 MX31_PIN_DRDY0__DRDY0
,
102 IOMUX_MODE(MX31_PIN_LCS1
, IOMUX_CONFIG_GPIO
), /*ADV7125_PSAVE*/
104 MX31_PIN_CSPI2_MOSI__SCL
,
105 MX31_PIN_CSPI2_MISO__SDA
,
109 #define ARMADILLO5X0_RTC_GPIO IOMUX_TO_GPIO(MX31_PIN_SRXD4)
111 static struct i2c_board_info armadillo5x0_i2c_rtc
= {
112 I2C_BOARD_INFO("s35390a", 0x30),
116 static struct gpio_keys_button armadillo5x0_buttons
[] = {
118 .code
= KEY_ENTER
, /*28*/
119 .gpio
= IOMUX_TO_GPIO(MX31_PIN_SCLK0
),
124 .code
= KEY_BACK
, /*158*/
125 .gpio
= IOMUX_TO_GPIO(MX31_PIN_SRST0
),
132 static struct gpio_keys_platform_data armadillo5x0_button_data
= {
133 .buttons
= armadillo5x0_buttons
,
134 .nbuttons
= ARRAY_SIZE(armadillo5x0_buttons
),
137 static struct platform_device armadillo5x0_button_device
= {
142 .platform_data
= &armadillo5x0_button_data
,
149 static struct mxc_nand_platform_data armadillo5x0_nand_flash_pdata
= {
157 static struct mtd_partition armadillo5x0_nor_flash_partitions
[] = {
159 .name
= "nor.bootloader",
160 .offset
= 0x00000000,
163 .name
= "nor.kernel",
164 .offset
= MTDPART_OFS_APPEND
,
167 .name
= "nor.userland",
168 .offset
= MTDPART_OFS_APPEND
,
169 .size
= 110*128*1024,
171 .name
= "nor.config",
172 .offset
= MTDPART_OFS_APPEND
,
177 static struct physmap_flash_data armadillo5x0_nor_flash_pdata
= {
179 .parts
= armadillo5x0_nor_flash_partitions
,
180 .nr_parts
= ARRAY_SIZE(armadillo5x0_nor_flash_partitions
),
183 static struct resource armadillo5x0_nor_flash_resource
= {
184 .flags
= IORESOURCE_MEM
,
185 .start
= CS0_BASE_ADDR
,
186 .end
= CS0_BASE_ADDR
+ SZ_64M
- 1,
189 static struct platform_device armadillo5x0_nor_flash
= {
190 .name
= "physmap-flash",
193 .resource
= &armadillo5x0_nor_flash_resource
,
199 static const struct fb_videomode fb_modedb
[] = {
200 { /* 640x480 @ 60 Hz */
212 .sync
= FB_SYNC_OE_ACT_HIGH
,
213 .vmode
= FB_VMODE_NONINTERLACED
,
215 }, {/* 800x600 @ 56 Hz */
227 .sync
= FB_SYNC_OE_ACT_HIGH
| FB_SYNC_HOR_HIGH_ACT
|
228 FB_SYNC_VERT_HIGH_ACT
,
229 .vmode
= FB_VMODE_NONINTERLACED
,
234 static struct ipu_platform_data mx3_ipu_data
= {
235 .irq_base
= MXC_IPU_IRQ_START
,
238 static struct mx3fb_platform_data mx3fb_pdata
= {
239 .dma_dev
= &mx3_ipu
.dev
,
242 .num_modes
= ARRAY_SIZE(fb_modedb
),
249 static int armadillo5x0_sdhc1_get_ro(struct device
*dev
)
251 return gpio_get_value(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B
));
254 static int armadillo5x0_sdhc1_init(struct device
*dev
,
255 irq_handler_t detect_irq
, void *data
)
258 int gpio_det
, gpio_wp
;
260 gpio_det
= IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK
);
261 gpio_wp
= IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B
);
263 ret
= gpio_request(gpio_det
, "sdhc-card-detect");
267 gpio_direction_input(gpio_det
);
269 ret
= gpio_request(gpio_wp
, "sdhc-write-protect");
273 gpio_direction_input(gpio_wp
);
275 /* When supported the trigger type have to be BOTH */
276 ret
= request_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK
), detect_irq
,
277 IRQF_DISABLED
| IRQF_TRIGGER_FALLING
,
278 "sdhc-detect", data
);
281 goto err_gpio_free_2
;
295 static void armadillo5x0_sdhc1_exit(struct device
*dev
, void *data
)
297 free_irq(IOMUX_TO_IRQ(MX31_PIN_ATA_DMACK
), data
);
298 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_DMACK
));
299 gpio_free(IOMUX_TO_GPIO(MX31_PIN_ATA_RESET_B
));
302 static struct imxmmc_platform_data sdhc_pdata
= {
303 .get_ro
= armadillo5x0_sdhc1_get_ro
,
304 .init
= armadillo5x0_sdhc1_init
,
305 .exit
= armadillo5x0_sdhc1_exit
,
312 static struct resource armadillo5x0_smc911x_resources
[] = {
314 .start
= CS3_BASE_ADDR
,
315 .end
= CS3_BASE_ADDR
+ SZ_32M
- 1,
316 .flags
= IORESOURCE_MEM
,
318 .start
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_0
),
319 .end
= IOMUX_TO_IRQ(MX31_PIN_GPIO1_0
),
320 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_LOWLEVEL
,
324 static struct smsc911x_platform_config smsc911x_info
= {
325 .flags
= SMSC911X_USE_16BIT
,
326 .irq_polarity
= SMSC911X_IRQ_POLARITY_ACTIVE_LOW
,
327 .irq_type
= SMSC911X_IRQ_TYPE_PUSH_PULL
,
330 static struct platform_device armadillo5x0_smc911x_device
= {
333 .num_resources
= ARRAY_SIZE(armadillo5x0_smc911x_resources
),
334 .resource
= armadillo5x0_smc911x_resources
,
336 .platform_data
= &smsc911x_info
,
340 /* UART device data */
341 static struct imxuart_platform_data uart_pdata
= {
342 .flags
= IMXUART_HAVE_RTSCTS
,
345 static struct platform_device
*devices
[] __initdata
= {
346 &armadillo5x0_smc911x_device
,
348 &armadillo5x0_button_device
,
352 * Perform board specific initializations
354 static void __init
armadillo5x0_init(void)
356 mxc_iomux_setup_multiple_pins(armadillo5x0_pins
,
357 ARRAY_SIZE(armadillo5x0_pins
), "armadillo5x0");
359 platform_add_devices(devices
, ARRAY_SIZE(devices
));
362 mxc_register_device(&mxc_uart_device0
, &uart_pdata
);
363 mxc_register_device(&mxc_uart_device1
, &uart_pdata
);
365 /* SMSC9118 IRQ pin */
366 gpio_direction_input(MX31_PIN_GPIO1_0
);
369 mxc_register_device(&mxcsdhc_device0
, &sdhc_pdata
);
372 mxc_register_device(&mx3_ipu
, &mx3_ipu_data
);
373 mxc_register_device(&mx3_fb
, &mx3fb_pdata
);
375 /* Register NOR Flash */
376 mxc_register_device(&armadillo5x0_nor_flash
,
377 &armadillo5x0_nor_flash_pdata
);
379 /* Register NAND Flash */
380 mxc_register_device(&mxc_nand_device
, &armadillo5x0_nand_flash_pdata
);
382 /* set NAND page size to 2k if not configured via boot mode pins */
383 __raw_writel(__raw_readl(MXC_CCM_RCSR
) | (1 << 30), MXC_CCM_RCSR
);
386 /* Get RTC IRQ and register the chip */
387 if (gpio_request(ARMADILLO5X0_RTC_GPIO
, "rtc") == 0) {
388 if (gpio_direction_input(ARMADILLO5X0_RTC_GPIO
) == 0)
389 armadillo5x0_i2c_rtc
.irq
= gpio_to_irq(ARMADILLO5X0_RTC_GPIO
);
391 gpio_free(ARMADILLO5X0_RTC_GPIO
);
393 if (armadillo5x0_i2c_rtc
.irq
== 0)
394 pr_warning("armadillo5x0_init: failed to get RTC IRQ\n");
395 i2c_register_board_info(1, &armadillo5x0_i2c_rtc
, 1);
398 static void __init
armadillo5x0_timer_init(void)
400 mx31_clocks_init(26000000);
403 static struct sys_timer armadillo5x0_timer
= {
404 .init
= armadillo5x0_timer_init
,
407 MACHINE_START(ARMADILLO5X0
, "Armadillo-500")
408 /* Maintainer: Alberto Panizzo */
409 .phys_io
= AIPS1_BASE_ADDR
,
410 .io_pg_offst
= ((AIPS1_BASE_ADDR_VIRT
) >> 18) & 0xfffc,
411 .boot_params
= PHYS_OFFSET
+ 0x00000100,
412 .map_io
= mx31_map_io
,
413 .init_irq
= mx31_init_irq
,
414 .timer
= &armadillo5x0_timer
,
415 .init_machine
= armadillo5x0_init
,