xtensa: fix high memory/reserved memory collision
[cris-mirror.git] / arch / blackfin / mach-bf518 / boards / tcm-bf518.c
blob37d868085f6a2e92c226a6661d82612dbf218fcd
1 /*
2 * Copyright 2004-2009 Analog Devices Inc.
3 * 2005 National ICT Australia (NICTA)
4 * Aidan Williams <aidan@nicta.com.au>
6 * Licensed under the GPL-2 or later.
7 */
9 #include <linux/device.h>
10 #include <linux/etherdevice.h>
11 #include <linux/platform_device.h>
12 #include <linux/mtd/mtd.h>
13 #include <linux/mtd/partitions.h>
14 #include <linux/mtd/physmap.h>
15 #include <linux/spi/spi.h>
16 #include <linux/spi/flash.h>
18 #include <linux/i2c.h>
19 #include <linux/irq.h>
20 #include <linux/interrupt.h>
21 #include <asm/dma.h>
22 #include <asm/bfin5xx_spi.h>
23 #include <asm/reboot.h>
24 #include <asm/portmux.h>
25 #include <asm/dpmc.h>
26 #include <asm/bfin_sdh.h>
27 #include <linux/spi/ad7877.h>
30 * Name the Board for the /proc/cpuinfo
32 const char bfin_board_name[] = "Bluetechnix TCM-BF518";
35 * Driver needs to know address, irq and flag pin.
38 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
39 static struct mtd_partition tcm_partitions[] = {
41 .name = "bootloader(nor)",
42 .size = 0x40000,
43 .offset = 0,
46 .name = "linux(nor)",
47 .size = 0x1C0000,
48 .offset = MTDPART_OFS_APPEND,
52 static struct physmap_flash_data tcm_flash_data = {
53 .width = 2,
54 .parts = tcm_partitions,
55 .nr_parts = ARRAY_SIZE(tcm_partitions),
58 static struct resource tcm_flash_resource = {
59 .start = 0x20000000,
60 .end = 0x201fffff,
61 .flags = IORESOURCE_MEM,
64 static struct platform_device tcm_flash_device = {
65 .name = "physmap-flash",
66 .id = 0,
67 .dev = {
68 .platform_data = &tcm_flash_data,
70 .num_resources = 1,
71 .resource = &tcm_flash_resource,
73 #endif
75 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
76 static struct platform_device rtc_device = {
77 .name = "rtc-bfin",
78 .id = -1,
80 #endif
82 #if IS_ENABLED(CONFIG_BFIN_MAC)
83 #include <linux/bfin_mac.h>
84 static const unsigned short bfin_mac_peripherals[] = P_MII0;
86 static struct bfin_phydev_platform_data bfin_phydev_data[] = {
88 .addr = 1,
89 .irq = IRQ_MAC_PHYINT,
93 static struct bfin_mii_bus_platform_data bfin_mii_bus_data = {
94 .phydev_number = 1,
95 .phydev_data = bfin_phydev_data,
96 .phy_mode = PHY_INTERFACE_MODE_MII,
97 .mac_peripherals = bfin_mac_peripherals,
100 static struct platform_device bfin_mii_bus = {
101 .name = "bfin_mii_bus",
102 .dev = {
103 .platform_data = &bfin_mii_bus_data,
107 static struct platform_device bfin_mac_device = {
108 .name = "bfin_mac",
109 .dev = {
110 .platform_data = &bfin_mii_bus,
113 #endif
115 #if IS_ENABLED(CONFIG_MTD_M25P80)
116 static struct mtd_partition bfin_spi_flash_partitions[] = {
118 .name = "bootloader(spi)",
119 .size = 0x00040000,
120 .offset = 0,
121 .mask_flags = MTD_CAP_ROM
122 }, {
123 .name = "linux kernel(spi)",
124 .size = MTDPART_SIZ_FULL,
125 .offset = MTDPART_OFS_APPEND,
129 static struct flash_platform_data bfin_spi_flash_data = {
130 .name = "m25p80",
131 .parts = bfin_spi_flash_partitions,
132 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
133 .type = "m25p16",
136 /* SPI flash chip (m25p64) */
137 static struct bfin5xx_spi_chip spi_flash_chip_info = {
138 .enable_dma = 0, /* use dma transfer with this chip*/
140 #endif
142 #if IS_ENABLED(CONFIG_MMC_SPI)
143 static struct bfin5xx_spi_chip mmc_spi_chip_info = {
144 .enable_dma = 0,
146 #endif
148 #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
149 static const struct ad7877_platform_data bfin_ad7877_ts_info = {
150 .model = 7877,
151 .vref_delay_usecs = 50, /* internal, no capacitor */
152 .x_plate_ohms = 419,
153 .y_plate_ohms = 486,
154 .pressure_max = 1000,
155 .pressure_min = 0,
156 .stopacq_polarity = 1,
157 .first_conversion_delay = 3,
158 .acquisition_time = 1,
159 .averaging = 1,
160 .pen_down_acc_interval = 1,
162 #endif
164 static struct spi_board_info bfin_spi_board_info[] __initdata = {
165 #if IS_ENABLED(CONFIG_MTD_M25P80)
167 /* the modalias must be the same as spi device driver name */
168 .modalias = "m25p80", /* Name of spi_driver for this device */
169 .max_speed_hz = 25000000, /* max spi clock (SCK) speed in HZ */
170 .bus_num = 0, /* Framework bus number */
171 .chip_select = 2, /* SPI0_SSEL2 */
172 .platform_data = &bfin_spi_flash_data,
173 .controller_data = &spi_flash_chip_info,
174 .mode = SPI_MODE_3,
176 #endif
178 #if IS_ENABLED(CONFIG_MMC_SPI)
180 .modalias = "mmc_spi",
181 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
182 .bus_num = 0,
183 .chip_select = 5,
184 .controller_data = &mmc_spi_chip_info,
185 .mode = SPI_MODE_3,
187 #endif
188 #if IS_ENABLED(CONFIG_TOUCHSCREEN_AD7877)
190 .modalias = "ad7877",
191 .platform_data = &bfin_ad7877_ts_info,
192 .irq = IRQ_PF8,
193 .max_speed_hz = 12500000, /* max spi clock (SCK) speed in HZ */
194 .bus_num = 0,
195 .chip_select = 2,
197 #endif
198 #if IS_ENABLED(CONFIG_SND_SOC_WM8731) \
199 && defined(CONFIG_SND_SOC_WM8731_SPI)
201 .modalias = "wm8731",
202 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
203 .bus_num = 0,
204 .chip_select = 5,
205 .mode = SPI_MODE_0,
207 #endif
208 #if IS_ENABLED(CONFIG_SPI_SPIDEV)
210 .modalias = "spidev",
211 .max_speed_hz = 3125000, /* max spi clock (SCK) speed in HZ */
212 .bus_num = 0,
213 .chip_select = 1,
215 #endif
216 #if IS_ENABLED(CONFIG_FB_BFIN_LQ035Q1)
218 .modalias = "bfin-lq035q1-spi",
219 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
220 .bus_num = 0,
221 .chip_select = 1,
222 .mode = SPI_CPHA | SPI_CPOL,
224 #endif
227 /* SPI controller data */
228 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
229 /* SPI (0) */
230 static struct bfin5xx_spi_master bfin_spi0_info = {
231 .num_chipselect = 6,
232 .enable_dma = 1, /* master has the ability to do dma transfer */
233 .pin_req = {P_SPI0_SCK, P_SPI0_MISO, P_SPI0_MOSI, 0},
236 static struct resource bfin_spi0_resource[] = {
237 [0] = {
238 .start = SPI0_REGBASE,
239 .end = SPI0_REGBASE + 0xFF,
240 .flags = IORESOURCE_MEM,
242 [1] = {
243 .start = CH_SPI0,
244 .end = CH_SPI0,
245 .flags = IORESOURCE_DMA,
247 [2] = {
248 .start = IRQ_SPI0,
249 .end = IRQ_SPI0,
250 .flags = IORESOURCE_IRQ,
254 static struct platform_device bfin_spi0_device = {
255 .name = "bfin-spi",
256 .id = 0, /* Bus number */
257 .num_resources = ARRAY_SIZE(bfin_spi0_resource),
258 .resource = bfin_spi0_resource,
259 .dev = {
260 .platform_data = &bfin_spi0_info, /* Passed to driver */
264 /* SPI (1) */
265 static struct bfin5xx_spi_master bfin_spi1_info = {
266 .num_chipselect = 6,
267 .enable_dma = 1, /* master has the ability to do dma transfer */
268 .pin_req = {P_SPI1_SCK, P_SPI1_MISO, P_SPI1_MOSI, 0},
271 static struct resource bfin_spi1_resource[] = {
272 [0] = {
273 .start = SPI1_REGBASE,
274 .end = SPI1_REGBASE + 0xFF,
275 .flags = IORESOURCE_MEM,
277 [1] = {
278 .start = CH_SPI1,
279 .end = CH_SPI1,
280 .flags = IORESOURCE_DMA,
282 [2] = {
283 .start = IRQ_SPI1,
284 .end = IRQ_SPI1,
285 .flags = IORESOURCE_IRQ,
289 static struct platform_device bfin_spi1_device = {
290 .name = "bfin-spi",
291 .id = 1, /* Bus number */
292 .num_resources = ARRAY_SIZE(bfin_spi1_resource),
293 .resource = bfin_spi1_resource,
294 .dev = {
295 .platform_data = &bfin_spi1_info, /* Passed to driver */
298 #endif /* spi master and devices */
300 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
301 #ifdef CONFIG_SERIAL_BFIN_UART0
302 static struct resource bfin_uart0_resources[] = {
304 .start = UART0_THR,
305 .end = UART0_GCTL+2,
306 .flags = IORESOURCE_MEM,
309 .start = IRQ_UART0_TX,
310 .end = IRQ_UART0_TX,
311 .flags = IORESOURCE_IRQ,
314 .start = IRQ_UART0_RX,
315 .end = IRQ_UART0_RX,
316 .flags = IORESOURCE_IRQ,
319 .start = IRQ_UART0_ERROR,
320 .end = IRQ_UART0_ERROR,
321 .flags = IORESOURCE_IRQ,
324 .start = CH_UART0_TX,
325 .end = CH_UART0_TX,
326 .flags = IORESOURCE_DMA,
329 .start = CH_UART0_RX,
330 .end = CH_UART0_RX,
331 .flags = IORESOURCE_DMA,
335 static unsigned short bfin_uart0_peripherals[] = {
336 P_UART0_TX, P_UART0_RX, 0
339 static struct platform_device bfin_uart0_device = {
340 .name = "bfin-uart",
341 .id = 0,
342 .num_resources = ARRAY_SIZE(bfin_uart0_resources),
343 .resource = bfin_uart0_resources,
344 .dev = {
345 .platform_data = &bfin_uart0_peripherals, /* Passed to driver */
348 #endif
349 #ifdef CONFIG_SERIAL_BFIN_UART1
350 static struct resource bfin_uart1_resources[] = {
352 .start = UART1_THR,
353 .end = UART1_GCTL+2,
354 .flags = IORESOURCE_MEM,
357 .start = IRQ_UART1_TX,
358 .end = IRQ_UART1_TX,
359 .flags = IORESOURCE_IRQ,
362 .start = IRQ_UART1_RX,
363 .end = IRQ_UART1_RX,
364 .flags = IORESOURCE_IRQ,
367 .start = IRQ_UART1_ERROR,
368 .end = IRQ_UART1_ERROR,
369 .flags = IORESOURCE_IRQ,
372 .start = CH_UART1_TX,
373 .end = CH_UART1_TX,
374 .flags = IORESOURCE_DMA,
377 .start = CH_UART1_RX,
378 .end = CH_UART1_RX,
379 .flags = IORESOURCE_DMA,
383 static unsigned short bfin_uart1_peripherals[] = {
384 P_UART1_TX, P_UART1_RX, 0
387 static struct platform_device bfin_uart1_device = {
388 .name = "bfin-uart",
389 .id = 1,
390 .num_resources = ARRAY_SIZE(bfin_uart1_resources),
391 .resource = bfin_uart1_resources,
392 .dev = {
393 .platform_data = &bfin_uart1_peripherals, /* Passed to driver */
396 #endif
397 #endif
399 #if IS_ENABLED(CONFIG_BFIN_SIR)
400 #ifdef CONFIG_BFIN_SIR0
401 static struct resource bfin_sir0_resources[] = {
403 .start = 0xFFC00400,
404 .end = 0xFFC004FF,
405 .flags = IORESOURCE_MEM,
408 .start = IRQ_UART0_RX,
409 .end = IRQ_UART0_RX+1,
410 .flags = IORESOURCE_IRQ,
413 .start = CH_UART0_RX,
414 .end = CH_UART0_RX+1,
415 .flags = IORESOURCE_DMA,
419 static struct platform_device bfin_sir0_device = {
420 .name = "bfin_sir",
421 .id = 0,
422 .num_resources = ARRAY_SIZE(bfin_sir0_resources),
423 .resource = bfin_sir0_resources,
425 #endif
426 #ifdef CONFIG_BFIN_SIR1
427 static struct resource bfin_sir1_resources[] = {
429 .start = 0xFFC02000,
430 .end = 0xFFC020FF,
431 .flags = IORESOURCE_MEM,
434 .start = IRQ_UART1_RX,
435 .end = IRQ_UART1_RX+1,
436 .flags = IORESOURCE_IRQ,
439 .start = CH_UART1_RX,
440 .end = CH_UART1_RX+1,
441 .flags = IORESOURCE_DMA,
445 static struct platform_device bfin_sir1_device = {
446 .name = "bfin_sir",
447 .id = 1,
448 .num_resources = ARRAY_SIZE(bfin_sir1_resources),
449 .resource = bfin_sir1_resources,
451 #endif
452 #endif
454 #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
455 static const u16 bfin_twi0_pins[] = {P_TWI0_SCL, P_TWI0_SDA, 0};
457 static struct resource bfin_twi0_resource[] = {
458 [0] = {
459 .start = TWI0_REGBASE,
460 .end = TWI0_REGBASE,
461 .flags = IORESOURCE_MEM,
463 [1] = {
464 .start = IRQ_TWI,
465 .end = IRQ_TWI,
466 .flags = IORESOURCE_IRQ,
470 static struct platform_device i2c_bfin_twi_device = {
471 .name = "i2c-bfin-twi",
472 .id = 0,
473 .num_resources = ARRAY_SIZE(bfin_twi0_resource),
474 .resource = bfin_twi0_resource,
475 .dev = {
476 .platform_data = &bfin_twi0_pins,
479 #endif
481 static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
482 #if IS_ENABLED(CONFIG_BFIN_TWI_LCD)
484 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
486 #endif
487 #if IS_ENABLED(CONFIG_INPUT_PCF8574)
489 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
490 .irq = IRQ_PF8,
492 #endif
495 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
496 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
497 static struct resource bfin_sport0_uart_resources[] = {
499 .start = SPORT0_TCR1,
500 .end = SPORT0_MRCS3+4,
501 .flags = IORESOURCE_MEM,
504 .start = IRQ_SPORT0_RX,
505 .end = IRQ_SPORT0_RX+1,
506 .flags = IORESOURCE_IRQ,
509 .start = IRQ_SPORT0_ERROR,
510 .end = IRQ_SPORT0_ERROR,
511 .flags = IORESOURCE_IRQ,
515 static unsigned short bfin_sport0_peripherals[] = {
516 P_SPORT0_TFS, P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_RFS,
517 P_SPORT0_DRPRI, P_SPORT0_RSCLK, 0
520 static struct platform_device bfin_sport0_uart_device = {
521 .name = "bfin-sport-uart",
522 .id = 0,
523 .num_resources = ARRAY_SIZE(bfin_sport0_uart_resources),
524 .resource = bfin_sport0_uart_resources,
525 .dev = {
526 .platform_data = &bfin_sport0_peripherals, /* Passed to driver */
529 #endif
530 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
531 static struct resource bfin_sport1_uart_resources[] = {
533 .start = SPORT1_TCR1,
534 .end = SPORT1_MRCS3+4,
535 .flags = IORESOURCE_MEM,
538 .start = IRQ_SPORT1_RX,
539 .end = IRQ_SPORT1_RX+1,
540 .flags = IORESOURCE_IRQ,
543 .start = IRQ_SPORT1_ERROR,
544 .end = IRQ_SPORT1_ERROR,
545 .flags = IORESOURCE_IRQ,
549 static unsigned short bfin_sport1_peripherals[] = {
550 P_SPORT1_TFS, P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_RFS,
551 P_SPORT1_DRPRI, P_SPORT1_RSCLK, 0
554 static struct platform_device bfin_sport1_uart_device = {
555 .name = "bfin-sport-uart",
556 .id = 1,
557 .num_resources = ARRAY_SIZE(bfin_sport1_uart_resources),
558 .resource = bfin_sport1_uart_resources,
559 .dev = {
560 .platform_data = &bfin_sport1_peripherals, /* Passed to driver */
563 #endif
564 #endif
566 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
567 #include <linux/input.h>
568 #include <linux/gpio_keys.h>
570 static struct gpio_keys_button bfin_gpio_keys_table[] = {
571 {BTN_0, GPIO_PG0, 1, "gpio-keys: BTN0"},
572 {BTN_1, GPIO_PG13, 1, "gpio-keys: BTN1"},
575 static struct gpio_keys_platform_data bfin_gpio_keys_data = {
576 .buttons = bfin_gpio_keys_table,
577 .nbuttons = ARRAY_SIZE(bfin_gpio_keys_table),
580 static struct platform_device bfin_device_gpiokeys = {
581 .name = "gpio-keys",
582 .dev = {
583 .platform_data = &bfin_gpio_keys_data,
586 #endif
588 #if IS_ENABLED(CONFIG_SDH_BFIN)
590 static struct bfin_sd_host bfin_sdh_data = {
591 .dma_chan = CH_RSI,
592 .irq_int0 = IRQ_RSI_INT0,
593 .pin_req = {P_RSI_DATA0, P_RSI_DATA1, P_RSI_DATA2, P_RSI_DATA3, P_RSI_CMD, P_RSI_CLK, 0},
596 static struct platform_device bf51x_sdh_device = {
597 .name = "bfin-sdh",
598 .id = 0,
599 .dev = {
600 .platform_data = &bfin_sdh_data,
603 #endif
605 static const unsigned int cclk_vlev_datasheet[] =
607 VRPAIR(VLEV_100, 400000000),
608 VRPAIR(VLEV_105, 426000000),
609 VRPAIR(VLEV_110, 500000000),
610 VRPAIR(VLEV_115, 533000000),
611 VRPAIR(VLEV_120, 600000000),
614 static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
615 .tuple_tab = cclk_vlev_datasheet,
616 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
617 .vr_settling_time = 25 /* us */,
620 static struct platform_device bfin_dpmc = {
621 .name = "bfin dpmc",
622 .dev = {
623 .platform_data = &bfin_dmpc_vreg_data,
627 static struct platform_device *tcm_devices[] __initdata = {
629 &bfin_dpmc,
631 #if IS_ENABLED(CONFIG_RTC_DRV_BFIN)
632 &rtc_device,
633 #endif
635 #if IS_ENABLED(CONFIG_BFIN_MAC)
636 &bfin_mii_bus,
637 &bfin_mac_device,
638 #endif
640 #if IS_ENABLED(CONFIG_SPI_BFIN5XX)
641 &bfin_spi0_device,
642 &bfin_spi1_device,
643 #endif
645 #if IS_ENABLED(CONFIG_SERIAL_BFIN)
646 #ifdef CONFIG_SERIAL_BFIN_UART0
647 &bfin_uart0_device,
648 #endif
649 #ifdef CONFIG_SERIAL_BFIN_UART1
650 &bfin_uart1_device,
651 #endif
652 #endif
654 #if IS_ENABLED(CONFIG_BFIN_SIR)
655 #ifdef CONFIG_BFIN_SIR0
656 &bfin_sir0_device,
657 #endif
658 #ifdef CONFIG_BFIN_SIR1
659 &bfin_sir1_device,
660 #endif
661 #endif
663 #if IS_ENABLED(CONFIG_I2C_BLACKFIN_TWI)
664 &i2c_bfin_twi_device,
665 #endif
667 #if IS_ENABLED(CONFIG_SERIAL_BFIN_SPORT)
668 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
669 &bfin_sport0_uart_device,
670 #endif
671 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
672 &bfin_sport1_uart_device,
673 #endif
674 #endif
676 #if IS_ENABLED(CONFIG_KEYBOARD_GPIO)
677 &bfin_device_gpiokeys,
678 #endif
680 #if IS_ENABLED(CONFIG_SDH_BFIN)
681 &bf51x_sdh_device,
682 #endif
684 #if IS_ENABLED(CONFIG_MTD_PHYSMAP)
685 &tcm_flash_device,
686 #endif
689 static int __init tcm_init(void)
691 printk(KERN_INFO "%s(): registering device resources\n", __func__);
692 i2c_register_board_info(0, bfin_i2c_board_info,
693 ARRAY_SIZE(bfin_i2c_board_info));
694 platform_add_devices(tcm_devices, ARRAY_SIZE(tcm_devices));
695 spi_register_board_info(bfin_spi_board_info, ARRAY_SIZE(bfin_spi_board_info));
696 return 0;
699 arch_initcall(tcm_init);
701 static struct platform_device *tcm_early_devices[] __initdata = {
702 #if defined(CONFIG_SERIAL_BFIN_CONSOLE) || defined(CONFIG_EARLY_PRINTK)
703 #ifdef CONFIG_SERIAL_BFIN_UART0
704 &bfin_uart0_device,
705 #endif
706 #ifdef CONFIG_SERIAL_BFIN_UART1
707 &bfin_uart1_device,
708 #endif
709 #endif
711 #if defined(CONFIG_SERIAL_BFIN_SPORT_CONSOLE)
712 #ifdef CONFIG_SERIAL_BFIN_SPORT0_UART
713 &bfin_sport0_uart_device,
714 #endif
715 #ifdef CONFIG_SERIAL_BFIN_SPORT1_UART
716 &bfin_sport1_uart_device,
717 #endif
718 #endif
721 void __init native_machine_early_platform_add_devices(void)
723 printk(KERN_INFO "register early platform devices\n");
724 early_platform_add_devices(tcm_early_devices,
725 ARRAY_SIZE(tcm_early_devices));
728 void native_machine_restart(char *cmd)
730 /* workaround reboot hang when booting from SPI */
731 if ((bfin_read_SYSCR() & 0x7) == 0x3)
732 bfin_reset_boot_spi_cs(P_DEFAULT_BOOT_SPI_CS);
735 int bfin_get_ether_addr(char *addr)
737 return 1;
739 EXPORT_SYMBOL(bfin_get_ether_addr);