davinci: Add NAND flash 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
blob62d37cb6f29d26388290637ffdf0b46da0d566bd
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>
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
47 * (UBL) and U-Boot.
49 struct mtd_partition da850_evm_nandflash_partition[] = {
51 .name = "u-boot env",
52 .offset = 0,
53 .size = SZ_128K,
54 .mask_flags = MTD_WRITEABLE,
57 .name = "UBL",
58 .offset = MTDPART_OFS_APPEND,
59 .size = SZ_128K,
60 .mask_flags = MTD_WRITEABLE,
63 .name = "u-boot",
64 .offset = MTDPART_OFS_APPEND,
65 .size = 4 * SZ_128K,
66 .mask_flags = MTD_WRITEABLE,
69 .name = "kernel",
70 .offset = 0x200000,
71 .size = SZ_2M,
72 .mask_flags = 0,
75 .name = "filesystem",
76 .offset = MTDPART_OFS_APPEND,
77 .size = MTDPART_SIZ_FULL,
78 .mask_flags = 0,
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",
104 .id = 1,
105 .dev = {
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),
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,
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,
159 .wires = 4,
160 .version = MMC_CTLR_VERSION_2,
163 static int da850_lcd_hw_init(void)
165 int status;
167 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
168 if (status < 0)
169 return status;
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;
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);
192 return 0;
195 static __init void da850_evm_init(void)
197 struct davinci_soc_info *soc_info = &davinci_soc_info;
198 int ret;
200 ret = da8xx_pinmux_setup(da850_nand_pins);
201 if (ret)
202 pr_warning("da850_evm_init: nand mux setup failed: %d\n",
203 ret);
205 platform_add_devices(da850_evm_devices,
206 ARRAY_SIZE(da850_evm_devices));
208 ret = da8xx_register_edma();
209 if (ret)
210 pr_warning("da850_evm_init: edma registration failed: %d\n",
211 ret);
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);
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);
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);
228 if (ret)
229 pr_warning("da850_evm_init: cpgmac mux setup failed: %d\n",
230 ret);
232 ret = da8xx_register_emac();
233 if (ret)
234 pr_warning("da850_evm_init: emac registration failed: %d\n",
235 ret);
237 ret = da8xx_register_watchdog();
238 if (ret)
239 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
240 ret);
242 ret = da8xx_pinmux_setup(da850_mmcsd0_pins);
243 if (ret)
244 pr_warning("da850_evm_init: mmcsd0 mux setup failed: %d\n",
245 ret);
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);
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);
259 ret = da8xx_register_mmcsd0(&da850_mmc_config);
260 if (ret)
261 pr_warning("da850_evm_init: mmcsd0 registration failed: %d\n",
262 ret);
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
269 * with arago fs
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);
275 if (ret)
276 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
277 ret);
279 da8xx_init_mcasp(0, &da850_evm_snd_data);
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);
286 ret = da850_lcd_hw_init();
287 if (ret)
288 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
289 ret);
291 ret = da8xx_register_lcdc();
292 if (ret)
293 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
294 ret);
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);
303 #endif
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)
315 da850_init();
318 MACHINE_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,
326 MACHINE_END