blob: 62d37cb6f29d26388290637ffdf0b46da0d566bd [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 Rajashekhara38beb922009-08-13 16:21:11 -040021#include <linux/platform_device.h>
22#include <linux/mtd/mtd.h>
23#include <linux/mtd/nand.h>
24#include <linux/mtd/partitions.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040025
26#include <asm/mach-types.h>
27#include <asm/mach/arch.h>
28
29#include <mach/common.h>
30#include <mach/irqs.h>
31#include <mach/cp_intc.h>
32#include <mach/da8xx.h>
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040033#include <mach/nand.h>
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -040034
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -040035#define DA850_EVM_PHY_MASK 0x1
36#define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
37
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -040038#define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
39#define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
40
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -040041#define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
42#define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
43
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -040044/* 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
47 * (UBL) and U-Boot.
48 */
49struct mtd_partition da850_evm_nandflash_partition[] = {
50 {
51 .name = "u-boot env",
52 .offset = 0,
53 .size = SZ_128K,
54 .mask_flags = MTD_WRITEABLE,
55 },
56 {
57 .name = "UBL",
58 .offset = MTDPART_OFS_APPEND,
59 .size = SZ_128K,
60 .mask_flags = MTD_WRITEABLE,
61 },
62 {
63 .name = "u-boot",
64 .offset = MTDPART_OFS_APPEND,
65 .size = 4 * SZ_128K,
66 .mask_flags = MTD_WRITEABLE,
67 },
68 {
69 .name = "kernel",
70 .offset = 0x200000,
71 .size = SZ_2M,
72 .mask_flags = 0,
73 },
74 {
75 .name = "filesystem",
76 .offset = MTDPART_OFS_APPEND,
77 .size = MTDPART_SIZ_FULL,
78 .mask_flags = 0,
79 },
80};
81
82static 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,
87};
88
89static struct resource da850_evm_nandflash_resource[] = {
90 {
91 .start = DA8XX_AEMIF_CS3_BASE,
92 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
93 .flags = IORESOURCE_MEM,
94 },
95 {
96 .start = DA8XX_AEMIF_CTL_BASE,
97 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
98 .flags = IORESOURCE_MEM,
99 },
100};
101
102static struct platform_device da850_evm_nandflash_device = {
103 .name = "davinci_nand",
104 .id = 1,
105 .dev = {
106 .platform_data = &da850_evm_nandflash_data,
107 },
108 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
109 .resource = da850_evm_nandflash_resource,
110};
111
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400112static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
113 .bus_freq = 100, /* kHz */
114 .bus_delay = 0, /* usec */
115};
116
117static struct davinci_uart_config da850_evm_uart_config __initdata = {
118 .enabled_uarts = 0x7,
119};
120
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400121static struct platform_device *da850_evm_devices[] __initdata = {
122 &da850_evm_nandflash_device,
123};
124
Chaithrika U S491214e2009-08-11 17:03:25 -0400125/* davinci da850 evm audio machine driver */
126static 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,
131};
132
133static 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),
138 .tdm_slots = 2,
139 .serial_dir = da850_iis_serializer_direction,
140 .eventq_no = EVENTQ_1,
141 .version = MCASP_VERSION_2,
142 .txnumevt = 1,
143 .rxnumevt = 1,
144};
145
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400146static int da850_evm_mmc_get_ro(int index)
147{
148 return gpio_get_value(DA850_MMCSD_WP_PIN);
149}
150
151static int da850_evm_mmc_get_cd(int index)
152{
153 return !gpio_get_value(DA850_MMCSD_CD_PIN);
154}
155
156static struct davinci_mmc_config da850_mmc_config = {
157 .get_ro = da850_evm_mmc_get_ro,
158 .get_cd = da850_evm_mmc_get_cd,
159 .wires = 4,
160 .version = MMC_CTLR_VERSION_2,
161};
162
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400163static int da850_lcd_hw_init(void)
164{
165 int status;
166
167 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
168 if (status < 0)
169 return status;
170
171 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
172 if (status < 0) {
173 gpio_free(DA850_LCD_BL_PIN);
174 return status;
175 }
176
177 gpio_direction_output(DA850_LCD_BL_PIN, 0);
178 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
179
180 /* disable lcd backlight */
181 gpio_set_value(DA850_LCD_BL_PIN, 0);
182
183 /* disable lcd power */
184 gpio_set_value(DA850_LCD_PWR_PIN, 0);
185
186 /* enable lcd power */
187 gpio_set_value(DA850_LCD_PWR_PIN, 1);
188
189 /* enable lcd backlight */
190 gpio_set_value(DA850_LCD_BL_PIN, 1);
191
192 return 0;
193}
Chaithrika U S491214e2009-08-11 17:03:25 -0400194
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400195static __init void da850_evm_init(void)
196{
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400197 struct davinci_soc_info *soc_info = &davinci_soc_info;
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400198 int ret;
199
Sudhakar Rajashekhara38beb922009-08-13 16:21:11 -0400200 ret = da8xx_pinmux_setup(da850_nand_pins);
201 if (ret)
202 pr_warning("da850_evm_init: nand mux setup failed: %d\n",
203 ret);
204
205 platform_add_devices(da850_evm_devices,
206 ARRAY_SIZE(da850_evm_devices));
207
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400208 ret = da8xx_register_edma();
209 if (ret)
210 pr_warning("da850_evm_init: edma registration failed: %d\n",
211 ret);
212
213 ret = da8xx_pinmux_setup(da850_i2c0_pins);
214 if (ret)
215 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
216 ret);
217
218 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
219 if (ret)
220 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
221 ret);
222
Sudhakar Rajashekhara5a4b1312009-07-17 04:47:10 -0400223 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;
226
227 ret = da8xx_pinmux_setup(da850_cpgmac_pins);
228 if (ret)
229 pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
230 ret);
231
232 ret = da8xx_register_emac();
233 if (ret)
234 pr_warning("da850_evm_init: emac registration failed: %d\n",
235 ret);
236
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400237 ret = da8xx_register_watchdog();
238 if (ret)
239 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
240 ret);
241
Sudhakar Rajashekhara700691f2009-08-13 15:16:23 -0400242 ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
243 if (ret)
244 pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
245 ret);
246
247 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
248 if (ret)
249 pr_warning("da850_evm_init: can not open GPIO %d\n",
250 DA850_MMCSD_CD_PIN);
251 gpio_direction_input(DA850_MMCSD_CD_PIN);
252
253 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
254 if (ret)
255 pr_warning("da850_evm_init: can not open GPIO %d\n",
256 DA850_MMCSD_WP_PIN);
257 gpio_direction_input(DA850_MMCSD_WP_PIN);
258
259 ret = da8xx_register_mmcsd0(&da850_mmc_config);
260 if (ret)
261 pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
262 ret);
263
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400264 davinci_serial_init(&da850_evm_uart_config);
265
266 /*
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
269 * with arago fs
270 */
271 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
272 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
Chaithrika U S491214e2009-08-11 17:03:25 -0400273
274 ret = da8xx_pinmux_setup(da850_mcasp_pins);
275 if (ret)
276 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
277 ret);
278
279 da8xx_init_mcasp(0, &da850_evm_snd_data);
Sudhakar Rajashekhara5cbdf272009-08-13 14:33:14 -0400280
281 ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
282 if (ret)
283 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
284 ret);
285
286 ret = da850_lcd_hw_init();
287 if (ret)
288 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
289 ret);
290
291 ret = da8xx_register_lcdc();
292 if (ret)
293 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
294 ret);
Sudhakar Rajashekhara0fbc5592009-07-16 06:42:18 -0400295}
296
297#ifdef CONFIG_SERIAL_8250_CONSOLE
298static int __init da850_evm_console_init(void)
299{
300 return add_preferred_console("ttyS", 2, "115200");
301}
302console_initcall(da850_evm_console_init);
303#endif
304
305static __init void da850_evm_irq_init(void)
306{
307 struct davinci_soc_info *soc_info = &davinci_soc_info;
308
309 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
310 soc_info->intc_irq_prios);
311}
312
313static void __init da850_evm_map_io(void)
314{
315 da850_init();
316}
317
318MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
319 .phys_io = IO_PHYS,
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,
326MACHINE_END