blob: 9aeefc403f3533867a469a2ec1deb590e9f039c1 [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 Vincentea05a572010-06-03 07:58:42 +010037#include "pins-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010038#include "board-mop500.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010039
40static pin_cfg_t mop500_pins[] = {
41 /* SSP0 */
42 GPIO143_SSP0_CLK,
43 GPIO144_SSP0_FRM,
44 GPIO145_SSP0_RXD,
45 GPIO146_SSP0_TXD,
46
47 /* I2C */
48 GPIO147_I2C0_SCL,
49 GPIO148_I2C0_SDA,
50 GPIO16_I2C1_SCL,
51 GPIO17_I2C1_SDA,
52 GPIO10_I2C2_SDA,
53 GPIO11_I2C2_SCL,
54 GPIO229_I2C3_SDA,
55 GPIO230_I2C3_SCL,
Sundar Iyer4c61c842010-09-29 19:43:09 -070056
57 /* SKE keypad */
58 GPIO153_KP_I7,
59 GPIO154_KP_I6,
60 GPIO155_KP_I5,
61 GPIO156_KP_I4,
62 GPIO157_KP_O7,
63 GPIO158_KP_O6,
64 GPIO159_KP_O5,
65 GPIO160_KP_O4,
66 GPIO161_KP_I3,
67 GPIO162_KP_I2,
68 GPIO163_KP_I1,
69 GPIO164_KP_I0,
70 GPIO165_KP_O3,
71 GPIO166_KP_O2,
72 GPIO167_KP_O1,
73 GPIO168_KP_O0,
Rabin Vincentb8410a12010-08-09 19:18:17 +053074
75 GPIO217_GPIO, /* GPIO_EXP_INT */
Rabin Vincentea05a572010-06-03 07:58:42 +010076};
77
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010078static void ab4500_spi_cs_control(u32 command)
79{
80 /* set the FRM signal, which is CS - TODO */
81}
82
83struct pl022_config_chip ab4500_chip_info = {
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010084 .com_mode = INTERRUPT_TRANSFER,
85 .iface = SSP_INTERFACE_MOTOROLA_SPI,
86 /* we can act as master only */
87 .hierarchy = SSP_MASTER,
88 .slave_tx_disable = 0,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010089 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
90 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010091 .cs_control = ab4500_spi_cs_control,
92};
93
Rabin Vincent39ae7022010-07-26 11:12:15 +010094static struct ab8500_platform_data ab8500_platdata = {
95 .irq_base = MOP500_AB8500_IRQ_BASE,
96};
97
Linus Walleij29aeb3c2010-09-06 22:15:08 +010098static struct resource ab8500_resources[] = {
99 [0] = {
100 .start = IRQ_AB8500,
101 .end = IRQ_AB8500,
102 .flags = IORESOURCE_IRQ
103 }
104};
105
106struct platform_device ab8500_device = {
107 .name = "ab8500-i2c",
108 .id = 0,
109 .dev = {
110 .platform_data = &ab8500_platdata,
111 },
112 .num_resources = 1,
113 .resource = ab8500_resources,
114};
115
116static struct spi_board_info ab8500_spi_devices[] = {
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100117 {
Linus Walleij29aeb3c2010-09-06 22:15:08 +0100118 .modalias = "ab8500-spi",
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100119 .controller_data = &ab4500_chip_info,
Rabin Vincent39ae7022010-07-26 11:12:15 +0100120 .platform_data = &ab8500_platdata,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100121 .max_speed_hz = 12000000,
122 .bus_num = 0,
123 .chip_select = 0,
Kevin Wellsbde435a2010-09-16 06:18:50 -0700124 .mode = SPI_MODE_3,
Rabin Vincent60559302010-07-26 11:09:27 +0100125 .irq = IRQ_DB8500_AB8500,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100126 },
127};
128
129static struct pl022_ssp_controller ssp0_platform_data = {
130 .bus_id = 0,
131 /* pl022 not yet supports dma */
132 .enable_dma = 0,
133 /* on this platform, gpio 31,142,144,214 &
134 * 224 are connected as chip selects
135 */
136 .num_chipselect = 5,
137};
138
Rabin Vincentb8410a12010-08-09 19:18:17 +0530139/*
140 * TC35892
141 */
142
143static void mop500_tc35892_init(struct tc35892 *tc35892, unsigned int base)
144{
145 mop500_sdi_tc35892_init();
146}
147
148static struct tc35892_gpio_platform_data mop500_tc35892_gpio_data = {
149 .gpio_base = MOP500_EGPIO(0),
150 .setup = mop500_tc35892_init,
151};
152
153static struct tc35892_platform_data mop500_tc35892_data = {
154 .gpio = &mop500_tc35892_gpio_data,
155 .irq_base = MOP500_EGPIO_IRQ_BASE,
156};
157
158static struct i2c_board_info mop500_i2c0_devices[] = {
159 {
160 I2C_BOARD_INFO("tc35892", 0x42),
161 .irq = NOMADIK_GPIO_TO_IRQ(217),
162 .platform_data = &mop500_tc35892_data,
163 },
164};
165
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100166#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100167static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100168 /* \
169 * slave data setup time, which is \
170 * 250 ns,100ns,10ns which is 14,6,2 \
171 * respectively for a 48 Mhz \
172 * i2c clock \
173 */ \
174 .slsu = _slsu, \
175 /* Tx FIFO threshold */ \
176 .tft = _tft, \
177 /* Rx FIFO threshold */ \
178 .rft = _rft, \
179 /* std. mode operation */ \
180 .clk_freq = clk, \
181 .sm = _sm, \
182}
183
184/*
185 * The board uses 4 i2c controllers, initialize all of
186 * them with slave data setup time of 250 ns,
187 * Tx & Rx FIFO threshold values as 1 and standard
188 * mode of operation
189 */
190U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
191U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
192U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
193U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
194
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100195static struct amba_device *amba_devs[] __initdata = {
Rabin Vincent4b27aa42010-05-03 08:18:38 +0100196 &ux500_uart0_device,
197 &ux500_uart1_device,
198 &ux500_uart2_device,
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +0100199 &u8500_ssp0_device,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100200};
201
Sundar Iyer4c61c842010-09-29 19:43:09 -0700202static const unsigned int ux500_keymap[] = {
203 KEY(2, 5, KEY_END),
204 KEY(4, 1, KEY_POWER),
205 KEY(3, 5, KEY_VOLUMEDOWN),
206 KEY(1, 3, KEY_3),
207 KEY(5, 2, KEY_RIGHT),
208 KEY(5, 0, KEY_9),
209
210 KEY(0, 5, KEY_MENU),
211 KEY(7, 6, KEY_ENTER),
212 KEY(4, 5, KEY_0),
213 KEY(6, 7, KEY_2),
214 KEY(3, 4, KEY_UP),
215 KEY(3, 3, KEY_DOWN),
216
217 KEY(6, 4, KEY_SEND),
218 KEY(6, 2, KEY_BACK),
219 KEY(4, 2, KEY_VOLUMEUP),
220 KEY(5, 5, KEY_1),
221 KEY(4, 3, KEY_LEFT),
222 KEY(3, 2, KEY_7),
223};
224
225static const struct matrix_keymap_data ux500_keymap_data = {
226 .keymap = ux500_keymap,
227 .keymap_size = ARRAY_SIZE(ux500_keymap),
228};
229
230/*
231 * Nomadik SKE keypad
232 */
233#define ROW_PIN_I0 164
234#define ROW_PIN_I1 163
235#define ROW_PIN_I2 162
236#define ROW_PIN_I3 161
237#define ROW_PIN_I4 156
238#define ROW_PIN_I5 155
239#define ROW_PIN_I6 154
240#define ROW_PIN_I7 153
241#define COL_PIN_O0 168
242#define COL_PIN_O1 167
243#define COL_PIN_O2 166
244#define COL_PIN_O3 165
245#define COL_PIN_O4 160
246#define COL_PIN_O5 159
247#define COL_PIN_O6 158
248#define COL_PIN_O7 157
249
250#define SKE_KPD_MAX_ROWS 8
251#define SKE_KPD_MAX_COLS 8
252
253static int ske_kp_rows[] = {
254 ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3,
255 ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7,
256};
257
258/*
259 * ske_set_gpio_row: request and set gpio rows
260 */
261static int ske_set_gpio_row(int gpio)
262{
263 int ret;
264
265 ret = gpio_request(gpio, "ske-kp");
266 if (ret < 0) {
267 pr_err("ske_set_gpio_row: gpio request failed\n");
268 return ret;
269 }
270
271 ret = gpio_direction_output(gpio, 1);
272 if (ret < 0) {
273 pr_err("ske_set_gpio_row: gpio direction failed\n");
274 gpio_free(gpio);
275 }
276
277 return ret;
278}
279
280/*
281 * ske_kp_init - enable the gpio configuration
282 */
283static int ske_kp_init(void)
284{
285 int ret, i;
286
287 for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
288 ret = ske_set_gpio_row(ske_kp_rows[i]);
289 if (ret < 0) {
290 pr_err("ske_kp_init: failed init\n");
291 return ret;
292 }
293 }
294
295 return 0;
296}
297
298static struct ske_keypad_platform_data ske_keypad_board = {
299 .init = ske_kp_init,
300 .keymap_data = &ux500_keymap_data,
301 .no_autorepeat = true,
302 .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */
303 .kcol = SKE_KPD_MAX_COLS,
304 .debounce_ms = 40, /* in millsecs */
305};
306
307
308
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100309/* add any platform devices here - TODO */
310static struct platform_device *platform_devs[] __initdata = {
Rabin Vincentf9faf232010-05-03 08:24:37 +0100311 &u8500_i2c0_device,
312 &ux500_i2c1_device,
313 &ux500_i2c2_device,
314 &ux500_i2c3_device,
Sundar Iyer4c61c842010-09-29 19:43:09 -0700315 &ux500_ske_keypad_device,
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100316};
317
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100318static void __init u8500_init_machine(void)
319{
320 int i;
321
Rabin Vincentea05a572010-06-03 07:58:42 +0100322 u8500_init_devices();
323
324 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
325
Rabin Vincentf9faf232010-05-03 08:24:37 +0100326 u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data;
327 ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
328 ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
329 ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
Sundar Iyer4c61c842010-09-29 19:43:09 -0700330 ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board;
Rabin Vincentf9faf232010-05-03 08:24:37 +0100331
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +0100332 u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
333
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100334 /* Register the active AMBA devices on this board */
335 for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
336 amba_device_register(amba_devs[i], &iomem_resource);
337
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100338 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
339
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100340 mop500_sdi_init();
341
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