blob: e940004eac16ef70bf732cba5156a55af2fc44ff [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>
Daniel Mack4e4fc052008-01-23 14:54:50 +010014#include <linux/interrupt.h>
Daniel Mack4c243c82010-05-22 00:29:38 +020015#include <linux/kernel.h>
Daniel Mack4e4fc052008-01-23 14:54:50 +010016#include <linux/mtd/mtd.h>
17#include <linux/mtd/partitions.h>
18#include <linux/mtd/physmap.h>
Daniel Mack4c243c82010-05-22 00:29:38 +020019#include <linux/platform_device.h>
20#include <linux/sysdev.h>
Marek Vasut7cca84a2010-05-22 00:29:37 +020021#include <linux/ucb1400.h>
Daniel Mack4c243c82010-05-22 00:29:38 +020022
Daniel Mack4e4fc052008-01-23 14:54:50 +010023#include <asm/mach/arch.h>
Daniel Mack4e4fc052008-01-23 14:54:50 +010024#include <asm/mach/flash.h>
Daniel Mack4c243c82010-05-22 00:29:38 +020025#include <asm/mach-types.h>
26#include <asm/sizes.h>
Eric Miao51c62982009-01-02 23:17:22 +080027
Marek Vasut7cca84a2010-05-22 00:29:37 +020028#include <mach/audio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010029#include <mach/colibri.h>
Daniel Mack4c243c82010-05-22 00:29:38 +020030#include <mach/pxa27x.h>
Daniel Mack4e4fc052008-01-23 14:54:50 +010031
Daniel Mack4e4fc052008-01-23 14:54:50 +010032#include "devices.h"
Daniel Mack4c243c82010-05-22 00:29:38 +020033#include "generic.h"
Daniel Mack4e4fc052008-01-23 14:54:50 +010034
Marek Vasutf95bb542010-05-22 00:29:33 +020035/******************************************************************************
Marek Vasut9b6956f2010-08-12 01:18:38 +020036 * Evaluation board MFP
37 ******************************************************************************/
38#ifdef CONFIG_MACH_COLIBRI_PXA270_EVALBOARD
39static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {
40 /* MMC */
41 GPIO32_MMC_CLK,
42 GPIO92_MMC_DAT_0,
43 GPIO109_MMC_DAT_1,
44 GPIO110_MMC_DAT_2,
45 GPIO111_MMC_DAT_3,
46 GPIO112_MMC_CMD,
47 GPIO0_GPIO, /* SD detect */
48
49 /* FFUART */
50 GPIO39_FFUART_TXD,
51 GPIO34_FFUART_RXD,
52
53 /* UHC */
54 GPIO88_USBH1_PWR,
55 GPIO89_USBH1_PEN,
56 GPIO119_USBH2_PWR,
57 GPIO120_USBH2_PEN,
58
59 /* PCMCIA */
60 GPIO85_nPCE_1,
61 GPIO54_nPCE_2,
62 GPIO55_nPREG,
63 GPIO50_nPIOR,
64 GPIO51_nPIOW,
65 GPIO49_nPWE,
66 GPIO48_nPOE,
67 GPIO57_nIOIS16,
68 GPIO56_nPWAIT,
69 GPIO104_PSKTSEL,
70 GPIO53_GPIO, /* RESET */
71 GPIO83_GPIO, /* BVD1 */
72 GPIO82_GPIO, /* BVD2 */
73 GPIO1_GPIO, /* READY */
74 GPIO84_GPIO, /* DETECT */
75 GPIO107_GPIO, /* PPEN */
76};
77#else
78static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {};
79#endif
80
81#ifdef CONFIG_MACH_COLIBRI_PXA270_INCOME
82static mfp_cfg_t income_pin_config[] __initdata = {
83 /* MMC */
84 GPIO32_MMC_CLK,
85 GPIO92_MMC_DAT_0,
86 GPIO109_MMC_DAT_1,
87 GPIO110_MMC_DAT_2,
88 GPIO111_MMC_DAT_3,
89 GPIO112_MMC_CMD,
90 GPIO0_GPIO, /* SD detect */
91 GPIO1_GPIO, /* SD read-only */
92
93 /* FFUART */
94 GPIO39_FFUART_TXD,
95 GPIO34_FFUART_RXD,
96
97 /* BFUART */
98 GPIO42_BTUART_RXD,
99 GPIO43_BTUART_TXD,
100 GPIO45_BTUART_RTS,
101
102 /* STUART */
103 GPIO46_STUART_RXD,
104 GPIO47_STUART_TXD,
105
106 /* UHC */
107 GPIO88_USBH1_PWR,
108 GPIO89_USBH1_PEN,
109
110 /* LCD */
111 GPIOxx_LCD_TFT_16BPP,
112
113 /* PWM */
114 GPIO16_PWM0_OUT,
115
116 /* I2C */
117 GPIO117_I2C_SCL,
118 GPIO118_I2C_SDA,
119
120 /* LED */
121 GPIO54_GPIO, /* LED A */
122 GPIO55_GPIO, /* LED B */
123};
124#else
125static mfp_cfg_t income_pin_config[] __initdata = {};
126#endif
127
128/******************************************************************************
Marek Vasutf95bb542010-05-22 00:29:33 +0200129 * Pin configuration
130 ******************************************************************************/
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100131static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200132 /* Ethernet */
Eric Miaoc0b15412008-08-08 14:59:03 +0800133 GPIO78_nCS_2, /* Ethernet CS */
134 GPIO114_GPIO, /* Ethernet IRQ */
Marek Vasutd01b8d62010-05-22 00:29:34 +0200135
Marek Vasut7cca84a2010-05-22 00:29:37 +0200136 /* AC97 */
137 GPIO28_AC97_BITCLK,
138 GPIO29_AC97_SDATA_IN_0,
139 GPIO30_AC97_SDATA_OUT,
140 GPIO31_AC97_SYNC,
141 GPIO95_AC97_nRESET,
142 GPIO98_AC97_SYSCLK,
143 GPIO113_GPIO, /* Touchscreen IRQ */
Eric Miaoc0b15412008-08-08 14:59:03 +0800144};
145
Marek Vasutf95bb542010-05-22 00:29:33 +0200146/******************************************************************************
147 * NOR Flash
148 ******************************************************************************/
149#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Daniel Mack4e4fc052008-01-23 14:54:50 +0100150static struct mtd_partition colibri_partitions[] = {
151 {
152 .name = "Bootloader",
153 .offset = 0x00000000,
154 .size = 0x00040000,
Marek Vasutf95bb542010-05-22 00:29:33 +0200155 .mask_flags = MTD_WRITEABLE /* force read-only */
Daniel Mack4e4fc052008-01-23 14:54:50 +0100156 }, {
157 .name = "Kernel",
158 .offset = 0x00040000,
159 .size = 0x00400000,
160 .mask_flags = 0
161 }, {
162 .name = "Rootfs",
163 .offset = 0x00440000,
164 .size = MTDPART_SIZ_FULL,
165 .mask_flags = 0
166 }
167};
168
169static struct physmap_flash_data colibri_flash_data[] = {
170 {
171 .width = 4, /* bankwidth in bytes */
172 .parts = colibri_partitions,
173 .nr_parts = ARRAY_SIZE(colibri_partitions)
174 }
175};
176
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100177static struct resource colibri_pxa270_flash_resource = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100178 .start = PXA_CS0_PHYS,
179 .end = PXA_CS0_PHYS + SZ_32M - 1,
180 .flags = IORESOURCE_MEM,
181};
182
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100183static struct platform_device colibri_pxa270_flash_device = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100184 .name = "physmap-flash",
185 .id = 0,
186 .dev = {
187 .platform_data = colibri_flash_data,
188 },
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100189 .resource = &colibri_pxa270_flash_resource,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100190 .num_resources = 1,
191};
192
Marek Vasutf95bb542010-05-22 00:29:33 +0200193static void __init colibri_pxa270_nor_init(void)
194{
195 platform_device_register(&colibri_pxa270_flash_device);
196}
197#else
198static inline void colibri_pxa270_nor_init(void) {}
199#endif
200
201/******************************************************************************
202 * Ethernet
203 ******************************************************************************/
204#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
205static struct resource colibri_pxa270_dm9000_resources[] = {
Marek Vasut403d2972010-05-22 00:29:39 +0200206 {
Marek Vasutf95bb542010-05-22 00:29:33 +0200207 .start = PXA_CS2_PHYS,
208 .end = PXA_CS2_PHYS + 3,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100209 .flags = IORESOURCE_MEM,
210 },
Marek Vasut403d2972010-05-22 00:29:39 +0200211 {
Marek Vasutf95bb542010-05-22 00:29:33 +0200212 .start = PXA_CS2_PHYS + 4,
213 .end = PXA_CS2_PHYS + 4 + 500,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100214 .flags = IORESOURCE_MEM,
215 },
Marek Vasut403d2972010-05-22 00:29:39 +0200216 {
Marek Vasutf95bb542010-05-22 00:29:33 +0200217 .start = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
218 .end = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
Michael Abbottd0afc852008-05-14 16:29:24 -0700219 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100220 },
221};
222
Marek Vasutf95bb542010-05-22 00:29:33 +0200223static struct platform_device colibri_pxa270_dm9000_device = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100224 .name = "dm9000",
225 .id = -1,
Marek Vasutf95bb542010-05-22 00:29:33 +0200226 .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources),
227 .resource = colibri_pxa270_dm9000_resources,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100228};
229
Marek Vasutf95bb542010-05-22 00:29:33 +0200230static void __init colibri_pxa270_eth_init(void)
231{
232 platform_device_register(&colibri_pxa270_dm9000_device);
233}
234#else
235static inline void colibri_pxa270_eth_init(void) {}
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100236#endif
Daniel Mack4e4fc052008-01-23 14:54:50 +0100237
Marek Vasutd01b8d62010-05-22 00:29:34 +0200238/******************************************************************************
Marek Vasut7cca84a2010-05-22 00:29:37 +0200239 * Audio and Touchscreen
240 ******************************************************************************/
241#if defined(CONFIG_TOUCHSCREEN_UCB1400) || \
242 defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
243static pxa2xx_audio_ops_t colibri_pxa270_ac97_pdata = {
244 .reset_gpio = 95,
245};
246
247static struct ucb1400_pdata colibri_pxa270_ucb1400_pdata = {
248 .irq = gpio_to_irq(GPIO113_COLIBRI_PXA270_TS_IRQ),
249};
250
251static struct platform_device colibri_pxa270_ucb1400_device = {
252 .name = "ucb1400_core",
253 .id = -1,
254 .dev = {
255 .platform_data = &colibri_pxa270_ucb1400_pdata,
256 },
257};
258
259static void __init colibri_pxa270_tsc_init(void)
260{
261 pxa_set_ac97_info(&colibri_pxa270_ac97_pdata);
262 platform_device_register(&colibri_pxa270_ucb1400_device);
263}
264#else
265static inline void colibri_pxa270_tsc_init(void) {}
266#endif
267
Daniel Mack4c243c82010-05-22 00:29:38 +0200268static int colibri_pxa270_baseboard;
269core_param(colibri_pxa270_baseboard, colibri_pxa270_baseboard, int, 0444);
270
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100271static void __init colibri_pxa270_init(void)
Daniel Mack4e4fc052008-01-23 14:54:50 +0100272{
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100273 pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config));
Marek Vasutf95bb542010-05-22 00:29:33 +0200274
275 colibri_pxa270_nor_init();
276 colibri_pxa270_eth_init();
Marek Vasut7cca84a2010-05-22 00:29:37 +0200277 colibri_pxa270_tsc_init();
Daniel Mack4c243c82010-05-22 00:29:38 +0200278
279 switch (colibri_pxa270_baseboard) {
280 case COLIBRI_PXA270_EVALBOARD:
Marek Vasut9b6956f2010-08-12 01:18:38 +0200281 pxa2xx_mfp_config(ARRAY_AND_SIZE(
282 colibri_pxa270_evalboard_pin_config));
Daniel Mack4c243c82010-05-22 00:29:38 +0200283 colibri_pxa270_evalboard_init();
284 break;
Marek Vasut403d2972010-05-22 00:29:39 +0200285 case COLIBRI_PXA270_INCOME:
Marek Vasut9b6956f2010-08-12 01:18:38 +0200286 pxa2xx_mfp_config(ARRAY_AND_SIZE(income_pin_config));
Marek Vasut403d2972010-05-22 00:29:39 +0200287 colibri_pxa270_income_boardinit();
288 break;
Daniel Mack4c243c82010-05-22 00:29:38 +0200289 default:
290 printk(KERN_ERR "Illegal colibri_pxa270_baseboard type %d\n",
291 colibri_pxa270_baseboard);
292 }
Daniel Mack4e4fc052008-01-23 14:54:50 +0100293}
294
Marek Vasut403d2972010-05-22 00:29:39 +0200295/* The "Income s.r.o. SH-Dmaster PXA270 SBC" board can be booted either
296 * with the INCOME mach type or with COLIBRI and the kernel parameter
297 * "colibri_pxa270_baseboard=1"
298 */
299static void __init colibri_pxa270_income_init(void)
300{
301 colibri_pxa270_baseboard = COLIBRI_PXA270_INCOME;
302 colibri_pxa270_init();
303}
304
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100305MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
Daniel Mack4e4fc052008-01-23 14:54:50 +0100306 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100307 .init_machine = colibri_pxa270_init,
Marek Vasut851982c2010-10-11 02:20:19 +0200308 .map_io = pxa27x_map_io,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100309 .init_irq = pxa27x_init_irq,
310 .timer = &pxa_timer,
311MACHINE_END
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100312
Marek Vasut403d2972010-05-22 00:29:39 +0200313MACHINE_START(INCOME, "Income s.r.o. SH-Dmaster PXA270 SBC")
Marek Vasut403d2972010-05-22 00:29:39 +0200314 .boot_params = 0xa0000100,
315 .init_machine = colibri_pxa270_income_init,
Marek Vasut851982c2010-10-11 02:20:19 +0200316 .map_io = pxa27x_map_io,
Marek Vasut403d2972010-05-22 00:29:39 +0200317 .init_irq = pxa27x_init_irq,
318 .timer = &pxa_timer,
319MACHINE_END
320