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