Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Support for Cogent CSB726 |
| 3 | * |
| 4 | * Copyright (c) 2008 Dmitry Eremin-Solenikov |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/io.h> |
| 14 | #include <linux/gpio.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/mtd/physmap.h> |
| 17 | #include <linux/mtd/partitions.h> |
| 18 | #include <linux/sm501.h> |
Dmitry Eremin-Solenikov | b860171 | 2009-04-22 00:43:21 +0400 | [diff] [blame] | 19 | #include <linux/smsc911x.h> |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 20 | |
| 21 | #include <asm/mach-types.h> |
| 22 | #include <asm/mach/arch.h> |
| 23 | #include <mach/csb726.h> |
| 24 | #include <mach/mfp-pxa27x.h> |
Eric Miao | f0a8370 | 2009-04-13 15:03:11 +0800 | [diff] [blame] | 25 | #include <plat/i2c.h> |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 26 | #include <mach/mmc.h> |
| 27 | #include <mach/ohci.h> |
| 28 | #include <mach/pxa2xx-regs.h> |
Dmitry Eremin-Solenikov | 96a9fca | 2009-04-22 00:43:22 +0400 | [diff] [blame^] | 29 | #include <mach/audio.h> |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 30 | |
| 31 | #include "generic.h" |
| 32 | #include "devices.h" |
| 33 | |
| 34 | /* |
| 35 | * n/a: 2, 5, 6, 7, 8, 23, 24, 25, 26, 27, 87, 88, 89, |
| 36 | * nu: 58 -- 77, 90, 91, 93, 102, 105-108, 114-116, |
| 37 | * XXX: 21, |
| 38 | * XXX: 79 CS_3 for LAN9215 or PSKTSEL on R2, R3 |
| 39 | * XXX: 33 CS_5 for LAN9215 on R1 |
| 40 | */ |
| 41 | |
| 42 | static unsigned long csb726_pin_config[] = { |
| 43 | GPIO78_nCS_2, /* EXP_CS */ |
| 44 | GPIO79_nCS_3, /* SMSC9215 */ |
| 45 | GPIO80_nCS_4, /* SM501 */ |
| 46 | |
| 47 | GPIO52_GPIO, /* #SMSC9251 int */ |
| 48 | GPIO53_GPIO, /* SM501 int */ |
| 49 | |
| 50 | GPIO1_GPIO, /* GPIO0 */ |
| 51 | GPIO11_GPIO, /* GPIO1 */ |
| 52 | GPIO9_GPIO, /* GPIO2 */ |
| 53 | GPIO10_GPIO, /* GPIO3 */ |
| 54 | GPIO16_PWM0_OUT, /* or GPIO4 */ |
| 55 | GPIO17_PWM1_OUT, /* or GPIO5 */ |
| 56 | GPIO94_GPIO, /* GPIO6 */ |
| 57 | GPIO95_GPIO, /* GPIO7 */ |
| 58 | GPIO96_GPIO, /* GPIO8 */ |
| 59 | GPIO97_GPIO, /* GPIO9 */ |
| 60 | GPIO15_GPIO, /* EXP_IRQ */ |
| 61 | GPIO18_RDY, /* EXP_WAIT */ |
| 62 | |
| 63 | GPIO0_GPIO, /* PWR_INT */ |
| 64 | GPIO104_GPIO, /* PWR_OFF */ |
| 65 | |
| 66 | GPIO12_GPIO, /* touch irq */ |
| 67 | |
| 68 | GPIO13_SSP2_TXD, |
| 69 | GPIO14_SSP2_SFRM, |
| 70 | MFP_CFG_OUT(GPIO19, AF1, DRIVE_LOW),/* SSP2_SYSCLK */ |
| 71 | GPIO22_SSP2_SCLK, |
| 72 | |
| 73 | GPIO81_SSP3_TXD, |
| 74 | GPIO82_SSP3_RXD, |
| 75 | GPIO83_SSP3_SFRM, |
| 76 | GPIO84_SSP3_SCLK, |
| 77 | |
| 78 | GPIO20_GPIO, /* SDIO int */ |
| 79 | GPIO32_MMC_CLK, |
| 80 | GPIO92_MMC_DAT_0, |
| 81 | GPIO109_MMC_DAT_1, |
| 82 | GPIO110_MMC_DAT_2, |
| 83 | GPIO111_MMC_DAT_3, |
| 84 | GPIO112_MMC_CMD, |
| 85 | GPIO100_GPIO, /* SD CD */ |
| 86 | GPIO101_GPIO, /* SD WP */ |
| 87 | |
| 88 | GPIO28_AC97_BITCLK, |
| 89 | GPIO29_AC97_SDATA_IN_0, |
| 90 | GPIO30_AC97_SDATA_OUT, |
| 91 | GPIO31_AC97_SYNC, |
| 92 | GPIO113_AC97_nRESET, |
| 93 | |
| 94 | GPIO34_FFUART_RXD, |
| 95 | GPIO35_FFUART_CTS, |
| 96 | GPIO36_FFUART_DCD, |
| 97 | GPIO37_FFUART_DSR, |
| 98 | GPIO38_FFUART_RI, |
| 99 | GPIO39_FFUART_TXD, |
| 100 | GPIO40_FFUART_DTR, |
| 101 | GPIO41_FFUART_RTS, |
| 102 | |
| 103 | GPIO42_BTUART_RXD, |
| 104 | GPIO43_BTUART_TXD, |
| 105 | GPIO44_BTUART_CTS, |
| 106 | GPIO45_BTUART_RTS, |
| 107 | |
| 108 | GPIO46_STUART_RXD, |
| 109 | GPIO47_STUART_TXD, |
| 110 | |
| 111 | GPIO48_nPOE, |
| 112 | GPIO49_nPWE, |
| 113 | GPIO50_nPIOR, |
| 114 | GPIO51_nPIOW, |
| 115 | GPIO54_nPCE_2, |
| 116 | GPIO55_nPREG, |
| 117 | GPIO56_nPWAIT, |
| 118 | GPIO57_nIOIS16, /* maybe unused */ |
| 119 | GPIO85_nPCE_1, |
| 120 | GPIO98_GPIO, /* CF IRQ */ |
| 121 | GPIO99_GPIO, /* CF CD */ |
| 122 | GPIO103_GPIO, /* Reset */ |
| 123 | |
| 124 | GPIO117_I2C_SCL, |
| 125 | GPIO118_I2C_SDA, |
| 126 | }; |
| 127 | |
| 128 | static struct pxamci_platform_data csb726_mci_data; |
| 129 | |
| 130 | static int csb726_mci_init(struct device *dev, |
| 131 | irq_handler_t detect, void *data) |
| 132 | { |
| 133 | int err; |
| 134 | |
| 135 | csb726_mci_data.detect_delay = msecs_to_jiffies(500); |
| 136 | |
| 137 | err = gpio_request(CSB726_GPIO_MMC_DETECT, "MMC detect"); |
| 138 | if (err) |
| 139 | goto err_det_req; |
| 140 | |
| 141 | err = gpio_direction_input(CSB726_GPIO_MMC_DETECT); |
| 142 | if (err) |
| 143 | goto err_det_dir; |
| 144 | |
| 145 | err = gpio_request(CSB726_GPIO_MMC_RO, "MMC ro"); |
| 146 | if (err) |
| 147 | goto err_ro_req; |
| 148 | |
| 149 | err = gpio_direction_input(CSB726_GPIO_MMC_RO); |
| 150 | if (err) |
| 151 | goto err_ro_dir; |
| 152 | |
| 153 | err = request_irq(gpio_to_irq(CSB726_GPIO_MMC_DETECT), detect, |
| 154 | IRQF_DISABLED, "MMC card detect", data); |
| 155 | if (err) |
| 156 | goto err_irq; |
| 157 | |
| 158 | return 0; |
| 159 | |
| 160 | err_irq: |
| 161 | err_ro_dir: |
| 162 | gpio_free(CSB726_GPIO_MMC_RO); |
| 163 | err_ro_req: |
| 164 | err_det_dir: |
| 165 | gpio_free(CSB726_GPIO_MMC_DETECT); |
| 166 | err_det_req: |
| 167 | return err; |
| 168 | } |
| 169 | |
| 170 | static int csb726_mci_get_ro(struct device *dev) |
| 171 | { |
| 172 | return gpio_get_value(CSB726_GPIO_MMC_RO); |
| 173 | } |
| 174 | |
| 175 | static void csb726_mci_exit(struct device *dev, void *data) |
| 176 | { |
| 177 | free_irq(gpio_to_irq(CSB726_GPIO_MMC_DETECT), data); |
| 178 | gpio_free(CSB726_GPIO_MMC_RO); |
| 179 | gpio_free(CSB726_GPIO_MMC_DETECT); |
| 180 | } |
| 181 | |
| 182 | static struct pxamci_platform_data csb726_mci = { |
| 183 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 184 | .init = csb726_mci_init, |
| 185 | .get_ro = csb726_mci_get_ro, |
| 186 | /* FIXME setpower */ |
| 187 | .exit = csb726_mci_exit, |
| 188 | }; |
| 189 | |
| 190 | static struct pxaohci_platform_data csb726_ohci_platform_data = { |
| 191 | .port_mode = PMM_NPS_MODE, |
| 192 | .flags = ENABLE_PORT1 | NO_OC_PROTECTION, |
| 193 | }; |
| 194 | |
| 195 | static struct mtd_partition csb726_flash_partitions[] = { |
| 196 | { |
| 197 | .name = "Bootloader", |
| 198 | .offset = 0, |
| 199 | .size = CSB726_FLASH_uMON, |
| 200 | .mask_flags = MTD_WRITEABLE /* force read-only */ |
| 201 | }, |
| 202 | { |
| 203 | .name = "root", |
| 204 | .offset = MTDPART_OFS_APPEND, |
| 205 | .size = MTDPART_SIZ_FULL, |
| 206 | } |
| 207 | }; |
| 208 | |
| 209 | static struct physmap_flash_data csb726_flash_data = { |
| 210 | .width = 2, |
| 211 | .parts = csb726_flash_partitions, |
| 212 | .nr_parts = ARRAY_SIZE(csb726_flash_partitions), |
| 213 | }; |
| 214 | |
| 215 | static struct resource csb726_flash_resources[] = { |
| 216 | { |
| 217 | .start = PXA_CS0_PHYS, |
| 218 | .end = PXA_CS0_PHYS + CSB726_FLASH_SIZE - 1 , |
| 219 | .flags = IORESOURCE_MEM, |
| 220 | } |
| 221 | }; |
| 222 | |
| 223 | static struct platform_device csb726_flash = { |
| 224 | .name = "physmap-flash", |
| 225 | .dev = { |
| 226 | .platform_data = &csb726_flash_data, |
| 227 | }, |
| 228 | .resource = csb726_flash_resources, |
| 229 | .num_resources = ARRAY_SIZE(csb726_flash_resources), |
| 230 | }; |
| 231 | |
| 232 | static struct resource csb726_sm501_resources[] = { |
| 233 | { |
| 234 | .start = PXA_CS4_PHYS, |
| 235 | .end = PXA_CS4_PHYS + SZ_8M - 1, |
| 236 | .flags = IORESOURCE_MEM, |
| 237 | .name = "sm501-localmem", |
| 238 | }, |
| 239 | { |
| 240 | .start = PXA_CS4_PHYS + SZ_64M - SZ_2M, |
| 241 | .end = PXA_CS4_PHYS + SZ_64M - 1, |
| 242 | .flags = IORESOURCE_MEM, |
| 243 | .name = "sm501-regs", |
| 244 | }, |
| 245 | { |
| 246 | .start = CSB726_IRQ_SM501, |
| 247 | .end = CSB726_IRQ_SM501, |
| 248 | .flags = IORESOURCE_IRQ, |
| 249 | }, |
| 250 | }; |
| 251 | |
| 252 | static struct sm501_initdata csb726_sm501_initdata = { |
| 253 | /* .devices = SM501_USE_USB_HOST, */ |
| 254 | .devices = SM501_USE_USB_HOST | SM501_USE_UART0 | SM501_USE_UART1, |
| 255 | }; |
| 256 | |
| 257 | static struct sm501_platdata csb726_sm501_platdata = { |
| 258 | .init = &csb726_sm501_initdata, |
| 259 | }; |
| 260 | |
| 261 | static struct platform_device csb726_sm501 = { |
| 262 | .name = "sm501", |
| 263 | .id = 0, |
| 264 | .num_resources = ARRAY_SIZE(csb726_sm501_resources), |
| 265 | .resource = csb726_sm501_resources, |
| 266 | .dev = { |
| 267 | .platform_data = &csb726_sm501_platdata, |
| 268 | }, |
| 269 | }; |
| 270 | |
| 271 | static struct resource csb726_lan_resources[] = { |
| 272 | { |
| 273 | .start = PXA_CS3_PHYS, |
| 274 | .end = PXA_CS3_PHYS + SZ_64K - 1, |
| 275 | .flags = IORESOURCE_MEM, |
| 276 | }, |
| 277 | { |
| 278 | .start = CSB726_IRQ_LAN, |
| 279 | .end = CSB726_IRQ_LAN, |
Dmitry Eremin-Solenikov | b860171 | 2009-04-22 00:43:21 +0400 | [diff] [blame] | 280 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE, |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 281 | }, |
| 282 | }; |
| 283 | |
Dmitry Eremin-Solenikov | b860171 | 2009-04-22 00:43:21 +0400 | [diff] [blame] | 284 | struct smsc911x_platform_config csb726_lan_config = { |
| 285 | .irq_type = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 286 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 287 | .flags = SMSC911X_USE_32BIT, |
| 288 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 289 | }; |
| 290 | |
| 291 | |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 292 | static struct platform_device csb726_lan = { |
Dmitry Eremin-Solenikov | b860171 | 2009-04-22 00:43:21 +0400 | [diff] [blame] | 293 | .name = "smsc911x", |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 294 | .id = -1, |
| 295 | .num_resources = ARRAY_SIZE(csb726_lan_resources), |
| 296 | .resource = csb726_lan_resources, |
Dmitry Eremin-Solenikov | b860171 | 2009-04-22 00:43:21 +0400 | [diff] [blame] | 297 | .dev = { |
| 298 | .platform_data = &csb726_lan_config, |
| 299 | }, |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 300 | }; |
| 301 | |
| 302 | static struct platform_device *devices[] __initdata = { |
| 303 | &csb726_flash, |
| 304 | &csb726_sm501, |
| 305 | &csb726_lan, |
| 306 | }; |
| 307 | |
| 308 | static void __init csb726_init(void) |
| 309 | { |
| 310 | pxa2xx_mfp_config(ARRAY_AND_SIZE(csb726_pin_config)); |
| 311 | /* MSC1 = 0x7ffc3ffc; *//* LAN9215/EXP_CS */ |
| 312 | /* MSC2 = 0x06697ff4; *//* none/SM501 */ |
| 313 | MSC2 = (MSC2 & ~0xffff) | 0x7ff4; /* SM501 */ |
| 314 | |
| 315 | pxa_set_i2c_info(NULL); |
| 316 | pxa27x_set_i2c_power_info(NULL); |
| 317 | pxa_set_mci_info(&csb726_mci); |
| 318 | pxa_set_ohci_info(&csb726_ohci_platform_data); |
Dmitry Eremin-Solenikov | 96a9fca | 2009-04-22 00:43:22 +0400 | [diff] [blame^] | 319 | pxa_set_ac97_info(NULL); |
Dmitry Eremin-Solenikov | aac4297 | 2009-02-16 20:40:55 +0300 | [diff] [blame] | 320 | |
| 321 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 322 | } |
| 323 | |
| 324 | MACHINE_START(CSB726, "Cogent CSB726") |
| 325 | .phys_io = 0x40000000, |
| 326 | .boot_params = 0xa0000100, |
| 327 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 328 | .map_io = pxa_map_io, |
| 329 | .init_irq = pxa27x_init_irq, |
| 330 | .init_machine = csb726_init, |
| 331 | .timer = &pxa_timer, |
| 332 | MACHINE_END |