blob: 67d9c634c05db2bb7a4377bdc2a7f79e3db4b76a [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>
Linus Walleij5d7b8462010-10-14 13:57:59 +020020#include <linux/amba/serial.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010021#include <linux/spi/spi.h>
Rabin Vincent39ae7022010-07-26 11:12:15 +010022#include <linux/mfd/ab8500.h>
Sundar Iyer20406eb2010-12-13 09:33:14 +053023#include <linux/mfd/tc3589x.h>
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010024#include <linux/leds-lp5521.h>
Philippe Langlaisa71b8192011-01-14 10:53:59 +010025#include <linux/input.h>
26#include <linux/gpio_keys.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010027
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010028#include <asm/mach-types.h>
29#include <asm/mach/arch.h>
30
Rabin Vincentea05a572010-06-03 07:58:42 +010031#include <plat/pincfg.h>
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010032#include <plat/i2c.h>
Linus Walleij5d7b8462010-10-14 13:57:59 +020033#include <plat/ste_dma40.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010034
35#include <mach/hardware.h>
36#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010037#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010038#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010039
Linus Walleij5d7b8462010-10-14 13:57:59 +020040#include "ste-dma40-db8500.h"
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053041#include "devices-db8500.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010042#include "pins-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010043#include "board-mop500.h"
Bengt Jonssona1e516e2010-12-10 11:08:48 +010044#include "board-mop500-regulators.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010045
46static pin_cfg_t mop500_pins[] = {
47 /* SSP0 */
48 GPIO143_SSP0_CLK,
49 GPIO144_SSP0_FRM,
50 GPIO145_SSP0_RXD,
51 GPIO146_SSP0_TXD,
52
53 /* I2C */
54 GPIO147_I2C0_SCL,
55 GPIO148_I2C0_SDA,
56 GPIO16_I2C1_SCL,
57 GPIO17_I2C1_SDA,
58 GPIO10_I2C2_SDA,
59 GPIO11_I2C2_SCL,
60 GPIO229_I2C3_SDA,
61 GPIO230_I2C3_SCL,
Sundar Iyer4c61c842010-09-29 19:43:09 -070062
63 /* SKE keypad */
64 GPIO153_KP_I7,
65 GPIO154_KP_I6,
66 GPIO155_KP_I5,
67 GPIO156_KP_I4,
68 GPIO157_KP_O7,
69 GPIO158_KP_O6,
70 GPIO159_KP_O5,
71 GPIO160_KP_O4,
72 GPIO161_KP_I3,
73 GPIO162_KP_I2,
74 GPIO163_KP_I1,
75 GPIO164_KP_I0,
76 GPIO165_KP_O3,
77 GPIO166_KP_O2,
78 GPIO167_KP_O1,
79 GPIO168_KP_O0,
Rabin Vincentb8410a12010-08-09 19:18:17 +053080
Sundar Iyer556fb032010-12-03 20:35:38 +053081 /* GPIO_EXP_INT */
82 GPIO217_GPIO,
83
84 /* STMPE1601 IRQ */
85 GPIO218_GPIO | PIN_INPUT_PULLUP,
Sundar Iyer71f933f2011-01-21 10:56:18 +053086
87 /* touch screen */
88 GPIO84_GPIO | PIN_INPUT_PULLUP,
Mian Yousaf Kaukab6f3f3c3f2011-01-21 18:21:50 +010089
90 /* USB OTG */
91 GPIO256_USB_NXT | PIN_PULL_DOWN,
92 GPIO257_USB_STP | PIN_PULL_UP,
93 GPIO258_USB_XCLK | PIN_PULL_DOWN,
94 GPIO259_USB_DIR | PIN_PULL_DOWN,
95 GPIO260_USB_DAT7 | PIN_PULL_DOWN,
96 GPIO261_USB_DAT6 | PIN_PULL_DOWN,
97 GPIO262_USB_DAT5 | PIN_PULL_DOWN,
98 GPIO263_USB_DAT4 | PIN_PULL_DOWN,
99 GPIO264_USB_DAT3 | PIN_PULL_DOWN,
100 GPIO265_USB_DAT2 | PIN_PULL_DOWN,
101 GPIO266_USB_DAT1 | PIN_PULL_DOWN,
102 GPIO267_USB_DAT0 | PIN_PULL_DOWN,
Rabin Vincentea05a572010-06-03 07:58:42 +0100103};
104
Rabin Vincent39ae7022010-07-26 11:12:15 +0100105static struct ab8500_platform_data ab8500_platdata = {
106 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssona1e516e2010-12-10 11:08:48 +0100107 .regulator = ab8500_regulators,
108 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Rabin Vincent39ae7022010-07-26 11:12:15 +0100109};
110
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100111static struct resource ab8500_resources[] = {
112 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +0530113 .start = IRQ_DB8500_AB8500,
114 .end = IRQ_DB8500_AB8500,
115 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100116 }
117};
118
119struct platform_device ab8500_device = {
120 .name = "ab8500-i2c",
121 .id = 0,
122 .dev = {
123 .platform_data = &ab8500_platdata,
124 },
125 .num_resources = 1,
126 .resource = ab8500_resources,
127};
128
Rabin Vincentb8410a12010-08-09 19:18:17 +0530129/*
130 * TC35892
131 */
132
Sundar Iyer20406eb2010-12-13 09:33:14 +0530133static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +0530134{
135 mop500_sdi_tc35892_init();
136}
137
Sundar Iyer20406eb2010-12-13 09:33:14 +0530138static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +0530139 .gpio_base = MOP500_EGPIO(0),
140 .setup = mop500_tc35892_init,
141};
142
Sundar Iyer20406eb2010-12-13 09:33:14 +0530143static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +0530144 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +0530145 .gpio = &mop500_tc35892_gpio_data,
146 .irq_base = MOP500_EGPIO_IRQ_BASE,
147};
148
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100149static struct lp5521_led_config lp5521_pri_led[] = {
150 [0] = {
151 .chan_nr = 0,
152 .led_current = 0x2f,
153 .max_current = 0x5f,
154 },
155 [1] = {
156 .chan_nr = 1,
157 .led_current = 0x2f,
158 .max_current = 0x5f,
159 },
160 [2] = {
161 .chan_nr = 2,
162 .led_current = 0x2f,
163 .max_current = 0x5f,
164 },
165};
166
167static struct lp5521_platform_data __initdata lp5521_pri_data = {
168 .label = "lp5521_pri",
169 .led_config = &lp5521_pri_led[0],
170 .num_channels = 3,
171 .clock_mode = LP5521_CLOCK_EXT,
172};
173
174static struct lp5521_led_config lp5521_sec_led[] = {
175 [0] = {
176 .chan_nr = 0,
177 .led_current = 0x2f,
178 .max_current = 0x5f,
179 },
180 [1] = {
181 .chan_nr = 1,
182 .led_current = 0x2f,
183 .max_current = 0x5f,
184 },
185 [2] = {
186 .chan_nr = 2,
187 .led_current = 0x2f,
188 .max_current = 0x5f,
189 },
190};
191
192static struct lp5521_platform_data __initdata lp5521_sec_data = {
193 .label = "lp5521_sec",
194 .led_config = &lp5521_sec_led[0],
195 .num_channels = 3,
196 .clock_mode = LP5521_CLOCK_EXT,
197};
198
Rabin Vincentb8410a12010-08-09 19:18:17 +0530199static struct i2c_board_info mop500_i2c0_devices[] = {
200 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530201 I2C_BOARD_INFO("tc3589x", 0x42),
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100202 .irq = NOMADIK_GPIO_TO_IRQ(217),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530203 .platform_data = &mop500_tc35892_data,
204 },
205};
206
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100207static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
208 {
209 /* lp5521 LED driver, 1st device */
210 I2C_BOARD_INFO("lp5521", 0x33),
211 .platform_data = &lp5521_pri_data,
212 },
213 {
214 /* lp5521 LED driver, 2st device */
215 I2C_BOARD_INFO("lp5521", 0x34),
216 .platform_data = &lp5521_sec_data,
217 },
Lee Jonesbb3b2182011-01-13 14:41:22 +0000218 {
219 /* Light sensor Rohm BH1780GLI */
220 I2C_BOARD_INFO("bh1780", 0x29),
221 },
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100222};
223
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100224#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100225static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100226 /* \
227 * slave data setup time, which is \
228 * 250 ns,100ns,10ns which is 14,6,2 \
229 * respectively for a 48 Mhz \
230 * i2c clock \
231 */ \
232 .slsu = _slsu, \
233 /* Tx FIFO threshold */ \
234 .tft = _tft, \
235 /* Rx FIFO threshold */ \
236 .rft = _rft, \
237 /* std. mode operation */ \
238 .clk_freq = clk, \
239 .sm = _sm, \
240}
241
242/*
243 * The board uses 4 i2c controllers, initialize all of
244 * them with slave data setup time of 250 ns,
245 * Tx & Rx FIFO threshold values as 1 and standard
246 * mode of operation
247 */
248U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
249U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
250U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
251U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
252
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530253static void __init mop500_i2c_init(void)
254{
255 db8500_add_i2c0(&u8500_i2c0_data);
256 db8500_add_i2c1(&u8500_i2c1_data);
257 db8500_add_i2c2(&u8500_i2c2_data);
258 db8500_add_i2c3(&u8500_i2c3_data);
259}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100260
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100261static struct gpio_keys_button mop500_gpio_keys[] = {
262 {
263 .desc = "SFH7741 Proximity Sensor",
264 .type = EV_SW,
265 .code = SW_FRONT_PROXIMITY,
266 .gpio = GPIO_PROX_SENSOR,
267 .active_low = 0,
268 .can_disable = 1,
269 }
270};
271
272static struct regulator *prox_regulator;
273static int mop500_prox_activate(struct device *dev);
274static void mop500_prox_deactivate(struct device *dev);
275
276static struct gpio_keys_platform_data mop500_gpio_keys_data = {
277 .buttons = mop500_gpio_keys,
278 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
279 .enable = mop500_prox_activate,
280 .disable = mop500_prox_deactivate,
281};
282
283static struct platform_device mop500_gpio_keys_device = {
284 .name = "gpio-keys",
285 .id = 0,
286 .dev = {
287 .platform_data = &mop500_gpio_keys_data,
288 },
289};
290
291static int mop500_prox_activate(struct device *dev)
292{
293 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
294 "vcc");
295 if (IS_ERR(prox_regulator)) {
296 dev_err(&mop500_gpio_keys_device.dev,
297 "no regulator\n");
298 return PTR_ERR(prox_regulator);
299 }
300 regulator_enable(prox_regulator);
301 return 0;
302}
303
304static void mop500_prox_deactivate(struct device *dev)
305{
306 regulator_disable(prox_regulator);
307 regulator_put(prox_regulator);
308}
309
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100310/* add any platform devices here - TODO */
311static struct platform_device *platform_devs[] __initdata = {
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100312 &mop500_gpio_keys_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100313};
314
Linus Walleij5d7b8462010-10-14 13:57:59 +0200315#ifdef CONFIG_STE_DMA40
316static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
317 .mode = STEDMA40_MODE_LOGICAL,
318 .dir = STEDMA40_PERIPH_TO_MEM,
319 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
320 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
321 .src_info.data_width = STEDMA40_BYTE_WIDTH,
322 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
323};
324
325static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
326 .mode = STEDMA40_MODE_LOGICAL,
327 .dir = STEDMA40_MEM_TO_PERIPH,
328 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
329 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
330 .src_info.data_width = STEDMA40_BYTE_WIDTH,
331 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
332};
333#endif
334
335static struct pl022_ssp_controller ssp0_platform_data = {
336 .bus_id = 0,
337#ifdef CONFIG_STE_DMA40
338 .enable_dma = 1,
339 .dma_filter = stedma40_filter,
340 .dma_rx_param = &ssp0_dma_cfg_rx,
341 .dma_tx_param = &ssp0_dma_cfg_tx,
342#else
343 .enable_dma = 0,
344#endif
345 /* on this platform, gpio 31,142,144,214 &
346 * 224 are connected as chip selects
347 */
348 .num_chipselect = 5,
349};
350
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530351static void __init mop500_spi_init(void)
352{
353 db8500_add_ssp0(&ssp0_platform_data);
354}
355
Linus Walleij5d7b8462010-10-14 13:57:59 +0200356#ifdef CONFIG_STE_DMA40
357static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
358 .mode = STEDMA40_MODE_LOGICAL,
359 .dir = STEDMA40_PERIPH_TO_MEM,
360 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
361 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
362 .src_info.data_width = STEDMA40_BYTE_WIDTH,
363 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
364};
365
366static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
367 .mode = STEDMA40_MODE_LOGICAL,
368 .dir = STEDMA40_MEM_TO_PERIPH,
369 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
370 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
371 .src_info.data_width = STEDMA40_BYTE_WIDTH,
372 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
373};
374
375static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
376 .mode = STEDMA40_MODE_LOGICAL,
377 .dir = STEDMA40_PERIPH_TO_MEM,
378 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
379 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
380 .src_info.data_width = STEDMA40_BYTE_WIDTH,
381 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
382};
383
384static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
385 .mode = STEDMA40_MODE_LOGICAL,
386 .dir = STEDMA40_MEM_TO_PERIPH,
387 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
388 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
389 .src_info.data_width = STEDMA40_BYTE_WIDTH,
390 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
391};
392
393static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
394 .mode = STEDMA40_MODE_LOGICAL,
395 .dir = STEDMA40_PERIPH_TO_MEM,
396 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
397 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
398 .src_info.data_width = STEDMA40_BYTE_WIDTH,
399 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
400};
401
402static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
403 .mode = STEDMA40_MODE_LOGICAL,
404 .dir = STEDMA40_MEM_TO_PERIPH,
405 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
406 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
407 .src_info.data_width = STEDMA40_BYTE_WIDTH,
408 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
409};
410#endif
411
412static struct amba_pl011_data uart0_plat = {
413#ifdef CONFIG_STE_DMA40
414 .dma_filter = stedma40_filter,
415 .dma_rx_param = &uart0_dma_cfg_rx,
416 .dma_tx_param = &uart0_dma_cfg_tx,
417#endif
418};
419
420static struct amba_pl011_data uart1_plat = {
421#ifdef CONFIG_STE_DMA40
422 .dma_filter = stedma40_filter,
423 .dma_rx_param = &uart1_dma_cfg_rx,
424 .dma_tx_param = &uart1_dma_cfg_tx,
425#endif
426};
427
428static struct amba_pl011_data uart2_plat = {
429#ifdef CONFIG_STE_DMA40
430 .dma_filter = stedma40_filter,
431 .dma_rx_param = &uart2_dma_cfg_rx,
432 .dma_tx_param = &uart2_dma_cfg_tx,
433#endif
434};
435
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530436static void __init mop500_uart_init(void)
437{
Linus Walleij5d7b8462010-10-14 13:57:59 +0200438 db8500_add_uart0(&uart0_plat);
439 db8500_add_uart1(&uart1_plat);
440 db8500_add_uart2(&uart2_plat);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530441}
442
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100443static void __init u8500_init_machine(void)
444{
Rabin Vincentea05a572010-06-03 07:58:42 +0100445 u8500_init_devices();
446
447 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
448
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100449 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
450
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530451 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100452 mop500_sdi_init();
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530453 mop500_spi_init();
454 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100455
Sundar Iyerd5d22812010-12-13 09:33:11 +0530456 platform_device_register(&ab8500_device);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530457
458 i2c_register_board_info(0, mop500_i2c0_devices,
459 ARRAY_SIZE(mop500_i2c0_devices));
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100460 i2c_register_board_info(2, mop500_i2c2_devices,
461 ARRAY_SIZE(mop500_i2c2_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100462}
463
464MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
465 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100466 .boot_params = 0x100,
467 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100468 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100469 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100470 .timer = &ux500_timer,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100471 .init_machine = u8500_init_machine,
472MACHINE_END