blob: 90dd0869edc9ad4bce0803bb287564c964a073e1 [file] [log] [blame]
Michael Hennerich59003142007-10-21 16:54:27 +08001/*
2 * File: arch/blackfin/mach-bf527/boards/ezkit.c
3 * Based on: arch/blackfin/mach-bf537/boards/stamp.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
Michael Hennericha628a8b2008-01-22 17:29:16 +080011 * Copyright 2004-2008 Analog Devices Inc.
Michael Hennerich59003142007-10-21 16:54:27 +080012 *
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)
Mike Frysingerf02bcec2007-11-15 21:29:15 +080038#include <linux/usb/isp1362.h>
Michael Hennerich59003142007-10-21 16:54:27 +080039#endif
Jeff Garzik0a87e3e2008-02-01 18:02:30 -050040#include <linux/ata_platform.h>
Michael Hennerich59003142007-10-21 16:54:27 +080041#include <linux/irq.h>
42#include <linux/interrupt.h>
Mike Frysinger632f6582007-11-15 21:25:47 +080043#include <linux/usb/sl811.h>
Mike Frysinger67f2d332008-02-09 01:49:23 +080044#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
Michael Hennerich1089e222007-12-24 11:49:29 +080045#include <linux/usb/musb.h>
Mike Frysinger67f2d332008-02-09 01:49:23 +080046#endif
Michael Hennerich64307f72007-10-29 16:55:18 +080047#include <asm/cplb.h>
Michael Hennerich59003142007-10-21 16:54:27 +080048#include <asm/dma.h>
49#include <asm/bfin5xx_spi.h>
50#include <asm/reboot.h>
Michael Hennerich64307f72007-10-29 16:55:18 +080051#include <asm/nand.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080052#include <asm/portmux.h>
Michael Hennerich14b03202008-05-07 11:41:26 +080053#include <asm/dpmc.h>
Michael Hennerich59003142007-10-21 16:54:27 +080054#include <linux/spi/ad7877.h>
55
56/*
57 * Name the Board for the /proc/cpuinfo
58 */
Mike Frysinger066954a2007-10-21 22:36:06 +080059const char bfin_board_name[] = "ADDS-BF527-EZKIT";
Michael Hennerich59003142007-10-21 16:54:27 +080060
61/*
62 * Driver needs to know address, irq and flag pin.
63 */
64
65#define ISP1761_BASE 0x203C0000
66#define ISP1761_IRQ IRQ_PF7
67
68#if defined(CONFIG_USB_ISP1760_HCD) || defined(CONFIG_USB_ISP1760_HCD_MODULE)
69static struct resource bfin_isp1761_resources[] = {
70 [0] = {
71 .name = "isp1761-regs",
72 .start = ISP1761_BASE + 0x00000000,
73 .end = ISP1761_BASE + 0x000fffff,
74 .flags = IORESOURCE_MEM,
75 },
76 [1] = {
77 .start = ISP1761_IRQ,
78 .end = ISP1761_IRQ,
79 .flags = IORESOURCE_IRQ,
80 },
81};
82
83static struct platform_device bfin_isp1761_device = {
84 .name = "isp1761",
85 .id = 0,
86 .num_resources = ARRAY_SIZE(bfin_isp1761_resources),
87 .resource = bfin_isp1761_resources,
88};
89
90static struct platform_device *bfin_isp1761_devices[] = {
91 &bfin_isp1761_device,
92};
93
94int __init bfin_isp1761_init(void)
95{
96 unsigned int num_devices = ARRAY_SIZE(bfin_isp1761_devices);
97
Harvey Harrisonb85d8582008-04-23 09:39:01 +080098 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich59003142007-10-21 16:54:27 +080099 set_irq_type(ISP1761_IRQ, IRQF_TRIGGER_FALLING);
100
101 return platform_add_devices(bfin_isp1761_devices, num_devices);
102}
103
104void __exit bfin_isp1761_exit(void)
105{
106 platform_device_unregister(&bfin_isp1761_device);
107}
108
109arch_initcall(bfin_isp1761_init);
110#endif
111
Michael Hennerich1089e222007-12-24 11:49:29 +0800112#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
113static struct resource musb_resources[] = {
114 [0] = {
115 .start = 0xffc03800,
116 .end = 0xffc03cff,
117 .flags = IORESOURCE_MEM,
118 },
119 [1] = { /* general IRQ */
120 .start = IRQ_USB_INT0,
121 .end = IRQ_USB_INT0,
122 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
123 },
124 [2] = { /* DMA IRQ */
125 .start = IRQ_USB_DMA,
126 .end = IRQ_USB_DMA,
127 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
128 },
129};
130
131static struct musb_hdrc_platform_data musb_plat = {
132#if defined(CONFIG_USB_MUSB_OTG)
133 .mode = MUSB_OTG,
134#elif defined(CONFIG_USB_MUSB_HDRC_HCD)
135 .mode = MUSB_HOST,
136#elif defined(CONFIG_USB_GADGET_MUSB_HDRC)
137 .mode = MUSB_PERIPHERAL,
138#endif
139 .multipoint = 0,
140};
141
142static u64 musb_dmamask = ~(u32)0;
143
144static struct platform_device musb_device = {
145 .name = "musb_hdrc",
146 .id = 0,
147 .dev = {
148 .dma_mask = &musb_dmamask,
149 .coherent_dma_mask = 0xffffffff,
150 .platform_data = &musb_plat,
151 },
152 .num_resources = ARRAY_SIZE(musb_resources),
153 .resource = musb_resources,
154};
155#endif
156
157#if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
158
159static struct resource bf52x_t350mcqb_resources[] = {
160 {
161 .start = IRQ_PPI_ERROR,
162 .end = IRQ_PPI_ERROR,
163 .flags = IORESOURCE_IRQ,
164 },
165};
166
167static struct platform_device bf52x_t350mcqb_device = {
168 .name = "bfin-t350mcqb",
169 .id = -1,
170 .num_resources = ARRAY_SIZE(bf52x_t350mcqb_resources),
171 .resource = bf52x_t350mcqb_resources,
172};
173#endif
174
Michael Hennerich64307f72007-10-29 16:55:18 +0800175#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
176static struct mtd_partition partition_info[] = {
177 {
178 .name = "Linux Kernel",
179 .offset = 0,
180 .size = 4 * SIZE_1M,
181 },
182 {
183 .name = "File System",
Mike Frysingeredf05642008-02-25 11:38:11 +0800184 .offset = MTDPART_OFS_APPEND,
185 .size = MTDPART_SIZ_FULL,
Michael Hennerich64307f72007-10-29 16:55:18 +0800186 },
187};
188
189static struct bf5xx_nand_platform bf5xx_nand_platform = {
190 .page_size = NFC_PG_SIZE_256,
191 .data_width = NFC_NWIDTH_8,
192 .partitions = partition_info,
193 .nr_partitions = ARRAY_SIZE(partition_info),
194 .rd_dly = 3,
195 .wr_dly = 3,
196};
197
198static struct resource bf5xx_nand_resources[] = {
199 {
200 .start = NFC_CTL,
201 .end = NFC_DATA_RD + 2,
202 .flags = IORESOURCE_MEM,
203 },
204 {
205 .start = CH_NFC,
206 .end = CH_NFC,
207 .flags = IORESOURCE_IRQ,
208 },
209};
210
211static struct platform_device bf5xx_nand_device = {
212 .name = "bf5xx-nand",
213 .id = 0,
214 .num_resources = ARRAY_SIZE(bf5xx_nand_resources),
215 .resource = bf5xx_nand_resources,
216 .dev = {
217 .platform_data = &bf5xx_nand_platform,
218 },
219};
220#endif
221
Michael Hennerich59003142007-10-21 16:54:27 +0800222#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
223static struct resource bfin_pcmcia_cf_resources[] = {
224 {
225 .start = 0x20310000, /* IO PORT */
226 .end = 0x20312000,
227 .flags = IORESOURCE_MEM,
228 }, {
229 .start = 0x20311000, /* Attribute Memory */
230 .end = 0x20311FFF,
231 .flags = IORESOURCE_MEM,
232 }, {
233 .start = IRQ_PF4,
234 .end = IRQ_PF4,
235 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
236 }, {
237 .start = 6, /* Card Detect PF6 */
238 .end = 6,
239 .flags = IORESOURCE_IRQ,
240 },
241};
242
243static struct platform_device bfin_pcmcia_cf_device = {
244 .name = "bfin_cf_pcmcia",
245 .id = -1,
246 .num_resources = ARRAY_SIZE(bfin_pcmcia_cf_resources),
247 .resource = bfin_pcmcia_cf_resources,
248};
249#endif
250
251#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
252static struct platform_device rtc_device = {
253 .name = "rtc-bfin",
254 .id = -1,
255};
256#endif
257
258#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
259static struct resource smc91x_resources[] = {
260 {
261 .name = "smc91x-regs",
262 .start = 0x20300300,
263 .end = 0x20300300 + 16,
264 .flags = IORESOURCE_MEM,
265 }, {
266
267 .start = IRQ_PF7,
268 .end = IRQ_PF7,
269 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
270 },
271};
272static struct platform_device smc91x_device = {
273 .name = "smc91x",
274 .id = 0,
275 .num_resources = ARRAY_SIZE(smc91x_resources),
276 .resource = smc91x_resources,
277};
278#endif
279
280#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
281static struct resource dm9000_resources[] = {
282 [0] = {
283 .start = 0x203FB800,
284 .end = 0x203FB800 + 8,
285 .flags = IORESOURCE_MEM,
286 },
287 [1] = {
288 .start = IRQ_PF9,
289 .end = IRQ_PF9,
290 .flags = (IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE),
291 },
292};
293
294static struct platform_device dm9000_device = {
295 .name = "dm9000",
296 .id = -1,
297 .num_resources = ARRAY_SIZE(dm9000_resources),
298 .resource = dm9000_resources,
299};
300#endif
301
302#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
303static struct resource sl811_hcd_resources[] = {
304 {
305 .start = 0x20340000,
306 .end = 0x20340000,
307 .flags = IORESOURCE_MEM,
308 }, {
309 .start = 0x20340004,
310 .end = 0x20340004,
311 .flags = IORESOURCE_MEM,
312 }, {
313 .start = CONFIG_USB_SL811_BFIN_IRQ,
314 .end = CONFIG_USB_SL811_BFIN_IRQ,
315 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
316 },
317};
318
319#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
320void sl811_port_power(struct device *dev, int is_on)
321{
322 gpio_request(CONFIG_USB_SL811_BFIN_GPIO_VBUS, "usb:SL811_VBUS");
Michael Hennerichacbcd262008-01-22 18:36:20 +0800323 gpio_direction_output(CONFIG_USB_SL811_BFIN_GPIO_VBUS, is_on);
Michael Hennerich59003142007-10-21 16:54:27 +0800324}
325#endif
326
327static struct sl811_platform_data sl811_priv = {
328 .potpg = 10,
329 .power = 250, /* == 500mA */
330#if defined(CONFIG_USB_SL811_BFIN_USE_VBUS)
331 .port_power = &sl811_port_power,
332#endif
333};
334
335static struct platform_device sl811_hcd_device = {
336 .name = "sl811-hcd",
337 .id = 0,
338 .dev = {
339 .platform_data = &sl811_priv,
340 },
341 .num_resources = ARRAY_SIZE(sl811_hcd_resources),
342 .resource = sl811_hcd_resources,
343};
344#endif
345
346#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
347static struct resource isp1362_hcd_resources[] = {
348 {
349 .start = 0x20360000,
350 .end = 0x20360000,
351 .flags = IORESOURCE_MEM,
352 }, {
353 .start = 0x20360004,
354 .end = 0x20360004,
355 .flags = IORESOURCE_MEM,
356 }, {
357 .start = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
358 .end = CONFIG_USB_ISP1362_BFIN_GPIO_IRQ,
359 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
360 },
361};
362
363static struct isp1362_platform_data isp1362_priv = {
364 .sel15Kres = 1,
365 .clknotstop = 0,
366 .oc_enable = 0,
367 .int_act_high = 0,
368 .int_edge_triggered = 0,
369 .remote_wakeup_connected = 0,
370 .no_power_switching = 1,
371 .power_switching_mode = 0,
372};
373
374static struct platform_device isp1362_hcd_device = {
375 .name = "isp1362-hcd",
376 .id = 0,
377 .dev = {
378 .platform_data = &isp1362_priv,
379 },
380 .num_resources = ARRAY_SIZE(isp1362_hcd_resources),
381 .resource = isp1362_hcd_resources,
382};
383#endif
384
385#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
386static struct platform_device bfin_mac_device = {
387 .name = "bfin_mac",
388};
389#endif
390
391#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
392static struct resource net2272_bfin_resources[] = {
393 {
394 .start = 0x20300000,
395 .end = 0x20300000 + 0x100,
396 .flags = IORESOURCE_MEM,
397 }, {
398 .start = IRQ_PF7,
399 .end = IRQ_PF7,
400 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
401 },
402};
403
404static struct platform_device net2272_bfin_device = {
405 .name = "net2272",
406 .id = -1,
407 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
408 .resource = net2272_bfin_resources,
409};
410#endif
411
412#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
413/* all SPI peripherals info goes here */
414
415#if defined(CONFIG_MTD_M25P80) \
416 || defined(CONFIG_MTD_M25P80_MODULE)
417static struct mtd_partition bfin_spi_flash_partitions[] = {
418 {
419 .name = "bootloader",
Grace Panac76d882008-04-24 06:33:56 +0800420 .size = 0x00040000,
Michael Hennerich59003142007-10-21 16:54:27 +0800421 .offset = 0,
422 .mask_flags = MTD_CAP_ROM
423 }, {
424 .name = "kernel",
425 .size = 0xe0000,
Mike Frysingeredf05642008-02-25 11:38:11 +0800426 .offset = MTDPART_OFS_APPEND,
Michael Hennerich59003142007-10-21 16:54:27 +0800427 }, {
428 .name = "file system",
Mike Frysingeredf05642008-02-25 11:38:11 +0800429 .size = MTDPART_SIZ_FULL,
430 .offset = MTDPART_OFS_APPEND,
Michael Hennerich59003142007-10-21 16:54:27 +0800431 }
432};
433
434static struct flash_platform_data bfin_spi_flash_data = {
435 .name = "m25p80",
436 .parts = bfin_spi_flash_partitions,
437 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
438 .type = "m25p64",
439};
440
441/* SPI flash chip (m25p64) */
442static struct bfin5xx_spi_chip spi_flash_chip_info = {
443 .enable_dma = 0, /* use dma transfer with this chip*/
444 .bits_per_word = 8,
445};
446#endif
447
448#if defined(CONFIG_SPI_ADC_BF533) \
449 || defined(CONFIG_SPI_ADC_BF533_MODULE)
450/* SPI ADC chip */
451static struct bfin5xx_spi_chip spi_adc_chip_info = {
452 .enable_dma = 1, /* use dma transfer with this chip*/
453 .bits_per_word = 16,
454};
455#endif
456
457#if defined(CONFIG_SND_BLACKFIN_AD1836) \
458 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
459static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
460 .enable_dma = 0,
461 .bits_per_word = 16,
462};
463#endif
464
465#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
466static struct bfin5xx_spi_chip ad9960_spi_chip_info = {
467 .enable_dma = 0,
468 .bits_per_word = 16,
469};
470#endif
471
472#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
473static struct bfin5xx_spi_chip spi_mmc_chip_info = {
474 .enable_dma = 1,
475 .bits_per_word = 8,
476};
477#endif
478
479#if defined(CONFIG_PBX)
480static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
481 .ctl_reg = 0x4, /* send zero */
482 .enable_dma = 0,
483 .bits_per_word = 8,
484 .cs_change_per_word = 1,
485};
486#endif
487
Michael Hennerich59003142007-10-21 16:54:27 +0800488#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
489static struct bfin5xx_spi_chip spi_ad7877_chip_info = {
490 .enable_dma = 0,
491 .bits_per_word = 16,
492};
493
494static const struct ad7877_platform_data bfin_ad7877_ts_info = {
495 .model = 7877,
496 .vref_delay_usecs = 50, /* internal, no capacitor */
497 .x_plate_ohms = 419,
498 .y_plate_ohms = 486,
499 .pressure_max = 1000,
500 .pressure_min = 0,
501 .stopacq_polarity = 1,
502 .first_conversion_delay = 3,
503 .acquisition_time = 1,
504 .averaging = 1,
505 .pen_down_acc_interval = 1,
506};
507#endif
508
Michael Hennerichc7d48962007-11-15 21:33:31 +0800509#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
Michael Hennerich0954f702007-11-13 00:16:19 +0800510 && defined(CONFIG_SND_SOC_WM8731_SPI)
511static struct bfin5xx_spi_chip spi_wm8731_chip_info = {
512 .enable_dma = 0,
513 .bits_per_word = 16,
514};
515#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800516
517#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
518static struct bfin5xx_spi_chip spidev_chip_info = {
519 .enable_dma = 0,
520 .bits_per_word = 8,
521};
522#endif
523
Michael Hennerich59003142007-10-21 16:54:27 +0800524static struct spi_board_info bfin_spi_board_info[] __initdata = {
525#if defined(CONFIG_MTD_M25P80) \
526 || defined(CONFIG_MTD_M25P80_MODULE)
527 {
528 /* the modalias must be the same as spi device driver name */
529 .modalias = "m25p80", /* Name of spi_driver for this device */
530 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
531 .bus_num = 0, /* Framework bus number */
532 .chip_select = 1, /* Framework chip select. On STAMP537 it is SPISSEL1*/
533 .platform_data = &bfin_spi_flash_data,
534 .controller_data = &spi_flash_chip_info,
535 .mode = SPI_MODE_3,
536 },
537#endif
538
539#if defined(CONFIG_SPI_ADC_BF533) \
540 || defined(CONFIG_SPI_ADC_BF533_MODULE)
541 {
542 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
543 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
544 .bus_num = 0, /* Framework bus number */
545 .chip_select = 1, /* Framework chip select. */
546 .platform_data = NULL, /* No spi_driver specific config */
547 .controller_data = &spi_adc_chip_info,
548 },
549#endif
550
551#if defined(CONFIG_SND_BLACKFIN_AD1836) \
552 || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
553 {
554 .modalias = "ad1836-spi",
555 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
556 .bus_num = 0,
557 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
558 .controller_data = &ad1836_spi_chip_info,
559 },
560#endif
561#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)
562 {
563 .modalias = "ad9960-spi",
564 .max_speed_hz = 10000000, /* max spi clock (SCK) speed in HZ */
565 .bus_num = 0,
566 .chip_select = 1,
567 .controller_data = &ad9960_spi_chip_info,
568 },
569#endif
570#if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
571 {
572 .modalias = "spi_mmc_dummy",
573 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
574 .bus_num = 0,
575 .chip_select = 0,
576 .platform_data = NULL,
577 .controller_data = &spi_mmc_chip_info,
578 .mode = SPI_MODE_3,
579 },
580 {
581 .modalias = "spi_mmc",
582 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
583 .bus_num = 0,
584 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
585 .platform_data = NULL,
586 .controller_data = &spi_mmc_chip_info,
587 .mode = SPI_MODE_3,
588 },
589#endif
590#if defined(CONFIG_PBX)
591 {
592 .modalias = "fxs-spi",
593 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
594 .bus_num = 0,
595 .chip_select = 8 - CONFIG_J11_JUMPER,
596 .controller_data = &spi_si3xxx_chip_info,
597 .mode = SPI_MODE_3,
598 },
599 {
600 .modalias = "fxo-spi",
601 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
602 .bus_num = 0,
603 .chip_select = 8 - CONFIG_J19_JUMPER,
604 .controller_data = &spi_si3xxx_chip_info,
605 .mode = SPI_MODE_3,
606 },
607#endif
Michael Hennerich59003142007-10-21 16:54:27 +0800608#if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE)
609 {
610 .modalias = "ad7877",
611 .platform_data = &bfin_ad7877_ts_info,
612 .irq = IRQ_PF6,
613 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
Michael Hennerich0954f702007-11-13 00:16:19 +0800614 .bus_num = 0,
Michael Hennerich59003142007-10-21 16:54:27 +0800615 .chip_select = 1,
616 .controller_data = &spi_ad7877_chip_info,
617 },
618#endif
Michael Hennerichc7d48962007-11-15 21:33:31 +0800619#if defined(CONFIG_SND_SOC_WM8731) || defined(CONFIG_SND_SOC_WM8731_MODULE) \
Michael Hennerich0954f702007-11-13 00:16:19 +0800620 && defined(CONFIG_SND_SOC_WM8731_SPI)
621 {
622 .modalias = "wm8731",
623 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
624 .bus_num = 0,
625 .chip_select = 5,
626 .controller_data = &spi_wm8731_chip_info,
627 .mode = SPI_MODE_0,
628 },
629#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800630#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
631 {
632 .modalias = "spidev",
633 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
634 .bus_num = 0,
635 .chip_select = 1,
636 .controller_data = &spidev_chip_info,
637 },
638#endif
Michael Hennerich59003142007-10-21 16:54:27 +0800639};
640
641/* SPI controller data */
642static struct bfin5xx_spi_master bfin_spi0_info = {
643 .num_chipselect = 8,
644 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800645 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Michael Hennerich59003142007-10-21 16:54:27 +0800646};
647
648/* SPI (0) */
649static struct resource bfin_spi0_resource[] = {
650 [0] = {
651 .start = SPI0_REGBASE,
652 .end = SPI0_REGBASE + 0xFF,
653 .flags = IORESOURCE_MEM,
654 },
655 [1] = {
656 .start = CH_SPI,
657 .end = CH_SPI,
658 .flags = IORESOURCE_IRQ,
659 },
660};
661
662static struct platform_device bfin_spi0_device = {
663 .name = "bfin-spi",
664 .id = 0, /* Bus number */
665 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
666 .resource = bfin_spi0_resource,
667 .dev = {
668 .platform_data = &bfin_spi0_info, /* Passed to driver */
669 },
670};
671#endif /* spi master and devices */
672
673#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
674static struct platform_device bfin_fb_device = {
675 .name = "bf537-lq035",
676};
677#endif
678
679#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
680static struct platform_device bfin_fb_adv7393_device = {
681 .name = "bfin-adv7393",
682};
683#endif
684
685#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
686static struct resource bfin_uart_resources[] = {
687#ifdef CONFIG_SERIAL_BFIN_UART0
688 {
689 .start = 0xFFC00400,
690 .end = 0xFFC004FF,
691 .flags = IORESOURCE_MEM,
692 },
693#endif
694#ifdef CONFIG_SERIAL_BFIN_UART1
695 {
696 .start = 0xFFC02000,
697 .end = 0xFFC020FF,
698 .flags = IORESOURCE_MEM,
699 },
700#endif
701};
702
703static struct platform_device bfin_uart_device = {
704 .name = "bfin-uart",
705 .id = 1,
706 .num_resources = ARRAY_SIZE(bfin_uart_resources),
707 .resource = bfin_uart_resources,
708};
709#endif
710
Graf Yang5be36d22008-04-25 03:09:15 +0800711#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
712static struct resource bfin_sir_resources[] = {
713#ifdef CONFIG_BFIN_SIR0
714 {
715 .start = 0xFFC00400,
716 .end = 0xFFC004FF,
717 .flags = IORESOURCE_MEM,
718 },
719#endif
720#ifdef CONFIG_BFIN_SIR1
721 {
722 .start = 0xFFC02000,
723 .end = 0xFFC020FF,
724 .flags = IORESOURCE_MEM,
725 },
726#endif
727};
728
729static struct platform_device bfin_sir_device = {
730 .name = "bfin_sir",
731 .id = 0,
732 .num_resources = ARRAY_SIZE(bfin_sir_resources),
733 .resource = bfin_sir_resources,
734};
735#endif
736
Michael Hennerich59003142007-10-21 16:54:27 +0800737#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
738static struct resource bfin_twi0_resource[] = {
739 [0] = {
740 .start = TWI0_REGBASE,
741 .end = TWI0_REGBASE,
742 .flags = IORESOURCE_MEM,
743 },
744 [1] = {
745 .start = IRQ_TWI,
746 .end = IRQ_TWI,
747 .flags = IORESOURCE_IRQ,
748 },
749};
750
751static struct platform_device i2c_bfin_twi_device = {
752 .name = "i2c-bfin-twi",
753 .id = 0,
754 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
755 .resource = bfin_twi0_resource,
756};
757#endif
758
759#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
760static struct platform_device bfin_sport0_uart_device = {
761 .name = "bfin-sport-uart",
762 .id = 0,
763};
764
765static struct platform_device bfin_sport1_uart_device = {
766 .name = "bfin-sport-uart",
767 .id = 1,
768};
769#endif
770
771#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
772#define PATA_INT 55
773
774static struct pata_platform_info bfin_pata_platform_data = {
775 .ioport_shift = 1,
776 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
777};
778
779static struct resource bfin_pata_resources[] = {
780 {
781 .start = 0x20314020,
782 .end = 0x2031403F,
783 .flags = IORESOURCE_MEM,
784 },
785 {
786 .start = 0x2031401C,
787 .end = 0x2031401F,
788 .flags = IORESOURCE_MEM,
789 },
790 {
791 .start = PATA_INT,
792 .end = PATA_INT,
793 .flags = IORESOURCE_IRQ,
794 },
795};
796
797static struct platform_device bfin_pata_device = {
798 .name = "pata_platform",
799 .id = -1,
800 .num_resources = ARRAY_SIZE(bfin_pata_resources),
801 .resource = bfin_pata_resources,
802 .dev = {
803 .platform_data = &bfin_pata_platform_data,
804 }
805};
806#endif
807
Michael Hennerich1089e222007-12-24 11:49:29 +0800808#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
809#include <linux/input.h>
810#include <linux/gpio_keys.h>
811
812static struct gpio_keys_button bfin_gpio_keys_table[] = {
813 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
814 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
815};
816
817static struct gpio_keys_platform_data bfin_gpio_keys_data = {
818 .buttons = bfin_gpio_keys_table,
819 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
820};
821
822static struct platform_device bfin_device_gpiokeys = {
823 .name = "gpio-keys",
824 .dev = {
825 .platform_data = &bfin_gpio_keys_data,
826 },
827};
828#endif
829
Mike Frysingercad2ab62008-02-22 17:01:31 +0800830static struct resource bfin_gpios_resources = {
831 .start = 0,
832 .end = MAX_BLACKFIN_GPIOS - 1,
833 .flags = IORESOURCE_IRQ,
834};
835
836static struct platform_device bfin_gpios_device = {
837 .name = "simple-gpio",
838 .id = -1,
839 .num_resources = 1,
840 .resource = &bfin_gpios_resources,
841};
842
Michael Hennerich14b03202008-05-07 11:41:26 +0800843static const unsigned int cclk_vlev_datasheet[] =
844{
845 VRPAIR(VLEV_100, 400000000),
846 VRPAIR(VLEV_105, 426000000),
847 VRPAIR(VLEV_110, 500000000),
848 VRPAIR(VLEV_115, 533000000),
849 VRPAIR(VLEV_120, 600000000),
850};
851
852static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
853 .tuple_tab = cclk_vlev_datasheet,
854 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
855 .vr_settling_time = 25 /* us */,
856};
857
858static struct platform_device bfin_dpmc = {
859 .name = "bfin dpmc",
860 .dev = {
861 .platform_data = &bfin_dmpc_vreg_data,
862 },
863};
864
Michael Hennerich59003142007-10-21 16:54:27 +0800865static struct platform_device *stamp_devices[] __initdata = {
Michael Hennerich14b03202008-05-07 11:41:26 +0800866
867 &bfin_dpmc,
868
Michael Hennerich64307f72007-10-29 16:55:18 +0800869#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
870 &bf5xx_nand_device,
871#endif
872
Michael Hennerich59003142007-10-21 16:54:27 +0800873#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
874 &bfin_pcmcia_cf_device,
875#endif
876
877#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
878 &rtc_device,
879#endif
880
881#if defined(CONFIG_USB_SL811_HCD) || defined(CONFIG_USB_SL811_HCD_MODULE)
882 &sl811_hcd_device,
883#endif
884
885#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
886 &isp1362_hcd_device,
887#endif
888
Michael Hennerich1089e222007-12-24 11:49:29 +0800889#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
890 &musb_device,
891#endif
892
Michael Hennerich59003142007-10-21 16:54:27 +0800893#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
894 &smc91x_device,
895#endif
896
897#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
898 &dm9000_device,
899#endif
900
901#if defined(CONFIG_BFIN_MAC) || defined(CONFIG_BFIN_MAC_MODULE)
902 &bfin_mac_device,
903#endif
904
905#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
906 &net2272_bfin_device,
907#endif
908
909#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
910 &bfin_spi0_device,
911#endif
912
913#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
914 &bfin_fb_device,
915#endif
916
Michael Hennerich1089e222007-12-24 11:49:29 +0800917#if defined(CONFIG_FB_BFIN_T350MCQB) || defined(CONFIG_FB_BFIN_T350MCQB_MODULE)
918 &bf52x_t350mcqb_device,
919#endif
920
Michael Hennerich59003142007-10-21 16:54:27 +0800921#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
922 &bfin_fb_adv7393_device,
923#endif
924
925#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
926 &bfin_uart_device,
927#endif
928
Graf Yang5be36d22008-04-25 03:09:15 +0800929#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
930 &bfin_sir_device,
931#endif
932
Michael Hennerich59003142007-10-21 16:54:27 +0800933#if defined(CONFIG_I2C_BLACKFIN_TWI) || defined(CONFIG_I2C_BLACKFIN_TWI_MODULE)
934 &i2c_bfin_twi_device,
935#endif
936
937#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
938 &bfin_sport0_uart_device,
939 &bfin_sport1_uart_device,
940#endif
941
942#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
943 &bfin_pata_device,
944#endif
Michael Hennerich1089e222007-12-24 11:49:29 +0800945
946#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
947 &bfin_device_gpiokeys,
948#endif
Mike Frysingercad2ab62008-02-22 17:01:31 +0800949
950 &bfin_gpios_device,
Michael Hennerich59003142007-10-21 16:54:27 +0800951};
952
953static int __init stamp_init(void)
954{
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800955 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Michael Hennerich59003142007-10-21 16:54:27 +0800956 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
957#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
958 spi_register_board_info(bfin_spi_board_info,
959 ARRAY_SIZE(bfin_spi_board_info));
960#endif
961
962#if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
963 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
964#endif
965 return 0;
966}
967
968arch_initcall(stamp_init);
969
970void native_machine_restart(char *cmd)
971{
972 /* workaround reboot hang when booting from SPI */
973 if ((bfin_read_SYSCR() & 0x7) == 0x3)
974 bfin_gpio_reset_spi0_ssel1();
975}
Mike Frysinger137b1522007-11-22 16:07:03 +0800976
Mike Frysinger9862cc52007-11-15 21:21:20 +0800977void bfin_get_ether_addr(char *addr)
Mike Frysinger137b1522007-11-22 16:07:03 +0800978{
Mike Frysinger181afa92008-02-25 11:42:17 +0800979 /* the MAC is stored in OTP memory page 0xDF */
980 u32 ret;
981 u64 otp_mac;
982 u32 (*otp_read)(u32 page, u32 flags, u64 *page_content) = (void *)0xEF00001A;
983
984 ret = otp_read(0xDF, 0x00, &otp_mac);
985 if (!(ret & 0x1)) {
986 char *otp_mac_p = (char *)&otp_mac;
987 for (ret = 0; ret < 6; ++ret)
988 addr[ret] = otp_mac_p[5 - ret];
989 }
Mike Frysinger137b1522007-11-22 16:07:03 +0800990}
Mike Frysinger9862cc52007-11-15 21:21:20 +0800991EXPORT_SYMBOL(bfin_get_ether_addr);