Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 ST-Ericsson |
| 3 | * |
| 4 | * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2, as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/io.h> |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 16 | #include <linux/i2c.h> |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 17 | #include <linux/gpio.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 18 | #include <linux/amba/bus.h> |
| 19 | #include <linux/amba/pl022.h> |
| 20 | #include <linux/spi/spi.h> |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 21 | #include <linux/mfd/ab8500.h> |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 22 | #include <linux/mfd/tc3589x.h> |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame^] | 23 | #include <linux/input.h> |
| 24 | #include <linux/gpio_keys.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 25 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 26 | #include <asm/mach-types.h> |
| 27 | #include <asm/mach/arch.h> |
| 28 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 29 | #include <plat/pincfg.h> |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 30 | #include <plat/i2c.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 31 | |
| 32 | #include <mach/hardware.h> |
| 33 | #include <mach/setup.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 34 | #include <mach/devices.h> |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 35 | #include <mach/irqs.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 36 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 37 | #include "devices-db8500.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 38 | #include "pins-db8500.h" |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 39 | #include "board-mop500.h" |
Bengt Jonsson | a1e516e | 2010-12-10 11:08:48 +0100 | [diff] [blame] | 40 | #include "board-mop500-regulators.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 41 | |
| 42 | static pin_cfg_t mop500_pins[] = { |
| 43 | /* SSP0 */ |
| 44 | GPIO143_SSP0_CLK, |
| 45 | GPIO144_SSP0_FRM, |
| 46 | GPIO145_SSP0_RXD, |
| 47 | GPIO146_SSP0_TXD, |
| 48 | |
| 49 | /* I2C */ |
| 50 | GPIO147_I2C0_SCL, |
| 51 | GPIO148_I2C0_SDA, |
| 52 | GPIO16_I2C1_SCL, |
| 53 | GPIO17_I2C1_SDA, |
| 54 | GPIO10_I2C2_SDA, |
| 55 | GPIO11_I2C2_SCL, |
| 56 | GPIO229_I2C3_SDA, |
| 57 | GPIO230_I2C3_SCL, |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 58 | |
| 59 | /* SKE keypad */ |
| 60 | GPIO153_KP_I7, |
| 61 | GPIO154_KP_I6, |
| 62 | GPIO155_KP_I5, |
| 63 | GPIO156_KP_I4, |
| 64 | GPIO157_KP_O7, |
| 65 | GPIO158_KP_O6, |
| 66 | GPIO159_KP_O5, |
| 67 | GPIO160_KP_O4, |
| 68 | GPIO161_KP_I3, |
| 69 | GPIO162_KP_I2, |
| 70 | GPIO163_KP_I1, |
| 71 | GPIO164_KP_I0, |
| 72 | GPIO165_KP_O3, |
| 73 | GPIO166_KP_O2, |
| 74 | GPIO167_KP_O1, |
| 75 | GPIO168_KP_O0, |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 76 | |
Sundar Iyer | 556fb03 | 2010-12-03 20:35:38 +0530 | [diff] [blame] | 77 | /* GPIO_EXP_INT */ |
| 78 | GPIO217_GPIO, |
| 79 | |
| 80 | /* STMPE1601 IRQ */ |
| 81 | GPIO218_GPIO | PIN_INPUT_PULLUP, |
Sundar Iyer | 71f933f | 2011-01-21 10:56:18 +0530 | [diff] [blame] | 82 | |
| 83 | /* touch screen */ |
| 84 | GPIO84_GPIO | PIN_INPUT_PULLUP, |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 85 | }; |
| 86 | |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 87 | static struct ab8500_platform_data ab8500_platdata = { |
| 88 | .irq_base = MOP500_AB8500_IRQ_BASE, |
Bengt Jonsson | a1e516e | 2010-12-10 11:08:48 +0100 | [diff] [blame] | 89 | .regulator = ab8500_regulators, |
| 90 | .num_regulator = ARRAY_SIZE(ab8500_regulators), |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 91 | }; |
| 92 | |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 93 | static struct resource ab8500_resources[] = { |
| 94 | [0] = { |
Rabin Vincent | 22039b7 | 2010-12-08 11:07:56 +0530 | [diff] [blame] | 95 | .start = IRQ_DB8500_AB8500, |
| 96 | .end = IRQ_DB8500_AB8500, |
| 97 | .flags = IORESOURCE_IRQ |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 98 | } |
| 99 | }; |
| 100 | |
| 101 | struct platform_device ab8500_device = { |
| 102 | .name = "ab8500-i2c", |
| 103 | .id = 0, |
| 104 | .dev = { |
| 105 | .platform_data = &ab8500_platdata, |
| 106 | }, |
| 107 | .num_resources = 1, |
| 108 | .resource = ab8500_resources, |
| 109 | }; |
| 110 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 111 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 112 | .bus_id = 0, |
| 113 | /* pl022 not yet supports dma */ |
| 114 | .enable_dma = 0, |
| 115 | /* on this platform, gpio 31,142,144,214 & |
| 116 | * 224 are connected as chip selects |
| 117 | */ |
| 118 | .num_chipselect = 5, |
| 119 | }; |
| 120 | |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 121 | /* |
| 122 | * TC35892 |
| 123 | */ |
| 124 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 125 | static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base) |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 126 | { |
| 127 | mop500_sdi_tc35892_init(); |
| 128 | } |
| 129 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 130 | static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = { |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 131 | .gpio_base = MOP500_EGPIO(0), |
| 132 | .setup = mop500_tc35892_init, |
| 133 | }; |
| 134 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 135 | static struct tc3589x_platform_data mop500_tc35892_data = { |
Sundar Iyer | 611b759 | 2010-12-13 09:33:15 +0530 | [diff] [blame] | 136 | .block = TC3589x_BLOCK_GPIO, |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 137 | .gpio = &mop500_tc35892_gpio_data, |
| 138 | .irq_base = MOP500_EGPIO_IRQ_BASE, |
| 139 | }; |
| 140 | |
| 141 | static struct i2c_board_info mop500_i2c0_devices[] = { |
| 142 | { |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 143 | I2C_BOARD_INFO("tc3589x", 0x42), |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 144 | .irq = NOMADIK_GPIO_TO_IRQ(217), |
| 145 | .platform_data = &mop500_tc35892_data, |
| 146 | }, |
| 147 | }; |
| 148 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 149 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 150 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 151 | /* \ |
| 152 | * slave data setup time, which is \ |
| 153 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 154 | * respectively for a 48 Mhz \ |
| 155 | * i2c clock \ |
| 156 | */ \ |
| 157 | .slsu = _slsu, \ |
| 158 | /* Tx FIFO threshold */ \ |
| 159 | .tft = _tft, \ |
| 160 | /* Rx FIFO threshold */ \ |
| 161 | .rft = _rft, \ |
| 162 | /* std. mode operation */ \ |
| 163 | .clk_freq = clk, \ |
| 164 | .sm = _sm, \ |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | * The board uses 4 i2c controllers, initialize all of |
| 169 | * them with slave data setup time of 250 ns, |
| 170 | * Tx & Rx FIFO threshold values as 1 and standard |
| 171 | * mode of operation |
| 172 | */ |
| 173 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 174 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 175 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 176 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 177 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 178 | static void __init mop500_i2c_init(void) |
| 179 | { |
| 180 | db8500_add_i2c0(&u8500_i2c0_data); |
| 181 | db8500_add_i2c1(&u8500_i2c1_data); |
| 182 | db8500_add_i2c2(&u8500_i2c2_data); |
| 183 | db8500_add_i2c3(&u8500_i2c3_data); |
| 184 | } |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 185 | |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame^] | 186 | static struct gpio_keys_button mop500_gpio_keys[] = { |
| 187 | { |
| 188 | .desc = "SFH7741 Proximity Sensor", |
| 189 | .type = EV_SW, |
| 190 | .code = SW_FRONT_PROXIMITY, |
| 191 | .gpio = GPIO_PROX_SENSOR, |
| 192 | .active_low = 0, |
| 193 | .can_disable = 1, |
| 194 | } |
| 195 | }; |
| 196 | |
| 197 | static struct regulator *prox_regulator; |
| 198 | static int mop500_prox_activate(struct device *dev); |
| 199 | static void mop500_prox_deactivate(struct device *dev); |
| 200 | |
| 201 | static struct gpio_keys_platform_data mop500_gpio_keys_data = { |
| 202 | .buttons = mop500_gpio_keys, |
| 203 | .nbuttons = ARRAY_SIZE(mop500_gpio_keys), |
| 204 | .enable = mop500_prox_activate, |
| 205 | .disable = mop500_prox_deactivate, |
| 206 | }; |
| 207 | |
| 208 | static struct platform_device mop500_gpio_keys_device = { |
| 209 | .name = "gpio-keys", |
| 210 | .id = 0, |
| 211 | .dev = { |
| 212 | .platform_data = &mop500_gpio_keys_data, |
| 213 | }, |
| 214 | }; |
| 215 | |
| 216 | static int mop500_prox_activate(struct device *dev) |
| 217 | { |
| 218 | prox_regulator = regulator_get(&mop500_gpio_keys_device.dev, |
| 219 | "vcc"); |
| 220 | if (IS_ERR(prox_regulator)) { |
| 221 | dev_err(&mop500_gpio_keys_device.dev, |
| 222 | "no regulator\n"); |
| 223 | return PTR_ERR(prox_regulator); |
| 224 | } |
| 225 | regulator_enable(prox_regulator); |
| 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | static void mop500_prox_deactivate(struct device *dev) |
| 230 | { |
| 231 | regulator_disable(prox_regulator); |
| 232 | regulator_put(prox_regulator); |
| 233 | } |
| 234 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 235 | /* add any platform devices here - TODO */ |
| 236 | static struct platform_device *platform_devs[] __initdata = { |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame^] | 237 | &mop500_gpio_keys_device, |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 238 | }; |
| 239 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 240 | static void __init mop500_spi_init(void) |
| 241 | { |
| 242 | db8500_add_ssp0(&ssp0_platform_data); |
| 243 | } |
| 244 | |
| 245 | static void __init mop500_uart_init(void) |
| 246 | { |
| 247 | db8500_add_uart0(); |
| 248 | db8500_add_uart1(); |
| 249 | db8500_add_uart2(); |
| 250 | } |
| 251 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 252 | static void __init u8500_init_machine(void) |
| 253 | { |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 254 | u8500_init_devices(); |
| 255 | |
| 256 | nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins)); |
| 257 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 258 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 259 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 260 | mop500_i2c_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 261 | mop500_sdi_init(); |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 262 | mop500_spi_init(); |
| 263 | mop500_uart_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 264 | |
Sundar Iyer | d5d2281 | 2010-12-13 09:33:11 +0530 | [diff] [blame] | 265 | platform_device_register(&ab8500_device); |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 266 | |
| 267 | i2c_register_board_info(0, mop500_i2c0_devices, |
| 268 | ARRAY_SIZE(mop500_i2c0_devices)); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 272 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 273 | .boot_params = 0x100, |
| 274 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 275 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 276 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 277 | .timer = &ux500_timer, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 278 | .init_machine = u8500_init_machine, |
| 279 | MACHINE_END |