blob: 287956cebe8bc65cded3b260685c557c5c62a870 [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>
20#include <linux/spi/spi.h>
Rabin Vincent39ae7022010-07-26 11:12:15 +010021#include <linux/mfd/ab8500.h>
Rabin Vincentb8410a12010-08-09 19:18:17 +053022#include <linux/mfd/tc35892.h>
Sundar Iyer4c61c842010-09-29 19:43:09 -070023#include <linux/input/matrix_keypad.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010024
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010025#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27
Rabin Vincentea05a572010-06-03 07:58:42 +010028#include <plat/pincfg.h>
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010029#include <plat/i2c.h>
Sundar Iyer4c61c842010-09-29 19:43:09 -070030#include <plat/ske.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010031
32#include <mach/hardware.h>
33#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010034#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010035#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010036
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053037#include "devices-db8500.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010038#include "pins-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010039#include "board-mop500.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010040
41static pin_cfg_t mop500_pins[] = {
42 /* SSP0 */
43 GPIO143_SSP0_CLK,
44 GPIO144_SSP0_FRM,
45 GPIO145_SSP0_RXD,
46 GPIO146_SSP0_TXD,
47
48 /* I2C */
49 GPIO147_I2C0_SCL,
50 GPIO148_I2C0_SDA,
51 GPIO16_I2C1_SCL,
52 GPIO17_I2C1_SDA,
53 GPIO10_I2C2_SDA,
54 GPIO11_I2C2_SCL,
55 GPIO229_I2C3_SDA,
56 GPIO230_I2C3_SCL,
Sundar Iyer4c61c842010-09-29 19:43:09 -070057
58 /* SKE keypad */
59 GPIO153_KP_I7,
60 GPIO154_KP_I6,
61 GPIO155_KP_I5,
62 GPIO156_KP_I4,
63 GPIO157_KP_O7,
64 GPIO158_KP_O6,
65 GPIO159_KP_O5,
66 GPIO160_KP_O4,
67 GPIO161_KP_I3,
68 GPIO162_KP_I2,
69 GPIO163_KP_I1,
70 GPIO164_KP_I0,
71 GPIO165_KP_O3,
72 GPIO166_KP_O2,
73 GPIO167_KP_O1,
74 GPIO168_KP_O0,
Rabin Vincentb8410a12010-08-09 19:18:17 +053075
76 GPIO217_GPIO, /* GPIO_EXP_INT */
Rabin Vincentea05a572010-06-03 07:58:42 +010077};
78
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010079static void ab4500_spi_cs_control(u32 command)
80{
81 /* set the FRM signal, which is CS - TODO */
82}
83
84struct pl022_config_chip ab4500_chip_info = {
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010085 .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,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010090 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
91 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010092 .cs_control = ab4500_spi_cs_control,
93};
94
Rabin Vincent39ae7022010-07-26 11:12:15 +010095static struct ab8500_platform_data ab8500_platdata = {
96 .irq_base = MOP500_AB8500_IRQ_BASE,
97};
98
Linus Walleij29aeb3c2010-09-06 22:15:08 +010099static struct resource ab8500_resources[] = {
100 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +0530101 .start = IRQ_DB8500_AB8500,
102 .end = IRQ_DB8500_AB8500,
103 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100104 }
105};
106
107struct platform_device ab8500_device = {
108 .name = "ab8500-i2c",
109 .id = 0,
110 .dev = {
111 .platform_data = &ab8500_platdata,
112 },
113 .num_resources = 1,
114 .resource = ab8500_resources,
115};
116
117static struct spi_board_info ab8500_spi_devices[] = {
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100118 {
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100119 .modalias = "ab8500-spi",
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100120 .controller_data = &ab4500_chip_info,
Rabin Vincent39ae7022010-07-26 11:12:15 +0100121 .platform_data = &ab8500_platdata,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100122 .max_speed_hz = 12000000,
123 .bus_num = 0,
124 .chip_select = 0,
Kevin Wellsbde435a2010-09-16 06:18:50 -0700125 .mode = SPI_MODE_3,
Rabin Vincent60559302010-07-26 11:09:27 +0100126 .irq = IRQ_DB8500_AB8500,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100127 },
128};
129
130static struct pl022_ssp_controller ssp0_platform_data = {
131 .bus_id = 0,
132 /* pl022 not yet supports dma */
133 .enable_dma = 0,
134 /* on this platform, gpio 31,142,144,214 &
135 * 224 are connected as chip selects
136 */
137 .num_chipselect = 5,
138};
139
Rabin Vincentb8410a12010-08-09 19:18:17 +0530140/*
141 * TC35892
142 */
143
144static void mop500_tc35892_init(struct tc35892 *tc35892, unsigned int base)
145{
146 mop500_sdi_tc35892_init();
147}
148
149static struct tc35892_gpio_platform_data mop500_tc35892_gpio_data = {
150 .gpio_base = MOP500_EGPIO(0),
151 .setup = mop500_tc35892_init,
152};
153
154static struct tc35892_platform_data mop500_tc35892_data = {
155 .gpio = &mop500_tc35892_gpio_data,
156 .irq_base = MOP500_EGPIO_IRQ_BASE,
157};
158
159static struct i2c_board_info mop500_i2c0_devices[] = {
160 {
161 I2C_BOARD_INFO("tc35892", 0x42),
162 .irq = NOMADIK_GPIO_TO_IRQ(217),
163 .platform_data = &mop500_tc35892_data,
164 },
165};
166
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100167#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100168static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100169 /* \
170 * slave data setup time, which is \
171 * 250 ns,100ns,10ns which is 14,6,2 \
172 * respectively for a 48 Mhz \
173 * i2c clock \
174 */ \
175 .slsu = _slsu, \
176 /* Tx FIFO threshold */ \
177 .tft = _tft, \
178 /* Rx FIFO threshold */ \
179 .rft = _rft, \
180 /* std. mode operation */ \
181 .clk_freq = clk, \
182 .sm = _sm, \
183}
184
185/*
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
189 * mode of operation
190 */
191U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
192U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
193U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
194U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
195
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530196static void __init mop500_i2c_init(void)
197{
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);
202}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100203
Sundar Iyer4c61c842010-09-29 19:43:09 -0700204static const unsigned int ux500_keymap[] = {
205 KEY(2, 5, KEY_END),
206 KEY(4, 1, KEY_POWER),
207 KEY(3, 5, KEY_VOLUMEDOWN),
208 KEY(1, 3, KEY_3),
209 KEY(5, 2, KEY_RIGHT),
210 KEY(5, 0, KEY_9),
211
212 KEY(0, 5, KEY_MENU),
213 KEY(7, 6, KEY_ENTER),
214 KEY(4, 5, KEY_0),
215 KEY(6, 7, KEY_2),
216 KEY(3, 4, KEY_UP),
217 KEY(3, 3, KEY_DOWN),
218
219 KEY(6, 4, KEY_SEND),
220 KEY(6, 2, KEY_BACK),
221 KEY(4, 2, KEY_VOLUMEUP),
222 KEY(5, 5, KEY_1),
223 KEY(4, 3, KEY_LEFT),
224 KEY(3, 2, KEY_7),
225};
226
227static const struct matrix_keymap_data ux500_keymap_data = {
228 .keymap = ux500_keymap,
229 .keymap_size = ARRAY_SIZE(ux500_keymap),
230};
231
232/*
233 * Nomadik SKE keypad
234 */
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
251
252#define SKE_KPD_MAX_ROWS 8
253#define SKE_KPD_MAX_COLS 8
254
255static 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,
258};
259
260/*
261 * ske_set_gpio_row: request and set gpio rows
262 */
263static int ske_set_gpio_row(int gpio)
264{
265 int ret;
266
267 ret = gpio_request(gpio, "ske-kp");
268 if (ret < 0) {
269 pr_err("ske_set_gpio_row: gpio request failed\n");
270 return ret;
271 }
272
273 ret = gpio_direction_output(gpio, 1);
274 if (ret < 0) {
275 pr_err("ske_set_gpio_row: gpio direction failed\n");
276 gpio_free(gpio);
277 }
278
279 return ret;
280}
281
282/*
283 * ske_kp_init - enable the gpio configuration
284 */
285static int ske_kp_init(void)
286{
287 int ret, i;
288
289 for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
290 ret = ske_set_gpio_row(ske_kp_rows[i]);
291 if (ret < 0) {
292 pr_err("ske_kp_init: failed init\n");
293 return ret;
294 }
295 }
296
297 return 0;
298}
299
300static struct ske_keypad_platform_data ske_keypad_board = {
301 .init = ske_kp_init,
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 */
307};
308
309
310
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100311/* add any platform devices here - TODO */
312static struct platform_device *platform_devs[] __initdata = {
Sundar Iyer4c61c842010-09-29 19:43:09 -0700313 &ux500_ske_keypad_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100314};
315
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530316static void __init mop500_spi_init(void)
317{
318 db8500_add_ssp0(&ssp0_platform_data);
319}
320
321static void __init mop500_uart_init(void)
322{
323 db8500_add_uart0();
324 db8500_add_uart1();
325 db8500_add_uart2();
326}
327
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100328static void __init u8500_init_machine(void)
329{
Rabin Vincentea05a572010-06-03 07:58:42 +0100330 u8500_init_devices();
331
332 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
333
Sundar Iyer4c61c842010-09-29 19:43:09 -0700334 ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board;
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100335 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
336
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530337 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100338 mop500_sdi_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530339 mop500_spi_init();
340 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100341
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100342 /* 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);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530348
349 i2c_register_board_info(0, mop500_i2c0_devices,
350 ARRAY_SIZE(mop500_i2c0_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100351}
352
353MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
354 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100355 .boot_params = 0x100,
356 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100357 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100358 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100359 .timer = &ux500_timer,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100360 .init_machine = u8500_init_machine,
361MACHINE_END