omap24xx: Workaround n810 FN key issue
[oweals/openwrt.git] / target / linux / omap24xx / patches-2.6.37 / 300-nokia-board.patch
1 ---
2  arch/arm/mach-omap1/board-nokia770.c |   16 +
3  arch/arm/mach-omap2/Kconfig          |   10 
4  arch/arm/mach-omap2/Makefile         |    2 
5  arch/arm/mach-omap2/board-n8x0-lcd.c |  127 ++++++++++++
6  arch/arm/mach-omap2/board-n8x0-usb.c |  175 +++++++++++++++++
7  arch/arm/mach-omap2/board-n8x0.c     |  355 ++++++++++++++++++++++++++---------
8  arch/arm/mach-omap2/control.c        |    2 
9  arch/arm/mach-omap2/serial.c         |    8 
10  8 files changed, 608 insertions(+), 87 deletions(-)
11
12 Index: linux-2.6.37/arch/arm/mach-omap1/board-nokia770.c
13 ===================================================================
14 --- linux-2.6.37.orig/arch/arm/mach-omap1/board-nokia770.c      2011-01-05 01:50:19.000000000 +0100
15 +++ linux-2.6.37/arch/arm/mach-omap1/board-nokia770.c   2011-01-28 18:09:59.378233620 +0100
16 @@ -36,6 +36,7 @@
17  #include <plat/lcd_mipid.h>
18  #include <plat/mmc.h>
19  #include <plat/clock.h>
20 +#include <plat/cbus.h>
21  
22  #define ADS7846_PENDOWN_GPIO   15
23  
24 @@ -95,8 +96,23 @@
25         .resource       = nokia770_kp_resources,
26  };
27  
28 +static struct cbus_host_platform_data nokia770_cbus_data = {
29 +       .clk_gpio       = OMAP_MPUIO(11),
30 +       .dat_gpio       = OMAP_MPUIO(10),
31 +       .sel_gpio       = OMAP_MPUIO(9),
32 +};
33 +
34 +static struct platform_device nokia770_cbus_device = {
35 +       .name           = "cbus",
36 +       .id             = -1,
37 +       .dev            = {
38 +               .platform_data = &nokia770_cbus_data,
39 +       },
40 +};
41 +
42  static struct platform_device *nokia770_devices[] __initdata = {
43         &nokia770_kp_device,
44 +       &nokia770_cbus_device,
45  };
46  
47  static void mipid_shutdown(struct mipid_platform_data *pdata)
48 Index: linux-2.6.37/arch/arm/mach-omap2/board-n8x0.c
49 ===================================================================
50 --- linux-2.6.37.orig/arch/arm/mach-omap2/board-n8x0.c  2011-01-05 01:50:19.000000000 +0100
51 +++ linux-2.6.37/arch/arm/mach-omap2/board-n8x0.c       2011-01-28 18:13:25.864968462 +0100
52 @@ -18,9 +18,13 @@
53  #include <linux/io.h>
54  #include <linux/stddef.h>
55  #include <linux/i2c.h>
56 +#include <linux/platform_device.h>
57  #include <linux/spi/spi.h>
58 +#include <linux/spi/tsc2005.h>
59 +#include <linux/input.h>
60  #include <linux/usb/musb.h>
61  #include <sound/tlv320aic3x.h>
62 +#include <linux/i2c/lm8323.h>
63  
64  #include <asm/mach/arch.h>
65  #include <asm/mach-types.h>
66 @@ -33,6 +37,8 @@
67  #include <plat/onenand.h>
68  #include <plat/mmc.h>
69  #include <plat/serial.h>
70 +#include <plat/cbus.h>
71 +#include <plat/gpio-switch.h>
72  
73  #include "mux.h"
74  
75 @@ -40,109 +46,162 @@
76  static int slot2_cover_open;
77  static struct device *mmc_device;
78  
79 -#define TUSB6010_ASYNC_CS      1
80 -#define TUSB6010_SYNC_CS       4
81 -#define TUSB6010_GPIO_INT      58
82 -#define TUSB6010_GPIO_ENABLE   0
83 -#define TUSB6010_DMACHAN       0x3f
84 +#define        RX51_TSC2005_RESET_GPIO 94
85 +#define        RX51_TSC2005_IRQ_GPIO   106
86 +#define OMAP_TAG_NOKIA_BT      0x4e01
87 +
88 +/* We map the FN key as LALT to workaround an X keycode problem.
89 + * The XKB map needs to be adjusted to support this. */
90 +#define MAP_FN_AS_LEFTALT
91 +
92 +static s16 rx44_keymap[LM8323_KEYMAP_SIZE] = {
93 +       [0x01] = KEY_Q,
94 +       [0x02] = KEY_K,
95 +       [0x03] = KEY_O,
96 +       [0x04] = KEY_P,
97 +       [0x05] = KEY_BACKSPACE,
98 +       [0x06] = KEY_A,
99 +       [0x07] = KEY_S,
100 +       [0x08] = KEY_D,
101 +       [0x09] = KEY_F,
102 +       [0x0a] = KEY_G,
103 +       [0x0b] = KEY_H,
104 +       [0x0c] = KEY_J,
105 +
106 +       [0x11] = KEY_W,
107 +       [0x12] = KEY_F4,
108 +       [0x13] = KEY_L,
109 +       [0x14] = KEY_APOSTROPHE,
110 +       [0x16] = KEY_Z,
111 +       [0x17] = KEY_X,
112 +       [0x18] = KEY_C,
113 +       [0x19] = KEY_V,
114 +       [0x1a] = KEY_B,
115 +       [0x1b] = KEY_N,
116 +       [0x1c] = KEY_LEFTSHIFT, /* Actually, this is both shift keys */
117 +       [0x1f] = KEY_F7,
118 +
119 +       [0x21] = KEY_E,
120 +       [0x22] = KEY_SEMICOLON,
121 +       [0x23] = KEY_MINUS,
122 +       [0x24] = KEY_EQUAL,
123 +#ifdef MAP_FN_AS_LEFTALT
124 +       [0x2b] = KEY_LEFTALT,
125 +#else
126 +       [0x2b] = KEY_FN,
127 +#endif
128 +       [0x2c] = KEY_M,
129 +       [0x2f] = KEY_F8,
130  
131 -#if defined(CONFIG_USB_TUSB6010) || \
132 -       defined(CONFIG_USB_TUSB6010_MODULE)
133 -/*
134 - * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
135 - * 1.5 V voltage regulators of PM companion chip. Companion chip will then
136 - * provide then PGOOD signal to TUSB6010 which will release it from reset.
137 - */
138 -static int tusb_set_power(int state)
139 -{
140 -       int i, retval = 0;
141 +       [0x31] = KEY_R,
142 +       [0x32] = KEY_RIGHTCTRL,
143 +       [0x34] = KEY_SPACE,
144 +       [0x35] = KEY_COMMA,
145 +       [0x37] = KEY_UP,
146 +       [0x3c] = KEY_COMPOSE,
147 +       [0x3f] = KEY_F6,
148 +
149 +       [0x41] = KEY_T,
150 +       [0x44] = KEY_DOT,
151 +       [0x46] = KEY_RIGHT,
152 +       [0x4f] = KEY_F5,
153 +       [0x51] = KEY_Y,
154 +       [0x53] = KEY_DOWN,
155 +       [0x55] = KEY_ENTER,
156 +       [0x5f] = KEY_ESC,
157 +
158 +       [0x61] = KEY_U,
159 +       [0x64] = KEY_LEFT,
160 +
161 +       [0x71] = KEY_I,
162 +       [0x75] = KEY_KPENTER,
163 +};
164 +
165 +static struct lm8323_platform_data lm8323_pdata = {
166 +       .repeat         = 0, /* Repeat is handled in userspace for now. */
167 +       .keymap         = rx44_keymap,
168 +       .size_x         = 8,
169 +       .size_y         = 12,
170 +       .debounce_time  = 12,
171 +       .active_time    = 500,
172 +
173 +       .name           = "Internal keyboard",
174 +       .pwm_names[0]   = "n810::keyboard",
175 +       .pwm_names[1]   = "n810::cover",
176 +       //.pwm1_name    = "n810::keyboard",
177 +       //.pwm2_name    = "n810::cover",
178 +};
179 +
180 +struct omap_bluetooth_config {
181 +       u8    chip_type;
182 +       u8    bt_wakeup_gpio;
183 +       u8    host_wakeup_gpio;
184 +       u8    reset_gpio;
185 +       u8    bt_uart;
186 +       u8    bd_addr[6];
187 +       u8    bt_sysclk;
188 +};
189 +
190 +static struct platform_device n8x0_bt_device = {
191 +       .name           = "hci_h4p",
192 +       .id             = -1,
193 +       .num_resources  = 0,
194 +};
195 +
196 +void __init n8x0_bt_init(void)
197 +{
198 +       const struct omap_bluetooth_config *bt_config;
199 +
200 +       bt_config = (void *) omap_get_config(OMAP_TAG_NOKIA_BT,
201 +                                            struct omap_bluetooth_config);
202 +       n8x0_bt_device.dev.platform_data = (void *) bt_config;
203 +       if (platform_device_register(&n8x0_bt_device) < 0)
204 +               BUG();
205 +}
206  
207 -       if (state) {
208 -               gpio_set_value(TUSB6010_GPIO_ENABLE, 1);
209 -               msleep(1);
210 +static struct omap2_mcspi_device_config mipid_mcspi_config = {
211 +       .turbo_mode     = 0,
212 +       .single_channel = 1,
213 +};
214  
215 -               /* Wait until TUSB6010 pulls INT pin down */
216 -               i = 100;
217 -               while (i && gpio_get_value(TUSB6010_GPIO_INT)) {
218 -                       msleep(1);
219 -                       i--;
220 -               }
221 +static int slot1_cover_open;
222 +static int slot2_cover_open;
223 +static struct device *mmc_device;
224  
225 -               if (!i) {
226 -                       printk(KERN_ERR "tusb: powerup failed\n");
227 -                       retval = -ENODEV;
228 -               }
229 -       } else {
230 -               gpio_set_value(TUSB6010_GPIO_ENABLE, 0);
231 -               msleep(10);
232 -       }
233  
234 -       return retval;
235 -}
236 -
237 -static struct musb_hdrc_config musb_config = {
238 -       .multipoint     = 1,
239 -       .dyn_fifo       = 1,
240 -       .num_eps        = 16,
241 -       .ram_bits       = 12,
242 +static struct omap2_mcspi_device_config p54spi_mcspi_config = {
243 +       .turbo_mode     = 0,
244 +       .single_channel = 1,
245  };
246  
247 -static struct musb_hdrc_platform_data tusb_data = {
248 -#if defined(CONFIG_USB_MUSB_OTG)
249 -       .mode           = MUSB_OTG,
250 -#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
251 -       .mode           = MUSB_PERIPHERAL,
252 -#else /* defined(CONFIG_USB_MUSB_HOST) */
253 -       .mode           = MUSB_HOST,
254 +#ifdef CONFIG_MACH_NOKIA_N8X0_LCD
255 +extern struct mipid_platform_data n8x0_mipid_platform_data;
256  #endif
257 -       .set_power      = tusb_set_power,
258 -       .min_power      = 25,   /* x2 = 50 mA drawn from VBUS as peripheral */
259 -       .power          = 100,  /* Max 100 mA VBUS for host mode */
260 -       .config         = &musb_config,
261 -};
262  
263 -static void __init n8x0_usb_init(void)
264 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
265 +static struct tsc2005_platform_data tsc2005_config;
266 +static void rx51_tsc2005_set_reset(bool enable)
267  {
268 -       int ret = 0;
269 -       static char     announce[] __initdata = KERN_INFO "TUSB 6010\n";
270 -
271 -       /* PM companion chip power control pin */
272 -       ret = gpio_request(TUSB6010_GPIO_ENABLE, "TUSB6010 enable");
273 -       if (ret != 0) {
274 -               printk(KERN_ERR "Could not get TUSB power GPIO%i\n",
275 -                      TUSB6010_GPIO_ENABLE);
276 -               return;
277 -       }
278 -       gpio_direction_output(TUSB6010_GPIO_ENABLE, 0);
279 -
280 -       tusb_set_power(0);
281 -
282 -       ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2,
283 -                                       TUSB6010_ASYNC_CS, TUSB6010_SYNC_CS,
284 -                                       TUSB6010_GPIO_INT, TUSB6010_DMACHAN);
285 -       if (ret != 0)
286 -               goto err;
287 -
288 -       printk(announce);
289 -
290 -       return;
291 -
292 -err:
293 -       gpio_free(TUSB6010_GPIO_ENABLE);
294 +       gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
295  }
296 -#else
297 -
298 -static void __init n8x0_usb_init(void) {}
299 -
300 -#endif /*CONFIG_USB_TUSB6010 */
301 -
302  
303 -static struct omap2_mcspi_device_config p54spi_mcspi_config = {
304 +static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
305         .turbo_mode     = 0,
306         .single_channel = 1,
307  };
308 +#endif
309  
310  static struct spi_board_info n800_spi_board_info[] __initdata = {
311 +#ifdef CONFIG_MACH_NOKIA_N8X0_LCD
312 +       {
313 +               .modalias       = "lcd_mipid",
314 +               .bus_num        = 1,
315 +               .chip_select    = 1,
316 +               .max_speed_hz   = 4000000,
317 +               .controller_data= &mipid_mcspi_config,
318 +               .platform_data  = &n8x0_mipid_platform_data,
319 +       },
320 +#endif
321         {
322                 .modalias       = "p54spi",
323                 .bus_num        = 2,
324 @@ -150,8 +209,60 @@
325                 .max_speed_hz   = 48000000,
326                 .controller_data = &p54spi_mcspi_config,
327         },
328 +       {
329 +               .modalias        = "tsc2005",
330 +               .bus_num         = 1,
331 +               .chip_select     = 0,
332 +               .irq             = OMAP_GPIO_IRQ(RX51_TSC2005_IRQ_GPIO),
333 +               .max_speed_hz    = 6000000,
334 +               .controller_data = &tsc2005_mcspi_config,
335 +               .platform_data   = &tsc2005_config,
336 +       },
337  };
338  
339 +static void __init tsc2005_set_config(void)
340 +{
341 +       const struct omap_lcd_config *conf;
342 +
343 +       conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
344 +       if (conf != NULL) {
345 +#ifdef CONFIG_TOUCHSCREEN_TSC2005
346 +               if (strcmp(conf->panel_name, "lph8923") == 0) {
347 +                       tsc2005_config.ts_x_plate_ohm = 180;
348 +                       tsc2005_config.ts_hw_avg = 0;
349 +                       tsc2005_config.ts_ignore_last = 0;
350 +                       tsc2005_config.ts_touch_pressure = 1500;
351 +                       tsc2005_config.ts_stab_time = 100;
352 +                       tsc2005_config.ts_pressure_max = 2048;
353 +                       tsc2005_config.ts_pressure_fudge = 2;
354 +                       tsc2005_config.ts_x_max = 4096;
355 +                       tsc2005_config.ts_x_fudge = 4;
356 +                       tsc2005_config.ts_y_max = 4096;
357 +                       tsc2005_config.ts_y_fudge = 7;
358 +                       tsc2005_config.set_reset = rx51_tsc2005_set_reset;
359 +               } else if (strcmp(conf->panel_name, "ls041y3") == 0) {
360 +                       tsc2005_config.ts_x_plate_ohm = 280;
361 +                       tsc2005_config.ts_hw_avg = 0;
362 +                       tsc2005_config.ts_ignore_last = 0;
363 +                       tsc2005_config.ts_touch_pressure = 1500;
364 +                       tsc2005_config.ts_stab_time = 1000;
365 +                       tsc2005_config.ts_pressure_max = 2048;
366 +                       tsc2005_config.ts_pressure_fudge = 2;
367 +                       tsc2005_config.ts_x_max = 4096;
368 +                       tsc2005_config.ts_x_fudge = 4;
369 +                       tsc2005_config.ts_y_max = 4096;
370 +                       tsc2005_config.ts_y_fudge = 7;
371 +                       tsc2005_config.set_reset = rx51_tsc2005_set_reset;
372 +               } else {
373 +                       printk(KERN_ERR "Unknown panel type, set default "
374 +                              "touchscreen configuration\n");
375 +                       tsc2005_config.ts_x_plate_ohm = 200;
376 +                       tsc2005_config.ts_stab_time = 100;
377 +               }
378 +#endif
379 +       }
380 +}
381 +
382  #if defined(CONFIG_MTD_ONENAND_OMAP2) || \
383         defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
384  
385 @@ -184,6 +295,20 @@
386         },
387  };
388  
389 +static struct cbus_host_platform_data n8x0_cbus_data = {
390 +       .clk_gpio       = 66,
391 +       .dat_gpio       = 65,
392 +       .sel_gpio       = 64,
393 +};
394 +
395 +static struct platform_device n8x0_cbus_device = {
396 +       .name           = "cbus",
397 +       .id             = -1,
398 +       .dev            = {
399 +               .platform_data = &n8x0_cbus_data,
400 +       },
401 +};
402 +
403  static struct omap_onenand_platform_data board_onenand_data = {
404         .cs             = 0,
405         .gpio_irq       = 26,
406 @@ -626,6 +751,11 @@
407  
408  static struct i2c_board_info n810_i2c_board_info_2[] __initdata = {
409         {
410 +               I2C_BOARD_INFO("lm8323", 0x45),
411 +               .irq            = OMAP_GPIO_IRQ(109),
412 +               .platform_data  = &lm8323_pdata,
413 +       },
414 +       {
415                 I2C_BOARD_INFO("tlv320aic3x", 0x18),
416                 .platform_data = &n810_aic33_data,
417         },
418 @@ -657,10 +787,62 @@
419  #define board_mux      NULL
420  #endif
421  
422 +#ifdef CONFIG_MACH_NOKIA_N8X0_LCD
423 +extern void n8x0_mipid_init(void);
424 +extern void n8x0_blizzard_init(void);
425 +#else
426 +#define n8x0_mipid_init() 0
427 +#define n8x0_blizzard_init() 0
428 +#endif
429 +
430 +extern void n8x0_usb_init(void);
431 +
432 +static struct omap_gpio_switch n8x0_gpio_switches[] __initdata = {
433 +       {
434 +               .name                   = "headphone",
435 +               .gpio                   = -1,
436 +               .debounce_rising        = 200,
437 +               .debounce_falling       = 200,
438 +       }, {
439 +               .name                   = "cam_act",
440 +               .gpio                   = -1,
441 +               .debounce_rising        = 200,
442 +               .debounce_falling       = 200,
443 +       }, {
444 +               .name                   = "cam_turn",
445 +               .gpio                   = -1,
446 +               .debounce_rising        = 100,
447 +               .debounce_falling       = 100,
448 +       }, {
449 +               .name                   = "slide",
450 +               .gpio                   = -1,
451 +               .debounce_rising        = 200,
452 +               .debounce_falling       = 200,
453 +       }, {
454 +               .name                   = "kb_lock",
455 +               .gpio                   = -1,
456 +               .debounce_rising        = 200,
457 +               .debounce_falling       = 200,
458 +       },
459 +};
460 +
461 +static void __init n8x0_gpio_switches_init(void)
462 +{
463 +       /* The switches are actually registered through ATAG mechanism.
464 +        * This just updates the parameters (thus .gpio is -1) */
465 +       omap_register_gpio_switches(n8x0_gpio_switches,
466 +                                   ARRAY_SIZE(n8x0_gpio_switches));
467 +}
468 +
469  static void __init n8x0_init_machine(void)
470  {
471         omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
472 +       n8x0_gpio_switches_init();
473 +       platform_device_register(&n8x0_cbus_device);
474 +       n8x0_bt_init();
475 +
476         /* FIXME: add n810 spi devices */
477 +       tsc2005_set_config();
478         spi_register_board_info(n800_spi_board_info,
479                                 ARRAY_SIZE(n800_spi_board_info));
480         omap_register_i2c_bus(1, 400, n8x0_i2c_board_info_1,
481 @@ -671,6 +853,10 @@
482                                         ARRAY_SIZE(n810_i2c_board_info_2));
483  
484         omap_serial_init();
485 +
486 +       n8x0_mipid_init();
487 +       n8x0_blizzard_init();
488 +
489         n8x0_onenand_init();
490         n8x0_mmc_init();
491         n8x0_usb_init();
492 Index: linux-2.6.37/arch/arm/mach-omap2/board-n8x0-lcd.c
493 ===================================================================
494 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
495 +++ linux-2.6.37/arch/arm/mach-omap2/board-n8x0-lcd.c   2011-01-28 18:10:37.941647955 +0100
496 @@ -0,0 +1,127 @@
497 +/*
498 + * linux/arch/arm/mach-omap2/board-n8x0.c
499 + *
500 + * Copyright (C) 2005-2009 Nokia Corporation
501 + * Author: Juha Yrjola <juha.yrjola@nokia.com>
502 + *
503 + * Modified from mach-omap2/board-generic.c
504 + *
505 + * This program is free software; you can redistribute it and/or modify
506 + * it under the terms of the GNU General Public License version 2 as
507 + * published by the Free Software Foundation.
508 + */
509 +
510 +#include <linux/clk.h>
511 +#include <linux/delay.h>
512 +#include <linux/gpio.h>
513 +#include <linux/omapfb.h>
514 +
515 +#include <plat/lcd_mipid.h>
516 +#include <plat/blizzard.h>
517 +
518 +#include <../drivers/cbus/tahvo.h>
519 +
520 +#define N8X0_BLIZZARD_POWERDOWN_GPIO   15
521 +
522 +// MIPID LCD Panel
523 +
524 +static void mipid_shutdown(struct mipid_platform_data *pdata)
525 +{
526 +       if (pdata->nreset_gpio != -1) {
527 +               pr_info("shutdown LCD\n");
528 +               gpio_set_value(pdata->nreset_gpio, 0);
529 +               msleep(120);
530 +       }
531 +}
532 +
533 +struct mipid_platform_data n8x0_mipid_platform_data = {
534 +       .shutdown = mipid_shutdown,
535 +};
536 +
537 +void __init n8x0_mipid_init(void)
538 +{
539 +       const struct omap_lcd_config *conf;
540 +
541 +       conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config);
542 +       if (conf != NULL) {
543 +               n8x0_mipid_platform_data.nreset_gpio = conf->nreset_gpio;
544 +               n8x0_mipid_platform_data.data_lines = conf->data_lines;
545 +               printk(KERN_INFO "N8x0 MIPID config loaded");
546 +       }
547 +       else
548 +               printk(KERN_INFO "N8x0 MIPID config not provided");
549 +}
550 +
551 +
552 +// Epson Blizzard LCD Controller
553 +
554 +static struct {
555 +       struct clk *sys_ck;
556 +} blizzard;
557 +
558 +static int blizzard_get_clocks(void)
559 +{
560 +       blizzard.sys_ck = clk_get(0, "osc_ck");
561 +       if (IS_ERR(blizzard.sys_ck)) {
562 +               printk(KERN_ERR "can't get Blizzard clock\n");
563 +               return PTR_ERR(blizzard.sys_ck);
564 +       }
565 +       return 0;
566 +}
567 +
568 +static unsigned long blizzard_get_clock_rate(struct device *dev)
569 +{
570 +       return clk_get_rate(blizzard.sys_ck);
571 +}
572 +
573 +static void blizzard_enable_clocks(int enable)
574 +{
575 +       if (enable)
576 +               clk_enable(blizzard.sys_ck);
577 +       else
578 +               clk_disable(blizzard.sys_ck);
579 +}
580 +
581 +static void blizzard_power_up(struct device *dev)
582 +{
583 +       /* Vcore to 1.475V */
584 +       tahvo_set_clear_reg_bits(0x07, 0, 0xf);
585 +       msleep(10);
586 +
587 +       blizzard_enable_clocks(1);
588 +       gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
589 +}
590 +
591 +static void blizzard_power_down(struct device *dev)
592 +{
593 +       gpio_set_value(N8X0_BLIZZARD_POWERDOWN_GPIO, 0);
594 +       blizzard_enable_clocks(0);
595 +
596 +       /* Vcore to 1.005V */
597 +       tahvo_set_clear_reg_bits(0x07, 0xf, 0);
598 +}
599 +
600 +static struct blizzard_platform_data n8x0_blizzard_data = {
601 +       .power_up       = blizzard_power_up,
602 +       .power_down     = blizzard_power_down,
603 +       .get_clock_rate = blizzard_get_clock_rate,
604 +       .te_connected   = 1,
605 +};
606 +
607 +void __init n8x0_blizzard_init(void)
608 +{
609 +       int r;
610 +
611 +       r = gpio_request(N8X0_BLIZZARD_POWERDOWN_GPIO, "Blizzard pd");
612 +       if (r < 0)
613 +       {
614 +               printk(KERN_ERR "Can't get N8x0 Blizzard powerdown GPIO %d\n", N8X0_BLIZZARD_POWERDOWN_GPIO);
615 +               return;
616 +       }
617 +       gpio_direction_output(N8X0_BLIZZARD_POWERDOWN_GPIO, 1);
618 +
619 +       blizzard_get_clocks();
620 +       omapfb_set_ctrl_platform_data(&n8x0_blizzard_data);
621 +
622 +       printk(KERN_INFO "N8x0 Blizzard initialized");
623 +}
624 Index: linux-2.6.37/arch/arm/mach-omap2/board-n8x0-usb.c
625 ===================================================================
626 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
627 +++ linux-2.6.37/arch/arm/mach-omap2/board-n8x0-usb.c   2011-01-28 18:09:59.378233620 +0100
628 @@ -0,0 +1,175 @@
629 +/*
630 + * linux/arch/arm/mach-omap2/board-n8x0-usb.c
631 + *
632 + * Copyright (C) 2006 Nokia Corporation
633 + * Author: Juha Yrjola
634 + *
635 + * This program is free software; you can redistribute it and/or modify
636 + * it under the terms of the GNU General Public License version 2 as
637 + * published by the Free Software Foundation.
638 + */
639 +
640 +#include <linux/types.h>
641 +#include <linux/delay.h>
642 +#include <linux/platform_device.h>
643 +#include <linux/clk.h>
644 +#include <linux/err.h>
645 +#include <linux/gpio.h>
646 +#include <linux/usb/musb.h>
647 +
648 +#include <plat/gpmc.h>
649 +
650 +#define TUSB_ASYNC_CS          1
651 +#define TUSB_SYNC_CS           4
652 +#define GPIO_TUSB_INT          58
653 +#define GPIO_TUSB_ENABLE       0
654 +
655 +static int tusb_set_power(int state);
656 +static int tusb_set_clock(struct clk *osc_ck, int state);
657 +
658 +#if    defined(CONFIG_USB_MUSB_OTG)
659 +#      define BOARD_MODE       MUSB_OTG
660 +#elif  defined(CONFIG_USB_MUSB_PERIPHERAL)
661 +#      define BOARD_MODE       MUSB_PERIPHERAL
662 +#else  /* defined(CONFIG_USB_MUSB_HOST) */
663 +#      define BOARD_MODE       MUSB_HOST
664 +#endif
665 +
666 +static struct musb_hdrc_eps_bits musb_eps[] = {
667 +       {       "ep1_tx", 5,    },
668 +       {       "ep1_rx", 5,    },
669 +       {       "ep2_tx", 5,    },
670 +       {       "ep2_rx", 5,    },
671 +       {       "ep3_tx", 3,    },
672 +       {       "ep3_rx", 3,    },
673 +       {       "ep4_tx", 3,    },
674 +       {       "ep4_rx", 3,    },
675 +       {       "ep5_tx", 2,    },
676 +       {       "ep5_rx", 2,    },
677 +       {       "ep6_tx", 2,    },
678 +       {       "ep6_rx", 2,    },
679 +       {       "ep7_tx", 2,    },
680 +       {       "ep7_rx", 2,    },
681 +       {       "ep8_tx", 2,    },
682 +       {       "ep8_rx", 2,    },
683 +       {       "ep9_tx", 2,    },
684 +       {       "ep9_rx", 2,    },
685 +       {       "ep10_tx", 2,   },
686 +       {       "ep10_rx", 2,   },
687 +       {       "ep11_tx", 2,   },
688 +       {       "ep11_rx", 2,   },
689 +       {       "ep12_tx", 2,   },
690 +       {       "ep12_rx", 2,   },
691 +       {       "ep13_tx", 2,   },
692 +       {       "ep13_rx", 2,   },
693 +       {       "ep14_tx", 2,   },
694 +       {       "ep14_rx", 2,   },
695 +       {       "ep15_tx", 2,   },
696 +       {       "ep15_rx", 2,   },
697 +};
698 +
699 +static struct musb_hdrc_config musb_config = {
700 +       .multipoint     = 1,
701 +       .dyn_fifo       = 1,
702 +       .soft_con       = 1,
703 +       .dma            = 1,
704 +       .num_eps        = 16,
705 +       .dma_channels   = 7,
706 +       .ram_bits       = 12,
707 +       .eps_bits       = musb_eps,
708 +};
709 +
710 +static struct musb_hdrc_platform_data tusb_data = {
711 +       .mode           = BOARD_MODE,
712 +       .set_power      = tusb_set_power,
713 +       .set_clock      = tusb_set_clock,
714 +       .min_power      = 25,   /* x2 = 50 mA drawn from VBUS as peripheral */
715 +       .power          = 100,  /* Max 100 mA VBUS for host mode */
716 +       .clock          = "osc_ck",
717 +       .config         = &musb_config,
718 +};
719 +
720 +/*
721 + * Enable or disable power to TUSB6010. When enabling, turn on 3.3 V and
722 + * 1.5 V voltage regulators of PM companion chip. Companion chip will then
723 + * provide then PGOOD signal to TUSB6010 which will release it from reset.
724 + */
725 +static int tusb_set_power(int state)
726 +{
727 +       int i, retval = 0;
728 +
729 +       if (state) {
730 +               gpio_set_value(GPIO_TUSB_ENABLE, 1);
731 +               msleep(1);
732 +
733 +               /* Wait until TUSB6010 pulls INT pin down */
734 +               i = 100;
735 +               while (i && gpio_get_value(GPIO_TUSB_INT)) {
736 +                       msleep(1);
737 +                       i--;
738 +               }
739 +
740 +               if (!i) {
741 +                       printk(KERN_ERR "tusb: powerup failed\n");
742 +                       retval = -ENODEV;
743 +               }
744 +       } else {
745 +               gpio_set_value(GPIO_TUSB_ENABLE, 0);
746 +               msleep(10);
747 +       }
748 +
749 +       return retval;
750 +}
751 +
752 +static int             osc_ck_on;
753 +
754 +static int tusb_set_clock(struct clk *osc_ck, int state)
755 +{
756 +       if (state) {
757 +               if (osc_ck_on > 0)
758 +                       return -ENODEV;
759 +
760 +               //omap2_block_sleep();
761 +               clk_enable(osc_ck);
762 +               osc_ck_on = 1;
763 +       } else {
764 +               if (osc_ck_on == 0)
765 +                       return -ENODEV;
766 +
767 +               clk_disable(osc_ck);
768 +               osc_ck_on = 0;
769 +               //omap2_allow_sleep();
770 +       }
771 +
772 +       return 0;
773 +}
774 +
775 +void __init n8x0_usb_init(void)
776 +{
777 +       int ret = 0;
778 +       static char     announce[] __initdata = KERN_INFO "TUSB 6010\n";
779 +
780 +       /* PM companion chip power control pin */
781 +       ret = gpio_request(GPIO_TUSB_ENABLE, "TUSB6010 enable");
782 +       if (ret != 0) {
783 +               printk(KERN_ERR "Could not get TUSB power GPIO%i\n",
784 +                      GPIO_TUSB_ENABLE);
785 +               return;
786 +       }
787 +       gpio_direction_output(GPIO_TUSB_ENABLE, 0);
788 +
789 +       tusb_set_power(0);
790 +
791 +       ret = tusb6010_setup_interface(&tusb_data, TUSB6010_REFCLK_19, 2,
792 +                                       TUSB_ASYNC_CS, TUSB_SYNC_CS,
793 +                                       GPIO_TUSB_INT, 0x3f);
794 +       if (ret != 0)
795 +               goto err;
796 +
797 +       printk(announce);
798 +
799 +       return;
800 +
801 +err:
802 +       gpio_free(GPIO_TUSB_ENABLE);
803 +}
804 Index: linux-2.6.37/arch/arm/mach-omap2/control.c
805 ===================================================================
806 --- linux-2.6.37.orig/arch/arm/mach-omap2/control.c     2011-01-05 01:50:19.000000000 +0100
807 +++ linux-2.6.37/arch/arm/mach-omap2/control.c  2011-01-28 18:09:59.378233620 +0100
808 @@ -172,6 +172,7 @@
809         return __raw_readw(OMAP_CTRL_REGADDR(offset));
810  }
811  
812 +EXPORT_SYMBOL_GPL(omap_ctrl_readl);
813  u32 omap_ctrl_readl(u16 offset)
814  {
815         return __raw_readl(OMAP_CTRL_REGADDR(offset));
816 @@ -187,6 +188,7 @@
817         __raw_writew(val, OMAP_CTRL_REGADDR(offset));
818  }
819  
820 +EXPORT_SYMBOL_GPL(omap_ctrl_writel);
821  void omap_ctrl_writel(u32 val, u16 offset)
822  {
823         __raw_writel(val, OMAP_CTRL_REGADDR(offset));
824 Index: linux-2.6.37/arch/arm/mach-omap2/Kconfig
825 ===================================================================
826 --- linux-2.6.37.orig/arch/arm/mach-omap2/Kconfig       2011-01-05 01:50:19.000000000 +0100
827 +++ linux-2.6.37/arch/arm/mach-omap2/Kconfig    2011-01-28 18:09:59.378233620 +0100
828 @@ -210,6 +210,16 @@
829         select MACH_NOKIA_N810
830         select MACH_NOKIA_N810_WIMAX
831  
832 +config MACH_NOKIA_N8X0_LCD
833 +       bool
834 +       depends on MACH_NOKIA_N8X0 && FB_OMAP_LCDC_BLIZZARD && FB_OMAP_LCD_MIPID
835 +       default y
836 +
837 +config MACH_NOKIA_N8X0_USB
838 +       bool
839 +       depends on MACH_NOKIA_N8X0 && MACH_OMAP2_TUSB6010
840 +       default y
841 +
842  config MACH_NOKIA_RX51
843         bool "Nokia RX-51 board"
844         depends on ARCH_OMAP3
845 Index: linux-2.6.37/arch/arm/mach-omap2/Makefile
846 ===================================================================
847 --- linux-2.6.37.orig/arch/arm/mach-omap2/Makefile      2011-01-05 01:50:19.000000000 +0100
848 +++ linux-2.6.37/arch/arm/mach-omap2/Makefile   2011-01-28 18:09:59.378233620 +0100
849 @@ -139,6 +139,8 @@
850                                            hsmmc.o \
851                                            board-flash.o
852  obj-$(CONFIG_MACH_NOKIA_N8X0)          += board-n8x0.o
853 +obj-$(CONFIG_MACH_NOKIA_N8X0_LCD)      += board-n8x0-lcd.o
854 +obj-$(CONFIG_MACH_NOKIA_N8X0_USB)      += board-n8x0-usb.o
855  obj-$(CONFIG_MACH_NOKIA_RX51)          += board-rx51.o \
856                                            board-rx51-sdram.o \
857                                            board-rx51-peripherals.o \