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