blob: 671f9d67f23a33b34207c965cce9ec53f386345a [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>
Mike Frysingerde8c43f2008-01-24 17:14:04 +080035#include <linux/mtd/physmap.h>
Bryan Wu1394f032007-05-06 14:50:22 -070036#include <linux/spi/spi.h>
37#include <linux/spi/flash.h>
38#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
Mike Frysingerf02bcec2007-11-15 21:29:15 +080039#include <linux/usb/isp1362.h>
Bryan Wu1394f032007-05-06 14:50:22 -070040#endif
Jeff Garzik0a87e3e2008-02-01 18:02:30 -050041#include <linux/ata_platform.h>
Bryan Wu1394f032007-05-06 14:50:22 -070042#include <linux/irq.h>
43#include <linux/interrupt.h>
Bryan Wu81d9c7f2008-03-26 10:02:13 +080044#include <linux/i2c.h>
David Brownell27f5d752007-10-04 18:06:16 -070045#include <linux/usb/sl811.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080046#include <asm/dma.h>
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080047#include <asm/bfin5xx_spi.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080048#include <asm/reboot.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080049#include <asm/portmux.h>
Michael Hennerich14b03202008-05-07 11:41:26 +080050#include <asm/dpmc.h>
Bryan Wu1394f032007-05-06 14:50:22 -070051#include <linux/spi/ad7877.h>
52
53/*
54 * Name the Board for the /proc/cpuinfo
55 */
Mike Frysinger066954a2007-10-21 22:36:06 +080056const char bfin_board_name[] = "ADDS-BF537-STAMP";
Bryan Wu1394f032007-05-06 14:50:22 -070057
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{
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080093 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
Bryan Wu1394f032007-05-06 14:50:22 -070094
Harvey Harrisonb85d8582008-04-23 09:39:01 +080095 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu1394f032007-05-06 14:50:22 -070096 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
Michael Hennerich2463ef22008-01-27 16:49:48 +0800109#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
Mike Frysingercad2ab62008-02-22 17:01:31 +0800133static 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
Bryan Wu1394f032007-05-06 14:50:22 -0700146#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,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800152 }, {
Simon Arlottd2d50aa2007-06-11 15:31:30 +0800153 .start = 0x20311000, /* Attribute Memory */
Bryan Wu1394f032007-05-06 14:50:22 -0700154 .end = 0x20311FFF,
155 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800156 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700157 .start = IRQ_PF4,
158 .end = IRQ_PF4,
159 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800160 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700161 .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,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800189 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700190
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
Alex Landauf40d24d2007-07-12 12:11:48 +0800204#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
Michael Hennerich561cc182007-11-17 23:56:08 +0800226#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
Bryan Wu1394f032007-05-06 14:50:22 -0700248#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,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800254 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700255 .start = 0x20340004,
256 .end = 0x20340004,
257 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800258 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700259 .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{
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800268 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
Michael Hennerichacbcd262008-01-22 18:36:20 +0800269 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
Bryan Wu1394f032007-05-06 14:50:22 -0700270}
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,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800298 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700299 .start = 0x20360004,
300 .end = 0x20360004,
301 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800302 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700303 .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,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800343 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700344 .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
Mike Frysinger793dc272008-03-26 08:09:12 +0800358#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800359static struct mtd_partition stamp_partitions[] = {
360 {
361 .name = "Bootloader",
Mike Frysingeredf05642008-02-25 11:38:11 +0800362 .size = 0x40000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800363 .offset = 0,
364 }, {
365 .name = "Kernel",
366 .size = 0xE0000,
367 .offset = MTDPART_OFS_APPEND,
368 }, {
369 .name = "RootFS",
Mike Frysingeredf05642008-02-25 11:38:11 +0800370 .size = 0x400000 - 0x40000 - 0xE0000 - 0x10000,
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800371 .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};
Mike Frysinger793dc272008-03-26 08:09:12 +0800401#endif
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800402
Bryan Wu1394f032007-05-06 14:50:22 -0700403#if defined(CONFIG_MTD_M25P80) \
404 || defined(CONFIG_MTD_M25P80_MODULE)
405static struct mtd_partition bfin_spi_flash_partitions[] = {
406 {
407 .name = "bootloader",
Mike Frysingeredf05642008-02-25 11:38:11 +0800408 .size = 0x00040000,
Bryan Wu1394f032007-05-06 14:50:22 -0700409 .offset = 0,
410 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800411 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700412 .name = "kernel",
413 .size = 0xe0000,
Mike Frysingeredf05642008-02-25 11:38:11 +0800414 .offset = MTDPART_OFS_APPEND,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800415 }, {
Bryan Wu1394f032007-05-06 14:50:22 -0700416 .name = "file system",
Mike Frysingeredf05642008-02-25 11:38:11 +0800417 .size = MTDPART_SIZ_FULL,
418 .offset = MTDPART_OFS_APPEND,
Bryan Wu1394f032007-05-06 14:50:22 -0700419 }
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
Bryan Wu1394f032007-05-06 14:50:22 -0700476#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
477static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700478 .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
Michael Hennerich6e668932008-02-09 01:54:09 +0800497#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
Michael Hennerich8e9d5c72008-04-24 08:46:19 +0800504#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
Bryan Wu1394f032007-05-06 14:50:22 -0700513static 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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800520 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700521 .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
Michael Hennerich8e9d5c72008-04-24 08:46:19 +0800527#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
Bryan Wu1394f032007-05-06 14:50:22 -0700538#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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800543 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700544 .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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800555 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700556 .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 */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800564 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700565 .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",
Sonic Zhang111cf972007-10-30 11:48:42 +0800572 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800573 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700574 .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",
Sonic Zhang111cf972007-10-30 11:48:42 +0800581 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800582 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700583 .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 {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800591 .modalias = "fxs-spi",
592 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800593 .bus_num = 0,
594 .chip_select = 8 - CONFIG_J11_JUMPER,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800595 .controller_data = &spi_si3xxx_chip_info,
Bryan Wu1394f032007-05-06 14:50:22 -0700596 .mode = SPI_MODE_3,
597 },
598 {
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800599 .modalias = "fxo-spi",
600 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800601 .bus_num = 0,
602 .chip_select = 8 - CONFIG_J19_JUMPER,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800603 .controller_data = &spi_si3xxx_chip_info,
Bryan Wu1394f032007-05-06 14:50:22 -0700604 .mode = SPI_MODE_3,
605 },
606#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700607#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 */
Michael Hennerichc7d48962007-11-15 21:33:31 +0800613 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700614 .chip_select = 1,
615 .controller_data = &spi_ad7877_chip_info,
616 },
617#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800618#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
Bryan Wu1394f032007-05-06 14:50:22 -0700627};
628
Mike Frysinger5bda2722008-06-07 15:03:01 +0800629#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700630/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800631static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700632 .num_chipselect = 8,
633 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800634 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700635};
636
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800637/* 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,
Bryan Wu1394f032007-05-06 14:50:22 -0700656 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800657 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700658 },
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 = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800664 .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",
Bryan Wu1394f032007-05-06 14:50:22 -0700671};
672#endif
673
674#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
675static struct resource bfin_uart_resources[] = {
Sonic Zhang233b28a2007-11-21 17:04:41 +0800676#ifdef CONFIG_SERIAL_BFIN_UART0
Bryan Wu1394f032007-05-06 14:50:22 -0700677 {
678 .start = 0xFFC00400,
679 .end = 0xFFC004FF,
680 .flags = IORESOURCE_MEM,
Sonic Zhang233b28a2007-11-21 17:04:41 +0800681 },
682#endif
683#ifdef CONFIG_SERIAL_BFIN_UART1
684 {
Bryan Wu1394f032007-05-06 14:50:22 -0700685 .start = 0xFFC02000,
686 .end = 0xFFC020FF,
687 .flags = IORESOURCE_MEM,
688 },
Sonic Zhang233b28a2007-11-21 17:04:41 +0800689#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700690};
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
Graf Yang5be36d22008-04-25 03:09:15 +0800700#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
Bryan Wu1394f032007-05-06 14:50:22 -0700726#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800727static 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
Bryan Wu1394f032007-05-06 14:50:22 -0700740static struct platform_device i2c_bfin_twi_device = {
741 .name = "i2c-bfin-twi",
742 .id = 0,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800743 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
744 .resource = bfin_twi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700745};
746#endif
747
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800748#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),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800753 .irq = 55,
754 },
755#endif
756#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
757 {
758 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800759 },
760#endif
761#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
762 {
763 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800764 .irq = 72,
765 },
766#endif
767};
768#endif
769
Bryan Wu1394f032007-05-06 14:50:22 -0700770#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
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800782#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,
Mike Frysinger64e5c512007-10-30 11:56:13 +0800787 .irq_flags = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800788};
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
Michael Hennerich14b03202008-05-07 11:41:26 +0800819static 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
Bryan Wu1394f032007-05-06 14:50:22 -0700846static struct platform_device *stamp_devices[] __initdata = {
Michael Hennerich14b03202008-05-07 11:41:26 +0800847
848 &bfin_dpmc,
849
Bryan Wu1394f032007-05-06 14:50:22 -0700850#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
Alex Landauf40d24d2007-07-12 12:11:48 +0800870#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
871 &dm9000_device,
872#endif
873
Michael Hennerich561cc182007-11-17 23:56:08 +0800874#if defined(CONFIG_AX88180) || defined(CONFIG_AX88180_MODULE)
875 &ax88180_device,
876#endif
877
Bryan Wu1394f032007-05-06 14:50:22 -0700878#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)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800887 &bfin_spi0_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700888#endif
889
890#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
891 &bfin_fb_device,
892#endif
893
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800894#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
895 &bfin_fb_adv7393_device,
896#endif
897
Bryan Wu1394f032007-05-06 14:50:22 -0700898#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
899 &bfin_uart_device,
900#endif
901
Graf Yang5be36d22008-04-25 03:09:15 +0800902#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
903 &bfin_sir_device,
904#endif
905
Bryan Wu1394f032007-05-06 14:50:22 -0700906#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
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800914
915#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
916 &bfin_pata_device,
917#endif
Michael Hennerich2463ef22008-01-27 16:49:48 +0800918
919#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
920 &bfin_device_gpiokeys,
921#endif
Mike Frysingercad2ab62008-02-22 17:01:31 +0800922
923 &bfin_gpios_device,
Mike Frysinger793dc272008-03-26 08:09:12 +0800924
925#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
Mike Frysingerde8c43f2008-01-24 17:14:04 +0800926 &stamp_flash_device,
Mike Frysinger793dc272008-03-26 08:09:12 +0800927#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700928};
929
930static int __init stamp_init(void)
931{
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800932 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800933
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
Bryan Wu1394f032007-05-06 14:50:22 -0700939 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
Mike Frysinger5bda2722008-06-07 15:03:01 +0800940 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800941
942#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
943 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
944#endif
Bryan Wu81d9c7f2008-03-26 10:02:13 +0800945
Bryan Wu1394f032007-05-06 14:50:22 -0700946 return 0;
947}
948
949arch_initcall(stamp_init);
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800950
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}
Mike Frysinger137b1522007-11-22 16:07:03 +0800957
958/*
959 * Currently the MAC address is saved in Flash by U-Boot
960 */
961#define FLASH_MAC 0x203f0000
Mike Frysinger9862cc52007-11-15 21:21:20 +0800962void bfin_get_ether_addr(char *addr)
Mike Frysinger137b1522007-11-22 16:07:03 +0800963{
964 *(u32 *)(&(addr[0])) = bfin_read32(FLASH_MAC);
965 *(u16 *)(&(addr[4])) = bfin_read16(FLASH_MAC + 4);
966}
Mike Frysinger9862cc52007-11-15 21:21:20 +0800967EXPORT_SYMBOL(bfin_get_ether_addr);