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 */ 282f8163baSRussell King #include <linux/gpio.h> 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> 363bc48014SLadislav Michl #include <linux/smc91x.h> 37ddba6c7fSTomi Valkeinen #include <linux/omapfb.h> 387c38cf02STony Lindgren #include <linux/mtd/mtd.h> 397c38cf02STony Lindgren #include <linux/mtd/partitions.h> 40561b036aSLadislav Michl #include <linux/mtd/physmap.h> 416d16bfb5SDavid Brownell #include <linux/i2c/tps65010.h> 426d16bfb5SDavid Brownell 43dbdf9cedSTony Lindgren #include <asm/mach-types.h> 44dbdf9cedSTony Lindgren #include <asm/mach/arch.h> 45dbdf9cedSTony Lindgren #include <asm/mach/map.h> 46dbdf9cedSTony Lindgren 47561b036aSLadislav Michl #include <plat/flash.h> 48ce491cf8STony Lindgren #include <plat/mux.h> 49ce491cf8STony Lindgren #include <plat/tc.h> 502e3ee9f4STony Lindgren 512e3ee9f4STony Lindgren #include <mach/hardware.h> 52*b924b204STony Lindgren #include <mach/usb.h> 532e3ee9f4STony Lindgren 544e65331cSTony Lindgren #include "common.h" 559b6553cdSTony Lindgren 563a0110cdSTony Lindgren /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ 573a0110cdSTony Lindgren #define OMAP_OSK_ETHR_START 0x04800300 583a0110cdSTony Lindgren 593a0110cdSTony Lindgren /* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with 603a0110cdSTony Lindgren * alternate pin configurations for hardware-controlled blinking. 613a0110cdSTony Lindgren */ 623a0110cdSTony Lindgren #define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */) 633a0110cdSTony Lindgren # define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0) 643a0110cdSTony Lindgren # define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1) 653a0110cdSTony Lindgren # define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2) 663a0110cdSTony Lindgren # define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3) 673a0110cdSTony Lindgren # define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4) 683a0110cdSTony Lindgren # define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5) 693a0110cdSTony Lindgren 707c38cf02STony Lindgren static struct mtd_partition osk_partitions[] = { 717c38cf02STony Lindgren /* bootloader (U-Boot, etc) in first sector */ 727c38cf02STony Lindgren { 737c38cf02STony Lindgren .name = "bootloader", 747c38cf02STony Lindgren .offset = 0, 757c38cf02STony Lindgren .size = SZ_128K, 767c38cf02STony Lindgren .mask_flags = MTD_WRITEABLE, /* force read-only */ 777c38cf02STony Lindgren }, 787c38cf02STony Lindgren /* bootloader params in the next sector */ 797c38cf02STony Lindgren { 807c38cf02STony Lindgren .name = "params", 817c38cf02STony Lindgren .offset = MTDPART_OFS_APPEND, 827c38cf02STony Lindgren .size = SZ_128K, 837c38cf02STony Lindgren .mask_flags = 0, 847c38cf02STony Lindgren }, { 857c38cf02STony Lindgren .name = "kernel", 867c38cf02STony Lindgren .offset = MTDPART_OFS_APPEND, 877c38cf02STony Lindgren .size = SZ_2M, 887c38cf02STony Lindgren .mask_flags = 0 897c38cf02STony Lindgren }, { 907c38cf02STony Lindgren .name = "filesystem", 917c38cf02STony Lindgren .offset = MTDPART_OFS_APPEND, 927c38cf02STony Lindgren .size = MTDPART_SIZ_FULL, 937c38cf02STony Lindgren .mask_flags = 0 947c38cf02STony Lindgren } 95dbdf9cedSTony Lindgren }; 96dbdf9cedSTony Lindgren 97561b036aSLadislav Michl static struct physmap_flash_data osk_flash_data = { 987c38cf02STony Lindgren .width = 2, 99561b036aSLadislav Michl .set_vpp = omap1_set_vpp, 1007c38cf02STony Lindgren .parts = osk_partitions, 1017c38cf02STony Lindgren .nr_parts = ARRAY_SIZE(osk_partitions), 1027c38cf02STony Lindgren }; 1037c38cf02STony Lindgren 1047c38cf02STony Lindgren static struct resource osk_flash_resource = { 1057c38cf02STony Lindgren /* this is on CS3, wherever it's mapped */ 1067c38cf02STony Lindgren .flags = IORESOURCE_MEM, 1077c38cf02STony Lindgren }; 1087c38cf02STony Lindgren 1097c38cf02STony Lindgren static struct platform_device osk5912_flash_device = { 110561b036aSLadislav Michl .name = "physmap-flash", 1117c38cf02STony Lindgren .id = 0, 1127c38cf02STony Lindgren .dev = { 1137c38cf02STony Lindgren .platform_data = &osk_flash_data, 1147c38cf02STony Lindgren }, 1157c38cf02STony Lindgren .num_resources = 1, 1167c38cf02STony Lindgren .resource = &osk_flash_resource, 1177c38cf02STony Lindgren }; 118dbdf9cedSTony Lindgren 1193bc48014SLadislav Michl static struct smc91x_platdata osk5912_smc91x_info = { 1203bc48014SLadislav Michl .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, 1213bc48014SLadislav Michl .leda = RPC_LED_100_10, 1223bc48014SLadislav Michl .ledb = RPC_LED_TX_RX, 1233bc48014SLadislav Michl }; 1243bc48014SLadislav Michl 125dbdf9cedSTony Lindgren static struct resource osk5912_smc91x_resources[] = { 126dbdf9cedSTony Lindgren [0] = { 127dbdf9cedSTony Lindgren .start = OMAP_OSK_ETHR_START, /* Physical */ 128dbdf9cedSTony Lindgren .end = OMAP_OSK_ETHR_START + 0xf, 129dbdf9cedSTony Lindgren .flags = IORESOURCE_MEM, 130dbdf9cedSTony Lindgren }, 131dbdf9cedSTony Lindgren [1] = { 132e7b3dc7eSRussell King .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, 133dbdf9cedSTony Lindgren }, 134dbdf9cedSTony Lindgren }; 135dbdf9cedSTony Lindgren 136dbdf9cedSTony Lindgren static struct platform_device osk5912_smc91x_device = { 137dbdf9cedSTony Lindgren .name = "smc91x", 138dbdf9cedSTony Lindgren .id = -1, 1393bc48014SLadislav Michl .dev = { 1403bc48014SLadislav Michl .platform_data = &osk5912_smc91x_info, 1413bc48014SLadislav Michl }, 142dbdf9cedSTony Lindgren .num_resources = ARRAY_SIZE(osk5912_smc91x_resources), 143dbdf9cedSTony Lindgren .resource = osk5912_smc91x_resources, 144dbdf9cedSTony Lindgren }; 145dbdf9cedSTony Lindgren 146dbdf9cedSTony Lindgren static struct resource osk5912_cf_resources[] = { 147dbdf9cedSTony Lindgren [0] = { 148dbdf9cedSTony Lindgren .flags = IORESOURCE_IRQ, 149dbdf9cedSTony Lindgren }, 150dbdf9cedSTony Lindgren }; 151dbdf9cedSTony Lindgren 152dbdf9cedSTony Lindgren static struct platform_device osk5912_cf_device = { 153dbdf9cedSTony Lindgren .name = "omap_cf", 154dbdf9cedSTony Lindgren .id = -1, 155dbdf9cedSTony Lindgren .dev = { 156dbdf9cedSTony Lindgren .platform_data = (void *) 2 /* CS2 */, 157dbdf9cedSTony Lindgren }, 158dbdf9cedSTony Lindgren .num_resources = ARRAY_SIZE(osk5912_cf_resources), 159dbdf9cedSTony Lindgren .resource = osk5912_cf_resources, 160dbdf9cedSTony Lindgren }; 161dbdf9cedSTony Lindgren 162dbdf9cedSTony Lindgren static struct platform_device *osk5912_devices[] __initdata = { 1637c38cf02STony Lindgren &osk5912_flash_device, 164dbdf9cedSTony Lindgren &osk5912_smc91x_device, 165dbdf9cedSTony Lindgren &osk5912_cf_device, 166dbdf9cedSTony Lindgren }; 167dbdf9cedSTony Lindgren 168d94577d5SDavid Brownell static struct gpio_led tps_leds[] = { 169d94577d5SDavid Brownell /* NOTE: D9 and D2 have hardware blink support. 170d94577d5SDavid Brownell * Also, D9 requires non-battery power. 171d94577d5SDavid Brownell */ 1725dd81e25SDavid Brownell { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9", 1735dd81e25SDavid Brownell .default_trigger = "ide-disk", }, 174d94577d5SDavid Brownell { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", }, 175d94577d5SDavid Brownell { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1, 176d94577d5SDavid Brownell .default_trigger = "heartbeat", }, 177d94577d5SDavid Brownell }; 178d94577d5SDavid Brownell 179d94577d5SDavid Brownell static struct gpio_led_platform_data tps_leds_data = { 180d94577d5SDavid Brownell .num_leds = 3, 181d94577d5SDavid Brownell .leds = tps_leds, 182d94577d5SDavid Brownell }; 183d94577d5SDavid Brownell 184d94577d5SDavid Brownell static struct platform_device osk5912_tps_leds = { 185d94577d5SDavid Brownell .name = "leds-gpio", 186d94577d5SDavid Brownell .id = 0, 187d94577d5SDavid Brownell .dev.platform_data = &tps_leds_data, 188d94577d5SDavid Brownell }; 189d94577d5SDavid Brownell 190d94577d5SDavid Brownell static int osk_tps_setup(struct i2c_client *client, void *context) 191d94577d5SDavid Brownell { 192d94577d5SDavid Brownell /* Set GPIO 1 HIGH to disable VBUS power supply; 193d94577d5SDavid Brownell * OHCI driver powers it up/down as needed. 194d94577d5SDavid Brownell */ 195d94577d5SDavid Brownell gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en"); 196d94577d5SDavid Brownell gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1); 197d94577d5SDavid Brownell 198d94577d5SDavid Brownell /* Set GPIO 2 high so LED D3 is off by default */ 199d94577d5SDavid Brownell tps65010_set_gpio_out_value(GPIO2, HIGH); 200d94577d5SDavid Brownell 201d94577d5SDavid Brownell /* Set GPIO 3 low to take ethernet out of reset */ 202d94577d5SDavid Brownell gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset"); 203d94577d5SDavid Brownell gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0); 204d94577d5SDavid Brownell 205d94577d5SDavid Brownell /* GPIO4 is VDD_DSP */ 206d94577d5SDavid Brownell gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power"); 207d94577d5SDavid Brownell gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1); 208d94577d5SDavid Brownell /* REVISIT if DSP support isn't configured, power it off ... */ 209d94577d5SDavid Brownell 210d94577d5SDavid Brownell /* Let LED1 (D9) blink; leds-gpio may override it */ 211d94577d5SDavid Brownell tps65010_set_led(LED1, BLINK); 212d94577d5SDavid Brownell 213d94577d5SDavid Brownell /* Set LED2 off by default */ 214d94577d5SDavid Brownell tps65010_set_led(LED2, OFF); 215d94577d5SDavid Brownell 216d94577d5SDavid Brownell /* Enable LOW_PWR handshake */ 217d94577d5SDavid Brownell tps65010_set_low_pwr(ON); 218d94577d5SDavid Brownell 219d94577d5SDavid Brownell /* Switch VLDO2 to 3.0V for AIC23 */ 220d94577d5SDavid Brownell tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V 221d94577d5SDavid Brownell | TPS_LDO1_ENABLE); 222d94577d5SDavid Brownell 223d94577d5SDavid Brownell /* register these three LEDs */ 224d94577d5SDavid Brownell osk5912_tps_leds.dev.parent = &client->dev; 225d94577d5SDavid Brownell platform_device_register(&osk5912_tps_leds); 226d94577d5SDavid Brownell 227d94577d5SDavid Brownell return 0; 228d94577d5SDavid Brownell } 229d94577d5SDavid Brownell 230d94577d5SDavid Brownell static struct tps65010_board tps_board = { 231d94577d5SDavid Brownell .base = OSK_TPS_GPIO_BASE, 232d94577d5SDavid Brownell .outmask = 0x0f, 233d94577d5SDavid Brownell .setup = osk_tps_setup, 234d94577d5SDavid Brownell }; 235d94577d5SDavid Brownell 2368056c6cbSDavid Brownell static struct i2c_board_info __initdata osk_i2c_board_info[] = { 2378056c6cbSDavid Brownell { 2388056c6cbSDavid Brownell I2C_BOARD_INFO("tps65010", 0x48), 239d94577d5SDavid Brownell .platform_data = &tps_board, 240d94577d5SDavid Brownell 2418056c6cbSDavid Brownell }, 2429b4a3577SArun KS { 2439b4a3577SArun KS I2C_BOARD_INFO("tlv320aic23", 0x1B), 2449b4a3577SArun KS }, 2458056c6cbSDavid Brownell /* TODO when driver support is ready: 2468056c6cbSDavid Brownell * - optionally on Mistral, ov9640 camera sensor at 0x30 2478056c6cbSDavid Brownell */ 2488056c6cbSDavid Brownell }; 2498056c6cbSDavid Brownell 250dbdf9cedSTony Lindgren static void __init osk_init_smc91x(void) 251dbdf9cedSTony Lindgren { 252030b1545STony Lindgren u32 l; 253030b1545STony Lindgren 254ac37a0b0SDavid Brownell if ((gpio_request(0, "smc_irq")) < 0) { 255dbdf9cedSTony Lindgren printk("Error requesting gpio 0 for smc91x irq\n"); 256dbdf9cedSTony Lindgren return; 257dbdf9cedSTony Lindgren } 258dbdf9cedSTony Lindgren 259dbdf9cedSTony Lindgren /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ 260030b1545STony Lindgren l = omap_readl(EMIFS_CCS(1)); 261030b1545STony Lindgren l |= 0x3; 262030b1545STony Lindgren omap_writel(l, EMIFS_CCS(1)); 263dbdf9cedSTony Lindgren } 264dbdf9cedSTony Lindgren 265dbdf9cedSTony Lindgren static void __init osk_init_cf(void) 266dbdf9cedSTony Lindgren { 267dbdf9cedSTony Lindgren omap_cfg_reg(M7_1610_GPIO62); 268ac37a0b0SDavid Brownell if ((gpio_request(62, "cf_irq")) < 0) { 269dbdf9cedSTony Lindgren printk("Error requesting gpio 62 for CF irq\n"); 270dbdf9cedSTony Lindgren return; 271dbdf9cedSTony Lindgren } 2727c38cf02STony Lindgren /* the CF I/O IRQ is really active-low */ 2736845664aSThomas Gleixner irq_set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING); 274dbdf9cedSTony Lindgren } 275dbdf9cedSTony Lindgren 276dbdf9cedSTony Lindgren static struct omap_usb_config osk_usb_config __initdata = { 277dbdf9cedSTony Lindgren /* has usb host connector (A) ... for development it can also 278dbdf9cedSTony Lindgren * be used, with a NONSTANDARD gender-bending cable/dongle, as 279dbdf9cedSTony Lindgren * a peripheral. 280dbdf9cedSTony Lindgren */ 281dbdf9cedSTony Lindgren #ifdef CONFIG_USB_GADGET_OMAP 282dbdf9cedSTony Lindgren .register_dev = 1, 283dbdf9cedSTony Lindgren .hmc_mode = 0, 284dbdf9cedSTony Lindgren #else 285dbdf9cedSTony Lindgren .register_host = 1, 286dbdf9cedSTony Lindgren .hmc_mode = 16, 287dbdf9cedSTony Lindgren .rwc = 1, 288dbdf9cedSTony Lindgren #endif 289dbdf9cedSTony Lindgren .pins[0] = 2, 290dbdf9cedSTony Lindgren }; 291dbdf9cedSTony Lindgren 29278762841SDavid Brownell #ifdef CONFIG_OMAP_OSK_MISTRAL 2933179a019STony Lindgren static struct omap_lcd_config osk_lcd_config __initdata = { 2943179a019STony Lindgren .ctrl_name = "internal", 2953179a019STony Lindgren }; 29678762841SDavid Brownell #endif 2973179a019STony Lindgren 2987c38cf02STony Lindgren #ifdef CONFIG_OMAP_OSK_MISTRAL 2997c38cf02STony Lindgren 30078762841SDavid Brownell #include <linux/input.h> 3012430c62eSDavid Brownell #include <linux/i2c/at24.h> 30278762841SDavid Brownell #include <linux/spi/spi.h> 30378762841SDavid Brownell #include <linux/spi/ads7846.h> 30478762841SDavid Brownell 305ce491cf8STony Lindgren #include <plat/keypad.h> 30678762841SDavid Brownell 3072430c62eSDavid Brownell static struct at24_platform_data at24c04 = { 3082430c62eSDavid Brownell .byte_len = SZ_4K / 8, 3092430c62eSDavid Brownell .page_size = 16, 3102430c62eSDavid Brownell }; 3112430c62eSDavid Brownell 3122430c62eSDavid Brownell static struct i2c_board_info __initdata mistral_i2c_board_info[] = { 3132430c62eSDavid Brownell { 3142430c62eSDavid Brownell /* NOTE: powered from LCD supply */ 3152430c62eSDavid Brownell I2C_BOARD_INFO("24c04", 0x50), 3162430c62eSDavid Brownell .platform_data = &at24c04, 3172430c62eSDavid Brownell }, 3182430c62eSDavid Brownell /* TODO when driver support is ready: 3192430c62eSDavid Brownell * - optionally ov9640 camera sensor at 0x30 3202430c62eSDavid Brownell */ 3212430c62eSDavid Brownell }; 3222430c62eSDavid Brownell 323da1f026bSJanusz Krzysztofik static const unsigned int osk_keymap[] = { 32478762841SDavid Brownell /* KEY(col, row, code) */ 32578762841SDavid Brownell KEY(0, 0, KEY_F1), /* SW4 */ 326da1f026bSJanusz Krzysztofik KEY(3, 0, KEY_UP), /* (sw2/up) */ 32778762841SDavid Brownell KEY(1, 1, KEY_LEFTCTRL), /* SW5 */ 328da1f026bSJanusz Krzysztofik KEY(2, 1, KEY_LEFT), /* (sw2/left) */ 329da1f026bSJanusz Krzysztofik KEY(0, 2, KEY_SPACE), /* SW3 */ 330da1f026bSJanusz Krzysztofik KEY(1, 2, KEY_ESC), /* SW6 */ 33178762841SDavid Brownell KEY(2, 2, KEY_DOWN), /* (sw2/down) */ 332da1f026bSJanusz Krzysztofik KEY(2, 3, KEY_ENTER), /* (sw2/select) */ 33378762841SDavid Brownell KEY(3, 3, KEY_RIGHT), /* (sw2/right) */ 334da1f026bSJanusz Krzysztofik }; 335da1f026bSJanusz Krzysztofik 336da1f026bSJanusz Krzysztofik static const struct matrix_keymap_data osk_keymap_data = { 337da1f026bSJanusz Krzysztofik .keymap = osk_keymap, 338da1f026bSJanusz Krzysztofik .keymap_size = ARRAY_SIZE(osk_keymap), 33978762841SDavid Brownell }; 34078762841SDavid Brownell 34178762841SDavid Brownell static struct omap_kp_platform_data osk_kp_data = { 34278762841SDavid Brownell .rows = 8, 34378762841SDavid Brownell .cols = 8, 344da1f026bSJanusz Krzysztofik .keymap_data = &osk_keymap_data, 3454d24607bSKomal Shah .delay = 9, 34678762841SDavid Brownell }; 34778762841SDavid Brownell 34878762841SDavid Brownell static struct resource osk5912_kp_resources[] = { 34978762841SDavid Brownell [0] = { 35078762841SDavid Brownell .start = INT_KEYBOARD, 35178762841SDavid Brownell .end = INT_KEYBOARD, 35278762841SDavid Brownell .flags = IORESOURCE_IRQ, 35378762841SDavid Brownell }, 35478762841SDavid Brownell }; 35578762841SDavid Brownell 35678762841SDavid Brownell static struct platform_device osk5912_kp_device = { 35778762841SDavid Brownell .name = "omap-keypad", 35878762841SDavid Brownell .id = -1, 35978762841SDavid Brownell .dev = { 36078762841SDavid Brownell .platform_data = &osk_kp_data, 36178762841SDavid Brownell }, 36278762841SDavid Brownell .num_resources = ARRAY_SIZE(osk5912_kp_resources), 36378762841SDavid Brownell .resource = osk5912_kp_resources, 36478762841SDavid Brownell }; 36578762841SDavid Brownell 3664dcc6d24SDavid Brownell static struct omap_backlight_config mistral_bl_data = { 3674dcc6d24SDavid Brownell .default_intensity = 0xa0, 3684dcc6d24SDavid Brownell }; 3694dcc6d24SDavid Brownell 3704dcc6d24SDavid Brownell static struct platform_device mistral_bl_device = { 3714dcc6d24SDavid Brownell .name = "omap-bl", 3724dcc6d24SDavid Brownell .id = -1, 3734dcc6d24SDavid Brownell .dev = { 3744dcc6d24SDavid Brownell .platform_data = &mistral_bl_data, 3754dcc6d24SDavid Brownell }, 3764dcc6d24SDavid Brownell }; 3774dcc6d24SDavid Brownell 37878762841SDavid Brownell static struct platform_device osk5912_lcd_device = { 37978762841SDavid Brownell .name = "lcd_osk", 38078762841SDavid Brownell .id = -1, 38178762841SDavid Brownell }; 38278762841SDavid Brownell 38378762841SDavid Brownell static struct platform_device *mistral_devices[] __initdata = { 38478762841SDavid Brownell &osk5912_kp_device, 3854dcc6d24SDavid Brownell &mistral_bl_device, 38678762841SDavid Brownell &osk5912_lcd_device, 38778762841SDavid Brownell }; 38878762841SDavid Brownell 389e8cdf7bdSDavid Brownell static int mistral_get_pendown_state(void) 390e8cdf7bdSDavid Brownell { 391ac37a0b0SDavid Brownell return !gpio_get_value(4); 392e8cdf7bdSDavid Brownell } 393e8cdf7bdSDavid Brownell 39478762841SDavid Brownell static const struct ads7846_platform_data mistral_ts_info = { 39578762841SDavid Brownell .model = 7846, 39678762841SDavid Brownell .vref_delay_usecs = 100, /* internal, no capacitor */ 39778762841SDavid Brownell .x_plate_ohms = 419, 39878762841SDavid Brownell .y_plate_ohms = 486, 399e8cdf7bdSDavid Brownell .get_pendown_state = mistral_get_pendown_state, 40078762841SDavid Brownell }; 40178762841SDavid Brownell 40278762841SDavid Brownell static struct spi_board_info __initdata mistral_boardinfo[] = { { 40378762841SDavid Brownell /* MicroWire (bus 2) CS0 has an ads7846e */ 40478762841SDavid Brownell .modalias = "ads7846", 40578762841SDavid Brownell .platform_data = &mistral_ts_info, 40678762841SDavid Brownell .max_speed_hz = 120000 /* max sample rate at 3V */ 40778762841SDavid Brownell * 26 /* command + data + overhead */, 40878762841SDavid Brownell .bus_num = 2, 40978762841SDavid Brownell .chip_select = 0, 41078762841SDavid Brownell } }; 41178762841SDavid Brownell 4127c38cf02STony Lindgren #ifdef CONFIG_PM 4137c38cf02STony Lindgren static irqreturn_t 4140cd61b68SLinus Torvalds osk_mistral_wake_interrupt(int irq, void *ignored) 4157c38cf02STony Lindgren { 4167c38cf02STony Lindgren return IRQ_HANDLED; 4177c38cf02STony Lindgren } 4187c38cf02STony Lindgren #endif 4197c38cf02STony Lindgren 4207c38cf02STony Lindgren static void __init osk_mistral_init(void) 4217c38cf02STony Lindgren { 42278762841SDavid Brownell /* NOTE: we could actually tell if there's a Mistral board 4237c38cf02STony Lindgren * attached, e.g. by trying to read something from the ads7846. 42478762841SDavid Brownell * But this arch_init() code is too early for that, since we 42578762841SDavid Brownell * can't talk to the ads or even the i2c eeprom. 4267c38cf02STony Lindgren */ 4277c38cf02STony Lindgren 428c72d8950SDavid Brownell /* parallel camera interface */ 429c72d8950SDavid Brownell omap_cfg_reg(J15_1610_CAM_LCLK); 430c72d8950SDavid Brownell omap_cfg_reg(J18_1610_CAM_D7); 431c72d8950SDavid Brownell omap_cfg_reg(J19_1610_CAM_D6); 432c72d8950SDavid Brownell omap_cfg_reg(J14_1610_CAM_D5); 433c72d8950SDavid Brownell omap_cfg_reg(K18_1610_CAM_D4); 434c72d8950SDavid Brownell omap_cfg_reg(K19_1610_CAM_D3); 435c72d8950SDavid Brownell omap_cfg_reg(K15_1610_CAM_D2); 436c72d8950SDavid Brownell omap_cfg_reg(K14_1610_CAM_D1); 437c72d8950SDavid Brownell omap_cfg_reg(L19_1610_CAM_D0); 438c72d8950SDavid Brownell omap_cfg_reg(L18_1610_CAM_VS); 439c72d8950SDavid Brownell omap_cfg_reg(L15_1610_CAM_HS); 440c72d8950SDavid Brownell omap_cfg_reg(M19_1610_CAM_RSTZ); 441c72d8950SDavid Brownell omap_cfg_reg(Y15_1610_CAM_OUTCLK); 442c72d8950SDavid Brownell 443c72d8950SDavid Brownell /* serial camera interface */ 444c72d8950SDavid Brownell omap_cfg_reg(H19_1610_CAM_EXCLK); 445c72d8950SDavid Brownell omap_cfg_reg(W13_1610_CCP_CLKM); 446c72d8950SDavid Brownell omap_cfg_reg(Y12_1610_CCP_CLKP); 447c72d8950SDavid Brownell /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */ 4486e2d4107SDavid Cohen /* omap_cfg_reg(Y14_1610_CCP_DATAM); */ 449c72d8950SDavid Brownell omap_cfg_reg(W14_1610_CCP_DATAP); 450c72d8950SDavid Brownell 451c72d8950SDavid Brownell /* CAM_PWDN */ 452ac37a0b0SDavid Brownell if (gpio_request(11, "cam_pwdn") == 0) { 453c72d8950SDavid Brownell omap_cfg_reg(N20_1610_GPIO11); 454ac37a0b0SDavid Brownell gpio_direction_output(11, 0); 455c72d8950SDavid Brownell } else 456c72d8950SDavid Brownell pr_debug("OSK+Mistral: CAM_PWDN is awol\n"); 457c72d8950SDavid Brownell 458c72d8950SDavid Brownell 4596e2d4107SDavid Cohen /* omap_cfg_reg(P19_1610_GPIO6); */ /* BUSY */ 460ac37a0b0SDavid Brownell gpio_request(6, "ts_busy"); 461ac37a0b0SDavid Brownell gpio_direction_input(6); 462ac37a0b0SDavid Brownell 4636e2d4107SDavid Cohen omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */ 464ac37a0b0SDavid Brownell gpio_request(4, "ts_int"); 465ac37a0b0SDavid Brownell gpio_direction_input(4); 4666845664aSThomas Gleixner irq_set_irq_type(gpio_to_irq(4), IRQ_TYPE_EDGE_FALLING); 467ac37a0b0SDavid Brownell 46846a0a540STarun Kanti DebBarma mistral_boardinfo[0].irq = gpio_to_irq(4); 46978762841SDavid Brownell spi_register_board_info(mistral_boardinfo, 47078762841SDavid Brownell ARRAY_SIZE(mistral_boardinfo)); 47178762841SDavid Brownell 4722430c62eSDavid Brownell /* the sideways button (SW1) is for use as a "wakeup" button 4732430c62eSDavid Brownell * 4742430c62eSDavid Brownell * NOTE: The Mistral board has the wakeup button (SW1) wired 4752430c62eSDavid Brownell * to the LCD 3.3V rail, which is powered down during suspend. 4762430c62eSDavid Brownell * To allow this button to wake up the omap, work around this 4772430c62eSDavid Brownell * HW bug by rewiring SW1 to use the main 3.3V rail. 4782430c62eSDavid Brownell */ 4797c38cf02STony Lindgren omap_cfg_reg(N15_1610_MPUIO2); 480ac37a0b0SDavid Brownell if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) { 4817c38cf02STony Lindgren int ret = 0; 48215f74b03SDavid Brownell int irq = gpio_to_irq(OMAP_MPUIO(2)); 483ac37a0b0SDavid Brownell 484ac37a0b0SDavid Brownell gpio_direction_input(OMAP_MPUIO(2)); 4856845664aSThomas Gleixner irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING); 4867c38cf02STony Lindgren #ifdef CONFIG_PM 4877c38cf02STony Lindgren /* share the IRQ in case someone wants to use the 4887c38cf02STony Lindgren * button for more than wakeup from system sleep. 4897c38cf02STony Lindgren */ 49015f74b03SDavid Brownell ret = request_irq(irq, 4917c38cf02STony Lindgren &osk_mistral_wake_interrupt, 49252e405eaSThomas Gleixner IRQF_SHARED, "mistral_wakeup", 4937c38cf02STony Lindgren &osk_mistral_wake_interrupt); 4947c38cf02STony Lindgren if (ret != 0) { 495ac37a0b0SDavid Brownell gpio_free(OMAP_MPUIO(2)); 4967c38cf02STony Lindgren printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n", 4977c38cf02STony Lindgren ret); 4987c38cf02STony Lindgren } else 49915f74b03SDavid Brownell enable_irq_wake(irq); 5007c38cf02STony Lindgren #endif 5017c38cf02STony Lindgren } else 5027c38cf02STony Lindgren printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n"); 50378762841SDavid Brownell 5044dcc6d24SDavid Brownell /* LCD: backlight, and power; power controls other devices on the 5054dcc6d24SDavid Brownell * board, like the touchscreen, EEPROM, and wakeup (!) switch. 5064dcc6d24SDavid Brownell */ 5074dcc6d24SDavid Brownell omap_cfg_reg(PWL); 508ac37a0b0SDavid Brownell if (gpio_request(2, "lcd_pwr") == 0) 509ac37a0b0SDavid Brownell gpio_direction_output(2, 1); 5104dcc6d24SDavid Brownell 5112430c62eSDavid Brownell i2c_register_board_info(1, mistral_i2c_board_info, 5122430c62eSDavid Brownell ARRAY_SIZE(mistral_i2c_board_info)); 5132430c62eSDavid Brownell 51478762841SDavid Brownell platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices)); 5157c38cf02STony Lindgren } 5167c38cf02STony Lindgren #else 5177c38cf02STony Lindgren static void __init osk_mistral_init(void) { } 5187c38cf02STony Lindgren #endif 5197c38cf02STony Lindgren 5209b6553cdSTony Lindgren #define EMIFS_CS3_VAL (0x88013141) 5219b6553cdSTony Lindgren 522dbdf9cedSTony Lindgren static void __init osk_init(void) 523dbdf9cedSTony Lindgren { 524030b1545STony Lindgren u32 l; 525030b1545STony Lindgren 526c2cdaffeSTony Lindgren osk_init_smc91x(); 527c2cdaffeSTony Lindgren osk_init_cf(); 528c2cdaffeSTony Lindgren 5299b6553cdSTony Lindgren /* Workaround for wrong CS3 (NOR flash) timing 5309b6553cdSTony Lindgren * There are some U-Boot versions out there which configure 5319b6553cdSTony Lindgren * wrong CS3 memory timings. This mainly leads to CRC 5326cbdc8c5SSimon Arlott * or similar errors if you use NOR flash (e.g. with JFFS2) 5339b6553cdSTony Lindgren */ 534030b1545STony Lindgren l = omap_readl(EMIFS_CCS(3)); 535030b1545STony Lindgren if (l != EMIFS_CS3_VAL) 536030b1545STony Lindgren omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3)); 5379b6553cdSTony Lindgren 5387c38cf02STony Lindgren osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys(); 5397c38cf02STony Lindgren osk_flash_resource.end += SZ_32M - 1; 54046a0a540STarun Kanti DebBarma osk5912_smc91x_resources[1].start = gpio_to_irq(0); 54146a0a540STarun Kanti DebBarma osk5912_smc91x_resources[1].end = gpio_to_irq(0); 54246a0a540STarun Kanti DebBarma osk5912_cf_resources[0].start = gpio_to_irq(62); 54346a0a540STarun Kanti DebBarma osk5912_cf_resources[0].end = gpio_to_irq(62); 544dbdf9cedSTony Lindgren platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices)); 545f35ae634STony Lindgren 546f35ae634STony Lindgren l = omap_readl(USB_TRANSCEIVER_CTRL); 547f35ae634STony Lindgren l |= (3 << 1); 548f35ae634STony Lindgren omap_writel(l, USB_TRANSCEIVER_CTRL); 5497c38cf02STony Lindgren 550dd0cdd88STony Lindgren omap1_usb_init(&osk_usb_config); 551b0b5aa3fSFelipe Balbi 5528056c6cbSDavid Brownell /* irq for tps65010 chip */ 5538056c6cbSDavid Brownell /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */ 5548056c6cbSDavid Brownell if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0) 5558056c6cbSDavid Brownell gpio_direction_input(OMAP_MPUIO(1)); 5568056c6cbSDavid Brownell 5573179a019STony Lindgren omap_serial_init(); 55846a0a540STarun Kanti DebBarma osk_i2c_board_info[0].irq = gpio_to_irq(OMAP_MPUIO(1)); 5591ed16a86SJarkko Nikula omap_register_i2c_bus(1, 400, osk_i2c_board_info, 5601ed16a86SJarkko Nikula ARRAY_SIZE(osk_i2c_board_info)); 5617c38cf02STony Lindgren osk_mistral_init(); 562ddba6c7fSTomi Valkeinen 563ddba6c7fSTomi Valkeinen #ifdef CONFIG_OMAP_OSK_MISTRAL 564ddba6c7fSTomi Valkeinen omapfb_set_lcd_config(&osk_lcd_config); 565ddba6c7fSTomi Valkeinen #endif 566ddba6c7fSTomi Valkeinen 567dbdf9cedSTony Lindgren } 568dbdf9cedSTony Lindgren 569dbdf9cedSTony Lindgren MACHINE_START(OMAP_OSK, "TI-OSK") 570dbdf9cedSTony Lindgren /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */ 571246e389dSNicolas Pitre .atag_offset = 0x100, 5727b88e62fSTony Lindgren .map_io = omap16xx_map_io, 5737b88e62fSTony Lindgren .init_early = omap1_init_early, 57471ee7dadSRussell King .reserve = omap_reserve, 5757b88e62fSTony Lindgren .init_irq = omap1_init_irq, 576dbdf9cedSTony Lindgren .init_machine = osk_init, 57782c3bd03SShawn Guo .init_late = omap1_init_late, 578e74984e4STony Lindgren .timer = &omap1_timer, 579baa95883SRussell King .restart = omap1_restart, 580dbdf9cedSTony Lindgren MACHINE_END 581