blob: 64816b08d13ce7948f76e1f0ba7b28dc9b78c7a6 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
Bryan Wu1394f032007-05-06 14:50:22 -07005 *
Robin Getz96f10502009-09-24 14:11:24 +00006 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07007 */
8
9#include <linux/device.h>
10#include <linux/platform_device.h>
11#include <linux/mtd/mtd.h>
12#include <linux/mtd/partitions.h>
Mike Frysinger4d5e6fd2009-06-13 06:34:49 -040013#include <linux/mtd/plat-ram.h>
Bryan Wu1394f032007-05-06 14:50:22 -070014#include <linux/spi/spi.h>
15#include <linux/spi/flash.h>
Mike Frysinger67f2d332008-02-09 01:49:23 +080016#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
Mike Frysingerf02bcec2007-11-15 21:29:15 +080017#include <linux/usb/isp1362.h>
Mike Frysinger67f2d332008-02-09 01:49:23 +080018#endif
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080019#include <linux/irq.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080020#include <asm/dma.h>
Bryan Wu1394f032007-05-06 14:50:22 -070021#include <asm/bfin5xx_spi.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080022#include <asm/portmux.h>
Michael Hennerich14b03202008-05-07 11:41:26 +080023#include <asm/dpmc.h>
Bryan Wu1394f032007-05-06 14:50:22 -070024
25/*
26 * Name the Board for the /proc/cpuinfo
27 */
Mike Frysingerfe85cad2008-11-18 17:48:22 +080028const char bfin_board_name[] = "ADI BF533-EZKIT";
Bryan Wu1394f032007-05-06 14:50:22 -070029
30#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
31static struct platform_device rtc_device = {
32 .name = "rtc-bfin",
33 .id = -1,
34};
35#endif
36
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080037#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
38static struct platform_device bfin_fb_adv7393_device = {
39 .name = "bfin-adv7393",
40};
41#endif
42
Bryan Wu1394f032007-05-06 14:50:22 -070043/*
44 * USB-LAN EzExtender board
45 * Driver needs to know address, irq and flag pin.
46 */
47#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +000048#include <linux/smc91x.h>
49
50static struct smc91x_platdata smc91x_info = {
51 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
52 .leda = RPC_LED_100_10,
53 .ledb = RPC_LED_TX_RX,
54};
55
Bryan Wu1394f032007-05-06 14:50:22 -070056static struct resource smc91x_resources[] = {
57 {
58 .name = "smc91x-regs",
59 .start = 0x20310300,
60 .end = 0x20310300 + 16,
61 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080062 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070063 .start = IRQ_PF9,
64 .end = IRQ_PF9,
65 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
66 },
67};
68static struct platform_device smc91x_device = {
69 .name = "smc91x",
70 .id = 0,
71 .num_resources = ARRAY_SIZE(smc91x_resources),
72 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +000073 .dev = {
74 .platform_data = &smc91x_info,
75 },
Bryan Wu1394f032007-05-06 14:50:22 -070076};
77#endif
78
Mike Frysinger4d5e6fd2009-06-13 06:34:49 -040079#if defined(CONFIG_MTD_PSD4256G) || defined(CONFIG_MTD_PSD4256G_MODULE)
80static const char *map_probes[] = {
81 "stm_flash",
82 NULL,
83};
84
85static struct platdata_mtd_ram stm_pri_data_a = {
86 .mapname = "Flash A Primary",
87 .map_probes = map_probes,
88 .bankwidth = 2,
89};
90
91static struct resource stm_pri_resource_a = {
92 .start = 0x20000000,
93 .end = 0x200fffff,
94 .flags = IORESOURCE_MEM,
95};
96
97static struct platform_device stm_pri_device_a = {
98 .name = "mtd-ram",
99 .id = 0,
100 .dev = {
101 .platform_data = &stm_pri_data_a,
102 },
103 .num_resources = 1,
104 .resource = &stm_pri_resource_a,
105};
106
107static struct platdata_mtd_ram stm_pri_data_b = {
108 .mapname = "Flash B Primary",
109 .map_probes = map_probes,
110 .bankwidth = 2,
111};
112
113static struct resource stm_pri_resource_b = {
114 .start = 0x20100000,
115 .end = 0x201fffff,
116 .flags = IORESOURCE_MEM,
117};
118
119static struct platform_device stm_pri_device_b = {
120 .name = "mtd-ram",
121 .id = 4,
122 .dev = {
123 .platform_data = &stm_pri_data_b,
124 },
125 .num_resources = 1,
126 .resource = &stm_pri_resource_b,
127};
128#endif
129
130#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
131static struct platdata_mtd_ram sram_data_a = {
132 .mapname = "Flash A SRAM",
133 .bankwidth = 2,
134};
135
136static struct resource sram_resource_a = {
137 .start = 0x20240000,
138 .end = 0x2024ffff,
139 .flags = IORESOURCE_MEM,
140};
141
142static struct platform_device sram_device_a = {
143 .name = "mtd-ram",
144 .id = 8,
145 .dev = {
146 .platform_data = &sram_data_a,
147 },
148 .num_resources = 1,
149 .resource = &sram_resource_a,
150};
151
152static struct platdata_mtd_ram sram_data_b = {
153 .mapname = "Flash B SRAM",
154 .bankwidth = 2,
155};
156
157static struct resource sram_resource_b = {
158 .start = 0x202c0000,
159 .end = 0x202cffff,
160 .flags = IORESOURCE_MEM,
161};
162
163static struct platform_device sram_device_b = {
164 .name = "mtd-ram",
165 .id = 9,
166 .dev = {
167 .platform_data = &sram_data_b,
168 },
169 .num_resources = 1,
170 .resource = &sram_resource_b,
171};
172#endif
173
Bryan Wu1394f032007-05-06 14:50:22 -0700174#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
175static struct mtd_partition bfin_spi_flash_partitions[] = {
176 {
Robin Getzaa582972008-08-05 17:47:29 +0800177 .name = "bootloader(spi)",
Bryan Wu1394f032007-05-06 14:50:22 -0700178 .size = 0x00020000,
179 .offset = 0,
180 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800181 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800182 .name = "linux kernel(spi)",
Bryan Wu1394f032007-05-06 14:50:22 -0700183 .size = 0xe0000,
Mike Frysingeredf05642008-02-25 11:38:11 +0800184 .offset = MTDPART_OFS_APPEND,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800185 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800186 .name = "file system(spi)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800187 .size = MTDPART_SIZ_FULL,
188 .offset = MTDPART_OFS_APPEND,
Bryan Wu1394f032007-05-06 14:50:22 -0700189 }
190};
191
192static struct flash_platform_data bfin_spi_flash_data = {
193 .name = "m25p80",
194 .parts = bfin_spi_flash_partitions,
195 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
196 .type = "m25p64",
197};
198
199/* SPI flash chip (m25p64) */
200static struct bfin5xx_spi_chip spi_flash_chip_info = {
201 .enable_dma = 0, /* use dma transfer with this chip*/
202 .bits_per_word = 8,
203};
204#endif
205
Mike Frysingera261eec2009-05-20 14:05:36 +0000206#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700207/* SPI ADC chip */
208static struct bfin5xx_spi_chip spi_adc_chip_info = {
209 .enable_dma = 1, /* use dma transfer with this chip*/
210 .bits_per_word = 16,
211};
212#endif
213
214#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
215static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
216 .enable_dma = 0,
217 .bits_per_word = 16,
218};
219#endif
220
Michael Hennerich6e668932008-02-09 01:54:09 +0800221#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
222static struct bfin5xx_spi_chip spidev_chip_info = {
223 .enable_dma = 0,
224 .bits_per_word = 8,
225};
226#endif
227
Bryan Wu1394f032007-05-06 14:50:22 -0700228static struct spi_board_info bfin_spi_board_info[] __initdata = {
229#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
230 {
231 /* the modalias must be the same as spi device driver name */
232 .modalias = "m25p80", /* Name of spi_driver for this device */
233 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800234 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700235 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
236 .platform_data = &bfin_spi_flash_data,
237 .controller_data = &spi_flash_chip_info,
238 .mode = SPI_MODE_3,
239 },
240#endif
241
Mike Frysingera261eec2009-05-20 14:05:36 +0000242#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700243 {
244 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
245 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800246 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700247 .chip_select = 1, /* Framework chip select. */
248 .platform_data = NULL, /* No spi_driver specific config */
249 .controller_data = &spi_adc_chip_info,
250 },
251#endif
252
253#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
254 {
Barry Songdac98172009-08-13 21:07:37 +0000255 .modalias = "ad1836",
Bryan Wu1394f032007-05-06 14:50:22 -0700256 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800257 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700258 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
259 .controller_data = &ad1836_spi_chip_info,
260 },
261#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800262#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
263 {
264 .modalias = "spidev",
265 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
266 .bus_num = 0,
267 .chip_select = 1,
268 .controller_data = &spidev_chip_info,
269 },
270#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700271};
272
Mike Frysinger5bda2722008-06-07 15:03:01 +0800273#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800274/* SPI (0) */
275static struct resource bfin_spi0_resource[] = {
276 [0] = {
277 .start = SPI0_REGBASE,
278 .end = SPI0_REGBASE + 0xFF,
279 .flags = IORESOURCE_MEM,
280 },
281 [1] = {
282 .start = CH_SPI,
283 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000284 .flags = IORESOURCE_DMA,
285 },
286 [2] = {
287 .start = IRQ_SPI,
288 .end = IRQ_SPI,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800289 .flags = IORESOURCE_IRQ,
290 }
291};
292
Bryan Wu1394f032007-05-06 14:50:22 -0700293/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800294static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700295 .num_chipselect = 8,
296 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800297 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700298};
299
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800300static struct platform_device bfin_spi0_device = {
301 .name = "bfin-spi",
302 .id = 0, /* Bus number */
303 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
304 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700305 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800306 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700307 },
308};
309#endif /* spi master and devices */
310
311#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
312static struct resource bfin_uart_resources[] = {
313 {
314 .start = 0xFFC00400,
315 .end = 0xFFC004FF,
316 .flags = IORESOURCE_MEM,
317 },
318};
319
320static struct platform_device bfin_uart_device = {
321 .name = "bfin-uart",
322 .id = 1,
323 .num_resources = ARRAY_SIZE(bfin_uart_resources),
324 .resource = bfin_uart_resources,
325};
326#endif
327
Graf Yang5be36d22008-04-25 03:09:15 +0800328#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang5be36d22008-04-25 03:09:15 +0800329#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800330static struct resource bfin_sir0_resources[] = {
Graf Yang5be36d22008-04-25 03:09:15 +0800331 {
332 .start = 0xFFC00400,
333 .end = 0xFFC004FF,
334 .flags = IORESOURCE_MEM,
335 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800336 {
337 .start = IRQ_UART0_RX,
338 .end = IRQ_UART0_RX+1,
339 .flags = IORESOURCE_IRQ,
340 },
341 {
342 .start = CH_UART0_RX,
343 .end = CH_UART0_RX+1,
344 .flags = IORESOURCE_DMA,
345 },
Graf Yang5be36d22008-04-25 03:09:15 +0800346};
347
Graf Yang42bd8bc2009-01-07 23:14:39 +0800348static struct platform_device bfin_sir0_device = {
Graf Yang5be36d22008-04-25 03:09:15 +0800349 .name = "bfin_sir",
350 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800351 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
352 .resource = bfin_sir0_resources,
Graf Yang5be36d22008-04-25 03:09:15 +0800353};
354#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800355#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800356
Michael Hennerich2463ef22008-01-27 16:49:48 +0800357#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
358#include <linux/input.h>
359#include <linux/gpio_keys.h>
360
361static struct gpio_keys_button bfin_gpio_keys_table[] = {
362 {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
363 {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
364 {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
365 {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
366};
367
368static struct gpio_keys_platform_data bfin_gpio_keys_data = {
369 .buttons = bfin_gpio_keys_table,
370 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
371};
372
373static struct platform_device bfin_device_gpiokeys = {
374 .name = "gpio-keys",
375 .dev = {
376 .platform_data = &bfin_gpio_keys_data,
377 },
378};
379#endif
380
Mike Frysingercad2ab62008-02-22 17:01:31 +0800381static struct resource bfin_gpios_resources = {
382 .start = 0,
383 .end = MAX_BLACKFIN_GPIOS - 1,
384 .flags = IORESOURCE_IRQ,
385};
386
387static struct platform_device bfin_gpios_device = {
388 .name = "simple-gpio",
389 .id = -1,
390 .num_resources = 1,
391 .resource = &bfin_gpios_resources,
392};
393
Bryan Wue3163952008-01-24 16:19:15 +0800394#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
395#include <linux/i2c-gpio.h>
396
397static struct i2c_gpio_platform_data i2c_gpio_data = {
398 .sda_pin = 1,
399 .scl_pin = 0,
400 .sda_is_open_drain = 0,
401 .scl_is_open_drain = 0,
402 .udelay = 40,
403};
404
405static struct platform_device i2c_gpio_device = {
406 .name = "i2c-gpio",
407 .id = 0,
408 .dev = {
409 .platform_data = &i2c_gpio_data,
410 },
411};
412#endif
413
Michael Hennerich14b03202008-05-07 11:41:26 +0800414static const unsigned int cclk_vlev_datasheet[] =
415{
416 VRPAIR(VLEV_085, 250000000),
417 VRPAIR(VLEV_090, 376000000),
418 VRPAIR(VLEV_095, 426000000),
419 VRPAIR(VLEV_100, 426000000),
420 VRPAIR(VLEV_105, 476000000),
421 VRPAIR(VLEV_110, 476000000),
422 VRPAIR(VLEV_115, 476000000),
423 VRPAIR(VLEV_120, 600000000),
424 VRPAIR(VLEV_125, 600000000),
425 VRPAIR(VLEV_130, 600000000),
426};
427
428static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
429 .tuple_tab = cclk_vlev_datasheet,
430 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
431 .vr_settling_time = 25 /* us */,
432};
433
434static struct platform_device bfin_dpmc = {
435 .name = "bfin dpmc",
436 .dev = {
437 .platform_data = &bfin_dmpc_vreg_data,
438 },
439};
440
Bryan Wu1394f032007-05-06 14:50:22 -0700441static struct platform_device *ezkit_devices[] __initdata = {
Michael Hennerich14b03202008-05-07 11:41:26 +0800442
443 &bfin_dpmc,
444
Mike Frysinger4d5e6fd2009-06-13 06:34:49 -0400445#if defined(CONFIG_MTD_PSD4256G) || defined(CONFIG_MTD_PSD4256G_MODULE)
446 &stm_pri_device_a,
447 &stm_pri_device_b,
448#endif
449
450#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
451 &sram_device_a,
452 &sram_device_b,
453#endif
454
Bryan Wu1394f032007-05-06 14:50:22 -0700455#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
456 &smc91x_device,
457#endif
458
459#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800460 &bfin_spi0_device,
461#endif
462
463#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
464 &bfin_fb_adv7393_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700465#endif
466
467#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
468 &rtc_device,
469#endif
470
Sonic Zhange062cea2009-01-07 23:14:39 +0800471#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
472 &bfin_uart_device,
473#endif
474
Graf Yang5be36d22008-04-25 03:09:15 +0800475#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800476#ifdef CONFIG_BFIN_SIR0
477 &bfin_sir0_device,
478#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800479#endif
480
Michael Hennerich2463ef22008-01-27 16:49:48 +0800481#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
482 &bfin_device_gpiokeys,
483#endif
Bryan Wue3163952008-01-24 16:19:15 +0800484
485#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
486 &i2c_gpio_device,
487#endif
Mike Frysingercad2ab62008-02-22 17:01:31 +0800488
489 &bfin_gpios_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700490};
491
492static int __init ezkit_init(void)
493{
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800494 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu1394f032007-05-06 14:50:22 -0700495 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
Bryan Wu1394f032007-05-06 14:50:22 -0700496 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Bryan Wu1394f032007-05-06 14:50:22 -0700497 return 0;
498}
499
500arch_initcall(ezkit_init);