Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 1 | /* |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 2 | * linux/arch/arm/mach-pxa/colibri-pxa270.c |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 3 | * |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 4 | * Support for Toradex PXA270 based Colibri module |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 5 | * Daniel Mack <daniel@caiaq.de> |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 6 | * Marek Vasut <marek.vasut@gmail.com> |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 7 | * |
| 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 Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 24 | #include <linux/gpio.h> |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 26 | #include <mach/hardware.h> |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 27 | #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 Miao | 51c6298 | 2009-01-02 23:17:22 +0800 | [diff] [blame] | 33 | |
| 34 | #include <mach/pxa27x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 35 | #include <mach/colibri.h> |
Marek Vasut | d01b8d6 | 2010-05-22 00:29:34 +0200 | [diff] [blame] | 36 | #include <mach/mmc.h> |
Marek Vasut | 8f14619 | 2010-05-22 00:29:36 +0200 | [diff] [blame^] | 37 | #include <mach/ohci.h> |
| 38 | #include <mach/pxa27x-udc.h> |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 39 | |
| 40 | #include "generic.h" |
| 41 | #include "devices.h" |
| 42 | |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 43 | /****************************************************************************** |
| 44 | * Pin configuration |
| 45 | ******************************************************************************/ |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 46 | static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = { |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 47 | /* Ethernet */ |
Eric Miao | c0b1541 | 2008-08-08 14:59:03 +0800 | [diff] [blame] | 48 | GPIO78_nCS_2, /* Ethernet CS */ |
| 49 | GPIO114_GPIO, /* Ethernet IRQ */ |
Marek Vasut | d01b8d6 | 2010-05-22 00:29:34 +0200 | [diff] [blame] | 50 | |
| 51 | /* MMC */ |
| 52 | GPIO32_MMC_CLK, |
| 53 | GPIO92_MMC_DAT_0, |
| 54 | GPIO109_MMC_DAT_1, |
| 55 | GPIO110_MMC_DAT_2, |
| 56 | GPIO111_MMC_DAT_3, |
| 57 | GPIO112_MMC_CMD, |
| 58 | GPIO0_GPIO, /* SD detect */ |
Marek Vasut | 12d9420 | 2010-05-22 00:29:35 +0200 | [diff] [blame] | 59 | |
| 60 | /* FFUART */ |
| 61 | GPIO39_FFUART_TXD, |
| 62 | GPIO34_FFUART_RXD, |
Marek Vasut | 8f14619 | 2010-05-22 00:29:36 +0200 | [diff] [blame^] | 63 | |
| 64 | /* UHC */ |
| 65 | GPIO88_USBH1_PWR, |
| 66 | GPIO89_USBH1_PEN, |
| 67 | GPIO119_USBH2_PWR, |
| 68 | GPIO120_USBH2_PEN, |
Eric Miao | c0b1541 | 2008-08-08 14:59:03 +0800 | [diff] [blame] | 69 | }; |
| 70 | |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 71 | /****************************************************************************** |
| 72 | * NOR Flash |
| 73 | ******************************************************************************/ |
| 74 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 75 | static struct mtd_partition colibri_partitions[] = { |
| 76 | { |
| 77 | .name = "Bootloader", |
| 78 | .offset = 0x00000000, |
| 79 | .size = 0x00040000, |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 80 | .mask_flags = MTD_WRITEABLE /* force read-only */ |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 81 | }, { |
| 82 | .name = "Kernel", |
| 83 | .offset = 0x00040000, |
| 84 | .size = 0x00400000, |
| 85 | .mask_flags = 0 |
| 86 | }, { |
| 87 | .name = "Rootfs", |
| 88 | .offset = 0x00440000, |
| 89 | .size = MTDPART_SIZ_FULL, |
| 90 | .mask_flags = 0 |
| 91 | } |
| 92 | }; |
| 93 | |
| 94 | static struct physmap_flash_data colibri_flash_data[] = { |
| 95 | { |
| 96 | .width = 4, /* bankwidth in bytes */ |
| 97 | .parts = colibri_partitions, |
| 98 | .nr_parts = ARRAY_SIZE(colibri_partitions) |
| 99 | } |
| 100 | }; |
| 101 | |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 102 | static struct resource colibri_pxa270_flash_resource = { |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 103 | .start = PXA_CS0_PHYS, |
| 104 | .end = PXA_CS0_PHYS + SZ_32M - 1, |
| 105 | .flags = IORESOURCE_MEM, |
| 106 | }; |
| 107 | |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 108 | static struct platform_device colibri_pxa270_flash_device = { |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 109 | .name = "physmap-flash", |
| 110 | .id = 0, |
| 111 | .dev = { |
| 112 | .platform_data = colibri_flash_data, |
| 113 | }, |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 114 | .resource = &colibri_pxa270_flash_resource, |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 115 | .num_resources = 1, |
| 116 | }; |
| 117 | |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 118 | static void __init colibri_pxa270_nor_init(void) |
| 119 | { |
| 120 | platform_device_register(&colibri_pxa270_flash_device); |
| 121 | } |
| 122 | #else |
| 123 | static inline void colibri_pxa270_nor_init(void) {} |
| 124 | #endif |
| 125 | |
| 126 | /****************************************************************************** |
| 127 | * Ethernet |
| 128 | ******************************************************************************/ |
| 129 | #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE) |
| 130 | static struct resource colibri_pxa270_dm9000_resources[] = { |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 131 | [0] = { |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 132 | .start = PXA_CS2_PHYS, |
| 133 | .end = PXA_CS2_PHYS + 3, |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 134 | .flags = IORESOURCE_MEM, |
| 135 | }, |
| 136 | [1] = { |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 137 | .start = PXA_CS2_PHYS + 4, |
| 138 | .end = PXA_CS2_PHYS + 4 + 500, |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 139 | .flags = IORESOURCE_MEM, |
| 140 | }, |
| 141 | [2] = { |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 142 | .start = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ), |
| 143 | .end = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ), |
Michael Abbott | d0afc85 | 2008-05-14 16:29:24 -0700 | [diff] [blame] | 144 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 145 | }, |
| 146 | }; |
| 147 | |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 148 | static struct platform_device colibri_pxa270_dm9000_device = { |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 149 | .name = "dm9000", |
| 150 | .id = -1, |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 151 | .num_resources = ARRAY_SIZE(colibri_pxa270_dm9000_resources), |
| 152 | .resource = colibri_pxa270_dm9000_resources, |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 153 | }; |
| 154 | |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 155 | static void __init colibri_pxa270_eth_init(void) |
| 156 | { |
| 157 | platform_device_register(&colibri_pxa270_dm9000_device); |
| 158 | } |
| 159 | #else |
| 160 | static inline void colibri_pxa270_eth_init(void) {} |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 161 | #endif |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 162 | |
Marek Vasut | d01b8d6 | 2010-05-22 00:29:34 +0200 | [diff] [blame] | 163 | /****************************************************************************** |
| 164 | * SD/MMC card controller |
| 165 | ******************************************************************************/ |
| 166 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 167 | static struct pxamci_platform_data colibri_pxa270_mci_platform_data = { |
| 168 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 169 | .gpio_power = -1, |
| 170 | .gpio_card_detect = GPIO0_COLIBRI_PXA270_SD_DETECT, |
| 171 | .gpio_card_ro = -1, |
| 172 | .detect_delay_ms = 200, |
| 173 | }; |
| 174 | |
| 175 | static void __init colibri_pxa270_mmc_init(void) |
| 176 | { |
| 177 | pxa_set_mci_info(&colibri_pxa270_mci_platform_data); |
| 178 | } |
| 179 | #else |
| 180 | static inline void colibri_pxa270_mmc_init(void) {} |
| 181 | #endif |
| 182 | |
Marek Vasut | 8f14619 | 2010-05-22 00:29:36 +0200 | [diff] [blame^] | 183 | /****************************************************************************** |
| 184 | * USB Host |
| 185 | ******************************************************************************/ |
| 186 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 187 | static int colibri_pxa270_ohci_init(struct device *dev) |
| 188 | { |
| 189 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; |
| 190 | return 0; |
| 191 | } |
| 192 | |
| 193 | static struct pxaohci_platform_data colibri_pxa270_ohci_info = { |
| 194 | .port_mode = PMM_PERPORT_MODE, |
| 195 | .flags = ENABLE_PORT1 | ENABLE_PORT2 | |
| 196 | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 197 | .init = colibri_pxa270_ohci_init, |
| 198 | }; |
| 199 | |
| 200 | static void __init colibri_pxa270_uhc_init(void) |
| 201 | { |
| 202 | pxa_set_ohci_info(&colibri_pxa270_ohci_info); |
| 203 | } |
| 204 | #else |
| 205 | static inline void colibri_pxa270_uhc_init(void) {} |
| 206 | #endif |
| 207 | |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 208 | static void __init colibri_pxa270_init(void) |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 209 | { |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 210 | pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config)); |
Russell King | cc155c6 | 2009-11-09 13:34:08 +0800 | [diff] [blame] | 211 | pxa_set_ffuart_info(NULL); |
| 212 | pxa_set_btuart_info(NULL); |
| 213 | pxa_set_stuart_info(NULL); |
Marek Vasut | f95bb54 | 2010-05-22 00:29:33 +0200 | [diff] [blame] | 214 | |
| 215 | colibri_pxa270_nor_init(); |
| 216 | colibri_pxa270_eth_init(); |
Marek Vasut | d01b8d6 | 2010-05-22 00:29:34 +0200 | [diff] [blame] | 217 | colibri_pxa270_mmc_init(); |
Marek Vasut | 8f14619 | 2010-05-22 00:29:36 +0200 | [diff] [blame^] | 218 | colibri_pxa270_uhc_init(); |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 219 | } |
| 220 | |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 221 | MACHINE_START(COLIBRI, "Toradex Colibri PXA270") |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 222 | .phys_io = 0x40000000, |
| 223 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 224 | .boot_params = COLIBRI_SDRAM_BASE + 0x100, |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 225 | .init_machine = colibri_pxa270_init, |
Daniel Mack | 4e4fc05 | 2008-01-23 14:54:50 +0100 | [diff] [blame] | 226 | .map_io = pxa_map_io, |
| 227 | .init_irq = pxa27x_init_irq, |
| 228 | .timer = &pxa_timer, |
| 229 | MACHINE_END |
Daniel Mack | 5c0dbb8 | 2009-03-13 16:37:08 +0100 | [diff] [blame] | 230 | |