blob: cbaf0196c74791518e3c22da32dcae69ed87efa9 [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 */
Eric Miaoc0b15412008-08-08 14:59:03 +080057};
58
Marek Vasutf95bb542010-05-22 00:29:33 +020059/******************************************************************************
60 * NOR Flash
61 ******************************************************************************/
62#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Daniel Mack4e4fc052008-01-23 14:54:50 +010063static struct mtd_partition colibri_partitions[] = {
64 {
65 .name = "Bootloader",
66 .offset = 0x00000000,
67 .size = 0x00040000,
Marek Vasutf95bb542010-05-22 00:29:33 +020068 .mask_flags = MTD_WRITEABLE /* force read-only */
Daniel Mack4e4fc052008-01-23 14:54:50 +010069 }, {
70 .name = "Kernel",
71 .offset = 0x00040000,
72 .size = 0x00400000,
73 .mask_flags = 0
74 }, {
75 .name = "Rootfs",
76 .offset = 0x00440000,
77 .size = MTDPART_SIZ_FULL,
78 .mask_flags = 0
79 }
80};
81
82static struct physmap_flash_data colibri_flash_data[] = {
83 {
84 .width = 4, /* bankwidth in bytes */
85 .parts = colibri_partitions,
86 .nr_parts = ARRAY_SIZE(colibri_partitions)
87 }
88};
89
Daniel Mack5c0dbb82009-03-13 16:37:08 +010090static struct resource colibri_pxa270_flash_resource = {
Daniel Mack4e4fc052008-01-23 14:54:50 +010091 .start = PXA_CS0_PHYS,
92 .end = PXA_CS0_PHYS + SZ_32M - 1,
93 .flags = IORESOURCE_MEM,
94};
95
Daniel Mack5c0dbb82009-03-13 16:37:08 +010096static struct platform_device colibri_pxa270_flash_device = {
Daniel Mack4e4fc052008-01-23 14:54:50 +010097 .name = "physmap-flash",
98 .id = 0,
99 .dev = {
100 .platform_data = colibri_flash_data,
101 },
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100102 .resource = &colibri_pxa270_flash_resource,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100103 .num_resources = 1,
104};
105
Marek Vasutf95bb542010-05-22 00:29:33 +0200106static void __init colibri_pxa270_nor_init(void)
107{
108 platform_device_register(&colibri_pxa270_flash_device);
109}
110#else
111static inline void colibri_pxa270_nor_init(void) {}
112#endif
113
114/******************************************************************************
115 * Ethernet
116 ******************************************************************************/
117#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
118static struct resource colibri_pxa270_dm9000_resources[] = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100119 [0] = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200120 .start = PXA_CS2_PHYS,
121 .end = PXA_CS2_PHYS + 3,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100122 .flags = IORESOURCE_MEM,
123 },
124 [1] = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200125 .start = PXA_CS2_PHYS + 4,
126 .end = PXA_CS2_PHYS + 4 + 500,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100127 .flags = IORESOURCE_MEM,
128 },
129 [2] = {
Marek Vasutf95bb542010-05-22 00:29:33 +0200130 .start = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
131 .end = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
Michael Abbottd0afc852008-05-14 16:29:24 -0700132 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100133 },
134};
135
Marek Vasutf95bb542010-05-22 00:29:33 +0200136static struct platform_device colibri_pxa270_dm9000_device = {
Daniel Mack4e4fc052008-01-23 14:54:50 +0100137 .name = "dm9000",
138 .id = -1,
Marek Vasutf95bb542010-05-22 00:29:33 +0200139 .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources),
140 .resource = colibri_pxa270_dm9000_resources,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100141};
142
Marek Vasutf95bb542010-05-22 00:29:33 +0200143static void __init colibri_pxa270_eth_init(void)
144{
145 platform_device_register(&colibri_pxa270_dm9000_device);
146}
147#else
148static inline void colibri_pxa270_eth_init(void) {}
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100149#endif
Daniel Mack4e4fc052008-01-23 14:54:50 +0100150
Marek Vasutd01b8d62010-05-22 00:29:34 +0200151/******************************************************************************
152 * SD/MMC card controller
153 ******************************************************************************/
154#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
155static struct pxamci_platform_data colibri_pxa270_mci_platform_data = {
156 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
157 .gpio_power = -1,
158 .gpio_card_detect = GPIO0_COLIBRI_PXA270_SD_DETECT,
159 .gpio_card_ro = -1,
160 .detect_delay_ms = 200,
161};
162
163static void __init colibri_pxa270_mmc_init(void)
164{
165 pxa_set_mci_info(&colibri_pxa270_mci_platform_data);
166}
167#else
168static inline void colibri_pxa270_mmc_init(void) {}
169#endif
170
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100171static void __init colibri_pxa270_init(void)
Daniel Mack4e4fc052008-01-23 14:54:50 +0100172{
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100173 pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config));
Russell Kingcc155c62009-11-09 13:34:08 +0800174 pxa_set_ffuart_info(NULL);
175 pxa_set_btuart_info(NULL);
176 pxa_set_stuart_info(NULL);
Marek Vasutf95bb542010-05-22 00:29:33 +0200177
178 colibri_pxa270_nor_init();
179 colibri_pxa270_eth_init();
Marek Vasutd01b8d62010-05-22 00:29:34 +0200180 colibri_pxa270_mmc_init();
Daniel Mack4e4fc052008-01-23 14:54:50 +0100181}
182
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100183MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
Daniel Mack4e4fc052008-01-23 14:54:50 +0100184 .phys_io = 0x40000000,
185 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
186 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100187 .init_machine = colibri_pxa270_init,
Daniel Mack4e4fc052008-01-23 14:54:50 +0100188 .map_io = pxa_map_io,
189 .init_irq = pxa27x_init_irq,
190 .timer = &pxa_timer,
191MACHINE_END
Daniel Mack5c0dbb82009-03-13 16:37:08 +0100192