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/property.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>
33 #include <linux/nvmem-provider.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
38 #include <mach/common.h>
40 #include <mach/da8xx.h>
44 #define DA830_EVM_PHY_ID ""
46 * USB1 VBUS is controlled by GPIO1[15], over-current is reported on GPIO2[4].
48 #define ON_BD_USB_DRV GPIO_TO_PIN(1, 15)
49 #define ON_BD_USB_OVC GPIO_TO_PIN(2, 4)
51 static const short da830_evm_usb11_pins[] = {
52 DA830_GPIO1_15, DA830_GPIO2_4,
56 static struct gpiod_lookup_table da830_evm_usb_gpio_lookup = {
57 .dev_id = "ohci-da8xx",
59 GPIO_LOOKUP("davinci_gpio", ON_BD_USB_DRV, "vbus", 0),
60 GPIO_LOOKUP("davinci_gpio", ON_BD_USB_OVC, "oc", 0),
64 static struct da8xx_ohci_root_hub da830_evm_usb11_pdata = {
65 /* TPS2065 switch @ 5V */
66 .potpgt = (3 + 1) / 2, /* 3 ms max */
69 static __init void da830_evm_usb_init(void)
73 ret = da8xx_register_usb_phy_clocks();
75 pr_warn("%s: USB PHY CLK registration failed: %d\n",
78 ret = da8xx_register_usb_phy();
80 pr_warn("%s: USB PHY registration failed: %d\n",
83 ret = davinci_cfg_reg(DA830_USB0_DRVVBUS);
85 pr_warn("%s: USB 2.0 PinMux setup failed: %d\n", __func__, ret);
88 * TPS2065 switch @ 5V supplies 1 A (sustains 1.5 A),
89 * with the power on to power good time of 3 ms.
91 ret = da8xx_register_usb20(1000, 3);
93 pr_warn("%s: USB 2.0 registration failed: %d\n",
97 ret = davinci_cfg_reg_list(da830_evm_usb11_pins);
99 pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret);
103 gpiod_add_lookup_table(&da830_evm_usb_gpio_lookup);
105 ret = da8xx_register_usb11(&da830_evm_usb11_pdata);
107 pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret);
110 static const short da830_evm_mcasp1_pins[] = {
111 DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1,
112 DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5,
113 DA830_ACLKR1, DA830_AXR1_6, DA830_AXR1_7, DA830_AXR1_8, DA830_AXR1_10,
118 static u8 da830_iis_serializer_direction[] = {
119 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
120 INACTIVE_MODE, TX_MODE, INACTIVE_MODE, INACTIVE_MODE,
121 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
124 static struct snd_platform_data da830_evm_snd_data = {
125 .tx_dma_offset = 0x2000,
126 .rx_dma_offset = 0x2000,
127 .op_mode = DAVINCI_MCASP_IIS_MODE,
128 .num_serializer = ARRAY_SIZE(da830_iis_serializer_direction),
130 .serial_dir = da830_iis_serializer_direction,
131 .asp_chan_q = EVENTQ_0,
132 .version = MCASP_VERSION_2,
138 * GPIO2[1] is used as MMC_SD_WP and GPIO2[2] as MMC_SD_INS.
140 static const short da830_evm_mmc_sd_pins[] = {
141 DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2,
142 DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5,
143 DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK,
144 DA830_MMCSD_CMD, DA830_GPIO2_1, DA830_GPIO2_2,
148 #define DA830_MMCSD_WP_PIN GPIO_TO_PIN(2, 1)
149 #define DA830_MMCSD_CD_PIN GPIO_TO_PIN(2, 2)
151 static struct gpiod_lookup_table mmc_gpios_table = {
152 .dev_id = "da830-mmc.0",
154 /* gpio chip 1 contains gpio range 32-63 */
155 GPIO_LOOKUP("davinci_gpio", DA830_MMCSD_CD_PIN, "cd",
157 GPIO_LOOKUP("davinci_gpio", DA830_MMCSD_WP_PIN, "wp",
162 static struct davinci_mmc_config da830_evm_mmc_config = {
164 .max_freq = 50000000,
165 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
168 static inline void da830_evm_init_mmc(void)
172 ret = davinci_cfg_reg_list(da830_evm_mmc_sd_pins);
174 pr_warn("%s: mmc/sd mux setup failed: %d\n", __func__, ret);
178 gpiod_add_lookup_table(&mmc_gpios_table);
180 ret = da8xx_register_mmcsd0(&da830_evm_mmc_config);
182 pr_warn("%s: mmc/sd registration failed: %d\n", __func__, ret);
183 gpiod_remove_lookup_table(&mmc_gpios_table);
187 #define HAS_MMC IS_ENABLED(CONFIG_MMC_DAVINCI)
189 #ifdef CONFIG_DA830_UI_NAND
190 static struct mtd_partition da830_evm_nand_partitions[] = {
191 /* bootloader (U-Boot, etc) in first sector */
193 .name = "bootloader",
196 .mask_flags = MTD_WRITEABLE, /* force read-only */
198 /* bootloader params in the next sector */
201 .offset = MTDPART_OFS_APPEND,
203 .mask_flags = MTD_WRITEABLE, /* force read-only */
208 .offset = MTDPART_OFS_APPEND,
214 .name = "filesystem",
215 .offset = MTDPART_OFS_APPEND,
216 .size = MTDPART_SIZ_FULL,
221 /* flash bbt decriptors */
222 static uint8_t da830_evm_nand_bbt_pattern[] = { 'B', 'b', 't', '0' };
223 static uint8_t da830_evm_nand_mirror_pattern[] = { '1', 't', 'b', 'B' };
225 static struct nand_bbt_descr da830_evm_nand_bbt_main_descr = {
226 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
227 NAND_BBT_WRITE | NAND_BBT_2BIT |
228 NAND_BBT_VERSION | NAND_BBT_PERCHIP,
233 .pattern = da830_evm_nand_bbt_pattern
236 static struct nand_bbt_descr da830_evm_nand_bbt_mirror_descr = {
237 .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE |
238 NAND_BBT_WRITE | NAND_BBT_2BIT |
239 NAND_BBT_VERSION | NAND_BBT_PERCHIP,
244 .pattern = da830_evm_nand_mirror_pattern
247 static struct davinci_aemif_timing da830_evm_nandflash_timing = {
257 static struct davinci_nand_pdata da830_evm_nand_pdata = {
259 .parts = da830_evm_nand_partitions,
260 .nr_parts = ARRAY_SIZE(da830_evm_nand_partitions),
261 .ecc_mode = NAND_ECC_HW,
263 .bbt_options = NAND_BBT_USE_FLASH,
264 .bbt_td = &da830_evm_nand_bbt_main_descr,
265 .bbt_md = &da830_evm_nand_bbt_mirror_descr,
266 .timing = &da830_evm_nandflash_timing,
269 static struct resource da830_evm_nand_resources[] = {
270 [0] = { /* First memory resource is NAND I/O window */
271 .start = DA8XX_AEMIF_CS3_BASE,
272 .end = DA8XX_AEMIF_CS3_BASE + PAGE_SIZE - 1,
273 .flags = IORESOURCE_MEM,
275 [1] = { /* Second memory resource is AEMIF control registers */
276 .start = DA8XX_AEMIF_CTL_BASE,
277 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
278 .flags = IORESOURCE_MEM,
282 static struct platform_device da830_evm_aemif_devices[] = {
284 .name = "davinci_nand",
287 .platform_data = &da830_evm_nand_pdata,
289 .num_resources = ARRAY_SIZE(da830_evm_nand_resources),
290 .resource = da830_evm_nand_resources,
294 static struct resource da830_evm_aemif_resource[] = {
296 .start = DA8XX_AEMIF_CTL_BASE,
297 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
298 .flags = IORESOURCE_MEM,
302 static struct aemif_abus_data da830_evm_aemif_abus_data[] = {
308 static struct aemif_platform_data da830_evm_aemif_pdata = {
309 .abus_data = da830_evm_aemif_abus_data,
310 .num_abus_data = ARRAY_SIZE(da830_evm_aemif_abus_data),
311 .sub_devices = da830_evm_aemif_devices,
312 .num_sub_devices = ARRAY_SIZE(da830_evm_aemif_devices),
316 static struct platform_device da830_evm_aemif_device = {
320 .platform_data = &da830_evm_aemif_pdata,
322 .resource = da830_evm_aemif_resource,
323 .num_resources = ARRAY_SIZE(da830_evm_aemif_resource),
327 * UI board NAND/NOR flashes only use 8-bit data bus.
329 static const short da830_evm_emif25_pins[] = {
330 DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,
331 DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,
332 DA830_EMA_A_0, DA830_EMA_A_1, DA830_EMA_A_2, DA830_EMA_A_3,
333 DA830_EMA_A_4, DA830_EMA_A_5, DA830_EMA_A_6, DA830_EMA_A_7,
334 DA830_EMA_A_8, DA830_EMA_A_9, DA830_EMA_A_10, DA830_EMA_A_11,
335 DA830_EMA_A_12, DA830_EMA_BA_0, DA830_EMA_BA_1, DA830_NEMA_WE,
336 DA830_NEMA_CS_2, DA830_NEMA_CS_3, DA830_NEMA_OE, DA830_EMA_WAIT_0,
340 static inline void da830_evm_init_nand(int mux_mode)
345 pr_warn("WARNING: both MMC/SD and NAND are enabled, but they share AEMIF pins\n"
346 "\tDisable MMC/SD for NAND support\n");
350 ret = davinci_cfg_reg_list(da830_evm_emif25_pins);
352 pr_warn("%s: emif25 mux setup failed: %d\n", __func__, ret);
354 ret = platform_device_register(&da830_evm_aemif_device);
356 pr_warn("%s: AEMIF device not registered\n", __func__);
358 gpio_direction_output(mux_mode, 1);
361 static inline void da830_evm_init_nand(int mux_mode) { }
364 #ifdef CONFIG_DA830_UI_LCD
365 static inline void da830_evm_init_lcdc(int mux_mode)
369 ret = davinci_cfg_reg_list(da830_lcdcntl_pins);
371 pr_warn("%s: lcdcntl mux setup failed: %d\n", __func__, ret);
373 ret = da8xx_register_lcdc(&sharp_lcd035q3dg01_pdata);
375 pr_warn("%s: lcd setup failed: %d\n", __func__, ret);
377 gpio_direction_output(mux_mode, 0);
380 static inline void da830_evm_init_lcdc(int mux_mode) { }
383 static struct nvmem_cell_info da830_evm_nvmem_cells[] = {
391 static struct nvmem_cell_table da830_evm_nvmem_cell_table = {
392 .nvmem_name = "1-00500",
393 .cells = da830_evm_nvmem_cells,
394 .ncells = ARRAY_SIZE(da830_evm_nvmem_cells),
397 static struct nvmem_cell_lookup da830_evm_nvmem_cell_lookup = {
398 .nvmem_name = "1-00500",
399 .cell_name = "macaddr",
400 .dev_id = "davinci_emac.1",
401 .con_id = "mac-address",
404 static const struct property_entry da830_evm_i2c_eeprom_properties[] = {
405 PROPERTY_ENTRY_U32("pagesize", 64),
409 static int __init da830_evm_ui_expander_setup(struct i2c_client *client,
410 int gpio, unsigned ngpio, void *context)
412 gpio_request(gpio + 6, "UI MUX_MODE");
414 /* Drive mux mode low to match the default without UI card */
415 gpio_direction_output(gpio + 6, 0);
417 da830_evm_init_lcdc(gpio + 6);
419 da830_evm_init_nand(gpio + 6);
424 static int da830_evm_ui_expander_teardown(struct i2c_client *client, int gpio,
425 unsigned ngpio, void *context)
431 static struct pcf857x_platform_data __initdata da830_evm_ui_expander_info = {
432 .gpio_base = DAVINCI_N_GPIO,
433 .setup = da830_evm_ui_expander_setup,
434 .teardown = da830_evm_ui_expander_teardown,
437 static struct i2c_board_info __initdata da830_evm_i2c_devices[] = {
439 I2C_BOARD_INFO("24c256", 0x50),
440 .properties = da830_evm_i2c_eeprom_properties,
443 I2C_BOARD_INFO("tlv320aic3x", 0x18),
446 I2C_BOARD_INFO("pcf8574", 0x3f),
447 .platform_data = &da830_evm_ui_expander_info,
451 static struct davinci_i2c_platform_data da830_evm_i2c_0_pdata = {
452 .bus_freq = 100, /* kHz */
453 .bus_delay = 0, /* usec */
457 * The following EDMA channels/slots are not being used by drivers (for
458 * example: Timer, GPIO, UART events etc) on da830/omap-l137 EVM, hence
459 * they are being reserved for codecs on the DSP side.
461 static const s16 da830_dma_rsv_chans[][2] = {
462 /* (offset, number) */
470 static const s16 da830_dma_rsv_slots[][2] = {
471 /* (offset, number) */
479 static struct edma_rsv_info da830_edma_rsv[] = {
481 .rsv_chans = da830_dma_rsv_chans,
482 .rsv_slots = da830_dma_rsv_slots,
486 static struct mtd_partition da830evm_spiflash_part[] = {
491 .mask_flags = MTD_WRITEABLE,
495 .offset = MTDPART_OFS_APPEND,
496 .size = SZ_16K + SZ_8K,
497 .mask_flags = MTD_WRITEABLE,
501 .offset = MTDPART_OFS_APPEND,
502 .size = SZ_256K - SZ_32K,
503 .mask_flags = MTD_WRITEABLE,
506 .name = "U-Boot-Environment",
507 .offset = MTDPART_OFS_APPEND,
513 .offset = MTDPART_OFS_APPEND,
514 .size = MTDPART_SIZ_FULL,
519 static struct flash_platform_data da830evm_spiflash_data = {
521 .parts = da830evm_spiflash_part,
522 .nr_parts = ARRAY_SIZE(da830evm_spiflash_part),
526 static struct davinci_spi_config da830evm_spiflash_cfg = {
527 .io_type = SPI_IO_TYPE_DMA,
532 static struct spi_board_info da830evm_spi_info[] = {
534 .modalias = "m25p80",
535 .platform_data = &da830evm_spiflash_data,
536 .controller_data = &da830evm_spiflash_cfg,
538 .max_speed_hz = 30000000,
544 static __init void da830_evm_init(void)
546 struct davinci_soc_info *soc_info = &davinci_soc_info;
549 da830_register_clocks();
551 ret = da830_register_gpio();
553 pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
555 ret = da830_register_edma(da830_edma_rsv);
557 pr_warn("%s: edma registration failed: %d\n", __func__, ret);
559 ret = davinci_cfg_reg_list(da830_i2c0_pins);
561 pr_warn("%s: i2c0 mux setup failed: %d\n", __func__, ret);
563 ret = da8xx_register_i2c(0, &da830_evm_i2c_0_pdata);
565 pr_warn("%s: i2c0 registration failed: %d\n", __func__, ret);
567 da830_evm_usb_init();
569 soc_info->emac_pdata->rmii_en = 1;
570 soc_info->emac_pdata->phy_id = DA830_EVM_PHY_ID;
572 ret = davinci_cfg_reg_list(da830_cpgmac_pins);
574 pr_warn("%s: cpgmac mux setup failed: %d\n", __func__, ret);
576 ret = da8xx_register_emac();
578 pr_warn("%s: emac registration failed: %d\n", __func__, ret);
580 ret = da8xx_register_watchdog();
582 pr_warn("%s: watchdog registration failed: %d\n",
585 davinci_serial_init(da8xx_serial_device);
587 nvmem_add_cell_table(&da830_evm_nvmem_cell_table);
588 nvmem_add_cell_lookups(&da830_evm_nvmem_cell_lookup, 1);
590 i2c_register_board_info(1, da830_evm_i2c_devices,
591 ARRAY_SIZE(da830_evm_i2c_devices));
593 ret = davinci_cfg_reg_list(da830_evm_mcasp1_pins);
595 pr_warn("%s: mcasp1 mux setup failed: %d\n", __func__, ret);
597 da8xx_register_mcasp(1, &da830_evm_snd_data);
599 da830_evm_init_mmc();
601 ret = da8xx_register_rtc();
603 pr_warn("%s: rtc setup failed: %d\n", __func__, ret);
605 ret = spi_register_board_info(da830evm_spi_info,
606 ARRAY_SIZE(da830evm_spi_info));
608 pr_warn("%s: spi info registration failed: %d\n",
611 ret = da8xx_register_spi_bus(0, ARRAY_SIZE(da830evm_spi_info));
613 pr_warn("%s: spi 0 registration failed: %d\n", __func__, ret);
615 regulator_has_full_constraints();
618 #ifdef CONFIG_SERIAL_8250_CONSOLE
619 static int __init da830_evm_console_init(void)
621 if (!machine_is_davinci_da830_evm())
624 return add_preferred_console("ttyS", 2, "115200");
626 console_initcall(da830_evm_console_init);
629 static void __init da830_evm_map_io(void)
634 MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM")
635 .atag_offset = 0x100,
636 .map_io = da830_evm_map_io,
637 .init_irq = da830_init_irq,
638 .init_time = da830_init_time,
639 .init_machine = da830_evm_init,
640 .init_late = davinci_init_late,
641 .dma_zone_size = SZ_128M,