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