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 */ 28c32c81f3SLinus Walleij #include <linux/gpio/consumer.h> 29c32c81f3SLinus Walleij #include <linux/gpio/driver.h> 3015d157e8SLinus Walleij #include <linux/gpio/machine.h> 31dbdf9cedSTony Lindgren #include <linux/kernel.h> 32dbdf9cedSTony Lindgren #include <linux/init.h> 33d052d1beSRussell King #include <linux/platform_device.h> 34a524626bSTony Lindgren #include <linux/interrupt.h> 35d533c128SThomas Gleixner #include <linux/irq.h> 368056c6cbSDavid Brownell #include <linux/i2c.h> 37d94577d5SDavid Brownell #include <linux/leds.h> 383bc48014SLadislav Michl #include <linux/smc91x.h> 39ddba6c7fSTomi Valkeinen #include <linux/omapfb.h> 407c38cf02STony Lindgren #include <linux/mtd/mtd.h> 417c38cf02STony Lindgren #include <linux/mtd/partitions.h> 42561b036aSLadislav Michl #include <linux/mtd/physmap.h> 439787076cSWolfram Sang #include <linux/mfd/tps65010.h> 444b25408fSTony Lindgren #include <linux/platform_data/gpio-omap.h> 45cc012729SIgor Grinberg #include <linux/platform_data/omap1_bl.h> 467e0a9e62SArnd Bergmann #include <linux/soc/ti/omap1-io.h> 476d16bfb5SDavid Brownell 48dbdf9cedSTony Lindgren #include <asm/mach-types.h> 49dbdf9cedSTony Lindgren #include <asm/mach/arch.h> 50dbdf9cedSTony Lindgren #include <asm/mach/map.h> 51dbdf9cedSTony Lindgren 527e0a9e62SArnd Bergmann #include "tc.h" 53100f9638SArnd Bergmann #include "flash.h" 547e0a9e62SArnd Bergmann #include "mux.h" 557e0a9e62SArnd Bergmann #include "hardware.h" 56e8e77e97SArnd Bergmann #include "usb.h" 574e65331cSTony Lindgren #include "common.h" 589b6553cdSTony Lindgren 5915d157e8SLinus Walleij /* Name of the GPIO chip used by the OMAP for GPIOs 0..15 */ 6015d157e8SLinus Walleij #define OMAP_GPIO_LABEL "gpio-0-15" 6115d157e8SLinus Walleij 623a0110cdSTony Lindgren /* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ 633a0110cdSTony Lindgren #define OMAP_OSK_ETHR_START 0x04800300 643a0110cdSTony Lindgren 653a0110cdSTony Lindgren /* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with 663a0110cdSTony Lindgren * alternate pin configurations for hardware-controlled blinking. 673a0110cdSTony Lindgren */ 68c32c81f3SLinus Walleij #define OSK_TPS_GPIO_USB_PWR_EN 0 69c32c81f3SLinus Walleij #define OSK_TPS_GPIO_LED_D3 1 70c32c81f3SLinus Walleij #define OSK_TPS_GPIO_LAN_RESET 2 71c32c81f3SLinus Walleij #define OSK_TPS_GPIO_DSP_PWR_EN 3 72c32c81f3SLinus Walleij #define OSK_TPS_GPIO_LED_D9 4 73c32c81f3SLinus Walleij #define OSK_TPS_GPIO_LED_D2 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 */ 177c32c81f3SLinus Walleij { .name = "d9", .default_trigger = "disk-activity", }, 178c32c81f3SLinus Walleij { .name = "d2", }, 179c32c81f3SLinus Walleij { .name = "d3", .default_trigger = "heartbeat", }, 180c32c81f3SLinus Walleij }; 181c32c81f3SLinus Walleij 182c32c81f3SLinus Walleij static struct gpiod_lookup_table tps_leds_gpio_table = { 183c32c81f3SLinus Walleij .dev_id = "leds-gpio", 184c32c81f3SLinus Walleij .table = { 185c32c81f3SLinus Walleij /* Use local offsets on TPS65010 */ 186c32c81f3SLinus Walleij GPIO_LOOKUP_IDX("tps65010", OSK_TPS_GPIO_LED_D9, NULL, 0, GPIO_ACTIVE_HIGH), 187c32c81f3SLinus Walleij GPIO_LOOKUP_IDX("tps65010", OSK_TPS_GPIO_LED_D2, NULL, 1, GPIO_ACTIVE_HIGH), 188c32c81f3SLinus Walleij GPIO_LOOKUP_IDX("tps65010", OSK_TPS_GPIO_LED_D3, NULL, 2, GPIO_ACTIVE_LOW), 189c32c81f3SLinus Walleij { } 190c32c81f3SLinus Walleij }, 191d94577d5SDavid Brownell }; 192d94577d5SDavid Brownell 193d94577d5SDavid Brownell static struct gpio_led_platform_data tps_leds_data = { 194d94577d5SDavid Brownell .num_leds = 3, 195d94577d5SDavid Brownell .leds = tps_leds, 196d94577d5SDavid Brownell }; 197d94577d5SDavid Brownell 198d94577d5SDavid Brownell static struct platform_device osk5912_tps_leds = { 199d94577d5SDavid Brownell .name = "leds-gpio", 200d94577d5SDavid Brownell .id = 0, 201d94577d5SDavid Brownell .dev.platform_data = &tps_leds_data, 202d94577d5SDavid Brownell }; 203d94577d5SDavid Brownell 204c32c81f3SLinus Walleij /* The board just hold these GPIOs hogged from setup to teardown */ 205c32c81f3SLinus Walleij static struct gpio_desc *eth_reset; 206c32c81f3SLinus Walleij static struct gpio_desc *vdd_dsp; 207c32c81f3SLinus Walleij 208c32c81f3SLinus Walleij static int osk_tps_setup(struct i2c_client *client, struct gpio_chip *gc) 209d94577d5SDavid Brownell { 210c32c81f3SLinus Walleij struct gpio_desc *d; 2110b31c53bSArnd Bergmann if (!IS_BUILTIN(CONFIG_TPS65010)) 2120b31c53bSArnd Bergmann return -ENOSYS; 2130b31c53bSArnd Bergmann 214d94577d5SDavid Brownell /* Set GPIO 1 HIGH to disable VBUS power supply; 215d94577d5SDavid Brownell * OHCI driver powers it up/down as needed. 216d94577d5SDavid Brownell */ 217c32c81f3SLinus Walleij d = gpiochip_request_own_desc(gc, OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en", 218c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH, GPIOD_OUT_HIGH); 2196efac017SLinus Walleij /* Free the GPIO again as the driver will request it */ 220c32c81f3SLinus Walleij gpiochip_free_own_desc(d); 221d94577d5SDavid Brownell 222d94577d5SDavid Brownell /* Set GPIO 2 high so LED D3 is off by default */ 223d94577d5SDavid Brownell tps65010_set_gpio_out_value(GPIO2, HIGH); 224d94577d5SDavid Brownell 225d94577d5SDavid Brownell /* Set GPIO 3 low to take ethernet out of reset */ 226c32c81f3SLinus Walleij eth_reset = gpiochip_request_own_desc(gc, OSK_TPS_GPIO_LAN_RESET, "smc_reset", 227c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW); 228d94577d5SDavid Brownell 229d94577d5SDavid Brownell /* GPIO4 is VDD_DSP */ 230c32c81f3SLinus Walleij vdd_dsp = gpiochip_request_own_desc(gc, OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power", 231c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH, GPIOD_OUT_HIGH); 232d94577d5SDavid Brownell /* REVISIT if DSP support isn't configured, power it off ... */ 233d94577d5SDavid Brownell 234d94577d5SDavid Brownell /* Let LED1 (D9) blink; leds-gpio may override it */ 235d94577d5SDavid Brownell tps65010_set_led(LED1, BLINK); 236d94577d5SDavid Brownell 237d94577d5SDavid Brownell /* Set LED2 off by default */ 238d94577d5SDavid Brownell tps65010_set_led(LED2, OFF); 239d94577d5SDavid Brownell 240d94577d5SDavid Brownell /* Enable LOW_PWR handshake */ 241d94577d5SDavid Brownell tps65010_set_low_pwr(ON); 242d94577d5SDavid Brownell 243d94577d5SDavid Brownell /* Switch VLDO2 to 3.0V for AIC23 */ 244d94577d5SDavid Brownell tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V 245d94577d5SDavid Brownell | TPS_LDO1_ENABLE); 246d94577d5SDavid Brownell 247d94577d5SDavid Brownell /* register these three LEDs */ 248d94577d5SDavid Brownell osk5912_tps_leds.dev.parent = &client->dev; 249c32c81f3SLinus Walleij gpiod_add_lookup_table(&tps_leds_gpio_table); 250d94577d5SDavid Brownell platform_device_register(&osk5912_tps_leds); 251d94577d5SDavid Brownell 252d94577d5SDavid Brownell return 0; 253d94577d5SDavid Brownell } 254d94577d5SDavid Brownell 255c32c81f3SLinus Walleij static void osk_tps_teardown(struct i2c_client *client, struct gpio_chip *gc) 256c32c81f3SLinus Walleij { 257c32c81f3SLinus Walleij gpiochip_free_own_desc(eth_reset); 258c32c81f3SLinus Walleij gpiochip_free_own_desc(vdd_dsp); 259c32c81f3SLinus Walleij } 260c32c81f3SLinus Walleij 261d94577d5SDavid Brownell static struct tps65010_board tps_board = { 262d94577d5SDavid Brownell .outmask = 0x0f, 263d94577d5SDavid Brownell .setup = osk_tps_setup, 264c32c81f3SLinus Walleij .teardown = osk_tps_teardown, 265d94577d5SDavid Brownell }; 266d94577d5SDavid Brownell 2678056c6cbSDavid Brownell static struct i2c_board_info __initdata osk_i2c_board_info[] = { 2688056c6cbSDavid Brownell { 26915d157e8SLinus Walleij /* This device will get the name "i2c-tps65010" */ 2708056c6cbSDavid Brownell I2C_BOARD_INFO("tps65010", 0x48), 27115d157e8SLinus Walleij .dev_name = "tps65010", 272d94577d5SDavid Brownell .platform_data = &tps_board, 273d94577d5SDavid Brownell 2748056c6cbSDavid Brownell }, 2759b4a3577SArun KS { 2769b4a3577SArun KS I2C_BOARD_INFO("tlv320aic23", 0x1B), 2779b4a3577SArun KS }, 2788056c6cbSDavid Brownell /* TODO when driver support is ready: 2798056c6cbSDavid Brownell * - optionally on Mistral, ov9640 camera sensor at 0x30 2808056c6cbSDavid Brownell */ 2818056c6cbSDavid Brownell }; 2828056c6cbSDavid Brownell 283dbdf9cedSTony Lindgren static void __init osk_init_smc91x(void) 284dbdf9cedSTony Lindgren { 285030b1545STony Lindgren u32 l; 286030b1545STony Lindgren 287dbdf9cedSTony Lindgren /* Check EMIFS wait states to fix errors with SMC_GET_PKT_HDR */ 288030b1545STony Lindgren l = omap_readl(EMIFS_CCS(1)); 289030b1545STony Lindgren l |= 0x3; 290030b1545STony Lindgren omap_writel(l, EMIFS_CCS(1)); 291dbdf9cedSTony Lindgren } 292dbdf9cedSTony Lindgren 293d87d44f7SArnd Bergmann static void __init osk_init_cf(int seg) 294dbdf9cedSTony Lindgren { 295d87d44f7SArnd Bergmann struct resource *res = &osk5912_cf_resources[1]; 296d87d44f7SArnd Bergmann 297dbdf9cedSTony Lindgren omap_cfg_reg(M7_1610_GPIO62); 298d87d44f7SArnd Bergmann 299d87d44f7SArnd Bergmann switch (seg) { 300d87d44f7SArnd Bergmann /* NOTE: CS0 could be configured too ... */ 301d87d44f7SArnd Bergmann case 1: 302d87d44f7SArnd Bergmann res->start = OMAP_CS1_PHYS; 303d87d44f7SArnd Bergmann break; 304d87d44f7SArnd Bergmann case 2: 305d87d44f7SArnd Bergmann res->start = OMAP_CS2_PHYS; 306d87d44f7SArnd Bergmann break; 307d87d44f7SArnd Bergmann case 3: 308d87d44f7SArnd Bergmann res->start = omap_cs3_phys(); 309d87d44f7SArnd Bergmann break; 310d87d44f7SArnd Bergmann } 311d87d44f7SArnd Bergmann 312d87d44f7SArnd Bergmann res->end = res->start + SZ_8K - 1; 313d87d44f7SArnd Bergmann osk5912_cf_device.dev.platform_data = (void *)(uintptr_t)seg; 314d87d44f7SArnd Bergmann 315d87d44f7SArnd Bergmann /* NOTE: better EMIFS setup might support more cards; but the 316d87d44f7SArnd Bergmann * TRM only shows how to affect regular flash signals, not their 317d87d44f7SArnd Bergmann * CF/PCMCIA variants... 318d87d44f7SArnd Bergmann */ 319d87d44f7SArnd Bergmann pr_debug("%s: cs%d, previous ccs %08x acs %08x\n", __func__, 320d87d44f7SArnd Bergmann seg, omap_readl(EMIFS_CCS(seg)), omap_readl(EMIFS_ACS(seg))); 321d87d44f7SArnd Bergmann omap_writel(0x0004a1b3, EMIFS_CCS(seg)); /* synch mode 4 etc */ 322d87d44f7SArnd Bergmann omap_writel(0x00000000, EMIFS_ACS(seg)); /* OE hold/setup */ 323dbdf9cedSTony Lindgren } 324dbdf9cedSTony Lindgren 32515d157e8SLinus Walleij static struct gpiod_lookup_table osk_usb_gpio_table = { 32615d157e8SLinus Walleij .dev_id = "ohci", 32715d157e8SLinus Walleij .table = { 32815d157e8SLinus Walleij /* Power GPIO on the I2C-attached TPS65010 */ 329c32c81f3SLinus Walleij GPIO_LOOKUP("tps65010", OSK_TPS_GPIO_USB_PWR_EN, "power", 330c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH), 33115d157e8SLinus Walleij GPIO_LOOKUP(OMAP_GPIO_LABEL, 9, "overcurrent", 33215d157e8SLinus Walleij GPIO_ACTIVE_HIGH), 333c32c81f3SLinus Walleij { } 33415d157e8SLinus Walleij }, 33515d157e8SLinus Walleij }; 33615d157e8SLinus Walleij 337dbdf9cedSTony Lindgren static struct omap_usb_config osk_usb_config __initdata = { 338dbdf9cedSTony Lindgren /* has usb host connector (A) ... for development it can also 339dbdf9cedSTony Lindgren * be used, with a NONSTANDARD gender-bending cable/dongle, as 340dbdf9cedSTony Lindgren * a peripheral. 341dbdf9cedSTony Lindgren */ 34277c2f02eSPaul Bolle #if IS_ENABLED(CONFIG_USB_OMAP) 343dbdf9cedSTony Lindgren .register_dev = 1, 344dbdf9cedSTony Lindgren .hmc_mode = 0, 345dbdf9cedSTony Lindgren #else 346dbdf9cedSTony Lindgren .register_host = 1, 347dbdf9cedSTony Lindgren .hmc_mode = 16, 348dbdf9cedSTony Lindgren .rwc = 1, 349dbdf9cedSTony Lindgren #endif 350dbdf9cedSTony Lindgren .pins[0] = 2, 351dbdf9cedSTony Lindgren }; 352dbdf9cedSTony Lindgren 3539b6553cdSTony Lindgren #define EMIFS_CS3_VAL (0x88013141) 3549b6553cdSTony Lindgren 355c32c81f3SLinus Walleij static struct gpiod_lookup_table osk_irq_gpio_table = { 356c32c81f3SLinus Walleij .dev_id = NULL, 357c32c81f3SLinus Walleij .table = { 358c32c81f3SLinus Walleij /* GPIO used for SMC91x IRQ */ 359c32c81f3SLinus Walleij GPIO_LOOKUP(OMAP_GPIO_LABEL, 0, "smc_irq", 360c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH), 361c32c81f3SLinus Walleij /* GPIO used for CF IRQ */ 362c32c81f3SLinus Walleij GPIO_LOOKUP("gpio-48-63", 14, "cf_irq", 363c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH), 364c32c81f3SLinus Walleij /* GPIO used by the TPS65010 chip */ 365c32c81f3SLinus Walleij GPIO_LOOKUP("mpuio", 1, "tps65010", 366c32c81f3SLinus Walleij GPIO_ACTIVE_HIGH), 367*df89de97SLinus Walleij /* GPIOs used for serial wakeup IRQs */ 368*df89de97SLinus Walleij GPIO_LOOKUP_IDX("gpio-32-47", 5, "wakeup", 0, 369*df89de97SLinus Walleij GPIO_ACTIVE_HIGH), 370*df89de97SLinus Walleij GPIO_LOOKUP_IDX("gpio-16-31", 2, "wakeup", 1, 371*df89de97SLinus Walleij GPIO_ACTIVE_HIGH), 372*df89de97SLinus Walleij GPIO_LOOKUP_IDX("gpio-48-63", 1, "wakeup", 2, 373*df89de97SLinus Walleij GPIO_ACTIVE_HIGH), 374c32c81f3SLinus Walleij { } 375c32c81f3SLinus Walleij }, 376c32c81f3SLinus Walleij }; 377c32c81f3SLinus Walleij 378dbdf9cedSTony Lindgren static void __init osk_init(void) 379dbdf9cedSTony Lindgren { 380c32c81f3SLinus Walleij struct gpio_desc *d; 381030b1545STony Lindgren u32 l; 382030b1545STony Lindgren 383c2cdaffeSTony Lindgren osk_init_smc91x(); 384d87d44f7SArnd Bergmann osk_init_cf(2); /* CS2 */ 385c2cdaffeSTony Lindgren 3869b6553cdSTony Lindgren /* Workaround for wrong CS3 (NOR flash) timing 3879b6553cdSTony Lindgren * There are some U-Boot versions out there which configure 3889b6553cdSTony Lindgren * wrong CS3 memory timings. This mainly leads to CRC 3896cbdc8c5SSimon Arlott * or similar errors if you use NOR flash (e.g. with JFFS2) 3909b6553cdSTony Lindgren */ 391030b1545STony Lindgren l = omap_readl(EMIFS_CCS(3)); 392030b1545STony Lindgren if (l != EMIFS_CS3_VAL) 393030b1545STony Lindgren omap_writel(EMIFS_CS3_VAL, EMIFS_CCS(3)); 3949b6553cdSTony Lindgren 3957c38cf02STony Lindgren osk_flash_resource.end = osk_flash_resource.start = omap_cs3_phys(); 3967c38cf02STony Lindgren osk_flash_resource.end += SZ_32M - 1; 397c32c81f3SLinus Walleij 398c32c81f3SLinus Walleij /* 399c32c81f3SLinus Walleij * Add the GPIOs to be used as IRQs and immediately look them up 400c32c81f3SLinus Walleij * to be passed as an IRQ resource. This is ugly but should work 401c32c81f3SLinus Walleij * until the day we convert to device tree. 402c32c81f3SLinus Walleij */ 403c32c81f3SLinus Walleij gpiod_add_lookup_table(&osk_irq_gpio_table); 404c32c81f3SLinus Walleij 405c32c81f3SLinus Walleij d = gpiod_get(NULL, "smc_irq", GPIOD_IN); 406c32c81f3SLinus Walleij if (IS_ERR(d)) { 407c32c81f3SLinus Walleij pr_err("Unable to get SMC IRQ GPIO descriptor\n"); 408c32c81f3SLinus Walleij } else { 409c32c81f3SLinus Walleij irq_set_irq_type(gpiod_to_irq(d), IRQ_TYPE_EDGE_RISING); 410c32c81f3SLinus Walleij osk5912_smc91x_resources[1] = DEFINE_RES_IRQ(gpiod_to_irq(d)); 411c32c81f3SLinus Walleij } 412c32c81f3SLinus Walleij 413c32c81f3SLinus Walleij d = gpiod_get(NULL, "cf_irq", GPIOD_IN); 414c32c81f3SLinus Walleij if (IS_ERR(d)) { 415c32c81f3SLinus Walleij pr_err("Unable to get CF IRQ GPIO descriptor\n"); 416c32c81f3SLinus Walleij } else { 417c32c81f3SLinus Walleij /* the CF I/O IRQ is really active-low */ 418c32c81f3SLinus Walleij irq_set_irq_type(gpiod_to_irq(d), IRQ_TYPE_EDGE_FALLING); 419c32c81f3SLinus Walleij osk5912_cf_resources[0] = DEFINE_RES_IRQ(gpiod_to_irq(d)); 420c32c81f3SLinus Walleij } 421c32c81f3SLinus Walleij 422dbdf9cedSTony Lindgren platform_add_devices(osk5912_devices, ARRAY_SIZE(osk5912_devices)); 423f35ae634STony Lindgren 424f35ae634STony Lindgren l = omap_readl(USB_TRANSCEIVER_CTRL); 425f35ae634STony Lindgren l |= (3 << 1); 426f35ae634STony Lindgren omap_writel(l, USB_TRANSCEIVER_CTRL); 4277c38cf02STony Lindgren 42815d157e8SLinus Walleij gpiod_add_lookup_table(&osk_usb_gpio_table); 429dd0cdd88STony Lindgren omap1_usb_init(&osk_usb_config); 430b0b5aa3fSFelipe Balbi 431c32c81f3SLinus Walleij omap_serial_init(); 432c32c81f3SLinus Walleij 4338056c6cbSDavid Brownell /* irq for tps65010 chip */ 4348056c6cbSDavid Brownell /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */ 435c32c81f3SLinus Walleij d = gpiod_get(NULL, "tps65010", GPIOD_IN); 436c32c81f3SLinus Walleij if (IS_ERR(d)) 437c32c81f3SLinus Walleij pr_err("Unable to get TPS65010 IRQ GPIO descriptor\n"); 438c32c81f3SLinus Walleij else 439c32c81f3SLinus Walleij osk_i2c_board_info[0].irq = gpiod_to_irq(d); 4401ed16a86SJarkko Nikula omap_register_i2c_bus(1, 400, osk_i2c_board_info, 4411ed16a86SJarkko Nikula ARRAY_SIZE(osk_i2c_board_info)); 442dbdf9cedSTony Lindgren } 443dbdf9cedSTony Lindgren 444dbdf9cedSTony Lindgren MACHINE_START(OMAP_OSK, "TI-OSK") 445dbdf9cedSTony Lindgren /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */ 446246e389dSNicolas Pitre .atag_offset = 0x100, 4479a99b142SArnd Bergmann .map_io = omap1_map_io, 4487b88e62fSTony Lindgren .init_early = omap1_init_early, 4497b88e62fSTony Lindgren .init_irq = omap1_init_irq, 450b694331cSTony Lindgren .handle_irq = omap1_handle_irq, 451dbdf9cedSTony Lindgren .init_machine = osk_init, 45282c3bd03SShawn Guo .init_late = omap1_init_late, 4536bb27d73SStephen Warren .init_time = omap1_timer_init, 454baa95883SRussell King .restart = omap1_restart, 455dbdf9cedSTony Lindgren MACHINE_END 456