Linux 2.6.26
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / blackfin / mach-bf537 / boards / stamp.c
CommitLineData
1394f032
BW
1/*
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>
de8c43f2 35#include <linux/mtd/physmap.h>
1394f032
BW
36#include <linux/spi/spi.h>
37#include <linux/spi/flash.h>
38#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
f02bcec5 39#include <linux/usb/isp1362.h>
1394f032 40#endif
0a87e3e9 41#include <linux/ata_platform.h>
1394f032
BW
42#include <linux/irq.h>
43#include <linux/interrupt.h>
81d9c7f2 44#include <linux/i2c.h>
27f5d75a 45#include <linux/usb/sl811.h>
c6c4d7bb 46#include <asm/dma.h>
1f83b8f1 47#include <asm/bfin5xx_spi.h>
c6c4d7bb 48#include <asm/reboot.h>
5d448dd5 49#include <asm/portmux.h>
14b03204 50#include <asm/dpmc.h>
1394f032
BW
51#include <linux/spi/ad7877.h>
52
53/*
54 * Name the Board for the /proc/cpuinfo
55 */
066954a3 56const char bfin_board_name[] = "ADDS-BF537-STAMP";
1394f032
BW
57
58/*
59 * Driver needs to know address, irq and flag pin.
60 */
61
62#define ISP1761_BASE 0x203C0000
63#define ISP1761_IRQ IRQ_PF7
64
65#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
66static struct resource bfin_isp1761_resources[] = {
67 [0] = {
68 .name = "isp1761-regs",
69 .start = ISP1761_BASE + 0x00000000,
70 .end = ISP1761_BASE + 0x000fffff,
71 .flags = IORESOURCE_MEM,
72 },
73 [1] = {
74 .start = ISP1761_IRQ,
75 .end = ISP1761_IRQ,
76 .flags = IORESOURCE_IRQ,
77 },
78};
79
80static struct platform_device bfin_isp1761_device = {
81 .name = "isp1761",
82 .id = 0,
83 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
84 .resource = bfin_isp1761_resources,
85};
86
87static struct platform_device *bfin_isp1761_devices[] = {
88 &bfin_isp1761_device,
89};
90
91int __init bfin_isp1761_init(void)
92{
1f83b8f1 93 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
1394f032 94
b85d858b 95 printk(KERN_INFO "%s(): registering device resources\n", __func__);
1394f032
BW
96 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
97
98 return platform_add_devices(bfin_isp1761_devices, num_devices);
99}
100
101void __exit bfin_isp1761_exit(void)
102{
103 platform_device_unregister(&bfin_isp1761_device);
104}
105
106arch_initcall(bfin_isp1761_init);
107#endif
108
2463ef22
MH
109#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
110#include <linux/input.h>
111#include <linux/gpio_keys.h>
112
113static struct gpio_keys_button bfin_gpio_keys_table[] = {
114 {BTN_0, GPIO_PF2, 1, "gpio-keys: BTN0"},
115 {BTN_1, GPIO_PF3, 1, "gpio-keys: BTN1"},
116 {BTN_2, GPIO_PF4, 1, "gpio-keys: BTN2"},
117 {BTN_3, GPIO_PF5, 1, "gpio-keys: BTN3"},
118};
119
120static struct gpio_keys_platform_data bfin_gpio_keys_data = {
121 .buttons = bfin_gpio_keys_table,
122 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
123};
124
125static struct platform_device bfin_device_gpiokeys = {
126 .name = "gpio-keys",
127 .dev = {
128 .platform_data = &bfin_gpio_keys_data,
129 },
130};
131#endif
132
cad2ab65
MF
133static struct resource bfin_gpios_resources = {
134 .start = 0,
135 .end = MAX_BLACKFIN_GPIOS - 1,
136 .flags = IORESOURCE_IRQ,
137};
138
139static struct platform_device bfin_gpios_device = {
140 .name = "simple-gpio",
141 .id = -1,
142 .num_resources = 1,
143 .resource = &bfin_gpios_resources,
144};
145
1394f032
BW
146#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
147static struct resource bfin_pcmcia_cf_resources[] = {
148 {
149 .start = 0x20310000, /* IO PORT */
150 .end = 0x20312000,
151 .flags = IORESOURCE_MEM,
1f83b8f1 152 }, {
d2d50aa9 153 .start = 0x20311000, /* Attribute Memory */
1394f032
BW
154 .end = 0x20311FFF,
155 .flags = IORESOURCE_MEM,
1f83b8f1 156 }, {
1394f032
BW
157 .start = IRQ_PF4,
158 .end = IRQ_PF4,
159 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
1f83b8f1 160 }, {
1394f032
BW
161 .start = 6, /* Card Detect PF6 */
162 .end = 6,
163 .flags = IORESOURCE_IRQ,
164 },
165};
166
167static struct platform_device bfin_pcmcia_cf_device = {
168 .name = "bfin_cf_pcmcia",
169 .id = -1,
170 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
171 .resource = bfin_pcmcia_cf_resources,
172};
173#endif
174
175#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
176static struct platform_device rtc_device = {
177 .name = "rtc-bfin",
178 .id = -1,
179};
180#endif
181
182#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
183static struct resource smc91x_resources[] = {
184 {
185 .name = "smc91x-regs",
186 .start = 0x20300300,
187 .end = 0x20300300 + 16,
188 .flags = IORESOURCE_MEM,
1f83b8f1 189 }, {
1394f032
BW
190
191 .start = IRQ_PF7,
192 .end = IRQ_PF7,
193 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
194 },
195};
196static struct platform_device smc91x_device = {
197 .name = "smc91x",
198 .id = 0,
199 .num_resources = ARRAY_SIZE(smc91x_resources),
200 .resource = smc91x_resources,
201};
202#endif
203
f40d24d9
AL
204#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
205static struct resource dm9000_resources[] = {
206 [0] = {
207 .start = 0x203FB800,
208 .end = 0x203FB800 + 8,
209 .flags = IORESOURCE_MEM,
210 },
211 [1] = {
212 .start = IRQ_PF9,
213 .end = IRQ_PF9,
214 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
215 },
216};
217
218static struct platform_device dm9000_device = {
219 .name = "dm9000",
220 .id = -1,
221 .num_resources = ARRAY_SIZE(dm9000_resources),
222 .resource = dm9000_resources,
223};
224#endif
225
561cc18b
MH
226#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
227static struct resource ax88180_resources[] = {
228 [0] = {
229 .start = 0x20300000,
230 .end = 0x20300000 + 0x8000,
231 .flags = IORESOURCE_MEM,
232 },
233 [1] = {
234 .start = IRQ_PF7,
235 .end = IRQ_PF7,
236 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL),
237 },
238};
239
240static struct platform_device ax88180_device = {
241 .name = "ax88180",
242 .id = -1,
243 .num_resources = ARRAY_SIZE(ax88180_resources),
244 .resource = ax88180_resources,
245};
246#endif
247
1394f032
BW
248#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
249static struct resource sl811_hcd_resources[] = {
250 {
251 .start = 0x20340000,
252 .end = 0x20340000,
253 .flags = IORESOURCE_MEM,
1f83b8f1 254 }, {
1394f032
BW
255 .start = 0x20340004,
256 .end = 0x20340004,
257 .flags = IORESOURCE_MEM,
1f83b8f1 258 }, {
1394f032
BW
259 .start = CONFIG_USB_SL811_BFIN_IRQ,
260 .end = CONFIG_USB_SL811_BFIN_IRQ,
261 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
262 },
263};
264
265#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
266void sl811_port_power(struct device *dev, int is_on)
267{
c6c4d7bb 268 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
acbcd263 269 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
1394f032
BW
270}
271#endif
272
273static struct sl811_platform_data sl811_priv = {
274 .potpg = 10,
275 .power = 250, /* == 500mA */
276#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
277 .port_power = &sl811_port_power,
278#endif
279};
280
281static struct platform_device sl811_hcd_device = {
282 .name = "sl811-hcd",
283 .id = 0,
284 .dev = {
285 .platform_data = &sl811_priv,
286 },
287 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
288 .resource = sl811_hcd_resources,
289};
290#endif
291
292#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
293static struct resource isp1362_hcd_resources[] = {
294 {
295 .start = 0x20360000,
296 .end = 0x20360000,
297 .flags = IORESOURCE_MEM,
1f83b8f1 298 }, {
1394f032
BW
299 .start = 0x20360004,
300 .end = 0x20360004,
301 .flags = IORESOURCE_MEM,
1f83b8f1 302 }, {
1394f032
BW
303 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
304 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
305 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
306 },
307};
308
309static struct isp1362_platform_data isp1362_priv = {
310 .sel15Kres = 1,
311 .clknotstop = 0,
312 .oc_enable = 0,
313 .int_act_high = 0,
314 .int_edge_triggered = 0,
315 .remote_wakeup_connected = 0,
316 .no_power_switching = 1,
317 .power_switching_mode = 0,
318};
319
320static struct platform_device isp1362_hcd_device = {
321 .name = "isp1362-hcd",
322 .id = 0,
323 .dev = {
324 .platform_data = &isp1362_priv,
325 },
326 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
327 .resource = isp1362_hcd_resources,
328};
329#endif
330
331#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
332static struct platform_device bfin_mac_device = {
333 .name = "bfin_mac",
334};
335#endif
336
337#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
338static struct resource net2272_bfin_resources[] = {
339 {
340 .start = 0x20300000,
341 .end = 0x20300000 + 0x100,
342 .flags = IORESOURCE_MEM,
1f83b8f1 343 }, {
1394f032
BW
344 .start = IRQ_PF7,
345 .end = IRQ_PF7,
346 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
347 },
348};
349
350static struct platform_device net2272_bfin_device = {
351 .name = "net2272",
352 .id = -1,
353 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
354 .resource = net2272_bfin_resources,
355};
356#endif
357
793dc27b 358#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
de8c43f2
MF
359static struct mtd_partition stamp_partitions[] = {
360 {
361 .name = "Bootloader",
edf05641 362 .size = 0x40000,
de8c43f2
MF
363 .offset = 0,
364 }, {
365 .name = "Kernel",
366 .size = 0xE0000,
367 .offset = MTDPART_OFS_APPEND,
368 }, {
369 .name = "RootFS",
edf05641 370 .size = 0x400000 - 0x40000 - 0xE0000 - 0x10000,
de8c43f2
MF
371 .offset = MTDPART_OFS_APPEND,
372 }, {
373 .name = "MAC Address",
374 .size = MTDPART_SIZ_FULL,
375 .offset = 0x3F0000,
376 .mask_flags = MTD_WRITEABLE,
377 }
378};
379
380static struct physmap_flash_data stamp_flash_data = {
381 .width = 2,
382 .parts = stamp_partitions,
383 .nr_parts = ARRAY_SIZE(stamp_partitions),
384};
385
386static struct resource stamp_flash_resource = {
387 .start = 0x20000000,
388 .end = 0x203fffff,
389 .flags = IORESOURCE_MEM,
390};
391
392static struct platform_device stamp_flash_device = {
393 .name = "physmap-flash",
394 .id = 0,
395 .dev = {
396 .platform_data = &stamp_flash_data,
397 },
398 .num_resources = 1,
399 .resource = &stamp_flash_resource,
400};
793dc27b 401#endif
de8c43f2 402
1394f032
BW
403#if defined(CONFIG_MTD_M25P80) \
404 || defined(CONFIG_MTD_M25P80_MODULE)
405static struct mtd_partition bfin_spi_flash_partitions[] = {
406 {
407 .name = "bootloader",
edf05641 408 .size = 0x00040000,
1394f032
BW
409 .offset = 0,
410 .mask_flags = MTD_CAP_ROM
1f83b8f1 411 }, {
1394f032
BW
412 .name = "kernel",
413 .size = 0xe0000,
edf05641 414 .offset = MTDPART_OFS_APPEND,
1f83b8f1 415 }, {
1394f032 416 .name = "file system",
edf05641
MF
417 .size = MTDPART_SIZ_FULL,
418 .offset = MTDPART_OFS_APPEND,
1394f032
BW
419 }
420};
421
422static struct flash_platform_data bfin_spi_flash_data = {
423 .name = "m25p80",
424 .parts = bfin_spi_flash_partitions,
425 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
426 .type = "m25p64",
427};
428
429/* SPI flash chip (m25p64) */
430static struct bfin5xx_spi_chip spi_flash_chip_info = {
431 .enable_dma = 0, /* use dma transfer with this chip*/
432 .bits_per_word = 8,
433};
434#endif
435
436#if defined(CONFIG_SPI_ADC_BF533) \
437 || defined(CONFIG_SPI_ADC_BF533_MODULE)
438/* SPI ADC chip */
439static struct bfin5xx_spi_chip spi_adc_chip_info = {
440 .enable_dma = 1, /* use dma transfer with this chip*/
441 .bits_per_word = 16,
442};
443#endif
444
445#if defined(CONFIG_SND_BLACKFIN_AD1836) \
446 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
447static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
448 .enable_dma = 0,
449 .bits_per_word = 16,
450};
451#endif
452
453#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
454static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
455 .enable_dma = 0,
456 .bits_per_word = 16,
457};
458#endif
459
460#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
461static struct bfin5xx_spi_chip spi_mmc_chip_info = {
462 .enable_dma = 1,
463 .bits_per_word = 8,
464};
465#endif
466
467#if defined(CONFIG_PBX)
468static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
469 .ctl_reg = 0x4, /* send zero */
470 .enable_dma = 0,
471 .bits_per_word = 8,
472 .cs_change_per_word = 1,
473};
474#endif
475
1394f032
BW
476#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
477static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
1394f032
BW
478 .enable_dma = 0,
479 .bits_per_word = 16,
480};
481
482static const struct ad7877_platform_data bfin_ad7877_ts_info = {
483 .model = 7877,
484 .vref_delay_usecs = 50, /* internal, no capacitor */
485 .x_plate_ohms = 419,
486 .y_plate_ohms = 486,
487 .pressure_max = 1000,
488 .pressure_min = 0,
489 .stopacq_polarity = 1,
490 .first_conversion_delay = 3,
491 .acquisition_time = 1,
492 .averaging = 1,
493 .pen_down_acc_interval = 1,
494};
495#endif
496
6e668936
MH
497#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
498static struct bfin5xx_spi_chip spidev_chip_info = {
499 .enable_dma = 0,
500 .bits_per_word = 8,
501};
502#endif
503
8e9d5c7d
MH
504#if defined(CONFIG_MTD_DATAFLASH) \
505 || defined(CONFIG_MTD_DATAFLASH_MODULE)
506/* DataFlash chip */
507static struct bfin5xx_spi_chip data_flash_chip_info = {
508 .enable_dma = 0, /* use dma transfer with this chip*/
509 .bits_per_word = 8,
510};
511#endif
512
1394f032
BW
513static struct spi_board_info bfin_spi_board_info[] __initdata = {
514#if defined(CONFIG_MTD_M25P80) \
515 || defined(CONFIG_MTD_M25P80_MODULE)
516 {
517 /* the modalias must be the same as spi device driver name */
518 .modalias = "m25p80", /* Name of spi_driver for this device */
519 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 520 .bus_num = 0, /* Framework bus number */
1394f032
BW
521 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
522 .platform_data = &bfin_spi_flash_data,
523 .controller_data = &spi_flash_chip_info,
524 .mode = SPI_MODE_3,
525 },
526#endif
8e9d5c7d
MH
527#if defined(CONFIG_MTD_DATAFLASH) \
528 || defined(CONFIG_MTD_DATAFLASH_MODULE)
529 { /* DataFlash chip */
530 .modalias = "mtd_dataflash",
531 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
532 .bus_num = 0, /* Framework bus number */
533 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
534 .controller_data = &data_flash_chip_info,
535 .mode = SPI_MODE_3,
536 },
537#endif
1394f032
BW
538#if defined(CONFIG_SPI_ADC_BF533) \
539 || defined(CONFIG_SPI_ADC_BF533_MODULE)
540 {
541 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
542 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 543 .bus_num = 0, /* Framework bus number */
1394f032
BW
544 .chip_select = 1, /* Framework chip select. */
545 .platform_data = NULL, /* No spi_driver specific config */
546 .controller_data = &spi_adc_chip_info,
547 },
548#endif
549
550#if defined(CONFIG_SND_BLACKFIN_AD1836) \
551 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
552 {
553 .modalias = "ad1836-spi",
554 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 555 .bus_num = 0,
1394f032
BW
556 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
557 .controller_data = &ad1836_spi_chip_info,
558 },
559#endif
560#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
561 {
562 .modalias = "ad9960-spi",
563 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 564 .bus_num = 0,
1394f032
BW
565 .chip_select = 1,
566 .controller_data = &ad9960_spi_chip_info,
567 },
568#endif
569#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
570 {
571 .modalias = "spi_mmc_dummy",
111cf97d 572 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 573 .bus_num = 0,
1394f032
BW
574 .chip_select = 0,
575 .platform_data = NULL,
576 .controller_data = &spi_mmc_chip_info,
577 .mode = SPI_MODE_3,
578 },
579 {
580 .modalias = "spi_mmc",
111cf97d 581 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 582 .bus_num = 0,
1394f032
BW
583 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
584 .platform_data = NULL,
585 .controller_data = &spi_mmc_chip_info,
586 .mode = SPI_MODE_3,
587 },
588#endif
589#if defined(CONFIG_PBX)
590 {
1f83b8f1
MF
591 .modalias = "fxs-spi",
592 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb
BW
593 .bus_num = 0,
594 .chip_select = 8 - CONFIG_J11_JUMPER,
1f83b8f1 595 .controller_data = &spi_si3xxx_chip_info,
1394f032
BW
596 .mode = SPI_MODE_3,
597 },
598 {
1f83b8f1
MF
599 .modalias = "fxo-spi",
600 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb
BW
601 .bus_num = 0,
602 .chip_select = 8 - CONFIG_J19_JUMPER,
1f83b8f1 603 .controller_data = &spi_si3xxx_chip_info,
1394f032
BW
604 .mode = SPI_MODE_3,
605 },
606#endif
1394f032
BW
607#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
608 {
609 .modalias = "ad7877",
610 .platform_data = &bfin_ad7877_ts_info,
611 .irq = IRQ_PF6,
612 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
c7d48966 613 .bus_num = 0,
1394f032
BW
614 .chip_select = 1,
615 .controller_data = &spi_ad7877_chip_info,
616 },
617#endif
6e668936
MH
618#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
619 {
620 .modalias = "spidev",
621 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
622 .bus_num = 0,
623 .chip_select = 1,
624 .controller_data = &spidev_chip_info,
625 },
626#endif
1394f032
BW
627};
628
5bda2723 629#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
1394f032 630/* SPI controller data */
c6c4d7bb 631static struct bfin5xx_spi_master bfin_spi0_info = {
1394f032
BW
632 .num_chipselect = 8,
633 .enable_dma = 1, /* master has the ability to do dma transfer */
5d448dd5 634 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1394f032
BW
635};
636
c6c4d7bb
BW
637/* SPI (0) */
638static struct resource bfin_spi0_resource[] = {
639 [0] = {
640 .start = SPI0_REGBASE,
641 .end = SPI0_REGBASE + 0xFF,
642 .flags = IORESOURCE_MEM,
643 },
644 [1] = {
645 .start = CH_SPI,
646 .end = CH_SPI,
647 .flags = IORESOURCE_IRQ,
648 },
649};
650
651static struct platform_device bfin_spi0_device = {
652 .name = "bfin-spi",
653 .id = 0, /* Bus number */
654 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
655 .resource = bfin_spi0_resource,
1394f032 656 .dev = {
c6c4d7bb 657 .platform_data = &bfin_spi0_info, /* Passed to driver */
1394f032
BW
658 },
659};
660#endif /* spi master and devices */
661
662#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
663static struct platform_device bfin_fb_device = {
c6c4d7bb
BW
664 .name = "bf537-lq035",
665};
666#endif
667
668#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
669static struct platform_device bfin_fb_adv7393_device = {
670 .name = "bfin-adv7393",
1394f032
BW
671};
672#endif
673
674#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
675static struct resource bfin_uart_resources[] = {
233b28a9 676#ifdef CONFIG_SERIAL_BFIN_UART0
1394f032
BW
677 {
678 .start = 0xFFC00400,
679 .end = 0xFFC004FF,
680 .flags = IORESOURCE_MEM,
233b28a9
SZ
681 },
682#endif
683#ifdef CONFIG_SERIAL_BFIN_UART1
684 {
1394f032
BW
685 .start = 0xFFC02000,
686 .end = 0xFFC020FF,
687 .flags = IORESOURCE_MEM,
688 },
233b28a9 689#endif
1394f032
BW
690};
691
692static struct platform_device bfin_uart_device = {
693 .name = "bfin-uart",
694 .id = 1,
695 .num_resources = ARRAY_SIZE(bfin_uart_resources),
696 .resource = bfin_uart_resources,
697};
698#endif
699
5be36d22
GY
700#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
701static struct resource bfin_sir_resources[] = {
702#ifdef CONFIG_BFIN_SIR0
703 {
704 .start = 0xFFC00400,
705 .end = 0xFFC004FF,
706 .flags = IORESOURCE_MEM,
707 },
708#endif
709#ifdef CONFIG_BFIN_SIR1
710 {
711 .start = 0xFFC02000,
712 .end = 0xFFC020FF,
713 .flags = IORESOURCE_MEM,
714 },
715#endif
716};
717
718static struct platform_device bfin_sir_device = {
719 .name = "bfin_sir",
720 .id = 0,
721 .num_resources = ARRAY_SIZE(bfin_sir_resources),
722 .resource = bfin_sir_resources,
723};
724#endif
725
1394f032 726#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
c6c4d7bb
BW
727static struct resource bfin_twi0_resource[] = {
728 [0] = {
729 .start = TWI0_REGBASE,
730 .end = TWI0_REGBASE,
731 .flags = IORESOURCE_MEM,
732 },
733 [1] = {
734 .start = IRQ_TWI,
735 .end = IRQ_TWI,
736 .flags = IORESOURCE_IRQ,
737 },
738};
739
1394f032
BW
740static struct platform_device i2c_bfin_twi_device = {
741 .name = "i2c-bfin-twi",
742 .id = 0,
c6c4d7bb
BW
743 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
744 .resource = bfin_twi0_resource,
1394f032
BW
745};
746#endif
747
81d9c7f2
BW
748#ifdef CONFIG_I2C_BOARDINFO
749static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
750#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
751 {
752 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
81d9c7f2
BW
753 .irq = 55,
754 },
755#endif
756#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
757 {
758 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
81d9c7f2
BW
759 },
760#endif
761#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
762 {
763 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
81d9c7f2
BW
764 .irq = 72,
765 },
766#endif
767};
768#endif
769
1394f032
BW
770#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
771static struct platform_device bfin_sport0_uart_device = {
772 .name = "bfin-sport-uart",
773 .id = 0,
774};
775
776static struct platform_device bfin_sport1_uart_device = {
777 .name = "bfin-sport-uart",
778 .id = 1,
779};
780#endif
781
c6c4d7bb
BW
782#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
783#define PATA_INT 55
784
785static struct pata_platform_info bfin_pata_platform_data = {
786 .ioport_shift = 1,
64e5c512 787 .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
c6c4d7bb
BW
788};
789
790static struct resource bfin_pata_resources[] = {
791 {
792 .start = 0x20314020,
793 .end = 0x2031403F,
794 .flags = IORESOURCE_MEM,
795 },
796 {
797 .start = 0x2031401C,
798 .end = 0x2031401F,
799 .flags = IORESOURCE_MEM,
800 },
801 {
802 .start = PATA_INT,
803 .end = PATA_INT,
804 .flags = IORESOURCE_IRQ,
805 },
806};
807
808static struct platform_device bfin_pata_device = {
809 .name = "pata_platform",
810 .id = -1,
811 .num_resources = ARRAY_SIZE(bfin_pata_resources),
812 .resource = bfin_pata_resources,
813 .dev = {
814 .platform_data = &bfin_pata_platform_data,
815 }
816};
817#endif
818
14b03204
MH
819static const unsigned int cclk_vlev_datasheet[] =
820{
821 VRPAIR(VLEV_085, 250000000),
822 VRPAIR(VLEV_090, 376000000),
823 VRPAIR(VLEV_095, 426000000),
824 VRPAIR(VLEV_100, 426000000),
825 VRPAIR(VLEV_105, 476000000),
826 VRPAIR(VLEV_110, 476000000),
827 VRPAIR(VLEV_115, 476000000),
828 VRPAIR(VLEV_120, 500000000),
829 VRPAIR(VLEV_125, 533000000),
830 VRPAIR(VLEV_130, 600000000),
831};
832
833static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
834 .tuple_tab = cclk_vlev_datasheet,
835 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
836 .vr_settling_time = 25 /* us */,
837};
838
839static struct platform_device bfin_dpmc = {
840 .name = "bfin dpmc",
841 .dev = {
842 .platform_data = &bfin_dmpc_vreg_data,
843 },
844};
845
1394f032 846static struct platform_device *stamp_devices[] __initdata = {
14b03204
MH
847
848 &bfin_dpmc,
849
1394f032
BW
850#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
851 &bfin_pcmcia_cf_device,
852#endif
853
854#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
855 &rtc_device,
856#endif
857
858#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
859 &sl811_hcd_device,
860#endif
861
862#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
863 &isp1362_hcd_device,
864#endif
865
866#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
867 &smc91x_device,
868#endif
869
f40d24d9
AL
870#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
871 &dm9000_device,
872#endif
873
561cc18b
MH
874#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
875 &ax88180_device,
876#endif
877
1394f032
BW
878#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
879 &bfin_mac_device,
880#endif
881
882#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
883 &net2272_bfin_device,
884#endif
885
886#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
c6c4d7bb 887 &bfin_spi0_device,
1394f032
BW
888#endif
889
890#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
891 &bfin_fb_device,
892#endif
893
c6c4d7bb
BW
894#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
895 &bfin_fb_adv7393_device,
896#endif
897
1394f032
BW
898#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
899 &bfin_uart_device,
900#endif
901
5be36d22
GY
902#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
903 &bfin_sir_device,
904#endif
905
1394f032
BW
906#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
907 &i2c_bfin_twi_device,
908#endif
909
910#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
911 &bfin_sport0_uart_device,
912 &bfin_sport1_uart_device,
913#endif
c6c4d7bb
BW
914
915#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
916 &bfin_pata_device,
917#endif
2463ef22
MH
918
919#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
920 &bfin_device_gpiokeys,
921#endif
cad2ab65
MF
922
923 &bfin_gpios_device,
793dc27b
MF
924
925#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
de8c43f2 926 &stamp_flash_device,
793dc27b 927#endif
1394f032
BW
928};
929
930static int __init stamp_init(void)
931{
b85d858b 932 printk(KERN_INFO "%s(): registering device resources\n", __func__);
81d9c7f2
BW
933
934#ifdef CONFIG_I2C_BOARDINFO
935 i2c_register_board_info(0, bfin_i2c_board_info,
936 ARRAY_SIZE(bfin_i2c_board_info));
937#endif
938
1394f032 939 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
5bda2723 940 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
c6c4d7bb
BW
941
942#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
943 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
944#endif
81d9c7f2 945
1394f032
BW
946 return 0;
947}
948
949arch_initcall(stamp_init);
c6c4d7bb
BW
950
951void native_machine_restart(char *cmd)
952{
953 /* workaround reboot hang when booting from SPI */
954 if ((bfin_read_SYSCR() & 0x7) == 0x3)
955 bfin_gpio_reset_spi0_ssel1();
956}
137b1529
MF
957
958/*
959 * Currently the MAC address is saved in Flash by U-Boot
960 */
961#define FLASH_MAC 0x203f0000
9862cc52 962void bfin_get_ether_addr(char *addr)
137b1529
MF
963{
964 *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
965 *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
966}
9862cc52 967EXPORT_SYMBOL(bfin_get_ether_addr);