blob: eb998ce6d46573c0cc77e1d7ebb0dae0a68c6920 [file] [log] [blame]
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -04001/*
2 * TI DA850/OMAP-L138 EVM board
3 *
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * Derived from: arch/arm/mach-davinci/board-da830-evm.c
7 * Original Copyrights follow:
8 *
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.
13 */
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>
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040020#include <linux/gpio.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040021
22#include <asm/mach-types.h>
23#include <asm/mach/arch.h>
24
25#include <mach/common.h>
26#include <mach/irqs.h>
27#include <mach/cp_intc.h>
28#include <mach/da8xx.h>
29
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -040030#define DA850_EVM_PHY_MASK 0x1
31#define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
32
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040033#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
34#define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
35
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -040036#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
37#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
38
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040039static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
40 .bus_freq = 100, /* kHz */
41 .bus_delay = 0, /* usec */
42};
43
44static struct davinci_uart_config da850_evm_uart_config __initdata = {
45 .enabled_uarts = 0x7,
46};
47
Chaithrika U S491214e2009-08-11 17:03:25 -040048/* davinci da850 evm audio machine driver */
49static 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,
54};
55
56static 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,
67};
68
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -040069static int da850_evm_mmc_get_ro(int index)
70{
71 return gpio_get_value(DA850_MMCSD_WP_PIN);
72}
73
74static int da850_evm_mmc_get_cd(int index)
75{
76 return !gpio_get_value(DA850_MMCSD_CD_PIN);
77}
78
79static 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,
84};
85
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040086static int da850_lcd_hw_init(void)
87{
88 int status;
89
90 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
91 if (status < 0)
92 return status;
93
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;
98 }
99
100 gpio_direction_output(DA850_LCD_BL_PIN, 0);
101 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
102
103 /* disable lcd backlight */
104 gpio_set_value(DA850_LCD_BL_PIN, 0);
105
106 /* disable lcd power */
107 gpio_set_value(DA850_LCD_PWR_PIN, 0);
108
109 /* enable lcd power */
110 gpio_set_value(DA850_LCD_PWR_PIN, 1);
111
112 /* enable lcd backlight */
113 gpio_set_value(DA850_LCD_BL_PIN, 1);
114
115 return 0;
116}
Chaithrika U S491214e2009-08-11 17:03:25 -0400117
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400118static __init void da850_evm_init(void)
119{
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400120 struct davinci_soc_info *soc_info = &davinci_soc_info;
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400121 int ret;
122
123 ret = da8xx_register_edma();
124 if (ret)
125 pr_warning("da850_evm_init: edma registration failed: %d\n",
126 ret);
127
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);
132
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);
137
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400138 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;
141
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);
146
147 ret = da8xx_register_emac();
148 if (ret)
149 pr_warning("da850_evm_init: emac registration failed: %d\n",
150 ret);
151
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400152 ret = da8xx_register_watchdog();
153 if (ret)
154 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
155 ret);
156
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400157 ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
158 if (ret)
159 pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
160 ret);
161
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);
167
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);
173
174 ret = da8xx_register_mmcsd0(&da850_mmc_config);
175 if (ret)
176 pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
177 ret);
178
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400179 davinci_serial_init(&da850_evm_uart_config);
180
181 /*
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
185 */
186 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
187 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
Chaithrika U S491214e2009-08-11 17:03:25 -0400188
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);
193
194 da8xx_init_mcasp(0, &da850_evm_snd_data);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400195
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);
200
201 ret = da850_lcd_hw_init();
202 if (ret)
203 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
204 ret);
205
206 ret = da8xx_register_lcdc();
207 if (ret)
208 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
209 ret);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400210}
211
212#ifdef CONFIG_SERIAL_8250_CONSOLE
213static int __init da850_evm_console_init(void)
214{
215 return add_preferred_console("ttyS", 2, "115200");
216}
217console_initcall(da850_evm_console_init);
218#endif
219
220static __init void da850_evm_irq_init(void)
221{
222 struct davinci_soc_info *soc_info = &davinci_soc_info;
223
224 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
225 soc_info->intc_irq_prios);
226}
227
228static void __init da850_evm_map_io(void)
229{
230 da850_init();
231}
232
233MACHINE_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,
241MACHINE_END