blob: 9ffcd63442f1a728234485ad68646102a088204d [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>
Michael Hennerich50c4c082009-09-22 13:10:09 +000020#include <linux/i2c.h>
Bryan Wuc6c4d7b2007-10-11 01:20:06 +080021#include <asm/dma.h>
Bryan Wu1394f032007-05-06 14:50:22 -070022#include <asm/bfin5xx_spi.h>
Bryan Wu5d448dd2007-11-12 23:24:42 +080023#include <asm/portmux.h>
Michael Hennerich14b03202008-05-07 11:41:26 +080024#include <asm/dpmc.h>
Bryan Wu1394f032007-05-06 14:50:22 -070025
26/*
27 * Name the Board for the /proc/cpuinfo
28 */
Mike Frysingerfe85cad2008-11-18 17:48:22 +080029const char bfin_board_name[] = "ADI BF533-EZKIT";
Bryan Wu1394f032007-05-06 14:50:22 -070030
31#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
32static struct platform_device rtc_device = {
33 .name = "rtc-bfin",
34 .id = -1,
35};
36#endif
37
38/*
39 * USB-LAN EzExtender board
40 * Driver needs to know address, irq and flag pin.
41 */
42#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +000043#include <linux/smc91x.h>
44
45static struct smc91x_platdata smc91x_info = {
46 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
47 .leda = RPC_LED_100_10,
48 .ledb = RPC_LED_TX_RX,
49};
50
Bryan Wu1394f032007-05-06 14:50:22 -070051static struct resource smc91x_resources[] = {
52 {
53 .name = "smc91x-regs",
54 .start = 0x20310300,
55 .end = 0x20310300 + 16,
56 .flags = IORESOURCE_MEM,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +080057 }, {
Bryan Wu1394f032007-05-06 14:50:22 -070058 .start = IRQ_PF9,
59 .end = IRQ_PF9,
60 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
61 },
62};
63static struct platform_device smc91x_device = {
64 .name = "smc91x",
65 .id = 0,
66 .num_resources = ARRAY_SIZE(smc91x_resources),
67 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +000068 .dev = {
69 .platform_data = &smc91x_info,
70 },
Bryan Wu1394f032007-05-06 14:50:22 -070071};
72#endif
73
Mike Frysinger4d5e6fd2009-06-13 06:34:49 -040074#if defined(CONFIG_MTD_PSD4256G) || defined(CONFIG_MTD_PSD4256G_MODULE)
75static const char *map_probes[] = {
76 "stm_flash",
77 NULL,
78};
79
80static struct platdata_mtd_ram stm_pri_data_a = {
81 .mapname = "Flash A Primary",
82 .map_probes = map_probes,
83 .bankwidth = 2,
84};
85
86static struct resource stm_pri_resource_a = {
87 .start = 0x20000000,
88 .end = 0x200fffff,
89 .flags = IORESOURCE_MEM,
90};
91
92static struct platform_device stm_pri_device_a = {
93 .name = "mtd-ram",
94 .id = 0,
95 .dev = {
96 .platform_data = &stm_pri_data_a,
97 },
98 .num_resources = 1,
99 .resource = &stm_pri_resource_a,
100};
101
102static struct platdata_mtd_ram stm_pri_data_b = {
103 .mapname = "Flash B Primary",
104 .map_probes = map_probes,
105 .bankwidth = 2,
106};
107
108static struct resource stm_pri_resource_b = {
109 .start = 0x20100000,
110 .end = 0x201fffff,
111 .flags = IORESOURCE_MEM,
112};
113
114static struct platform_device stm_pri_device_b = {
115 .name = "mtd-ram",
116 .id = 4,
117 .dev = {
118 .platform_data = &stm_pri_data_b,
119 },
120 .num_resources = 1,
121 .resource = &stm_pri_resource_b,
122};
123#endif
124
125#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
126static struct platdata_mtd_ram sram_data_a = {
127 .mapname = "Flash A SRAM",
128 .bankwidth = 2,
129};
130
131static struct resource sram_resource_a = {
132 .start = 0x20240000,
133 .end = 0x2024ffff,
134 .flags = IORESOURCE_MEM,
135};
136
137static struct platform_device sram_device_a = {
138 .name = "mtd-ram",
139 .id = 8,
140 .dev = {
141 .platform_data = &sram_data_a,
142 },
143 .num_resources = 1,
144 .resource = &sram_resource_a,
145};
146
147static struct platdata_mtd_ram sram_data_b = {
148 .mapname = "Flash B SRAM",
149 .bankwidth = 2,
150};
151
152static struct resource sram_resource_b = {
153 .start = 0x202c0000,
154 .end = 0x202cffff,
155 .flags = IORESOURCE_MEM,
156};
157
158static struct platform_device sram_device_b = {
159 .name = "mtd-ram",
160 .id = 9,
161 .dev = {
162 .platform_data = &sram_data_b,
163 },
164 .num_resources = 1,
165 .resource = &sram_resource_b,
166};
167#endif
168
Bryan Wu1394f032007-05-06 14:50:22 -0700169#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
170static struct mtd_partition bfin_spi_flash_partitions[] = {
171 {
Robin Getzaa582972008-08-05 17:47:29 +0800172 .name = "bootloader(spi)",
Bryan Wu1394f032007-05-06 14:50:22 -0700173 .size = 0x00020000,
174 .offset = 0,
175 .mask_flags = MTD_CAP_ROM
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800176 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800177 .name = "linux kernel(spi)",
Bryan Wu1394f032007-05-06 14:50:22 -0700178 .size = 0xe0000,
Mike Frysingeredf05642008-02-25 11:38:11 +0800179 .offset = MTDPART_OFS_APPEND,
Mike Frysinger1f83b8f2007-07-12 22:58:21 +0800180 }, {
Robin Getzaa582972008-08-05 17:47:29 +0800181 .name = "file system(spi)",
Mike Frysingeredf05642008-02-25 11:38:11 +0800182 .size = MTDPART_SIZ_FULL,
183 .offset = MTDPART_OFS_APPEND,
Bryan Wu1394f032007-05-06 14:50:22 -0700184 }
185};
186
187static struct flash_platform_data bfin_spi_flash_data = {
188 .name = "m25p80",
189 .parts = bfin_spi_flash_partitions,
190 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
191 .type = "m25p64",
192};
193
194/* SPI flash chip (m25p64) */
195static struct bfin5xx_spi_chip spi_flash_chip_info = {
196 .enable_dma = 0, /* use dma transfer with this chip*/
197 .bits_per_word = 8,
198};
199#endif
200
Mike Frysingera261eec2009-05-20 14:05:36 +0000201#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700202/* SPI ADC chip */
203static struct bfin5xx_spi_chip spi_adc_chip_info = {
204 .enable_dma = 1, /* use dma transfer with this chip*/
205 .bits_per_word = 16,
206};
207#endif
208
209#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
210static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
211 .enable_dma = 0,
212 .bits_per_word = 16,
213};
214#endif
215
Michael Hennerich6e668932008-02-09 01:54:09 +0800216#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
217static struct bfin5xx_spi_chip spidev_chip_info = {
218 .enable_dma = 0,
219 .bits_per_word = 8,
220};
221#endif
222
Bryan Wu1394f032007-05-06 14:50:22 -0700223static struct spi_board_info bfin_spi_board_info[] __initdata = {
224#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
225 {
226 /* the modalias must be the same as spi device driver name */
227 .modalias = "m25p80", /* Name of spi_driver for this device */
228 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800229 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700230 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
231 .platform_data = &bfin_spi_flash_data,
232 .controller_data = &spi_flash_chip_info,
233 .mode = SPI_MODE_3,
234 },
235#endif
236
Mike Frysingera261eec2009-05-20 14:05:36 +0000237#if defined(CONFIG_BFIN_SPI_ADC) || defined(CONFIG_BFIN_SPI_ADC_MODULE)
Bryan Wu1394f032007-05-06 14:50:22 -0700238 {
239 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
240 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800241 .bus_num = 0, /* Framework bus number */
Bryan Wu1394f032007-05-06 14:50:22 -0700242 .chip_select = 1, /* Framework chip select. */
243 .platform_data = NULL, /* No spi_driver specific config */
244 .controller_data = &spi_adc_chip_info,
245 },
246#endif
247
248#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
249 {
Barry Songdac98172009-08-13 21:07:37 +0000250 .modalias = "ad1836",
Bryan Wu1394f032007-05-06 14:50:22 -0700251 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800252 .bus_num = 0,
Bryan Wu1394f032007-05-06 14:50:22 -0700253 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
254 .controller_data = &ad1836_spi_chip_info,
255 },
256#endif
Michael Hennerich6e668932008-02-09 01:54:09 +0800257#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
258 {
259 .modalias = "spidev",
260 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
261 .bus_num = 0,
262 .chip_select = 1,
263 .controller_data = &spidev_chip_info,
264 },
265#endif
Bryan Wu1394f032007-05-06 14:50:22 -0700266};
267
Mike Frysinger5bda2722008-06-07 15:03:01 +0800268#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800269/* SPI (0) */
270static struct resource bfin_spi0_resource[] = {
271 [0] = {
272 .start = SPI0_REGBASE,
273 .end = SPI0_REGBASE + 0xFF,
274 .flags = IORESOURCE_MEM,
275 },
276 [1] = {
277 .start = CH_SPI,
278 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000279 .flags = IORESOURCE_DMA,
280 },
281 [2] = {
282 .start = IRQ_SPI,
283 .end = IRQ_SPI,
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800284 .flags = IORESOURCE_IRQ,
285 }
286};
287
Bryan Wu1394f032007-05-06 14:50:22 -0700288/* SPI controller data */
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800289static struct bfin5xx_spi_master bfin_spi0_info = {
Bryan Wu1394f032007-05-06 14:50:22 -0700290 .num_chipselect = 8,
291 .enable_dma = 1, /* master has the ability to do dma transfer */
Bryan Wu5d448dd2007-11-12 23:24:42 +0800292 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
Bryan Wu1394f032007-05-06 14:50:22 -0700293};
294
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800295static struct platform_device bfin_spi0_device = {
296 .name = "bfin-spi",
297 .id = 0, /* Bus number */
298 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
299 .resource = bfin_spi0_resource,
Bryan Wu1394f032007-05-06 14:50:22 -0700300 .dev = {
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800301 .platform_data = &bfin_spi0_info, /* Passed to driver */
Bryan Wu1394f032007-05-06 14:50:22 -0700302 },
303};
304#endif /* spi master and devices */
305
306#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
307static struct resource bfin_uart_resources[] = {
308 {
309 .start = 0xFFC00400,
310 .end = 0xFFC004FF,
311 .flags = IORESOURCE_MEM,
312 },
313};
314
315static struct platform_device bfin_uart_device = {
316 .name = "bfin-uart",
317 .id = 1,
318 .num_resources = ARRAY_SIZE(bfin_uart_resources),
319 .resource = bfin_uart_resources,
320};
321#endif
322
Graf Yang5be36d22008-04-25 03:09:15 +0800323#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang5be36d22008-04-25 03:09:15 +0800324#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800325static struct resource bfin_sir0_resources[] = {
Graf Yang5be36d22008-04-25 03:09:15 +0800326 {
327 .start = 0xFFC00400,
328 .end = 0xFFC004FF,
329 .flags = IORESOURCE_MEM,
330 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800331 {
332 .start = IRQ_UART0_RX,
333 .end = IRQ_UART0_RX+1,
334 .flags = IORESOURCE_IRQ,
335 },
336 {
337 .start = CH_UART0_RX,
338 .end = CH_UART0_RX+1,
339 .flags = IORESOURCE_DMA,
340 },
Graf Yang5be36d22008-04-25 03:09:15 +0800341};
342
Graf Yang42bd8bc2009-01-07 23:14:39 +0800343static struct platform_device bfin_sir0_device = {
Graf Yang5be36d22008-04-25 03:09:15 +0800344 .name = "bfin_sir",
345 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800346 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
347 .resource = bfin_sir0_resources,
Graf Yang5be36d22008-04-25 03:09:15 +0800348};
349#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800350#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800351
Michael Hennerich2463ef22008-01-27 16:49:48 +0800352#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
353#include <linux/input.h>
354#include <linux/gpio_keys.h>
355
356static struct gpio_keys_button bfin_gpio_keys_table[] = {
357 {BTN_0, GPIO_PF7, 1, "gpio-keys: BTN0"},
358 {BTN_1, GPIO_PF8, 1, "gpio-keys: BTN1"},
359 {BTN_2, GPIO_PF9, 1, "gpio-keys: BTN2"},
360 {BTN_3, GPIO_PF10, 1, "gpio-keys: BTN3"},
361};
362
363static struct gpio_keys_platform_data bfin_gpio_keys_data = {
364 .buttons = bfin_gpio_keys_table,
365 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
366};
367
368static struct platform_device bfin_device_gpiokeys = {
369 .name = "gpio-keys",
370 .dev = {
371 .platform_data = &bfin_gpio_keys_data,
372 },
373};
374#endif
375
Mike Frysingercad2ab62008-02-22 17:01:31 +0800376static struct resource bfin_gpios_resources = {
377 .start = 0,
378 .end = MAX_BLACKFIN_GPIOS - 1,
379 .flags = IORESOURCE_IRQ,
380};
381
382static struct platform_device bfin_gpios_device = {
383 .name = "simple-gpio",
384 .id = -1,
385 .num_resources = 1,
386 .resource = &bfin_gpios_resources,
387};
388
Bryan Wue3163952008-01-24 16:19:15 +0800389#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
390#include <linux/i2c-gpio.h>
391
392static struct i2c_gpio_platform_data i2c_gpio_data = {
393 .sda_pin = 1,
394 .scl_pin = 0,
395 .sda_is_open_drain = 0,
396 .scl_is_open_drain = 0,
397 .udelay = 40,
398};
399
400static struct platform_device i2c_gpio_device = {
401 .name = "i2c-gpio",
402 .id = 0,
403 .dev = {
404 .platform_data = &i2c_gpio_data,
405 },
406};
407#endif
408
Michael Hennerich14b03202008-05-07 11:41:26 +0800409static const unsigned int cclk_vlev_datasheet[] =
410{
411 VRPAIR(VLEV_085, 250000000),
412 VRPAIR(VLEV_090, 376000000),
413 VRPAIR(VLEV_095, 426000000),
414 VRPAIR(VLEV_100, 426000000),
415 VRPAIR(VLEV_105, 476000000),
416 VRPAIR(VLEV_110, 476000000),
417 VRPAIR(VLEV_115, 476000000),
418 VRPAIR(VLEV_120, 600000000),
419 VRPAIR(VLEV_125, 600000000),
420 VRPAIR(VLEV_130, 600000000),
421};
422
423static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
424 .tuple_tab = cclk_vlev_datasheet,
425 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
426 .vr_settling_time = 25 /* us */,
427};
428
429static struct platform_device bfin_dpmc = {
430 .name = "bfin dpmc",
431 .dev = {
432 .platform_data = &bfin_dmpc_vreg_data,
433 },
434};
435
Michael Hennerich50c4c082009-09-22 13:10:09 +0000436static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
437#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
438 {
439 I2C_BOARD_INFO("bfin-adv7393", 0x2B),
440 },
441#endif
442};
443
Bryan Wu1394f032007-05-06 14:50:22 -0700444static struct platform_device *ezkit_devices[] __initdata = {
Michael Hennerich14b03202008-05-07 11:41:26 +0800445
446 &bfin_dpmc,
447
Mike Frysinger4d5e6fd2009-06-13 06:34:49 -0400448#if defined(CONFIG_MTD_PSD4256G) || defined(CONFIG_MTD_PSD4256G_MODULE)
449 &stm_pri_device_a,
450 &stm_pri_device_b,
451#endif
452
453#if defined(CONFIG_MTD_PLATRAM) || defined(CONFIG_MTD_PLATRAM_MODULE)
454 &sram_device_a,
455 &sram_device_b,
456#endif
457
Bryan Wu1394f032007-05-06 14:50:22 -0700458#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
459 &smc91x_device,
460#endif
461
462#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
Bryan Wuc6c4d7b2007-10-11 01:20:06 +0800463 &bfin_spi0_device,
464#endif
465
Bryan Wu1394f032007-05-06 14:50:22 -0700466#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
467 &rtc_device,
468#endif
469
Sonic Zhange062cea2009-01-07 23:14:39 +0800470#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
471 &bfin_uart_device,
472#endif
473
Graf Yang5be36d22008-04-25 03:09:15 +0800474#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800475#ifdef CONFIG_BFIN_SIR0
476 &bfin_sir0_device,
477#endif
Graf Yang5be36d22008-04-25 03:09:15 +0800478#endif
479
Michael Hennerich2463ef22008-01-27 16:49:48 +0800480#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
481 &bfin_device_gpiokeys,
482#endif
Bryan Wue3163952008-01-24 16:19:15 +0800483
484#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
485 &i2c_gpio_device,
486#endif
Mike Frysingercad2ab62008-02-22 17:01:31 +0800487
488 &bfin_gpios_device,
Bryan Wu1394f032007-05-06 14:50:22 -0700489};
490
491static int __init ezkit_init(void)
492{
Harvey Harrisonb85d8582008-04-23 09:39:01 +0800493 printk(KERN_INFO "%s(): registering device resources\n", __func__);
Bryan Wu1394f032007-05-06 14:50:22 -0700494 platform_add_devices(ezkit_devices, ARRAY_SIZE(ezkit_devices));
Bryan Wu1394f032007-05-06 14:50:22 -0700495 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
Michael Hennerich50c4c082009-09-22 13:10:09 +0000496 i2c_register_board_info(0, bfin_i2c_board_info,
497 ARRAY_SIZE(bfin_i2c_board_info));
Bryan Wu1394f032007-05-06 14:50:22 -0700498 return 0;
499}
500
501arch_initcall(ezkit_init);