blob: d0076453d7ffd4bf36a31c4dfdd49db10fce291c [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>
Bengt Jonsson79568b92011-03-11 11:54:46 +010023#include <linux/regulator/ab8500.h>
Sundar Iyer20406eb2010-12-13 09:33:14 +053024#include <linux/mfd/tc3589x.h>
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010025#include <linux/leds-lp5521.h>
Philippe Langlaisa71b8192011-01-14 10:53:59 +010026#include <linux/input.h>
27#include <linux/gpio_keys.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010028
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010029#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31
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 Vincentfbf1ead2010-09-29 19:46:32 +053041#include "devices-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010042#include "board-mop500.h"
Bengt Jonssona1e516e2010-12-10 11:08:48 +010043#include "board-mop500-regulators.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010044
Rabin Vincent39ae7022010-07-26 11:12:15 +010045static struct ab8500_platform_data ab8500_platdata = {
46 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssona1e516e2010-12-10 11:08:48 +010047 .regulator = ab8500_regulators,
48 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Rabin Vincent39ae7022010-07-26 11:12:15 +010049};
50
Linus Walleij29aeb3c2010-09-06 22:15:08 +010051static struct resource ab8500_resources[] = {
52 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +053053 .start = IRQ_DB8500_AB8500,
54 .end = IRQ_DB8500_AB8500,
55 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +010056 }
57};
58
59struct platform_device ab8500_device = {
60 .name = "ab8500-i2c",
61 .id = 0,
62 .dev = {
63 .platform_data = &ab8500_platdata,
64 },
65 .num_resources = 1,
66 .resource = ab8500_resources,
67};
68
Rabin Vincentb8410a12010-08-09 19:18:17 +053069/*
70 * TC35892
71 */
72
Sundar Iyer20406eb2010-12-13 09:33:14 +053073static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +053074{
75 mop500_sdi_tc35892_init();
76}
77
Sundar Iyer20406eb2010-12-13 09:33:14 +053078static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +053079 .gpio_base = MOP500_EGPIO(0),
80 .setup = mop500_tc35892_init,
81};
82
Sundar Iyer20406eb2010-12-13 09:33:14 +053083static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +053084 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +053085 .gpio = &mop500_tc35892_gpio_data,
86 .irq_base = MOP500_EGPIO_IRQ_BASE,
87};
88
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010089static struct lp5521_led_config lp5521_pri_led[] = {
90 [0] = {
91 .chan_nr = 0,
92 .led_current = 0x2f,
93 .max_current = 0x5f,
94 },
95 [1] = {
96 .chan_nr = 1,
97 .led_current = 0x2f,
98 .max_current = 0x5f,
99 },
100 [2] = {
101 .chan_nr = 2,
102 .led_current = 0x2f,
103 .max_current = 0x5f,
104 },
105};
106
107static struct lp5521_platform_data __initdata lp5521_pri_data = {
108 .label = "lp5521_pri",
109 .led_config = &lp5521_pri_led[0],
110 .num_channels = 3,
111 .clock_mode = LP5521_CLOCK_EXT,
112};
113
114static struct lp5521_led_config lp5521_sec_led[] = {
115 [0] = {
116 .chan_nr = 0,
117 .led_current = 0x2f,
118 .max_current = 0x5f,
119 },
120 [1] = {
121 .chan_nr = 1,
122 .led_current = 0x2f,
123 .max_current = 0x5f,
124 },
125 [2] = {
126 .chan_nr = 2,
127 .led_current = 0x2f,
128 .max_current = 0x5f,
129 },
130};
131
132static struct lp5521_platform_data __initdata lp5521_sec_data = {
133 .label = "lp5521_sec",
134 .led_config = &lp5521_sec_led[0],
135 .num_channels = 3,
136 .clock_mode = LP5521_CLOCK_EXT,
137};
138
Rabin Vincentb8410a12010-08-09 19:18:17 +0530139static struct i2c_board_info mop500_i2c0_devices[] = {
140 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530141 I2C_BOARD_INFO("tc3589x", 0x42),
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100142 .irq = NOMADIK_GPIO_TO_IRQ(217),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530143 .platform_data = &mop500_tc35892_data,
144 },
145};
146
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100147static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
148 {
149 /* lp5521 LED driver, 1st device */
150 I2C_BOARD_INFO("lp5521", 0x33),
151 .platform_data = &lp5521_pri_data,
152 },
153 {
154 /* lp5521 LED driver, 2st device */
155 I2C_BOARD_INFO("lp5521", 0x34),
156 .platform_data = &lp5521_sec_data,
157 },
Lee Jonesbb3b2182011-01-13 14:41:22 +0000158 {
159 /* Light sensor Rohm BH1780GLI */
160 I2C_BOARD_INFO("bh1780", 0x29),
161 },
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100162};
163
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100164#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100165static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100166 /* \
167 * slave data setup time, which is \
168 * 250 ns,100ns,10ns which is 14,6,2 \
169 * respectively for a 48 Mhz \
170 * i2c clock \
171 */ \
172 .slsu = _slsu, \
173 /* Tx FIFO threshold */ \
174 .tft = _tft, \
175 /* Rx FIFO threshold */ \
176 .rft = _rft, \
177 /* std. mode operation */ \
178 .clk_freq = clk, \
179 .sm = _sm, \
180}
181
182/*
183 * The board uses 4 i2c controllers, initialize all of
184 * them with slave data setup time of 250 ns,
185 * Tx & Rx FIFO threshold values as 1 and standard
186 * mode of operation
187 */
188U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
189U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
190U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
191U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
192
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530193static void __init mop500_i2c_init(void)
194{
195 db8500_add_i2c0(&u8500_i2c0_data);
196 db8500_add_i2c1(&u8500_i2c1_data);
197 db8500_add_i2c2(&u8500_i2c2_data);
198 db8500_add_i2c3(&u8500_i2c3_data);
199}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100200
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100201static struct gpio_keys_button mop500_gpio_keys[] = {
202 {
203 .desc = "SFH7741 Proximity Sensor",
204 .type = EV_SW,
205 .code = SW_FRONT_PROXIMITY,
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100206 .active_low = 0,
207 .can_disable = 1,
208 }
209};
210
211static struct regulator *prox_regulator;
212static int mop500_prox_activate(struct device *dev);
213static void mop500_prox_deactivate(struct device *dev);
214
215static struct gpio_keys_platform_data mop500_gpio_keys_data = {
216 .buttons = mop500_gpio_keys,
217 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
218 .enable = mop500_prox_activate,
219 .disable = mop500_prox_deactivate,
220};
221
222static struct platform_device mop500_gpio_keys_device = {
223 .name = "gpio-keys",
224 .id = 0,
225 .dev = {
226 .platform_data = &mop500_gpio_keys_data,
227 },
228};
229
230static int mop500_prox_activate(struct device *dev)
231{
232 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
233 "vcc");
234 if (IS_ERR(prox_regulator)) {
235 dev_err(&mop500_gpio_keys_device.dev,
236 "no regulator\n");
237 return PTR_ERR(prox_regulator);
238 }
239 regulator_enable(prox_regulator);
240 return 0;
241}
242
243static void mop500_prox_deactivate(struct device *dev)
244{
245 regulator_disable(prox_regulator);
246 regulator_put(prox_regulator);
247}
248
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100249/* add any platform devices here - TODO */
250static struct platform_device *platform_devs[] __initdata = {
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100251 &mop500_gpio_keys_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100252};
253
Linus Walleij5d7b8462010-10-14 13:57:59 +0200254#ifdef CONFIG_STE_DMA40
255static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
256 .mode = STEDMA40_MODE_LOGICAL,
257 .dir = STEDMA40_PERIPH_TO_MEM,
258 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
259 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
260 .src_info.data_width = STEDMA40_BYTE_WIDTH,
261 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
262};
263
264static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
265 .mode = STEDMA40_MODE_LOGICAL,
266 .dir = STEDMA40_MEM_TO_PERIPH,
267 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
268 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
269 .src_info.data_width = STEDMA40_BYTE_WIDTH,
270 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
271};
272#endif
273
274static struct pl022_ssp_controller ssp0_platform_data = {
275 .bus_id = 0,
276#ifdef CONFIG_STE_DMA40
277 .enable_dma = 1,
278 .dma_filter = stedma40_filter,
279 .dma_rx_param = &ssp0_dma_cfg_rx,
280 .dma_tx_param = &ssp0_dma_cfg_tx,
281#else
282 .enable_dma = 0,
283#endif
284 /* on this platform, gpio 31,142,144,214 &
285 * 224 are connected as chip selects
286 */
287 .num_chipselect = 5,
288};
289
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530290static void __init mop500_spi_init(void)
291{
292 db8500_add_ssp0(&ssp0_platform_data);
293}
294
Linus Walleij5d7b8462010-10-14 13:57:59 +0200295#ifdef CONFIG_STE_DMA40
296static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
297 .mode = STEDMA40_MODE_LOGICAL,
298 .dir = STEDMA40_PERIPH_TO_MEM,
299 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
300 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
301 .src_info.data_width = STEDMA40_BYTE_WIDTH,
302 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
303};
304
305static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
306 .mode = STEDMA40_MODE_LOGICAL,
307 .dir = STEDMA40_MEM_TO_PERIPH,
308 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
309 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
310 .src_info.data_width = STEDMA40_BYTE_WIDTH,
311 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
312};
313
314static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
315 .mode = STEDMA40_MODE_LOGICAL,
316 .dir = STEDMA40_PERIPH_TO_MEM,
317 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
318 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
319 .src_info.data_width = STEDMA40_BYTE_WIDTH,
320 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
321};
322
323static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
324 .mode = STEDMA40_MODE_LOGICAL,
325 .dir = STEDMA40_MEM_TO_PERIPH,
326 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
327 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
328 .src_info.data_width = STEDMA40_BYTE_WIDTH,
329 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
330};
331
332static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
333 .mode = STEDMA40_MODE_LOGICAL,
334 .dir = STEDMA40_PERIPH_TO_MEM,
335 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
336 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
337 .src_info.data_width = STEDMA40_BYTE_WIDTH,
338 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
339};
340
341static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
342 .mode = STEDMA40_MODE_LOGICAL,
343 .dir = STEDMA40_MEM_TO_PERIPH,
344 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
345 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
346 .src_info.data_width = STEDMA40_BYTE_WIDTH,
347 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
348};
349#endif
350
351static struct amba_pl011_data uart0_plat = {
352#ifdef CONFIG_STE_DMA40
353 .dma_filter = stedma40_filter,
354 .dma_rx_param = &uart0_dma_cfg_rx,
355 .dma_tx_param = &uart0_dma_cfg_tx,
356#endif
357};
358
359static struct amba_pl011_data uart1_plat = {
360#ifdef CONFIG_STE_DMA40
361 .dma_filter = stedma40_filter,
362 .dma_rx_param = &uart1_dma_cfg_rx,
363 .dma_tx_param = &uart1_dma_cfg_tx,
364#endif
365};
366
367static struct amba_pl011_data uart2_plat = {
368#ifdef CONFIG_STE_DMA40
369 .dma_filter = stedma40_filter,
370 .dma_rx_param = &uart2_dma_cfg_rx,
371 .dma_tx_param = &uart2_dma_cfg_tx,
372#endif
373};
374
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530375static void __init mop500_uart_init(void)
376{
Linus Walleij5d7b8462010-10-14 13:57:59 +0200377 db8500_add_uart0(&uart0_plat);
378 db8500_add_uart1(&uart1_plat);
379 db8500_add_uart2(&uart2_plat);
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530380}
381
Linus Walleij4b4f7572011-02-15 15:01:35 +0100382static void __init mop500_init_machine(void)
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100383{
Linus Walleij4b4f7572011-02-15 15:01:35 +0100384 /*
385 * The HREFv60 board removed a GPIO expander and routed
386 * all these GPIO pins to the internal GPIO controller
387 * instead.
388 */
389 if (machine_is_hrefv60())
390 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
391 else
392 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
393
Rabin Vincentea05a572010-06-03 07:58:42 +0100394 u8500_init_devices();
395
Rabin Vincentfe052032011-02-11 17:07:21 -0700396 mop500_pins_init();
Rabin Vincentea05a572010-06-03 07:58:42 +0100397
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100398 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
399
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530400 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100401 mop500_sdi_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530402 mop500_spi_init();
403 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100404
Sundar Iyerd5d22812010-12-13 09:33:11 +0530405 platform_device_register(&ab8500_device);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530406
407 i2c_register_board_info(0, mop500_i2c0_devices,
408 ARRAY_SIZE(mop500_i2c0_devices));
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100409 i2c_register_board_info(2, mop500_i2c2_devices,
410 ARRAY_SIZE(mop500_i2c2_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100411}
412
413MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
414 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100415 .boot_params = 0x100,
416 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100417 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100418 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100419 .timer = &ux500_timer,
Linus Walleij4b4f7572011-02-15 15:01:35 +0100420 .init_machine = mop500_init_machine,
421MACHINE_END
422
423MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
424 .boot_params = 0x100,
425 .map_io = u8500_map_io,
426 .init_irq = ux500_init_irq,
427 .timer = &ux500_timer,
428 .init_machine = mop500_init_machine,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100429MACHINE_END