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> 2915d157e8SLinus Walleij #include <linux/gpio/machine.h> 30dbdf9cedSTony Lindgren #include <linux/kernel.h> 31dbdf9cedSTony Lindgren #include <linux/init.h> 32d052d1beSRussell King #include <linux/platform_device.h> 33a524626bSTony Lindgren #include <linux/interrupt.h> 34d533c128SThomas Gleixner #include <linux/irq.h> 358056c6cbSDavid Brownell #include <linux/i2c.h> 36d94577d5SDavid Brownell #include <linux/leds.h> 373bc48014SLadislav Michl #include <linux/smc91x.h> 38ddba6c7fSTomi Valkeinen #include <linux/omapfb.h> 397c38cf02STony Lindgren #include <linux/mtd/mtd.h> 407c38cf02STony Lindgren #include <linux/mtd/partitions.h> 41561b036aSLadislav Michl #include <linux/mtd/physmap.h> 429787076cSWolfram Sang #include <linux/mfd/tps65010.h> 434b25408fSTony Lindgren #include <linux/platform_data/gpio-omap.h> 44cc012729SIgor Grinberg #include <linux/platform_data/omap1_bl.h> 45*7e0a9e62SArnd Bergmann #include <linux/soc/ti/omap1-io.h> 466d16bfb5SDavid Brownell 47dbdf9cedSTony Lindgren #include <asm/mach-types.h> 48dbdf9cedSTony Lindgren #include <asm/mach/arch.h> 49dbdf9cedSTony Lindgren #include <asm/mach/map.h> 50dbdf9cedSTony Lindgren 51*7e0a9e62SArnd Bergmann #include "tc.h" 52100f9638SArnd Bergmann #include "flash.h" 53*7e0a9e62SArnd Bergmann #include "mux.h" 54*7e0a9e62SArnd Bergmann #include "hardware.h" 55e8e77e97SArnd Bergmann #include "usb.h" 564e65331cSTony Lindgren #include "common.h" 579b6553cdSTony Lindgren 5815d157e8SLinus Walleij /* Name of the GPIO chip used by the OMAP for GPIOs 0..15 */ 5915d157e8SLinus Walleij #define OMAP_GPIO_LABEL "gpio-0-15" 6015d157e8SLinus Walleij 613a0110cdSTony Lindgren /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ 623a0110cdSTony Lindgren #define OMAP_OSK_ETHR_START 0x04800300 633a0110cdSTony Lindgren 643a0110cdSTony Lindgren /* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with 653a0110cdSTony Lindgren * alternate pin configurations for hardware-controlled blinking. 663a0110cdSTony Lindgren */ 673a0110cdSTony Lindgren #define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */) 683a0110cdSTony Lindgren # define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0) 693a0110cdSTony Lindgren # define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1) 703a0110cdSTony Lindgren # define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2) 713a0110cdSTony Lindgren # define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3) 723a0110cdSTony Lindgren # define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4) 733a0110cdSTony Lindgren # define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5) 743a0110cdSTony Lindgren 757c38cf02STony Lindgren static struct mtd_partition osk_partitions[] = { 767c38cf02STony Lindgren /* bootloader (U-Boot, etc) in first sector */ 777c38cf02STony Lindgren { 787c38cf02STony Lindgren .name = "bootloader", 797c38cf02STony Lindgren .offset = 0, 807c38cf02STony Lindgren .size = SZ_128K, 817c38cf02STony Lindgren .mask_flags = MTD_WRITEABLE, /* force read-only */ 827c38cf02STony Lindgren }, 837c38cf02STony Lindgren /* bootloader params in the next sector */ 847c38cf02STony Lindgren { 857c38cf02STony Lindgren .name = "params", 867c38cf02STony Lindgren .offset = MTDPART_OFS_APPEND, 877c38cf02STony Lindgren .size = SZ_128K, 887c38cf02STony Lindgren .mask_flags = 0, 897c38cf02STony Lindgren }, { 907c38cf02STony Lindgren .name = "kernel", 917c38cf02STony Lindgren .offset = MTDPART_OFS_APPEND, 927c38cf02STony Lindgren .size = SZ_2M, 937c38cf02STony Lindgren .mask_flags = 0 947c38cf02STony Lindgren }, { 957c38cf02STony Lindgren .name = "filesystem", 967c38cf02STony Lindgren .offset = MTDPART_OFS_APPEND, 977c38cf02STony Lindgren .size = MTDPART_SIZ_FULL, 987c38cf02STony Lindgren .mask_flags = 0 997c38cf02STony Lindgren } 100dbdf9cedSTony Lindgren }; 101dbdf9cedSTony Lindgren 102561b036aSLadislav Michl static struct physmap_flash_data osk_flash_data = { 1037c38cf02STony Lindgren .width = 2, 104561b036aSLadislav Michl .set_vpp = omap1_set_vpp, 1057c38cf02STony Lindgren .parts = osk_partitions, 1067c38cf02STony Lindgren .nr_parts = ARRAY_SIZE(osk_partitions), 1077c38cf02STony Lindgren }; 1087c38cf02STony Lindgren 1097c38cf02STony Lindgren static struct resource osk_flash_resource = { 1107c38cf02STony Lindgren /* this is on CS3, wherever it's mapped */ 1117c38cf02STony Lindgren .flags = IORESOURCE_MEM, 1127c38cf02STony Lindgren }; 1137c38cf02STony Lindgren 1147c38cf02STony Lindgren static struct platform_device osk5912_flash_device = { 115561b036aSLadislav Michl .name = "physmap-flash", 1167c38cf02STony Lindgren .id = 0, 1177c38cf02STony Lindgren .dev = { 1187c38cf02STony Lindgren .platform_data = &osk_flash_data, 1197c38cf02STony Lindgren }, 1207c38cf02STony Lindgren .num_resources = 1, 1217c38cf02STony Lindgren .resource = &osk_flash_resource, 1227c38cf02STony Lindgren }; 123dbdf9cedSTony Lindgren 1243bc48014SLadislav Michl static struct smc91x_platdata osk5912_smc91x_info = { 1253bc48014SLadislav Michl .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT, 1263bc48014SLadislav Michl .leda = RPC_LED_100_10, 1273bc48014SLadislav Michl .ledb = RPC_LED_TX_RX, 1283bc48014SLadislav Michl }; 1293bc48014SLadislav Michl 130dbdf9cedSTony Lindgren static struct resource osk5912_smc91x_resources[] = { 131dbdf9cedSTony Lindgren [0] = { 132dbdf9cedSTony Lindgren .start = OMAP_OSK_ETHR_START, /* Physical */ 133dbdf9cedSTony Lindgren .end = OMAP_OSK_ETHR_START + 0xf, 134dbdf9cedSTony Lindgren .flags = IORESOURCE_MEM, 135dbdf9cedSTony Lindgren }, 136dbdf9cedSTony Lindgren [1] = { 137e7b3dc7eSRussell King .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, 138dbdf9cedSTony Lindgren }, 139dbdf9cedSTony Lindgren }; 140dbdf9cedSTony Lindgren 141dbdf9cedSTony Lindgren static struct platform_device osk5912_smc91x_device = { 142dbdf9cedSTony Lindgren .name = "smc91x", 143dbdf9cedSTony Lindgren .id = -1, 1443bc48014SLadislav Michl .dev = { 1453bc48014SLadislav Michl .platform_data = &osk5912_smc91x_info, 1463bc48014SLadislav Michl }, 147dbdf9cedSTony Lindgren .num_resources = ARRAY_SIZE(osk5912_smc91x_resources), 148dbdf9cedSTony Lindgren .resource = osk5912_smc91x_resources, 149dbdf9cedSTony Lindgren }; 150dbdf9cedSTony Lindgren 151dbdf9cedSTony Lindgren static struct resource osk5912_cf_resources[] = { 152dbdf9cedSTony Lindgren [0] = { 153dbdf9cedSTony Lindgren .flags = IORESOURCE_IRQ, 154dbdf9cedSTony Lindgren }, 155d87d44f7SArnd Bergmann [1] = { 156d87d44f7SArnd Bergmann .flags = IORESOURCE_MEM, 157d87d44f7SArnd Bergmann }, 158dbdf9cedSTony Lindgren }; 159dbdf9cedSTony Lindgren 160dbdf9cedSTony Lindgren static struct platform_device osk5912_cf_device = { 161dbdf9cedSTony Lindgren .name = "omap_cf", 162dbdf9cedSTony Lindgren .id = -1, 163dbdf9cedSTony Lindgren .num_resources = ARRAY_SIZE(osk5912_cf_resources), 164dbdf9cedSTony Lindgren .resource = osk5912_cf_resources, 165dbdf9cedSTony Lindgren }; 166dbdf9cedSTony Lindgren 167dbdf9cedSTony Lindgren static struct platform_device *osk5912_devices[] __initdata = { 1687c38cf02STony Lindgren &osk5912_flash_device, 169dbdf9cedSTony Lindgren &osk5912_smc91x_device, 170dbdf9cedSTony Lindgren &osk5912_cf_device, 171dbdf9cedSTony Lindgren }; 172dbdf9cedSTony Lindgren 17340dda872SArvind Yadav static const struct gpio_led tps_leds[] = { 174d94577d5SDavid Brownell /* NOTE: D9 and D2 have hardware blink support. 175d94577d5SDavid Brownell * Also, D9 requires non-battery power. 176d94577d5SDavid Brownell */ 1775dd81e25SDavid Brownell { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9", 178e5808227SStephan Linz .default_trigger = "disk-activity", }, 179d94577d5SDavid Brownell { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", }, 180d94577d5SDavid Brownell { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1, 181d94577d5SDavid Brownell .default_trigger = "heartbeat", }, 182d94577d5SDavid Brownell }; 183d94577d5SDavid Brownell 184d94577d5SDavid Brownell static struct gpio_led_platform_data tps_leds_data = { 185d94577d5SDavid Brownell .num_leds = 3, 186d94577d5SDavid Brownell .leds = tps_leds, 187d94577d5SDavid Brownell }; 188d94577d5SDavid Brownell 189d94577d5SDavid Brownell static struct platform_device osk5912_tps_leds = { 190d94577d5SDavid Brownell .name = "leds-gpio", 191d94577d5SDavid Brownell .id = 0, 192d94577d5SDavid Brownell .dev.platform_data = &tps_leds_data, 193d94577d5SDavid Brownell }; 194d94577d5SDavid Brownell 195d94577d5SDavid Brownell static int osk_tps_setup(struct i2c_client *client, void *context) 196d94577d5SDavid Brownell { 1970b31c53bSArnd Bergmann if (!IS_BUILTIN(CONFIG_TPS65010)) 1980b31c53bSArnd Bergmann return -ENOSYS; 1990b31c53bSArnd Bergmann 200d94577d5SDavid Brownell /* Set GPIO 1 HIGH to disable VBUS power supply; 201d94577d5SDavid Brownell * OHCI driver powers it up/down as needed. 202d94577d5SDavid Brownell */ 203d94577d5SDavid Brownell gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en"); 204d94577d5SDavid Brownell gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1); 2056efac017SLinus Walleij /* Free the GPIO again as the driver will request it */ 2066efac017SLinus Walleij gpio_free(OSK_TPS_GPIO_USB_PWR_EN); 207d94577d5SDavid Brownell 208d94577d5SDavid Brownell /* Set GPIO 2 high so LED D3 is off by default */ 209d94577d5SDavid Brownell tps65010_set_gpio_out_value(GPIO2, HIGH); 210d94577d5SDavid Brownell 211d94577d5SDavid Brownell /* Set GPIO 3 low to take ethernet out of reset */ 212d94577d5SDavid Brownell gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset"); 213d94577d5SDavid Brownell gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0); 214d94577d5SDavid Brownell 215d94577d5SDavid Brownell /* GPIO4 is VDD_DSP */ 216d94577d5SDavid Brownell gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power"); 217d94577d5SDavid Brownell gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1); 218d94577d5SDavid Brownell /* REVISIT if DSP support isn't configured, power it off ... */ 219d94577d5SDavid Brownell 220d94577d5SDavid Brownell /* Let LED1 (D9) blink; leds-gpio may override it */ 221d94577d5SDavid Brownell tps65010_set_led(LED1, BLINK); 222d94577d5SDavid Brownell 223d94577d5SDavid Brownell /* Set LED2 off by default */ 224d94577d5SDavid Brownell tps65010_set_led(LED2, OFF); 225d94577d5SDavid Brownell 226d94577d5SDavid Brownell /* Enable LOW_PWR handshake */ 227d94577d5SDavid Brownell tps65010_set_low_pwr(ON); 228d94577d5SDavid Brownell 229d94577d5SDavid Brownell /* Switch VLDO2 to 3.0V for AIC23 */ 230d94577d5SDavid Brownell tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V 231d94577d5SDavid Brownell | TPS_LDO1_ENABLE); 232d94577d5SDavid Brownell 233d94577d5SDavid Brownell /* register these three LEDs */ 234d94577d5SDavid Brownell osk5912_tps_leds.dev.parent = &client->dev; 235d94577d5SDavid Brownell platform_device_register(&osk5912_tps_leds); 236d94577d5SDavid Brownell 237d94577d5SDavid Brownell return 0; 238d94577d5SDavid Brownell } 239d94577d5SDavid Brownell 240d94577d5SDavid Brownell static struct tps65010_board tps_board = { 241d94577d5SDavid Brownell .base = OSK_TPS_GPIO_BASE, 242d94577d5SDavid Brownell .outmask = 0x0f, 243d94577d5SDavid Brownell .setup = osk_tps_setup, 244d94577d5SDavid Brownell }; 245d94577d5SDavid Brownell 2468056c6cbSDavid Brownell static struct i2c_board_info __initdata osk_i2c_board_info[] = { 2478056c6cbSDavid Brownell { 24815d157e8SLinus Walleij /* This device will get the name "i2c-tps65010" */ 2498056c6cbSDavid Brownell I2C_BOARD_INFO("tps65010", 0x48), 25015d157e8SLinus Walleij .dev_name = "tps65010", 251d94577d5SDavid Brownell .platform_data = &tps_board, 252d94577d5SDavid Brownell 2538056c6cbSDavid Brownell }, 2549b4a3577SArun KS { 2559b4a3577SArun KS I2C_BOARD_INFO("tlv320aic23", 0x1B), 2569b4a3577SArun KS }, 2578056c6cbSDavid Brownell /* TODO when driver support is ready: 2588056c6cbSDavid Brownell * - optionally on Mistral, ov9640 camera sensor at 0x30 2598056c6cbSDavid Brownell */ 2608056c6cbSDavid Brownell }; 2618056c6cbSDavid Brownell 262dbdf9cedSTony Lindgren static void __init osk_init_smc91x(void) 263dbdf9cedSTony Lindgren { 264030b1545STony Lindgren u32 l; 265030b1545STony Lindgren 266ac37a0b0SDavid Brownell if ((gpio_request(0, "smc_irq")) < 0) { 267dbdf9cedSTony Lindgren printk("Error requesting gpio 0 for smc91x irq\n"); 268dbdf9cedSTony Lindgren return; 269dbdf9cedSTony Lindgren } 270dbdf9cedSTony Lindgren 271dbdf9cedSTony Lindgren /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ 272030b1545STony Lindgren l = omap_readl(EMIFS_CCS(1)); 273030b1545STony Lindgren l |= 0x3; 274030b1545STony Lindgren omap_writel(l, EMIFS_CCS(1)); 275dbdf9cedSTony Lindgren } 276dbdf9cedSTony Lindgren 277d87d44f7SArnd Bergmann static void __init osk_init_cf(int seg) 278dbdf9cedSTony Lindgren { 279d87d44f7SArnd Bergmann struct resource *res = &osk5912_cf_resources[1]; 280d87d44f7SArnd Bergmann 281dbdf9cedSTony Lindgren omap_cfg_reg(M7_1610_GPIO62); 282ac37a0b0SDavid Brownell if ((gpio_request(62, "cf_irq")) < 0) { 283dbdf9cedSTony Lindgren printk("Error requesting gpio 62 for CF irq\n"); 284dbdf9cedSTony Lindgren return; 285dbdf9cedSTony Lindgren } 286d87d44f7SArnd Bergmann 287d87d44f7SArnd Bergmann switch (seg) { 288d87d44f7SArnd Bergmann /* NOTE: CS0 could be configured too ... */ 289d87d44f7SArnd Bergmann case 1: 290d87d44f7SArnd Bergmann res->start = OMAP_CS1_PHYS; 291d87d44f7SArnd Bergmann break; 292d87d44f7SArnd Bergmann case 2: 293d87d44f7SArnd Bergmann res->start = OMAP_CS2_PHYS; 294d87d44f7SArnd Bergmann break; 295d87d44f7SArnd Bergmann case 3: 296d87d44f7SArnd Bergmann res->start = omap_cs3_phys(); 297d87d44f7SArnd Bergmann break; 298d87d44f7SArnd Bergmann } 299d87d44f7SArnd Bergmann 300d87d44f7SArnd Bergmann res->end = res->start + SZ_8K - 1; 301d87d44f7SArnd Bergmann osk5912_cf_device.dev.platform_data = (void *)(uintptr_t)seg; 302d87d44f7SArnd Bergmann 303d87d44f7SArnd Bergmann /* NOTE: better EMIFS setup might support more cards; but the 304d87d44f7SArnd Bergmann * TRM only shows how to affect regular flash signals, not their 305d87d44f7SArnd Bergmann * CF/PCMCIA variants... 306d87d44f7SArnd Bergmann */ 307d87d44f7SArnd Bergmann pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", __func__, 308d87d44f7SArnd Bergmann seg, omap_readl(EMIFS_CCS(seg)), omap_readl(EMIFS_ACS(seg))); 309d87d44f7SArnd Bergmann omap_writel(0x0004a1b3, EMIFS_CCS(seg)); /* synch mode 4 etc */ 310d87d44f7SArnd Bergmann omap_writel(0x00000000, EMIFS_ACS(seg)); /* OE hold/setup */ 311d87d44f7SArnd Bergmann 3127c38cf02STony Lindgren /* the CF I/O IRQ is really active-low */ 3136845664aSThomas Gleixner irq_set_irq_type(gpio_to_irq(62), IRQ_TYPE_EDGE_FALLING); 314dbdf9cedSTony Lindgren } 315dbdf9cedSTony Lindgren 31615d157e8SLinus Walleij static struct gpiod_lookup_table osk_usb_gpio_table = { 31715d157e8SLinus Walleij .dev_id = "ohci", 31815d157e8SLinus Walleij .table = { 31915d157e8SLinus Walleij /* Power GPIO on the I2C-attached TPS65010 */ 32045c57754SLinus Walleij GPIO_LOOKUP("tps65010", 0, "power", GPIO_ACTIVE_HIGH), 32115d157e8SLinus Walleij GPIO_LOOKUP(OMAP_GPIO_LABEL, 9, "overcurrent", 32215d157e8SLinus Walleij GPIO_ACTIVE_HIGH), 32315d157e8SLinus Walleij }, 32415d157e8SLinus Walleij }; 32515d157e8SLinus Walleij 326dbdf9cedSTony Lindgren static struct omap_usb_config osk_usb_config __initdata = { 327dbdf9cedSTony Lindgren /* has usb host connector (A) ... for development it can also 328dbdf9cedSTony Lindgren * be used, with a NONSTANDARD gender-bending cable/dongle, as 329dbdf9cedSTony Lindgren * a peripheral. 330dbdf9cedSTony Lindgren */ 33177c2f02eSPaul Bolle #if IS_ENABLED(CONFIG_USB_OMAP) 332dbdf9cedSTony Lindgren .register_dev = 1, 333dbdf9cedSTony Lindgren .hmc_mode = 0, 334dbdf9cedSTony Lindgren #else 335dbdf9cedSTony Lindgren .register_host = 1, 336dbdf9cedSTony Lindgren .hmc_mode = 16, 337dbdf9cedSTony Lindgren .rwc = 1, 338dbdf9cedSTony Lindgren #endif 339dbdf9cedSTony Lindgren .pins[0] = 2, 340dbdf9cedSTony Lindgren }; 341dbdf9cedSTony Lindgren 34278762841SDavid Brownell #ifdef CONFIG_OMAP_OSK_MISTRAL 343d25c70cfSBhumika Goyal static const struct omap_lcd_config osk_lcd_config __initconst = { 3443179a019STony Lindgren .ctrl_name = "internal", 3453179a019STony Lindgren }; 34678762841SDavid Brownell #endif 3473179a019STony Lindgren 3487c38cf02STony Lindgren #ifdef CONFIG_OMAP_OSK_MISTRAL 3497c38cf02STony Lindgren 35078762841SDavid Brownell #include <linux/input.h> 351fbd412baSBartosz Golaszewski #include <linux/property.h> 35278762841SDavid Brownell #include <linux/spi/spi.h> 35378762841SDavid Brownell #include <linux/spi/ads7846.h> 35478762841SDavid Brownell 3552203747cSArnd Bergmann #include <linux/platform_data/keypad-omap.h> 35678762841SDavid Brownell 357fbd412baSBartosz Golaszewski static const struct property_entry mistral_at24_properties[] = { 358fbd412baSBartosz Golaszewski PROPERTY_ENTRY_U32("pagesize", 16), 359fbd412baSBartosz Golaszewski { } 3602430c62eSDavid Brownell }; 3612430c62eSDavid Brownell 36274031824SHeikki Krogerus static const struct software_node mistral_at24_node = { 36374031824SHeikki Krogerus .properties = mistral_at24_properties, 36474031824SHeikki Krogerus }; 36574031824SHeikki Krogerus 3662430c62eSDavid Brownell static struct i2c_board_info __initdata mistral_i2c_board_info[] = { 3672430c62eSDavid Brownell { 3682430c62eSDavid Brownell /* NOTE: powered from LCD supply */ 3692430c62eSDavid Brownell I2C_BOARD_INFO("24c04", 0x50), 37074031824SHeikki Krogerus .swnode = &mistral_at24_node, 3712430c62eSDavid Brownell }, 3722430c62eSDavid Brownell /* TODO when driver support is ready: 3732430c62eSDavid Brownell * - optionally ov9640 camera sensor at 0x30 3742430c62eSDavid Brownell */ 3752430c62eSDavid Brownell }; 3762430c62eSDavid Brownell 377da1f026bSJanusz Krzysztofik static const unsigned int osk_keymap[] = { 37878762841SDavid Brownell /* KEY(col, row, code) */ 37978762841SDavid Brownell KEY(0, 0, KEY_F1), /* SW4 */ 380da1f026bSJanusz Krzysztofik KEY(3, 0, KEY_UP), /* (sw2/up) */ 38178762841SDavid Brownell KEY(1, 1, KEY_LEFTCTRL), /* SW5 */ 382da1f026bSJanusz Krzysztofik KEY(2, 1, KEY_LEFT), /* (sw2/left) */ 383da1f026bSJanusz Krzysztofik KEY(0, 2, KEY_SPACE), /* SW3 */ 384da1f026bSJanusz Krzysztofik KEY(1, 2, KEY_ESC), /* SW6 */ 38578762841SDavid Brownell KEY(2, 2, KEY_DOWN), /* (sw2/down) */ 386da1f026bSJanusz Krzysztofik KEY(2, 3, KEY_ENTER), /* (sw2/select) */ 38778762841SDavid Brownell KEY(3, 3, KEY_RIGHT), /* (sw2/right) */ 388da1f026bSJanusz Krzysztofik }; 389da1f026bSJanusz Krzysztofik 390da1f026bSJanusz Krzysztofik static const struct matrix_keymap_data osk_keymap_data = { 391da1f026bSJanusz Krzysztofik .keymap = osk_keymap, 392da1f026bSJanusz Krzysztofik .keymap_size = ARRAY_SIZE(osk_keymap), 39378762841SDavid Brownell }; 39478762841SDavid Brownell 39578762841SDavid Brownell static struct omap_kp_platform_data osk_kp_data = { 39678762841SDavid Brownell .rows = 8, 39778762841SDavid Brownell .cols = 8, 398da1f026bSJanusz Krzysztofik .keymap_data = &osk_keymap_data, 3994d24607bSKomal Shah .delay = 9, 40078762841SDavid Brownell }; 40178762841SDavid Brownell 40278762841SDavid Brownell static struct resource osk5912_kp_resources[] = { 40378762841SDavid Brownell [0] = { 40478762841SDavid Brownell .start = INT_KEYBOARD, 40578762841SDavid Brownell .end = INT_KEYBOARD, 40678762841SDavid Brownell .flags = IORESOURCE_IRQ, 40778762841SDavid Brownell }, 40878762841SDavid Brownell }; 40978762841SDavid Brownell 41078762841SDavid Brownell static struct platform_device osk5912_kp_device = { 41178762841SDavid Brownell .name = "omap-keypad", 41278762841SDavid Brownell .id = -1, 41378762841SDavid Brownell .dev = { 41478762841SDavid Brownell .platform_data = &osk_kp_data, 41578762841SDavid Brownell }, 41678762841SDavid Brownell .num_resources = ARRAY_SIZE(osk5912_kp_resources), 41778762841SDavid Brownell .resource = osk5912_kp_resources, 41878762841SDavid Brownell }; 41978762841SDavid Brownell 4204dcc6d24SDavid Brownell static struct omap_backlight_config mistral_bl_data = { 4214dcc6d24SDavid Brownell .default_intensity = 0xa0, 4224dcc6d24SDavid Brownell }; 4234dcc6d24SDavid Brownell 4244dcc6d24SDavid Brownell static struct platform_device mistral_bl_device = { 4254dcc6d24SDavid Brownell .name = "omap-bl", 4264dcc6d24SDavid Brownell .id = -1, 4274dcc6d24SDavid Brownell .dev = { 4284dcc6d24SDavid Brownell .platform_data = &mistral_bl_data, 4294dcc6d24SDavid Brownell }, 4304dcc6d24SDavid Brownell }; 4314dcc6d24SDavid Brownell 43278762841SDavid Brownell static struct platform_device osk5912_lcd_device = { 43378762841SDavid Brownell .name = "lcd_osk", 43478762841SDavid Brownell .id = -1, 43578762841SDavid Brownell }; 43678762841SDavid Brownell 43740dda872SArvind Yadav static const struct gpio_led mistral_gpio_led_pins[] = { 438dafbeadfSBryan Wu { 439dafbeadfSBryan Wu .name = "mistral:red", 440dafbeadfSBryan Wu .default_trigger = "heartbeat", 441dafbeadfSBryan Wu .gpio = 3, 442dafbeadfSBryan Wu }, 443dafbeadfSBryan Wu { 444dafbeadfSBryan Wu .name = "mistral:green", 445dafbeadfSBryan Wu .default_trigger = "cpu0", 446dafbeadfSBryan Wu .gpio = OMAP_MPUIO(4), 447dafbeadfSBryan Wu }, 448dafbeadfSBryan Wu }; 449dafbeadfSBryan Wu 450dafbeadfSBryan Wu static struct gpio_led_platform_data mistral_gpio_led_data = { 451dafbeadfSBryan Wu .leds = mistral_gpio_led_pins, 452dafbeadfSBryan Wu .num_leds = ARRAY_SIZE(mistral_gpio_led_pins), 453dafbeadfSBryan Wu }; 454dafbeadfSBryan Wu 455dafbeadfSBryan Wu static struct platform_device mistral_gpio_leds = { 456dafbeadfSBryan Wu .name = "leds-gpio", 457dafbeadfSBryan Wu .id = -1, 458dafbeadfSBryan Wu .dev = { 459dafbeadfSBryan Wu .platform_data = &mistral_gpio_led_data, 460dafbeadfSBryan Wu }, 461dafbeadfSBryan Wu }; 462dafbeadfSBryan Wu 46378762841SDavid Brownell static struct platform_device *mistral_devices[] __initdata = { 46478762841SDavid Brownell &osk5912_kp_device, 4654dcc6d24SDavid Brownell &mistral_bl_device, 46678762841SDavid Brownell &osk5912_lcd_device, 467dafbeadfSBryan Wu &mistral_gpio_leds, 46878762841SDavid Brownell }; 46978762841SDavid Brownell 470e8cdf7bdSDavid Brownell static int mistral_get_pendown_state(void) 471e8cdf7bdSDavid Brownell { 472ac37a0b0SDavid Brownell return !gpio_get_value(4); 473e8cdf7bdSDavid Brownell } 474e8cdf7bdSDavid Brownell 47578762841SDavid Brownell static const struct ads7846_platform_data mistral_ts_info = { 47678762841SDavid Brownell .model = 7846, 47778762841SDavid Brownell .vref_delay_usecs = 100, /* internal, no capacitor */ 47878762841SDavid Brownell .x_plate_ohms = 419, 47978762841SDavid Brownell .y_plate_ohms = 486, 480e8cdf7bdSDavid Brownell .get_pendown_state = mistral_get_pendown_state, 48178762841SDavid Brownell }; 48278762841SDavid Brownell 48378762841SDavid Brownell static struct spi_board_info __initdata mistral_boardinfo[] = { { 48478762841SDavid Brownell /* MicroWire (bus 2) CS0 has an ads7846e */ 48578762841SDavid Brownell .modalias = "ads7846", 48678762841SDavid Brownell .platform_data = &mistral_ts_info, 48778762841SDavid Brownell .max_speed_hz = 120000 /* max sample rate at 3V */ 48878762841SDavid Brownell * 26 /* command + data + overhead */, 48978762841SDavid Brownell .bus_num = 2, 49078762841SDavid Brownell .chip_select = 0, 49178762841SDavid Brownell } }; 49278762841SDavid Brownell 4937c38cf02STony Lindgren static irqreturn_t 4940cd61b68SLinus Torvalds osk_mistral_wake_interrupt(int irq, void *ignored) 4957c38cf02STony Lindgren { 4967c38cf02STony Lindgren return IRQ_HANDLED; 4977c38cf02STony Lindgren } 4987c38cf02STony Lindgren 4997c38cf02STony Lindgren static void __init osk_mistral_init(void) 5007c38cf02STony Lindgren { 50178762841SDavid Brownell /* NOTE: we could actually tell if there's a Mistral board 5027c38cf02STony Lindgren * attached, e.g. by trying to read something from the ads7846. 50378762841SDavid Brownell * But this arch_init() code is too early for that, since we 50478762841SDavid Brownell * can't talk to the ads or even the i2c eeprom. 5057c38cf02STony Lindgren */ 5067c38cf02STony Lindgren 507c72d8950SDavid Brownell /* parallel camera interface */ 508c72d8950SDavid Brownell omap_cfg_reg(J15_1610_CAM_LCLK); 509c72d8950SDavid Brownell omap_cfg_reg(J18_1610_CAM_D7); 510c72d8950SDavid Brownell omap_cfg_reg(J19_1610_CAM_D6); 511c72d8950SDavid Brownell omap_cfg_reg(J14_1610_CAM_D5); 512c72d8950SDavid Brownell omap_cfg_reg(K18_1610_CAM_D4); 513c72d8950SDavid Brownell omap_cfg_reg(K19_1610_CAM_D3); 514c72d8950SDavid Brownell omap_cfg_reg(K15_1610_CAM_D2); 515c72d8950SDavid Brownell omap_cfg_reg(K14_1610_CAM_D1); 516c72d8950SDavid Brownell omap_cfg_reg(L19_1610_CAM_D0); 517c72d8950SDavid Brownell omap_cfg_reg(L18_1610_CAM_VS); 518c72d8950SDavid Brownell omap_cfg_reg(L15_1610_CAM_HS); 519c72d8950SDavid Brownell omap_cfg_reg(M19_1610_CAM_RSTZ); 520c72d8950SDavid Brownell omap_cfg_reg(Y15_1610_CAM_OUTCLK); 521c72d8950SDavid Brownell 522c72d8950SDavid Brownell /* serial camera interface */ 523c72d8950SDavid Brownell omap_cfg_reg(H19_1610_CAM_EXCLK); 524c72d8950SDavid Brownell omap_cfg_reg(W13_1610_CCP_CLKM); 525c72d8950SDavid Brownell omap_cfg_reg(Y12_1610_CCP_CLKP); 526c72d8950SDavid Brownell /* CCP_DATAM CONFLICTS WITH UART1.TX (and serial console) */ 5276e2d4107SDavid Cohen /* omap_cfg_reg(Y14_1610_CCP_DATAM); */ 528c72d8950SDavid Brownell omap_cfg_reg(W14_1610_CCP_DATAP); 529c72d8950SDavid Brownell 530c72d8950SDavid Brownell /* CAM_PWDN */ 531ac37a0b0SDavid Brownell if (gpio_request(11, "cam_pwdn") == 0) { 532c72d8950SDavid Brownell omap_cfg_reg(N20_1610_GPIO11); 533ac37a0b0SDavid Brownell gpio_direction_output(11, 0); 534c72d8950SDavid Brownell } else 535c72d8950SDavid Brownell pr_debug("OSK+Mistral: CAM_PWDN is awol\n"); 536c72d8950SDavid Brownell 537c72d8950SDavid Brownell 5386e2d4107SDavid Cohen /* omap_cfg_reg(P19_1610_GPIO6); */ /* BUSY */ 539ac37a0b0SDavid Brownell gpio_request(6, "ts_busy"); 540ac37a0b0SDavid Brownell gpio_direction_input(6); 541ac37a0b0SDavid Brownell 5426e2d4107SDavid Cohen omap_cfg_reg(P20_1610_GPIO4); /* PENIRQ */ 543ac37a0b0SDavid Brownell gpio_request(4, "ts_int"); 544ac37a0b0SDavid Brownell gpio_direction_input(4); 5456845664aSThomas Gleixner irq_set_irq_type(gpio_to_irq(4), IRQ_TYPE_EDGE_FALLING); 546ac37a0b0SDavid Brownell 54746a0a540STarun Kanti DebBarma mistral_boardinfo[0].irq = gpio_to_irq(4); 54878762841SDavid Brownell spi_register_board_info(mistral_boardinfo, 54978762841SDavid Brownell ARRAY_SIZE(mistral_boardinfo)); 55078762841SDavid Brownell 5512430c62eSDavid Brownell /* the sideways button (SW1) is for use as a "wakeup" button 5522430c62eSDavid Brownell * 5532430c62eSDavid Brownell * NOTE: The Mistral board has the wakeup button (SW1) wired 5542430c62eSDavid Brownell * to the LCD 3.3V rail, which is powered down during suspend. 5552430c62eSDavid Brownell * To allow this button to wake up the omap, work around this 5562430c62eSDavid Brownell * HW bug by rewiring SW1 to use the main 3.3V rail. 5572430c62eSDavid Brownell */ 5587c38cf02STony Lindgren omap_cfg_reg(N15_1610_MPUIO2); 559ac37a0b0SDavid Brownell if (gpio_request(OMAP_MPUIO(2), "wakeup") == 0) { 5607c38cf02STony Lindgren int ret = 0; 56115f74b03SDavid Brownell int irq = gpio_to_irq(OMAP_MPUIO(2)); 562ac37a0b0SDavid Brownell 563ac37a0b0SDavid Brownell gpio_direction_input(OMAP_MPUIO(2)); 5646845664aSThomas Gleixner irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING); 5657c38cf02STony Lindgren /* share the IRQ in case someone wants to use the 5667c38cf02STony Lindgren * button for more than wakeup from system sleep. 5677c38cf02STony Lindgren */ 56815f74b03SDavid Brownell ret = request_irq(irq, 5697c38cf02STony Lindgren &osk_mistral_wake_interrupt, 57052e405eaSThomas Gleixner IRQF_SHARED, "mistral_wakeup", 5717c38cf02STony Lindgren &osk_mistral_wake_interrupt); 5727c38cf02STony Lindgren if (ret != 0) { 573ac37a0b0SDavid Brownell gpio_free(OMAP_MPUIO(2)); 5747c38cf02STony Lindgren printk(KERN_ERR "OSK+Mistral: no wakeup irq, %d?\n", 5757c38cf02STony Lindgren ret); 5767c38cf02STony Lindgren } else 57715f74b03SDavid Brownell enable_irq_wake(irq); 5787c38cf02STony Lindgren } else 5797c38cf02STony Lindgren printk(KERN_ERR "OSK+Mistral: wakeup button is awol\n"); 58078762841SDavid Brownell 5814dcc6d24SDavid Brownell /* LCD: backlight, and power; power controls other devices on the 5824dcc6d24SDavid Brownell * board, like the touchscreen, EEPROM, and wakeup (!) switch. 5834dcc6d24SDavid Brownell */ 5844dcc6d24SDavid Brownell omap_cfg_reg(PWL); 585ac37a0b0SDavid Brownell if (gpio_request(2, "lcd_pwr") == 0) 586ac37a0b0SDavid Brownell gpio_direction_output(2, 1); 5874dcc6d24SDavid Brownell 588dafbeadfSBryan Wu /* 589dafbeadfSBryan Wu * GPIO based LEDs 590dafbeadfSBryan Wu */ 591dafbeadfSBryan Wu omap_cfg_reg(P18_1610_GPIO3); 592dafbeadfSBryan Wu omap_cfg_reg(MPUIO4); 593dafbeadfSBryan Wu 5942430c62eSDavid Brownell i2c_register_board_info(1, mistral_i2c_board_info, 5952430c62eSDavid Brownell ARRAY_SIZE(mistral_i2c_board_info)); 5962430c62eSDavid Brownell 59778762841SDavid Brownell platform_add_devices(mistral_devices, ARRAY_SIZE(mistral_devices)); 5987c38cf02STony Lindgren } 5997c38cf02STony Lindgren #else 6007c38cf02STony Lindgren static void __init osk_mistral_init(void) { } 6017c38cf02STony Lindgren #endif 6027c38cf02STony Lindgren 6039b6553cdSTony Lindgren #define EMIFS_CS3_VAL (0x88013141) 6049b6553cdSTony Lindgren 605dbdf9cedSTony Lindgren static void __init osk_init(void) 606dbdf9cedSTony Lindgren { 607030b1545STony Lindgren u32 l; 608030b1545STony Lindgren 609c2cdaffeSTony Lindgren osk_init_smc91x(); 610d87d44f7SArnd Bergmann osk_init_cf(2); /* CS2 */ 611c2cdaffeSTony Lindgren 6129b6553cdSTony Lindgren /* Workaround for wrong CS3 (NOR flash) timing 6139b6553cdSTony Lindgren * There are some U-Boot versions out there which configure 6149b6553cdSTony Lindgren * wrong CS3 memory timings. This mainly leads to CRC 6156cbdc8c5SSimon Arlott * or similar errors if you use NOR flash (e.g. with JFFS2) 6169b6553cdSTony Lindgren */ 617030b1545STony Lindgren l = omap_readl(EMIFS_CCS(3)); 618030b1545STony Lindgren if (l != EMIFS_CS3_VAL) 619030b1545STony Lindgren omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3)); 6209b6553cdSTony Lindgren 6217c38cf02STony Lindgren osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys(); 6227c38cf02STony Lindgren osk_flash_resource.end += SZ_32M - 1; 62346a0a540STarun Kanti DebBarma osk5912_smc91x_resources[1].start = gpio_to_irq(0); 62446a0a540STarun Kanti DebBarma osk5912_smc91x_resources[1].end = gpio_to_irq(0); 62546a0a540STarun Kanti DebBarma osk5912_cf_resources[0].start = gpio_to_irq(62); 62646a0a540STarun Kanti DebBarma osk5912_cf_resources[0].end = gpio_to_irq(62); 627dbdf9cedSTony Lindgren platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices)); 628f35ae634STony Lindgren 629f35ae634STony Lindgren l = omap_readl(USB_TRANSCEIVER_CTRL); 630f35ae634STony Lindgren l |= (3 << 1); 631f35ae634STony Lindgren omap_writel(l, USB_TRANSCEIVER_CTRL); 6327c38cf02STony Lindgren 63315d157e8SLinus Walleij gpiod_add_lookup_table(&osk_usb_gpio_table); 634dd0cdd88STony Lindgren omap1_usb_init(&osk_usb_config); 635b0b5aa3fSFelipe Balbi 6368056c6cbSDavid Brownell /* irq for tps65010 chip */ 6378056c6cbSDavid Brownell /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */ 6388056c6cbSDavid Brownell if (gpio_request(OMAP_MPUIO(1), "tps65010") == 0) 6398056c6cbSDavid Brownell gpio_direction_input(OMAP_MPUIO(1)); 6408056c6cbSDavid Brownell 6413179a019STony Lindgren omap_serial_init(); 64246a0a540STarun Kanti DebBarma osk_i2c_board_info[0].irq = gpio_to_irq(OMAP_MPUIO(1)); 6431ed16a86SJarkko Nikula omap_register_i2c_bus(1, 400, osk_i2c_board_info, 6441ed16a86SJarkko Nikula ARRAY_SIZE(osk_i2c_board_info)); 6457c38cf02STony Lindgren osk_mistral_init(); 646ddba6c7fSTomi Valkeinen 647ddba6c7fSTomi Valkeinen #ifdef CONFIG_OMAP_OSK_MISTRAL 648ddba6c7fSTomi Valkeinen omapfb_set_lcd_config(&osk_lcd_config); 649ddba6c7fSTomi Valkeinen #endif 650ddba6c7fSTomi Valkeinen 651dbdf9cedSTony Lindgren } 652dbdf9cedSTony Lindgren 653dbdf9cedSTony Lindgren MACHINE_START(OMAP_OSK, "TI-OSK") 654dbdf9cedSTony Lindgren /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */ 655246e389dSNicolas Pitre .atag_offset = 0x100, 6567b88e62fSTony Lindgren .map_io = omap16xx_map_io, 6577b88e62fSTony Lindgren .init_early = omap1_init_early, 6587b88e62fSTony Lindgren .init_irq = omap1_init_irq, 659b694331cSTony Lindgren .handle_irq = omap1_handle_irq, 660dbdf9cedSTony Lindgren .init_machine = osk_init, 66182c3bd03SShawn Guo .init_late = omap1_init_late, 6626bb27d73SStephen Warren .init_time = omap1_timer_init, 663baa95883SRussell King .restart = omap1_restart, 664dbdf9cedSTony Lindgren MACHINE_END 665