blob: 3c72fc34f142965580142ffc0493566a0bd70b67 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
2 * File: arch/blackfin/mach-bf537/boards/stamp.c
3 * Based on: arch/blackfin/mach-bf533/boards/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, see the file COPYING, or write
27 * to the Free Software Foundation, Inc.,
28 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
35#include <linux/spi/spi.h>
36#include <linux/spi/flash.h>
37#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38#include <linux/usb_isp1362.h>
39#endif
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080040#include <linux/irq.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080041#include <asm/dma.h>
Bryan Wu1394f032007-05-06 14:50:22 -070042#include <asm/bfin5xx_spi.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080043#include <asm/portmux.h>
David Brownell27f5d752007-10-04 18:06:16 -070044#include <linux/usb/sl811.h>
Bryan Wu1394f032007-05-06 14:50:22 -070045
46#include <linux/spi/ad7877.h>
47
48/*
49 * Name the Board for the /proc/cpuinfo
50 */
Mike Frysinger066954a2007-10-21 22:36:06 +080051const char bfin_board_name[] = "PNAV-1.0";
Bryan Wu1394f032007-05-06 14:50:22 -070052
53/*
54 * Driver needs to know address, irq and flag pin.
55 */
56
57#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
58static struct resource bfin_pcmcia_cf_resources[] = {
59 {
60 .start = 0x20310000, /* IO PORT */
61 .end = 0x20312000,
62 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080063 }, {
Simon Arlottd2d50aa2007-06-11 15:31:30 +080064 .start = 0x20311000, /* Attribute Memory */
Bryan Wu1394f032007-05-06 14:50:22 -070065 .end = 0x20311FFF,
66 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080067 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070068 .start = IRQ_PF4,
69 .end = IRQ_PF4,
70 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080071 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070072 .start = 6, /* Card Detect PF6 */
73 .end = 6,
74 .flags = IORESOURCE_IRQ,
75 },
76};
77
78static struct platform_device bfin_pcmcia_cf_device = {
79 .name = "bfin_cf_pcmcia",
80 .id = -1,
81 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
82 .resource = bfin_pcmcia_cf_resources,
83};
84#endif
85
86#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
87static struct platform_device rtc_device = {
88 .name = "rtc-bfin",
89 .id = -1,
90};
91#endif
92
93#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
94static struct resource smc91x_resources[] = {
95 {
96 .name = "smc91x-regs",
97 .start = 0x20300300,
98 .end = 0x20300300 + 16,
99 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800100 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700101
102 .start = IRQ_PF7,
103 .end = IRQ_PF7,
104 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
105 },
106};
107static struct platform_device smc91x_device = {
108 .name = "smc91x",
109 .id = 0,
110 .num_resources = ARRAY_SIZE(smc91x_resources),
111 .resource = smc91x_resources,
112};
113#endif
114
115#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
116static struct resource sl811_hcd_resources[] = {
117 {
118 .start = 0x20340000,
119 .end = 0x20340000,
120 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800121 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700122 .start = 0x20340004,
123 .end = 0x20340004,
124 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800125 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700126 .start = CONFIG_USB_SL811_BFIN_IRQ,
127 .end = CONFIG_USB_SL811_BFIN_IRQ,
128 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
129 },
130};
131
132#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
133void sl811_port_power(struct device *dev, int is_on)
134{
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800135 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
136 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS);
Bryan Wu1394f032007-05-06 14:50:22 -0700137
138 if (is_on)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800139 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 1);
Bryan Wu1394f032007-05-06 14:50:22 -0700140 else
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800141 gpio_set_value(CONFIG_USB_SL811_BFIN_GPIO_VBUS, 0);
Bryan Wu1394f032007-05-06 14:50:22 -0700142}
143#endif
144
145static struct sl811_platform_data sl811_priv = {
146 .potpg = 10,
147 .power = 250, /* == 500mA */
148#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
149 .port_power = &sl811_port_power,
150#endif
151};
152
153static struct platform_device sl811_hcd_device = {
154 .name = "sl811-hcd",
155 .id = 0,
156 .dev = {
157 .platform_data = &sl811_priv,
158 },
159 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
160 .resource = sl811_hcd_resources,
161};
162#endif
163
164#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
165static struct resource isp1362_hcd_resources[] = {
166 {
167 .start = 0x20360000,
168 .end = 0x20360000,
169 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800170 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700171 .start = 0x20360004,
172 .end = 0x20360004,
173 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800174 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700175 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
176 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
177 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
178 },
179};
180
181static struct isp1362_platform_data isp1362_priv = {
182 .sel15Kres = 1,
183 .clknotstop = 0,
184 .oc_enable = 0,
185 .int_act_high = 0,
186 .int_edge_triggered = 0,
187 .remote_wakeup_connected = 0,
188 .no_power_switching = 1,
189 .power_switching_mode = 0,
190};
191
192static struct platform_device isp1362_hcd_device = {
193 .name = "isp1362-hcd",
194 .id = 0,
195 .dev = {
196 .platform_data = &isp1362_priv,
197 },
198 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
199 .resource = isp1362_hcd_resources,
200};
201#endif
202
203#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
204static struct platform_device bfin_mac_device = {
205 .name = "bfin_mac",
206};
207#endif
208
209#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
210static struct resource net2272_bfin_resources[] = {
211 {
212 .start = 0x20300000,
213 .end = 0x20300000 + 0x100,
214 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800215 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700216 .start = IRQ_PF7,
217 .end = IRQ_PF7,
218 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
219 },
220};
221
222static struct platform_device net2272_bfin_device = {
223 .name = "net2272",
224 .id = -1,
225 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
226 .resource = net2272_bfin_resources,
227};
228#endif
229
230#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
231/* all SPI peripherals info goes here */
232
233#if defined(CONFIG_MTD_M25P80) \
234 || defined(CONFIG_MTD_M25P80_MODULE)
235static struct mtd_partition bfin_spi_flash_partitions[] = {
236 {
237 .name = "bootloader",
238 .size = 0x00020000,
239 .offset = 0,
240 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800241 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700242 .name = "kernel",
243 .size = 0xe0000,
244 .offset = 0x20000
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800245 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700246 .name = "file system",
247 .size = 0x700000,
248 .offset = 0x00100000,
249 }
250};
251
252static struct flash_platform_data bfin_spi_flash_data = {
253 .name = "m25p80",
254 .parts = bfin_spi_flash_partitions,
255 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
256 .type = "m25p64",
257};
258
259/* SPI flash chip (m25p64) */
260static struct bfin5xx_spi_chip spi_flash_chip_info = {
261 .enable_dma = 0, /* use dma transfer with this chip*/
262 .bits_per_word = 8,
263};
264#endif
265
266#if defined(CONFIG_SPI_ADC_BF533) \
267 || defined(CONFIG_SPI_ADC_BF533_MODULE)
268/* SPI ADC chip */
269static struct bfin5xx_spi_chip spi_adc_chip_info = {
270 .enable_dma = 1, /* use dma transfer with this chip*/
271 .bits_per_word = 16,
272};
273#endif
274
275#if defined(CONFIG_SND_BLACKFIN_AD1836) \
276 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
277static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
278 .enable_dma = 0,
279 .bits_per_word = 16,
280};
281#endif
282
283#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
284static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
285 .enable_dma = 0,
286 .bits_per_word = 16,
287};
288#endif
289
290#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
291static struct bfin5xx_spi_chip spi_mmc_chip_info = {
292 .enable_dma = 1,
293 .bits_per_word = 8,
294};
295#endif
296
Bryan Wu1394f032007-05-06 14:50:22 -0700297#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
298static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
299 .cs_change_per_word = 1,
300 .enable_dma = 0,
301 .bits_per_word = 16,
302};
303
304static const struct ad7877_platform_data bfin_ad7877_ts_info = {
305 .model = 7877,
306 .vref_delay_usecs = 50, /* internal, no capacitor */
307 .x_plate_ohms = 419,
308 .y_plate_ohms = 486,
309 .pressure_max = 1000,
310 .pressure_min = 0,
311 .stopacq_polarity = 1,
312 .first_conversion_delay = 3,
313 .acquisition_time = 1,
314 .averaging = 1,
315 .pen_down_acc_interval = 1,
316};
317#endif
318
319static struct spi_board_info bfin_spi_board_info[] __initdata = {
320#if defined(CONFIG_MTD_M25P80) \
321 || defined(CONFIG_MTD_M25P80_MODULE)
322 {
323 /* the modalias must be the same as spi device driver name */
324 .modalias = "m25p80", /* Name of spi_driver for this device */
325 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800326 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700327 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
328 .platform_data = &bfin_spi_flash_data,
329 .controller_data = &spi_flash_chip_info,
330 .mode = SPI_MODE_3,
331 },
332#endif
333
334#if defined(CONFIG_SPI_ADC_BF533) \
335 || defined(CONFIG_SPI_ADC_BF533_MODULE)
336 {
337 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
338 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800339 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700340 .chip_select = 1, /* Framework chip select. */
341 .platform_data = NULL, /* No spi_driver specific config */
342 .controller_data = &spi_adc_chip_info,
343 },
344#endif
345
346#if defined(CONFIG_SND_BLACKFIN_AD1836) \
347 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
348 {
349 .modalias = "ad1836-spi",
350 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800351 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700352 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
353 .controller_data = &ad1836_spi_chip_info,
354 },
355#endif
356#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
357 {
358 .modalias = "ad9960-spi",
359 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800360 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700361 .chip_select = 1,
362 .controller_data = &ad9960_spi_chip_info,
363 },
364#endif
365#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
366 {
367 .modalias = "spi_mmc_dummy",
368 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800369 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700370 .chip_select = 7,
371 .platform_data = NULL,
372 .controller_data = &spi_mmc_chip_info,
373 .mode = SPI_MODE_3,
374 },
375 {
376 .modalias = "spi_mmc",
377 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800378 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700379 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
380 .platform_data = NULL,
381 .controller_data = &spi_mmc_chip_info,
382 .mode = SPI_MODE_3,
383 },
384#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700385#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
386{
387 .modalias = "ad7877",
388 .platform_data = &bfin_ad7877_ts_info,
389 .irq = IRQ_PF2,
390 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
391 .bus_num = 1,
392 .chip_select = 5,
393 .controller_data = &spi_ad7877_chip_info,
394},
395#endif
396
397};
398
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800399/* SPI (0) */
400static struct resource bfin_spi0_resource[] = {
401 [0] = {
402 .start = SPI0_REGBASE,
403 .end = SPI0_REGBASE + 0xFF,
404 .flags = IORESOURCE_MEM,
405 },
406 [1] = {
407 .start = CH_SPI,
408 .end = CH_SPI,
409 .flags = IORESOURCE_IRQ,
410 }
411};
412
Bryan Wu1394f032007-05-06 14:50:22 -0700413/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800414static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700415 .num_chipselect = 8,
416 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800417 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700418};
419
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800420static struct platform_device bfin_spi0_device = {
421 .name = "bfin-spi",
422 .id = 0, /* Bus number */
423 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
424 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700425 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800426 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700427 },
428};
429#endif /* spi master and devices */
430
431#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
432static struct platform_device bfin_fb_device = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800433 .name = "bf537-lq035",
Bryan Wu1394f032007-05-06 14:50:22 -0700434};
435#endif
436
437#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
438static struct resource bfin_uart_resources[] = {
439 {
440 .start = 0xFFC00400,
441 .end = 0xFFC004FF,
442 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800443 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700444 .start = 0xFFC02000,
445 .end = 0xFFC020FF,
446 .flags = IORESOURCE_MEM,
447 },
448};
449
450static struct platform_device bfin_uart_device = {
451 .name = "bfin-uart",
452 .id = 1,
453 .num_resources = ARRAY_SIZE(bfin_uart_resources),
454 .resource = bfin_uart_resources,
455};
456#endif
457
458
459static struct platform_device *stamp_devices[] __initdata = {
460#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
461 &bfin_pcmcia_cf_device,
462#endif
463
464#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
465 &rtc_device,
466#endif
467
468#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
469 &sl811_hcd_device,
470#endif
471
472#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
473 &isp1362_hcd_device,
474#endif
475
476#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
477 &smc91x_device,
478#endif
479
480#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
481 &bfin_mac_device,
482#endif
483
484#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
485 &net2272_bfin_device,
486#endif
487
488#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800489 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700490#endif
491
492#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
493 &bfin_fb_device,
494#endif
495
496#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
497 &bfin_uart_device,
498#endif
499};
500
501static int __init stamp_init(void)
502{
503 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
504 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
505#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
506 spi_register_board_info(bfin_spi_board_info,
507 ARRAY_SIZE(bfin_spi_board_info));
508#endif
509 return 0;
510}
511
512arch_initcall(stamp_init);