blob: 8790d984cac81550373c61d46ab9ee0a425c8452 [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
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010031#include <plat/i2c.h>
Linus Walleij5d7b8462010-10-14 13:57:59 +020032#include <plat/ste_dma40.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010033
34#include <mach/hardware.h>
35#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010036#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010037#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010038
Linus Walleij5d7b8462010-10-14 13:57:59 +020039#include "ste-dma40-db8500.h"
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053040#include "devices-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010041#include "board-mop500.h"
Bengt Jonssona1e516e2010-12-10 11:08:48 +010042#include "board-mop500-regulators.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010043
Rabin Vincent39ae7022010-07-26 11:12:15 +010044static struct ab8500_platform_data ab8500_platdata = {
45 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssona1e516e2010-12-10 11:08:48 +010046 .regulator = ab8500_regulators,
47 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Rabin Vincent39ae7022010-07-26 11:12:15 +010048};
49
Linus Walleij29aeb3c2010-09-06 22:15:08 +010050static struct resource ab8500_resources[] = {
51 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +053052 .start = IRQ_DB8500_AB8500,
53 .end = IRQ_DB8500_AB8500,
54 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +010055 }
56};
57
58struct platform_device ab8500_device = {
59 .name = "ab8500-i2c",
60 .id = 0,
61 .dev = {
62 .platform_data = &ab8500_platdata,
63 },
64 .num_resources = 1,
65 .resource = ab8500_resources,
66};
67
Rabin Vincentb8410a12010-08-09 19:18:17 +053068/*
69 * TC35892
70 */
71
Sundar Iyer20406eb2010-12-13 09:33:14 +053072static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +053073{
74 mop500_sdi_tc35892_init();
75}
76
Sundar Iyer20406eb2010-12-13 09:33:14 +053077static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +053078 .gpio_base = MOP500_EGPIO(0),
79 .setup = mop500_tc35892_init,
80};
81
Sundar Iyer20406eb2010-12-13 09:33:14 +053082static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +053083 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +053084 .gpio = &mop500_tc35892_gpio_data,
85 .irq_base = MOP500_EGPIO_IRQ_BASE,
86};
87
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010088static struct lp5521_led_config lp5521_pri_led[] = {
89 [0] = {
90 .chan_nr = 0,
91 .led_current = 0x2f,
92 .max_current = 0x5f,
93 },
94 [1] = {
95 .chan_nr = 1,
96 .led_current = 0x2f,
97 .max_current = 0x5f,
98 },
99 [2] = {
100 .chan_nr = 2,
101 .led_current = 0x2f,
102 .max_current = 0x5f,
103 },
104};
105
106static struct lp5521_platform_data __initdata lp5521_pri_data = {
107 .label = "lp5521_pri",
108 .led_config = &lp5521_pri_led[0],
109 .num_channels = 3,
110 .clock_mode = LP5521_CLOCK_EXT,
111};
112
113static struct lp5521_led_config lp5521_sec_led[] = {
114 [0] = {
115 .chan_nr = 0,
116 .led_current = 0x2f,
117 .max_current = 0x5f,
118 },
119 [1] = {
120 .chan_nr = 1,
121 .led_current = 0x2f,
122 .max_current = 0x5f,
123 },
124 [2] = {
125 .chan_nr = 2,
126 .led_current = 0x2f,
127 .max_current = 0x5f,
128 },
129};
130
131static struct lp5521_platform_data __initdata lp5521_sec_data = {
132 .label = "lp5521_sec",
133 .led_config = &lp5521_sec_led[0],
134 .num_channels = 3,
135 .clock_mode = LP5521_CLOCK_EXT,
136};
137
Rabin Vincentb8410a12010-08-09 19:18:17 +0530138static struct i2c_board_info mop500_i2c0_devices[] = {
139 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530140 I2C_BOARD_INFO("tc3589x", 0x42),
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100141 .irq = NOMADIK_GPIO_TO_IRQ(217),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530142 .platform_data = &mop500_tc35892_data,
143 },
144};
145
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100146static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
147 {
148 /* lp5521 LED driver, 1st device */
149 I2C_BOARD_INFO("lp5521", 0x33),
150 .platform_data = &lp5521_pri_data,
151 },
152 {
153 /* lp5521 LED driver, 2st device */
154 I2C_BOARD_INFO("lp5521", 0x34),
155 .platform_data = &lp5521_sec_data,
156 },
Lee Jonesbb3b2182011-01-13 14:41:22 +0000157 {
158 /* Light sensor Rohm BH1780GLI */
159 I2C_BOARD_INFO("bh1780", 0x29),
160 },
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100161};
162
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100163#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100164static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100165 /* \
166 * slave data setup time, which is \
167 * 250 ns,100ns,10ns which is 14,6,2 \
168 * respectively for a 48 Mhz \
169 * i2c clock \
170 */ \
171 .slsu = _slsu, \
172 /* Tx FIFO threshold */ \
173 .tft = _tft, \
174 /* Rx FIFO threshold */ \
175 .rft = _rft, \
176 /* std. mode operation */ \
177 .clk_freq = clk, \
178 .sm = _sm, \
179}
180
181/*
182 * The board uses 4 i2c controllers, initialize all of
183 * them with slave data setup time of 250 ns,
184 * Tx & Rx FIFO threshold values as 1 and standard
185 * mode of operation
186 */
187U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
188U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
189U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
190U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
191
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530192static void __init mop500_i2c_init(void)
193{
194 db8500_add_i2c0(&u8500_i2c0_data);
195 db8500_add_i2c1(&u8500_i2c1_data);
196 db8500_add_i2c2(&u8500_i2c2_data);
197 db8500_add_i2c3(&u8500_i2c3_data);
198}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100199
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100200static struct gpio_keys_button mop500_gpio_keys[] = {
201 {
202 .desc = "SFH7741 Proximity Sensor",
203 .type = EV_SW,
204 .code = SW_FRONT_PROXIMITY,
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100205 .active_low = 0,
206 .can_disable = 1,
207 }
208};
209
210static struct regulator *prox_regulator;
211static int mop500_prox_activate(struct device *dev);
212static void mop500_prox_deactivate(struct device *dev);
213
214static struct gpio_keys_platform_data mop500_gpio_keys_data = {
215 .buttons = mop500_gpio_keys,
216 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
217 .enable = mop500_prox_activate,
218 .disable = mop500_prox_deactivate,
219};
220
221static struct platform_device mop500_gpio_keys_device = {
222 .name = "gpio-keys",
223 .id = 0,
224 .dev = {
225 .platform_data = &mop500_gpio_keys_data,
226 },
227};
228
229static int mop500_prox_activate(struct device *dev)
230{
231 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
232 "vcc");
233 if (IS_ERR(prox_regulator)) {
234 dev_err(&mop500_gpio_keys_device.dev,
235 "no regulator\n");
236 return PTR_ERR(prox_regulator);
237 }
238 regulator_enable(prox_regulator);
239 return 0;
240}
241
242static void mop500_prox_deactivate(struct device *dev)
243{
244 regulator_disable(prox_regulator);
245 regulator_put(prox_regulator);
246}
247
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100248/* add any platform devices here - TODO */
249static struct platform_device *platform_devs[] __initdata = {
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100250 &mop500_gpio_keys_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100251};
252
Linus Walleij5d7b8462010-10-14 13:57:59 +0200253#ifdef CONFIG_STE_DMA40
254static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
255 .mode = STEDMA40_MODE_LOGICAL,
256 .dir = STEDMA40_PERIPH_TO_MEM,
257 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
258 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
259 .src_info.data_width = STEDMA40_BYTE_WIDTH,
260 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
261};
262
263static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
264 .mode = STEDMA40_MODE_LOGICAL,
265 .dir = STEDMA40_MEM_TO_PERIPH,
266 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
267 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
268 .src_info.data_width = STEDMA40_BYTE_WIDTH,
269 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
270};
271#endif
272
273static struct pl022_ssp_controller ssp0_platform_data = {
274 .bus_id = 0,
275#ifdef CONFIG_STE_DMA40
276 .enable_dma = 1,
277 .dma_filter = stedma40_filter,
278 .dma_rx_param = &ssp0_dma_cfg_rx,
279 .dma_tx_param = &ssp0_dma_cfg_tx,
280#else
281 .enable_dma = 0,
282#endif
283 /* on this platform, gpio 31,142,144,214 &
284 * 224 are connected as chip selects
285 */
286 .num_chipselect = 5,
287};
288
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530289static void __init mop500_spi_init(void)
290{
291 db8500_add_ssp0(&ssp0_platform_data);
292}
293
Linus Walleij5d7b8462010-10-14 13:57:59 +0200294#ifdef CONFIG_STE_DMA40
295static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
296 .mode = STEDMA40_MODE_LOGICAL,
297 .dir = STEDMA40_PERIPH_TO_MEM,
298 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
299 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
300 .src_info.data_width = STEDMA40_BYTE_WIDTH,
301 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
302};
303
304static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
305 .mode = STEDMA40_MODE_LOGICAL,
306 .dir = STEDMA40_MEM_TO_PERIPH,
307 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
308 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
309 .src_info.data_width = STEDMA40_BYTE_WIDTH,
310 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
311};
312
313static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
314 .mode = STEDMA40_MODE_LOGICAL,
315 .dir = STEDMA40_PERIPH_TO_MEM,
316 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
317 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
318 .src_info.data_width = STEDMA40_BYTE_WIDTH,
319 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
320};
321
322static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
323 .mode = STEDMA40_MODE_LOGICAL,
324 .dir = STEDMA40_MEM_TO_PERIPH,
325 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
326 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
327 .src_info.data_width = STEDMA40_BYTE_WIDTH,
328 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
329};
330
331static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
332 .mode = STEDMA40_MODE_LOGICAL,
333 .dir = STEDMA40_PERIPH_TO_MEM,
334 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
335 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
336 .src_info.data_width = STEDMA40_BYTE_WIDTH,
337 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
338};
339
340static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
341 .mode = STEDMA40_MODE_LOGICAL,
342 .dir = STEDMA40_MEM_TO_PERIPH,
343 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
344 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
345 .src_info.data_width = STEDMA40_BYTE_WIDTH,
346 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
347};
348#endif
349
350static struct amba_pl011_data uart0_plat = {
351#ifdef CONFIG_STE_DMA40
352 .dma_filter = stedma40_filter,
353 .dma_rx_param = &uart0_dma_cfg_rx,
354 .dma_tx_param = &uart0_dma_cfg_tx,
355#endif
356};
357
358static struct amba_pl011_data uart1_plat = {
359#ifdef CONFIG_STE_DMA40
360 .dma_filter = stedma40_filter,
361 .dma_rx_param = &uart1_dma_cfg_rx,
362 .dma_tx_param = &uart1_dma_cfg_tx,
363#endif
364};
365
366static struct amba_pl011_data uart2_plat = {
367#ifdef CONFIG_STE_DMA40
368 .dma_filter = stedma40_filter,
369 .dma_rx_param = &uart2_dma_cfg_rx,
370 .dma_tx_param = &uart2_dma_cfg_tx,
371#endif
372};
373
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530374static void __init mop500_uart_init(void)
375{
Linus Walleij5d7b8462010-10-14 13:57:59 +0200376 db8500_add_uart0(&uart0_plat);
377 db8500_add_uart1(&uart1_plat);
378 db8500_add_uart2(&uart2_plat);
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530379}
380
Linus Walleij4b4f7572011-02-15 15:01:35 +0100381static void __init mop500_init_machine(void)
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100382{
Linus Walleij4b4f7572011-02-15 15:01:35 +0100383 /*
384 * The HREFv60 board removed a GPIO expander and routed
385 * all these GPIO pins to the internal GPIO controller
386 * instead.
387 */
388 if (machine_is_hrefv60())
389 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
390 else
391 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
392
Rabin Vincentea05a572010-06-03 07:58:42 +0100393 u8500_init_devices();
394
Rabin Vincentfe052032011-02-11 17:07:21 -0700395 mop500_pins_init();
Rabin Vincentea05a572010-06-03 07:58:42 +0100396
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100397 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
398
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530399 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100400 mop500_sdi_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530401 mop500_spi_init();
402 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100403
Sundar Iyerd5d22812010-12-13 09:33:11 +0530404 platform_device_register(&ab8500_device);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530405
406 i2c_register_board_info(0, mop500_i2c0_devices,
407 ARRAY_SIZE(mop500_i2c0_devices));
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100408 i2c_register_board_info(2, mop500_i2c2_devices,
409 ARRAY_SIZE(mop500_i2c2_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100410}
411
412MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
413 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100414 .boot_params = 0x100,
415 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100416 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100417 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100418 .timer = &ux500_timer,
Linus Walleij4b4f7572011-02-15 15:01:35 +0100419 .init_machine = mop500_init_machine,
420MACHINE_END
421
422MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
423 .boot_params = 0x100,
424 .map_io = u8500_map_io,
425 .init_irq = ux500_init_irq,
426 .timer = &ux500_timer,
427 .init_machine = mop500_init_machine,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100428MACHINE_END