blob: fc78a3893981cedc9ca895f7d8b4084361603a24 [file] [log] [blame]
Benjamin Matthews130de7c2008-08-14 14:55:54 +08001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Board Info File for the BlackStamp
Benjamin Matthews130de7c2008-08-14 14:55:54 +08003 *
Benjamin Matthews130de7c2008-08-14 14:55:54 +08004 * Copyright 2004-2008 Analog Devices Inc.
Robin Getz96f10502009-09-24 14:11:24 +00005 * 2008 Benjamin Matthews <bmat@lle.rochester.edu>
6 * 2005 National ICT Australia (NICTA)
7 * Aidan Williams <aidan@nicta.com.au>
Benjamin Matthews130de7c2008-08-14 14:55:54 +08008 *
9 * More info about the BlackStamp at:
10 * http://blackfin.uclinux.org/gf/project/blackstamp/
11 *
12 * Licensed under the GPL-2 or later.
13 */
14
15#include <linux/device.h>
16#include <linux/platform_device.h>
17#include <linux/mtd/mtd.h>
18#include <linux/mtd/partitions.h>
19#include <linux/mtd/physmap.h>
20#include <linux/spi/spi.h>
21#include <linux/spi/flash.h>
22#include <linux/irq.h>
23#include <linux/i2c.h>
24#include <asm/dma.h>
25#include <asm/bfin5xx_spi.h>
26#include <asm/portmux.h>
27#include <asm/dpmc.h>
28
29/*
30 * Name the Board for the /proc/cpuinfo
31 */
32const char bfin_board_name[] = "BlackStamp";
33
34#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
35static struct platform_device rtc_device = {
36 .name = "rtc-bfin",
37 .id = -1,
38};
39#endif
40
41/*
42 * Driver needs to know address, irq and flag pin.
43 */
44#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
Michael Hennerich61f09b52009-07-24 08:48:31 +000045#include <linux/smc91x.h>
46
47static struct smc91x_platdata smc91x_info = {
48 .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
49 .leda = RPC_LED_100_10,
50 .ledb = RPC_LED_TX_RX,
51};
52
Benjamin Matthews130de7c2008-08-14 14:55:54 +080053static struct resource smc91x_resources[] = {
54 {
55 .name = "smc91x-regs",
56 .start = 0x20300300,
57 .end = 0x20300300 + 16,
58 .flags = IORESOURCE_MEM,
59 }, {
60 .start = IRQ_PF3,
61 .end = IRQ_PF3,
62 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
63 },
64};
65
66static struct platform_device smc91x_device = {
67 .name = "smc91x",
68 .id = 0,
69 .num_resources = ARRAY_SIZE(smc91x_resources),
70 .resource = smc91x_resources,
Michael Hennerich61f09b52009-07-24 08:48:31 +000071 .dev = {
72 .platform_data = &smc91x_info,
73 },
Benjamin Matthews130de7c2008-08-14 14:55:54 +080074};
75#endif
76
77#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
78static struct mtd_partition bfin_spi_flash_partitions[] = {
79 {
80 .name = "bootloader(spi)",
81 .size = 0x00040000,
82 .offset = 0,
83 .mask_flags = MTD_CAP_ROM
84 }, {
85 .name = "linux kernel(spi)",
86 .size = 0x180000,
87 .offset = MTDPART_OFS_APPEND,
88 }, {
89 .name = "file system(spi)",
90 .size = MTDPART_SIZ_FULL,
91 .offset = MTDPART_OFS_APPEND,
92 }
93};
94
95static struct flash_platform_data bfin_spi_flash_data = {
96 .name = "m25p80",
97 .parts = bfin_spi_flash_partitions,
98 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
99 .type = "m25p64",
100};
101
102/* SPI flash chip (m25p64) */
103static struct bfin5xx_spi_chip spi_flash_chip_info = {
104 .enable_dma = 0, /* use dma transfer with this chip*/
105 .bits_per_word = 8,
106};
107#endif
108
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800109#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
110static struct bfin5xx_spi_chip mmc_spi_chip_info = {
111 .enable_dma = 0,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800112 .bits_per_word = 8,
113};
114#endif
115
116#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
117static struct bfin5xx_spi_chip spidev_chip_info = {
118 .enable_dma = 0,
119 .bits_per_word = 8,
120};
121#endif
122
123static struct spi_board_info bfin_spi_board_info[] __initdata = {
124#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
125 {
126 /* the modalias must be the same as spi device driver name */
127 .modalias = "m25p80", /* Name of spi_driver for this device */
128 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
129 .bus_num = 0, /* Framework bus number */
130 .chip_select = 2, /* Framework chip select. */
131 .platform_data = &bfin_spi_flash_data,
132 .controller_data = &spi_flash_chip_info,
133 .mode = SPI_MODE_3,
134 },
135#endif
136
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800137#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800138 {
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800139 .modalias = "mmc_spi",
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800140 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
141 .bus_num = 0,
Michael Hennerichf3f704d2009-03-06 00:27:57 +0800142 .chip_select = 5,
143 .controller_data = &mmc_spi_chip_info,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800144 .mode = SPI_MODE_3,
145 },
146#endif
147
148#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
149 {
150 .modalias = "spidev",
151 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
152 .bus_num = 0,
153 .chip_select = 7,
154 .controller_data = &spidev_chip_info,
155 },
156#endif
157};
158
159#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
160/* SPI (0) */
161static struct resource bfin_spi0_resource[] = {
162 [0] = {
163 .start = SPI0_REGBASE,
164 .end = SPI0_REGBASE + 0xFF,
165 .flags = IORESOURCE_MEM,
166 },
167 [1] = {
168 .start = CH_SPI,
169 .end = CH_SPI,
Yi Li53122692009-06-05 12:11:11 +0000170 .flags = IORESOURCE_DMA,
171 },
172 [2] = {
173 .start = IRQ_SPI,
174 .end = IRQ_SPI,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800175 .flags = IORESOURCE_IRQ,
176 }
177};
178
179/* SPI controller data */
180static struct bfin5xx_spi_master bfin_spi0_info = {
181 .num_chipselect = 8,
182 .enable_dma = 1, /* master has the ability to do dma transfer */
183 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
184};
185
186static struct platform_device bfin_spi0_device = {
187 .name = "bfin-spi",
188 .id = 0, /* Bus number */
189 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
190 .resource = bfin_spi0_resource,
191 .dev = {
192 .platform_data = &bfin_spi0_info, /* Passed to driver */
193 },
194};
195#endif /* spi master and devices */
196
197#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
198static struct resource bfin_uart_resources[] = {
199 {
200 .start = 0xFFC00400,
201 .end = 0xFFC004FF,
202 .flags = IORESOURCE_MEM,
203 },
204};
205
206static struct platform_device bfin_uart_device = {
207 .name = "bfin-uart",
208 .id = 1,
209 .num_resources = ARRAY_SIZE(bfin_uart_resources),
210 .resource = bfin_uart_resources,
211};
212#endif
213
214#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800215#ifdef CONFIG_BFIN_SIR0
Graf Yang42bd8bc2009-01-07 23:14:39 +0800216static struct resource bfin_sir0_resources[] = {
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800217 {
218 .start = 0xFFC00400,
219 .end = 0xFFC004FF,
220 .flags = IORESOURCE_MEM,
221 },
Graf Yang42bd8bc2009-01-07 23:14:39 +0800222 {
223 .start = IRQ_UART0_RX,
224 .end = IRQ_UART0_RX+1,
225 .flags = IORESOURCE_IRQ,
226 },
227 {
228 .start = CH_UART0_RX,
229 .end = CH_UART0_RX+1,
230 .flags = IORESOURCE_DMA,
231 },
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800232};
233
Graf Yang42bd8bc2009-01-07 23:14:39 +0800234static struct platform_device bfin_sir0_device = {
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800235 .name = "bfin_sir",
236 .id = 0,
Graf Yang42bd8bc2009-01-07 23:14:39 +0800237 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
238 .resource = bfin_sir0_resources,
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800239};
240#endif
Graf Yang42bd8bc2009-01-07 23:14:39 +0800241#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800242
243#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
244static struct platform_device bfin_sport0_uart_device = {
245 .name = "bfin-sport-uart",
246 .id = 0,
247};
248
249static struct platform_device bfin_sport1_uart_device = {
250 .name = "bfin-sport-uart",
251 .id = 1,
252};
253#endif
254
255#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
256#include <linux/input.h>
257#include <linux/gpio_keys.h>
258
259static struct gpio_keys_button bfin_gpio_keys_table[] = {
260 {BTN_0, GPIO_PF4, 0, "gpio-keys: BTN0"},
261 {BTN_1, GPIO_PF5, 0, "gpio-keys: BTN1"},
262 {BTN_2, GPIO_PF6, 0, "gpio-keys: BTN2"},
263}; /* Mapped to the first three PF Test Points */
264
265static struct gpio_keys_platform_data bfin_gpio_keys_data = {
266 .buttons = bfin_gpio_keys_table,
267 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
268};
269
270static struct platform_device bfin_device_gpiokeys = {
271 .name = "gpio-keys",
272 .dev = {
273 .platform_data = &bfin_gpio_keys_data,
274 },
275};
276#endif
277
278static struct resource bfin_gpios_resources = {
279 .start = 0,
280 .end = MAX_BLACKFIN_GPIOS - 1,
281 .flags = IORESOURCE_IRQ,
282};
283
284static struct platform_device bfin_gpios_device = {
285 .name = "simple-gpio",
286 .id = -1,
287 .num_resources = 1,
288 .resource = &bfin_gpios_resources,
289};
290
291#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
292#include <linux/i2c-gpio.h>
293
294static struct i2c_gpio_platform_data i2c_gpio_data = {
295 .sda_pin = 8,
296 .scl_pin = 9,
297 .sda_is_open_drain = 0,
298 .scl_is_open_drain = 0,
299 .udelay = 40,
300}; /* This hasn't actually been used these pins
301 * are (currently) free pins on the expansion connector */
302
303static struct platform_device i2c_gpio_device = {
304 .name = "i2c-gpio",
305 .id = 0,
306 .dev = {
307 .platform_data = &i2c_gpio_data,
308 },
309};
310#endif
311
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800312static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
313};
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800314
315static const unsigned int cclk_vlev_datasheet[] =
316{
317 VRPAIR(VLEV_085, 250000000),
318 VRPAIR(VLEV_090, 376000000),
319 VRPAIR(VLEV_095, 426000000),
320 VRPAIR(VLEV_100, 426000000),
321 VRPAIR(VLEV_105, 476000000),
322 VRPAIR(VLEV_110, 476000000),
323 VRPAIR(VLEV_115, 476000000),
324 VRPAIR(VLEV_120, 600000000),
325 VRPAIR(VLEV_125, 600000000),
326 VRPAIR(VLEV_130, 600000000),
327};
328
329static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
330 .tuple_tab = cclk_vlev_datasheet,
331 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
332 .vr_settling_time = 25 /* us */,
333};
334
335static struct platform_device bfin_dpmc = {
336 .name = "bfin dpmc",
337 .dev = {
338 .platform_data = &bfin_dmpc_vreg_data,
339 },
340};
341
342static struct platform_device *stamp_devices[] __initdata = {
343
344 &bfin_dpmc,
345
346#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
347 &rtc_device,
348#endif
349
350#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
351 &smc91x_device,
352#endif
353
354
355#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
356 &bfin_spi0_device,
357#endif
358
359#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
360 &bfin_uart_device,
361#endif
362
363#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
Graf Yang42bd8bc2009-01-07 23:14:39 +0800364#ifdef CONFIG_BFIN_SIR0
365 &bfin_sir0_device,
366#endif
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800367#endif
368
369#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
370 &bfin_sport0_uart_device,
371 &bfin_sport1_uart_device,
372#endif
373
374#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
375 &bfin_device_gpiokeys,
376#endif
377
378#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
379 &i2c_gpio_device,
380#endif
381
382 &bfin_gpios_device,
383};
384
385static int __init blackstamp_init(void)
386{
387 int ret;
388
389 printk(KERN_INFO "%s(): registering device resources\n", __func__);
390
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800391 i2c_register_board_info(0, bfin_i2c_board_info,
392 ARRAY_SIZE(bfin_i2c_board_info));
Benjamin Matthews130de7c2008-08-14 14:55:54 +0800393
394 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
395 if (ret < 0)
396 return ret;
397
398#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
399 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
400 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
401 bfin_write_FIO_FLAG_S(PF0);
402 SSYNC();
403#endif
404
405 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
406 return 0;
407}
408
409arch_initcall(blackstamp_init);