2 * Support for Cogent CSB726
4 * Copyright (c) 2008 Dmitry Eremin-Solenikov
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.
11 #include <linux/kernel.h>
12 #include <linux/init.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>
20 #include <asm/mach-types.h>
21 #include <asm/mach/arch.h>
22 #include <mach/csb726.h>
23 #include <mach/mfp-pxa27x.h>
26 #include <mach/ohci.h>
27 #include <mach/pxa2xx-regs.h>
33 * n/a: 2, 5, 6, 7, 8, 23, 24, 25, 26, 27, 87, 88, 89,
34 * nu: 58 -- 77, 90, 91, 93, 102, 105-108, 114-116,
36 * XXX: 79 CS_3 for LAN9215 or PSKTSEL on R2, R3
37 * XXX: 33 CS_5 for LAN9215 on R1
40 static unsigned long csb726_pin_config[] = {
41 GPIO78_nCS_2, /* EXP_CS */
42 GPIO79_nCS_3, /* SMSC9215 */
43 GPIO80_nCS_4, /* SM501 */
45 GPIO52_GPIO, /* #SMSC9251 int */
46 GPIO53_GPIO, /* SM501 int */
48 GPIO1_GPIO, /* GPIO0 */
49 GPIO11_GPIO, /* GPIO1 */
50 GPIO9_GPIO, /* GPIO2 */
51 GPIO10_GPIO, /* GPIO3 */
52 GPIO16_PWM0_OUT, /* or GPIO4 */
53 GPIO17_PWM1_OUT, /* or GPIO5 */
54 GPIO94_GPIO, /* GPIO6 */
55 GPIO95_GPIO, /* GPIO7 */
56 GPIO96_GPIO, /* GPIO8 */
57 GPIO97_GPIO, /* GPIO9 */
58 GPIO15_GPIO, /* EXP_IRQ */
59 GPIO18_RDY, /* EXP_WAIT */
61 GPIO0_GPIO, /* PWR_INT */
62 GPIO104_GPIO, /* PWR_OFF */
64 GPIO12_GPIO, /* touch irq */
68 MFP_CFG_OUT(GPIO19, AF1, DRIVE_LOW),/* SSP2_SYSCLK */
76 GPIO20_GPIO, /* SDIO int */
83 GPIO100_GPIO, /* SD CD */
84 GPIO101_GPIO, /* SD WP */
87 GPIO29_AC97_SDATA_IN_0,
88 GPIO30_AC97_SDATA_OUT,
116 GPIO57_nIOIS16, /* maybe unused */
118 GPIO98_GPIO, /* CF IRQ */
119 GPIO99_GPIO, /* CF CD */
120 GPIO103_GPIO, /* Reset */
126 static struct pxamci_platform_data csb726_mci_data;
128 static int csb726_mci_init(struct device *dev,
129 irq_handler_t detect, void *data)
133 csb726_mci_data.detect_delay = msecs_to_jiffies(500);
135 err = gpio_request(CSB726_GPIO_MMC_DETECT, "MMC detect");
139 err = gpio_direction_input(CSB726_GPIO_MMC_DETECT);
143 err = gpio_request(CSB726_GPIO_MMC_RO, "MMC ro");
147 err = gpio_direction_input(CSB726_GPIO_MMC_RO);
151 err = request_irq(gpio_to_irq(CSB726_GPIO_MMC_DETECT), detect,
152 IRQF_DISABLED, "MMC card detect", data);
160 gpio_free(CSB726_GPIO_MMC_RO);
163 gpio_free(CSB726_GPIO_MMC_DETECT);
168 static int csb726_mci_get_ro(struct device *dev)
170 return gpio_get_value(CSB726_GPIO_MMC_RO);
173 static void csb726_mci_exit(struct device *dev, void *data)
175 free_irq(gpio_to_irq(CSB726_GPIO_MMC_DETECT), data);
176 gpio_free(CSB726_GPIO_MMC_RO);
177 gpio_free(CSB726_GPIO_MMC_DETECT);
180 static struct pxamci_platform_data csb726_mci = {
181 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
182 .init = csb726_mci_init,
183 .get_ro = csb726_mci_get_ro,
185 .exit = csb726_mci_exit,
188 static struct pxaohci_platform_data csb726_ohci_platform_data = {
189 .port_mode = PMM_NPS_MODE,
190 .flags = ENABLE_PORT1 | NO_OC_PROTECTION,
193 static struct mtd_partition csb726_flash_partitions[] = {
195 .name = "Bootloader",
197 .size = CSB726_FLASH_uMON,
198 .mask_flags = MTD_WRITEABLE /* force read-only */
202 .offset = MTDPART_OFS_APPEND,
203 .size = MTDPART_SIZ_FULL,
207 static struct physmap_flash_data csb726_flash_data = {
209 .parts = csb726_flash_partitions,
210 .nr_parts = ARRAY_SIZE(csb726_flash_partitions),
213 static struct resource csb726_flash_resources[] = {
215 .start = PXA_CS0_PHYS,
216 .end = PXA_CS0_PHYS + CSB726_FLASH_SIZE - 1 ,
217 .flags = IORESOURCE_MEM,
221 static struct platform_device csb726_flash = {
222 .name = "physmap-flash",
224 .platform_data = &csb726_flash_data,
226 .resource = csb726_flash_resources,
227 .num_resources = ARRAY_SIZE(csb726_flash_resources),
230 static struct resource csb726_sm501_resources[] = {
232 .start = PXA_CS4_PHYS,
233 .end = PXA_CS4_PHYS + SZ_8M - 1,
234 .flags = IORESOURCE_MEM,
235 .name = "sm501-localmem",
238 .start = PXA_CS4_PHYS + SZ_64M - SZ_2M,
239 .end = PXA_CS4_PHYS + SZ_64M - 1,
240 .flags = IORESOURCE_MEM,
241 .name = "sm501-regs",
244 .start = CSB726_IRQ_SM501,
245 .end = CSB726_IRQ_SM501,
246 .flags = IORESOURCE_IRQ,
250 static struct sm501_initdata csb726_sm501_initdata = {
251 /* .devices = SM501_USE_USB_HOST, */
252 .devices = SM501_USE_USB_HOST | SM501_USE_UART0 | SM501_USE_UART1,
255 static struct sm501_platdata csb726_sm501_platdata = {
256 .init = &csb726_sm501_initdata,
259 static struct platform_device csb726_sm501 = {
262 .num_resources = ARRAY_SIZE(csb726_sm501_resources),
263 .resource = csb726_sm501_resources,
265 .platform_data = &csb726_sm501_platdata,
269 static struct resource csb726_lan_resources[] = {
271 .start = PXA_CS3_PHYS,
272 .end = PXA_CS3_PHYS + SZ_64K - 1,
273 .flags = IORESOURCE_MEM,
276 .start = CSB726_IRQ_LAN,
277 .end = CSB726_IRQ_LAN,
278 .flags = IORESOURCE_IRQ,
282 static struct platform_device csb726_lan = {
285 .num_resources = ARRAY_SIZE(csb726_lan_resources),
286 .resource = csb726_lan_resources,
289 static struct platform_device *devices[] __initdata = {
295 static void __init csb726_init(void)
297 pxa2xx_mfp_config(ARRAY_AND_SIZE(csb726_pin_config));
298 /* MSC1 = 0x7ffc3ffc; *//* LAN9215/EXP_CS */
299 /* MSC2 = 0x06697ff4; *//* none/SM501 */
300 MSC2 = (MSC2 & ~0xffff) | 0x7ff4; /* SM501 */
302 pxa_set_i2c_info(NULL);
303 pxa27x_set_i2c_power_info(NULL);
304 pxa_set_mci_info(&csb726_mci);
305 pxa_set_ohci_info(&csb726_ohci_platform_data);
307 platform_add_devices(devices, ARRAY_SIZE(devices));
310 MACHINE_START(CSB726, "Cogent CSB726")
311 .phys_io = 0x40000000,
312 .boot_params = 0xa0000100,
313 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
314 .map_io = pxa_map_io,
315 .init_irq = pxa27x_init_irq,
316 .init_machine = csb726_init,