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/spi/spi.h>
21 #include <linux/mfd/ab8500.h>
22 #include <linux/mfd/tc35892.h>
23 #include <linux/input/matrix_keypad.h>
25 #include <asm/mach-types.h>
26 #include <asm/mach/arch.h>
28 #include <plat/pincfg.h>
32 #include <mach/hardware.h>
33 #include <mach/setup.h>
34 #include <mach/devices.h>
35 #include <mach/irqs.h>
37 #include "devices-db8500.h"
38 #include "pins-db8500.h"
39 #include "board-mop500.h"
41 static pin_cfg_t mop500_pins
[] = {
76 GPIO217_GPIO
, /* GPIO_EXP_INT */
79 static void ab4500_spi_cs_control(u32 command
)
81 /* set the FRM signal, which is CS - TODO */
84 struct pl022_config_chip ab4500_chip_info
= {
85 .com_mode
= INTERRUPT_TRANSFER
,
86 .iface
= SSP_INTERFACE_MOTOROLA_SPI
,
87 /* we can act as master only */
88 .hierarchy
= SSP_MASTER
,
89 .slave_tx_disable
= 0,
90 .rx_lev_trig
= SSP_RX_1_OR_MORE_ELEM
,
91 .tx_lev_trig
= SSP_TX_1_OR_MORE_EMPTY_LOC
,
92 .cs_control
= ab4500_spi_cs_control
,
95 static struct ab8500_platform_data ab8500_platdata
= {
96 .irq_base
= MOP500_AB8500_IRQ_BASE
,
99 static struct resource ab8500_resources
[] = {
103 .flags
= IORESOURCE_IRQ
107 struct platform_device ab8500_device
= {
108 .name
= "ab8500-i2c",
111 .platform_data
= &ab8500_platdata
,
114 .resource
= ab8500_resources
,
117 static struct spi_board_info ab8500_spi_devices
[] = {
119 .modalias
= "ab8500-spi",
120 .controller_data
= &ab4500_chip_info
,
121 .platform_data
= &ab8500_platdata
,
122 .max_speed_hz
= 12000000,
126 .irq
= IRQ_DB8500_AB8500
,
130 static struct pl022_ssp_controller ssp0_platform_data
= {
132 /* pl022 not yet supports dma */
134 /* on this platform, gpio 31,142,144,214 &
135 * 224 are connected as chip selects
144 static void mop500_tc35892_init(struct tc35892
*tc35892
, unsigned int base
)
146 mop500_sdi_tc35892_init();
149 static struct tc35892_gpio_platform_data mop500_tc35892_gpio_data
= {
150 .gpio_base
= MOP500_EGPIO(0),
151 .setup
= mop500_tc35892_init
,
154 static struct tc35892_platform_data mop500_tc35892_data
= {
155 .gpio
= &mop500_tc35892_gpio_data
,
156 .irq_base
= MOP500_EGPIO_IRQ_BASE
,
159 static struct i2c_board_info mop500_i2c0_devices
[] = {
161 I2C_BOARD_INFO("tc35892", 0x42),
162 .irq
= NOMADIK_GPIO_TO_IRQ(217),
163 .platform_data
= &mop500_tc35892_data
,
167 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
168 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
170 * slave data setup time, which is \
171 * 250 ns,100ns,10ns which is 14,6,2 \
172 * respectively for a 48 Mhz \
176 /* Tx FIFO threshold */ \
178 /* Rx FIFO threshold */ \
180 /* std. mode operation */ \
186 * The board uses 4 i2c controllers, initialize all of
187 * them with slave data setup time of 250 ns,
188 * Tx & Rx FIFO threshold values as 1 and standard
191 U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD
);
192 U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD
);
193 U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD
);
194 U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD
);
196 static void __init
mop500_i2c_init(void)
198 db8500_add_i2c0(&u8500_i2c0_data
);
199 db8500_add_i2c1(&u8500_i2c1_data
);
200 db8500_add_i2c2(&u8500_i2c2_data
);
201 db8500_add_i2c3(&u8500_i2c3_data
);
204 static const unsigned int ux500_keymap
[] = {
206 KEY(4, 1, KEY_POWER
),
207 KEY(3, 5, KEY_VOLUMEDOWN
),
209 KEY(5, 2, KEY_RIGHT
),
213 KEY(7, 6, KEY_ENTER
),
221 KEY(4, 2, KEY_VOLUMEUP
),
227 static const struct matrix_keymap_data ux500_keymap_data
= {
228 .keymap
= ux500_keymap
,
229 .keymap_size
= ARRAY_SIZE(ux500_keymap
),
235 #define ROW_PIN_I0 164
236 #define ROW_PIN_I1 163
237 #define ROW_PIN_I2 162
238 #define ROW_PIN_I3 161
239 #define ROW_PIN_I4 156
240 #define ROW_PIN_I5 155
241 #define ROW_PIN_I6 154
242 #define ROW_PIN_I7 153
243 #define COL_PIN_O0 168
244 #define COL_PIN_O1 167
245 #define COL_PIN_O2 166
246 #define COL_PIN_O3 165
247 #define COL_PIN_O4 160
248 #define COL_PIN_O5 159
249 #define COL_PIN_O6 158
250 #define COL_PIN_O7 157
252 #define SKE_KPD_MAX_ROWS 8
253 #define SKE_KPD_MAX_COLS 8
255 static int ske_kp_rows
[] = {
256 ROW_PIN_I0
, ROW_PIN_I1
, ROW_PIN_I2
, ROW_PIN_I3
,
257 ROW_PIN_I4
, ROW_PIN_I5
, ROW_PIN_I6
, ROW_PIN_I7
,
261 * ske_set_gpio_row: request and set gpio rows
263 static int ske_set_gpio_row(int gpio
)
267 ret
= gpio_request(gpio
, "ske-kp");
269 pr_err("ske_set_gpio_row: gpio request failed\n");
273 ret
= gpio_direction_output(gpio
, 1);
275 pr_err("ske_set_gpio_row: gpio direction failed\n");
283 * ske_kp_init - enable the gpio configuration
285 static int ske_kp_init(void)
289 for (i
= 0; i
< SKE_KPD_MAX_ROWS
; i
++) {
290 ret
= ske_set_gpio_row(ske_kp_rows
[i
]);
292 pr_err("ske_kp_init: failed init\n");
300 static struct ske_keypad_platform_data ske_keypad_board
= {
302 .keymap_data
= &ux500_keymap_data
,
303 .no_autorepeat
= true,
304 .krow
= SKE_KPD_MAX_ROWS
, /* 8x8 matrix */
305 .kcol
= SKE_KPD_MAX_COLS
,
306 .debounce_ms
= 40, /* in millsecs */
311 /* add any platform devices here - TODO */
312 static struct platform_device
*platform_devs
[] __initdata
= {
313 &ux500_ske_keypad_device
,
316 static void __init
mop500_spi_init(void)
318 db8500_add_ssp0(&ssp0_platform_data
);
321 static void __init
mop500_uart_init(void)
328 static void __init
u8500_init_machine(void)
330 u8500_init_devices();
332 nmk_config_pins(mop500_pins
, ARRAY_SIZE(mop500_pins
));
334 ux500_ske_keypad_device
.dev
.platform_data
= &ske_keypad_board
;
335 platform_add_devices(platform_devs
, ARRAY_SIZE(platform_devs
));
342 /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */
343 if (cpu_is_u8500ed() || cpu_is_u8500v10())
344 spi_register_board_info(ab8500_spi_devices
,
345 ARRAY_SIZE(ab8500_spi_devices
));
346 else /* If HW is v.1.1 or later use I2C to access AB8500 */
347 platform_device_register(&ab8500_device
);
349 i2c_register_board_info(0, mop500_i2c0_devices
,
350 ARRAY_SIZE(mop500_i2c0_devices
));
353 MACHINE_START(U8500
, "ST-Ericsson MOP500 platform")
354 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
355 .boot_params
= 0x100,
356 .map_io
= u8500_map_io
,
357 .init_irq
= ux500_init_irq
,
358 /* we re-use nomadik timer here */
359 .timer
= &ux500_timer
,
360 .init_machine
= u8500_init_machine
,