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