davinci: Add NOR flash support for da850/omap-l138
[linux-2.6/libata-dev.git] / arch / arm / mach-davinci / board-da850-evm.c
blob70a2f487da95219f2e0be45d54c9704bf67304ed
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>
21 #include <linux/platform_device.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/nand.h>
24 #include <linux/mtd/partitions.h>
25 #include <linux/mtd/physmap.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
30 #include <mach/common.h>
31 #include <mach/irqs.h>
32 #include <mach/cp_intc.h>
33 #include <mach/da8xx.h>
34 #include <mach/nand.h>
36 #define DA850_EVM_PHY_MASK 0x1
37 #define DA850_EVM_MDIO_FREQUENCY 2200000 /* PHY bus frequency */
39 #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
40 #define DA850_LCD_PWR_PIN GPIO_TO_PIN(8, 10)
42 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
43 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
45 static struct mtd_partition da850_evm_norflash_partition[] = {
47 .name = "NOR filesystem",
48 .offset = 0,
49 .size = MTDPART_SIZ_FULL,
50 .mask_flags = 0,
54 static struct physmap_flash_data da850_evm_norflash_data = {
55 .width = 2,
56 .parts = da850_evm_norflash_partition,
57 .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
60 static struct resource da850_evm_norflash_resource[] = {
62 .start = DA8XX_AEMIF_CS2_BASE,
63 .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
64 .flags = IORESOURCE_MEM,
68 static struct platform_device da850_evm_norflash_device = {
69 .name = "physmap-flash",
70 .id = 0,
71 .dev = {
72 .platform_data = &da850_evm_norflash_data,
74 .num_resources = 1,
75 .resource = da850_evm_norflash_resource,
78 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
79 * (128K blocks). It may be used instead of the (default) SPI flash
80 * to boot, using TI's tools to install the secondary boot loader
81 * (UBL) and U-Boot.
83 struct mtd_partition da850_evm_nandflash_partition[] = {
85 .name = "u-boot env",
86 .offset = 0,
87 .size = SZ_128K,
88 .mask_flags = MTD_WRITEABLE,
91 .name = "UBL",
92 .offset = MTDPART_OFS_APPEND,
93 .size = SZ_128K,
94 .mask_flags = MTD_WRITEABLE,
97 .name = "u-boot",
98 .offset = MTDPART_OFS_APPEND,
99 .size = 4 * SZ_128K,
100 .mask_flags = MTD_WRITEABLE,
103 .name = "kernel",
104 .offset = 0x200000,
105 .size = SZ_2M,
106 .mask_flags = 0,
109 .name = "filesystem",
110 .offset = MTDPART_OFS_APPEND,
111 .size = MTDPART_SIZ_FULL,
112 .mask_flags = 0,
116 static struct davinci_nand_pdata da850_evm_nandflash_data = {
117 .parts = da850_evm_nandflash_partition,
118 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
119 .ecc_mode = NAND_ECC_HW,
120 .options = NAND_USE_FLASH_BBT,
123 static struct resource da850_evm_nandflash_resource[] = {
125 .start = DA8XX_AEMIF_CS3_BASE,
126 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
127 .flags = IORESOURCE_MEM,
130 .start = DA8XX_AEMIF_CTL_BASE,
131 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
132 .flags = IORESOURCE_MEM,
136 static struct platform_device da850_evm_nandflash_device = {
137 .name = "davinci_nand",
138 .id = 1,
139 .dev = {
140 .platform_data = &da850_evm_nandflash_data,
142 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
143 .resource = da850_evm_nandflash_resource,
146 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
147 .bus_freq = 100, /* kHz */
148 .bus_delay = 0, /* usec */
151 static struct davinci_uart_config da850_evm_uart_config __initdata = {
152 .enabled_uarts = 0x7,
155 static struct platform_device *da850_evm_devices[] __initdata = {
156 &da850_evm_nandflash_device,
157 &da850_evm_norflash_device,
160 /* davinci da850 evm audio machine driver */
161 static u8 da850_iis_serializer_direction[] = {
162 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
163 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
164 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
165 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
168 static struct snd_platform_data da850_evm_snd_data = {
169 .tx_dma_offset = 0x2000,
170 .rx_dma_offset = 0x2000,
171 .op_mode = DAVINCI_MCASP_IIS_MODE,
172 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
173 .tdm_slots = 2,
174 .serial_dir = da850_iis_serializer_direction,
175 .eventq_no = EVENTQ_1,
176 .version = MCASP_VERSION_2,
177 .txnumevt = 1,
178 .rxnumevt = 1,
181 static int da850_evm_mmc_get_ro(int index)
183 return gpio_get_value(DA850_MMCSD_WP_PIN);
186 static int da850_evm_mmc_get_cd(int index)
188 return !gpio_get_value(DA850_MMCSD_CD_PIN);
191 static struct davinci_mmc_config da850_mmc_config = {
192 .get_ro = da850_evm_mmc_get_ro,
193 .get_cd = da850_evm_mmc_get_cd,
194 .wires = 4,
195 .version = MMC_CTLR_VERSION_2,
198 static int da850_lcd_hw_init(void)
200 int status;
202 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
203 if (status < 0)
204 return status;
206 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
207 if (status < 0) {
208 gpio_free(DA850_LCD_BL_PIN);
209 return status;
212 gpio_direction_output(DA850_LCD_BL_PIN, 0);
213 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
215 /* disable lcd backlight */
216 gpio_set_value(DA850_LCD_BL_PIN, 0);
218 /* disable lcd power */
219 gpio_set_value(DA850_LCD_PWR_PIN, 0);
221 /* enable lcd power */
222 gpio_set_value(DA850_LCD_PWR_PIN, 1);
224 /* enable lcd backlight */
225 gpio_set_value(DA850_LCD_BL_PIN, 1);
227 return 0;
230 #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
231 #define DA8XX_AEMIF_ASIZE_16BIT 0x1
233 static void __init da850_evm_init_nor(void)
235 void __iomem *aemif_addr;
237 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
239 /* Configure data bus width of CS2 to 16 bit */
240 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
241 DA8XX_AEMIF_ASIZE_16BIT,
242 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
244 iounmap(aemif_addr);
247 static __init void da850_evm_init(void)
249 struct davinci_soc_info *soc_info = &davinci_soc_info;
250 int ret;
252 ret = da8xx_pinmux_setup(da850_nand_pins);
253 if (ret)
254 pr_warning("da850_evm_init: nand mux setup failed: %d\n",
255 ret);
257 ret = da8xx_pinmux_setup(da850_nor_pins);
258 if (ret)
259 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
260 ret);
262 da850_evm_init_nor();
264 platform_add_devices(da850_evm_devices,
265 ARRAY_SIZE(da850_evm_devices));
267 ret = da8xx_register_edma();
268 if (ret)
269 pr_warning("da850_evm_init: edma registration failed: %d\n",
270 ret);
272 ret = da8xx_pinmux_setup(da850_i2c0_pins);
273 if (ret)
274 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
275 ret);
277 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
278 if (ret)
279 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
280 ret);
282 soc_info->emac_pdata->phy_mask = DA850_EVM_PHY_MASK;
283 soc_info->emac_pdata->mdio_max_freq = DA850_EVM_MDIO_FREQUENCY;
284 soc_info->emac_pdata->rmii_en = 0;
286 ret = da8xx_pinmux_setup(da850_cpgmac_pins);
287 if (ret)
288 pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
289 ret);
291 ret = da8xx_register_emac();
292 if (ret)
293 pr_warning("da850_evm_init: emac registration failed: %d\n",
294 ret);
296 ret = da8xx_register_watchdog();
297 if (ret)
298 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
299 ret);
301 ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
302 if (ret)
303 pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
304 ret);
306 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
307 if (ret)
308 pr_warning("da850_evm_init: can not open GPIO %d\n",
309 DA850_MMCSD_CD_PIN);
310 gpio_direction_input(DA850_MMCSD_CD_PIN);
312 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
313 if (ret)
314 pr_warning("da850_evm_init: can not open GPIO %d\n",
315 DA850_MMCSD_WP_PIN);
316 gpio_direction_input(DA850_MMCSD_WP_PIN);
318 ret = da8xx_register_mmcsd0(&da850_mmc_config);
319 if (ret)
320 pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
321 ret);
323 davinci_serial_init(&da850_evm_uart_config);
326 * shut down uart 0 and 1; they are not used on the board and
327 * accessing them causes endless "too much work in irq53" messages
328 * with arago fs
330 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
331 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
333 ret = da8xx_pinmux_setup(da850_mcasp_pins);
334 if (ret)
335 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
336 ret);
338 da8xx_init_mcasp(0, &da850_evm_snd_data);
340 ret = da8xx_pinmux_setup(da850_lcdcntl_pins);
341 if (ret)
342 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
343 ret);
345 ret = da850_lcd_hw_init();
346 if (ret)
347 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
348 ret);
350 ret = da8xx_register_lcdc();
351 if (ret)
352 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
353 ret);
356 #ifdef CONFIG_SERIAL_8250_CONSOLE
357 static int __init da850_evm_console_init(void)
359 return add_preferred_console("ttyS", 2, "115200");
361 console_initcall(da850_evm_console_init);
362 #endif
364 static __init void da850_evm_irq_init(void)
366 struct davinci_soc_info *soc_info = &davinci_soc_info;
368 cp_intc_init((void __iomem *)DA8XX_CP_INTC_VIRT, DA850_N_CP_INTC_IRQ,
369 soc_info->intc_irq_prios);
372 static void __init da850_evm_map_io(void)
374 da850_init();
377 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138 EVM")
378 .phys_io = IO_PHYS,
379 .io_pg_offst = (__IO_ADDRESS(IO_PHYS) >> 18) & 0xfffc,
380 .boot_params = (DA8XX_DDR_BASE + 0x100),
381 .map_io = da850_evm_map_io,
382 .init_irq = da850_evm_irq_init,
383 .timer = &davinci_timer,
384 .init_machine = da850_evm_init,
385 MACHINE_END