blob: ffe3cf1451a8fee6b6366a8daabf6f00a758aefd [file] [log] [blame]
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01001/*
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 Vincentb8410a12010-08-09 19:18:17 +053016#include <linux/i2c.h>
Rabin Vincentea05a572010-06-03 07:58:42 +010017#include <linux/gpio.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010018#include <linux/amba/bus.h>
19#include <linux/amba/pl022.h>
20#include <linux/spi/spi.h>
Rabin Vincent39ae7022010-07-26 11:12:15 +010021#include <linux/mfd/ab8500.h>
Sundar Iyer20406eb2010-12-13 09:33:14 +053022#include <linux/mfd/tc3589x.h>
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010023#include <linux/leds-lp5521.h>
Philippe Langlaisa71b8192011-01-14 10:53:59 +010024#include <linux/input.h>
25#include <linux/gpio_keys.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010026
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010027#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29
Rabin Vincentea05a572010-06-03 07:58:42 +010030#include <plat/pincfg.h>
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010031#include <plat/i2c.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010032
33#include <mach/hardware.h>
34#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010035#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010036#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010037
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053038#include "devices-db8500.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010039#include "pins-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010040#include "board-mop500.h"
Bengt Jonssona1e516e2010-12-10 11:08:48 +010041#include "board-mop500-regulators.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010042
43static pin_cfg_t mop500_pins[] = {
44 /* SSP0 */
45 GPIO143_SSP0_CLK,
46 GPIO144_SSP0_FRM,
47 GPIO145_SSP0_RXD,
48 GPIO146_SSP0_TXD,
49
50 /* I2C */
51 GPIO147_I2C0_SCL,
52 GPIO148_I2C0_SDA,
53 GPIO16_I2C1_SCL,
54 GPIO17_I2C1_SDA,
55 GPIO10_I2C2_SDA,
56 GPIO11_I2C2_SCL,
57 GPIO229_I2C3_SDA,
58 GPIO230_I2C3_SCL,
Sundar Iyer4c61c842010-09-29 19:43:09 -070059
60 /* SKE keypad */
61 GPIO153_KP_I7,
62 GPIO154_KP_I6,
63 GPIO155_KP_I5,
64 GPIO156_KP_I4,
65 GPIO157_KP_O7,
66 GPIO158_KP_O6,
67 GPIO159_KP_O5,
68 GPIO160_KP_O4,
69 GPIO161_KP_I3,
70 GPIO162_KP_I2,
71 GPIO163_KP_I1,
72 GPIO164_KP_I0,
73 GPIO165_KP_O3,
74 GPIO166_KP_O2,
75 GPIO167_KP_O1,
76 GPIO168_KP_O0,
Rabin Vincentb8410a12010-08-09 19:18:17 +053077
Sundar Iyer556fb032010-12-03 20:35:38 +053078 /* GPIO_EXP_INT */
79 GPIO217_GPIO,
80
81 /* STMPE1601 IRQ */
82 GPIO218_GPIO | PIN_INPUT_PULLUP,
Sundar Iyer71f933f2011-01-21 10:56:18 +053083
84 /* touch screen */
85 GPIO84_GPIO | PIN_INPUT_PULLUP,
Rabin Vincentea05a572010-06-03 07:58:42 +010086};
87
Rabin Vincent39ae7022010-07-26 11:12:15 +010088static struct ab8500_platform_data ab8500_platdata = {
89 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssona1e516e2010-12-10 11:08:48 +010090 .regulator = ab8500_regulators,
91 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Rabin Vincent39ae7022010-07-26 11:12:15 +010092};
93
Linus Walleij29aeb3c2010-09-06 22:15:08 +010094static struct resource ab8500_resources[] = {
95 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +053096 .start = IRQ_DB8500_AB8500,
97 .end = IRQ_DB8500_AB8500,
98 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +010099 }
100};
101
102struct platform_device ab8500_device = {
103 .name = "ab8500-i2c",
104 .id = 0,
105 .dev = {
106 .platform_data = &ab8500_platdata,
107 },
108 .num_resources = 1,
109 .resource = ab8500_resources,
110};
111
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100112static struct pl022_ssp_controller ssp0_platform_data = {
113 .bus_id = 0,
114 /* pl022 not yet supports dma */
115 .enable_dma = 0,
116 /* on this platform, gpio 31,142,144,214 &
117 * 224 are connected as chip selects
118 */
119 .num_chipselect = 5,
120};
121
Rabin Vincentb8410a12010-08-09 19:18:17 +0530122/*
123 * TC35892
124 */
125
Sundar Iyer20406eb2010-12-13 09:33:14 +0530126static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +0530127{
128 mop500_sdi_tc35892_init();
129}
130
Sundar Iyer20406eb2010-12-13 09:33:14 +0530131static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +0530132 .gpio_base = MOP500_EGPIO(0),
133 .setup = mop500_tc35892_init,
134};
135
Sundar Iyer20406eb2010-12-13 09:33:14 +0530136static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +0530137 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +0530138 .gpio = &mop500_tc35892_gpio_data,
139 .irq_base = MOP500_EGPIO_IRQ_BASE,
140};
141
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100142static struct lp5521_led_config lp5521_pri_led[] = {
143 [0] = {
144 .chan_nr = 0,
145 .led_current = 0x2f,
146 .max_current = 0x5f,
147 },
148 [1] = {
149 .chan_nr = 1,
150 .led_current = 0x2f,
151 .max_current = 0x5f,
152 },
153 [2] = {
154 .chan_nr = 2,
155 .led_current = 0x2f,
156 .max_current = 0x5f,
157 },
158};
159
160static struct lp5521_platform_data __initdata lp5521_pri_data = {
161 .label = "lp5521_pri",
162 .led_config = &lp5521_pri_led[0],
163 .num_channels = 3,
164 .clock_mode = LP5521_CLOCK_EXT,
165};
166
167static struct lp5521_led_config lp5521_sec_led[] = {
168 [0] = {
169 .chan_nr = 0,
170 .led_current = 0x2f,
171 .max_current = 0x5f,
172 },
173 [1] = {
174 .chan_nr = 1,
175 .led_current = 0x2f,
176 .max_current = 0x5f,
177 },
178 [2] = {
179 .chan_nr = 2,
180 .led_current = 0x2f,
181 .max_current = 0x5f,
182 },
183};
184
185static struct lp5521_platform_data __initdata lp5521_sec_data = {
186 .label = "lp5521_sec",
187 .led_config = &lp5521_sec_led[0],
188 .num_channels = 3,
189 .clock_mode = LP5521_CLOCK_EXT,
190};
191
Rabin Vincentb8410a12010-08-09 19:18:17 +0530192static struct i2c_board_info mop500_i2c0_devices[] = {
193 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530194 I2C_BOARD_INFO("tc3589x", 0x42),
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100195 .irq = NOMADIK_GPIO_TO_IRQ(217),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530196 .platform_data = &mop500_tc35892_data,
197 },
198};
199
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100200static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
201 {
202 /* lp5521 LED driver, 1st device */
203 I2C_BOARD_INFO("lp5521", 0x33),
204 .platform_data = &lp5521_pri_data,
205 },
206 {
207 /* lp5521 LED driver, 2st device */
208 I2C_BOARD_INFO("lp5521", 0x34),
209 .platform_data = &lp5521_sec_data,
210 },
Lee Jonesbb3b2182011-01-13 14:41:22 +0000211 {
212 /* Light sensor Rohm BH1780GLI */
213 I2C_BOARD_INFO("bh1780", 0x29),
214 },
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100215};
216
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100217#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100218static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100219 /* \
220 * slave data setup time, which is \
221 * 250 ns,100ns,10ns which is 14,6,2 \
222 * respectively for a 48 Mhz \
223 * i2c clock \
224 */ \
225 .slsu = _slsu, \
226 /* Tx FIFO threshold */ \
227 .tft = _tft, \
228 /* Rx FIFO threshold */ \
229 .rft = _rft, \
230 /* std. mode operation */ \
231 .clk_freq = clk, \
232 .sm = _sm, \
233}
234
235/*
236 * The board uses 4 i2c controllers, initialize all of
237 * them with slave data setup time of 250 ns,
238 * Tx & Rx FIFO threshold values as 1 and standard
239 * mode of operation
240 */
241U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
242U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
243U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
244U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
245
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530246static void __init mop500_i2c_init(void)
247{
248 db8500_add_i2c0(&u8500_i2c0_data);
249 db8500_add_i2c1(&u8500_i2c1_data);
250 db8500_add_i2c2(&u8500_i2c2_data);
251 db8500_add_i2c3(&u8500_i2c3_data);
252}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100253
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100254static struct gpio_keys_button mop500_gpio_keys[] = {
255 {
256 .desc = "SFH7741 Proximity Sensor",
257 .type = EV_SW,
258 .code = SW_FRONT_PROXIMITY,
259 .gpio = GPIO_PROX_SENSOR,
260 .active_low = 0,
261 .can_disable = 1,
262 }
263};
264
265static struct regulator *prox_regulator;
266static int mop500_prox_activate(struct device *dev);
267static void mop500_prox_deactivate(struct device *dev);
268
269static struct gpio_keys_platform_data mop500_gpio_keys_data = {
270 .buttons = mop500_gpio_keys,
271 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
272 .enable = mop500_prox_activate,
273 .disable = mop500_prox_deactivate,
274};
275
276static struct platform_device mop500_gpio_keys_device = {
277 .name = "gpio-keys",
278 .id = 0,
279 .dev = {
280 .platform_data = &mop500_gpio_keys_data,
281 },
282};
283
284static int mop500_prox_activate(struct device *dev)
285{
286 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
287 "vcc");
288 if (IS_ERR(prox_regulator)) {
289 dev_err(&mop500_gpio_keys_device.dev,
290 "no regulator\n");
291 return PTR_ERR(prox_regulator);
292 }
293 regulator_enable(prox_regulator);
294 return 0;
295}
296
297static void mop500_prox_deactivate(struct device *dev)
298{
299 regulator_disable(prox_regulator);
300 regulator_put(prox_regulator);
301}
302
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100303/* add any platform devices here - TODO */
304static struct platform_device *platform_devs[] __initdata = {
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100305 &mop500_gpio_keys_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100306};
307
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530308static void __init mop500_spi_init(void)
309{
310 db8500_add_ssp0(&ssp0_platform_data);
311}
312
313static void __init mop500_uart_init(void)
314{
315 db8500_add_uart0();
316 db8500_add_uart1();
317 db8500_add_uart2();
318}
319
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100320static void __init u8500_init_machine(void)
321{
Rabin Vincentea05a572010-06-03 07:58:42 +0100322 u8500_init_devices();
323
324 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
325
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100326 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
327
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530328 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100329 mop500_sdi_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530330 mop500_spi_init();
331 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100332
Sundar Iyerd5d22812010-12-13 09:33:11 +0530333 platform_device_register(&ab8500_device);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530334
335 i2c_register_board_info(0, mop500_i2c0_devices,
336 ARRAY_SIZE(mop500_i2c0_devices));
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100337 i2c_register_board_info(2, mop500_i2c2_devices,
338 ARRAY_SIZE(mop500_i2c2_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100339}
340
341MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
342 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100343 .boot_params = 0x100,
344 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100345 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100346 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100347 .timer = &ux500_timer,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100348 .init_machine = u8500_init_machine,
349MACHINE_END