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> |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 20 | #include <linux/amba/serial.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 21 | #include <linux/spi/spi.h> |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 22 | #include <linux/mfd/ab8500.h> |
Bengt Jonsson | 79568b94 | 2011-03-11 11:54:46 +0100 | [diff] [blame] | 23 | #include <linux/regulator/ab8500.h> |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 24 | #include <linux/mfd/tc3589x.h> |
Linus Walleij | fe67dfc | 2011-03-07 11:48:15 +0100 | [diff] [blame] | 25 | #include <linux/mfd/tps6105x.h> |
Bibek Basu | 3ef374a | 2011-02-15 12:56:16 +0530 | [diff] [blame] | 26 | #include <linux/mfd/ab8500/gpio.h> |
Philippe Langlais | dd7b2a0 | 2011-01-12 11:26:20 +0100 | [diff] [blame] | 27 | #include <linux/leds-lp5521.h> |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame] | 28 | #include <linux/input.h> |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 29 | #include <linux/smsc911x.h> |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame] | 30 | #include <linux/gpio_keys.h> |
Shreshtha Kumar Sahu | 1a7d436 | 2011-06-13 10:11:44 +0200 | [diff] [blame] | 31 | #include <linux/delay.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 32 | |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 33 | #include <linux/leds.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 37 | #include <plat/i2c.h> |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 38 | #include <plat/ste_dma40.h> |
Shreshtha Kumar Sahu | 1a7d436 | 2011-06-13 10:11:44 +0200 | [diff] [blame] | 39 | #include <plat/pincfg.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 40 | |
| 41 | #include <mach/hardware.h> |
| 42 | #include <mach/setup.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 43 | #include <mach/devices.h> |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 44 | #include <mach/irqs.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 45 | |
Shreshtha Kumar Sahu | 1a7d436 | 2011-06-13 10:11:44 +0200 | [diff] [blame] | 46 | #include "pins-db8500.h" |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 47 | #include "ste-dma40-db8500.h" |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 48 | #include "devices-db8500.h" |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 49 | #include "board-mop500.h" |
Bengt Jonsson | a1e516e | 2010-12-10 11:08:48 +0100 | [diff] [blame] | 50 | #include "board-mop500-regulators.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 51 | |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 52 | static struct gpio_led snowball_led_array[] = { |
| 53 | { |
| 54 | .name = "user_led", |
| 55 | .default_trigger = "none", |
| 56 | .gpio = 142, |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | static struct gpio_led_platform_data snowball_led_data = { |
| 61 | .leds = snowball_led_array, |
| 62 | .num_leds = ARRAY_SIZE(snowball_led_array), |
| 63 | }; |
| 64 | |
| 65 | static struct platform_device snowball_led_dev = { |
| 66 | .name = "leds-gpio", |
| 67 | .dev = { |
| 68 | .platform_data = &snowball_led_data, |
| 69 | }, |
| 70 | }; |
| 71 | |
Bibek Basu | 3ef374a | 2011-02-15 12:56:16 +0530 | [diff] [blame] | 72 | static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { |
| 73 | .gpio_base = MOP500_AB8500_GPIO(0), |
| 74 | .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE, |
| 75 | /* config_reg is the initial configuration of ab8500 pins. |
| 76 | * The pins can be configured as GPIO or alt functions based |
| 77 | * on value present in GpioSel1 to GpioSel6 and AlternatFunction |
| 78 | * register. This is the array of 7 configuration settings. |
| 79 | * One has to compile time decide these settings. Below is the |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 80 | * explanation of these setting |
Bibek Basu | 3ef374a | 2011-02-15 12:56:16 +0530 | [diff] [blame] | 81 | * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO |
| 82 | * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO |
| 83 | * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO |
| 84 | * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO |
| 85 | * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO |
| 86 | * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO |
| 87 | * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured |
| 88 | * as GPIO then this register selectes the alternate fucntions |
| 89 | */ |
| 90 | .config_reg = {0x00, 0x1E, 0x80, 0x01, |
| 91 | 0x7A, 0x00, 0x00}, |
| 92 | }; |
| 93 | |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 94 | static struct gpio_keys_button snowball_key_array[] = { |
| 95 | { |
| 96 | .gpio = 32, |
| 97 | .type = EV_KEY, |
| 98 | .code = KEY_1, |
| 99 | .desc = "userpb", |
| 100 | .active_low = 1, |
| 101 | .debounce_interval = 50, |
| 102 | .wakeup = 1, |
| 103 | }, |
| 104 | { |
| 105 | .gpio = 151, |
| 106 | .type = EV_KEY, |
| 107 | .code = KEY_2, |
| 108 | .desc = "extkb1", |
| 109 | .active_low = 1, |
| 110 | .debounce_interval = 50, |
| 111 | .wakeup = 1, |
| 112 | }, |
| 113 | { |
| 114 | .gpio = 152, |
| 115 | .type = EV_KEY, |
| 116 | .code = KEY_3, |
| 117 | .desc = "extkb2", |
| 118 | .active_low = 1, |
| 119 | .debounce_interval = 50, |
| 120 | .wakeup = 1, |
| 121 | }, |
| 122 | { |
| 123 | .gpio = 161, |
| 124 | .type = EV_KEY, |
| 125 | .code = KEY_4, |
| 126 | .desc = "extkb3", |
| 127 | .active_low = 1, |
| 128 | .debounce_interval = 50, |
| 129 | .wakeup = 1, |
| 130 | }, |
| 131 | { |
| 132 | .gpio = 162, |
| 133 | .type = EV_KEY, |
| 134 | .code = KEY_5, |
| 135 | .desc = "extkb4", |
| 136 | .active_low = 1, |
| 137 | .debounce_interval = 50, |
| 138 | .wakeup = 1, |
| 139 | }, |
| 140 | }; |
| 141 | |
| 142 | static struct gpio_keys_platform_data snowball_key_data = { |
| 143 | .buttons = snowball_key_array, |
| 144 | .nbuttons = ARRAY_SIZE(snowball_key_array), |
| 145 | }; |
| 146 | |
| 147 | static struct platform_device snowball_key_dev = { |
| 148 | .name = "gpio-keys", |
| 149 | .id = -1, |
| 150 | .dev = { |
| 151 | .platform_data = &snowball_key_data, |
| 152 | } |
| 153 | }; |
| 154 | |
| 155 | static struct smsc911x_platform_config snowball_sbnet_cfg = { |
| 156 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, |
| 157 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 158 | .flags = SMSC911X_USE_16BIT | SMSC911X_FORCE_INTERNAL_PHY, |
| 159 | .shift = 1, |
| 160 | }; |
| 161 | |
| 162 | static struct resource sbnet_res[] = { |
| 163 | { |
| 164 | .name = "smsc911x-memory", |
| 165 | .start = (0x5000 << 16), |
| 166 | .end = (0x5000 << 16) + 0xffff, |
| 167 | .flags = IORESOURCE_MEM, |
| 168 | }, |
| 169 | { |
| 170 | .start = NOMADIK_GPIO_TO_IRQ(140), |
| 171 | .end = NOMADIK_GPIO_TO_IRQ(140), |
| 172 | .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, |
| 173 | }, |
| 174 | }; |
| 175 | |
| 176 | static struct platform_device snowball_sbnet_dev = { |
| 177 | .name = "smsc911x", |
| 178 | .num_resources = ARRAY_SIZE(sbnet_res), |
| 179 | .resource = sbnet_res, |
| 180 | .dev = { |
| 181 | .platform_data = &snowball_sbnet_cfg, |
| 182 | }, |
| 183 | }; |
| 184 | |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 185 | static struct ab8500_platform_data ab8500_platdata = { |
| 186 | .irq_base = MOP500_AB8500_IRQ_BASE, |
Bengt Jonsson | dfa3a82 | 2011-03-09 13:34:17 +0100 | [diff] [blame] | 187 | .regulator_reg_init = ab8500_regulator_reg_init, |
| 188 | .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init), |
Bengt Jonsson | a1e516e | 2010-12-10 11:08:48 +0100 | [diff] [blame] | 189 | .regulator = ab8500_regulators, |
| 190 | .num_regulator = ARRAY_SIZE(ab8500_regulators), |
Bibek Basu | 3ef374a | 2011-02-15 12:56:16 +0530 | [diff] [blame] | 191 | .gpio = &ab8500_gpio_pdata, |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 192 | }; |
| 193 | |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 194 | static struct resource ab8500_resources[] = { |
| 195 | [0] = { |
Rabin Vincent | 22039b7 | 2010-12-08 11:07:56 +0530 | [diff] [blame] | 196 | .start = IRQ_DB8500_AB8500, |
| 197 | .end = IRQ_DB8500_AB8500, |
| 198 | .flags = IORESOURCE_IRQ |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 199 | } |
| 200 | }; |
| 201 | |
| 202 | struct platform_device ab8500_device = { |
| 203 | .name = "ab8500-i2c", |
| 204 | .id = 0, |
| 205 | .dev = { |
| 206 | .platform_data = &ab8500_platdata, |
| 207 | }, |
| 208 | .num_resources = 1, |
| 209 | .resource = ab8500_resources, |
| 210 | }; |
| 211 | |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 212 | /* |
Linus Walleij | fe67dfc | 2011-03-07 11:48:15 +0100 | [diff] [blame] | 213 | * TPS61052 |
| 214 | */ |
| 215 | |
| 216 | static struct tps6105x_platform_data mop500_tps61052_data = { |
| 217 | .mode = TPS6105X_MODE_VOLTAGE, |
| 218 | .regulator_data = &tps61052_regulator, |
| 219 | }; |
| 220 | |
| 221 | /* |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 222 | * TC35892 |
| 223 | */ |
| 224 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 225 | static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base) |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 226 | { |
| 227 | mop500_sdi_tc35892_init(); |
| 228 | } |
| 229 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 230 | static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = { |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 231 | .gpio_base = MOP500_EGPIO(0), |
| 232 | .setup = mop500_tc35892_init, |
| 233 | }; |
| 234 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 235 | static struct tc3589x_platform_data mop500_tc35892_data = { |
Sundar Iyer | 611b759 | 2010-12-13 09:33:15 +0530 | [diff] [blame] | 236 | .block = TC3589x_BLOCK_GPIO, |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 237 | .gpio = &mop500_tc35892_gpio_data, |
| 238 | .irq_base = MOP500_EGPIO_IRQ_BASE, |
| 239 | }; |
| 240 | |
Philippe Langlais | dd7b2a0 | 2011-01-12 11:26:20 +0100 | [diff] [blame] | 241 | static struct lp5521_led_config lp5521_pri_led[] = { |
| 242 | [0] = { |
| 243 | .chan_nr = 0, |
| 244 | .led_current = 0x2f, |
| 245 | .max_current = 0x5f, |
| 246 | }, |
| 247 | [1] = { |
| 248 | .chan_nr = 1, |
| 249 | .led_current = 0x2f, |
| 250 | .max_current = 0x5f, |
| 251 | }, |
| 252 | [2] = { |
| 253 | .chan_nr = 2, |
| 254 | .led_current = 0x2f, |
| 255 | .max_current = 0x5f, |
| 256 | }, |
| 257 | }; |
| 258 | |
| 259 | static struct lp5521_platform_data __initdata lp5521_pri_data = { |
| 260 | .label = "lp5521_pri", |
| 261 | .led_config = &lp5521_pri_led[0], |
| 262 | .num_channels = 3, |
| 263 | .clock_mode = LP5521_CLOCK_EXT, |
| 264 | }; |
| 265 | |
| 266 | static struct lp5521_led_config lp5521_sec_led[] = { |
| 267 | [0] = { |
| 268 | .chan_nr = 0, |
| 269 | .led_current = 0x2f, |
| 270 | .max_current = 0x5f, |
| 271 | }, |
| 272 | [1] = { |
| 273 | .chan_nr = 1, |
| 274 | .led_current = 0x2f, |
| 275 | .max_current = 0x5f, |
| 276 | }, |
| 277 | [2] = { |
| 278 | .chan_nr = 2, |
| 279 | .led_current = 0x2f, |
| 280 | .max_current = 0x5f, |
| 281 | }, |
| 282 | }; |
| 283 | |
| 284 | static struct lp5521_platform_data __initdata lp5521_sec_data = { |
| 285 | .label = "lp5521_sec", |
| 286 | .led_config = &lp5521_sec_led[0], |
| 287 | .num_channels = 3, |
| 288 | .clock_mode = LP5521_CLOCK_EXT, |
| 289 | }; |
| 290 | |
Linus Walleij | fe67dfc | 2011-03-07 11:48:15 +0100 | [diff] [blame] | 291 | static struct i2c_board_info __initdata mop500_i2c0_devices[] = { |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 292 | { |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 293 | I2C_BOARD_INFO("tc3589x", 0x42), |
Philippe Langlais | dd7b2a0 | 2011-01-12 11:26:20 +0100 | [diff] [blame] | 294 | .irq = NOMADIK_GPIO_TO_IRQ(217), |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 295 | .platform_data = &mop500_tc35892_data, |
| 296 | }, |
Linus Walleij | cf568c5 | 2011-03-30 14:31:42 +0200 | [diff] [blame] | 297 | /* I2C0 devices only available prior to HREFv60 */ |
Linus Walleij | fe67dfc | 2011-03-07 11:48:15 +0100 | [diff] [blame] | 298 | { |
| 299 | I2C_BOARD_INFO("tps61052", 0x33), |
| 300 | .platform_data = &mop500_tps61052_data, |
| 301 | }, |
| 302 | }; |
| 303 | |
Linus Walleij | cf568c5 | 2011-03-30 14:31:42 +0200 | [diff] [blame] | 304 | #define NUM_PRE_V60_I2C0_DEVICES 1 |
| 305 | |
Philippe Langlais | dd7b2a0 | 2011-01-12 11:26:20 +0100 | [diff] [blame] | 306 | static struct i2c_board_info __initdata mop500_i2c2_devices[] = { |
| 307 | { |
| 308 | /* lp5521 LED driver, 1st device */ |
| 309 | I2C_BOARD_INFO("lp5521", 0x33), |
| 310 | .platform_data = &lp5521_pri_data, |
| 311 | }, |
| 312 | { |
| 313 | /* lp5521 LED driver, 2st device */ |
| 314 | I2C_BOARD_INFO("lp5521", 0x34), |
| 315 | .platform_data = &lp5521_sec_data, |
| 316 | }, |
Lee Jones | bb3b218 | 2011-01-13 14:41:22 +0000 | [diff] [blame] | 317 | { |
| 318 | /* Light sensor Rohm BH1780GLI */ |
| 319 | I2C_BOARD_INFO("bh1780", 0x29), |
| 320 | }, |
Philippe Langlais | dd7b2a0 | 2011-01-12 11:26:20 +0100 | [diff] [blame] | 321 | }; |
| 322 | |
Linus Walleij | 2b030bd | 2011-05-13 12:31:13 +0200 | [diff] [blame] | 323 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, t_out, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 324 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 325 | /* \ |
| 326 | * slave data setup time, which is \ |
| 327 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 328 | * respectively for a 48 Mhz \ |
| 329 | * i2c clock \ |
| 330 | */ \ |
| 331 | .slsu = _slsu, \ |
| 332 | /* Tx FIFO threshold */ \ |
| 333 | .tft = _tft, \ |
| 334 | /* Rx FIFO threshold */ \ |
| 335 | .rft = _rft, \ |
| 336 | /* std. mode operation */ \ |
| 337 | .clk_freq = clk, \ |
Linus Walleij | 2b030bd | 2011-05-13 12:31:13 +0200 | [diff] [blame] | 338 | /* Slave response timeout(ms) */\ |
| 339 | .timeout = t_out, \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 340 | .sm = _sm, \ |
| 341 | } |
| 342 | |
| 343 | /* |
| 344 | * The board uses 4 i2c controllers, initialize all of |
| 345 | * them with slave data setup time of 250 ns, |
Linus Walleij | 2b030bd | 2011-05-13 12:31:13 +0200 | [diff] [blame] | 346 | * Tx & Rx FIFO threshold values as 8 and standard |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 347 | * mode of operation |
| 348 | */ |
Linus Walleij | 2b030bd | 2011-05-13 12:31:13 +0200 | [diff] [blame] | 349 | U8500_I2C_CONTROLLER(0, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); |
| 350 | U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); |
| 351 | U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); |
| 352 | U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 353 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 354 | static void __init mop500_i2c_init(void) |
| 355 | { |
| 356 | db8500_add_i2c0(&u8500_i2c0_data); |
| 357 | db8500_add_i2c1(&u8500_i2c1_data); |
| 358 | db8500_add_i2c2(&u8500_i2c2_data); |
| 359 | db8500_add_i2c3(&u8500_i2c3_data); |
| 360 | } |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 361 | |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame] | 362 | static struct gpio_keys_button mop500_gpio_keys[] = { |
| 363 | { |
| 364 | .desc = "SFH7741 Proximity Sensor", |
| 365 | .type = EV_SW, |
| 366 | .code = SW_FRONT_PROXIMITY, |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame] | 367 | .active_low = 0, |
| 368 | .can_disable = 1, |
| 369 | } |
| 370 | }; |
| 371 | |
| 372 | static struct regulator *prox_regulator; |
| 373 | static int mop500_prox_activate(struct device *dev); |
| 374 | static void mop500_prox_deactivate(struct device *dev); |
| 375 | |
| 376 | static struct gpio_keys_platform_data mop500_gpio_keys_data = { |
| 377 | .buttons = mop500_gpio_keys, |
| 378 | .nbuttons = ARRAY_SIZE(mop500_gpio_keys), |
| 379 | .enable = mop500_prox_activate, |
| 380 | .disable = mop500_prox_deactivate, |
| 381 | }; |
| 382 | |
| 383 | static struct platform_device mop500_gpio_keys_device = { |
| 384 | .name = "gpio-keys", |
| 385 | .id = 0, |
| 386 | .dev = { |
| 387 | .platform_data = &mop500_gpio_keys_data, |
| 388 | }, |
| 389 | }; |
| 390 | |
| 391 | static int mop500_prox_activate(struct device *dev) |
| 392 | { |
| 393 | prox_regulator = regulator_get(&mop500_gpio_keys_device.dev, |
| 394 | "vcc"); |
| 395 | if (IS_ERR(prox_regulator)) { |
| 396 | dev_err(&mop500_gpio_keys_device.dev, |
| 397 | "no regulator\n"); |
| 398 | return PTR_ERR(prox_regulator); |
| 399 | } |
| 400 | regulator_enable(prox_regulator); |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static void mop500_prox_deactivate(struct device *dev) |
| 405 | { |
| 406 | regulator_disable(prox_regulator); |
| 407 | regulator_put(prox_regulator); |
| 408 | } |
| 409 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 410 | /* add any platform devices here - TODO */ |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 411 | static struct platform_device *mop500_platform_devs[] __initdata = { |
Philippe Langlais | a71b819 | 2011-01-14 10:53:59 +0100 | [diff] [blame] | 412 | &mop500_gpio_keys_device, |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 413 | &ab8500_device, |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 414 | }; |
| 415 | |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 416 | #ifdef CONFIG_STE_DMA40 |
| 417 | static struct stedma40_chan_cfg ssp0_dma_cfg_rx = { |
| 418 | .mode = STEDMA40_MODE_LOGICAL, |
| 419 | .dir = STEDMA40_PERIPH_TO_MEM, |
| 420 | .src_dev_type = DB8500_DMA_DEV8_SSP0_RX, |
| 421 | .dst_dev_type = STEDMA40_DEV_DST_MEMORY, |
| 422 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 423 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 424 | }; |
| 425 | |
| 426 | static struct stedma40_chan_cfg ssp0_dma_cfg_tx = { |
| 427 | .mode = STEDMA40_MODE_LOGICAL, |
| 428 | .dir = STEDMA40_MEM_TO_PERIPH, |
| 429 | .src_dev_type = STEDMA40_DEV_SRC_MEMORY, |
| 430 | .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX, |
| 431 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 432 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 433 | }; |
| 434 | #endif |
| 435 | |
| 436 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 437 | .bus_id = 0, |
| 438 | #ifdef CONFIG_STE_DMA40 |
| 439 | .enable_dma = 1, |
| 440 | .dma_filter = stedma40_filter, |
| 441 | .dma_rx_param = &ssp0_dma_cfg_rx, |
| 442 | .dma_tx_param = &ssp0_dma_cfg_tx, |
| 443 | #else |
| 444 | .enable_dma = 0, |
| 445 | #endif |
| 446 | /* on this platform, gpio 31,142,144,214 & |
| 447 | * 224 are connected as chip selects |
| 448 | */ |
| 449 | .num_chipselect = 5, |
| 450 | }; |
| 451 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 452 | static void __init mop500_spi_init(void) |
| 453 | { |
| 454 | db8500_add_ssp0(&ssp0_platform_data); |
| 455 | } |
| 456 | |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 457 | #ifdef CONFIG_STE_DMA40 |
| 458 | static struct stedma40_chan_cfg uart0_dma_cfg_rx = { |
| 459 | .mode = STEDMA40_MODE_LOGICAL, |
| 460 | .dir = STEDMA40_PERIPH_TO_MEM, |
| 461 | .src_dev_type = DB8500_DMA_DEV13_UART0_RX, |
| 462 | .dst_dev_type = STEDMA40_DEV_DST_MEMORY, |
| 463 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 464 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 465 | }; |
| 466 | |
| 467 | static struct stedma40_chan_cfg uart0_dma_cfg_tx = { |
| 468 | .mode = STEDMA40_MODE_LOGICAL, |
| 469 | .dir = STEDMA40_MEM_TO_PERIPH, |
| 470 | .src_dev_type = STEDMA40_DEV_SRC_MEMORY, |
| 471 | .dst_dev_type = DB8500_DMA_DEV13_UART0_TX, |
| 472 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 473 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 474 | }; |
| 475 | |
| 476 | static struct stedma40_chan_cfg uart1_dma_cfg_rx = { |
| 477 | .mode = STEDMA40_MODE_LOGICAL, |
| 478 | .dir = STEDMA40_PERIPH_TO_MEM, |
| 479 | .src_dev_type = DB8500_DMA_DEV12_UART1_RX, |
| 480 | .dst_dev_type = STEDMA40_DEV_DST_MEMORY, |
| 481 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 482 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 483 | }; |
| 484 | |
| 485 | static struct stedma40_chan_cfg uart1_dma_cfg_tx = { |
| 486 | .mode = STEDMA40_MODE_LOGICAL, |
| 487 | .dir = STEDMA40_MEM_TO_PERIPH, |
| 488 | .src_dev_type = STEDMA40_DEV_SRC_MEMORY, |
| 489 | .dst_dev_type = DB8500_DMA_DEV12_UART1_TX, |
| 490 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 491 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 492 | }; |
| 493 | |
| 494 | static struct stedma40_chan_cfg uart2_dma_cfg_rx = { |
| 495 | .mode = STEDMA40_MODE_LOGICAL, |
| 496 | .dir = STEDMA40_PERIPH_TO_MEM, |
| 497 | .src_dev_type = DB8500_DMA_DEV11_UART2_RX, |
| 498 | .dst_dev_type = STEDMA40_DEV_DST_MEMORY, |
| 499 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 500 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 501 | }; |
| 502 | |
| 503 | static struct stedma40_chan_cfg uart2_dma_cfg_tx = { |
| 504 | .mode = STEDMA40_MODE_LOGICAL, |
| 505 | .dir = STEDMA40_MEM_TO_PERIPH, |
| 506 | .src_dev_type = STEDMA40_DEV_SRC_MEMORY, |
| 507 | .dst_dev_type = DB8500_DMA_DEV11_UART2_TX, |
| 508 | .src_info.data_width = STEDMA40_BYTE_WIDTH, |
| 509 | .dst_info.data_width = STEDMA40_BYTE_WIDTH, |
| 510 | }; |
| 511 | #endif |
| 512 | |
Shreshtha Kumar Sahu | 1a7d436 | 2011-06-13 10:11:44 +0200 | [diff] [blame] | 513 | |
| 514 | static pin_cfg_t mop500_pins_uart0[] = { |
| 515 | GPIO0_U0_CTSn | PIN_INPUT_PULLUP, |
| 516 | GPIO1_U0_RTSn | PIN_OUTPUT_HIGH, |
| 517 | GPIO2_U0_RXD | PIN_INPUT_PULLUP, |
| 518 | GPIO3_U0_TXD | PIN_OUTPUT_HIGH, |
| 519 | }; |
| 520 | |
| 521 | #define PRCC_K_SOFTRST_SET 0x18 |
| 522 | #define PRCC_K_SOFTRST_CLEAR 0x1C |
| 523 | static void ux500_uart0_reset(void) |
| 524 | { |
| 525 | void __iomem *prcc_rst_set, *prcc_rst_clr; |
| 526 | |
| 527 | prcc_rst_set = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE + |
| 528 | PRCC_K_SOFTRST_SET); |
| 529 | prcc_rst_clr = (void __iomem *)IO_ADDRESS(U8500_CLKRST1_BASE + |
| 530 | PRCC_K_SOFTRST_CLEAR); |
| 531 | |
| 532 | /* Activate soft reset PRCC_K_SOFTRST_CLEAR */ |
| 533 | writel((readl(prcc_rst_clr) | 0x1), prcc_rst_clr); |
| 534 | udelay(1); |
| 535 | |
| 536 | /* Release soft reset PRCC_K_SOFTRST_SET */ |
| 537 | writel((readl(prcc_rst_set) | 0x1), prcc_rst_set); |
| 538 | udelay(1); |
| 539 | } |
| 540 | |
| 541 | static void ux500_uart0_init(void) |
| 542 | { |
| 543 | int ret; |
| 544 | |
| 545 | ret = nmk_config_pins(mop500_pins_uart0, |
| 546 | ARRAY_SIZE(mop500_pins_uart0)); |
| 547 | if (ret < 0) |
| 548 | pr_err("pl011: uart pins_enable failed\n"); |
| 549 | } |
| 550 | |
| 551 | static void ux500_uart0_exit(void) |
| 552 | { |
| 553 | int ret; |
| 554 | |
| 555 | ret = nmk_config_pins_sleep(mop500_pins_uart0, |
| 556 | ARRAY_SIZE(mop500_pins_uart0)); |
| 557 | if (ret < 0) |
| 558 | pr_err("pl011: uart pins_disable failed\n"); |
| 559 | } |
| 560 | |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 561 | static struct amba_pl011_data uart0_plat = { |
| 562 | #ifdef CONFIG_STE_DMA40 |
| 563 | .dma_filter = stedma40_filter, |
| 564 | .dma_rx_param = &uart0_dma_cfg_rx, |
| 565 | .dma_tx_param = &uart0_dma_cfg_tx, |
| 566 | #endif |
Shreshtha Kumar Sahu | 1a7d436 | 2011-06-13 10:11:44 +0200 | [diff] [blame] | 567 | .init = ux500_uart0_init, |
| 568 | .exit = ux500_uart0_exit, |
| 569 | .reset = ux500_uart0_reset, |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 570 | }; |
| 571 | |
| 572 | static struct amba_pl011_data uart1_plat = { |
| 573 | #ifdef CONFIG_STE_DMA40 |
| 574 | .dma_filter = stedma40_filter, |
| 575 | .dma_rx_param = &uart1_dma_cfg_rx, |
| 576 | .dma_tx_param = &uart1_dma_cfg_tx, |
| 577 | #endif |
| 578 | }; |
| 579 | |
| 580 | static struct amba_pl011_data uart2_plat = { |
| 581 | #ifdef CONFIG_STE_DMA40 |
| 582 | .dma_filter = stedma40_filter, |
| 583 | .dma_rx_param = &uart2_dma_cfg_rx, |
| 584 | .dma_tx_param = &uart2_dma_cfg_tx, |
| 585 | #endif |
| 586 | }; |
| 587 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 588 | static void __init mop500_uart_init(void) |
| 589 | { |
Linus Walleij | 5d7b846 | 2010-10-14 13:57:59 +0200 | [diff] [blame] | 590 | db8500_add_uart0(&uart0_plat); |
| 591 | db8500_add_uart1(&uart1_plat); |
| 592 | db8500_add_uart2(&uart2_plat); |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 593 | } |
| 594 | |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 595 | static struct platform_device *snowball_platform_devs[] __initdata = { |
| 596 | &snowball_led_dev, |
| 597 | &snowball_key_dev, |
| 598 | &snowball_sbnet_dev, |
| 599 | &ab8500_device, |
| 600 | }; |
| 601 | |
Linus Walleij | 4b4f757 | 2011-02-15 15:01:35 +0100 | [diff] [blame] | 602 | static void __init mop500_init_machine(void) |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 603 | { |
Linus Walleij | cf568c5 | 2011-03-30 14:31:42 +0200 | [diff] [blame] | 604 | int i2c0_devs; |
| 605 | |
Lee Jones | 110c2c2 | 2011-08-26 16:54:07 +0100 | [diff] [blame^] | 606 | mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; |
Linus Walleij | 4b4f757 | 2011-02-15 15:01:35 +0100 | [diff] [blame] | 607 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 608 | u8500_init_devices(); |
| 609 | |
Rabin Vincent | fe05203 | 2011-02-11 17:07:21 -0700 | [diff] [blame] | 610 | mop500_pins_init(); |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 611 | |
Lee Jones | 110c2c2 | 2011-08-26 16:54:07 +0100 | [diff] [blame^] | 612 | platform_add_devices(mop500_platform_devs, |
| 613 | ARRAY_SIZE(mop500_platform_devs)); |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 614 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 615 | mop500_i2c_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 616 | mop500_sdi_init(); |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 617 | mop500_spi_init(); |
| 618 | mop500_uart_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 619 | |
Linus Walleij | cf568c5 | 2011-03-30 14:31:42 +0200 | [diff] [blame] | 620 | i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); |
Lee Jones | 110c2c2 | 2011-08-26 16:54:07 +0100 | [diff] [blame^] | 621 | |
| 622 | i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs); |
| 623 | i2c_register_board_info(2, mop500_i2c2_devices, |
| 624 | ARRAY_SIZE(mop500_i2c2_devices)); |
| 625 | |
| 626 | /* This board has full regulator constraints */ |
| 627 | regulator_has_full_constraints(); |
| 628 | } |
| 629 | |
| 630 | static void __init snowball_init_machine(void) |
| 631 | { |
| 632 | int i2c0_devs; |
| 633 | |
| 634 | u8500_init_devices(); |
| 635 | |
| 636 | snowball_pins_init(); |
| 637 | |
| 638 | platform_add_devices(snowball_platform_devs, |
| 639 | ARRAY_SIZE(snowball_platform_devs)); |
| 640 | |
| 641 | mop500_i2c_init(); |
| 642 | snowball_sdi_init(); |
| 643 | mop500_spi_init(); |
| 644 | mop500_uart_init(); |
| 645 | |
| 646 | i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); |
| 647 | i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs); |
| 648 | i2c_register_board_info(2, mop500_i2c2_devices, |
| 649 | ARRAY_SIZE(mop500_i2c2_devices)); |
| 650 | |
| 651 | /* This board has full regulator constraints */ |
| 652 | regulator_has_full_constraints(); |
| 653 | } |
| 654 | |
| 655 | static void __init hrefv60_init_machine(void) |
| 656 | { |
| 657 | int i2c0_devs; |
| 658 | |
| 659 | /* |
| 660 | * The HREFv60 board removed a GPIO expander and routed |
| 661 | * all these GPIO pins to the internal GPIO controller |
| 662 | * instead. |
| 663 | */ |
| 664 | mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; |
| 665 | |
| 666 | u8500_init_devices(); |
| 667 | |
| 668 | hrefv60_pins_init(); |
| 669 | |
| 670 | platform_add_devices(mop500_platform_devs, |
| 671 | ARRAY_SIZE(mop500_platform_devs)); |
| 672 | |
| 673 | mop500_i2c_init(); |
| 674 | mop500_sdi_init(); |
| 675 | mop500_spi_init(); |
| 676 | mop500_uart_init(); |
| 677 | |
| 678 | i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); |
| 679 | |
| 680 | i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES; |
Linus Walleij | cf568c5 | 2011-03-30 14:31:42 +0200 | [diff] [blame] | 681 | |
| 682 | i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs); |
Philippe Langlais | dd7b2a0 | 2011-01-12 11:26:20 +0100 | [diff] [blame] | 683 | i2c_register_board_info(2, mop500_i2c2_devices, |
| 684 | ARRAY_SIZE(mop500_i2c2_devices)); |
Linus Walleij | db24520 | 2011-04-04 10:44:51 +0200 | [diff] [blame] | 685 | |
| 686 | /* This board has full regulator constraints */ |
| 687 | regulator_has_full_constraints(); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 691 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 692 | .boot_params = 0x100, |
| 693 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 694 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 695 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 696 | .timer = &ux500_timer, |
Linus Walleij | 4b4f757 | 2011-02-15 15:01:35 +0100 | [diff] [blame] | 697 | .init_machine = mop500_init_machine, |
| 698 | MACHINE_END |
| 699 | |
| 700 | MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+") |
| 701 | .boot_params = 0x100, |
| 702 | .map_io = u8500_map_io, |
| 703 | .init_irq = ux500_init_irq, |
| 704 | .timer = &ux500_timer, |
Lee Jones | 110c2c2 | 2011-08-26 16:54:07 +0100 | [diff] [blame^] | 705 | .init_machine = hrefv60_init_machine, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 706 | MACHINE_END |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 707 | |
| 708 | MACHINE_START(SNOWBALL, "Calao Systems Snowball platform") |
| 709 | .boot_params = 0x100, |
| 710 | .map_io = u8500_map_io, |
| 711 | .init_irq = ux500_init_irq, |
| 712 | /* we re-use nomadik timer here */ |
| 713 | .timer = &ux500_timer, |
Lee Jones | 110c2c2 | 2011-08-26 16:54:07 +0100 | [diff] [blame^] | 714 | .init_machine = snowball_init_machine, |
Robert Marklund | 350abe0 | 2011-06-20 15:55:46 +0200 | [diff] [blame] | 715 | MACHINE_END |