[Blackfin] arch: enable generic GPIO based I2C driver in STAMP-BF533, EZKIT-BF533...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / blackfin / mach-bf533 / boards / stamp.c
blobcd87df730ef5d333af8296366e4fc72b5cf026bc
1 /*
2 * File: arch/blackfin/mach-bf533/stamp.c
3 * Based on: arch/blackfin/mach-bf533/ezkit.c
4 * Author: Aidan Williams <aidan@nicta.com.au>
6 * Created: 2005
7 * Description: Board Info File for the BF533-STAMP
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
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)
38 #include <linux/usb/isp1362.h>
39 #endif
40 #include <linux/pata_platform.h>
41 #include <linux/irq.h>
42 #include <asm/dma.h>
43 #include <asm/bfin5xx_spi.h>
44 #include <asm/reboot.h>
45 #include <asm/portmux.h>
48 * Name the Board for the /proc/cpuinfo
50 const char bfin_board_name[] = "ADDS-BF533-STAMP";
52 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
53 static struct platform_device rtc_device = {
54 .name = "rtc-bfin",
55 .id = -1,
57 #endif
60 * Driver needs to know address, irq and flag pin.
62 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
63 static struct resource smc91x_resources[] = {
65 .name = "smc91x-regs",
66 .start = 0x20300300,
67 .end = 0x20300300 + 16,
68 .flags = IORESOURCE_MEM,
69 }, {
70 .start = IRQ_PF7,
71 .end = IRQ_PF7,
72 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
76 static struct platform_device smc91x_device = {
77 .name = "smc91x",
78 .id = 0,
79 .num_resources = ARRAY_SIZE(smc91x_resources),
80 .resource = smc91x_resources,
82 #endif
84 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
85 static struct platform_device bfin_fb_adv7393_device = {
86 .name = "bfin-adv7393",
88 #endif
90 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
91 static struct resource net2272_bfin_resources[] = {
93 .start = 0x20300000,
94 .end = 0x20300000 + 0x100,
95 .flags = IORESOURCE_MEM,
96 }, {
97 .start = IRQ_PF10,
98 .end = IRQ_PF10,
99 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
103 static struct platform_device net2272_bfin_device = {
104 .name = "net2272",
105 .id = -1,
106 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
107 .resource = net2272_bfin_resources,
109 #endif
111 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
112 /* all SPI peripherals info goes here */
114 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
115 static struct mtd_partition bfin_spi_flash_partitions[] = {
117 .name = "bootloader",
118 .size = 0x00020000,
119 .offset = 0,
120 .mask_flags = MTD_CAP_ROM
121 }, {
122 .name = "kernel",
123 .size = 0xe0000,
124 .offset = 0x20000
125 }, {
126 .name = "file system",
127 .size = 0x700000,
128 .offset = 0x00100000,
132 static struct flash_platform_data bfin_spi_flash_data = {
133 .name = "m25p80",
134 .parts = bfin_spi_flash_partitions,
135 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
136 .type = "m25p64",
139 /* SPI flash chip (m25p64) */
140 static struct bfin5xx_spi_chip spi_flash_chip_info = {
141 .enable_dma = 0, /* use dma transfer with this chip*/
142 .bits_per_word = 8,
144 #endif
146 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
147 /* SPI ADC chip */
148 static struct bfin5xx_spi_chip spi_adc_chip_info = {
149 .enable_dma = 1, /* use dma transfer with this chip*/
150 .bits_per_word = 16,
152 #endif
154 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
155 static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
156 .enable_dma = 0,
157 .bits_per_word = 16,
159 #endif
161 #if defined(CONFIG_PBX)
162 static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
163 .ctl_reg = 0x4, /* send zero */
164 .enable_dma = 0,
165 .bits_per_word = 8,
166 .cs_change_per_word = 1,
168 #endif
170 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
171 static struct bfin5xx_spi_chip ad5304_chip_info = {
172 .enable_dma = 0,
173 .bits_per_word = 16,
175 #endif
177 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
178 static struct bfin5xx_spi_chip spi_mmc_chip_info = {
179 .enable_dma = 1,
180 .bits_per_word = 8,
182 #endif
184 static struct spi_board_info bfin_spi_board_info[] __initdata = {
185 #if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
187 /* the modalias must be the same as spi device driver name */
188 .modalias = "m25p80", /* Name of spi_driver for this device */
189 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
190 .bus_num = 0, /* Framework bus number */
191 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
192 .platform_data = &bfin_spi_flash_data,
193 .controller_data = &spi_flash_chip_info,
194 .mode = SPI_MODE_3,
196 #endif
198 #if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
200 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
201 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
202 .bus_num = 0, /* Framework bus number */
203 .chip_select = 1, /* Framework chip select. */
204 .platform_data = NULL, /* No spi_driver specific config */
205 .controller_data = &spi_adc_chip_info,
207 #endif
209 #if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
211 .modalias = "ad1836-spi",
212 .max_speed_hz = 31250000, /* max spi clock (SCK) speed in HZ */
213 .bus_num = 0,
214 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
215 .controller_data = &ad1836_spi_chip_info,
217 #endif
219 #if defined(CONFIG_SPI_MMC) || defined(CONFIG_SPI_MMC_MODULE)
221 .modalias = "spi_mmc_dummy",
222 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
223 .bus_num = 0,
224 .chip_select = 0,
225 .platform_data = NULL,
226 .controller_data = &spi_mmc_chip_info,
227 .mode = SPI_MODE_3,
230 .modalias = "spi_mmc",
231 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
232 .bus_num = 0,
233 .chip_select = CONFIG_SPI_MMC_CS_CHAN,
234 .platform_data = NULL,
235 .controller_data = &spi_mmc_chip_info,
236 .mode = SPI_MODE_3,
238 #endif
240 #if defined(CONFIG_PBX)
242 .modalias = "fxs-spi",
243 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
244 .bus_num = 0,
245 .chip_select = 8 - CONFIG_J11_JUMPER,
246 .controller_data = &spi_si3xxx_chip_info,
247 .mode = SPI_MODE_3,
250 .modalias = "fxo-spi",
251 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
252 .bus_num = 0,
253 .chip_select = 8 - CONFIG_J19_JUMPER,
254 .controller_data = &spi_si3xxx_chip_info,
255 .mode = SPI_MODE_3,
257 #endif
259 #if defined(CONFIG_AD5304) || defined(CONFIG_AD5304_MODULE)
261 .modalias = "ad5304_spi",
262 .max_speed_hz = 1000000, /* max spi clock (SCK) speed in HZ */
263 .bus_num = 0,
264 .chip_select = 2,
265 .platform_data = NULL,
266 .controller_data = &ad5304_chip_info,
267 .mode = SPI_MODE_2,
269 #endif
272 /* SPI (0) */
273 static struct resource bfin_spi0_resource[] = {
274 [0] = {
275 .start = SPI0_REGBASE,
276 .end = SPI0_REGBASE + 0xFF,
277 .flags = IORESOURCE_MEM,
279 [1] = {
280 .start = CH_SPI,
281 .end = CH_SPI,
282 .flags = IORESOURCE_IRQ,
286 /* SPI controller data */
287 static struct bfin5xx_spi_master bfin_spi0_info = {
288 .num_chipselect = 8,
289 .enable_dma = 1, /* master has the ability to do dma transfer */
290 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
293 static struct platform_device bfin_spi0_device = {
294 .name = "bfin-spi",
295 .id = 0, /* Bus number */
296 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
297 .resource = bfin_spi0_resource,
298 .dev = {
299 .platform_data = &bfin_spi0_info, /* Passed to driver */
302 #endif /* spi master and devices */
304 #if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
305 static struct platform_device bfin_fb_device = {
306 .name = "bf537-fb",
308 #endif
310 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
311 static struct resource bfin_uart_resources[] = {
313 .start = 0xFFC00400,
314 .end = 0xFFC004FF,
315 .flags = IORESOURCE_MEM,
319 static struct platform_device bfin_uart_device = {
320 .name = "bfin-uart",
321 .id = 1,
322 .num_resources = ARRAY_SIZE(bfin_uart_resources),
323 .resource = bfin_uart_resources,
325 #endif
327 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
328 static struct platform_device bfin_sport0_uart_device = {
329 .name = "bfin-sport-uart",
330 .id = 0,
333 static struct platform_device bfin_sport1_uart_device = {
334 .name = "bfin-sport-uart",
335 .id = 1,
337 #endif
339 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
340 #define PATA_INT 55
342 static struct pata_platform_info bfin_pata_platform_data = {
343 .ioport_shift = 1,
344 .irq_type = IRQF_TRIGGER_HIGH | IRQF_DISABLED,
347 static struct resource bfin_pata_resources[] = {
349 .start = 0x20314020,
350 .end = 0x2031403F,
351 .flags = IORESOURCE_MEM,
354 .start = 0x2031401C,
355 .end = 0x2031401F,
356 .flags = IORESOURCE_MEM,
359 .start = PATA_INT,
360 .end = PATA_INT,
361 .flags = IORESOURCE_IRQ,
365 static struct platform_device bfin_pata_device = {
366 .name = "pata_platform",
367 .id = -1,
368 .num_resources = ARRAY_SIZE(bfin_pata_resources),
369 .resource = bfin_pata_resources,
370 .dev = {
371 .platform_data = &bfin_pata_platform_data,
374 #endif
376 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
377 #include <linux/input.h>
378 #include <linux/gpio_keys.h>
380 static struct gpio_keys_button bfin_gpio_keys_table[] = {
381 {BTN_0, GPIO_PF5, 1, "gpio-keys: BTN0"},
382 {BTN_1, GPIO_PF6, 1, "gpio-keys: BTN1"},
383 {BTN_2, GPIO_PF8, 1, "gpio-keys: BTN2"},
386 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
387 .buttons = bfin_gpio_keys_table,
388 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
391 static struct platform_device bfin_device_gpiokeys = {
392 .name = "gpio-keys",
393 .dev = {
394 .platform_data = &bfin_gpio_keys_data,
397 #endif
399 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
400 #include <linux/i2c-gpio.h>
402 static struct i2c_gpio_platform_data i2c_gpio_data = {
403 .sda_pin = 2,
404 .scl_pin = 3,
405 .sda_is_open_drain = 0,
406 .scl_is_open_drain = 0,
407 .udelay = 40,
410 static struct platform_device i2c_gpio_device = {
411 .name = "i2c-gpio",
412 .id = 0,
413 .dev = {
414 .platform_data = &i2c_gpio_data,
417 #endif
419 static struct platform_device *stamp_devices[] __initdata = {
420 #if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
421 &rtc_device,
422 #endif
424 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
425 &smc91x_device,
426 #endif
428 #if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
429 &bfin_fb_adv7393_device,
430 #endif
432 #if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
433 &net2272_bfin_device,
434 #endif
436 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
437 &bfin_spi0_device,
438 #endif
440 #if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
441 &bfin_uart_device,
442 #endif
444 #if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
445 &bfin_sport0_uart_device,
446 &bfin_sport1_uart_device,
447 #endif
449 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
450 &bfin_pata_device,
451 #endif
453 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
454 &bfin_device_gpiokeys,
455 #endif
457 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
458 &i2c_gpio_device,
459 #endif
462 static int __init stamp_init(void)
464 int ret;
466 printk(KERN_INFO "%s(): registering device resources\n", __FUNCTION__);
467 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
468 if (ret < 0)
469 return ret;
471 #if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
472 # if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
473 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
474 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (1 << CONFIG_ENET_FLASH_PIN));
475 bfin_write_FIO_FLAG_S(1 << CONFIG_ENET_FLASH_PIN);
476 SSYNC();
477 # endif
478 #endif
480 #if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
481 spi_register_board_info(bfin_spi_board_info,
482 ARRAY_SIZE(bfin_spi_board_info));
483 #endif
484 #if defined(CONFIG_PATA_PLATFORM) || defined(CONFIG_PATA_PLATFORM_MODULE)
485 irq_desc[PATA_INT].status |= IRQ_NOAUTOEN;
486 #endif
487 return 0;
490 arch_initcall(stamp_init);
492 void native_machine_restart(char *cmd)
494 #if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
495 # define BIT_TO_SET (1 << CONFIG_ENET_FLASH_PIN)
496 bfin_write_FIO_INEN(~BIT_TO_SET);
497 bfin_write_FIO_DIR(BIT_TO_SET);
498 bfin_write_FIO_FLAG_C(BIT_TO_SET);
499 #endif