Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/mach-omap2/board-omap3logic.c |
| 3 | * |
| 4 | * Copyright (C) 2010 Li-Pro.Net |
| 5 | * Stephan Linz <linz@li-pro.net> |
| 6 | * |
| 7 | * Copyright (C) 2010 Logic Product Development, Inc. |
| 8 | * Peter Barada <peter.barada@logicpd.com> |
| 9 | * |
| 10 | * Modified from Beagle, EVM, and RX51 |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License version 2 as |
| 14 | * published by the Free Software Foundation. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/platform_device.h> |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/err.h> |
| 22 | #include <linux/clk.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/gpio.h> |
| 25 | |
| 26 | #include <linux/regulator/machine.h> |
| 27 | |
| 28 | #include <linux/i2c/twl.h> |
Tim Nordell | 8430281 | 2010-09-27 16:05:48 +0000 | [diff] [blame] | 29 | #include <linux/mmc/host.h> |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 30 | |
| 31 | #include <mach/hardware.h> |
| 32 | #include <asm/mach-types.h> |
| 33 | #include <asm/mach/arch.h> |
| 34 | #include <asm/mach/map.h> |
| 35 | |
| 36 | #include "mux.h" |
Tim Nordell | 8430281 | 2010-09-27 16:05:48 +0000 | [diff] [blame] | 37 | #include "hsmmc.h" |
Paul Walmsley | 4814ced | 2010-10-08 11:40:20 -0600 | [diff] [blame] | 38 | #include "control.h" |
Mike Rapoport | fbd8071 | 2011-04-25 01:09:06 +0300 | [diff] [blame] | 39 | #include "common-board-devices.h" |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 40 | |
| 41 | #include <plat/mux.h> |
| 42 | #include <plat/board.h> |
Tony Lindgren | 4e65331 | 2011-11-10 22:45:17 +0100 | [diff] [blame] | 43 | #include "common.h" |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 44 | #include <plat/gpmc-smsc911x.h> |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 45 | #include <plat/gpmc.h> |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 46 | #include <plat/sdrc.h> |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 47 | |
| 48 | #define OMAP3LOGIC_SMSC911X_CS 1 |
| 49 | |
| 50 | #define OMAP3530_LV_SOM_MMC_GPIO_CD 110 |
| 51 | #define OMAP3530_LV_SOM_MMC_GPIO_WP 126 |
| 52 | #define OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ 152 |
| 53 | |
| 54 | #define OMAP3_TORPEDO_MMC_GPIO_CD 127 |
| 55 | #define OMAP3_TORPEDO_SMSC911X_GPIO_IRQ 129 |
| 56 | |
Oleg Drokin | 786b01a | 2011-06-06 18:57:07 +0000 | [diff] [blame] | 57 | static struct regulator_consumer_supply omap3logic_vmmc1_supply[] = { |
| 58 | REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"), |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */ |
| 62 | static struct regulator_init_data omap3logic_vmmc1 = { |
| 63 | .constraints = { |
| 64 | .name = "VMMC1", |
| 65 | .min_uV = 1850000, |
| 66 | .max_uV = 3150000, |
| 67 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 68 | | REGULATOR_MODE_STANDBY, |
| 69 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 70 | | REGULATOR_CHANGE_MODE |
| 71 | | REGULATOR_CHANGE_STATUS, |
| 72 | }, |
Oleg Drokin | 786b01a | 2011-06-06 18:57:07 +0000 | [diff] [blame] | 73 | .num_consumer_supplies = ARRAY_SIZE(omap3logic_vmmc1_supply), |
| 74 | .consumer_supplies = omap3logic_vmmc1_supply, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | static struct twl4030_gpio_platform_data omap3logic_gpio_data = { |
| 78 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 79 | .irq_base = TWL4030_GPIO_IRQ_BASE, |
| 80 | .irq_end = TWL4030_GPIO_IRQ_END, |
| 81 | .use_leds = true, |
| 82 | .pullups = BIT(1), |
| 83 | .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) |
| 84 | | BIT(13) | BIT(15) | BIT(16) | BIT(17), |
| 85 | }; |
| 86 | |
| 87 | static struct twl4030_platform_data omap3logic_twldata = { |
| 88 | .irq_base = TWL4030_IRQ_BASE, |
| 89 | .irq_end = TWL4030_IRQ_END, |
| 90 | |
| 91 | /* platform_data for children goes here */ |
| 92 | .gpio = &omap3logic_gpio_data, |
Tim Nordell | 8430281 | 2010-09-27 16:05:48 +0000 | [diff] [blame] | 93 | .vmmc1 = &omap3logic_vmmc1, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 94 | }; |
| 95 | |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 96 | static int __init omap3logic_i2c_init(void) |
| 97 | { |
Mike Rapoport | fbd8071 | 2011-04-25 01:09:06 +0300 | [diff] [blame] | 98 | omap3_pmic_init("twl4030", &omap3logic_twldata); |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 99 | return 0; |
| 100 | } |
| 101 | |
Tim Nordell | 8430281 | 2010-09-27 16:05:48 +0000 | [diff] [blame] | 102 | static struct omap2_hsmmc_info __initdata board_mmc_info[] = { |
| 103 | { |
| 104 | .name = "external", |
| 105 | .mmc = 1, |
| 106 | .caps = MMC_CAP_4_BIT_DATA, |
| 107 | .gpio_cd = -EINVAL, |
| 108 | .gpio_wp = -EINVAL, |
| 109 | }, |
| 110 | {} /* Terminator */ |
| 111 | }; |
| 112 | |
| 113 | static void __init board_mmc_init(void) |
| 114 | { |
| 115 | if (machine_is_omap3530_lv_som()) { |
| 116 | /* OMAP3530 LV SOM board */ |
| 117 | board_mmc_info[0].gpio_cd = OMAP3530_LV_SOM_MMC_GPIO_CD; |
| 118 | board_mmc_info[0].gpio_wp = OMAP3530_LV_SOM_MMC_GPIO_WP; |
| 119 | omap_mux_init_signal("gpio_110", OMAP_PIN_OUTPUT); |
| 120 | omap_mux_init_signal("gpio_126", OMAP_PIN_OUTPUT); |
| 121 | } else if (machine_is_omap3_torpedo()) { |
| 122 | /* OMAP3 Torpedo board */ |
| 123 | board_mmc_info[0].gpio_cd = OMAP3_TORPEDO_MMC_GPIO_CD; |
| 124 | omap_mux_init_signal("gpio_127", OMAP_PIN_OUTPUT); |
| 125 | } else { |
| 126 | /* unsupported board */ |
| 127 | printk(KERN_ERR "%s(): unknown machine type\n", __func__); |
| 128 | return; |
| 129 | } |
| 130 | |
| 131 | omap2_hsmmc_init(board_mmc_info); |
Tim Nordell | 8430281 | 2010-09-27 16:05:48 +0000 | [diff] [blame] | 132 | } |
| 133 | |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 134 | static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = { |
| 135 | .cs = OMAP3LOGIC_SMSC911X_CS, |
| 136 | .gpio_irq = -EINVAL, |
| 137 | .gpio_reset = -EINVAL, |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | /* TODO/FIXME (comment by Peter Barada, LogicPD): |
| 141 | * Fix the PBIAS voltage for Torpedo MMC1 pins that |
| 142 | * are used for other needs (IRQs, etc). */ |
| 143 | static void omap3torpedo_fix_pbias_voltage(void) |
| 144 | { |
| 145 | u16 control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE; |
| 146 | u32 reg; |
| 147 | |
| 148 | if (machine_is_omap3_torpedo()) |
| 149 | { |
| 150 | /* Set the bias for the pin */ |
| 151 | reg = omap_ctrl_readl(control_pbias_offset); |
| 152 | |
| 153 | reg &= ~OMAP343X_PBIASLITEPWRDNZ1; |
| 154 | omap_ctrl_writel(reg, control_pbias_offset); |
| 155 | |
| 156 | /* 100ms delay required for PBIAS configuration */ |
| 157 | msleep(100); |
| 158 | |
| 159 | reg |= OMAP343X_PBIASLITEVMODE1; |
| 160 | reg |= OMAP343X_PBIASLITEPWRDNZ1; |
| 161 | omap_ctrl_writel(reg | 0x300, control_pbias_offset); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | static inline void __init board_smsc911x_init(void) |
| 166 | { |
| 167 | if (machine_is_omap3530_lv_som()) { |
| 168 | /* OMAP3530 LV SOM board */ |
| 169 | board_smsc911x_data.gpio_irq = |
| 170 | OMAP3530_LV_SOM_SMSC911X_GPIO_IRQ; |
| 171 | omap_mux_init_signal("gpio_152", OMAP_PIN_INPUT); |
| 172 | } else if (machine_is_omap3_torpedo()) { |
| 173 | /* OMAP3 Torpedo board */ |
| 174 | board_smsc911x_data.gpio_irq = OMAP3_TORPEDO_SMSC911X_GPIO_IRQ; |
| 175 | omap_mux_init_signal("gpio_129", OMAP_PIN_INPUT); |
| 176 | } else { |
| 177 | /* unsupported board */ |
| 178 | printk(KERN_ERR "%s(): unknown machine type\n", __func__); |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | gpmc_smsc911x_init(&board_smsc911x_data); |
| 183 | } |
| 184 | |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 185 | #ifdef CONFIG_OMAP_MUX |
| 186 | static struct omap_board_mux board_mux[] __initdata = { |
| 187 | { .reg_offset = OMAP_MUX_TERMINATOR }, |
| 188 | }; |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 189 | #endif |
| 190 | |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 191 | static void __init omap3logic_init(void) |
| 192 | { |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 193 | omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); |
| 194 | omap3torpedo_fix_pbias_voltage(); |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 195 | omap3logic_i2c_init(); |
| 196 | omap_serial_init(); |
Tony Lindgren | a4ca9db | 2011-08-22 23:57:23 -0700 | [diff] [blame] | 197 | omap_sdrc_init(NULL, NULL); |
Tim Nordell | 8430281 | 2010-09-27 16:05:48 +0000 | [diff] [blame] | 198 | board_mmc_init(); |
Tim Nordell | 26428b5 | 2010-09-27 16:05:50 +0000 | [diff] [blame] | 199 | board_smsc911x_init(); |
| 200 | |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 201 | /* Ensure SDRC pins are mux'd for self-refresh */ |
| 202 | omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); |
| 203 | omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); |
| 204 | } |
| 205 | |
| 206 | MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board") |
Nicolas Pitre | 5e52b43 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 207 | .atag_offset = 0x100, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 208 | .map_io = omap3_map_io, |
Tony Lindgren | 8f5b5a4 | 2011-08-22 23:57:24 -0700 | [diff] [blame] | 209 | .init_early = omap35xx_init_early, |
Tony Lindgren | 741e3a8 | 2011-05-17 03:51:26 -0700 | [diff] [blame] | 210 | .init_irq = omap3_init_irq, |
Marc Zyngier | 6b2f55d | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 211 | .handle_irq = omap3_intc_handle_irq, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 212 | .init_machine = omap3logic_init, |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 213 | .timer = &omap3_timer, |
Russell King | baa9588 | 2011-11-05 17:06:28 +0000 | [diff] [blame] | 214 | .restart = omap_prcm_restart, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 215 | MACHINE_END |
| 216 | |
| 217 | MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board") |
Nicolas Pitre | 5e52b43 | 2011-07-05 22:38:15 -0400 | [diff] [blame] | 218 | .atag_offset = 0x100, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 219 | .map_io = omap3_map_io, |
Tony Lindgren | 8f5b5a4 | 2011-08-22 23:57:24 -0700 | [diff] [blame] | 220 | .init_early = omap35xx_init_early, |
Tony Lindgren | 741e3a8 | 2011-05-17 03:51:26 -0700 | [diff] [blame] | 221 | .init_irq = omap3_init_irq, |
Marc Zyngier | 6b2f55d | 2011-09-06 10:23:45 +0100 | [diff] [blame] | 222 | .handle_irq = omap3_intc_handle_irq, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 223 | .init_machine = omap3logic_init, |
Tony Lindgren | e74984e | 2011-03-29 15:54:48 -0700 | [diff] [blame] | 224 | .timer = &omap3_timer, |
Russell King | baa9588 | 2011-11-05 17:06:28 +0000 | [diff] [blame] | 225 | .restart = omap_prcm_restart, |
Tim Nordell | d40f3f1 | 2010-09-27 16:05:47 +0000 | [diff] [blame] | 226 | MACHINE_END |