2 * TI DA830/OMAP L137 EVM board
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 * Derived from: arch/arm/mach-davinci/board-dm644x-evm.c
7 * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
8 * the terms of the GNU General Public License version 2. This program
9 * is licensed "as is" without any warranty of any kind, whether express
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/console.h>
15 #include <linux/interrupt.h>
16 #include <linux/gpio.h>
17 #include <linux/gpio/machine.h>
18 #include <linux/platform_device.h>
19 #include <linux/i2c.h>
20 #include <linux/platform_data/pcf857x.h>
21 #include <linux/platform_data/at24.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/partitions.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/flash.h>
26 #include <linux/platform_data/gpio-davinci.h>
27 #include <linux/platform_data/mtd-davinci.h>
28 #include <linux/platform_data/mtd-davinci-aemif.h>
29 #include <linux/platform_data/spi-davinci.h>
30 #include <linux/platform_data/usb-davinci.h>
31 #include <linux/platform_data/ti-aemif.h>
32 #include <linux/regulator/machine.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.h>
37 #include <mach/common.h>
40 #include <mach/da8xx.h>
42 #define DA830_EVM_PHY_ID ""
44 * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
46 #define ON_BD_USB_DRV GPIO_TO_PIN(1, 15)
47 #define ON_BD_USB_OVC GPIO_TO_PIN(2, 4)
49 static const short da830_evm_usb11_pins[] = {
50 DA830_GPIO1_15, DA830_GPIO2_4,
54 static da8xx_ocic_handler_t da830_evm_usb_ocic_handler;
56 static int da830_evm_usb_set_power(unsigned port, int on)
58 gpio_set_value(ON_BD_USB_DRV, on);
62 static int da830_evm_usb_get_power(unsigned port)
64 return gpio_get_value(ON_BD_USB_DRV);
67 static int da830_evm_usb_get_oci(unsigned port)
69 return !gpio_get_value(ON_BD_USB_OVC);
72 static irqreturn_t da830_evm_usb_ocic_irq(int, void *);
74 static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)
76 int irq = gpio_to_irq(ON_BD_USB_OVC);
79 if (handler != NULL) {
80 da830_evm_usb_ocic_handler = handler;
82 error = request_irq(irq, da830_evm_usb_ocic_irq,
83 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
84 "OHCI over-current indicator", NULL);
86 pr_err("%s: could not request IRQ to watch over-current indicator changes\n",
94 static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
95 .set_power = da830_evm_usb_set_power,
96 .get_power = da830_evm_usb_get_power,
97 .get_oci = da830_evm_usb_get_oci,
98 .ocic_notify = da830_evm_usb_ocic_notify,
100 /* TPS2065 switch @ 5V */
101 .potpgt = (3 + 1) / 2, /* 3 ms max */
104 static irqreturn_t da830_evm_usb_ocic_irq(int irq, void *dev_id)
106 da830_evm_usb_ocic_handler(&da830_evm_usb11_pdata, 1);
110 static __init void da830_evm_usb_init(void)
114 ret = da8xx_register_usb_phy_clocks();
116 pr_warn("%s: USB PHY CLK registration failed: %d\n",
119 ret = da8xx_register_usb_phy();
121 pr_warn("%s: USB PHY registration failed: %d\n",
124 ret = davinci_cfg_reg(DA830_USB0_DRVVBUS);
126 pr_warn("%s: USB 2.0 PinMux setup failed: %d\n", __func__, ret);
129 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
130 * with the power on to power good time of 3 ms.
132 ret = da8xx_register_usb20(1000, 3);
134 pr_warn("%s: USB 2.0 registration failed: %d\n",
138 ret = davinci_cfg_reg_list(da830_evm_usb11_pins);
140 pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
144 ret = gpio_request(ON_BD_USB_DRV, "ON_BD_USB_DRV");
146 pr_err("%s: failed to request GPIO for USB 1.1 port power control: %d\n",
150 gpio_direction_output(ON_BD_USB_DRV, 0);
152 ret = gpio_request(ON_BD_USB_OVC, "ON_BD_USB_OVC");
154 pr_err("%s: failed to request GPIO for USB 1.1 port over-current indicator: %d\n",
158 gpio_direction_input(ON_BD_USB_OVC);
160 ret = da8xx_register_usb11(&da830_evm_usb11_pdata);
162 pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
165 static const short da830_evm_mcasp1_pins[] = {
166 DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1,
167 DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5,
168 DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10,
173 static u8 da830_iis_serializer_direction[] = {
174 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
175 INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE,
176 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
179 static struct snd_platform_data da830_evm_snd_data = {
180 .tx_dma_offset = 0x2000,
181 .rx_dma_offset = 0x2000,
182 .op_mode = DAVINCI_MCASP_IIS_MODE,
183 .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
185 .serial_dir = da830_iis_serializer_direction,
186 .asp_chan_q = EVENTQ_0,
187 .version = MCASP_VERSION_2,
193 * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS.
195 static const short da830_evm_mmc_sd_pins[] = {
196 DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2,
197 DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5,
198 DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK,
199 DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2,
203 #define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1)
204 #define DA830_MMCSD_CD_PIN GPIO_TO_PIN(2, 2)
206 static struct gpiod_lookup_table mmc_gpios_table = {
207 .dev_id = "da830-mmc.0",
209 /* gpio chip 1 contains gpio range 32-63 */
210 GPIO_LOOKUP("davinci_gpio.0", DA830_MMCSD_CD_PIN, "cd",
212 GPIO_LOOKUP("davinci_gpio.0", DA830_MMCSD_WP_PIN, "wp",
217 static struct davinci_mmc_config da830_evm_mmc_config = {
219 .max_freq = 50000000,
220 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
223 static inline void da830_evm_init_mmc(void)
227 ret = davinci_cfg_reg_list(da830_evm_mmc_sd_pins);
229 pr_warn("%s: mmc/sd mux setup failed: %d\n", __func__, ret);
233 gpiod_add_lookup_table(&mmc_gpios_table);
235 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config);
237 pr_warn("%s: mmc/sd registration failed: %d\n", __func__, ret);
238 gpiod_remove_lookup_table(&mmc_gpios_table);
242 #define HAS_MMC IS_ENABLED(CONFIG_MMC_DAVINCI)
244 #ifdef CONFIG_DA830_UI_NAND
245 static struct mtd_partition da830_evm_nand_partitions[] = {
246 /* bootloader (U-Boot, etc) in first sector */
248 .name = "bootloader",
251 .mask_flags = MTD_WRITEABLE, /* force read-only */
253 /* bootloader params in the next sector */
256 .offset = MTDPART_OFS_APPEND,
258 .mask_flags = MTD_WRITEABLE, /* force read-only */
263 .offset = MTDPART_OFS_APPEND,
269 .name = "filesystem",
270 .offset = MTDPART_OFS_APPEND,
271 .size = MTDPART_SIZ_FULL,
276 /* flash bbt decriptors */
277 static uint8_t da830_evm_nand_bbt_pattern[] = { 'B', 'b', 't', '0' };
278 static uint8_t da830_evm_nand_mirror_pattern[] = { '1', 't', 'b', 'B' };
280 static struct nand_bbt_descr da830_evm_nand_bbt_main_descr = {
281 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
282 NAND_BBT_WRITE | NAND_BBT_2BIT |
283 NAND_BBT_VERSION | NAND_BBT_PERCHIP,
288 .pattern = da830_evm_nand_bbt_pattern
291 static struct nand_bbt_descr da830_evm_nand_bbt_mirror_descr = {
292 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
293 NAND_BBT_WRITE | NAND_BBT_2BIT |
294 NAND_BBT_VERSION | NAND_BBT_PERCHIP,
299 .pattern = da830_evm_nand_mirror_pattern
302 static struct davinci_aemif_timing da830_evm_nandflash_timing = {
312 static struct davinci_nand_pdata da830_evm_nand_pdata = {
314 .parts = da830_evm_nand_partitions,
315 .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions),
316 .ecc_mode = NAND_ECC_HW,
318 .bbt_options = NAND_BBT_USE_FLASH,
319 .bbt_td = &da830_evm_nand_bbt_main_descr,
320 .bbt_md = &da830_evm_nand_bbt_mirror_descr,
321 .timing = &da830_evm_nandflash_timing,
324 static struct resource da830_evm_nand_resources[] = {
325 [0] = { /* First memory resource is NAND I/O window */
326 .start = DA8XX_AEMIF_CS3_BASE,
327 .end = DA8XX_AEMIF_CS3_BASE + PAGE_SIZE - 1,
328 .flags = IORESOURCE_MEM,
330 [1] = { /* Second memory resource is AEMIF control registers */
331 .start = DA8XX_AEMIF_CTL_BASE,
332 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
333 .flags = IORESOURCE_MEM,
337 static struct platform_device da830_evm_aemif_devices[] = {
339 .name = "davinci_nand",
342 .platform_data = &da830_evm_nand_pdata,
344 .num_resources = ARRAY_SIZE(da830_evm_nand_resources),
345 .resource = da830_evm_nand_resources,
349 static struct resource da830_evm_aemif_resource[] = {
351 .start = DA8XX_AEMIF_CTL_BASE,
352 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
353 .flags = IORESOURCE_MEM,
357 static struct aemif_abus_data da830_evm_aemif_abus_data[] = {
363 static struct aemif_platform_data da830_evm_aemif_pdata = {
364 .abus_data = da830_evm_aemif_abus_data,
365 .num_abus_data = ARRAY_SIZE(da830_evm_aemif_abus_data),
366 .sub_devices = da830_evm_aemif_devices,
367 .num_sub_devices = ARRAY_SIZE(da830_evm_aemif_devices),
371 static struct platform_device da830_evm_aemif_device = {
375 .platform_data = &da830_evm_aemif_pdata,
377 .resource = da830_evm_aemif_resource,
378 .num_resources = ARRAY_SIZE(da830_evm_aemif_resource),
382 * UI board NAND/NOR flashes only use 8-bit data bus.
384 static const short da830_evm_emif25_pins[] = {
385 DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,
386 DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,
387 DA830_EMA_A_0, DA830_EMA_A_1, DA830_EMA_A_2, DA830_EMA_A_3,
388 DA830_EMA_A_4, DA830_EMA_A_5, DA830_EMA_A_6, DA830_EMA_A_7,
389 DA830_EMA_A_8, DA830_EMA_A_9, DA830_EMA_A_10, DA830_EMA_A_11,
390 DA830_EMA_A_12, DA830_EMA_BA_0, DA830_EMA_BA_1, DA830_NEMA_WE,
391 DA830_NEMA_CS_2, DA830_NEMA_CS_3, DA830_NEMA_OE, DA830_EMA_WAIT_0,
395 static inline void da830_evm_init_nand(int mux_mode)
400 pr_warn("WARNING: both MMC/SD and NAND are enabled, but they share AEMIF pins\n"
401 "\tDisable MMC/SD for NAND support\n");
405 ret = davinci_cfg_reg_list(da830_evm_emif25_pins);
407 pr_warn("%s: emif25 mux setup failed: %d\n", __func__, ret);
409 ret = platform_device_register(&da830_evm_aemif_device);
411 pr_warn("%s: AEMIF device not registered\n", __func__);
413 gpio_direction_output(mux_mode, 1);
416 static inline void da830_evm_init_nand(int mux_mode) { }
419 #ifdef CONFIG_DA830_UI_LCD
420 static inline void da830_evm_init_lcdc(int mux_mode)
424 ret = davinci_cfg_reg_list(da830_lcdcntl_pins);
426 pr_warn("%s: lcdcntl mux setup failed: %d\n", __func__, ret);
428 ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
430 pr_warn("%s: lcd setup failed: %d\n", __func__, ret);
432 gpio_direction_output(mux_mode, 0);
435 static inline void da830_evm_init_lcdc(int mux_mode) { }
438 static struct at24_platform_data da830_evm_i2c_eeprom_info = {
439 .byte_len = SZ_256K / 8,
441 .flags = AT24_FLAG_ADDR16,
442 .setup = davinci_get_mac_addr,
443 .context = (void *)0x7f00,
446 static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
447 int gpio, unsigned ngpio, void *context)
449 gpio_request(gpio + 6, "UI MUX_MODE");
451 /* Drive mux mode low to match the default without UI card */
452 gpio_direction_output(gpio + 6, 0);
454 da830_evm_init_lcdc(gpio + 6);
456 da830_evm_init_nand(gpio + 6);
461 static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
462 unsigned ngpio, void *context)
468 static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
469 .gpio_base = DAVINCI_N_GPIO,
470 .setup = da830_evm_ui_expander_setup,
471 .teardown = da830_evm_ui_expander_teardown,
474 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
476 I2C_BOARD_INFO("24c256", 0x50),
477 .platform_data = &da830_evm_i2c_eeprom_info,
480 I2C_BOARD_INFO("tlv320aic3x", 0x18),
483 I2C_BOARD_INFO("pcf8574", 0x3f),
484 .platform_data = &da830_evm_ui_expander_info,
488 static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
489 .bus_freq = 100, /* kHz */
490 .bus_delay = 0, /* usec */
494 * The following EDMA channels/slots are not being used by drivers (for
495 * example: Timer, GPIO, UART events etc) on da830/omap-l137 EVM, hence
496 * they are being reserved for codecs on the DSP side.
498 static const s16 da830_dma_rsv_chans[][2] = {
499 /* (offset, number) */
507 static const s16 da830_dma_rsv_slots[][2] = {
508 /* (offset, number) */
516 static struct edma_rsv_info da830_edma_rsv[] = {
518 .rsv_chans = da830_dma_rsv_chans,
519 .rsv_slots = da830_dma_rsv_slots,
523 static struct mtd_partition da830evm_spiflash_part[] = {
528 .mask_flags = MTD_WRITEABLE,
532 .offset = MTDPART_OFS_APPEND,
533 .size = SZ_16K + SZ_8K,
534 .mask_flags = MTD_WRITEABLE,
538 .offset = MTDPART_OFS_APPEND,
539 .size = SZ_256K - SZ_32K,
540 .mask_flags = MTD_WRITEABLE,
543 .name = "U-Boot-Environment",
544 .offset = MTDPART_OFS_APPEND,
550 .offset = MTDPART_OFS_APPEND,
551 .size = MTDPART_SIZ_FULL,
556 static struct flash_platform_data da830evm_spiflash_data = {
558 .parts = da830evm_spiflash_part,
559 .nr_parts = ARRAY_SIZE(da830evm_spiflash_part),
563 static struct davinci_spi_config da830evm_spiflash_cfg = {
564 .io_type = SPI_IO_TYPE_DMA,
569 static struct spi_board_info da830evm_spi_info[] = {
571 .modalias = "m25p80",
572 .platform_data = &da830evm_spiflash_data,
573 .controller_data = &da830evm_spiflash_cfg,
575 .max_speed_hz = 30000000,
581 static __init void da830_evm_init(void)
583 struct davinci_soc_info *soc_info = &davinci_soc_info;
586 da830_register_clocks();
588 ret = da830_register_gpio();
590 pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
592 ret = da830_register_edma(da830_edma_rsv);
594 pr_warn("%s: edma registration failed: %d\n", __func__, ret);
596 ret = davinci_cfg_reg_list(da830_i2c0_pins);
598 pr_warn("%s: i2c0 mux setup failed: %d\n", __func__, ret);
600 ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata);
602 pr_warn("%s: i2c0 registration failed: %d\n", __func__, ret);
604 da830_evm_usb_init();
606 soc_info->emac_pdata->rmii_en = 1;
607 soc_info->emac_pdata->phy_id = DA830_EVM_PHY_ID;
609 ret = davinci_cfg_reg_list(da830_cpgmac_pins);
611 pr_warn("%s: cpgmac mux setup failed: %d\n", __func__, ret);
613 ret = da8xx_register_emac();
615 pr_warn("%s: emac registration failed: %d\n", __func__, ret);
617 ret = da8xx_register_watchdog();
619 pr_warn("%s: watchdog registration failed: %d\n",
622 davinci_serial_init(da8xx_serial_device);
623 i2c_register_board_info(1, da830_evm_i2c_devices,
624 ARRAY_SIZE(da830_evm_i2c_devices));
626 ret = davinci_cfg_reg_list(da830_evm_mcasp1_pins);
628 pr_warn("%s: mcasp1 mux setup failed: %d\n", __func__, ret);
630 da8xx_register_mcasp(1, &da830_evm_snd_data);
632 da830_evm_init_mmc();
634 ret = da8xx_register_rtc();
636 pr_warn("%s: rtc setup failed: %d\n", __func__, ret);
638 ret = spi_register_board_info(da830evm_spi_info,
639 ARRAY_SIZE(da830evm_spi_info));
641 pr_warn("%s: spi info registration failed: %d\n",
644 ret = da8xx_register_spi_bus(0, ARRAY_SIZE(da830evm_spi_info));
646 pr_warn("%s: spi 0 registration failed: %d\n", __func__, ret);
648 regulator_has_full_constraints();
651 #ifdef CONFIG_SERIAL_8250_CONSOLE
652 static int __init da830_evm_console_init(void)
654 if (!machine_is_davinci_da830_evm())
657 return add_preferred_console("ttyS", 2, "115200");
659 console_initcall(da830_evm_console_init);
662 static void __init da830_evm_map_io(void)
667 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
668 .atag_offset = 0x100,
669 .map_io = da830_evm_map_io,
670 .init_irq = cp_intc_init,
671 .init_time = da830_init_time,
672 .init_machine = da830_evm_init,
673 .init_late = davinci_init_late,
674 .dma_zone_size = SZ_128M,