1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI DA830/OMAP L137 EVM board
5 * Author: Mark A. Greer <mgreer@mvista.com>
6 * Derived from: arch/arm/mach-davinci/board-dm644x-evm.c
8 * 2007, 2009 (c) MontaVista Software, Inc.
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/console.h>
13 #include <linux/interrupt.h>
14 #include <linux/gpio.h>
15 #include <linux/gpio/machine.h>
16 #include <linux/platform_device.h>
17 #include <linux/i2c.h>
18 #include <linux/platform_data/pcf857x.h>
19 #include <linux/property.h>
20 #include <linux/mtd/mtd.h>
21 #include <linux/mtd/partitions.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/flash.h>
24 #include <linux/platform_data/gpio-davinci.h>
25 #include <linux/platform_data/mtd-davinci.h>
26 #include <linux/platform_data/mtd-davinci-aemif.h>
27 #include <linux/platform_data/spi-davinci.h>
28 #include <linux/platform_data/usb-davinci.h>
29 #include <linux/platform_data/ti-aemif.h>
30 #include <linux/regulator/fixed.h>
31 #include <linux/regulator/machine.h>
32 #include <linux/nvmem-provider.h>
34 #include <asm/mach-types.h>
35 #include <asm/mach/arch.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 struct regulator_consumer_supply da830_evm_usb_supplies[] = {
55 REGULATOR_SUPPLY("vbus", NULL),
58 static struct regulator_init_data da830_evm_usb_vbus_data = {
59 .consumer_supplies = da830_evm_usb_supplies,
60 .num_consumer_supplies = ARRAY_SIZE(da830_evm_usb_supplies),
62 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
66 static struct fixed_voltage_config da830_evm_usb_vbus = {
67 .supply_name = "vbus",
68 .microvolts = 33000000,
69 .init_data = &da830_evm_usb_vbus_data,
72 static struct platform_device da830_evm_usb_vbus_device = {
73 .name = "reg-fixed-voltage",
76 .platform_data = &da830_evm_usb_vbus,
80 static struct gpiod_lookup_table da830_evm_usb_oc_gpio_lookup = {
81 .dev_id = "ohci-da8xx",
83 GPIO_LOOKUP("davinci_gpio", ON_BD_USB_OVC, "oc", 0),
88 static struct gpiod_lookup_table da830_evm_usb_vbus_gpio_lookup = {
89 .dev_id = "reg-fixed-voltage.0",
91 GPIO_LOOKUP("davinci_gpio", ON_BD_USB_DRV, NULL, 0),
96 static struct gpiod_lookup_table *da830_evm_usb_gpio_lookups[] = {
97 &da830_evm_usb_oc_gpio_lookup,
98 &da830_evm_usb_vbus_gpio_lookup,
101 static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
102 /* TPS2065 switch @ 5V */
103 .potpgt = (3 + 1) / 2, /* 3 ms max */
106 static __init void da830_evm_usb_init(void)
110 ret = da8xx_register_usb_phy_clocks();
112 pr_warn("%s: USB PHY CLK registration failed: %d\n",
115 gpiod_add_lookup_tables(da830_evm_usb_gpio_lookups,
116 ARRAY_SIZE(da830_evm_usb_gpio_lookups));
118 ret = da8xx_register_usb_phy();
120 pr_warn("%s: USB PHY registration failed: %d\n",
123 ret = davinci_cfg_reg(DA830_USB0_DRVVBUS);
125 pr_warn("%s: USB 2.0 PinMux setup failed: %d\n", __func__, ret);
128 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
129 * with the power on to power good time of 3 ms.
131 ret = da8xx_register_usb20(1000, 3);
133 pr_warn("%s: USB 2.0 registration failed: %d\n",
137 ret = davinci_cfg_reg_list(da830_evm_usb11_pins);
139 pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
143 ret = platform_device_register(&da830_evm_usb_vbus_device);
145 pr_warn("%s: Unable to register the vbus supply\n", __func__);
149 ret = da8xx_register_usb11(&da830_evm_usb11_pdata);
151 pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
154 static const short da830_evm_mcasp1_pins[] = {
155 DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1,
156 DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5,
157 DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10,
162 static u8 da830_iis_serializer_direction[] = {
163 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
164 INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE,
165 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
168 static struct snd_platform_data da830_evm_snd_data = {
169 .tx_dma_offset = 0x2000,
170 .rx_dma_offset = 0x2000,
171 .op_mode = DAVINCI_MCASP_IIS_MODE,
172 .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
174 .serial_dir = da830_iis_serializer_direction,
175 .asp_chan_q = EVENTQ_0,
176 .version = MCASP_VERSION_2,
182 * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS.
184 static const short da830_evm_mmc_sd_pins[] = {
185 DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2,
186 DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5,
187 DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK,
188 DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2,
192 #define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1)
193 #define DA830_MMCSD_CD_PIN GPIO_TO_PIN(2, 2)
195 static struct gpiod_lookup_table mmc_gpios_table = {
196 .dev_id = "da830-mmc.0",
198 /* gpio chip 1 contains gpio range 32-63 */
199 GPIO_LOOKUP("davinci_gpio", DA830_MMCSD_CD_PIN, "cd",
201 GPIO_LOOKUP("davinci_gpio", DA830_MMCSD_WP_PIN, "wp",
207 static struct davinci_mmc_config da830_evm_mmc_config = {
209 .max_freq = 50000000,
210 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
213 static inline void da830_evm_init_mmc(void)
217 ret = davinci_cfg_reg_list(da830_evm_mmc_sd_pins);
219 pr_warn("%s: mmc/sd mux setup failed: %d\n", __func__, ret);
223 gpiod_add_lookup_table(&mmc_gpios_table);
225 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config);
227 pr_warn("%s: mmc/sd registration failed: %d\n", __func__, ret);
228 gpiod_remove_lookup_table(&mmc_gpios_table);
232 #define HAS_MMC IS_ENABLED(CONFIG_MMC_DAVINCI)
234 #ifdef CONFIG_DA830_UI_NAND
235 static struct mtd_partition da830_evm_nand_partitions[] = {
236 /* bootloader (U-Boot, etc) in first sector */
238 .name = "bootloader",
241 .mask_flags = MTD_WRITEABLE, /* force read-only */
243 /* bootloader params in the next sector */
246 .offset = MTDPART_OFS_APPEND,
248 .mask_flags = MTD_WRITEABLE, /* force read-only */
253 .offset = MTDPART_OFS_APPEND,
259 .name = "filesystem",
260 .offset = MTDPART_OFS_APPEND,
261 .size = MTDPART_SIZ_FULL,
266 /* flash bbt descriptors */
267 static uint8_t da830_evm_nand_bbt_pattern[] = { 'B', 'b', 't', '0' };
268 static uint8_t da830_evm_nand_mirror_pattern[] = { '1', 't', 'b', 'B' };
270 static struct nand_bbt_descr da830_evm_nand_bbt_main_descr = {
271 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
272 NAND_BBT_WRITE | NAND_BBT_2BIT |
273 NAND_BBT_VERSION | NAND_BBT_PERCHIP,
278 .pattern = da830_evm_nand_bbt_pattern
281 static struct nand_bbt_descr da830_evm_nand_bbt_mirror_descr = {
282 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
283 NAND_BBT_WRITE | NAND_BBT_2BIT |
284 NAND_BBT_VERSION | NAND_BBT_PERCHIP,
289 .pattern = da830_evm_nand_mirror_pattern
292 static struct davinci_aemif_timing da830_evm_nandflash_timing = {
302 static struct davinci_nand_pdata da830_evm_nand_pdata = {
304 .parts = da830_evm_nand_partitions,
305 .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions),
306 .engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST,
308 .bbt_options = NAND_BBT_USE_FLASH,
309 .bbt_td = &da830_evm_nand_bbt_main_descr,
310 .bbt_md = &da830_evm_nand_bbt_mirror_descr,
311 .timing = &da830_evm_nandflash_timing,
314 static struct resource da830_evm_nand_resources[] = {
315 [0] = { /* First memory resource is NAND I/O window */
316 .start = DA8XX_AEMIF_CS3_BASE,
317 .end = DA8XX_AEMIF_CS3_BASE + PAGE_SIZE - 1,
318 .flags = IORESOURCE_MEM,
320 [1] = { /* Second memory resource is AEMIF control registers */
321 .start = DA8XX_AEMIF_CTL_BASE,
322 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
323 .flags = IORESOURCE_MEM,
327 static struct platform_device da830_evm_aemif_devices[] = {
329 .name = "davinci_nand",
332 .platform_data = &da830_evm_nand_pdata,
334 .num_resources = ARRAY_SIZE(da830_evm_nand_resources),
335 .resource = da830_evm_nand_resources,
339 static struct resource da830_evm_aemif_resource[] = {
341 .start = DA8XX_AEMIF_CTL_BASE,
342 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
343 .flags = IORESOURCE_MEM,
347 static struct aemif_abus_data da830_evm_aemif_abus_data[] = {
353 static struct aemif_platform_data da830_evm_aemif_pdata = {
354 .abus_data = da830_evm_aemif_abus_data,
355 .num_abus_data = ARRAY_SIZE(da830_evm_aemif_abus_data),
356 .sub_devices = da830_evm_aemif_devices,
357 .num_sub_devices = ARRAY_SIZE(da830_evm_aemif_devices),
361 static struct platform_device da830_evm_aemif_device = {
365 .platform_data = &da830_evm_aemif_pdata,
367 .resource = da830_evm_aemif_resource,
368 .num_resources = ARRAY_SIZE(da830_evm_aemif_resource),
372 * UI board NAND/NOR flashes only use 8-bit data bus.
374 static const short da830_evm_emif25_pins[] = {
375 DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,
376 DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,
377 DA830_EMA_A_0, DA830_EMA_A_1, DA830_EMA_A_2, DA830_EMA_A_3,
378 DA830_EMA_A_4, DA830_EMA_A_5, DA830_EMA_A_6, DA830_EMA_A_7,
379 DA830_EMA_A_8, DA830_EMA_A_9, DA830_EMA_A_10, DA830_EMA_A_11,
380 DA830_EMA_A_12, DA830_EMA_BA_0, DA830_EMA_BA_1, DA830_NEMA_WE,
381 DA830_NEMA_CS_2, DA830_NEMA_CS_3, DA830_NEMA_OE, DA830_EMA_WAIT_0,
385 static inline void da830_evm_init_nand(int mux_mode)
390 pr_warn("WARNING: both MMC/SD and NAND are enabled, but they share AEMIF pins\n"
391 "\tDisable MMC/SD for NAND support\n");
395 ret = davinci_cfg_reg_list(da830_evm_emif25_pins);
397 pr_warn("%s: emif25 mux setup failed: %d\n", __func__, ret);
399 ret = platform_device_register(&da830_evm_aemif_device);
401 pr_warn("%s: AEMIF device not registered\n", __func__);
403 gpio_direction_output(mux_mode, 1);
406 static inline void da830_evm_init_nand(int mux_mode) { }
409 #ifdef CONFIG_DA830_UI_LCD
410 static inline void da830_evm_init_lcdc(int mux_mode)
414 ret = davinci_cfg_reg_list(da830_lcdcntl_pins);
416 pr_warn("%s: lcdcntl mux setup failed: %d\n", __func__, ret);
418 ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
420 pr_warn("%s: lcd setup failed: %d\n", __func__, ret);
422 gpio_direction_output(mux_mode, 0);
425 static inline void da830_evm_init_lcdc(int mux_mode) { }
428 static struct nvmem_cell_info da830_evm_nvmem_cells[] = {
436 static struct nvmem_cell_table da830_evm_nvmem_cell_table = {
437 .nvmem_name = "1-00500",
438 .cells = da830_evm_nvmem_cells,
439 .ncells = ARRAY_SIZE(da830_evm_nvmem_cells),
442 static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = {
443 .nvmem_name = "1-00500",
444 .cell_name = "macaddr",
445 .dev_id = "davinci_emac.1",
446 .con_id = "mac-address",
449 static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
450 PROPERTY_ENTRY_U32("pagesize", 64),
454 static const struct software_node da830_evm_i2c_eeprom_node = {
455 .properties = da830_evm_i2c_eeprom_properties,
458 static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
459 int gpio, unsigned ngpio, void *context)
461 gpio_request(gpio + 6, "UI MUX_MODE");
463 /* Drive mux mode low to match the default without UI card */
464 gpio_direction_output(gpio + 6, 0);
466 da830_evm_init_lcdc(gpio + 6);
468 da830_evm_init_nand(gpio + 6);
473 static void da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
474 unsigned ngpio, void *context)
479 static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
480 .gpio_base = DAVINCI_N_GPIO,
481 .setup = da830_evm_ui_expander_setup,
482 .teardown = da830_evm_ui_expander_teardown,
485 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
487 I2C_BOARD_INFO("24c256", 0x50),
488 .swnode = &da830_evm_i2c_eeprom_node,
491 I2C_BOARD_INFO("tlv320aic3x", 0x18),
494 I2C_BOARD_INFO("pcf8574", 0x3f),
495 .platform_data = &da830_evm_ui_expander_info,
499 static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
500 .bus_freq = 100, /* kHz */
501 .bus_delay = 0, /* usec */
505 * The following EDMA channels/slots are not being used by drivers (for
506 * example: Timer, GPIO, UART events etc) on da830/omap-l137 EVM, hence
507 * they are being reserved for codecs on the DSP side.
509 static const s16 da830_dma_rsv_chans[][2] = {
510 /* (offset, number) */
518 static const s16 da830_dma_rsv_slots[][2] = {
519 /* (offset, number) */
527 static struct edma_rsv_info da830_edma_rsv[] = {
529 .rsv_chans = da830_dma_rsv_chans,
530 .rsv_slots = da830_dma_rsv_slots,
534 static struct mtd_partition da830evm_spiflash_part[] = {
539 .mask_flags = MTD_WRITEABLE,
543 .offset = MTDPART_OFS_APPEND,
544 .size = SZ_16K + SZ_8K,
545 .mask_flags = MTD_WRITEABLE,
549 .offset = MTDPART_OFS_APPEND,
550 .size = SZ_256K - SZ_32K,
551 .mask_flags = MTD_WRITEABLE,
554 .name = "U-Boot-Environment",
555 .offset = MTDPART_OFS_APPEND,
561 .offset = MTDPART_OFS_APPEND,
562 .size = MTDPART_SIZ_FULL,
567 static struct flash_platform_data da830evm_spiflash_data = {
569 .parts = da830evm_spiflash_part,
570 .nr_parts = ARRAY_SIZE(da830evm_spiflash_part),
574 static struct davinci_spi_config da830evm_spiflash_cfg = {
575 .io_type = SPI_IO_TYPE_DMA,
580 static struct spi_board_info da830evm_spi_info[] = {
582 .modalias = "m25p80",
583 .platform_data = &da830evm_spiflash_data,
584 .controller_data = &da830evm_spiflash_cfg,
586 .max_speed_hz = 30000000,
592 static __init void da830_evm_init(void)
594 struct davinci_soc_info *soc_info = &davinci_soc_info;
597 da830_register_clocks();
599 ret = da830_register_gpio();
601 pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
603 ret = da830_register_edma(da830_edma_rsv);
605 pr_warn("%s: edma registration failed: %d\n", __func__, ret);
607 ret = davinci_cfg_reg_list(da830_i2c0_pins);
609 pr_warn("%s: i2c0 mux setup failed: %d\n", __func__, ret);
611 ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata);
613 pr_warn("%s: i2c0 registration failed: %d\n", __func__, ret);
615 da830_evm_usb_init();
617 soc_info->emac_pdata->rmii_en = 1;
618 soc_info->emac_pdata->phy_id = DA830_EVM_PHY_ID;
620 ret = davinci_cfg_reg_list(da830_cpgmac_pins);
622 pr_warn("%s: cpgmac mux setup failed: %d\n", __func__, ret);
624 ret = da8xx_register_emac();
626 pr_warn("%s: emac registration failed: %d\n", __func__, ret);
628 ret = da8xx_register_watchdog();
630 pr_warn("%s: watchdog registration failed: %d\n",
633 davinci_serial_init(da8xx_serial_device);
635 nvmem_add_cell_table(&da830_evm_nvmem_cell_table);
636 nvmem_add_cell_lookups(&da830_evm_nvmem_cell_lookup, 1);
638 i2c_register_board_info(1, da830_evm_i2c_devices,
639 ARRAY_SIZE(da830_evm_i2c_devices));
641 ret = davinci_cfg_reg_list(da830_evm_mcasp1_pins);
643 pr_warn("%s: mcasp1 mux setup failed: %d\n", __func__, ret);
645 da8xx_register_mcasp(1, &da830_evm_snd_data);
647 da830_evm_init_mmc();
649 ret = da8xx_register_rtc();
651 pr_warn("%s: rtc setup failed: %d\n", __func__, ret);
653 ret = spi_register_board_info(da830evm_spi_info,
654 ARRAY_SIZE(da830evm_spi_info));
656 pr_warn("%s: spi info registration failed: %d\n",
659 ret = da8xx_register_spi_bus(0, ARRAY_SIZE(da830evm_spi_info));
661 pr_warn("%s: spi 0 registration failed: %d\n", __func__, ret);
663 regulator_has_full_constraints();
666 #ifdef CONFIG_SERIAL_8250_CONSOLE
667 static int __init da830_evm_console_init(void)
669 if (!machine_is_davinci_da830_evm())
672 return add_preferred_console("ttyS", 2, "115200");
674 console_initcall(da830_evm_console_init);
677 static void __init da830_evm_map_io(void)
682 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
683 .atag_offset = 0x100,
684 .map_io = da830_evm_map_io,
685 .init_irq = da830_init_irq,
686 .init_time = da830_init_time,
687 .init_machine = da830_evm_init,
688 .init_late = davinci_init_late,
689 .dma_zone_size = SZ_128M,