Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 1 | /* |
| 2 | * board-omap3pandora.c (Pandora Handheld Console) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but |
| 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
| 16 | * 02110-1301 USA |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <linux/init.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/platform_device.h> |
| 23 | |
| 24 | #include <linux/spi/spi.h> |
| 25 | #include <linux/spi/ads7846.h> |
Grazvydas Ignotas | 64f535a | 2009-05-28 14:04:04 -0700 | [diff] [blame^] | 26 | #include <linux/regulator/machine.h> |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 27 | #include <linux/i2c/twl4030.h> |
| 28 | |
| 29 | #include <asm/mach-types.h> |
| 30 | #include <asm/mach/arch.h> |
| 31 | #include <asm/mach/map.h> |
| 32 | |
| 33 | #include <mach/board.h> |
| 34 | #include <mach/common.h> |
| 35 | #include <mach/gpio.h> |
| 36 | #include <mach/hardware.h> |
| 37 | #include <mach/mcspi.h> |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 38 | #include <mach/usb.h> |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 39 | |
Paul Walmsley | 2e12bd7 | 2009-05-28 14:03:59 -0700 | [diff] [blame] | 40 | #include "sdram-micron-mt46h32m32lf-6.h" |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 41 | #include "mmc-twl4030.h" |
| 42 | |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 43 | #define OMAP3_PANDORA_TS_GPIO 94 |
| 44 | |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 45 | static struct twl4030_hsmmc_info omap3pandora_mmc[] = { |
| 46 | { |
| 47 | .mmc = 1, |
| 48 | .wires = 4, |
| 49 | .gpio_cd = -EINVAL, |
| 50 | .gpio_wp = 126, |
| 51 | .ext_clock = 0, |
| 52 | }, |
| 53 | { |
| 54 | .mmc = 2, |
| 55 | .wires = 4, |
| 56 | .gpio_cd = -EINVAL, |
| 57 | .gpio_wp = 127, |
| 58 | .ext_clock = 1, |
David Brownell | 0329c37 | 2009-03-23 18:23:47 -0700 | [diff] [blame] | 59 | .transceiver = true, |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 60 | }, |
Grazvydas Ignotas | 07d83cc | 2009-03-23 18:23:47 -0700 | [diff] [blame] | 61 | { |
| 62 | .mmc = 3, |
| 63 | .wires = 4, |
| 64 | .gpio_cd = -EINVAL, |
| 65 | .gpio_wp = -EINVAL, |
| 66 | }, |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 67 | {} /* Terminator */ |
| 68 | }; |
| 69 | |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 70 | static struct omap_uart_config omap3pandora_uart_config __initdata = { |
| 71 | .enabled_uarts = (1 << 2), /* UART3 */ |
| 72 | }; |
| 73 | |
Grazvydas Ignotas | 64f535a | 2009-05-28 14:04:04 -0700 | [diff] [blame^] | 74 | static struct regulator_consumer_supply pandora_vmmc1_supply = { |
| 75 | .supply = "vmmc", |
| 76 | }; |
| 77 | |
| 78 | static struct regulator_consumer_supply pandora_vmmc2_supply = { |
| 79 | .supply = "vmmc", |
| 80 | }; |
| 81 | |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 82 | static int omap3pandora_twl_gpio_setup(struct device *dev, |
| 83 | unsigned gpio, unsigned ngpio) |
| 84 | { |
| 85 | /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */ |
| 86 | omap3pandora_mmc[0].gpio_cd = gpio + 0; |
| 87 | omap3pandora_mmc[1].gpio_cd = gpio + 1; |
| 88 | twl4030_mmc_init(omap3pandora_mmc); |
| 89 | |
Grazvydas Ignotas | 64f535a | 2009-05-28 14:04:04 -0700 | [diff] [blame^] | 90 | /* link regulators to MMC adapters */ |
| 91 | pandora_vmmc1_supply.dev = omap3pandora_mmc[0].dev; |
| 92 | pandora_vmmc2_supply.dev = omap3pandora_mmc[1].dev; |
| 93 | |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 94 | return 0; |
| 95 | } |
| 96 | |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 97 | static struct twl4030_gpio_platform_data omap3pandora_gpio_data = { |
| 98 | .gpio_base = OMAP_MAX_GPIO_LINES, |
| 99 | .irq_base = TWL4030_GPIO_IRQ_BASE, |
| 100 | .irq_end = TWL4030_GPIO_IRQ_END, |
Tony Lindgren | 90c62bf | 2008-12-10 17:37:17 -0800 | [diff] [blame] | 101 | .setup = omap3pandora_twl_gpio_setup, |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 102 | }; |
| 103 | |
Grazvydas Ignotas | 64f535a | 2009-05-28 14:04:04 -0700 | [diff] [blame^] | 104 | /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */ |
| 105 | static struct regulator_init_data pandora_vmmc1 = { |
| 106 | .constraints = { |
| 107 | .min_uV = 1850000, |
| 108 | .max_uV = 3150000, |
| 109 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 110 | | REGULATOR_MODE_STANDBY, |
| 111 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 112 | | REGULATOR_CHANGE_MODE |
| 113 | | REGULATOR_CHANGE_STATUS, |
| 114 | }, |
| 115 | .num_consumer_supplies = 1, |
| 116 | .consumer_supplies = &pandora_vmmc1_supply, |
| 117 | }; |
| 118 | |
| 119 | /* VMMC2 for MMC2 pins CMD, CLK, DAT0..DAT3 (max 100 mA) */ |
| 120 | static struct regulator_init_data pandora_vmmc2 = { |
| 121 | .constraints = { |
| 122 | .min_uV = 1850000, |
| 123 | .max_uV = 3150000, |
| 124 | .valid_modes_mask = REGULATOR_MODE_NORMAL |
| 125 | | REGULATOR_MODE_STANDBY, |
| 126 | .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
| 127 | | REGULATOR_CHANGE_MODE |
| 128 | | REGULATOR_CHANGE_STATUS, |
| 129 | }, |
| 130 | .num_consumer_supplies = 1, |
| 131 | .consumer_supplies = &pandora_vmmc2_supply, |
| 132 | }; |
| 133 | |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 134 | static struct twl4030_usb_data omap3pandora_usb_data = { |
| 135 | .usb_mode = T2_USB_MODE_ULPI, |
| 136 | }; |
| 137 | |
| 138 | static struct twl4030_platform_data omap3pandora_twldata = { |
| 139 | .irq_base = TWL4030_IRQ_BASE, |
| 140 | .irq_end = TWL4030_IRQ_END, |
| 141 | .gpio = &omap3pandora_gpio_data, |
| 142 | .usb = &omap3pandora_usb_data, |
Grazvydas Ignotas | 64f535a | 2009-05-28 14:04:04 -0700 | [diff] [blame^] | 143 | .vmmc1 = &pandora_vmmc1, |
| 144 | .vmmc2 = &pandora_vmmc2, |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 145 | }; |
| 146 | |
| 147 | static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = { |
| 148 | { |
| 149 | I2C_BOARD_INFO("tps65950", 0x48), |
| 150 | .flags = I2C_CLIENT_WAKE, |
| 151 | .irq = INT_34XX_SYS_NIRQ, |
| 152 | .platform_data = &omap3pandora_twldata, |
| 153 | }, |
| 154 | }; |
| 155 | |
| 156 | static int __init omap3pandora_i2c_init(void) |
| 157 | { |
| 158 | omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo, |
| 159 | ARRAY_SIZE(omap3pandora_i2c_boardinfo)); |
| 160 | /* i2c2 pins are not connected */ |
| 161 | omap_register_i2c_bus(3, 400, NULL, 0); |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | static void __init omap3pandora_init_irq(void) |
| 166 | { |
Paul Walmsley | 2e12bd7 | 2009-05-28 14:03:59 -0700 | [diff] [blame] | 167 | omap2_init_common_hw(mt46h32m32lf6_sdrc_params); |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 168 | omap_init_irq(); |
| 169 | omap_gpio_init(); |
| 170 | } |
| 171 | |
| 172 | static void __init omap3pandora_ads7846_init(void) |
| 173 | { |
| 174 | int gpio = OMAP3_PANDORA_TS_GPIO; |
| 175 | int ret; |
| 176 | |
| 177 | ret = gpio_request(gpio, "ads7846_pen_down"); |
| 178 | if (ret < 0) { |
| 179 | printk(KERN_ERR "Failed to request GPIO %d for " |
| 180 | "ads7846 pen down IRQ\n", gpio); |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | gpio_direction_input(gpio); |
| 185 | } |
| 186 | |
| 187 | static int ads7846_get_pendown_state(void) |
| 188 | { |
| 189 | return !gpio_get_value(OMAP3_PANDORA_TS_GPIO); |
| 190 | } |
| 191 | |
| 192 | static struct ads7846_platform_data ads7846_config = { |
| 193 | .x_max = 0x0fff, |
| 194 | .y_max = 0x0fff, |
| 195 | .x_plate_ohms = 180, |
| 196 | .pressure_max = 255, |
| 197 | .debounce_max = 10, |
| 198 | .debounce_tol = 3, |
| 199 | .debounce_rep = 1, |
| 200 | .get_pendown_state = ads7846_get_pendown_state, |
| 201 | .keep_vref_on = 1, |
| 202 | }; |
| 203 | |
| 204 | static struct omap2_mcspi_device_config ads7846_mcspi_config = { |
| 205 | .turbo_mode = 0, |
| 206 | .single_channel = 1, /* 0: slave, 1: master */ |
| 207 | }; |
| 208 | |
| 209 | static struct spi_board_info omap3pandora_spi_board_info[] __initdata = { |
| 210 | { |
| 211 | .modalias = "ads7846", |
| 212 | .bus_num = 1, |
| 213 | .chip_select = 0, |
| 214 | .max_speed_hz = 1500000, |
| 215 | .controller_data = &ads7846_mcspi_config, |
| 216 | .irq = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO), |
| 217 | .platform_data = &ads7846_config, |
| 218 | } |
| 219 | }; |
| 220 | |
| 221 | static struct platform_device omap3pandora_lcd_device = { |
| 222 | .name = "pandora_lcd", |
| 223 | .id = -1, |
| 224 | }; |
| 225 | |
| 226 | static struct omap_lcd_config omap3pandora_lcd_config __initdata = { |
| 227 | .ctrl_name = "internal", |
| 228 | }; |
| 229 | |
| 230 | static struct omap_board_config_kernel omap3pandora_config[] __initdata = { |
| 231 | { OMAP_TAG_UART, &omap3pandora_uart_config }, |
| 232 | { OMAP_TAG_LCD, &omap3pandora_lcd_config }, |
| 233 | }; |
| 234 | |
| 235 | static struct platform_device *omap3pandora_devices[] __initdata = { |
| 236 | &omap3pandora_lcd_device, |
| 237 | }; |
| 238 | |
| 239 | static void __init omap3pandora_init(void) |
| 240 | { |
| 241 | omap3pandora_i2c_init(); |
| 242 | platform_add_devices(omap3pandora_devices, |
| 243 | ARRAY_SIZE(omap3pandora_devices)); |
| 244 | omap_board_config = omap3pandora_config; |
| 245 | omap_board_config_size = ARRAY_SIZE(omap3pandora_config); |
| 246 | omap_serial_init(); |
| 247 | spi_register_board_info(omap3pandora_spi_board_info, |
| 248 | ARRAY_SIZE(omap3pandora_spi_board_info)); |
| 249 | omap3pandora_ads7846_init(); |
Felipe Balbi | 18cb7ac | 2009-03-23 18:34:06 -0700 | [diff] [blame] | 250 | usb_musb_init(); |
Grazvydas Ignotas | da17724 | 2008-12-10 17:36:54 -0800 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | static void __init omap3pandora_map_io(void) |
| 254 | { |
| 255 | omap2_set_globals_343x(); |
| 256 | omap2_map_common_io(); |
| 257 | } |
| 258 | |
| 259 | MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console") |
| 260 | .phys_io = 0x48000000, |
| 261 | .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc, |
| 262 | .boot_params = 0x80000100, |
| 263 | .map_io = omap3pandora_map_io, |
| 264 | .init_irq = omap3pandora_init_irq, |
| 265 | .init_machine = omap3pandora_init, |
| 266 | .timer = &omap_timer, |
| 267 | MACHINE_END |