xref: /linux/arch/arm/mach-omap1/board-osk.c (revision 87bd63f64790eb01a963e05fc5e9fbf366c9de6e)
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>
327c38cf02STony Lindgren #include <linux/interrupt.h>
337c38cf02STony Lindgren 
347c38cf02STony Lindgren #include <linux/mtd/mtd.h>
357c38cf02STony Lindgren #include <linux/mtd/partitions.h>
36dbdf9cedSTony Lindgren 
37dbdf9cedSTony Lindgren #include <asm/hardware.h>
38dbdf9cedSTony Lindgren #include <asm/mach-types.h>
39dbdf9cedSTony Lindgren #include <asm/mach/arch.h>
40dbdf9cedSTony Lindgren #include <asm/mach/map.h>
417c38cf02STony Lindgren #include <asm/mach/flash.h>
42dbdf9cedSTony Lindgren 
43dbdf9cedSTony Lindgren #include <asm/arch/gpio.h>
44dbdf9cedSTony Lindgren #include <asm/arch/usb.h>
45dbdf9cedSTony Lindgren #include <asm/arch/mux.h>
46dbdf9cedSTony Lindgren #include <asm/arch/tc.h>
47d48af15eSTony Lindgren #include <asm/arch/common.h>
48dbdf9cedSTony Lindgren 
497c38cf02STony Lindgren static struct mtd_partition osk_partitions[] = {
507c38cf02STony Lindgren 	/* bootloader (U-Boot, etc) in first sector */
517c38cf02STony Lindgren 	{
527c38cf02STony Lindgren 	      .name		= "bootloader",
537c38cf02STony Lindgren 	      .offset		= 0,
547c38cf02STony Lindgren 	      .size		= SZ_128K,
557c38cf02STony Lindgren 	      .mask_flags	= MTD_WRITEABLE, /* force read-only */
567c38cf02STony Lindgren 	},
577c38cf02STony Lindgren 	/* bootloader params in the next sector */
587c38cf02STony Lindgren 	{
597c38cf02STony Lindgren 	      .name		= "params",
607c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
617c38cf02STony Lindgren 	      .size		= SZ_128K,
627c38cf02STony Lindgren 	      .mask_flags	= 0,
637c38cf02STony Lindgren 	}, {
647c38cf02STony Lindgren 	      .name		= "kernel",
657c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
667c38cf02STony Lindgren 	      .size		= SZ_2M,
677c38cf02STony Lindgren 	      .mask_flags	= 0
687c38cf02STony Lindgren 	}, {
697c38cf02STony Lindgren 	      .name		= "filesystem",
707c38cf02STony Lindgren 	      .offset		= MTDPART_OFS_APPEND,
717c38cf02STony Lindgren 	      .size		= MTDPART_SIZ_FULL,
727c38cf02STony Lindgren 	      .mask_flags	= 0
737c38cf02STony Lindgren 	}
74dbdf9cedSTony Lindgren };
75dbdf9cedSTony Lindgren 
767c38cf02STony Lindgren static struct flash_platform_data osk_flash_data = {
777c38cf02STony Lindgren 	.map_name	= "cfi_probe",
787c38cf02STony Lindgren 	.width		= 2,
797c38cf02STony Lindgren 	.parts		= osk_partitions,
807c38cf02STony Lindgren 	.nr_parts	= ARRAY_SIZE(osk_partitions),
817c38cf02STony Lindgren };
827c38cf02STony Lindgren 
837c38cf02STony Lindgren static struct resource osk_flash_resource = {
847c38cf02STony Lindgren 	/* this is on CS3, wherever it's mapped */
857c38cf02STony Lindgren 	.flags		= IORESOURCE_MEM,
867c38cf02STony Lindgren };
877c38cf02STony Lindgren 
887c38cf02STony Lindgren static struct platform_device osk5912_flash_device = {
897c38cf02STony Lindgren 	.name		= "omapflash",
907c38cf02STony Lindgren 	.id		= 0,
917c38cf02STony Lindgren 	.dev		= {
927c38cf02STony Lindgren 		.platform_data	= &osk_flash_data,
937c38cf02STony Lindgren 	},
947c38cf02STony Lindgren 	.num_resources	= 1,
957c38cf02STony Lindgren 	.resource	= &osk_flash_resource,
967c38cf02STony Lindgren };
97dbdf9cedSTony Lindgren 
98dbdf9cedSTony Lindgren static struct resource osk5912_smc91x_resources[] = {
99dbdf9cedSTony Lindgren 	[0] = {
100dbdf9cedSTony Lindgren 		.start	= OMAP_OSK_ETHR_START,		/* Physical */
101dbdf9cedSTony Lindgren 		.end	= OMAP_OSK_ETHR_START + 0xf,
102dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_MEM,
103dbdf9cedSTony Lindgren 	},
104dbdf9cedSTony Lindgren 	[1] = {
105dbdf9cedSTony Lindgren 		.start	= OMAP_GPIO_IRQ(0),
106dbdf9cedSTony Lindgren 		.end	= OMAP_GPIO_IRQ(0),
107dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_IRQ,
108dbdf9cedSTony Lindgren 	},
109dbdf9cedSTony Lindgren };
110dbdf9cedSTony Lindgren 
111dbdf9cedSTony Lindgren static struct platform_device osk5912_smc91x_device = {
112dbdf9cedSTony Lindgren 	.name		= "smc91x",
113dbdf9cedSTony Lindgren 	.id		= -1,
114dbdf9cedSTony Lindgren 	.num_resources	= ARRAY_SIZE(osk5912_smc91x_resources),
115dbdf9cedSTony Lindgren 	.resource	= osk5912_smc91x_resources,
116dbdf9cedSTony Lindgren };
117dbdf9cedSTony Lindgren 
118dbdf9cedSTony Lindgren static struct resource osk5912_cf_resources[] = {
119dbdf9cedSTony Lindgren 	[0] = {
120dbdf9cedSTony Lindgren 		.start	= OMAP_GPIO_IRQ(62),
121dbdf9cedSTony Lindgren 		.end	= OMAP_GPIO_IRQ(62),
122dbdf9cedSTony Lindgren 		.flags	= IORESOURCE_IRQ,
123dbdf9cedSTony Lindgren 	},
124dbdf9cedSTony Lindgren };
125dbdf9cedSTony Lindgren 
126dbdf9cedSTony Lindgren static struct platform_device osk5912_cf_device = {
127dbdf9cedSTony Lindgren 	.name		= "omap_cf",
128dbdf9cedSTony Lindgren 	.id		= -1,
129dbdf9cedSTony Lindgren 	.dev = {
130dbdf9cedSTony Lindgren 		.platform_data	= (void *) 2 /* CS2 */,
131dbdf9cedSTony Lindgren 	},
132dbdf9cedSTony Lindgren 	.num_resources	= ARRAY_SIZE(osk5912_cf_resources),
133dbdf9cedSTony Lindgren 	.resource	= osk5912_cf_resources,
134dbdf9cedSTony Lindgren };
135dbdf9cedSTony Lindgren 
1367c38cf02STony Lindgren static struct platform_device osk5912_mcbsp1_device = {
1377c38cf02STony Lindgren 	.name		= "omap_mcbsp",
1387c38cf02STony Lindgren 	.id		= 1,
1397c38cf02STony Lindgren };
1407c38cf02STony Lindgren 
141dbdf9cedSTony Lindgren static struct platform_device *osk5912_devices[] __initdata = {
1427c38cf02STony Lindgren 	&osk5912_flash_device,
143dbdf9cedSTony Lindgren 	&osk5912_smc91x_device,
144dbdf9cedSTony Lindgren 	&osk5912_cf_device,
1457c38cf02STony Lindgren 	&osk5912_mcbsp1_device,
146dbdf9cedSTony Lindgren };
147dbdf9cedSTony Lindgren 
148dbdf9cedSTony Lindgren static void __init osk_init_smc91x(void)
149dbdf9cedSTony Lindgren {
150dbdf9cedSTony Lindgren 	if ((omap_request_gpio(0)) < 0) {
151dbdf9cedSTony Lindgren 		printk("Error requesting gpio 0 for smc91x irq\n");
152dbdf9cedSTony Lindgren 		return;
153dbdf9cedSTony Lindgren 	}
154dbdf9cedSTony Lindgren 
155dbdf9cedSTony Lindgren 	/* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */
1563179a019STony Lindgren 	EMIFS_CCS(1) |= 0x3;
157dbdf9cedSTony Lindgren }
158dbdf9cedSTony Lindgren 
159dbdf9cedSTony Lindgren static void __init osk_init_cf(void)
160dbdf9cedSTony Lindgren {
161dbdf9cedSTony Lindgren 	omap_cfg_reg(M7_1610_GPIO62);
162dbdf9cedSTony Lindgren 	if ((omap_request_gpio(62)) < 0) {
163dbdf9cedSTony Lindgren 		printk("Error requesting gpio 62 for CF irq\n");
164dbdf9cedSTony Lindgren 		return;
165dbdf9cedSTony Lindgren 	}
1667c38cf02STony Lindgren 	/* the CF I/O IRQ is really active-low */
1677c38cf02STony Lindgren 	set_irq_type(OMAP_GPIO_IRQ(62), IRQT_FALLING);
168dbdf9cedSTony Lindgren }
169dbdf9cedSTony Lindgren 
1707c38cf02STony Lindgren static void __init osk_init_irq(void)
171dbdf9cedSTony Lindgren {
172*87bd63f6STony Lindgren 	omap1_init_common_hw();
173dbdf9cedSTony Lindgren 	omap_init_irq();
174dbdf9cedSTony Lindgren 	omap_gpio_init();
175dbdf9cedSTony Lindgren 	osk_init_smc91x();
176dbdf9cedSTony Lindgren 	osk_init_cf();
177dbdf9cedSTony Lindgren }
178dbdf9cedSTony Lindgren 
179dbdf9cedSTony Lindgren static struct omap_usb_config osk_usb_config __initdata = {
180dbdf9cedSTony Lindgren 	/* has usb host connector (A) ... for development it can also
181dbdf9cedSTony Lindgren 	 * be used, with a NONSTANDARD gender-bending cable/dongle, as
182dbdf9cedSTony Lindgren 	 * a peripheral.
183dbdf9cedSTony Lindgren 	 */
184dbdf9cedSTony Lindgren #ifdef	CONFIG_USB_GADGET_OMAP
185dbdf9cedSTony Lindgren 	.register_dev	= 1,
186dbdf9cedSTony Lindgren 	.hmc_mode	= 0,
187dbdf9cedSTony Lindgren #else
188dbdf9cedSTony Lindgren 	.register_host	= 1,
189dbdf9cedSTony Lindgren 	.hmc_mode	= 16,
190dbdf9cedSTony Lindgren 	.rwc		= 1,
191dbdf9cedSTony Lindgren #endif
192dbdf9cedSTony Lindgren 	.pins[0]	= 2,
193dbdf9cedSTony Lindgren };
194dbdf9cedSTony Lindgren 
1953179a019STony Lindgren static struct omap_uart_config osk_uart_config __initdata = {
1963179a019STony Lindgren 	.enabled_uarts = (1 << 0),
1973179a019STony Lindgren };
1983179a019STony Lindgren 
1993179a019STony Lindgren static struct omap_lcd_config osk_lcd_config __initdata = {
2003179a019STony Lindgren 	.panel_name	= "osk",
2013179a019STony Lindgren 	.ctrl_name	= "internal",
2023179a019STony Lindgren };
2033179a019STony Lindgren 
204dbdf9cedSTony Lindgren static struct omap_board_config_kernel osk_config[] = {
205dbdf9cedSTony Lindgren 	{ OMAP_TAG_USB,           &osk_usb_config },
2063179a019STony Lindgren 	{ OMAP_TAG_UART,		&osk_uart_config },
2073179a019STony Lindgren 	{ OMAP_TAG_LCD,			&osk_lcd_config },
208dbdf9cedSTony Lindgren };
209dbdf9cedSTony Lindgren 
2107c38cf02STony Lindgren #ifdef	CONFIG_OMAP_OSK_MISTRAL
2117c38cf02STony Lindgren 
2127c38cf02STony Lindgren #ifdef	CONFIG_PM
2137c38cf02STony Lindgren static irqreturn_t
2147c38cf02STony Lindgren osk_mistral_wake_interrupt(int irq, void *ignored, struct pt_regs *regs)
2157c38cf02STony Lindgren {
2167c38cf02STony Lindgren 	return IRQ_HANDLED;
2177c38cf02STony Lindgren }
2187c38cf02STony Lindgren #endif
2197c38cf02STony Lindgren 
2207c38cf02STony Lindgren static void __init osk_mistral_init(void)
2217c38cf02STony Lindgren {
2227c38cf02STony Lindgren 	/* FIXME here's where to feed in framebuffer, touchpad, and
2237c38cf02STony Lindgren 	 * keyboard setup ...  not in the drivers for those devices!
2247c38cf02STony Lindgren 	 *
2257c38cf02STony Lindgren 	 * NOTE:  we could actually tell if there's a Mistral board
2267c38cf02STony Lindgren 	 * attached, e.g. by trying to read something from the ads7846.
2277c38cf02STony Lindgren 	 * But this is too early for that...
2287c38cf02STony Lindgren 	 */
2297c38cf02STony Lindgren 
2307c38cf02STony Lindgren 	/* the sideways button (SW1) is for use as a "wakeup" button */
2317c38cf02STony Lindgren 	omap_cfg_reg(N15_1610_MPUIO2);
2327c38cf02STony Lindgren 	if (omap_request_gpio(OMAP_MPUIO(2)) == 0) {
2337c38cf02STony Lindgren 		int ret = 0;
2347c38cf02STony Lindgren 		omap_set_gpio_direction(OMAP_MPUIO(2), 1);
2357c38cf02STony Lindgren 		set_irq_type(OMAP_GPIO_IRQ(OMAP_MPUIO(2)), IRQT_RISING);
2367c38cf02STony Lindgren #ifdef	CONFIG_PM
2377c38cf02STony Lindgren 		/* share the IRQ in case someone wants to use the
2387c38cf02STony Lindgren 		 * button for more than wakeup from system sleep.
2397c38cf02STony Lindgren 		 */
2407c38cf02STony Lindgren 		ret = request_irq(OMAP_GPIO_IRQ(OMAP_MPUIO(2)),
2417c38cf02STony Lindgren 				&osk_mistral_wake_interrupt,
2427c38cf02STony Lindgren 				SA_SHIRQ, "mistral_wakeup",
2437c38cf02STony Lindgren 				&osk_mistral_wake_interrupt);
2447c38cf02STony Lindgren 		if (ret != 0) {
2457c38cf02STony Lindgren 			omap_free_gpio(OMAP_MPUIO(2));
2467c38cf02STony Lindgren 			printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n",
2477c38cf02STony Lindgren 				ret);
2487c38cf02STony Lindgren 		} else
2497c38cf02STony Lindgren 			enable_irq_wake(OMAP_GPIO_IRQ(OMAP_MPUIO(2)));
2507c38cf02STony Lindgren #endif
2517c38cf02STony Lindgren 	} else
2527c38cf02STony Lindgren 		printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n");
2537c38cf02STony Lindgren }
2547c38cf02STony Lindgren #else
2557c38cf02STony Lindgren static void __init osk_mistral_init(void) { }
2567c38cf02STony Lindgren #endif
2577c38cf02STony Lindgren 
258dbdf9cedSTony Lindgren static void __init osk_init(void)
259dbdf9cedSTony Lindgren {
2607c38cf02STony Lindgren 	osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys();
2617c38cf02STony Lindgren 	osk_flash_resource.end += SZ_32M - 1;
262dbdf9cedSTony Lindgren 	platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices));
263dbdf9cedSTony Lindgren 	omap_board_config = osk_config;
264dbdf9cedSTony Lindgren 	omap_board_config_size = ARRAY_SIZE(osk_config);
265dbdf9cedSTony Lindgren 	USB_TRANSCEIVER_CTRL_REG |= (3 << 1);
2667c38cf02STony Lindgren 
2673179a019STony Lindgren 	omap_serial_init();
2687c38cf02STony Lindgren 	osk_mistral_init();
269dbdf9cedSTony Lindgren }
270dbdf9cedSTony Lindgren 
271dbdf9cedSTony Lindgren static void __init osk_map_io(void)
272dbdf9cedSTony Lindgren {
273*87bd63f6STony Lindgren 	omap1_map_common_io();
274dbdf9cedSTony Lindgren }
275dbdf9cedSTony Lindgren 
276dbdf9cedSTony Lindgren MACHINE_START(OMAP_OSK, "TI-OSK")
277dbdf9cedSTony Lindgren 	/* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
278dbdf9cedSTony Lindgren 	.phys_io	= 0xfff00000,
279dbdf9cedSTony Lindgren 	.io_pg_offst	= ((0xfef00000) >> 18) & 0xfffc,
280dbdf9cedSTony Lindgren 	.boot_params	= 0x10000100,
281dbdf9cedSTony Lindgren 	.map_io		= osk_map_io,
282dbdf9cedSTony Lindgren 	.init_irq	= osk_init_irq,
283dbdf9cedSTony Lindgren 	.init_machine	= osk_init,
284dbdf9cedSTony Lindgren 	.timer		= &omap_timer,
285dbdf9cedSTony Lindgren MACHINE_END
286