davinci: Add MMC/SD support for da850/omap-l138
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-davinci / board-da850-evm.c
blobeb998ce6d46573c0cc77e1d7ebb0dae0a68c6920
1 /*
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
12 * or implied.
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>
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
25 #include <mach/common.h>
26 #include <mach/irqs.h>
27 #include <mach/cp_intc.h>
28 #include <mach/da8xx.h>
30 #define DA850_EVM_PHY_MASK 0x1
31 #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
33 #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
34 #define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
36 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
37 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
39 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
40 .bus_freq = 100, /* kHz */
41 .bus_delay = 0, /* usec */
44 static struct davinci_uart_config da850_evm_uart_config __initdata = {
45 .enabled_uarts = 0x7,
48 /* davinci da850 evm audio machine driver */
49 static u8 da850_iis_serializer_direction[] = {
50 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
51 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
52 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
53 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
56 static struct snd_platform_data da850_evm_snd_data = {
57 .tx_dma_offset = 0x2000,
58 .rx_dma_offset = 0x2000,
59 .op_mode = DAVINCI_MCASP_IIS_MODE,
60 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
61 .tdm_slots = 2,
62 .serial_dir = da850_iis_serializer_direction,
63 .eventq_no = EVENTQ_1,
64 .version = MCASP_VERSION_2,
65 .txnumevt = 1,
66 .rxnumevt = 1,
69 static int da850_evm_mmc_get_ro(int index)
71 return gpio_get_value(DA850_MMCSD_WP_PIN);
74 static int da850_evm_mmc_get_cd(int index)
76 return !gpio_get_value(DA850_MMCSD_CD_PIN);
79 static struct davinci_mmc_config da850_mmc_config = {
80 .get_ro = da850_evm_mmc_get_ro,
81 .get_cd = da850_evm_mmc_get_cd,
82 .wires = 4,
83 .version = MMC_CTLR_VERSION_2,
86 static int da850_lcd_hw_init(void)
88 int status;
90 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
91 if (status < 0)
92 return status;
94 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
95 if (status < 0) {
96 gpio_free(DA850_LCD_BL_PIN);
97 return status;
100 gpio_direction_output(DA850_LCD_BL_PIN, 0);
101 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
103 /* disable lcd backlight */
104 gpio_set_value(DA850_LCD_BL_PIN, 0);
106 /* disable lcd power */
107 gpio_set_value(DA850_LCD_PWR_PIN, 0);
109 /* enable lcd power */
110 gpio_set_value(DA850_LCD_PWR_PIN, 1);
112 /* enable lcd backlight */
113 gpio_set_value(DA850_LCD_BL_PIN, 1);
115 return 0;
118 static __init void da850_evm_init(void)
120 struct davinci_soc_info *soc_info = &davinci_soc_info;
121 int ret;
123 ret = da8xx_register_edma();
124 if (ret)
125 pr_warning("da850_evm_init: edma registration failed: %d\n",
126 ret);
128 ret = da8xx_pinmux_setup(da850_i2c0_pins);
129 if (ret)
130 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
131 ret);
133 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
134 if (ret)
135 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
136 ret);
138 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
139 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
140 soc_info->emac_pdata->rmii_en = 0;
142 ret = da8xx_pinmux_setup(da850_cpgmac_pins);
143 if (ret)
144 pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
145 ret);
147 ret = da8xx_register_emac();
148 if (ret)
149 pr_warning("da850_evm_init: emac registration failed: %d\n",
150 ret);
152 ret = da8xx_register_watchdog();
153 if (ret)
154 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
155 ret);
157 ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
158 if (ret)
159 pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
160 ret);
162 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
163 if (ret)
164 pr_warning("da850_evm_init: can not open GPIO %d\n",
165 DA850_MMCSD_CD_PIN);
166 gpio_direction_input(DA850_MMCSD_CD_PIN);
168 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
169 if (ret)
170 pr_warning("da850_evm_init: can not open GPIO %d\n",
171 DA850_MMCSD_WP_PIN);
172 gpio_direction_input(DA850_MMCSD_WP_PIN);
174 ret = da8xx_register_mmcsd0(&da850_mmc_config);
175 if (ret)
176 pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
177 ret);
179 davinci_serial_init(&da850_evm_uart_config);
182 * shut down uart 0 and 1; they are not used on the board and
183 * accessing them causes endless "too much work in irq53" messages
184 * with arago fs
186 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
187 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
189 ret = da8xx_pinmux_setup(da850_mcasp_pins);
190 if (ret)
191 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
192 ret);
194 da8xx_init_mcasp(0, &da850_evm_snd_data);
196 ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
197 if (ret)
198 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
199 ret);
201 ret = da850_lcd_hw_init();
202 if (ret)
203 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
204 ret);
206 ret = da8xx_register_lcdc();
207 if (ret)
208 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
209 ret);
212 #ifdef CONFIG_SERIAL_8250_CONSOLE
213 static int __init da850_evm_console_init(void)
215 return add_preferred_console("ttyS", 2, "115200");
217 console_initcall(da850_evm_console_init);
218 #endif
220 static __init void da850_evm_irq_init(void)
222 struct davinci_soc_info *soc_info = &davinci_soc_info;
224 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
225 soc_info->intc_irq_prios);
228 static void __init da850_evm_map_io(void)
230 da850_init();
233 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
234 .phys_io = IO_PHYS,
235 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
236 .boot_params = (DA8XX_DDR_BASE + 0x100),
237 .map_io = da850_evm_map_io,
238 .init_irq = da850_evm_irq_init,
239 .timer = &davinci_timer,
240 .init_machine = da850_evm_init,
241 MACHINE_END