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/regulator/ab8500.h>
24 #include <linux/mfd/tc3589x.h>
25 #include <linux/leds-lp5521.h>
26 #include <linux/input.h>
27 #include <linux/gpio_keys.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
33 #include <plat/ste_dma40.h>
35 #include <mach/hardware.h>
36 #include <mach/setup.h>
37 #include <mach/devices.h>
38 #include <mach/irqs.h>
40 #include "ste-dma40-db8500.h"
41 #include "devices-db8500.h"
42 #include "board-mop500.h"
43 #include "board-mop500-regulators.h"
45 static struct ab8500_platform_data ab8500_platdata = {
46 .irq_base = MOP500_AB8500_IRQ_BASE,
47 .regulator = ab8500_regulators,
48 .num_regulator = ARRAY_SIZE(ab8500_regulators),
51 static struct resource ab8500_resources[] = {
53 .start = IRQ_DB8500_AB8500,
54 .end = IRQ_DB8500_AB8500,
55 .flags = IORESOURCE_IRQ
59 struct platform_device ab8500_device = {
63 .platform_data = &ab8500_platdata,
66 .resource = ab8500_resources,
73 static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
75 mop500_sdi_tc35892_init();
78 static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
79 .gpio_base = MOP500_EGPIO(0),
80 .setup = mop500_tc35892_init,
83 static struct tc3589x_platform_data mop500_tc35892_data = {
84 .block = TC3589x_BLOCK_GPIO,
85 .gpio = &mop500_tc35892_gpio_data,
86 .irq_base = MOP500_EGPIO_IRQ_BASE,
89 static struct lp5521_led_config lp5521_pri_led[] = {
107 static struct lp5521_platform_data __initdata lp5521_pri_data = {
108 .label = "lp5521_pri",
109 .led_config = &lp5521_pri_led[0],
111 .clock_mode = LP5521_CLOCK_EXT,
114 static struct lp5521_led_config lp5521_sec_led[] = {
132 static struct lp5521_platform_data __initdata lp5521_sec_data = {
133 .label = "lp5521_sec",
134 .led_config = &lp5521_sec_led[0],
136 .clock_mode = LP5521_CLOCK_EXT,
139 static struct i2c_board_info mop500_i2c0_devices[] = {
141 I2C_BOARD_INFO("tc3589x", 0x42),
142 .irq = NOMADIK_GPIO_TO_IRQ(217),
143 .platform_data = &mop500_tc35892_data,
147 static struct i2c_board_info __initdata mop500_i2c2_devices[] = {
149 /* lp5521 LED driver, 1st device */
150 I2C_BOARD_INFO("lp5521", 0x33),
151 .platform_data = &lp5521_pri_data,
154 /* lp5521 LED driver, 2st device */
155 I2C_BOARD_INFO("lp5521", 0x34),
156 .platform_data = &lp5521_sec_data,
159 /* Light sensor Rohm BH1780GLI */
160 I2C_BOARD_INFO("bh1780", 0x29),
164 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
165 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
167 * slave data setup time, which is \
168 * 250 ns,100ns,10ns which is 14,6,2 \
169 * respectively for a 48 Mhz \
173 /* Tx FIFO threshold */ \
175 /* Rx FIFO threshold */ \
177 /* std. mode operation */ \
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
188 U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
189 U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
190 U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
191 U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
193 static void __init mop500_i2c_init(void)
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);
201 static struct gpio_keys_button mop500_gpio_keys[] = {
203 .desc = "SFH7741 Proximity Sensor",
205 .code = SW_FRONT_PROXIMITY,
211 static struct regulator *prox_regulator;
212 static int mop500_prox_activate(struct device *dev);
213 static void mop500_prox_deactivate(struct device *dev);
215 static 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,
222 static struct platform_device mop500_gpio_keys_device = {
226 .platform_data = &mop500_gpio_keys_data,
230 static int mop500_prox_activate(struct device *dev)
232 prox_regulator = regulator_get(&mop500_gpio_keys_device.dev,
234 if (IS_ERR(prox_regulator)) {
235 dev_err(&mop500_gpio_keys_device.dev,
237 return PTR_ERR(prox_regulator);
239 regulator_enable(prox_regulator);
243 static void mop500_prox_deactivate(struct device *dev)
245 regulator_disable(prox_regulator);
246 regulator_put(prox_regulator);
249 /* add any platform devices here - TODO */
250 static struct platform_device *platform_devs[] __initdata = {
251 &mop500_gpio_keys_device,
254 #ifdef CONFIG_STE_DMA40
255 static 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,
264 static 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,
274 static struct pl022_ssp_controller ssp0_platform_data = {
276 #ifdef CONFIG_STE_DMA40
278 .dma_filter = stedma40_filter,
279 .dma_rx_param = &ssp0_dma_cfg_rx,
280 .dma_tx_param = &ssp0_dma_cfg_tx,
284 /* on this platform, gpio 31,142,144,214 &
285 * 224 are connected as chip selects
290 static void __init mop500_spi_init(void)
292 db8500_add_ssp0(&ssp0_platform_data);
295 #ifdef CONFIG_STE_DMA40
296 static 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,
305 static 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,
314 static 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,
323 static 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,
332 static 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,
341 static 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,
351 static 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,
359 static 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,
367 static 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,
375 static void __init mop500_uart_init(void)
377 db8500_add_uart0(&uart0_plat);
378 db8500_add_uart1(&uart1_plat);
379 db8500_add_uart2(&uart2_plat);
382 static void __init mop500_init_machine(void)
385 * The HREFv60 board removed a GPIO expander and routed
386 * all these GPIO pins to the internal GPIO controller
389 if (machine_is_hrefv60())
390 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
392 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
394 u8500_init_devices();
398 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
405 platform_device_register(&ab8500_device);
407 i2c_register_board_info(0, mop500_i2c0_devices,
408 ARRAY_SIZE(mop500_i2c0_devices));
409 i2c_register_board_info(2, mop500_i2c2_devices,
410 ARRAY_SIZE(mop500_i2c2_devices));
413 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
414 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
415 .boot_params = 0x100,
416 .map_io = u8500_map_io,
417 .init_irq = ux500_init_irq,
418 /* we re-use nomadik timer here */
419 .timer = &ux500_timer,
420 .init_machine = mop500_init_machine,
423 MACHINE_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,