Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / blackfin / mach-bf533 / boards / stamp.c
CommitLineData
1394f032
BW
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>
5 *
6 * Created: 2005
7 * Description: Board Info File for the BF533-STAMP
8 *
9 * Modified:
10 * Copyright 2005 National ICT Australia (NICTA)
11 * Copyright 2004-2006 Analog Devices Inc.
12 *
13 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 *
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.
19 *
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.
24 *
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
29 */
30
31#include <linux/device.h>
32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h>
de8c43f2 35#include <linux/mtd/physmap.h>
1394f032
BW
36#include <linux/spi/spi.h>
37#include <linux/spi/flash.h>
38#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
f02bcec5 39#include <linux/usb/isp1362.h>
1394f032 40#endif
1f83b8f1 41#include <linux/irq.h>
81d9c7f2 42#include <linux/i2c.h>
c6c4d7bb 43#include <asm/dma.h>
1394f032 44#include <asm/bfin5xx_spi.h>
c6c4d7bb 45#include <asm/reboot.h>
5d448dd5 46#include <asm/portmux.h>
14b03204 47#include <asm/dpmc.h>
1394f032
BW
48
49/*
50 * Name the Board for the /proc/cpuinfo
51 */
fe85cad2 52const char bfin_board_name[] = "ADI BF533-STAMP";
1394f032
BW
53
54#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
55static struct platform_device rtc_device = {
56 .name = "rtc-bfin",
57 .id = -1,
58};
59#endif
60
61/*
62 * Driver needs to know address, irq and flag pin.
63 */
64#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
65static struct resource smc91x_resources[] = {
66 {
67 .name = "smc91x-regs",
68 .start = 0x20300300,
69 .end = 0x20300300 + 16,
70 .flags = IORESOURCE_MEM,
1f83b8f1 71 }, {
1394f032
BW
72 .start = IRQ_PF7,
73 .end = IRQ_PF7,
74 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
75 },
76};
77
78static struct platform_device smc91x_device = {
79 .name = "smc91x",
80 .id = 0,
81 .num_resources = ARRAY_SIZE(smc91x_resources),
82 .resource = smc91x_resources,
83};
84#endif
85
c6c4d7bb
BW
86#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
87static struct platform_device bfin_fb_adv7393_device = {
88 .name = "bfin-adv7393",
89};
90#endif
91
1394f032
BW
92#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
93static struct resource net2272_bfin_resources[] = {
94 {
95 .start = 0x20300000,
96 .end = 0x20300000 + 0x100,
97 .flags = IORESOURCE_MEM,
1f83b8f1 98 }, {
1394f032
BW
99 .start = IRQ_PF10,
100 .end = IRQ_PF10,
101 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
102 },
103};
104
105static struct platform_device net2272_bfin_device = {
106 .name = "net2272",
107 .id = -1,
108 .num_resources = ARRAY_SIZE(net2272_bfin_resources),
109 .resource = net2272_bfin_resources,
110};
111#endif
112
9cd9c616 113#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
de8c43f2
MF
114static struct mtd_partition stamp_partitions[] = {
115 {
aa582977 116 .name = "bootloader(nor)",
edf05641 117 .size = 0x40000,
de8c43f2
MF
118 .offset = 0,
119 }, {
aa582977 120 .name = "linux kernel(nor)",
6ecb5b6d 121 .size = 0x180000,
de8c43f2
MF
122 .offset = MTDPART_OFS_APPEND,
123 }, {
aa582977 124 .name = "file system(nor)",
de8c43f2
MF
125 .size = MTDPART_SIZ_FULL,
126 .offset = MTDPART_OFS_APPEND,
127 }
128};
129
130static struct physmap_flash_data stamp_flash_data = {
131 .width = 2,
132 .parts = stamp_partitions,
133 .nr_parts = ARRAY_SIZE(stamp_partitions),
134};
135
136static struct resource stamp_flash_resource[] = {
137 {
138 .name = "cfi_probe",
139 .start = 0x20000000,
140 .end = 0x203fffff,
141 .flags = IORESOURCE_MEM,
142 }, {
9cd9c616
MF
143 .start = 0x7BB07BB0, /* AMBCTL0 setting when accessing flash */
144 .end = 0x7BB07BB0, /* AMBCTL1 setting when accessing flash */
145 .flags = IORESOURCE_MEM,
146 }, {
147 .start = GPIO_PF0,
de8c43f2
MF
148 .flags = IORESOURCE_IRQ,
149 }
150};
151
152static struct platform_device stamp_flash_device = {
9cd9c616 153 .name = "bfin-async-flash",
de8c43f2
MF
154 .id = 0,
155 .dev = {
156 .platform_data = &stamp_flash_data,
157 },
158 .num_resources = ARRAY_SIZE(stamp_flash_resource),
159 .resource = stamp_flash_resource,
160};
793dc27b 161#endif
de8c43f2 162
1394f032
BW
163#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
164static struct mtd_partition bfin_spi_flash_partitions[] = {
165 {
aa582977 166 .name = "bootloader(spi)",
edf05641 167 .size = 0x00040000,
1394f032
BW
168 .offset = 0,
169 .mask_flags = MTD_CAP_ROM
1f83b8f1 170 }, {
aa582977 171 .name = "linux kernel(spi)",
6ecb5b6d 172 .size = 0x180000,
edf05641 173 .offset = MTDPART_OFS_APPEND,
1f83b8f1 174 }, {
aa582977 175 .name = "file system(spi)",
edf05641
MF
176 .size = MTDPART_SIZ_FULL,
177 .offset = MTDPART_OFS_APPEND,
1394f032
BW
178 }
179};
180
181static struct flash_platform_data bfin_spi_flash_data = {
182 .name = "m25p80",
183 .parts = bfin_spi_flash_partitions,
184 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
185 .type = "m25p64",
186};
187
188/* SPI flash chip (m25p64) */
189static struct bfin5xx_spi_chip spi_flash_chip_info = {
190 .enable_dma = 0, /* use dma transfer with this chip*/
191 .bits_per_word = 8,
192};
193#endif
194
195#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
196/* SPI ADC chip */
197static struct bfin5xx_spi_chip spi_adc_chip_info = {
198 .enable_dma = 1, /* use dma transfer with this chip*/
199 .bits_per_word = 16,
200};
201#endif
202
203#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
204static struct bfin5xx_spi_chip ad1836_spi_chip_info = {
205 .enable_dma = 0,
206 .bits_per_word = 16,
207};
208#endif
209
210#if defined(CONFIG_PBX)
211static struct bfin5xx_spi_chip spi_si3xxx_chip_info = {
212 .ctl_reg = 0x4, /* send zero */
213 .enable_dma = 0,
214 .bits_per_word = 8,
215 .cs_change_per_word = 1,
216};
217#endif
218
6e668936
MH
219#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
220static struct bfin5xx_spi_chip spidev_chip_info = {
221 .enable_dma = 0,
222 .bits_per_word = 8,
223};
224#endif
225
1394f032
BW
226static struct spi_board_info bfin_spi_board_info[] __initdata = {
227#if defined(CONFIG_MTD_M25P80) || defined(CONFIG_MTD_M25P80_MODULE)
228 {
229 /* the modalias must be the same as spi device driver name */
230 .modalias = "m25p80", /* Name of spi_driver for this device */
231 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 232 .bus_num = 0, /* Framework bus number */
1394f032
BW
233 .chip_select = 2, /* Framework chip select. On STAMP537 it is SPISSEL2*/
234 .platform_data = &bfin_spi_flash_data,
235 .controller_data = &spi_flash_chip_info,
236 .mode = SPI_MODE_3,
237 },
238#endif
239
240#if defined(CONFIG_SPI_ADC_BF533) || defined(CONFIG_SPI_ADC_BF533_MODULE)
241 {
242 .modalias = "bfin_spi_adc", /* Name of spi_driver for this device */
243 .max_speed_hz = 6250000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 244 .bus_num = 0, /* Framework bus number */
1394f032
BW
245 .chip_select = 1, /* Framework chip select. */
246 .platform_data = NULL, /* No spi_driver specific config */
247 .controller_data = &spi_adc_chip_info,
248 },
249#endif
250
251#if defined(CONFIG_SND_BLACKFIN_AD1836) || defined(CONFIG_SND_BLACKFIN_AD1836_MODULE)
252 {
253 .modalias = "ad1836-spi",
254 .max_speed_hz = 31250000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb 255 .bus_num = 0,
1394f032
BW
256 .chip_select = CONFIG_SND_BLACKFIN_SPI_PFBIT,
257 .controller_data = &ad1836_spi_chip_info,
258 },
259#endif
260
261#if defined(CONFIG_PBX)
262 {
1f83b8f1
MF
263 .modalias = "fxs-spi",
264 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb
BW
265 .bus_num = 0,
266 .chip_select = 8 - CONFIG_J11_JUMPER,
1f83b8f1 267 .controller_data = &spi_si3xxx_chip_info,
1394f032
BW
268 .mode = SPI_MODE_3,
269 },
270 {
1f83b8f1
MF
271 .modalias = "fxo-spi",
272 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
c6c4d7bb
BW
273 .bus_num = 0,
274 .chip_select = 8 - CONFIG_J19_JUMPER,
1f83b8f1 275 .controller_data = &spi_si3xxx_chip_info,
1394f032
BW
276 .mode = SPI_MODE_3,
277 },
278#endif
279
6e668936
MH
280#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)
281 {
282 .modalias = "spidev",
283 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
284 .bus_num = 0,
285 .chip_select = 1,
286 .controller_data = &spidev_chip_info,
287 },
288#endif
1394f032
BW
289};
290
5bda2723 291#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
c6c4d7bb
BW
292/* SPI (0) */
293static struct resource bfin_spi0_resource[] = {
294 [0] = {
295 .start = SPI0_REGBASE,
296 .end = SPI0_REGBASE + 0xFF,
297 .flags = IORESOURCE_MEM,
298 },
299 [1] = {
300 .start = CH_SPI,
301 .end = CH_SPI,
302 .flags = IORESOURCE_IRQ,
303 }
304};
305
1394f032 306/* SPI controller data */
c6c4d7bb 307static struct bfin5xx_spi_master bfin_spi0_info = {
1394f032
BW
308 .num_chipselect = 8,
309 .enable_dma = 1, /* master has the ability to do dma transfer */
5d448dd5 310 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
1394f032
BW
311};
312
c6c4d7bb
BW
313static struct platform_device bfin_spi0_device = {
314 .name = "bfin-spi",
315 .id = 0, /* Bus number */
316 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
317 .resource = bfin_spi0_resource,
1394f032 318 .dev = {
c6c4d7bb 319 .platform_data = &bfin_spi0_info, /* Passed to driver */
1394f032
BW
320 },
321};
322#endif /* spi master and devices */
323
324#if defined(CONFIG_FB_BF537_LQ035) || defined(CONFIG_FB_BF537_LQ035_MODULE)
325static struct platform_device bfin_fb_device = {
326 .name = "bf537-fb",
327};
328#endif
329
330#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
331static struct resource bfin_uart_resources[] = {
332 {
333 .start = 0xFFC00400,
334 .end = 0xFFC004FF,
335 .flags = IORESOURCE_MEM,
336 },
337};
338
339static struct platform_device bfin_uart_device = {
340 .name = "bfin-uart",
341 .id = 1,
342 .num_resources = ARRAY_SIZE(bfin_uart_resources),
343 .resource = bfin_uart_resources,
344};
345#endif
346
5be36d22 347#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
5be36d22 348#ifdef CONFIG_BFIN_SIR0
42bd8bcb 349static struct resource bfin_sir0_resources[] = {
5be36d22
GY
350 {
351 .start = 0xFFC00400,
352 .end = 0xFFC004FF,
353 .flags = IORESOURCE_MEM,
354 },
42bd8bcb
GY
355 {
356 .start = IRQ_UART0_RX,
357 .end = IRQ_UART0_RX+1,
358 .flags = IORESOURCE_IRQ,
359 },
360 {
361 .start = CH_UART0_RX,
362 .end = CH_UART0_RX+1,
363 .flags = IORESOURCE_DMA,
364 },
5be36d22
GY
365};
366
42bd8bcb 367static struct platform_device bfin_sir0_device = {
5be36d22
GY
368 .name = "bfin_sir",
369 .id = 0,
42bd8bcb
GY
370 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
371 .resource = bfin_sir0_resources,
5be36d22
GY
372};
373#endif
42bd8bcb 374#endif
5be36d22 375
1394f032
BW
376#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
377static struct platform_device bfin_sport0_uart_device = {
378 .name = "bfin-sport-uart",
379 .id = 0,
380};
381
382static struct platform_device bfin_sport1_uart_device = {
383 .name = "bfin-sport-uart",
384 .id = 1,
385};
386#endif
387
2463ef22
MH
388#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
389#include <linux/input.h>
390#include <linux/gpio_keys.h>
391
392static struct gpio_keys_button bfin_gpio_keys_table[] = {
f1bceb47
MH
393 {BTN_0, GPIO_PF5, 0, "gpio-keys: BTN0"},
394 {BTN_1, GPIO_PF6, 0, "gpio-keys: BTN1"},
395 {BTN_2, GPIO_PF8, 0, "gpio-keys: BTN2"},
2463ef22
MH
396};
397
398static struct gpio_keys_platform_data bfin_gpio_keys_data = {
399 .buttons = bfin_gpio_keys_table,
400 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
401};
402
403static struct platform_device bfin_device_gpiokeys = {
404 .name = "gpio-keys",
405 .dev = {
406 .platform_data = &bfin_gpio_keys_data,
407 },
408};
409#endif
410
cad2ab65
MF
411static struct resource bfin_gpios_resources = {
412 .start = 0,
413 .end = MAX_BLACKFIN_GPIOS - 1,
414 .flags = IORESOURCE_IRQ,
415};
416
417static struct platform_device bfin_gpios_device = {
418 .name = "simple-gpio",
419 .id = -1,
420 .num_resources = 1,
421 .resource = &bfin_gpios_resources,
422};
423
e3163954
BW
424#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
425#include <linux/i2c-gpio.h>
426
427static struct i2c_gpio_platform_data i2c_gpio_data = {
428 .sda_pin = 2,
429 .scl_pin = 3,
430 .sda_is_open_drain = 0,
431 .scl_is_open_drain = 0,
432 .udelay = 40,
433};
434
435static struct platform_device i2c_gpio_device = {
436 .name = "i2c-gpio",
437 .id = 0,
438 .dev = {
439 .platform_data = &i2c_gpio_data,
440 },
441};
442#endif
443
81d9c7f2
BW
444static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
445#if defined(CONFIG_JOYSTICK_AD7142) || defined(CONFIG_JOYSTICK_AD7142_MODULE)
446 {
447 I2C_BOARD_INFO("ad7142_joystick", 0x2C),
81d9c7f2
BW
448 .irq = 39,
449 },
450#endif
451#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
452 {
453 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
81d9c7f2
BW
454 },
455#endif
456#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
457 {
458 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
81d9c7f2
BW
459 .irq = 39,
460 },
461#endif
462};
81d9c7f2 463
14b03204
MH
464static const unsigned int cclk_vlev_datasheet[] =
465{
466 VRPAIR(VLEV_085, 250000000),
467 VRPAIR(VLEV_090, 376000000),
468 VRPAIR(VLEV_095, 426000000),
469 VRPAIR(VLEV_100, 426000000),
470 VRPAIR(VLEV_105, 476000000),
471 VRPAIR(VLEV_110, 476000000),
472 VRPAIR(VLEV_115, 476000000),
473 VRPAIR(VLEV_120, 600000000),
474 VRPAIR(VLEV_125, 600000000),
475 VRPAIR(VLEV_130, 600000000),
476};
477
478static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
479 .tuple_tab = cclk_vlev_datasheet,
480 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
481 .vr_settling_time = 25 /* us */,
482};
483
484static struct platform_device bfin_dpmc = {
485 .name = "bfin dpmc",
486 .dev = {
487 .platform_data = &bfin_dmpc_vreg_data,
488 },
489};
490
1394f032 491static struct platform_device *stamp_devices[] __initdata = {
14b03204
MH
492
493 &bfin_dpmc,
494
1394f032
BW
495#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
496 &rtc_device,
497#endif
498
499#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
500 &smc91x_device,
501#endif
502
c6c4d7bb
BW
503#if defined(CONFIG_FB_BFIN_7393) || defined(CONFIG_FB_BFIN_7393_MODULE)
504 &bfin_fb_adv7393_device,
505#endif
506
1394f032
BW
507#if defined(CONFIG_USB_NET2272) || defined(CONFIG_USB_NET2272_MODULE)
508 &net2272_bfin_device,
509#endif
510
511#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
c6c4d7bb 512 &bfin_spi0_device,
1394f032
BW
513#endif
514
515#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
516 &bfin_uart_device,
517#endif
518
5be36d22 519#if defined(CONFIG_BFIN_SIR) || defined(CONFIG_BFIN_SIR_MODULE)
42bd8bcb
GY
520#ifdef CONFIG_BFIN_SIR0
521 &bfin_sir0_device,
522#endif
5be36d22
GY
523#endif
524
1394f032
BW
525#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
526 &bfin_sport0_uart_device,
527 &bfin_sport1_uart_device,
528#endif
c6c4d7bb 529
2463ef22
MH
530#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
531 &bfin_device_gpiokeys,
532#endif
e3163954
BW
533
534#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
535 &i2c_gpio_device,
536#endif
cad2ab65
MF
537
538 &bfin_gpios_device,
793dc27b 539
9cd9c616 540#if defined(CONFIG_MTD_BFIN_ASYNC) || defined(CONFIG_MTD_BFIN_ASYNC_MODULE)
de8c43f2 541 &stamp_flash_device,
793dc27b 542#endif
1394f032
BW
543};
544
545static int __init stamp_init(void)
546{
c0fc525d
MF
547 int ret;
548
b85d858b 549 printk(KERN_INFO "%s(): registering device resources\n", __func__);
81d9c7f2 550
81d9c7f2
BW
551 i2c_register_board_info(0, bfin_i2c_board_info,
552 ARRAY_SIZE(bfin_i2c_board_info));
81d9c7f2 553
c0fc525d
MF
554 ret = platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
555 if (ret < 0)
556 return ret;
557
558#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
c0fc525d 559 /* setup BF533_STAMP CPLD to route AMS3 to Ethernet MAC */
9cd9c616
MF
560 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF0);
561 bfin_write_FIO_FLAG_S(PF0);
c0fc525d 562 SSYNC();
c0fc525d
MF
563#endif
564
5bda2723 565 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
c6c4d7bb 566 return 0;
1394f032
BW
567}
568
569arch_initcall(stamp_init);
c6c4d7bb
BW
570
571void native_machine_restart(char *cmd)
572{
9cd9c616
MF
573 /* workaround pull up on cpld / flash pin not being strong enough */
574 bfin_write_FIO_INEN(~PF0);
575 bfin_write_FIO_DIR(PF0);
576 bfin_write_FIO_FLAG_C(PF0);
c6c4d7bb 577}