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