2 * TI DA850/OMAP-L138 EVM board
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
6 * Derived from: arch/arm/mach-davinci/board-da830-evm.c
7 * Original Copyrights follow:
9 * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
14 #include <linux/kernel.h>
15 #include <linux/module.h>
16 #include <linux/init.h>
17 #include <linux/console.h>
18 #include <linux/i2c.h>
19 #include <linux/i2c/at24.h>
20 #include <linux/gpio.h>
21 #include <linux/platform_device.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/partitions.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
29 #include <mach/common.h>
30 #include <mach/irqs.h>
31 #include <mach/cp_intc.h>
32 #include <mach/da8xx.h>
33 #include <mach/nand.h>
35 #define DA850_EVM_PHY_MASK 0x1
36 #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
38 #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
39 #define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
41 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
42 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
44 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
45 * (128K blocks). It may be used instead of the (default) SPI flash
46 * to boot, using TI's tools to install the secondary boot loader
49 struct mtd_partition da850_evm_nandflash_partition
[] = {
54 .mask_flags
= MTD_WRITEABLE
,
58 .offset
= MTDPART_OFS_APPEND
,
60 .mask_flags
= MTD_WRITEABLE
,
64 .offset
= MTDPART_OFS_APPEND
,
66 .mask_flags
= MTD_WRITEABLE
,
76 .offset
= MTDPART_OFS_APPEND
,
77 .size
= MTDPART_SIZ_FULL
,
82 static struct davinci_nand_pdata da850_evm_nandflash_data
= {
83 .parts
= da850_evm_nandflash_partition
,
84 .nr_parts
= ARRAY_SIZE(da850_evm_nandflash_partition
),
85 .ecc_mode
= NAND_ECC_HW
,
86 .options
= NAND_USE_FLASH_BBT
,
89 static struct resource da850_evm_nandflash_resource
[] = {
91 .start
= DA8XX_AEMIF_CS3_BASE
,
92 .end
= DA8XX_AEMIF_CS3_BASE
+ SZ_512K
+ 2 * SZ_1K
- 1,
93 .flags
= IORESOURCE_MEM
,
96 .start
= DA8XX_AEMIF_CTL_BASE
,
97 .end
= DA8XX_AEMIF_CTL_BASE
+ SZ_32K
- 1,
98 .flags
= IORESOURCE_MEM
,
102 static struct platform_device da850_evm_nandflash_device
= {
103 .name
= "davinci_nand",
106 .platform_data
= &da850_evm_nandflash_data
,
108 .num_resources
= ARRAY_SIZE(da850_evm_nandflash_resource
),
109 .resource
= da850_evm_nandflash_resource
,
112 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata
= {
113 .bus_freq
= 100, /* kHz */
114 .bus_delay
= 0, /* usec */
117 static struct davinci_uart_config da850_evm_uart_config __initdata
= {
118 .enabled_uarts
= 0x7,
121 static struct platform_device
*da850_evm_devices
[] __initdata
= {
122 &da850_evm_nandflash_device
,
125 /* davinci da850 evm audio machine driver */
126 static u8 da850_iis_serializer_direction
[] = {
127 INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
128 INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
129 INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, TX_MODE
,
130 RX_MODE
, INACTIVE_MODE
, INACTIVE_MODE
, INACTIVE_MODE
,
133 static struct snd_platform_data da850_evm_snd_data
= {
134 .tx_dma_offset
= 0x2000,
135 .rx_dma_offset
= 0x2000,
136 .op_mode
= DAVINCI_MCASP_IIS_MODE
,
137 .num_serializer
= ARRAY_SIZE(da850_iis_serializer_direction
),
139 .serial_dir
= da850_iis_serializer_direction
,
140 .eventq_no
= EVENTQ_1
,
141 .version
= MCASP_VERSION_2
,
146 static int da850_evm_mmc_get_ro(int index
)
148 return gpio_get_value(DA850_MMCSD_WP_PIN
);
151 static int da850_evm_mmc_get_cd(int index
)
153 return !gpio_get_value(DA850_MMCSD_CD_PIN
);
156 static struct davinci_mmc_config da850_mmc_config
= {
157 .get_ro
= da850_evm_mmc_get_ro
,
158 .get_cd
= da850_evm_mmc_get_cd
,
160 .version
= MMC_CTLR_VERSION_2
,
163 static int da850_lcd_hw_init(void)
167 status
= gpio_request(DA850_LCD_BL_PIN
, "lcd bl\n");
171 status
= gpio_request(DA850_LCD_PWR_PIN
, "lcd pwr\n");
173 gpio_free(DA850_LCD_BL_PIN
);
177 gpio_direction_output(DA850_LCD_BL_PIN
, 0);
178 gpio_direction_output(DA850_LCD_PWR_PIN
, 0);
180 /* disable lcd backlight */
181 gpio_set_value(DA850_LCD_BL_PIN
, 0);
183 /* disable lcd power */
184 gpio_set_value(DA850_LCD_PWR_PIN
, 0);
186 /* enable lcd power */
187 gpio_set_value(DA850_LCD_PWR_PIN
, 1);
189 /* enable lcd backlight */
190 gpio_set_value(DA850_LCD_BL_PIN
, 1);
195 static __init
void da850_evm_init(void)
197 struct davinci_soc_info
*soc_info
= &davinci_soc_info
;
200 ret
= da8xx_pinmux_setup(da850_nand_pins
);
202 pr_warning("da850_evm_init: nand mux setup failed: %d\n",
205 platform_add_devices(da850_evm_devices
,
206 ARRAY_SIZE(da850_evm_devices
));
208 ret
= da8xx_register_edma();
210 pr_warning("da850_evm_init: edma registration failed: %d\n",
213 ret
= da8xx_pinmux_setup(da850_i2c0_pins
);
215 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
218 ret
= da8xx_register_i2c(0, &da850_evm_i2c_0_pdata
);
220 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
223 soc_info
->emac_pdata
->phy_mask
= DA850_EVM_PHY_MASK
;
224 soc_info
->emac_pdata
->mdio_max_freq
= DA850_EVM_MDIO_FREQUENCY
;
225 soc_info
->emac_pdata
->rmii_en
= 0;
227 ret
= da8xx_pinmux_setup(da850_cpgmac_pins
);
229 pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
232 ret
= da8xx_register_emac();
234 pr_warning("da850_evm_init: emac registration failed: %d\n",
237 ret
= da8xx_register_watchdog();
239 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
242 ret
= da8xx_pinmux_setup(da850_mmcsd0_pins
);
244 pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
247 ret
= gpio_request(DA850_MMCSD_CD_PIN
, "MMC CD\n");
249 pr_warning("da850_evm_init: can not open GPIO %d\n",
251 gpio_direction_input(DA850_MMCSD_CD_PIN
);
253 ret
= gpio_request(DA850_MMCSD_WP_PIN
, "MMC WP\n");
255 pr_warning("da850_evm_init: can not open GPIO %d\n",
257 gpio_direction_input(DA850_MMCSD_WP_PIN
);
259 ret
= da8xx_register_mmcsd0(&da850_mmc_config
);
261 pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
264 davinci_serial_init(&da850_evm_uart_config
);
267 * shut down uart 0 and 1; they are not used on the board and
268 * accessing them causes endless "too much work in irq53" messages
271 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE
) + 0x30);
272 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE
) + 0x30);
274 ret
= da8xx_pinmux_setup(da850_mcasp_pins
);
276 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
279 da8xx_init_mcasp(0, &da850_evm_snd_data
);
281 ret
= da8xx_pinmux_setup(da850_lcdcntl_pins
);
283 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
286 ret
= da850_lcd_hw_init();
288 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
291 ret
= da8xx_register_lcdc();
293 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
297 #ifdef CONFIG_SERIAL_8250_CONSOLE
298 static int __init
da850_evm_console_init(void)
300 return add_preferred_console("ttyS", 2, "115200");
302 console_initcall(da850_evm_console_init
);
305 static __init
void da850_evm_irq_init(void)
307 struct davinci_soc_info
*soc_info
= &davinci_soc_info
;
309 cp_intc_init((void __iomem
*)DA8XX_CP_INTC_VIRT
, DA850_N_CP_INTC_IRQ
,
310 soc_info
->intc_irq_prios
);
313 static void __init
da850_evm_map_io(void)
318 MACHINE_START(DAVINCI_DA850_EVM
, "DaVinci DA850/OMAP-L138 EVM")
320 .io_pg_offst
= (__IO_ADDRESS(IO_PHYS
) >> 18) & 0xfffc,
321 .boot_params
= (DA8XX_DDR_BASE
+ 0x100),
322 .map_io
= da850_evm_map_io
,
323 .init_irq
= da850_evm_irq_init
,
324 .timer
= &davinci_timer
,
325 .init_machine
= da850_evm_init
,