blob: 6ac0164db6e883bb51dade1984ba324ed40ed742 [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>
Bibek Basu3ef374a2011-02-15 12:56:16 +053025#include <linux/mfd/ab8500/gpio.h>
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +010026#include <linux/leds-lp5521.h>
Philippe Langlaisa71b8192011-01-14 10:53:59 +010027#include <linux/input.h>
28#include <linux/gpio_keys.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010029
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010030#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010033#include <plat/i2c.h>
Linus Walleij5d7b8462010-10-14 13:57:59 +020034#include <plat/ste_dma40.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010035
36#include <mach/hardware.h>
37#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010038#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010039#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010040
Linus Walleij5d7b8462010-10-14 13:57:59 +020041#include "ste-dma40-db8500.h"
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053042#include "devices-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
Bibek Basu3ef374a2011-02-15 12:56:16 +053046static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
47 .gpio_base = MOP500_AB8500_GPIO(0),
48 .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE,
49 /* config_reg is the initial configuration of ab8500 pins.
50 * The pins can be configured as GPIO or alt functions based
51 * on value present in GpioSel1 to GpioSel6 and AlternatFunction
52 * register. This is the array of 7 configuration settings.
53 * One has to compile time decide these settings. Below is the
54 * explaination of these setting
55 * GpioSel1 = 0x00 => Pins GPIO1 to GPIO8 are not used as GPIO
56 * GpioSel2 = 0x1E => Pins GPIO10 to GPIO13 are configured as GPIO
57 * GpioSel3 = 0x80 => Pin GPIO24 is configured as GPIO
58 * GpioSel4 = 0x01 => Pin GPIo25 is configured as GPIO
59 * GpioSel5 = 0x7A => Pins GPIO34, GPIO36 to GPIO39 are conf as GPIO
60 * GpioSel6 = 0x00 => Pins GPIO41 & GPIo42 are not configured as GPIO
61 * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured
62 * as GPIO then this register selectes the alternate fucntions
63 */
64 .config_reg = {0x00, 0x1E, 0x80, 0x01,
65 0x7A, 0x00, 0x00},
66};
67
Rabin Vincent39ae7022010-07-26 11:12:15 +010068static struct ab8500_platform_data ab8500_platdata = {
69 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssona1e516e2010-12-10 11:08:48 +010070 .regulator = ab8500_regulators,
71 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Bibek Basu3ef374a2011-02-15 12:56:16 +053072 .gpio = &ab8500_gpio_pdata,
Rabin Vincent39ae7022010-07-26 11:12:15 +010073};
74
Linus Walleij29aeb3c2010-09-06 22:15:08 +010075static struct resource ab8500_resources[] = {
76 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +053077 .start = IRQ_DB8500_AB8500,
78 .end = IRQ_DB8500_AB8500,
79 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +010080 }
81};
82
83struct platform_device ab8500_device = {
84 .name = "ab8500-i2c",
85 .id = 0,
86 .dev = {
87 .platform_data = &ab8500_platdata,
88 },
89 .num_resources = 1,
90 .resource = ab8500_resources,
91};
92
Rabin Vincentb8410a12010-08-09 19:18:17 +053093/*
94 * TC35892
95 */
96
Sundar Iyer20406eb2010-12-13 09:33:14 +053097static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +053098{
99 mop500_sdi_tc35892_init();
100}
101
Sundar Iyer20406eb2010-12-13 09:33:14 +0530102static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +0530103 .gpio_base = MOP500_EGPIO(0),
104 .setup = mop500_tc35892_init,
105};
106
Sundar Iyer20406eb2010-12-13 09:33:14 +0530107static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +0530108 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +0530109 .gpio = &mop500_tc35892_gpio_data,
110 .irq_base = MOP500_EGPIO_IRQ_BASE,
111};
112
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100113static struct lp5521_led_config lp5521_pri_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_pri_data = {
132 .label = "lp5521_pri",
133 .led_config = &lp5521_pri_led[0],
134 .num_channels = 3,
135 .clock_mode = LP5521_CLOCK_EXT,
136};
137
138static struct lp5521_led_config lp5521_sec_led[] = {
139 [0] = {
140 .chan_nr = 0,
141 .led_current = 0x2f,
142 .max_current = 0x5f,
143 },
144 [1] = {
145 .chan_nr = 1,
146 .led_current = 0x2f,
147 .max_current = 0x5f,
148 },
149 [2] = {
150 .chan_nr = 2,
151 .led_current = 0x2f,
152 .max_current = 0x5f,
153 },
154};
155
156static struct lp5521_platform_data __initdata lp5521_sec_data = {
157 .label = "lp5521_sec",
158 .led_config = &lp5521_sec_led[0],
159 .num_channels = 3,
160 .clock_mode = LP5521_CLOCK_EXT,
161};
162
Rabin Vincentb8410a12010-08-09 19:18:17 +0530163static struct i2c_board_info mop500_i2c0_devices[] = {
164 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530165 I2C_BOARD_INFO("tc3589x", 0x42),
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100166 .irq = NOMADIK_GPIO_TO_IRQ(217),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530167 .platform_data = &mop500_tc35892_data,
168 },
169};
170
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100171static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
172 {
173 /* lp5521 LED driver, 1st device */
174 I2C_BOARD_INFO("lp5521", 0x33),
175 .platform_data = &lp5521_pri_data,
176 },
177 {
178 /* lp5521 LED driver, 2st device */
179 I2C_BOARD_INFO("lp5521", 0x34),
180 .platform_data = &lp5521_sec_data,
181 },
Lee Jonesbb3b2182011-01-13 14:41:22 +0000182 {
183 /* Light sensor Rohm BH1780GLI */
184 I2C_BOARD_INFO("bh1780", 0x29),
185 },
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100186};
187
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100188#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100189static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100190 /* \
191 * slave data setup time, which is \
192 * 250 ns,100ns,10ns which is 14,6,2 \
193 * respectively for a 48 Mhz \
194 * i2c clock \
195 */ \
196 .slsu = _slsu, \
197 /* Tx FIFO threshold */ \
198 .tft = _tft, \
199 /* Rx FIFO threshold */ \
200 .rft = _rft, \
201 /* std. mode operation */ \
202 .clk_freq = clk, \
203 .sm = _sm, \
204}
205
206/*
207 * The board uses 4 i2c controllers, initialize all of
208 * them with slave data setup time of 250 ns,
209 * Tx & Rx FIFO threshold values as 1 and standard
210 * mode of operation
211 */
212U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
213U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
214U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
215U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
216
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530217static void __init mop500_i2c_init(void)
218{
219 db8500_add_i2c0(&u8500_i2c0_data);
220 db8500_add_i2c1(&u8500_i2c1_data);
221 db8500_add_i2c2(&u8500_i2c2_data);
222 db8500_add_i2c3(&u8500_i2c3_data);
223}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100224
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100225static struct gpio_keys_button mop500_gpio_keys[] = {
226 {
227 .desc = "SFH7741 Proximity Sensor",
228 .type = EV_SW,
229 .code = SW_FRONT_PROXIMITY,
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100230 .active_low = 0,
231 .can_disable = 1,
232 }
233};
234
235static struct regulator *prox_regulator;
236static int mop500_prox_activate(struct device *dev);
237static void mop500_prox_deactivate(struct device *dev);
238
239static struct gpio_keys_platform_data mop500_gpio_keys_data = {
240 .buttons = mop500_gpio_keys,
241 .nbuttons = ARRAY_SIZE(mop500_gpio_keys),
242 .enable = mop500_prox_activate,
243 .disable = mop500_prox_deactivate,
244};
245
246static struct platform_device mop500_gpio_keys_device = {
247 .name = "gpio-keys",
248 .id = 0,
249 .dev = {
250 .platform_data = &mop500_gpio_keys_data,
251 },
252};
253
254static int mop500_prox_activate(struct device *dev)
255{
256 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
257 "vcc");
258 if (IS_ERR(prox_regulator)) {
259 dev_err(&mop500_gpio_keys_device.dev,
260 "no regulator\n");
261 return PTR_ERR(prox_regulator);
262 }
263 regulator_enable(prox_regulator);
264 return 0;
265}
266
267static void mop500_prox_deactivate(struct device *dev)
268{
269 regulator_disable(prox_regulator);
270 regulator_put(prox_regulator);
271}
272
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100273/* add any platform devices here - TODO */
274static struct platform_device *platform_devs[] __initdata = {
Philippe Langlaisa71b8192011-01-14 10:53:59 +0100275 &mop500_gpio_keys_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100276};
277
Linus Walleij5d7b8462010-10-14 13:57:59 +0200278#ifdef CONFIG_STE_DMA40
279static struct stedma40_chan_cfg ssp0_dma_cfg_rx = {
280 .mode = STEDMA40_MODE_LOGICAL,
281 .dir = STEDMA40_PERIPH_TO_MEM,
282 .src_dev_type = DB8500_DMA_DEV8_SSP0_RX,
283 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
284 .src_info.data_width = STEDMA40_BYTE_WIDTH,
285 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
286};
287
288static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
289 .mode = STEDMA40_MODE_LOGICAL,
290 .dir = STEDMA40_MEM_TO_PERIPH,
291 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
292 .dst_dev_type = DB8500_DMA_DEV8_SSP0_TX,
293 .src_info.data_width = STEDMA40_BYTE_WIDTH,
294 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
295};
296#endif
297
298static struct pl022_ssp_controller ssp0_platform_data = {
299 .bus_id = 0,
300#ifdef CONFIG_STE_DMA40
301 .enable_dma = 1,
302 .dma_filter = stedma40_filter,
303 .dma_rx_param = &ssp0_dma_cfg_rx,
304 .dma_tx_param = &ssp0_dma_cfg_tx,
305#else
306 .enable_dma = 0,
307#endif
308 /* on this platform, gpio 31,142,144,214 &
309 * 224 are connected as chip selects
310 */
311 .num_chipselect = 5,
312};
313
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530314static void __init mop500_spi_init(void)
315{
316 db8500_add_ssp0(&ssp0_platform_data);
317}
318
Linus Walleij5d7b8462010-10-14 13:57:59 +0200319#ifdef CONFIG_STE_DMA40
320static struct stedma40_chan_cfg uart0_dma_cfg_rx = {
321 .mode = STEDMA40_MODE_LOGICAL,
322 .dir = STEDMA40_PERIPH_TO_MEM,
323 .src_dev_type = DB8500_DMA_DEV13_UART0_RX,
324 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
325 .src_info.data_width = STEDMA40_BYTE_WIDTH,
326 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
327};
328
329static struct stedma40_chan_cfg uart0_dma_cfg_tx = {
330 .mode = STEDMA40_MODE_LOGICAL,
331 .dir = STEDMA40_MEM_TO_PERIPH,
332 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
333 .dst_dev_type = DB8500_DMA_DEV13_UART0_TX,
334 .src_info.data_width = STEDMA40_BYTE_WIDTH,
335 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
336};
337
338static struct stedma40_chan_cfg uart1_dma_cfg_rx = {
339 .mode = STEDMA40_MODE_LOGICAL,
340 .dir = STEDMA40_PERIPH_TO_MEM,
341 .src_dev_type = DB8500_DMA_DEV12_UART1_RX,
342 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
343 .src_info.data_width = STEDMA40_BYTE_WIDTH,
344 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
345};
346
347static struct stedma40_chan_cfg uart1_dma_cfg_tx = {
348 .mode = STEDMA40_MODE_LOGICAL,
349 .dir = STEDMA40_MEM_TO_PERIPH,
350 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
351 .dst_dev_type = DB8500_DMA_DEV12_UART1_TX,
352 .src_info.data_width = STEDMA40_BYTE_WIDTH,
353 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
354};
355
356static struct stedma40_chan_cfg uart2_dma_cfg_rx = {
357 .mode = STEDMA40_MODE_LOGICAL,
358 .dir = STEDMA40_PERIPH_TO_MEM,
359 .src_dev_type = DB8500_DMA_DEV11_UART2_RX,
360 .dst_dev_type = STEDMA40_DEV_DST_MEMORY,
361 .src_info.data_width = STEDMA40_BYTE_WIDTH,
362 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
363};
364
365static struct stedma40_chan_cfg uart2_dma_cfg_tx = {
366 .mode = STEDMA40_MODE_LOGICAL,
367 .dir = STEDMA40_MEM_TO_PERIPH,
368 .src_dev_type = STEDMA40_DEV_SRC_MEMORY,
369 .dst_dev_type = DB8500_DMA_DEV11_UART2_TX,
370 .src_info.data_width = STEDMA40_BYTE_WIDTH,
371 .dst_info.data_width = STEDMA40_BYTE_WIDTH,
372};
373#endif
374
375static struct amba_pl011_data uart0_plat = {
376#ifdef CONFIG_STE_DMA40
377 .dma_filter = stedma40_filter,
378 .dma_rx_param = &uart0_dma_cfg_rx,
379 .dma_tx_param = &uart0_dma_cfg_tx,
380#endif
381};
382
383static struct amba_pl011_data uart1_plat = {
384#ifdef CONFIG_STE_DMA40
385 .dma_filter = stedma40_filter,
386 .dma_rx_param = &uart1_dma_cfg_rx,
387 .dma_tx_param = &uart1_dma_cfg_tx,
388#endif
389};
390
391static struct amba_pl011_data uart2_plat = {
392#ifdef CONFIG_STE_DMA40
393 .dma_filter = stedma40_filter,
394 .dma_rx_param = &uart2_dma_cfg_rx,
395 .dma_tx_param = &uart2_dma_cfg_tx,
396#endif
397};
398
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530399static void __init mop500_uart_init(void)
400{
Linus Walleij5d7b8462010-10-14 13:57:59 +0200401 db8500_add_uart0(&uart0_plat);
402 db8500_add_uart1(&uart1_plat);
403 db8500_add_uart2(&uart2_plat);
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530404}
405
Linus Walleij4b4f7572011-02-15 15:01:35 +0100406static void __init mop500_init_machine(void)
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100407{
Linus Walleij4b4f7572011-02-15 15:01:35 +0100408 /*
409 * The HREFv60 board removed a GPIO expander and routed
410 * all these GPIO pins to the internal GPIO controller
411 * instead.
412 */
413 if (machine_is_hrefv60())
414 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
415 else
416 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
417
Rabin Vincentea05a572010-06-03 07:58:42 +0100418 u8500_init_devices();
419
Rabin Vincentfe052032011-02-11 17:07:21 -0700420 mop500_pins_init();
Rabin Vincentea05a572010-06-03 07:58:42 +0100421
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100422 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
423
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530424 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100425 mop500_sdi_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530426 mop500_spi_init();
427 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100428
Sundar Iyerd5d22812010-12-13 09:33:11 +0530429 platform_device_register(&ab8500_device);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530430
431 i2c_register_board_info(0, mop500_i2c0_devices,
432 ARRAY_SIZE(mop500_i2c0_devices));
Philippe Langlaisdd7b2a02011-01-12 11:26:20 +0100433 i2c_register_board_info(2, mop500_i2c2_devices,
434 ARRAY_SIZE(mop500_i2c2_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100435}
436
437MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
438 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100439 .boot_params = 0x100,
440 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100441 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100442 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100443 .timer = &ux500_timer,
Linus Walleij4b4f7572011-02-15 15:01:35 +0100444 .init_machine = mop500_init_machine,
445MACHINE_END
446
447MACHINE_START(HREFV60, "ST-Ericsson U8500 Platform HREFv60+")
448 .boot_params = 0x100,
449 .map_io = u8500_map_io,
450 .init_irq = ux500_init_irq,
451 .timer = &ux500_timer,
452 .init_machine = mop500_init_machine,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100453MACHINE_END