2 * Copyright (C) 2008-2009 ST-Ericsson
4 * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
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.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/platform_device.h>
16 #include <linux/i2c.h>
17 #include <linux/gpio.h>
18 #include <linux/amba/bus.h>
19 #include <linux/amba/pl022.h>
20 #include <linux/amba/serial.h>
21 #include <linux/spi/spi.h>
22 #include <linux/mfd/ab8500.h>
23 #include <linux/mfd/tc3589x.h>
24 #include <linux/leds-lp5521.h>
25 #include <linux/input.h>
26 #include <linux/gpio_keys.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
32 #include <plat/ste_dma40.h>
34 #include <mach/hardware.h>
35 #include <mach/setup.h>
36 #include <mach/devices.h>
37 #include <mach/irqs.h>
39 #include "ste-dma40-db8500.h"
40 #include "devices-db8500.h"
41 #include "board-mop500.h"
42 #include "board-mop500-regulators.h"
44 static struct ab8500_platform_data ab8500_platdata = {
45 .irq_base = MOP500_AB8500_IRQ_BASE,
46 .regulator = ab8500_regulators,
47 .num_regulator = ARRAY_SIZE(ab8500_regulators),
50 static struct resource ab8500_resources[] = {
52 .start = IRQ_DB8500_AB8500,
53 .end = IRQ_DB8500_AB8500,
54 .flags = IORESOURCE_IRQ
58 struct platform_device ab8500_device = {
62 .platform_data = &ab8500_platdata,
65 .resource = ab8500_resources,
72 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
74 mop500_sdi_tc35892_init();
77 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
78 .gpio_base = MOP500_EGPIO(0),
79 .setup = mop500_tc35892_init,
82 static struct tc3589x_platform_data mop500_tc35892_data = {
83 .block = TC3589x_BLOCK_GPIO,
84 .gpio = &mop500_tc35892_gpio_data,
85 .irq_base = MOP500_EGPIO_IRQ_BASE,
88 static struct lp5521_led_config lp5521_pri_led[] = {
106 static struct lp5521_platform_data __initdata lp5521_pri_data = {
107 .label = "lp5521_pri",
108 .led_config = &lp5521_pri_led[0],
110 .clock_mode = LP5521_CLOCK_EXT,
113 static struct lp5521_led_config lp5521_sec_led[] = {
131 static struct lp5521_platform_data __initdata lp5521_sec_data = {
132 .label = "lp5521_sec",
133 .led_config = &lp5521_sec_led[0],
135 .clock_mode = LP5521_CLOCK_EXT,
138 static struct i2c_board_info mop500_i2c0_devices[] = {
140 I2C_BOARD_INFO("tc3589x", 0x42),
141 .irq = NOMADIK_GPIO_TO_IRQ(217),
142 .platform_data = &mop500_tc35892_data,
146 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
148 /* lp5521 LED driver, 1st device */
149 I2C_BOARD_INFO("lp5521", 0x33),
150 .platform_data = &lp5521_pri_data,
153 /* lp5521 LED driver, 2st device */
154 I2C_BOARD_INFO("lp5521", 0x34),
155 .platform_data = &lp5521_sec_data,
158 /* Light sensor Rohm BH1780GLI */
159 I2C_BOARD_INFO("bh1780", 0x29),
163 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
164 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
166 * slave data setup time, which is \
167 * 250 ns,100ns,10ns which is 14,6,2 \
168 * respectively for a 48 Mhz \
172 /* Tx FIFO threshold */ \
174 /* Rx FIFO threshold */ \
176 /* std. mode operation */ \
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
187 U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
188 U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
189 U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
190 U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
192 static void __init mop500_i2c_init(void)
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);
200 static struct gpio_keys_button mop500_gpio_keys[] = {
202 .desc = "SFH7741 Proximity Sensor",
204 .code = SW_FRONT_PROXIMITY,
210 static struct regulator *prox_regulator;
211 static int mop500_prox_activate(struct device *dev);
212 static void mop500_prox_deactivate(struct device *dev);
214 static 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,
221 static struct platform_device mop500_gpio_keys_device = {
225 .platform_data = &mop500_gpio_keys_data,
229 static int mop500_prox_activate(struct device *dev)
231 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
233 if (IS_ERR(prox_regulator)) {
234 dev_err(&mop500_gpio_keys_device.dev,
236 return PTR_ERR(prox_regulator);
238 regulator_enable(prox_regulator);
242 static void mop500_prox_deactivate(struct device *dev)
244 regulator_disable(prox_regulator);
245 regulator_put(prox_regulator);
248 /* add any platform devices here - TODO */
249 static struct platform_device *platform_devs[] __initdata = {
250 &mop500_gpio_keys_device,
253 #ifdef CONFIG_STE_DMA40
254 static 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,
263 static 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,
273 static struct pl022_ssp_controller ssp0_platform_data = {
275 #ifdef CONFIG_STE_DMA40
277 .dma_filter = stedma40_filter,
278 .dma_rx_param = &ssp0_dma_cfg_rx,
279 .dma_tx_param = &ssp0_dma_cfg_tx,
283 /* on this platform, gpio 31,142,144,214 &
284 * 224 are connected as chip selects
289 static void __init mop500_spi_init(void)
291 db8500_add_ssp0(&ssp0_platform_data);
294 #ifdef CONFIG_STE_DMA40
295 static 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,
304 static 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,
313 static 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,
322 static 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,
331 static 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,
340 static 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,
350 static 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,
358 static 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,
366 static 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,
374 static void __init mop500_uart_init(void)
376 db8500_add_uart0(&uart0_plat);
377 db8500_add_uart1(&uart1_plat);
378 db8500_add_uart2(&uart2_plat);
381 static void __init mop500_init_machine(void)
384 * The HREFv60 board removed a GPIO expander and routed
385 * all these GPIO pins to the internal GPIO controller
388 if (machine_is_hrefv60())
389 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
391 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
393 u8500_init_devices();
397 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
404 platform_device_register(&ab8500_device);
406 i2c_register_board_info(0, mop500_i2c0_devices,
407 ARRAY_SIZE(mop500_i2c0_devices));
408 i2c_register_board_info(2, mop500_i2c2_devices,
409 ARRAY_SIZE(mop500_i2c2_devices));
412 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
413 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
414 .boot_params = 0x100,
415 .map_io = u8500_map_io,
416 .init_irq = ux500_init_irq,
417 /* we re-use nomadik timer here */
418 .timer = &ux500_timer,
419 .init_machine = mop500_init_machine,
422 MACHINE_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,