xref: /linux/arch/arm/mach-omap1/board-osk.c (revision b0b5aa3f4c17c6a21423b9728d701216ab2e1ff1)
1dbdf9cedSTony Lindgren /*
2dbdf9cedSTony Lindgren  * linux/arch/arm/mach-omap1/board-osk.c
3dbdf9cedSTony Lindgren  *
4dbdf9cedSTony Lindgren  * Board specific init for OMAP5912 OSK
5dbdf9cedSTony Lindgren  *
6dbdf9cedSTony Lindgren  * Written by Dirk Behme <dirk.behme@de.bosch.com>
7dbdf9cedSTony Lindgren  *
8dbdf9cedSTony Lindgren  * This program is free software; you can redistribute it and/or modify it
9dbdf9cedSTony Lindgren  * under the terms of the GNU General Public License as published by the
10dbdf9cedSTony Lindgren  * Free Software Foundation; either version 2 of the License, or (at your
11dbdf9cedSTony Lindgren  * option) any later version.
12dbdf9cedSTony Lindgren  *
13dbdf9cedSTony Lindgren  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
14dbdf9cedSTony Lindgren  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15dbdf9cedSTony Lindgren  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
16dbdf9cedSTony Lindgren  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17dbdf9cedSTony Lindgren  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18dbdf9cedSTony Lindgren  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
19dbdf9cedSTony Lindgren  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20dbdf9cedSTony Lindgren  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21dbdf9cedSTony Lindgren  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22dbdf9cedSTony Lindgren  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23dbdf9cedSTony Lindgren  *
24dbdf9cedSTony Lindgren  * You should have received a copy of the  GNU General Public License along
25dbdf9cedSTony Lindgren  * with this program; if not, write  to the Free Software Foundation, Inc.,
26dbdf9cedSTony Lindgren  * 675 Mass Ave, Cambridge, MA 02139, USA.
27dbdf9cedSTony Lindgren  */
28dbdf9cedSTony Lindgren 
29dbdf9cedSTony Lindgren #include <linux/kernel.h>
30dbdf9cedSTony Lindgren #include <linux/init.h>
31d052d1beSRussell King #include <linux/platform_device.h>
32a524626bSTony Lindgren #include <linux/interrupt.h>
33d533c128SThomas Gleixner #include <linux/irq.h>
348056c6cbSDavid Brownell #include <linux/i2c.h>
35d94577d5SDavid Brownell #include <linux/leds.h>
367c38cf02STony Lindgren 
377c38cf02STony Lindgren #include <linux/mtd/mtd.h>
387c38cf02STony Lindgren #include <linux/mtd/partitions.h>
39dbdf9cedSTony Lindgren 
406d16bfb5SDavid Brownell #include <linux/i2c/tps65010.h>
416d16bfb5SDavid Brownell 
42a09e64fbSRussell King #include <mach/hardware.h>
438056c6cbSDavid Brownell #include <asm/gpio.h>
448056c6cbSDavid Brownell 
45dbdf9cedSTony Lindgren #include <asm/mach-types.h>
46dbdf9cedSTony Lindgren #include <asm/mach/arch.h>
47dbdf9cedSTony Lindgren #include <asm/mach/map.h>
487c38cf02STony Lindgren #include <asm/mach/flash.h>
49dbdf9cedSTony Lindgren 
50a09e64fbSRussell King #include <mach/usb.h>
51a09e64fbSRussell King #include <mach/mux.h>
52a09e64fbSRussell King #include <mach/tc.h>
53a09e64fbSRussell King #include <mach/common.h>
549b6553cdSTony Lindgren 
553a0110cdSTony Lindgren /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */
563a0110cdSTony Lindgren #define OMAP_OSK_ETHR_START		0x04800300
573a0110cdSTony Lindgren 
583a0110cdSTony Lindgren /* TPS65010 has four GPIOs.  nPG and LED2 can be treated like GPIOs with
593a0110cdSTony Lindgren  * alternate pin configurations for hardware-controlled blinking.
603a0110cdSTony Lindgren  */
613a0110cdSTony Lindgren #define OSK_TPS_GPIO_BASE		(OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
623a0110cdSTony Lindgren #	define OSK_TPS_GPIO_USB_PWR_EN	(OSK_TPS_GPIO_BASE + 0)
633a0110cdSTony Lindgren #	define OSK_TPS_GPIO_LED_D3	(OSK_TPS_GPIO_BASE + 1)
643a0110cdSTony Lindgren #	define OSK_TPS_GPIO_LAN_RESET	(OSK_TPS_GPIO_BASE + 2)
653a0110cdSTony Lindgren #	define OSK_TPS_GPIO_DSP_PWR_EN	(OSK_TPS_GPIO_BASE + 3)
663a0110cdSTony Lindgren #	define OSK_TPS_GPIO_LED_D9	(OSK_TPS_GPIO_BASE + 4)
673a0110cdSTony Lindgren #	define OSK_TPS_GPIO_LED_D2	(OSK_TPS_GPIO_BASE + 5)
683a0110cdSTony Lindgren 
697c38cf02STony Lindgren static struct mtd_partition osk_partitions[] = {
707c38cf02STony Lindgren 	/* bootloader (U-Boot, etc) in first sector */
717c38cf02STony Lindgren 	{
727c38cf02STony Lindgren 	      .name		= "bootloader",
737c38cf02STony Lindgren 	      .offset		= 0,
747c38cf02STony Lindgren 	      .size		= SZ_128K,
757c38cf02STony Lindgren 	      .mask_flags	= MTD_WRITEABLE, /* force read-only */
767c38cf02STony Lindgren 	},
777c38cf02STony Lindgren 	/* bootloader params in the next sector */
787c38cf02STony Lindgren 	{
797c38cf02STony Lindgren 	      .name		= "params",
807c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
817c38cf02STony Lindgren 	      .size		= SZ_128K,
827c38cf02STony Lindgren 	      .mask_flags	= 0,
837c38cf02STony Lindgren 	}, {
847c38cf02STony Lindgren 	      .name		= "kernel",
857c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
867c38cf02STony Lindgren 	      .size		= SZ_2M,
877c38cf02STony Lindgren 	      .mask_flags	= 0
887c38cf02STony Lindgren 	}, {
897c38cf02STony Lindgren 	      .name		= "filesystem",
907c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
917c38cf02STony Lindgren 	      .size		= MTDPART_SIZ_FULL,
927c38cf02STony Lindgren 	      .mask_flags	= 0
937c38cf02STony Lindgren 	}
94dbdf9cedSTony Lindgren };
95dbdf9cedSTony Lindgren 
967c38cf02STony Lindgren static struct flash_platform_data osk_flash_data = {
977c38cf02STony Lindgren 	.map_name	= "cfi_probe",
987c38cf02STony Lindgren 	.width		= 2,
997c38cf02STony Lindgren 	.parts		= osk_partitions,
1007c38cf02STony Lindgren 	.nr_parts	= ARRAY_SIZE(osk_partitions),
1017c38cf02STony Lindgren };
1027c38cf02STony Lindgren 
1037c38cf02STony Lindgren static struct resource osk_flash_resource = {
1047c38cf02STony Lindgren 	/* this is on CS3, wherever it's mapped */
1057c38cf02STony Lindgren 	.flags		= IORESOURCE_MEM,
1067c38cf02STony Lindgren };
1077c38cf02STony Lindgren 
1087c38cf02STony Lindgren static struct platform_device osk5912_flash_device = {
1097c38cf02STony Lindgren 	.name		= "omapflash",
1107c38cf02STony Lindgren 	.id		= 0,
1117c38cf02STony Lindgren 	.dev		= {
1127c38cf02STony Lindgren 		.platform_data	= &osk_flash_data,
1137c38cf02STony Lindgren 	},
1147c38cf02STony Lindgren 	.num_resources	= 1,
1157c38cf02STony Lindgren 	.resource	= &osk_flash_resource,
1167c38cf02STony Lindgren };
117dbdf9cedSTony Lindgren 
118dbdf9cedSTony Lindgren static struct resource osk5912_smc91x_resources[] = {
119dbdf9cedSTony Lindgren 	[0] = {
120dbdf9cedSTony Lindgren 		.start	= OMAP_OSK_ETHR_START,		/* Physical */
121dbdf9cedSTony Lindgren 		.end	= OMAP_OSK_ETHR_START + 0xf,
122dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_MEM,
123dbdf9cedSTony Lindgren 	},
124dbdf9cedSTony Lindgren 	[1] = {
125dbdf9cedSTony Lindgren 		.start	= OMAP_GPIO_IRQ(0),
126dbdf9cedSTony Lindgren 		.end	= OMAP_GPIO_IRQ(0),
127e7b3dc7eSRussell King 		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
128dbdf9cedSTony Lindgren 	},
129dbdf9cedSTony Lindgren };
130dbdf9cedSTony Lindgren 
131dbdf9cedSTony Lindgren static struct platform_device osk5912_smc91x_device = {
132dbdf9cedSTony Lindgren 	.name		= "smc91x",
133dbdf9cedSTony Lindgren 	.id		= -1,
134dbdf9cedSTony Lindgren 	.num_resources	= ARRAY_SIZE(osk5912_smc91x_resources),
135dbdf9cedSTony Lindgren 	.resource	= osk5912_smc91x_resources,
136dbdf9cedSTony Lindgren };
137dbdf9cedSTony Lindgren 
138dbdf9cedSTony Lindgren static struct resource osk5912_cf_resources[] = {
139dbdf9cedSTony Lindgren 	[0] = {
140dbdf9cedSTony Lindgren 		.start	= OMAP_GPIO_IRQ(62),
141dbdf9cedSTony Lindgren 		.end	= OMAP_GPIO_IRQ(62),
142dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_IRQ,
143dbdf9cedSTony Lindgren 	},
144dbdf9cedSTony Lindgren };
145dbdf9cedSTony Lindgren 
146dbdf9cedSTony Lindgren static struct platform_device osk5912_cf_device = {
147dbdf9cedSTony Lindgren 	.name		= "omap_cf",
148dbdf9cedSTony Lindgren 	.id		= -1,
149dbdf9cedSTony Lindgren 	.dev = {
150dbdf9cedSTony Lindgren 		.platform_data	= (void *) 2 /* CS2 */,
151dbdf9cedSTony Lindgren 	},
152dbdf9cedSTony Lindgren 	.num_resources	= ARRAY_SIZE(osk5912_cf_resources),
153dbdf9cedSTony Lindgren 	.resource	= osk5912_cf_resources,
154dbdf9cedSTony Lindgren };
155dbdf9cedSTony Lindgren 
156dbdf9cedSTony Lindgren static struct platform_device *osk5912_devices[] __initdata = {
1577c38cf02STony Lindgren 	&osk5912_flash_device,
158dbdf9cedSTony Lindgren 	&osk5912_smc91x_device,
159dbdf9cedSTony Lindgren 	&osk5912_cf_device,
160dbdf9cedSTony Lindgren };
161dbdf9cedSTony Lindgren 
162d94577d5SDavid Brownell static struct gpio_led tps_leds[] = {
163d94577d5SDavid Brownell 	/* NOTE:  D9 and D2 have hardware blink support.
164d94577d5SDavid Brownell 	 * Also, D9 requires non-battery power.
165d94577d5SDavid Brownell 	 */
1665dd81e25SDavid Brownell 	{ .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9",
1675dd81e25SDavid Brownell 			.default_trigger = "ide-disk", },
168d94577d5SDavid Brownell 	{ .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
169d94577d5SDavid Brownell 	{ .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
170d94577d5SDavid Brownell 			.default_trigger = "heartbeat", },
171d94577d5SDavid Brownell };
172d94577d5SDavid Brownell 
173d94577d5SDavid Brownell static struct gpio_led_platform_data tps_leds_data = {
174d94577d5SDavid Brownell 	.num_leds	= 3,
175d94577d5SDavid Brownell 	.leds		= tps_leds,
176d94577d5SDavid Brownell };
177d94577d5SDavid Brownell 
178d94577d5SDavid Brownell static struct platform_device osk5912_tps_leds = {
179d94577d5SDavid Brownell 	.name			= "leds-gpio",
180d94577d5SDavid Brownell 	.id			= 0,
181d94577d5SDavid Brownell 	.dev.platform_data	= &tps_leds_data,
182d94577d5SDavid Brownell };
183d94577d5SDavid Brownell 
184d94577d5SDavid Brownell static int osk_tps_setup(struct i2c_client *client, void *context)
185d94577d5SDavid Brownell {
186d94577d5SDavid Brownell 	/* Set GPIO 1 HIGH to disable VBUS power supply;
187d94577d5SDavid Brownell 	 * OHCI driver powers it up/down as needed.
188d94577d5SDavid Brownell 	 */
189d94577d5SDavid Brownell 	gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
190d94577d5SDavid Brownell 	gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
191d94577d5SDavid Brownell 
192d94577d5SDavid Brownell 	/* Set GPIO 2 high so LED D3 is off by default */
193d94577d5SDavid Brownell 	tps65010_set_gpio_out_value(GPIO2, HIGH);
194d94577d5SDavid Brownell 
195d94577d5SDavid Brownell 	/* Set GPIO 3 low to take ethernet out of reset */
196d94577d5SDavid Brownell 	gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
197d94577d5SDavid Brownell 	gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
198d94577d5SDavid Brownell 
199d94577d5SDavid Brownell 	/* GPIO4 is VDD_DSP */
200d94577d5SDavid Brownell 	gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
201d94577d5SDavid Brownell 	gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
202d94577d5SDavid Brownell 	/* REVISIT if DSP support isn't configured, power it off ... */
203d94577d5SDavid Brownell 
204d94577d5SDavid Brownell 	/* Let LED1 (D9) blink; leds-gpio may override it */
205d94577d5SDavid Brownell 	tps65010_set_led(LED1, BLINK);
206d94577d5SDavid Brownell 
207d94577d5SDavid Brownell 	/* Set LED2 off by default */
208d94577d5SDavid Brownell 	tps65010_set_led(LED2, OFF);
209d94577d5SDavid Brownell 
210d94577d5SDavid Brownell 	/* Enable LOW_PWR handshake */
211d94577d5SDavid Brownell 	tps65010_set_low_pwr(ON);
212d94577d5SDavid Brownell 
213d94577d5SDavid Brownell 	/* Switch VLDO2 to 3.0V for AIC23 */
214d94577d5SDavid Brownell 	tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
215d94577d5SDavid Brownell 			| TPS_LDO1_ENABLE);
216d94577d5SDavid Brownell 
217d94577d5SDavid Brownell 	/* register these three LEDs */
218d94577d5SDavid Brownell 	osk5912_tps_leds.dev.parent = &client->dev;
219d94577d5SDavid Brownell 	platform_device_register(&osk5912_tps_leds);
220d94577d5SDavid Brownell 
221d94577d5SDavid Brownell 	return 0;
222d94577d5SDavid Brownell }
223d94577d5SDavid Brownell 
224d94577d5SDavid Brownell static struct tps65010_board tps_board = {
225d94577d5SDavid Brownell 	.base		= OSK_TPS_GPIO_BASE,
226d94577d5SDavid Brownell 	.outmask	= 0x0f,
227d94577d5SDavid Brownell 	.setup		= osk_tps_setup,
228d94577d5SDavid Brownell };
229d94577d5SDavid Brownell 
2308056c6cbSDavid Brownell static struct i2c_board_info __initdata osk_i2c_board_info[] = {
2318056c6cbSDavid Brownell 	{
2328056c6cbSDavid Brownell 		I2C_BOARD_INFO("tps65010", 0x48),
2338056c6cbSDavid Brownell 		.irq		= OMAP_GPIO_IRQ(OMAP_MPUIO(1)),
234d94577d5SDavid Brownell 		.platform_data	= &tps_board,
235d94577d5SDavid Brownell 
2368056c6cbSDavid Brownell 	},
2379b4a3577SArun KS 	{
2389b4a3577SArun KS 		I2C_BOARD_INFO("tlv320aic23", 0x1B),
2399b4a3577SArun KS 	},
2408056c6cbSDavid Brownell 	/* TODO when driver support is ready:
2418056c6cbSDavid Brownell 	 *  - optionally on Mistral, ov9640 camera sensor at 0x30
2428056c6cbSDavid Brownell 	 */
2438056c6cbSDavid Brownell };
2448056c6cbSDavid Brownell 
245dbdf9cedSTony Lindgren static void __init osk_init_smc91x(void)
246dbdf9cedSTony Lindgren {
247030b1545STony Lindgren 	u32 l;
248030b1545STony Lindgren 
249ac37a0b0SDavid Brownell 	if ((gpio_request(0, "smc_irq")) < 0) {
250dbdf9cedSTony Lindgren 		printk("Error requesting gpio 0 for smc91x irq\n");
251dbdf9cedSTony Lindgren 		return;
252dbdf9cedSTony Lindgren 	}
253dbdf9cedSTony Lindgren 
254dbdf9cedSTony Lindgren 	/* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
255030b1545STony Lindgren 	l = omap_readl(EMIFS_CCS(1));
256030b1545STony Lindgren 	l |= 0x3;
257030b1545STony Lindgren 	omap_writel(l, EMIFS_CCS(1));
258dbdf9cedSTony Lindgren }
259dbdf9cedSTony Lindgren 
260dbdf9cedSTony Lindgren static void __init osk_init_cf(void)
261dbdf9cedSTony Lindgren {
262dbdf9cedSTony Lindgren 	omap_cfg_reg(M7_1610_GPIO62);
263ac37a0b0SDavid Brownell 	if ((gpio_request(62, "cf_irq")) < 0) {
264dbdf9cedSTony Lindgren 		printk("Error requesting gpio 62 for CF irq\n");
265dbdf9cedSTony Lindgren 		return;
266dbdf9cedSTony Lindgren 	}
2677c38cf02STony Lindgren 	/* the CF I/O IRQ is really active-low */
26815f74b03SDavid Brownell 	set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING);
269dbdf9cedSTony Lindgren }
270dbdf9cedSTony Lindgren 
2717c38cf02STony Lindgren static void __init osk_init_irq(void)
272dbdf9cedSTony Lindgren {
27387bd63f6STony Lindgren 	omap1_init_common_hw();
274dbdf9cedSTony Lindgren 	omap_init_irq();
275dbdf9cedSTony Lindgren 	omap_gpio_init();
276dbdf9cedSTony Lindgren 	osk_init_smc91x();
277dbdf9cedSTony Lindgren 	osk_init_cf();
278dbdf9cedSTony Lindgren }
279dbdf9cedSTony Lindgren 
280dbdf9cedSTony Lindgren static struct omap_usb_config osk_usb_config __initdata = {
281dbdf9cedSTony Lindgren 	/* has usb host connector (A) ... for development it can also
282dbdf9cedSTony Lindgren 	 * be used, with a NONSTANDARD gender-bending cable/dongle, as
283dbdf9cedSTony Lindgren 	 * a peripheral.
284dbdf9cedSTony Lindgren 	 */
285dbdf9cedSTony Lindgren #ifdef	CONFIG_USB_GADGET_OMAP
286dbdf9cedSTony Lindgren 	.register_dev	= 1,
287dbdf9cedSTony Lindgren 	.hmc_mode	= 0,
288dbdf9cedSTony Lindgren #else
289dbdf9cedSTony Lindgren 	.register_host	= 1,
290dbdf9cedSTony Lindgren 	.hmc_mode	= 16,
291dbdf9cedSTony Lindgren 	.rwc		= 1,
292dbdf9cedSTony Lindgren #endif
293dbdf9cedSTony Lindgren 	.pins[0]	= 2,
294dbdf9cedSTony Lindgren };
295dbdf9cedSTony Lindgren 
2963179a019STony Lindgren static struct omap_uart_config osk_uart_config __initdata = {
2973179a019STony Lindgren 	.enabled_uarts = (1 << 0),
2983179a019STony Lindgren };
2993179a019STony Lindgren 
30078762841SDavid Brownell #ifdef	CONFIG_OMAP_OSK_MISTRAL
3013179a019STony Lindgren static struct omap_lcd_config osk_lcd_config __initdata = {
3023179a019STony Lindgren 	.ctrl_name	= "internal",
3033179a019STony Lindgren };
30478762841SDavid Brownell #endif
3053179a019STony Lindgren 
306e27a93a9STony Lindgren static struct omap_board_config_kernel osk_config[] __initdata = {
3073179a019STony Lindgren 	{ OMAP_TAG_UART,		&osk_uart_config },
30878762841SDavid Brownell #ifdef	CONFIG_OMAP_OSK_MISTRAL
3093179a019STony Lindgren 	{ OMAP_TAG_LCD,			&osk_lcd_config },
31078762841SDavid Brownell #endif
311dbdf9cedSTony Lindgren };
312dbdf9cedSTony Lindgren 
3137c38cf02STony Lindgren #ifdef	CONFIG_OMAP_OSK_MISTRAL
3147c38cf02STony Lindgren 
31578762841SDavid Brownell #include <linux/input.h>
3162430c62eSDavid Brownell #include <linux/i2c/at24.h>
31778762841SDavid Brownell #include <linux/spi/spi.h>
31878762841SDavid Brownell #include <linux/spi/ads7846.h>
31978762841SDavid Brownell 
320a09e64fbSRussell King #include <mach/keypad.h>
32178762841SDavid Brownell 
3222430c62eSDavid Brownell static struct at24_platform_data at24c04 = {
3232430c62eSDavid Brownell 	.byte_len	= SZ_4K / 8,
3242430c62eSDavid Brownell 	.page_size	= 16,
3252430c62eSDavid Brownell };
3262430c62eSDavid Brownell 
3272430c62eSDavid Brownell static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
3282430c62eSDavid Brownell 	{
3292430c62eSDavid Brownell 		/* NOTE:  powered from LCD supply */
3302430c62eSDavid Brownell 		I2C_BOARD_INFO("24c04", 0x50),
3312430c62eSDavid Brownell 		.platform_data	= &at24c04,
3322430c62eSDavid Brownell 	},
3332430c62eSDavid Brownell 	/* TODO when driver support is ready:
3342430c62eSDavid Brownell 	 *  - optionally ov9640 camera sensor at 0x30
3352430c62eSDavid Brownell 	 */
3362430c62eSDavid Brownell };
3372430c62eSDavid Brownell 
33878762841SDavid Brownell static const int osk_keymap[] = {
33978762841SDavid Brownell 	/* KEY(col, row, code) */
34078762841SDavid Brownell 	KEY(0, 0, KEY_F1),		/* SW4 */
34178762841SDavid Brownell 	KEY(0, 3, KEY_UP),		/* (sw2/up) */
34278762841SDavid Brownell 	KEY(1, 1, KEY_LEFTCTRL),	/* SW5 */
34378762841SDavid Brownell 	KEY(1, 2, KEY_LEFT),		/* (sw2/left) */
34478762841SDavid Brownell 	KEY(2, 0, KEY_SPACE),		/* SW3 */
34578762841SDavid Brownell 	KEY(2, 1, KEY_ESC),		/* SW6 */
34678762841SDavid Brownell 	KEY(2, 2, KEY_DOWN),		/* (sw2/down) */
34778762841SDavid Brownell 	KEY(3, 2, KEY_ENTER),		/* (sw2/select) */
34878762841SDavid Brownell 	KEY(3, 3, KEY_RIGHT),		/* (sw2/right) */
34978762841SDavid Brownell 	0
35078762841SDavid Brownell };
35178762841SDavid Brownell 
35278762841SDavid Brownell static struct omap_kp_platform_data osk_kp_data = {
35378762841SDavid Brownell 	.rows		= 8,
35478762841SDavid Brownell 	.cols		= 8,
35578762841SDavid Brownell 	.keymap		= (int *) osk_keymap,
3564d24607bSKomal Shah 	.keymapsize	= ARRAY_SIZE(osk_keymap),
3574d24607bSKomal Shah 	.delay		= 9,
35878762841SDavid Brownell };
35978762841SDavid Brownell 
36078762841SDavid Brownell static struct resource osk5912_kp_resources[] = {
36178762841SDavid Brownell 	[0] = {
36278762841SDavid Brownell 		.start	= INT_KEYBOARD,
36378762841SDavid Brownell 		.end	= INT_KEYBOARD,
36478762841SDavid Brownell 		.flags	= IORESOURCE_IRQ,
36578762841SDavid Brownell 	},
36678762841SDavid Brownell };
36778762841SDavid Brownell 
36878762841SDavid Brownell static struct platform_device osk5912_kp_device = {
36978762841SDavid Brownell 	.name		= "omap-keypad",
37078762841SDavid Brownell 	.id		= -1,
37178762841SDavid Brownell 	.dev		= {
37278762841SDavid Brownell 		.platform_data = &osk_kp_data,
37378762841SDavid Brownell 	},
37478762841SDavid Brownell 	.num_resources	= ARRAY_SIZE(osk5912_kp_resources),
37578762841SDavid Brownell 	.resource	= osk5912_kp_resources,
37678762841SDavid Brownell };
37778762841SDavid Brownell 
3784dcc6d24SDavid Brownell static struct omap_backlight_config mistral_bl_data = {
3794dcc6d24SDavid Brownell 	.default_intensity	= 0xa0,
3804dcc6d24SDavid Brownell };
3814dcc6d24SDavid Brownell 
3824dcc6d24SDavid Brownell static struct platform_device mistral_bl_device = {
3834dcc6d24SDavid Brownell 	.name		= "omap-bl",
3844dcc6d24SDavid Brownell 	.id		= -1,
3854dcc6d24SDavid Brownell 	.dev		= {
3864dcc6d24SDavid Brownell 		.platform_data = &mistral_bl_data,
3874dcc6d24SDavid Brownell 	},
3884dcc6d24SDavid Brownell };
3894dcc6d24SDavid Brownell 
39078762841SDavid Brownell static struct platform_device osk5912_lcd_device = {
39178762841SDavid Brownell 	.name		= "lcd_osk",
39278762841SDavid Brownell 	.id		= -1,
39378762841SDavid Brownell };
39478762841SDavid Brownell 
39578762841SDavid Brownell static struct platform_device *mistral_devices[] __initdata = {
39678762841SDavid Brownell 	&osk5912_kp_device,
3974dcc6d24SDavid Brownell 	&mistral_bl_device,
39878762841SDavid Brownell 	&osk5912_lcd_device,
39978762841SDavid Brownell };
40078762841SDavid Brownell 
401e8cdf7bdSDavid Brownell static int mistral_get_pendown_state(void)
402e8cdf7bdSDavid Brownell {
403ac37a0b0SDavid Brownell 	return !gpio_get_value(4);
404e8cdf7bdSDavid Brownell }
405e8cdf7bdSDavid Brownell 
40678762841SDavid Brownell static const struct ads7846_platform_data mistral_ts_info = {
40778762841SDavid Brownell 	.model			= 7846,
40878762841SDavid Brownell 	.vref_delay_usecs	= 100,	/* internal, no capacitor */
40978762841SDavid Brownell 	.x_plate_ohms		= 419,
41078762841SDavid Brownell 	.y_plate_ohms		= 486,
411e8cdf7bdSDavid Brownell 	.get_pendown_state	= mistral_get_pendown_state,
41278762841SDavid Brownell };
41378762841SDavid Brownell 
41478762841SDavid Brownell static struct spi_board_info __initdata mistral_boardinfo[] = { {
41578762841SDavid Brownell 	/* MicroWire (bus 2) CS0 has an ads7846e */
41678762841SDavid Brownell 	.modalias		= "ads7846",
41778762841SDavid Brownell 	.platform_data		= &mistral_ts_info,
41878762841SDavid Brownell 	.irq			= OMAP_GPIO_IRQ(4),
41978762841SDavid Brownell 	.max_speed_hz		= 120000 /* max sample rate at 3V */
42078762841SDavid Brownell 					* 26 /* command + data + overhead */,
42178762841SDavid Brownell 	.bus_num		= 2,
42278762841SDavid Brownell 	.chip_select		= 0,
42378762841SDavid Brownell } };
42478762841SDavid Brownell 
4257c38cf02STony Lindgren #ifdef	CONFIG_PM
4267c38cf02STony Lindgren static irqreturn_t
4270cd61b68SLinus Torvalds osk_mistral_wake_interrupt(int irq, void *ignored)
4287c38cf02STony Lindgren {
4297c38cf02STony Lindgren 	return IRQ_HANDLED;
4307c38cf02STony Lindgren }
4317c38cf02STony Lindgren #endif
4327c38cf02STony Lindgren 
4337c38cf02STony Lindgren static void __init osk_mistral_init(void)
4347c38cf02STony Lindgren {
43578762841SDavid Brownell 	/* NOTE:  we could actually tell if there's a Mistral board
4367c38cf02STony Lindgren 	 * attached, e.g. by trying to read something from the ads7846.
43778762841SDavid Brownell 	 * But this arch_init() code is too early for that, since we
43878762841SDavid Brownell 	 * can't talk to the ads or even the i2c eeprom.
4397c38cf02STony Lindgren 	 */
4407c38cf02STony Lindgren 
441c72d8950SDavid Brownell 	/* parallel camera interface */
442c72d8950SDavid Brownell 	omap_cfg_reg(J15_1610_CAM_LCLK);
443c72d8950SDavid Brownell 	omap_cfg_reg(J18_1610_CAM_D7);
444c72d8950SDavid Brownell 	omap_cfg_reg(J19_1610_CAM_D6);
445c72d8950SDavid Brownell 	omap_cfg_reg(J14_1610_CAM_D5);
446c72d8950SDavid Brownell 	omap_cfg_reg(K18_1610_CAM_D4);
447c72d8950SDavid Brownell 	omap_cfg_reg(K19_1610_CAM_D3);
448c72d8950SDavid Brownell 	omap_cfg_reg(K15_1610_CAM_D2);
449c72d8950SDavid Brownell 	omap_cfg_reg(K14_1610_CAM_D1);
450c72d8950SDavid Brownell 	omap_cfg_reg(L19_1610_CAM_D0);
451c72d8950SDavid Brownell 	omap_cfg_reg(L18_1610_CAM_VS);
452c72d8950SDavid Brownell 	omap_cfg_reg(L15_1610_CAM_HS);
453c72d8950SDavid Brownell 	omap_cfg_reg(M19_1610_CAM_RSTZ);
454c72d8950SDavid Brownell 	omap_cfg_reg(Y15_1610_CAM_OUTCLK);
455c72d8950SDavid Brownell 
456c72d8950SDavid Brownell 	/* serial camera interface */
457c72d8950SDavid Brownell 	omap_cfg_reg(H19_1610_CAM_EXCLK);
458c72d8950SDavid Brownell 	omap_cfg_reg(W13_1610_CCP_CLKM);
459c72d8950SDavid Brownell 	omap_cfg_reg(Y12_1610_CCP_CLKP);
460c72d8950SDavid Brownell 	/* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
4616e2d4107SDavid Cohen 	/* omap_cfg_reg(Y14_1610_CCP_DATAM); */
462c72d8950SDavid Brownell 	omap_cfg_reg(W14_1610_CCP_DATAP);
463c72d8950SDavid Brownell 
464c72d8950SDavid Brownell 	/* CAM_PWDN */
465ac37a0b0SDavid Brownell 	if (gpio_request(11, "cam_pwdn") == 0) {
466c72d8950SDavid Brownell 		omap_cfg_reg(N20_1610_GPIO11);
467ac37a0b0SDavid Brownell 		gpio_direction_output(11, 0);
468c72d8950SDavid Brownell 	} else
469c72d8950SDavid Brownell 		pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
470c72d8950SDavid Brownell 
471c72d8950SDavid Brownell 
4726e2d4107SDavid Cohen 	/* omap_cfg_reg(P19_1610_GPIO6); */	/* BUSY */
473ac37a0b0SDavid Brownell 	gpio_request(6, "ts_busy");
474ac37a0b0SDavid Brownell 	gpio_direction_input(6);
475ac37a0b0SDavid Brownell 
4766e2d4107SDavid Cohen 	omap_cfg_reg(P20_1610_GPIO4);	/* PENIRQ */
477ac37a0b0SDavid Brownell 	gpio_request(4, "ts_int");
478ac37a0b0SDavid Brownell 	gpio_direction_input(4);
47915f74b03SDavid Brownell 	set_irq_type(gpio_to_irq(4), IRQ_TYPE_EDGE_FALLING);
480ac37a0b0SDavid Brownell 
48178762841SDavid Brownell 	spi_register_board_info(mistral_boardinfo,
48278762841SDavid Brownell 			ARRAY_SIZE(mistral_boardinfo));
48378762841SDavid Brownell 
4842430c62eSDavid Brownell 	/* the sideways button (SW1) is for use as a "wakeup" button
4852430c62eSDavid Brownell 	 *
4862430c62eSDavid Brownell 	 * NOTE:  The Mistral board has the wakeup button (SW1) wired
4872430c62eSDavid Brownell 	 * to the LCD 3.3V rail, which is powered down during suspend.
4882430c62eSDavid Brownell 	 * To allow this button to wake up the omap, work around this
4892430c62eSDavid Brownell 	 * HW bug by rewiring SW1 to use the main 3.3V rail.
4902430c62eSDavid Brownell 	 */
4917c38cf02STony Lindgren 	omap_cfg_reg(N15_1610_MPUIO2);
492ac37a0b0SDavid Brownell 	if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) {
4937c38cf02STony Lindgren 		int ret = 0;
49415f74b03SDavid Brownell 		int irq = gpio_to_irq(OMAP_MPUIO(2));
495ac37a0b0SDavid Brownell 
496ac37a0b0SDavid Brownell 		gpio_direction_input(OMAP_MPUIO(2));
49715f74b03SDavid Brownell 		set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
4987c38cf02STony Lindgren #ifdef	CONFIG_PM
4997c38cf02STony Lindgren 		/* share the IRQ in case someone wants to use the
5007c38cf02STony Lindgren 		 * button for more than wakeup from system sleep.
5017c38cf02STony Lindgren 		 */
50215f74b03SDavid Brownell 		ret = request_irq(irq,
5037c38cf02STony Lindgren 				&osk_mistral_wake_interrupt,
50452e405eaSThomas Gleixner 				IRQF_SHARED, "mistral_wakeup",
5057c38cf02STony Lindgren 				&osk_mistral_wake_interrupt);
5067c38cf02STony Lindgren 		if (ret != 0) {
507ac37a0b0SDavid Brownell 			gpio_free(OMAP_MPUIO(2));
5087c38cf02STony Lindgren 			printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
5097c38cf02STony Lindgren 				ret);
5107c38cf02STony Lindgren 		} else
51115f74b03SDavid Brownell 			enable_irq_wake(irq);
5127c38cf02STony Lindgren #endif
5137c38cf02STony Lindgren 	} else
5147c38cf02STony Lindgren 		printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
51578762841SDavid Brownell 
5164dcc6d24SDavid Brownell 	/* LCD:  backlight, and power; power controls other devices on the
5174dcc6d24SDavid Brownell 	 * board, like the touchscreen, EEPROM, and wakeup (!) switch.
5184dcc6d24SDavid Brownell 	 */
5194dcc6d24SDavid Brownell 	omap_cfg_reg(PWL);
520ac37a0b0SDavid Brownell 	if (gpio_request(2, "lcd_pwr") == 0)
521ac37a0b0SDavid Brownell 		gpio_direction_output(2, 1);
5224dcc6d24SDavid Brownell 
5232430c62eSDavid Brownell 	i2c_register_board_info(1, mistral_i2c_board_info,
5242430c62eSDavid Brownell 			ARRAY_SIZE(mistral_i2c_board_info));
5252430c62eSDavid Brownell 
52678762841SDavid Brownell 	platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
5277c38cf02STony Lindgren }
5287c38cf02STony Lindgren #else
5297c38cf02STony Lindgren static void __init osk_mistral_init(void) { }
5307c38cf02STony Lindgren #endif
5317c38cf02STony Lindgren 
5329b6553cdSTony Lindgren #define EMIFS_CS3_VAL	(0x88013141)
5339b6553cdSTony Lindgren 
534dbdf9cedSTony Lindgren static void __init osk_init(void)
535dbdf9cedSTony Lindgren {
536030b1545STony Lindgren 	u32 l;
537030b1545STony Lindgren 
5389b6553cdSTony Lindgren 	/* Workaround for wrong CS3 (NOR flash) timing
5399b6553cdSTony Lindgren 	 * There are some U-Boot versions out there which configure
5409b6553cdSTony Lindgren 	 * wrong CS3 memory timings. This mainly leads to CRC
5416cbdc8c5SSimon Arlott 	 * or similar errors if you use NOR flash (e.g. with JFFS2)
5429b6553cdSTony Lindgren 	 */
543030b1545STony Lindgren 	l = omap_readl(EMIFS_CCS(3));
544030b1545STony Lindgren 	if (l != EMIFS_CS3_VAL)
545030b1545STony Lindgren 		omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3));
5469b6553cdSTony Lindgren 
5477c38cf02STony Lindgren 	osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
5487c38cf02STony Lindgren 	osk_flash_resource.end += SZ_32M - 1;
549dbdf9cedSTony Lindgren 	platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
550dbdf9cedSTony Lindgren 	omap_board_config = osk_config;
551dbdf9cedSTony Lindgren 	omap_board_config_size = ARRAY_SIZE(osk_config);
552f35ae634STony Lindgren 
553f35ae634STony Lindgren 	l = omap_readl(USB_TRANSCEIVER_CTRL);
554f35ae634STony Lindgren 	l |= (3 << 1);
555f35ae634STony Lindgren 	omap_writel(l, USB_TRANSCEIVER_CTRL);
5567c38cf02STony Lindgren 
557*b0b5aa3fSFelipe Balbi 	omap_usb_init(&osk_usb_config);
558*b0b5aa3fSFelipe Balbi 
5598056c6cbSDavid Brownell 	/* irq for tps65010 chip */
5608056c6cbSDavid Brownell 	/* bootloader effectively does:  omap_cfg_reg(U19_1610_MPUIO1); */
5618056c6cbSDavid Brownell 	if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
5628056c6cbSDavid Brownell 		gpio_direction_input(OMAP_MPUIO(1));
5638056c6cbSDavid Brownell 
5643179a019STony Lindgren 	omap_serial_init();
5651ed16a86SJarkko Nikula 	omap_register_i2c_bus(1, 400, osk_i2c_board_info,
5661ed16a86SJarkko Nikula 			      ARRAY_SIZE(osk_i2c_board_info));
5677c38cf02STony Lindgren 	osk_mistral_init();
568dbdf9cedSTony Lindgren }
569dbdf9cedSTony Lindgren 
570dbdf9cedSTony Lindgren static void __init osk_map_io(void)
571dbdf9cedSTony Lindgren {
57287bd63f6STony Lindgren 	omap1_map_common_io();
573dbdf9cedSTony Lindgren }
574dbdf9cedSTony Lindgren 
575dbdf9cedSTony Lindgren MACHINE_START(OMAP_OSK, "TI-OSK")
576dbdf9cedSTony Lindgren 	/* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
577dbdf9cedSTony Lindgren 	.phys_io	= 0xfff00000,
578dbdf9cedSTony Lindgren 	.io_pg_offst	= ((0xfef00000) >> 18) & 0xfffc,
579dbdf9cedSTony Lindgren 	.boot_params	= 0x10000100,
580dbdf9cedSTony Lindgren 	.map_io		= osk_map_io,
581dbdf9cedSTony Lindgren 	.init_irq	= osk_init_irq,
582dbdf9cedSTony Lindgren 	.init_machine	= osk_init,
583dbdf9cedSTony Lindgren 	.timer		= &omap_timer,
584dbdf9cedSTony Lindgren MACHINE_END
585