]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - arch/arm/mach-ux500/board-mop500.c
Linux 2.6.37-rc4
[mirror_ubuntu-eoan-kernel.git] / arch / arm / mach-ux500 / board-mop500.c
CommitLineData
aa44ef4d
SK
1/*
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>
ea05a57f 16#include <linux/gpio.h>
aa44ef4d
SK
17#include <linux/amba/bus.h>
18#include <linux/amba/pl022.h>
19#include <linux/spi/spi.h>
39ae702c 20#include <linux/mfd/ab8500.h>
4c61c845 21#include <linux/input/matrix_keypad.h>
aa44ef4d 22
aa44ef4d
SK
23#include <asm/mach-types.h>
24#include <asm/mach/arch.h>
25
ea05a57f 26#include <plat/pincfg.h>
d48a41c1 27#include <plat/i2c.h>
4c61c845 28#include <plat/ske.h>
aa44ef4d
SK
29
30#include <mach/hardware.h>
31#include <mach/setup.h>
9e4e7fe1 32#include <mach/devices.h>
29aeb3cf 33#include <mach/irqs.h>
aa44ef4d 34
ea05a57f 35#include "pins-db8500.h"
008f8a2f 36#include "board-mop500.h"
ea05a57f
RV
37
38static pin_cfg_t mop500_pins[] = {
39 /* SSP0 */
40 GPIO143_SSP0_CLK,
41 GPIO144_SSP0_FRM,
42 GPIO145_SSP0_RXD,
43 GPIO146_SSP0_TXD,
44
45 /* I2C */
46 GPIO147_I2C0_SCL,
47 GPIO148_I2C0_SDA,
48 GPIO16_I2C1_SCL,
49 GPIO17_I2C1_SDA,
50 GPIO10_I2C2_SDA,
51 GPIO11_I2C2_SCL,
52 GPIO229_I2C3_SDA,
53 GPIO230_I2C3_SCL,
4c61c845
SI
54
55 /* SKE keypad */
56 GPIO153_KP_I7,
57 GPIO154_KP_I6,
58 GPIO155_KP_I5,
59 GPIO156_KP_I4,
60 GPIO157_KP_O7,
61 GPIO158_KP_O6,
62 GPIO159_KP_O5,
63 GPIO160_KP_O4,
64 GPIO161_KP_I3,
65 GPIO162_KP_I2,
66 GPIO163_KP_I1,
67 GPIO164_KP_I0,
68 GPIO165_KP_O3,
69 GPIO166_KP_O2,
70 GPIO167_KP_O1,
71 GPIO168_KP_O0,
ea05a57f
RV
72};
73
aa44ef4d
SK
74static void ab4500_spi_cs_control(u32 command)
75{
76 /* set the FRM signal, which is CS - TODO */
77}
78
79struct pl022_config_chip ab4500_chip_info = {
aa44ef4d
SK
80 .com_mode = INTERRUPT_TRANSFER,
81 .iface = SSP_INTERFACE_MOTOROLA_SPI,
82 /* we can act as master only */
83 .hierarchy = SSP_MASTER,
84 .slave_tx_disable = 0,
aa44ef4d
SK
85 .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
86 .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
aa44ef4d
SK
87 .cs_control = ab4500_spi_cs_control,
88};
89
39ae702c
RV
90static struct ab8500_platform_data ab8500_platdata = {
91 .irq_base = MOP500_AB8500_IRQ_BASE,
92};
93
29aeb3cf
LW
94static struct resource ab8500_resources[] = {
95 [0] = {
96 .start = IRQ_AB8500,
97 .end = IRQ_AB8500,
98 .flags = IORESOURCE_IRQ
99 }
100};
101
102struct platform_device ab8500_device = {
103 .name = "ab8500-i2c",
104 .id = 0,
105 .dev = {
106 .platform_data = &ab8500_platdata,
107 },
108 .num_resources = 1,
109 .resource = ab8500_resources,
110};
111
112static struct spi_board_info ab8500_spi_devices[] = {
aa44ef4d 113 {
29aeb3cf 114 .modalias = "ab8500-spi",
aa44ef4d 115 .controller_data = &ab4500_chip_info,
39ae702c 116 .platform_data = &ab8500_platdata,
aa44ef4d
SK
117 .max_speed_hz = 12000000,
118 .bus_num = 0,
119 .chip_select = 0,
bde435a9 120 .mode = SPI_MODE_3,
6055930c 121 .irq = IRQ_DB8500_AB8500,
aa44ef4d
SK
122 },
123};
124
125static struct pl022_ssp_controller ssp0_platform_data = {
126 .bus_id = 0,
127 /* pl022 not yet supports dma */
128 .enable_dma = 0,
129 /* on this platform, gpio 31,142,144,214 &
130 * 224 are connected as chip selects
131 */
132 .num_chipselect = 5,
133};
134
d48a41c1 135#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
f9faf237 136static struct nmk_i2c_controller u8500_i2c##id##_data = { \
d48a41c1
SK
137 /* \
138 * slave data setup time, which is \
139 * 250 ns,100ns,10ns which is 14,6,2 \
140 * respectively for a 48 Mhz \
141 * i2c clock \
142 */ \
143 .slsu = _slsu, \
144 /* Tx FIFO threshold */ \
145 .tft = _tft, \
146 /* Rx FIFO threshold */ \
147 .rft = _rft, \
148 /* std. mode operation */ \
149 .clk_freq = clk, \
150 .sm = _sm, \
151}
152
153/*
154 * The board uses 4 i2c controllers, initialize all of
155 * them with slave data setup time of 250 ns,
156 * Tx & Rx FIFO threshold values as 1 and standard
157 * mode of operation
158 */
159U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
160U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
161U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
162U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
163
aa44ef4d 164static struct amba_device *amba_devs[] __initdata = {
4b27aa41
RV
165 &ux500_uart0_device,
166 &ux500_uart1_device,
167 &ux500_uart2_device,
9e4e7fe1 168 &u8500_ssp0_device,
aa44ef4d
SK
169};
170
4c61c845
SI
171static const unsigned int ux500_keymap[] = {
172 KEY(2, 5, KEY_END),
173 KEY(4, 1, KEY_POWER),
174 KEY(3, 5, KEY_VOLUMEDOWN),
175 KEY(1, 3, KEY_3),
176 KEY(5, 2, KEY_RIGHT),
177 KEY(5, 0, KEY_9),
178
179 KEY(0, 5, KEY_MENU),
180 KEY(7, 6, KEY_ENTER),
181 KEY(4, 5, KEY_0),
182 KEY(6, 7, KEY_2),
183 KEY(3, 4, KEY_UP),
184 KEY(3, 3, KEY_DOWN),
185
186 KEY(6, 4, KEY_SEND),
187 KEY(6, 2, KEY_BACK),
188 KEY(4, 2, KEY_VOLUMEUP),
189 KEY(5, 5, KEY_1),
190 KEY(4, 3, KEY_LEFT),
191 KEY(3, 2, KEY_7),
192};
193
194static const struct matrix_keymap_data ux500_keymap_data = {
195 .keymap = ux500_keymap,
196 .keymap_size = ARRAY_SIZE(ux500_keymap),
197};
198
199/*
200 * Nomadik SKE keypad
201 */
202#define ROW_PIN_I0 164
203#define ROW_PIN_I1 163
204#define ROW_PIN_I2 162
205#define ROW_PIN_I3 161
206#define ROW_PIN_I4 156
207#define ROW_PIN_I5 155
208#define ROW_PIN_I6 154
209#define ROW_PIN_I7 153
210#define COL_PIN_O0 168
211#define COL_PIN_O1 167
212#define COL_PIN_O2 166
213#define COL_PIN_O3 165
214#define COL_PIN_O4 160
215#define COL_PIN_O5 159
216#define COL_PIN_O6 158
217#define COL_PIN_O7 157
218
219#define SKE_KPD_MAX_ROWS 8
220#define SKE_KPD_MAX_COLS 8
221
222static int ske_kp_rows[] = {
223 ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3,
224 ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7,
225};
226
227/*
228 * ske_set_gpio_row: request and set gpio rows
229 */
230static int ske_set_gpio_row(int gpio)
231{
232 int ret;
233
234 ret = gpio_request(gpio, "ske-kp");
235 if (ret < 0) {
236 pr_err("ske_set_gpio_row: gpio request failed\n");
237 return ret;
238 }
239
240 ret = gpio_direction_output(gpio, 1);
241 if (ret < 0) {
242 pr_err("ske_set_gpio_row: gpio direction failed\n");
243 gpio_free(gpio);
244 }
245
246 return ret;
247}
248
249/*
250 * ske_kp_init - enable the gpio configuration
251 */
252static int ske_kp_init(void)
253{
254 int ret, i;
255
256 for (i = 0; i < SKE_KPD_MAX_ROWS; i++) {
257 ret = ske_set_gpio_row(ske_kp_rows[i]);
258 if (ret < 0) {
259 pr_err("ske_kp_init: failed init\n");
260 return ret;
261 }
262 }
263
264 return 0;
265}
266
267static struct ske_keypad_platform_data ske_keypad_board = {
268 .init = ske_kp_init,
269 .keymap_data = &ux500_keymap_data,
270 .no_autorepeat = true,
271 .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */
272 .kcol = SKE_KPD_MAX_COLS,
273 .debounce_ms = 40, /* in millsecs */
274};
275
276
277
d48a41c1
SK
278/* add any platform devices here - TODO */
279static struct platform_device *platform_devs[] __initdata = {
f9faf237
RV
280 &u8500_i2c0_device,
281 &ux500_i2c1_device,
282 &ux500_i2c2_device,
283 &ux500_i2c3_device,
4c61c845 284 &ux500_ske_keypad_device,
d48a41c1
SK
285};
286
aa44ef4d
SK
287static void __init u8500_init_machine(void)
288{
289 int i;
290
ea05a57f
RV
291 u8500_init_devices();
292
293 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
294
f9faf237
RV
295 u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data;
296 ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
297 ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
298 ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
4c61c845 299 ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board;
f9faf237 300
9e4e7fe1
RV
301 u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
302
aa44ef4d
SK
303 /* Register the active AMBA devices on this board */
304 for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
305 amba_device_register(amba_devs[i], &iomem_resource);
306
d48a41c1
SK
307 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
308
008f8a2f
HP
309 mop500_sdi_init();
310
29aeb3cf
LW
311 /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */
312 if (cpu_is_u8500ed() || cpu_is_u8500v10())
313 spi_register_board_info(ab8500_spi_devices,
314 ARRAY_SIZE(ab8500_spi_devices));
315 else /* If HW is v.1.1 or later use I2C to access AB8500 */
316 platform_device_register(&ab8500_device);
aa44ef4d
SK
317}
318
319MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
320 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
aa44ef4d
SK
321 .boot_params = 0x100,
322 .map_io = u8500_map_io,
178980f9 323 .init_irq = ux500_init_irq,
aa44ef4d 324 /* we re-use nomadik timer here */
41ac329f 325 .timer = &ux500_timer,
aa44ef4d
SK
326 .init_machine = u8500_init_machine,
327MACHINE_END