n810: Fix tsc2005 busnum
[openwrt/svn-archive/archive.git] / target / linux / omap24xx / patches-2.6.38 / 301-nokia-board-additional.patch
1 Index: linux-2.6.38-rc6/arch/arm/mach-omap2/board-n8x0.c
2 ===================================================================
3 --- linux-2.6.38-rc6.orig/arch/arm/mach-omap2/board-n8x0.c 2011-02-27 21:55:22.978833306 +0100
4 +++ linux-2.6.38-rc6/arch/arm/mach-omap2/board-n8x0.c 2011-02-27 22:36:52.335957066 +0100
5 @@ -23,6 +23,9 @@
6 #include <linux/spi/spi.h>
7 #include <linux/usb/musb.h>
8 #include <sound/tlv320aic3x.h>
9 +#include <linux/input.h>
10 +#include <linux/i2c/lm8323.h>
11 +#include <linux/spi/tsc2005.h>
12
13 #include <asm/mach/arch.h>
14 #include <asm/mach-types.h>
15 @@ -36,6 +39,7 @@
16 #include <plat/mmc.h>
17 #include <plat/serial.h>
18 #include <plat/cbus.h>
19 +#include <plat/gpio-switch.h>
20
21 #include "mux.h"
22
23 @@ -43,6 +47,221 @@ static int slot1_cover_open;
24 static int slot2_cover_open;
25 static struct device *mmc_device;
26
27 +/* We map the FN key as LALT to workaround an X keycode problem.
28 + * The XKB map needs to be adjusted to support this. */
29 +#define MAP_FN_AS_LEFTALT
30 +
31 +static s16 rx44_keymap[LM8323_KEYMAP_SIZE] = {
32 + [0x01] = KEY_Q,
33 + [0x02] = KEY_K,
34 + [0x03] = KEY_O,
35 + [0x04] = KEY_P,
36 + [0x05] = KEY_BACKSPACE,
37 + [0x06] = KEY_A,
38 + [0x07] = KEY_S,
39 + [0x08] = KEY_D,
40 + [0x09] = KEY_F,
41 + [0x0a] = KEY_G,
42 + [0x0b] = KEY_H,
43 + [0x0c] = KEY_J,
44 +
45 + [0x11] = KEY_W,
46 + [0x12] = KEY_F4,
47 + [0x13] = KEY_L,
48 + [0x14] = KEY_APOSTROPHE,
49 + [0x16] = KEY_Z,
50 + [0x17] = KEY_X,
51 + [0x18] = KEY_C,
52 + [0x19] = KEY_V,
53 + [0x1a] = KEY_B,
54 + [0x1b] = KEY_N,
55 + [0x1c] = KEY_LEFTSHIFT, /* Actually, this is both shift keys */
56 + [0x1f] = KEY_F7,
57 +
58 + [0x21] = KEY_E,
59 + [0x22] = KEY_SEMICOLON,
60 + [0x23] = KEY_MINUS,
61 + [0x24] = KEY_EQUAL,
62 +#ifdef MAP_FN_AS_LEFTALT
63 + [0x2b] = KEY_LEFTALT,
64 +#else
65 + [0x2b] = KEY_FN,
66 +#endif
67 + [0x2c] = KEY_M,
68 + [0x2f] = KEY_F8,
69 +
70 + [0x31] = KEY_R,
71 + [0x32] = KEY_RIGHTCTRL,
72 + [0x34] = KEY_SPACE,
73 + [0x35] = KEY_COMMA,
74 + [0x37] = KEY_UP,
75 + [0x3c] = KEY_COMPOSE,
76 + [0x3f] = KEY_F6,
77 +
78 + [0x41] = KEY_T,
79 + [0x44] = KEY_DOT,
80 + [0x46] = KEY_RIGHT,
81 + [0x4f] = KEY_F5,
82 + [0x51] = KEY_Y,
83 + [0x53] = KEY_DOWN,
84 + [0x55] = KEY_ENTER,
85 + [0x5f] = KEY_ESC,
86 +
87 + [0x61] = KEY_U,
88 + [0x64] = KEY_LEFT,
89 +
90 + [0x71] = KEY_I,
91 + [0x75] = KEY_KPENTER,
92 +};
93 +
94 +static struct lm8323_platform_data lm8323_pdata = {
95 + .repeat = 0, /* Repeat is handled in userspace for now. */
96 + .keymap = rx44_keymap,
97 + .size_x = 8,
98 + .size_y = 12,
99 + .debounce_time = 12,
100 + .active_time = 500,
101 +
102 + .name = "Internal keyboard",
103 + .pwm_names[0] = "n810::keyboard",
104 + .pwm_names[1] = "n810::cover",
105 +};
106 +
107 +#define OMAP_TAG_NOKIA_BT 0x4e01
108 +
109 +struct omap_bluetooth_config {
110 + u8 chip_type;
111 + u8 bt_wakeup_gpio;
112 + u8 host_wakeup_gpio;
113 + u8 reset_gpio;
114 + u8 bt_uart;
115 + u8 bd_addr[6];
116 + u8 bt_sysclk;
117 +};
118 +
119 +static struct platform_device n8x0_bt_device = {
120 + .name = "hci_h4p",
121 + .id = -1,
122 + .num_resources = 0,
123 +};
124 +
125 +void __init n8x0_bt_init(void)
126 +{
127 + const struct omap_bluetooth_config *bt_config;
128 +
129 + bt_config = (void *) omap_get_config(OMAP_TAG_NOKIA_BT,
130 + struct omap_bluetooth_config);
131 + n8x0_bt_device.dev.platform_data = (void *) bt_config;
132 + if (platform_device_register(&n8x0_bt_device) < 0)
133 + BUG();
134 +}
135 +
136 +#define RX51_TSC2005_RESET_GPIO 94
137 +#define RX51_TSC2005_IRQ_GPIO 106
138 +
139 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
140 +static struct tsc2005_platform_data tsc2005_config;
141 +static void rx51_tsc2005_set_reset(bool enable)
142 +{
143 + gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
144 +}
145 +
146 +static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
147 + .turbo_mode = 0,
148 + .single_channel = 1,
149 +};
150 +#endif
151 +
152 +static void __init tsc2005_set_config(void)
153 +{
154 + const struct omap_lcd_config *conf;
155 +
156 + conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
157 + if (conf != NULL) {
158 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
159 + if (strcmp(conf->panel_name, "lph8923") == 0) {
160 + tsc2005_config.ts_x_plate_ohm = 180;
161 + tsc2005_config.ts_hw_avg = 0;
162 + tsc2005_config.ts_ignore_last = 0;
163 + tsc2005_config.ts_touch_pressure = 1500;
164 + tsc2005_config.ts_stab_time = 100;
165 + tsc2005_config.ts_pressure_max = 2048;
166 + tsc2005_config.ts_pressure_fudge = 2;
167 + tsc2005_config.ts_x_max = 4096;
168 + tsc2005_config.ts_x_fudge = 4;
169 + tsc2005_config.ts_y_max = 4096;
170 + tsc2005_config.ts_y_fudge = 7;
171 + tsc2005_config.set_reset = rx51_tsc2005_set_reset;
172 + } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
173 + tsc2005_config.ts_x_plate_ohm = 280;
174 + tsc2005_config.ts_hw_avg = 0;
175 + tsc2005_config.ts_ignore_last = 0;
176 + tsc2005_config.ts_touch_pressure = 1500;
177 + tsc2005_config.ts_stab_time = 1000;
178 + tsc2005_config.ts_pressure_max = 2048;
179 + tsc2005_config.ts_pressure_fudge = 2;
180 + tsc2005_config.ts_x_max = 4096;
181 + tsc2005_config.ts_x_fudge = 4;
182 + tsc2005_config.ts_y_max = 4096;
183 + tsc2005_config.ts_y_fudge = 7;
184 + tsc2005_config.set_reset = rx51_tsc2005_set_reset;
185 + } else {
186 + printk(KERN_ERR "Unknown panel type, set default "
187 + "touchscreen configuration\n");
188 + tsc2005_config.ts_x_plate_ohm = 200;
189 + tsc2005_config.ts_stab_time = 100;
190 + }
191 +#endif
192 + }
193 +}
194 +
195 +static struct omap2_mcspi_device_config mipid_mcspi_config = {
196 + .turbo_mode = 0,
197 + .single_channel = 1,
198 +};
199 +
200 +extern struct mipid_platform_data n8x0_mipid_platform_data;
201 +
202 +extern void n8x0_mipid_init(void);
203 +extern void n8x0_blizzard_init(void);
204 +
205 +static struct omap_gpio_switch n8x0_gpio_switches[] __initdata = {
206 + {
207 + .name = "headphone",
208 + .gpio = -1,
209 + .debounce_rising = 200,
210 + .debounce_falling = 200,
211 + }, {
212 + .name = "cam_act",
213 + .gpio = -1,
214 + .debounce_rising = 200,
215 + .debounce_falling = 200,
216 + }, {
217 + .name = "cam_turn",
218 + .gpio = -1,
219 + .debounce_rising = 100,
220 + .debounce_falling = 100,
221 + }, {
222 + .name = "slide",
223 + .gpio = -1,
224 + .debounce_rising = 200,
225 + .debounce_falling = 200,
226 + }, {
227 + .name = "kb_lock",
228 + .gpio = -1,
229 + .debounce_rising = 200,
230 + .debounce_falling = 200,
231 + },
232 +};
233 +
234 +static void __init n8x0_gpio_switches_init(void)
235 +{
236 + /* The switches are actually registered through ATAG mechanism.
237 + * This just updates the parameters (thus .gpio is -1) */
238 + omap_register_gpio_switches(n8x0_gpio_switches,
239 + ARRAY_SIZE(n8x0_gpio_switches));
240 +}
241 +
242 #define TUSB6010_ASYNC_CS 1
243 #define TUSB6010_SYNC_CS 4
244 #define TUSB6010_GPIO_INT 58
245 @@ -146,12 +365,29 @@ static struct omap2_mcspi_device_config
246
247 static struct spi_board_info n800_spi_board_info[] __initdata = {
248 {
249 + .modalias = "lcd_mipid",
250 + .bus_num = 1,
251 + .chip_select = 1,
252 + .max_speed_hz = 4000000,
253 + .controller_data= &mipid_mcspi_config,
254 + .platform_data = &n8x0_mipid_platform_data,
255 + },
256 + {
257 .modalias = "p54spi",
258 .bus_num = 2,
259 .chip_select = 0,
260 .max_speed_hz = 48000000,
261 .controller_data = &p54spi_mcspi_config,
262 },
263 + {
264 + .modalias = "tsc2005",
265 + .bus_num = 1,
266 + .chip_select = 0,
267 + .irq = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
268 + .max_speed_hz = 6000000,
269 + .controller_data = &tsc2005_mcspi_config,
270 + .platform_data = &tsc2005_config,
271 + },
272 };
273
274 #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
275 @@ -727,6 +963,11 @@ static struct aic3x_pdata n810_aic33_dat
276 };
277
278 static struct i2c_board_info n810_i2c_board_info_2[] __initdata = {
279 + {
280 + I2C_BOARD_INFO("lm8323", 0x45),
281 + .irq = OMAP_GPIO_IRQ(109),
282 + .platform_data = &lm8323_pdata,
283 + },
284 {
285 I2C_BOARD_INFO("tlv320aic3x", 0x18),
286 .platform_data = &n810_aic33_data,
287 @@ -796,9 +1037,12 @@ static inline void board_serial_init(voi
288 static void __init n8x0_init_machine(void)
289 {
290 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
291 + n8x0_gpio_switches_init();
292 n8x0_cbus_init();
293 + n8x0_bt_init();
294
295 /* FIXME: add n810 spi devices */
296 + tsc2005_set_config();
297 spi_register_board_info(n800_spi_board_info,
298 ARRAY_SIZE(n800_spi_board_info));
299 omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
300 @@ -808,6 +1052,8 @@ static void __init n8x0_init_machine(voi
301 i2c_register_board_info(2, n810_i2c_board_info_2,
302 ARRAY_SIZE(n810_i2c_board_info_2));
303 board_serial_init();
304 + n8x0_mipid_init();
305 + n8x0_blizzard_init();
306 gpmc_onenand_init(board_onenand_data);
307 n8x0_mmc_init();
308 n8x0_usb_init();
309 Index: linux-2.6.38-rc6/arch/arm/mach-omap2/board-n8x0-lcd.c
310 ===================================================================
311 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
312 +++ linux-2.6.38-rc6/arch/arm/mach-omap2/board-n8x0-lcd.c 2011-02-27 22:36:50.837929678 +0100
313 @@ -0,0 +1,127 @@
314 +/*
315 + * linux/arch/arm/mach-omap2/board-n8x0.c
316 + *
317 + * Copyright (C) 2005-2009 Nokia Corporation
318 + * Author: Juha Yrjola <juha.yrjola@nokia.com>
319 + *
320 + * Modified from mach-omap2/board-generic.c
321 + *
322 + * This program is free software; you can redistribute it and/or modify
323 + * it under the terms of the GNU General Public License version 2 as
324 + * published by the Free Software Foundation.
325 + */
326 +
327 +#include <linux/clk.h>
328 +#include <linux/delay.h>
329 +#include <linux/gpio.h>
330 +#include <linux/omapfb.h>
331 +
332 +#include <plat/lcd_mipid.h>
333 +#include <plat/blizzard.h>
334 +
335 +#include <../drivers/cbus/tahvo.h>
336 +
337 +#define N8X0_BLIZZARD_POWERDOWN_GPIO 15
338 +
339 +// MIPID LCD Panel
340 +
341 +static void mipid_shutdown(struct mipid_platform_data *pdata)
342 +{
343 + if (pdata->nreset_gpio != -1) {
344 + pr_info("shutdown LCD\n");
345 + gpio_set_value(pdata->nreset_gpio, 0);
346 + msleep(120);
347 + }
348 +}
349 +
350 +struct mipid_platform_data n8x0_mipid_platform_data = {
351 + .shutdown = mipid_shutdown,
352 +};
353 +
354 +void __init n8x0_mipid_init(void)
355 +{
356 + const struct omap_lcd_config *conf;
357 +
358 + conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
359 + if (conf != NULL) {
360 + n8x0_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
361 + n8x0_mipid_platform_data.data_lines = conf->data_lines;
362 + printk(KERN_INFO "N8x0 MIPID config loaded");
363 + }
364 + else
365 + printk(KERN_INFO "N8x0 MIPID config not provided");
366 +}
367 +
368 +
369 +// Epson Blizzard LCD Controller
370 +
371 +static struct {
372 + struct clk *sys_ck;
373 +} blizzard;
374 +
375 +static int blizzard_get_clocks(void)
376 +{
377 + blizzard.sys_ck = clk_get(0, "osc_ck");
378 + if (IS_ERR(blizzard.sys_ck)) {
379 + printk(KERN_ERR "can't get Blizzard clock\n");
380 + return PTR_ERR(blizzard.sys_ck);
381 + }
382 + return 0;
383 +}
384 +
385 +static unsigned long blizzard_get_clock_rate(struct device *dev)
386 +{
387 + return clk_get_rate(blizzard.sys_ck);
388 +}
389 +
390 +static void blizzard_enable_clocks(int enable)
391 +{
392 + if (enable)
393 + clk_enable(blizzard.sys_ck);
394 + else
395 + clk_disable(blizzard.sys_ck);
396 +}
397 +
398 +static void blizzard_power_up(struct device *dev)
399 +{
400 + /* Vcore to 1.475V */
401 + tahvo_set_clear_reg_bits(0x07, 0, 0xf);
402 + msleep(10);
403 +
404 + blizzard_enable_clocks(1);
405 + gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
406 +}
407 +
408 +static void blizzard_power_down(struct device *dev)
409 +{
410 + gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 0);
411 + blizzard_enable_clocks(0);
412 +
413 + /* Vcore to 1.005V */
414 + tahvo_set_clear_reg_bits(0x07, 0xf, 0);
415 +}
416 +
417 +static struct blizzard_platform_data n8x0_blizzard_data = {
418 + .power_up = blizzard_power_up,
419 + .power_down = blizzard_power_down,
420 + .get_clock_rate = blizzard_get_clock_rate,
421 + .te_connected = 1,
422 +};
423 +
424 +void __init n8x0_blizzard_init(void)
425 +{
426 + int r;
427 +
428 + r = gpio_request(N8X0_BLIZZARD_POWERDOWN_GPIO, "Blizzard pd");
429 + if (r < 0)
430 + {
431 + printk(KERN_ERR "Can't get N8x0 Blizzard powerdown GPIO %d\n", N8X0_BLIZZARD_POWERDOWN_GPIO);
432 + return;
433 + }
434 + gpio_direction_output(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
435 +
436 + blizzard_get_clocks();
437 + omapfb_set_ctrl_platform_data(&n8x0_blizzard_data);
438 +
439 + printk(KERN_INFO "N8x0 Blizzard initialized");
440 +}
441 Index: linux-2.6.38-rc6/arch/arm/mach-omap2/Makefile
442 ===================================================================
443 --- linux-2.6.38-rc6.orig/arch/arm/mach-omap2/Makefile 2011-02-22 02:25:52.000000000 +0100
444 +++ linux-2.6.38-rc6/arch/arm/mach-omap2/Makefile 2011-02-27 21:55:22.998833653 +0100
445 @@ -177,6 +177,7 @@ obj-$(CONFIG_MACH_OMAP_3430SDP) += boar
446 hsmmc.o \
447 board-flash.o
448 obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0.o
449 +obj-$(CONFIG_MACH_NOKIA_N8X0) += board-n8x0-lcd.o
450 obj-$(CONFIG_MACH_NOKIA_RM680) += board-rm680.o \
451 sdram-nokia.o \
452 hsmmc.o
453 Index: linux-2.6.38-rc6/arch/arm/plat-omap/include/plat/cbus.h
454 ===================================================================
455 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
456 +++ linux-2.6.38-rc6/arch/arm/plat-omap/include/plat/cbus.h 2011-02-27 21:55:22.998833653 +0100
457 @@ -0,0 +1,40 @@
458 +/*
459 + * cbus.h - CBUS platform_data definition
460 + *
461 + * Copyright (C) 2004 - 2009 Nokia Corporation
462 + *
463 + * Written by Felipe Balbi <felipe.balbi@nokia.com>
464 + *
465 + * This file is subject to the terms and conditions of the GNU General
466 + * Public License. See the file "COPYING" in the main directory of this
467 + * archive for more details.
468 + *
469 + * This program is distributed in the hope that it will be useful,
470 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
471 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
472 + * GNU General Public License for more details.
473 + *
474 + * You should have received a copy of the GNU General Public License
475 + * along with this program; if not, write to the Free Software
476 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
477 + */
478 +
479 +#ifndef __PLAT_CBUS_H
480 +#define __PLAT_CBUS_H
481 +
482 +#define CBUS_RETU_DEVICE_ID 0x01
483 +#define CBUS_TAHVO_DEVICE_ID 0x02
484 +
485 +struct cbus_host_platform_data {
486 + int dat_gpio;
487 + int clk_gpio;
488 + int sel_gpio;
489 +};
490 +
491 +struct cbus_retu_platform_data {
492 + int irq_base;
493 + int irq_end;
494 + int devid;
495 +};
496 +
497 +#endif /* __PLAT_CBUS_H */
498 Index: linux-2.6.38-rc6/arch/arm/plat-omap/include/plat/irqs.h
499 ===================================================================
500 --- linux-2.6.38-rc6.orig/arch/arm/plat-omap/include/plat/irqs.h 2011-02-22 02:25:52.000000000 +0100
501 +++ linux-2.6.38-rc6/arch/arm/plat-omap/include/plat/irqs.h 2011-02-27 21:55:22.999833671 +0100
502 @@ -411,7 +411,20 @@
503 #define TWL_IRQ_END TWL6030_IRQ_END
504 #endif
505
506 -#define NR_IRQS TWL_IRQ_END
507 +/* GPMC related */
508 +#define OMAP_GPMC_IRQ_BASE (TWL_IRQ_END)
509 +#define OMAP_GPMC_NR_IRQS 7
510 +#define OMAP_GPMC_IRQ_END (OMAP_GPMC_IRQ_BASE + OMAP_GPMC_NR_IRQS)
511 +
512 +#define CBUS_RETU_IRQ_BASE OMAP_GPMC_IRQ_END
513 +#ifdef CONFIG_CBUS_RETU
514 +#define CBUS_RETU_NR_IRQS 16
515 +#else
516 +#define CBUS_RETU_NR_IRQS 0
517 +#endif
518 +#define CBUS_RETU_IRQ_END (CBUS_RETU_IRQ_BASE + CBUS_RETU_NR_IRQS)
519 +
520 +#define NR_IRQS CBUS_RETU_IRQ_END
521
522 #define OMAP_IRQ_BIT(irq) (1 << ((irq) % 32))
523