blob: 3d19a6a25b4b591239c7be9d9022f1c965426a6f [file] [log] [blame]
Daniel Mack4e4fc052008-01-23 14:54:50 +01001/*
Daniel Mack5c0dbb82009-03-13 16:37:08 +01002 * linux/arch/arm/mach-pxa/colibri-pxa270.c
Daniel Mack4e4fc052008-01-23 14:54:50 +01003 *
Daniel Mack5c0dbb82009-03-13 16:37:08 +01004 * Support for Toradex PXA270 based Colibri module
Daniel Mack4e4fc052008-01-23 14:54:50 +01005 * Daniel Mack <daniel@caiaq.de>
Marek Vasutf95bb542010-05-22 00:29:33 +02006 * Marek Vasut <marek.vasut@gmail.com>
Daniel Mack4e4fc052008-01-23 14:54:50 +01007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/sysdev.h>
17#include <linux/interrupt.h>
18#include <linux/bitops.h>
19#include <linux/ioport.h>
20#include <linux/delay.h>
21#include <linux/mtd/mtd.h>
22#include <linux/mtd/partitions.h>
23#include <linux/mtd/physmap.h>
Daniel Mack5c0dbb82009-03-13 16:37:08 +010024#include <linux/gpio.h>
Daniel Mack4e4fc052008-01-23 14:54:50 +010025#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/hardware.h>
Daniel Mack4e4fc052008-01-23 14:54:50 +010027#include <asm/irq.h>
28#include <asm/sizes.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/irq.h>
32#include <asm/mach/flash.h>
Eric Miao51c62982009-01-02 23:17:22 +080033
34#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/colibri.h>
Marek Vasutd01b8d62010-05-22 00:29:34 +020036#include <mach/mmc.h>
Daniel Mack4e4fc052008-01-23 14:54:50 +010037
38#include "generic.h"
39#include "devices.h"
40
Marek Vasutf95bb542010-05-22 00:29:33 +020041/******************************************************************************
42 * Pin configuration
43 ******************************************************************************/
Daniel Mack5c0dbb82009-03-13 16:37:08 +010044static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = {
Marek Vasutf95bb542010-05-22 00:29:33 +020045 /* Ethernet */
Eric Miaoc0b15412008-08-08 14:59:03 +080046 GPIO78_nCS_2, /* Ethernet CS */
47 GPIO114_GPIO, /* Ethernet IRQ */
Marek Vasutd01b8d62010-05-22 00:29:34 +020048
49 /* MMC */
50 GPIO32_MMC_CLK,
51 GPIO92_MMC_DAT_0,
52 GPIO109_MMC_DAT_1,
53 GPIO110_MMC_DAT_2,
54 GPIO111_MMC_DAT_3,
55 GPIO112_MMC_CMD,
56 GPIO0_GPIO, /* SD detect */
Marek Vasut12d94202010-05-22 00:29:35 +020057
58 /* FFUART */
59 GPIO39_FFUART_TXD,
60 GPIO34_FFUART_RXD,
Eric Miaoc0b15412008-08-08 14:59:03 +080061};
62
Marek Vasutf95bb542010-05-22 00:29:33 +020063/******************************************************************************
64 * NOR Flash
65 ******************************************************************************/
66#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Daniel Mack4e4fc052008-01-23 14:54:50 +010067static struct mtd_partition colibri_partitions[] = {
68 {
69 .name = "Bootloader",
70 .offset = 0x00000000,
71 .size = 0x00040000,
Marek Vasutf95bb542010-05-22 00:29:33 +020072 .mask_flags = MTD_WRITEABLE /* force read-only */
Daniel Mack4e4fc052008-01-23 14:54:50 +010073 }, {
74 .name = "Kernel",
75 .offset = 0x00040000,
76 .size = 0x00400000,
77 .mask_flags = 0
78 }, {
79 .name = "Rootfs",
80 .offset = 0x00440000,
81 .size = MTDPART_SIZ_FULL,
82 .mask_flags = 0
83 }
84};
85
86static struct physmap_flash_data colibri_flash_data[] = {
87 {
88 .width = 4, /* bankwidth in bytes */
89 .parts = colibri_partitions,
90 .nr_parts = ARRAY_SIZE(colibri_partitions)
91 }
92};
93
Daniel Mack5c0dbb82009-03-13 16:37:08 +010094static struct resource colibri_pxa270_flash_resource = {
Daniel Mack4e4fc052008-01-23 14:54:50 +010095 .start = PXA_CS0_PHYS,
96 .end = PXA_CS0_PHYS + SZ_32M - 1,
97 .flags = IORESOURCE_MEM,
98};
99
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100100static struct platform_device colibri_pxa270_flash_device = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100101 .name = "physmap-flash",
102 .id = 0,
103 .dev = {
104 .platform_data = colibri_flash_data,
105 },
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100106 .resource = &colibri_pxa270_flash_resource,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100107 .num_resources = 1,
108};
109
Marek Vasutf95bb542010-05-22 00:29:33 +0200110static void __init colibri_pxa270_nor_init(void)
111{
112 platform_device_register(&colibri_pxa270_flash_device);
113}
114#else
115static inline void colibri_pxa270_nor_init(void) {}
116#endif
117
118/******************************************************************************
119 * Ethernet
120 ******************************************************************************/
121#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
122static struct resource colibri_pxa270_dm9000_resources[] = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100123 [0] = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200124 .start = PXA_CS2_PHYS,
125 .end = PXA_CS2_PHYS + 3,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100126 .flags = IORESOURCE_MEM,
127 },
128 [1] = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200129 .start = PXA_CS2_PHYS + 4,
130 .end = PXA_CS2_PHYS + 4 + 500,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100131 .flags = IORESOURCE_MEM,
132 },
133 [2] = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200134 .start = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
135 .end = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
Michael Abbottd0afc852008-05-14 16:29:24 -0700136 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100137 },
138};
139
Marek Vasutf95bb542010-05-22 00:29:33 +0200140static struct platform_device colibri_pxa270_dm9000_device = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100141 .name = "dm9000",
142 .id = -1,
Marek Vasutf95bb542010-05-22 00:29:33 +0200143 .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources),
144 .resource = colibri_pxa270_dm9000_resources,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100145};
146
Marek Vasutf95bb542010-05-22 00:29:33 +0200147static void __init colibri_pxa270_eth_init(void)
148{
149 platform_device_register(&colibri_pxa270_dm9000_device);
150}
151#else
152static inline void colibri_pxa270_eth_init(void) {}
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100153#endif
Daniel Mack4e4fc052008-01-23 14:54:50 +0100154
Marek Vasutd01b8d62010-05-22 00:29:34 +0200155/******************************************************************************
156 * SD/MMC card controller
157 ******************************************************************************/
158#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
159static struct pxamci_platform_data colibri_pxa270_mci_platform_data = {
160 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
161 .gpio_power = -1,
162 .gpio_card_detect = GPIO0_COLIBRI_PXA270_SD_DETECT,
163 .gpio_card_ro = -1,
164 .detect_delay_ms = 200,
165};
166
167static void __init colibri_pxa270_mmc_init(void)
168{
169 pxa_set_mci_info(&colibri_pxa270_mci_platform_data);
170}
171#else
172static inline void colibri_pxa270_mmc_init(void) {}
173#endif
174
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100175static void __init colibri_pxa270_init(void)
Daniel Mack4e4fc052008-01-23 14:54:50 +0100176{
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100177 pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800178 pxa_set_ffuart_info(NULL);
179 pxa_set_btuart_info(NULL);
180 pxa_set_stuart_info(NULL);
Marek Vasutf95bb542010-05-22 00:29:33 +0200181
182 colibri_pxa270_nor_init();
183 colibri_pxa270_eth_init();
Marek Vasutd01b8d62010-05-22 00:29:34 +0200184 colibri_pxa270_mmc_init();
Daniel Mack4e4fc052008-01-23 14:54:50 +0100185}
186
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100187MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
Daniel Mack4e4fc052008-01-23 14:54:50 +0100188 .phys_io = 0x40000000,
189 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
190 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100191 .init_machine = colibri_pxa270_init,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100192 .map_io = pxa_map_io,
193 .init_irq = pxa27x_init_irq,
194 .timer = &pxa_timer,
195MACHINE_END
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100196