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