xref: /linux/arch/arm/mach-omap1/board-osk.c (revision d94577d5a581fe55c46b5b82eee733b8d053db19)
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>
35*d94577d5SDavid 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 
42dbdf9cedSTony Lindgren #include <asm/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 
50dbdf9cedSTony Lindgren #include <asm/arch/usb.h>
51dbdf9cedSTony Lindgren #include <asm/arch/mux.h>
52dbdf9cedSTony Lindgren #include <asm/arch/tc.h>
53d48af15eSTony Lindgren #include <asm/arch/common.h>
549b6553cdSTony Lindgren #include <asm/arch/mcbsp.h>
559b6553cdSTony Lindgren #include <asm/arch/omap-alsa.h>
569b6553cdSTony Lindgren 
577c38cf02STony Lindgren static struct mtd_partition osk_partitions[] = {
587c38cf02STony Lindgren 	/* bootloader (U-Boot, etc) in first sector */
597c38cf02STony Lindgren 	{
607c38cf02STony Lindgren 	      .name		= "bootloader",
617c38cf02STony Lindgren 	      .offset		= 0,
627c38cf02STony Lindgren 	      .size		= SZ_128K,
637c38cf02STony Lindgren 	      .mask_flags	= MTD_WRITEABLE, /* force read-only */
647c38cf02STony Lindgren 	},
657c38cf02STony Lindgren 	/* bootloader params in the next sector */
667c38cf02STony Lindgren 	{
677c38cf02STony Lindgren 	      .name		= "params",
687c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
697c38cf02STony Lindgren 	      .size		= SZ_128K,
707c38cf02STony Lindgren 	      .mask_flags	= 0,
717c38cf02STony Lindgren 	}, {
727c38cf02STony Lindgren 	      .name		= "kernel",
737c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
747c38cf02STony Lindgren 	      .size		= SZ_2M,
757c38cf02STony Lindgren 	      .mask_flags	= 0
767c38cf02STony Lindgren 	}, {
777c38cf02STony Lindgren 	      .name		= "filesystem",
787c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
797c38cf02STony Lindgren 	      .size		= MTDPART_SIZ_FULL,
807c38cf02STony Lindgren 	      .mask_flags	= 0
817c38cf02STony Lindgren 	}
82dbdf9cedSTony Lindgren };
83dbdf9cedSTony Lindgren 
847c38cf02STony Lindgren static struct flash_platform_data osk_flash_data = {
857c38cf02STony Lindgren 	.map_name	= "cfi_probe",
867c38cf02STony Lindgren 	.width		= 2,
877c38cf02STony Lindgren 	.parts		= osk_partitions,
887c38cf02STony Lindgren 	.nr_parts	= ARRAY_SIZE(osk_partitions),
897c38cf02STony Lindgren };
907c38cf02STony Lindgren 
917c38cf02STony Lindgren static struct resource osk_flash_resource = {
927c38cf02STony Lindgren 	/* this is on CS3, wherever it's mapped */
937c38cf02STony Lindgren 	.flags		= IORESOURCE_MEM,
947c38cf02STony Lindgren };
957c38cf02STony Lindgren 
967c38cf02STony Lindgren static struct platform_device osk5912_flash_device = {
977c38cf02STony Lindgren 	.name		= "omapflash",
987c38cf02STony Lindgren 	.id		= 0,
997c38cf02STony Lindgren 	.dev		= {
1007c38cf02STony Lindgren 		.platform_data	= &osk_flash_data,
1017c38cf02STony Lindgren 	},
1027c38cf02STony Lindgren 	.num_resources	= 1,
1037c38cf02STony Lindgren 	.resource	= &osk_flash_resource,
1047c38cf02STony Lindgren };
105dbdf9cedSTony Lindgren 
106dbdf9cedSTony Lindgren static struct resource osk5912_smc91x_resources[] = {
107dbdf9cedSTony Lindgren 	[0] = {
108dbdf9cedSTony Lindgren 		.start	= OMAP_OSK_ETHR_START,		/* Physical */
109dbdf9cedSTony Lindgren 		.end	= OMAP_OSK_ETHR_START + 0xf,
110dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_MEM,
111dbdf9cedSTony Lindgren 	},
112dbdf9cedSTony Lindgren 	[1] = {
113dbdf9cedSTony Lindgren 		.start	= OMAP_GPIO_IRQ(0),
114dbdf9cedSTony Lindgren 		.end	= OMAP_GPIO_IRQ(0),
115e7b3dc7eSRussell King 		.flags	= IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
116dbdf9cedSTony Lindgren 	},
117dbdf9cedSTony Lindgren };
118dbdf9cedSTony Lindgren 
119dbdf9cedSTony Lindgren static struct platform_device osk5912_smc91x_device = {
120dbdf9cedSTony Lindgren 	.name		= "smc91x",
121dbdf9cedSTony Lindgren 	.id		= -1,
122dbdf9cedSTony Lindgren 	.num_resources	= ARRAY_SIZE(osk5912_smc91x_resources),
123dbdf9cedSTony Lindgren 	.resource	= osk5912_smc91x_resources,
124dbdf9cedSTony Lindgren };
125dbdf9cedSTony Lindgren 
126dbdf9cedSTony Lindgren static struct resource osk5912_cf_resources[] = {
127dbdf9cedSTony Lindgren 	[0] = {
128dbdf9cedSTony Lindgren 		.start	= OMAP_GPIO_IRQ(62),
129dbdf9cedSTony Lindgren 		.end	= OMAP_GPIO_IRQ(62),
130dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_IRQ,
131dbdf9cedSTony Lindgren 	},
132dbdf9cedSTony Lindgren };
133dbdf9cedSTony Lindgren 
134dbdf9cedSTony Lindgren static struct platform_device osk5912_cf_device = {
135dbdf9cedSTony Lindgren 	.name		= "omap_cf",
136dbdf9cedSTony Lindgren 	.id		= -1,
137dbdf9cedSTony Lindgren 	.dev = {
138dbdf9cedSTony Lindgren 		.platform_data	= (void *) 2 /* CS2 */,
139dbdf9cedSTony Lindgren 	},
140dbdf9cedSTony Lindgren 	.num_resources	= ARRAY_SIZE(osk5912_cf_resources),
141dbdf9cedSTony Lindgren 	.resource	= osk5912_cf_resources,
142dbdf9cedSTony Lindgren };
143dbdf9cedSTony Lindgren 
1449b6553cdSTony Lindgren #define DEFAULT_BITPERSAMPLE 16
1459b6553cdSTony Lindgren 
1469b6553cdSTony Lindgren static struct omap_mcbsp_reg_cfg mcbsp_regs = {
1479b6553cdSTony Lindgren 	.spcr2 = FREE | FRST | GRST | XRST | XINTM(3),
1489b6553cdSTony Lindgren 	.spcr1 = RINTM(3) | RRST,
1499b6553cdSTony Lindgren 	.rcr2 = RPHASE | RFRLEN2(OMAP_MCBSP_WORD_8) |
1509b6553cdSTony Lindgren 	    RWDLEN2(OMAP_MCBSP_WORD_16) | RDATDLY(0),
1519b6553cdSTony Lindgren 	.rcr1 = RFRLEN1(OMAP_MCBSP_WORD_8) | RWDLEN1(OMAP_MCBSP_WORD_16),
1529b6553cdSTony Lindgren 	.xcr2 = XPHASE | XFRLEN2(OMAP_MCBSP_WORD_8) |
1539b6553cdSTony Lindgren 	    XWDLEN2(OMAP_MCBSP_WORD_16) | XDATDLY(0) | XFIG,
1549b6553cdSTony Lindgren 	.xcr1 = XFRLEN1(OMAP_MCBSP_WORD_8) | XWDLEN1(OMAP_MCBSP_WORD_16),
1559b6553cdSTony Lindgren 	.srgr1 = FWID(DEFAULT_BITPERSAMPLE - 1),
1569b6553cdSTony Lindgren 	.srgr2 = GSYNC | CLKSP | FSGM | FPER(DEFAULT_BITPERSAMPLE * 2 - 1),
1579b6553cdSTony Lindgren 	/*.pcr0 = FSXM | FSRM | CLKXM | CLKRM | CLKXP | CLKRP,*/ /* mcbsp: master */
1589b6553cdSTony Lindgren 	.pcr0 = CLKXP | CLKRP,  /* mcbsp: slave */
1599b6553cdSTony Lindgren };
1609b6553cdSTony Lindgren 
1619b6553cdSTony Lindgren static struct omap_alsa_codec_config alsa_config = {
1629b6553cdSTony Lindgren 	.name			= "OSK AIC23",
1639b6553cdSTony Lindgren 	.mcbsp_regs_alsa	= &mcbsp_regs,
1646e2d4107SDavid Cohen 	.codec_configure_dev	= NULL, /* aic23_configure, */
1656e2d4107SDavid Cohen 	.codec_set_samplerate	= NULL, /* aic23_set_samplerate, */
1666e2d4107SDavid Cohen 	.codec_clock_setup	= NULL, /* aic23_clock_setup, */
1676e2d4107SDavid Cohen 	.codec_clock_on		= NULL, /* aic23_clock_on, */
1686e2d4107SDavid Cohen 	.codec_clock_off	= NULL, /* aic23_clock_off, */
1696e2d4107SDavid Cohen 	.get_default_samplerate	= NULL, /* aic23_get_default_samplerate, */
1709b6553cdSTony Lindgren };
1719b6553cdSTony Lindgren 
1727c38cf02STony Lindgren static struct platform_device osk5912_mcbsp1_device = {
1739b6553cdSTony Lindgren 	.name	= "omap_alsa_mcbsp",
1747c38cf02STony Lindgren 	.id	= 1,
1759b6553cdSTony Lindgren 	.dev = {
1769b6553cdSTony Lindgren 		.platform_data	= &alsa_config,
1779b6553cdSTony Lindgren 	},
1789b6553cdSTony Lindgren };
1799b6553cdSTony Lindgren 
180dbdf9cedSTony Lindgren static struct platform_device *osk5912_devices[] __initdata = {
1817c38cf02STony Lindgren 	&osk5912_flash_device,
182dbdf9cedSTony Lindgren 	&osk5912_smc91x_device,
183dbdf9cedSTony Lindgren 	&osk5912_cf_device,
1847c38cf02STony Lindgren 	&osk5912_mcbsp1_device,
185dbdf9cedSTony Lindgren };
186dbdf9cedSTony Lindgren 
187*d94577d5SDavid Brownell static struct gpio_led tps_leds[] = {
188*d94577d5SDavid Brownell 	/* NOTE:  D9 and D2 have hardware blink support.
189*d94577d5SDavid Brownell 	 * Also, D9 requires non-battery power.
190*d94577d5SDavid Brownell 	 */
191*d94577d5SDavid Brownell 	{ .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9", },
192*d94577d5SDavid Brownell 	{ .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
193*d94577d5SDavid Brownell 	{ .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
194*d94577d5SDavid Brownell 			.default_trigger = "heartbeat", },
195*d94577d5SDavid Brownell };
196*d94577d5SDavid Brownell 
197*d94577d5SDavid Brownell static struct gpio_led_platform_data tps_leds_data = {
198*d94577d5SDavid Brownell 	.num_leds	= 3,
199*d94577d5SDavid Brownell 	.leds		= tps_leds,
200*d94577d5SDavid Brownell };
201*d94577d5SDavid Brownell 
202*d94577d5SDavid Brownell static struct platform_device osk5912_tps_leds = {
203*d94577d5SDavid Brownell 	.name			= "leds-gpio",
204*d94577d5SDavid Brownell 	.id			= 0,
205*d94577d5SDavid Brownell 	.dev.platform_data	= &tps_leds_data,
206*d94577d5SDavid Brownell };
207*d94577d5SDavid Brownell 
208*d94577d5SDavid Brownell static int osk_tps_setup(struct i2c_client *client, void *context)
209*d94577d5SDavid Brownell {
210*d94577d5SDavid Brownell 	/* Set GPIO 1 HIGH to disable VBUS power supply;
211*d94577d5SDavid Brownell 	 * OHCI driver powers it up/down as needed.
212*d94577d5SDavid Brownell 	 */
213*d94577d5SDavid Brownell 	gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
214*d94577d5SDavid Brownell 	gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
215*d94577d5SDavid Brownell 
216*d94577d5SDavid Brownell 	/* Set GPIO 2 high so LED D3 is off by default */
217*d94577d5SDavid Brownell 	tps65010_set_gpio_out_value(GPIO2, HIGH);
218*d94577d5SDavid Brownell 
219*d94577d5SDavid Brownell 	/* Set GPIO 3 low to take ethernet out of reset */
220*d94577d5SDavid Brownell 	gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
221*d94577d5SDavid Brownell 	gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
222*d94577d5SDavid Brownell 
223*d94577d5SDavid Brownell 	/* GPIO4 is VDD_DSP */
224*d94577d5SDavid Brownell 	gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
225*d94577d5SDavid Brownell 	gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
226*d94577d5SDavid Brownell 	/* REVISIT if DSP support isn't configured, power it off ... */
227*d94577d5SDavid Brownell 
228*d94577d5SDavid Brownell 	/* Let LED1 (D9) blink; leds-gpio may override it */
229*d94577d5SDavid Brownell 	tps65010_set_led(LED1, BLINK);
230*d94577d5SDavid Brownell 
231*d94577d5SDavid Brownell 	/* Set LED2 off by default */
232*d94577d5SDavid Brownell 	tps65010_set_led(LED2, OFF);
233*d94577d5SDavid Brownell 
234*d94577d5SDavid Brownell 	/* Enable LOW_PWR handshake */
235*d94577d5SDavid Brownell 	tps65010_set_low_pwr(ON);
236*d94577d5SDavid Brownell 
237*d94577d5SDavid Brownell 	/* Switch VLDO2 to 3.0V for AIC23 */
238*d94577d5SDavid Brownell 	tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
239*d94577d5SDavid Brownell 			| TPS_LDO1_ENABLE);
240*d94577d5SDavid Brownell 
241*d94577d5SDavid Brownell 	/* register these three LEDs */
242*d94577d5SDavid Brownell 	osk5912_tps_leds.dev.parent = &client->dev;
243*d94577d5SDavid Brownell 	platform_device_register(&osk5912_tps_leds);
244*d94577d5SDavid Brownell 
245*d94577d5SDavid Brownell 	return 0;
246*d94577d5SDavid Brownell }
247*d94577d5SDavid Brownell 
248*d94577d5SDavid Brownell static struct tps65010_board tps_board = {
249*d94577d5SDavid Brownell 	.base		= OSK_TPS_GPIO_BASE,
250*d94577d5SDavid Brownell 	.outmask	= 0x0f,
251*d94577d5SDavid Brownell 	.setup		= osk_tps_setup,
252*d94577d5SDavid Brownell };
253*d94577d5SDavid Brownell 
2548056c6cbSDavid Brownell static struct i2c_board_info __initdata osk_i2c_board_info[] = {
2558056c6cbSDavid Brownell 	{
2568056c6cbSDavid Brownell 		I2C_BOARD_INFO("tps65010", 0x48),
2578056c6cbSDavid Brownell 		.type		= "tps65010",
2588056c6cbSDavid Brownell 		.irq		= OMAP_GPIO_IRQ(OMAP_MPUIO(1)),
259*d94577d5SDavid Brownell 		.platform_data	= &tps_board,
260*d94577d5SDavid Brownell 
2618056c6cbSDavid Brownell 	},
2628056c6cbSDavid Brownell 	/* TODO when driver support is ready:
2638056c6cbSDavid Brownell 	 *  - aic23 audio chip at 0x1a
2648056c6cbSDavid Brownell 	 *  - on Mistral, 24c04 eeprom at 0x50
2658056c6cbSDavid Brownell 	 *  - optionally on Mistral, ov9640 camera sensor at 0x30
2668056c6cbSDavid Brownell 	 */
2678056c6cbSDavid Brownell };
2688056c6cbSDavid Brownell 
269dbdf9cedSTony Lindgren static void __init osk_init_smc91x(void)
270dbdf9cedSTony Lindgren {
271ac37a0b0SDavid Brownell 	if ((gpio_request(0, "smc_irq")) < 0) {
272dbdf9cedSTony Lindgren 		printk("Error requesting gpio 0 for smc91x irq\n");
273dbdf9cedSTony Lindgren 		return;
274dbdf9cedSTony Lindgren 	}
275dbdf9cedSTony Lindgren 
276dbdf9cedSTony Lindgren 	/* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
2773179a019STony Lindgren 	EMIFS_CCS(1) |= 0x3;
278dbdf9cedSTony Lindgren }
279dbdf9cedSTony Lindgren 
280dbdf9cedSTony Lindgren static void __init osk_init_cf(void)
281dbdf9cedSTony Lindgren {
282dbdf9cedSTony Lindgren 	omap_cfg_reg(M7_1610_GPIO62);
283ac37a0b0SDavid Brownell 	if ((gpio_request(62, "cf_irq")) < 0) {
284dbdf9cedSTony Lindgren 		printk("Error requesting gpio 62 for CF irq\n");
285dbdf9cedSTony Lindgren 		return;
286dbdf9cedSTony Lindgren 	}
2877c38cf02STony Lindgren 	/* the CF I/O IRQ is really active-low */
2887c38cf02STony Lindgren 	set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING);
289dbdf9cedSTony Lindgren }
290dbdf9cedSTony Lindgren 
2917c38cf02STony Lindgren static void __init osk_init_irq(void)
292dbdf9cedSTony Lindgren {
29387bd63f6STony Lindgren 	omap1_init_common_hw();
294dbdf9cedSTony Lindgren 	omap_init_irq();
295dbdf9cedSTony Lindgren 	omap_gpio_init();
296dbdf9cedSTony Lindgren 	osk_init_smc91x();
297dbdf9cedSTony Lindgren 	osk_init_cf();
298dbdf9cedSTony Lindgren }
299dbdf9cedSTony Lindgren 
300dbdf9cedSTony Lindgren static struct omap_usb_config osk_usb_config __initdata = {
301dbdf9cedSTony Lindgren 	/* has usb host connector (A) ... for development it can also
302dbdf9cedSTony Lindgren 	 * be used, with a NONSTANDARD gender-bending cable/dongle, as
303dbdf9cedSTony Lindgren 	 * a peripheral.
304dbdf9cedSTony Lindgren 	 */
305dbdf9cedSTony Lindgren #ifdef	CONFIG_USB_GADGET_OMAP
306dbdf9cedSTony Lindgren 	.register_dev	= 1,
307dbdf9cedSTony Lindgren 	.hmc_mode	= 0,
308dbdf9cedSTony Lindgren #else
309dbdf9cedSTony Lindgren 	.register_host	= 1,
310dbdf9cedSTony Lindgren 	.hmc_mode	= 16,
311dbdf9cedSTony Lindgren 	.rwc		= 1,
312dbdf9cedSTony Lindgren #endif
313dbdf9cedSTony Lindgren 	.pins[0]	= 2,
314dbdf9cedSTony Lindgren };
315dbdf9cedSTony Lindgren 
3163179a019STony Lindgren static struct omap_uart_config osk_uart_config __initdata = {
3173179a019STony Lindgren 	.enabled_uarts = (1 << 0),
3183179a019STony Lindgren };
3193179a019STony Lindgren 
32078762841SDavid Brownell #ifdef	CONFIG_OMAP_OSK_MISTRAL
3213179a019STony Lindgren static struct omap_lcd_config osk_lcd_config __initdata = {
3223179a019STony Lindgren 	.ctrl_name	= "internal",
3233179a019STony Lindgren };
32478762841SDavid Brownell #endif
3253179a019STony Lindgren 
326e27a93a9STony Lindgren static struct omap_board_config_kernel osk_config[] __initdata = {
327dbdf9cedSTony Lindgren 	{ OMAP_TAG_USB,           &osk_usb_config },
3283179a019STony Lindgren 	{ OMAP_TAG_UART,		&osk_uart_config },
32978762841SDavid Brownell #ifdef	CONFIG_OMAP_OSK_MISTRAL
3303179a019STony Lindgren 	{ OMAP_TAG_LCD,			&osk_lcd_config },
33178762841SDavid Brownell #endif
332dbdf9cedSTony Lindgren };
333dbdf9cedSTony Lindgren 
3347c38cf02STony Lindgren #ifdef	CONFIG_OMAP_OSK_MISTRAL
3357c38cf02STony Lindgren 
33678762841SDavid Brownell #include <linux/input.h>
33778762841SDavid Brownell #include <linux/spi/spi.h>
33878762841SDavid Brownell #include <linux/spi/ads7846.h>
33978762841SDavid Brownell 
34078762841SDavid Brownell #include <asm/arch/keypad.h>
34178762841SDavid Brownell 
34278762841SDavid Brownell static const int osk_keymap[] = {
34378762841SDavid Brownell 	/* KEY(col, row, code) */
34478762841SDavid Brownell 	KEY(0, 0, KEY_F1),		/* SW4 */
34578762841SDavid Brownell 	KEY(0, 3, KEY_UP),		/* (sw2/up) */
34678762841SDavid Brownell 	KEY(1, 1, KEY_LEFTCTRL),	/* SW5 */
34778762841SDavid Brownell 	KEY(1, 2, KEY_LEFT),		/* (sw2/left) */
34878762841SDavid Brownell 	KEY(2, 0, KEY_SPACE),		/* SW3 */
34978762841SDavid Brownell 	KEY(2, 1, KEY_ESC),		/* SW6 */
35078762841SDavid Brownell 	KEY(2, 2, KEY_DOWN),		/* (sw2/down) */
35178762841SDavid Brownell 	KEY(3, 2, KEY_ENTER),		/* (sw2/select) */
35278762841SDavid Brownell 	KEY(3, 3, KEY_RIGHT),		/* (sw2/right) */
35378762841SDavid Brownell 	0
35478762841SDavid Brownell };
35578762841SDavid Brownell 
35678762841SDavid Brownell static struct omap_kp_platform_data osk_kp_data = {
35778762841SDavid Brownell 	.rows		= 8,
35878762841SDavid Brownell 	.cols		= 8,
35978762841SDavid Brownell 	.keymap		= (int *) osk_keymap,
3604d24607bSKomal Shah 	.keymapsize	= ARRAY_SIZE(osk_keymap),
3614d24607bSKomal Shah 	.delay		= 9,
36278762841SDavid Brownell };
36378762841SDavid Brownell 
36478762841SDavid Brownell static struct resource osk5912_kp_resources[] = {
36578762841SDavid Brownell 	[0] = {
36678762841SDavid Brownell 		.start	= INT_KEYBOARD,
36778762841SDavid Brownell 		.end	= INT_KEYBOARD,
36878762841SDavid Brownell 		.flags	= IORESOURCE_IRQ,
36978762841SDavid Brownell 	},
37078762841SDavid Brownell };
37178762841SDavid Brownell 
37278762841SDavid Brownell static struct platform_device osk5912_kp_device = {
37378762841SDavid Brownell 	.name		= "omap-keypad",
37478762841SDavid Brownell 	.id		= -1,
37578762841SDavid Brownell 	.dev		= {
37678762841SDavid Brownell 		.platform_data = &osk_kp_data,
37778762841SDavid Brownell 	},
37878762841SDavid Brownell 	.num_resources	= ARRAY_SIZE(osk5912_kp_resources),
37978762841SDavid Brownell 	.resource	= osk5912_kp_resources,
38078762841SDavid Brownell };
38178762841SDavid Brownell 
3824dcc6d24SDavid Brownell static struct omap_backlight_config mistral_bl_data = {
3834dcc6d24SDavid Brownell 	.default_intensity	= 0xa0,
3844dcc6d24SDavid Brownell };
3854dcc6d24SDavid Brownell 
3864dcc6d24SDavid Brownell static struct platform_device mistral_bl_device = {
3874dcc6d24SDavid Brownell 	.name		= "omap-bl",
3884dcc6d24SDavid Brownell 	.id		= -1,
3894dcc6d24SDavid Brownell 	.dev		= {
3904dcc6d24SDavid Brownell 		.platform_data = &mistral_bl_data,
3914dcc6d24SDavid Brownell 	},
3924dcc6d24SDavid Brownell };
3934dcc6d24SDavid Brownell 
39478762841SDavid Brownell static struct platform_device osk5912_lcd_device = {
39578762841SDavid Brownell 	.name		= "lcd_osk",
39678762841SDavid Brownell 	.id		= -1,
39778762841SDavid Brownell };
39878762841SDavid Brownell 
39978762841SDavid Brownell static struct platform_device *mistral_devices[] __initdata = {
40078762841SDavid Brownell 	&osk5912_kp_device,
4014dcc6d24SDavid Brownell 	&mistral_bl_device,
40278762841SDavid Brownell 	&osk5912_lcd_device,
40378762841SDavid Brownell };
40478762841SDavid Brownell 
405e8cdf7bdSDavid Brownell static int mistral_get_pendown_state(void)
406e8cdf7bdSDavid Brownell {
407ac37a0b0SDavid Brownell 	return !gpio_get_value(4);
408e8cdf7bdSDavid Brownell }
409e8cdf7bdSDavid Brownell 
41078762841SDavid Brownell static const struct ads7846_platform_data mistral_ts_info = {
41178762841SDavid Brownell 	.model			= 7846,
41278762841SDavid Brownell 	.vref_delay_usecs	= 100,	/* internal, no capacitor */
41378762841SDavid Brownell 	.x_plate_ohms		= 419,
41478762841SDavid Brownell 	.y_plate_ohms		= 486,
415e8cdf7bdSDavid Brownell 	.get_pendown_state	= mistral_get_pendown_state,
41678762841SDavid Brownell };
41778762841SDavid Brownell 
41878762841SDavid Brownell static struct spi_board_info __initdata mistral_boardinfo[] = { {
41978762841SDavid Brownell 	/* MicroWire (bus 2) CS0 has an ads7846e */
42078762841SDavid Brownell 	.modalias		= "ads7846",
42178762841SDavid Brownell 	.platform_data		= &mistral_ts_info,
42278762841SDavid Brownell 	.irq			= OMAP_GPIO_IRQ(4),
42378762841SDavid Brownell 	.max_speed_hz		= 120000 /* max sample rate at 3V */
42478762841SDavid Brownell 					* 26 /* command + data + overhead */,
42578762841SDavid Brownell 	.bus_num		= 2,
42678762841SDavid Brownell 	.chip_select		= 0,
42778762841SDavid Brownell } };
42878762841SDavid Brownell 
4297c38cf02STony Lindgren #ifdef	CONFIG_PM
4307c38cf02STony Lindgren static irqreturn_t
4310cd61b68SLinus Torvalds osk_mistral_wake_interrupt(int irq, void *ignored)
4327c38cf02STony Lindgren {
4337c38cf02STony Lindgren 	return IRQ_HANDLED;
4347c38cf02STony Lindgren }
4357c38cf02STony Lindgren #endif
4367c38cf02STony Lindgren 
4377c38cf02STony Lindgren static void __init osk_mistral_init(void)
4387c38cf02STony Lindgren {
43978762841SDavid Brownell 	/* NOTE:  we could actually tell if there's a Mistral board
4407c38cf02STony Lindgren 	 * attached, e.g. by trying to read something from the ads7846.
44178762841SDavid Brownell 	 * But this arch_init() code is too early for that, since we
44278762841SDavid Brownell 	 * can't talk to the ads or even the i2c eeprom.
4437c38cf02STony Lindgren 	 */
4447c38cf02STony Lindgren 
445c72d8950SDavid Brownell 	/* parallel camera interface */
446c72d8950SDavid Brownell 	omap_cfg_reg(J15_1610_CAM_LCLK);
447c72d8950SDavid Brownell 	omap_cfg_reg(J18_1610_CAM_D7);
448c72d8950SDavid Brownell 	omap_cfg_reg(J19_1610_CAM_D6);
449c72d8950SDavid Brownell 	omap_cfg_reg(J14_1610_CAM_D5);
450c72d8950SDavid Brownell 	omap_cfg_reg(K18_1610_CAM_D4);
451c72d8950SDavid Brownell 	omap_cfg_reg(K19_1610_CAM_D3);
452c72d8950SDavid Brownell 	omap_cfg_reg(K15_1610_CAM_D2);
453c72d8950SDavid Brownell 	omap_cfg_reg(K14_1610_CAM_D1);
454c72d8950SDavid Brownell 	omap_cfg_reg(L19_1610_CAM_D0);
455c72d8950SDavid Brownell 	omap_cfg_reg(L18_1610_CAM_VS);
456c72d8950SDavid Brownell 	omap_cfg_reg(L15_1610_CAM_HS);
457c72d8950SDavid Brownell 	omap_cfg_reg(M19_1610_CAM_RSTZ);
458c72d8950SDavid Brownell 	omap_cfg_reg(Y15_1610_CAM_OUTCLK);
459c72d8950SDavid Brownell 
460c72d8950SDavid Brownell 	/* serial camera interface */
461c72d8950SDavid Brownell 	omap_cfg_reg(H19_1610_CAM_EXCLK);
462c72d8950SDavid Brownell 	omap_cfg_reg(W13_1610_CCP_CLKM);
463c72d8950SDavid Brownell 	omap_cfg_reg(Y12_1610_CCP_CLKP);
464c72d8950SDavid Brownell 	/* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */
4656e2d4107SDavid Cohen 	/* omap_cfg_reg(Y14_1610_CCP_DATAM); */
466c72d8950SDavid Brownell 	omap_cfg_reg(W14_1610_CCP_DATAP);
467c72d8950SDavid Brownell 
468c72d8950SDavid Brownell 	/* CAM_PWDN */
469ac37a0b0SDavid Brownell 	if (gpio_request(11, "cam_pwdn") == 0) {
470c72d8950SDavid Brownell 		omap_cfg_reg(N20_1610_GPIO11);
471ac37a0b0SDavid Brownell 		gpio_direction_output(11, 0);
472c72d8950SDavid Brownell 	} else
473c72d8950SDavid Brownell 		pr_debug("OSK+Mistral: CAM_PWDN is awol\n");
474c72d8950SDavid Brownell 
475c72d8950SDavid Brownell 
4766e2d4107SDavid Cohen 	/* omap_cfg_reg(P19_1610_GPIO6); */	/* BUSY */
477ac37a0b0SDavid Brownell 	gpio_request(6, "ts_busy");
478ac37a0b0SDavid Brownell 	gpio_direction_input(6);
479ac37a0b0SDavid Brownell 
4806e2d4107SDavid Cohen 	omap_cfg_reg(P20_1610_GPIO4);	/* PENIRQ */
481ac37a0b0SDavid Brownell 	gpio_request(4, "ts_int");
482ac37a0b0SDavid Brownell 	gpio_direction_input(4);
48378762841SDavid Brownell 	set_irq_type(OMAP_GPIO_IRQ(4), IRQT_FALLING);
484ac37a0b0SDavid Brownell 
48578762841SDavid Brownell 	spi_register_board_info(mistral_boardinfo,
48678762841SDavid Brownell 			ARRAY_SIZE(mistral_boardinfo));
48778762841SDavid Brownell 
4887c38cf02STony Lindgren 	/* the sideways button (SW1) is for use as a "wakeup" button */
4897c38cf02STony Lindgren 	omap_cfg_reg(N15_1610_MPUIO2);
490ac37a0b0SDavid Brownell 	if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) {
4917c38cf02STony Lindgren 		int ret = 0;
492ac37a0b0SDavid Brownell 
493ac37a0b0SDavid Brownell 		gpio_direction_input(OMAP_MPUIO(2));
4947c38cf02STony Lindgren 		set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING);
4957c38cf02STony Lindgren #ifdef	CONFIG_PM
4967c38cf02STony Lindgren 		/* share the IRQ in case someone wants to use the
4977c38cf02STony Lindgren 		 * button for more than wakeup from system sleep.
4987c38cf02STony Lindgren 		 */
4997c38cf02STony Lindgren 		ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)),
5007c38cf02STony Lindgren 				&osk_mistral_wake_interrupt,
50152e405eaSThomas Gleixner 				IRQF_SHARED, "mistral_wakeup",
5027c38cf02STony Lindgren 				&osk_mistral_wake_interrupt);
5037c38cf02STony Lindgren 		if (ret != 0) {
504ac37a0b0SDavid Brownell 			gpio_free(OMAP_MPUIO(2));
5057c38cf02STony Lindgren 			printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
5067c38cf02STony Lindgren 				ret);
5077c38cf02STony Lindgren 		} else
5087c38cf02STony Lindgren 			enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2)));
5097c38cf02STony Lindgren #endif
5107c38cf02STony Lindgren 	} else
5117c38cf02STony Lindgren 		printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
51278762841SDavid Brownell 
5134dcc6d24SDavid Brownell 	/* LCD:  backlight, and power; power controls other devices on the
5144dcc6d24SDavid Brownell 	 * board, like the touchscreen, EEPROM, and wakeup (!) switch.
5154dcc6d24SDavid Brownell 	 */
5164dcc6d24SDavid Brownell 	omap_cfg_reg(PWL);
517ac37a0b0SDavid Brownell 	if (gpio_request(2, "lcd_pwr") == 0)
518ac37a0b0SDavid Brownell 		gpio_direction_output(2, 1);
5194dcc6d24SDavid Brownell 
52078762841SDavid Brownell 	platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices));
5217c38cf02STony Lindgren }
5227c38cf02STony Lindgren #else
5237c38cf02STony Lindgren static void __init osk_mistral_init(void) { }
5247c38cf02STony Lindgren #endif
5257c38cf02STony Lindgren 
5269b6553cdSTony Lindgren #define EMIFS_CS3_VAL	(0x88013141)
5279b6553cdSTony Lindgren 
528dbdf9cedSTony Lindgren static void __init osk_init(void)
529dbdf9cedSTony Lindgren {
5309b6553cdSTony Lindgren 	/* Workaround for wrong CS3 (NOR flash) timing
5319b6553cdSTony Lindgren 	 * There are some U-Boot versions out there which configure
5329b6553cdSTony Lindgren 	 * wrong CS3 memory timings. This mainly leads to CRC
5336cbdc8c5SSimon Arlott 	 * or similar errors if you use NOR flash (e.g. with JFFS2)
5349b6553cdSTony Lindgren 	 */
5359b6553cdSTony Lindgren 	if (EMIFS_CCS(3) != EMIFS_CS3_VAL)
5369b6553cdSTony Lindgren 		EMIFS_CCS(3) = EMIFS_CS3_VAL;
5379b6553cdSTony Lindgren 
5387c38cf02STony Lindgren 	osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
5397c38cf02STony Lindgren 	osk_flash_resource.end += SZ_32M - 1;
540dbdf9cedSTony Lindgren 	platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
541dbdf9cedSTony Lindgren 	omap_board_config = osk_config;
542dbdf9cedSTony Lindgren 	omap_board_config_size = ARRAY_SIZE(osk_config);
543dbdf9cedSTony Lindgren 	USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
5447c38cf02STony Lindgren 
5458056c6cbSDavid Brownell 	/* irq for tps65010 chip */
5468056c6cbSDavid Brownell 	/* bootloader effectively does:  omap_cfg_reg(U19_1610_MPUIO1); */
5478056c6cbSDavid Brownell 	if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0)
5488056c6cbSDavid Brownell 		gpio_direction_input(OMAP_MPUIO(1));
5498056c6cbSDavid Brownell 
5503179a019STony Lindgren 	omap_serial_init();
5511ed16a86SJarkko Nikula 	omap_register_i2c_bus(1, 400, osk_i2c_board_info,
5521ed16a86SJarkko Nikula 			      ARRAY_SIZE(osk_i2c_board_info));
5537c38cf02STony Lindgren 	osk_mistral_init();
554dbdf9cedSTony Lindgren }
555dbdf9cedSTony Lindgren 
556dbdf9cedSTony Lindgren static void __init osk_map_io(void)
557dbdf9cedSTony Lindgren {
55887bd63f6STony Lindgren 	omap1_map_common_io();
559dbdf9cedSTony Lindgren }
560dbdf9cedSTony Lindgren 
561dbdf9cedSTony Lindgren MACHINE_START(OMAP_OSK, "TI-OSK")
562dbdf9cedSTony Lindgren 	/* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
563dbdf9cedSTony Lindgren 	.phys_io	= 0xfff00000,
564dbdf9cedSTony Lindgren 	.io_pg_offst	= ((0xfef00000) >> 18) & 0xfffc,
565dbdf9cedSTony Lindgren 	.boot_params	= 0x10000100,
566dbdf9cedSTony Lindgren 	.map_io		= osk_map_io,
567dbdf9cedSTony Lindgren 	.init_irq	= osk_init_irq,
568dbdf9cedSTony Lindgren 	.init_machine	= osk_init,
569dbdf9cedSTony Lindgren 	.timer		= &omap_timer,
570dbdf9cedSTony Lindgren MACHINE_END
571