PRCM: OMAP3: Fix to wrongly modified omap2_clk_wait_ready
[linux-ginger.git] / arch / arm / mach-omap2 / board-omap3evm.c
blobd8109ae087d2a1e2d99a0a8a3be550b415e5d2bd
1 /*
2 * linux/arch/arm/mach-omap2/board-omap3evm.c
4 * Copyright (C) 2008 Texas Instruments
6 * Modified from mach-omap2/board-3430sdp.c
8 * Initial code: Syed Mohammed Khasim
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/err.h>
20 #include <linux/clk.h>
21 #include <linux/io.h>
22 #include <linux/spi/spi.h>
23 #include <linux/spi/ads7846.h>
25 #include <asm/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
30 #include <asm/arch/gpio.h>
31 #include <asm/arch/board.h>
32 #include <asm/arch/hsmmc.h>
33 #include <asm/arch/usb-musb.h>
34 #include <asm/arch/usb-ehci.h>
35 #include <asm/arch/common.h>
36 #include <asm/arch/mcspi.h>
38 static struct resource omap3evm_smc911x_resources[] = {
39 [0] = {
40 .start = OMAP3EVM_ETHR_START,
41 .end = (OMAP3EVM_ETHR_START + OMAP3EVM_ETHR_SIZE - 1),
42 .flags = IORESOURCE_MEM,
44 [1] = {
45 .start = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
46 .end = OMAP_GPIO_IRQ(OMAP3EVM_ETHR_GPIO_IRQ),
47 .flags = IORESOURCE_IRQ,
51 static struct platform_device omap3evm_smc911x_device = {
52 .name = "smc911x",
53 .id = -1,
54 .num_resources = ARRAY_SIZE(omap3evm_smc911x_resources),
55 .resource = &omap3evm_smc911x_resources [0],
58 static inline void __init omap3evm_init_smc911x(void)
60 int eth_cs;
61 struct clk *l3ck;
62 unsigned int rate;
64 eth_cs = OMAP3EVM_SMC911X_CS;
66 l3ck = clk_get(NULL, "l3_ck");
67 if (IS_ERR(l3ck))
68 rate = 100000000;
69 else
70 rate = clk_get_rate(l3ck);
72 if (omap_request_gpio(OMAP3EVM_ETHR_GPIO_IRQ) < 0) {
73 printk(KERN_ERR "Failed to request GPIO%d for smc911x IRQ\n",
74 OMAP3EVM_ETHR_GPIO_IRQ);
75 return;
78 omap_set_gpio_direction(OMAP3EVM_ETHR_GPIO_IRQ, 1);
81 static struct omap_uart_config omap3_evm_uart_config __initdata = {
82 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
85 static int __init omap3_evm_i2c_init(void)
87 omap_register_i2c_bus(1, 2600, NULL, 0);
88 omap_register_i2c_bus(2, 400, NULL, 0);
89 omap_register_i2c_bus(3, 400, NULL, 0);
90 return 0;
93 static struct omap_mmc_config omap3_evm_mmc_config __initdata = {
94 .mmc [0] = {
95 .enabled = 1,
96 .wire4 = 1,
100 static struct platform_device omap3_evm_lcd_device = {
101 .name = "omap3evm_lcd",
102 .id = -1,
105 static struct omap_lcd_config omap3_evm_lcd_config __initdata = {
106 .ctrl_name = "internal",
109 static struct platform_device omap3_evm_twl4030rtc_device = {
110 .name = "twl4030_rtc",
111 .id = -1,
114 static void ads7846_dev_init(void)
116 if (omap_request_gpio(OMAP3_EVM_TS_GPIO) < 0)
117 printk(KERN_ERR "can't get ads7846 pen down GPIO\n");
119 omap_set_gpio_direction(OMAP3_EVM_TS_GPIO, 1);
121 omap_set_gpio_debounce(OMAP3_EVM_TS_GPIO, 1);
122 omap_set_gpio_debounce_time(OMAP3_EVM_TS_GPIO, 0xa);
125 static int ads7846_get_pendown_state(void)
127 return !omap_get_gpio_datain(OMAP3_EVM_TS_GPIO);
130 struct ads7846_platform_data ads7846_config = {
131 .get_pendown_state = ads7846_get_pendown_state,
132 .keep_vref_on = 1,
135 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
136 .turbo_mode = 0,
137 .single_channel = 1, /* 0: slave, 1: master */
140 struct spi_board_info omap3evm_spi_board_info[] = {
141 [0] = {
142 .modalias = "ads7846",
143 .bus_num = 1,
144 .chip_select = 0,
145 .max_speed_hz = 1500000,
146 .controller_data = &ads7846_mcspi_config,
147 .irq = OMAP_GPIO_IRQ(OMAP3_EVM_TS_GPIO),
148 .platform_data = &ads7846_config,
152 static void __init omap3_evm_init_irq(void)
154 omap2_init_common_hw();
155 omap_init_irq();
156 omap_gpio_init();
157 omap3evm_init_smc911x();
160 static struct omap_board_config_kernel omap3_evm_config[] __initdata = {
161 { OMAP_TAG_UART, &omap3_evm_uart_config },
162 { OMAP_TAG_MMC, &omap3_evm_mmc_config },
163 { OMAP_TAG_LCD, &omap3_evm_lcd_config },
166 static struct platform_device *omap3_evm_devices[] __initdata = {
167 &omap3_evm_lcd_device,
168 #ifdef CONFIG_RTC_DRV_TWL4030
169 &omap3_evm_twl4030rtc_device,
170 #endif
171 &omap3evm_smc911x_device,
174 static void __init omap3_evm_init(void)
176 platform_add_devices(omap3_evm_devices, ARRAY_SIZE(omap3_evm_devices));
177 omap_board_config = omap3_evm_config;
178 omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
180 spi_register_board_info(omap3evm_spi_board_info,
181 ARRAY_SIZE(omap3evm_spi_board_info));
183 omap_serial_init();
184 hsmmc_init();
185 usb_musb_init();
186 usb_ehci_init();
187 omap3evm_flash_init();
188 ads7846_dev_init();
191 arch_initcall(omap3_evm_i2c_init);
193 static void __init omap3_evm_map_io(void)
195 omap2_set_globals_343x();
196 omap2_map_common_io();
199 MACHINE_START(OMAP3EVM, "OMAP3 EVM")
200 /* Maintainer: Syed Mohammed Khasim - Texas Instruments */
201 .phys_io = 0x48000000,
202 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
203 .boot_params = 0x80000100,
204 .map_io = omap3_evm_map_io,
205 .init_irq = omap3_evm_init_irq,
206 .init_machine = omap3_evm_init,
207 .timer = &omap_timer,
208 MACHINE_END