OMAP3: PM: Ensure MUSB block can idle when driver not loaded
[linux-ginger.git] / arch / arm / mach-pxa / palmtx.c
blobe2d44b1a8a9b9111c3daeb2f06ba6c682dc224e8
1 /*
2 * Hardware definitions for PalmTX
4 * Author: Marek Vasut <marek.vasut@gmail.com>
6 * Based on work of:
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
10 * Michal Hrusecky
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * (find more info at www.hackndev.com)
20 #include <linux/platform_device.h>
21 #include <linux/delay.h>
22 #include <linux/irq.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/input.h>
25 #include <linux/pda_power.h>
26 #include <linux/pwm_backlight.h>
27 #include <linux/gpio.h>
28 #include <linux/wm97xx_batt.h>
29 #include <linux/power_supply.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <mach/pxa27x.h>
36 #include <mach/audio.h>
37 #include <mach/palmtx.h>
38 #include <mach/mmc.h>
39 #include <mach/pxafb.h>
40 #include <mach/irda.h>
41 #include <mach/pxa27x_keypad.h>
42 #include <mach/udc.h>
43 #include <mach/palmasoc.h>
45 #include "generic.h"
46 #include "devices.h"
48 /******************************************************************************
49 * Pin configuration
50 ******************************************************************************/
51 static unsigned long palmtx_pin_config[] __initdata = {
52 /* MMC */
53 GPIO32_MMC_CLK,
54 GPIO92_MMC_DAT_0,
55 GPIO109_MMC_DAT_1,
56 GPIO110_MMC_DAT_2,
57 GPIO111_MMC_DAT_3,
58 GPIO112_MMC_CMD,
59 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO115_GPIO, /* SD r/o switch */
63 /* AC97 */
64 GPIO28_AC97_BITCLK,
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
67 GPIO31_AC97_SYNC,
68 GPIO95_AC97_nRESET,
70 /* IrDA */
71 GPIO40_GPIO, /* ir disable */
72 GPIO46_FICP_RXD,
73 GPIO47_FICP_TXD,
75 /* PWM */
76 GPIO16_PWM0_OUT,
78 /* USB */
79 GPIO13_GPIO, /* usb detect */
80 GPIO93_GPIO, /* usb power */
82 /* PCMCIA */
83 GPIO48_nPOE,
84 GPIO49_nPWE,
85 GPIO50_nPIOR,
86 GPIO51_nPIOW,
87 GPIO85_nPCE_1,
88 GPIO54_nPCE_2,
89 GPIO79_PSKTSEL,
90 GPIO55_nPREG,
91 GPIO56_nPWAIT,
92 GPIO57_nIOIS16,
93 GPIO94_GPIO, /* wifi power 1 */
94 GPIO108_GPIO, /* wifi power 2 */
95 GPIO116_GPIO, /* wifi ready */
97 /* MATRIX KEYPAD */
98 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
99 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
100 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
101 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
102 GPIO103_KP_MKOUT_0,
103 GPIO104_KP_MKOUT_1,
104 GPIO105_KP_MKOUT_2,
106 /* LCD */
107 GPIO58_LCD_LDD_0,
108 GPIO59_LCD_LDD_1,
109 GPIO60_LCD_LDD_2,
110 GPIO61_LCD_LDD_3,
111 GPIO62_LCD_LDD_4,
112 GPIO63_LCD_LDD_5,
113 GPIO64_LCD_LDD_6,
114 GPIO65_LCD_LDD_7,
115 GPIO66_LCD_LDD_8,
116 GPIO67_LCD_LDD_9,
117 GPIO68_LCD_LDD_10,
118 GPIO69_LCD_LDD_11,
119 GPIO70_LCD_LDD_12,
120 GPIO71_LCD_LDD_13,
121 GPIO72_LCD_LDD_14,
122 GPIO73_LCD_LDD_15,
123 GPIO74_LCD_FCLK,
124 GPIO75_LCD_LCLK,
125 GPIO76_LCD_PCLK,
126 GPIO77_LCD_BIAS,
128 /* MISC. */
129 GPIO10_GPIO, /* hotsync button */
130 GPIO12_GPIO, /* power detect */
131 GPIO107_GPIO, /* earphone detect */
134 /******************************************************************************
135 * SD/MMC card controller
136 ******************************************************************************/
137 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
138 void *data)
140 int err = 0;
142 /* Setup an interrupt for detecting card insert/remove events */
143 err = gpio_request(GPIO_NR_PALMTX_SD_DETECT_N, "SD IRQ");
144 if (err)
145 goto err;
146 err = gpio_direction_input(GPIO_NR_PALMTX_SD_DETECT_N);
147 if (err)
148 goto err2;
149 err = request_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N),
150 palmtx_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
151 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
152 "SD/MMC card detect", data);
153 if (err) {
154 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
155 __func__);
156 goto err2;
159 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
160 if (err)
161 goto err3;
162 err = gpio_direction_output(GPIO_NR_PALMTX_SD_POWER, 0);
163 if (err)
164 goto err4;
166 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
167 if (err)
168 goto err4;
169 err = gpio_direction_input(GPIO_NR_PALMTX_SD_READONLY);
170 if (err)
171 goto err5;
173 printk(KERN_DEBUG "%s: irq registered\n", __func__);
175 return 0;
177 err5:
178 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
179 err4:
180 gpio_free(GPIO_NR_PALMTX_SD_POWER);
181 err3:
182 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
183 err2:
184 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
185 err:
186 return err;
189 static void palmtx_mci_exit(struct device *dev, void *data)
191 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
192 gpio_free(GPIO_NR_PALMTX_SD_POWER);
193 free_irq(gpio_to_irq(GPIO_NR_PALMTX_SD_DETECT_N), data);
194 gpio_free(GPIO_NR_PALMTX_SD_DETECT_N);
197 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
199 struct pxamci_platform_data *p_d = dev->platform_data;
200 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
203 static int palmtx_mci_get_ro(struct device *dev)
205 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
208 static struct pxamci_platform_data palmtx_mci_platform_data = {
209 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
210 .setpower = palmtx_mci_power,
211 .get_ro = palmtx_mci_get_ro,
212 .init = palmtx_mci_init,
213 .exit = palmtx_mci_exit,
216 /******************************************************************************
217 * GPIO keyboard
218 ******************************************************************************/
219 static unsigned int palmtx_matrix_keys[] = {
220 KEY(0, 0, KEY_POWER),
221 KEY(0, 1, KEY_F1),
222 KEY(0, 2, KEY_ENTER),
224 KEY(1, 0, KEY_F2),
225 KEY(1, 1, KEY_F3),
226 KEY(1, 2, KEY_F4),
228 KEY(2, 0, KEY_UP),
229 KEY(2, 2, KEY_DOWN),
231 KEY(3, 0, KEY_RIGHT),
232 KEY(3, 2, KEY_LEFT),
235 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
236 .matrix_key_rows = 4,
237 .matrix_key_cols = 3,
238 .matrix_key_map = palmtx_matrix_keys,
239 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
241 .debounce_interval = 30,
244 /******************************************************************************
245 * GPIO keys
246 ******************************************************************************/
247 static struct gpio_keys_button palmtx_pxa_buttons[] = {
248 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
251 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
252 .buttons = palmtx_pxa_buttons,
253 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
256 static struct platform_device palmtx_pxa_keys = {
257 .name = "gpio-keys",
258 .id = -1,
259 .dev = {
260 .platform_data = &palmtx_pxa_keys_data,
264 /******************************************************************************
265 * Backlight
266 ******************************************************************************/
267 static int palmtx_backlight_init(struct device *dev)
269 int ret;
271 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
272 if (ret)
273 goto err;
274 ret = gpio_direction_output(GPIO_NR_PALMTX_BL_POWER, 0);
275 if (ret)
276 goto err2;
277 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
278 if (ret)
279 goto err2;
280 ret = gpio_direction_output(GPIO_NR_PALMTX_LCD_POWER, 0);
281 if (ret)
282 goto err3;
284 return 0;
285 err3:
286 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
287 err2:
288 gpio_free(GPIO_NR_PALMTX_BL_POWER);
289 err:
290 return ret;
293 static int palmtx_backlight_notify(int brightness)
295 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
296 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
297 return brightness;
300 static void palmtx_backlight_exit(struct device *dev)
302 gpio_free(GPIO_NR_PALMTX_BL_POWER);
303 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
306 static struct platform_pwm_backlight_data palmtx_backlight_data = {
307 .pwm_id = 0,
308 .max_brightness = PALMTX_MAX_INTENSITY,
309 .dft_brightness = PALMTX_MAX_INTENSITY,
310 .pwm_period_ns = PALMTX_PERIOD_NS,
311 .init = palmtx_backlight_init,
312 .notify = palmtx_backlight_notify,
313 .exit = palmtx_backlight_exit,
316 static struct platform_device palmtx_backlight = {
317 .name = "pwm-backlight",
318 .dev = {
319 .parent = &pxa27x_device_pwm0.dev,
320 .platform_data = &palmtx_backlight_data,
324 /******************************************************************************
325 * IrDA
326 ******************************************************************************/
327 static int palmtx_irda_startup(struct device *dev)
329 int err;
330 err = gpio_request(GPIO_NR_PALMTX_IR_DISABLE, "IR DISABLE");
331 if (err)
332 goto err;
333 err = gpio_direction_output(GPIO_NR_PALMTX_IR_DISABLE, 1);
334 if (err)
335 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
336 err:
337 return err;
340 static void palmtx_irda_shutdown(struct device *dev)
342 gpio_free(GPIO_NR_PALMTX_IR_DISABLE);
345 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
347 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
348 pxa2xx_transceiver_mode(dev, mode);
351 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
352 .startup = palmtx_irda_startup,
353 .shutdown = palmtx_irda_shutdown,
354 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
355 .transceiver_mode = palmtx_irda_transceiver_mode,
358 /******************************************************************************
359 * UDC
360 ******************************************************************************/
361 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
362 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
363 .gpio_vbus_inverted = 1,
364 .gpio_pullup = GPIO_NR_PALMTX_USB_PULLUP,
365 .gpio_pullup_inverted = 0,
368 /******************************************************************************
369 * Power supply
370 ******************************************************************************/
371 static int power_supply_init(struct device *dev)
373 int ret;
375 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
376 if (ret)
377 goto err1;
378 ret = gpio_direction_input(GPIO_NR_PALMTX_POWER_DETECT);
379 if (ret)
380 goto err2;
382 return 0;
384 err2:
385 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
386 err1:
387 return ret;
390 static int palmtx_is_ac_online(void)
392 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
395 static void power_supply_exit(struct device *dev)
397 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
400 static char *palmtx_supplicants[] = {
401 "main-battery",
404 static struct pda_power_pdata power_supply_info = {
405 .init = power_supply_init,
406 .is_ac_online = palmtx_is_ac_online,
407 .exit = power_supply_exit,
408 .supplied_to = palmtx_supplicants,
409 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
412 static struct platform_device power_supply = {
413 .name = "pda-power",
414 .id = -1,
415 .dev = {
416 .platform_data = &power_supply_info,
420 /******************************************************************************
421 * WM97xx battery
422 ******************************************************************************/
423 static struct wm97xx_batt_info wm97xx_batt_pdata = {
424 .batt_aux = WM97XX_AUX_ID3,
425 .temp_aux = WM97XX_AUX_ID2,
426 .charge_gpio = -1,
427 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
428 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
429 .batt_mult = 1000,
430 .batt_div = 414,
431 .temp_mult = 1,
432 .temp_div = 1,
433 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
434 .batt_name = "main-batt",
437 /******************************************************************************
438 * aSoC audio
439 ******************************************************************************/
440 static struct palm27x_asoc_info palmtx_asoc_pdata = {
441 .jack_gpio = GPIO_NR_PALMTX_EARPHONE_DETECT,
444 static pxa2xx_audio_ops_t palmtx_ac97_pdata = {
445 .reset_gpio = 95,
448 static struct platform_device palmtx_asoc = {
449 .name = "palm27x-asoc",
450 .id = -1,
451 .dev = {
452 .platform_data = &palmtx_asoc_pdata,
456 /******************************************************************************
457 * Framebuffer
458 ******************************************************************************/
459 static struct pxafb_mode_info palmtx_lcd_modes[] = {
461 .pixclock = 57692,
462 .xres = 320,
463 .yres = 480,
464 .bpp = 16,
466 .left_margin = 32,
467 .right_margin = 1,
468 .upper_margin = 7,
469 .lower_margin = 1,
471 .hsync_len = 4,
472 .vsync_len = 1,
476 static struct pxafb_mach_info palmtx_lcd_screen = {
477 .modes = palmtx_lcd_modes,
478 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
479 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
482 /******************************************************************************
483 * Power management - standby
484 ******************************************************************************/
485 #ifdef CONFIG_PM
486 static u32 *addr __initdata;
487 static u32 resume[3] __initdata = {
488 0xe3a00101, /* mov r0, #0x40000000 */
489 0xe380060f, /* orr r0, r0, #0x00f00000 */
490 0xe590f008, /* ldr pc, [r0, #0x08] */
493 static int __init palmtx_pm_init(void)
495 int i;
497 /* this is where the bootloader jumps */
498 addr = phys_to_virt(PALMTX_STR_BASE);
500 for (i = 0; i < 3; i++)
501 addr[i] = resume[i];
503 return 0;
506 device_initcall(palmtx_pm_init);
507 #endif
509 /******************************************************************************
510 * Machine init
511 ******************************************************************************/
512 static struct platform_device *devices[] __initdata = {
513 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
514 &palmtx_pxa_keys,
515 #endif
516 &palmtx_backlight,
517 &power_supply,
518 &palmtx_asoc,
521 static struct map_desc palmtx_io_desc[] __initdata = {
523 .virtual = PALMTX_PCMCIA_VIRT,
524 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
525 .length = PALMTX_PCMCIA_SIZE,
526 .type = MT_DEVICE
530 static void __init palmtx_map_io(void)
532 pxa_map_io();
533 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
536 /* setup udc GPIOs initial state */
537 static void __init palmtx_udc_init(void)
539 if (!gpio_request(GPIO_NR_PALMTX_USB_PULLUP, "UDC Vbus")) {
540 gpio_direction_output(GPIO_NR_PALMTX_USB_PULLUP, 1);
541 gpio_free(GPIO_NR_PALMTX_USB_PULLUP);
546 static void __init palmtx_init(void)
548 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
550 set_pxa_fb_info(&palmtx_lcd_screen);
551 pxa_set_mci_info(&palmtx_mci_platform_data);
552 palmtx_udc_init();
553 pxa_set_ac97_info(&palmtx_ac97_pdata);
554 pxa_set_udc_info(&palmtx_udc_info);
555 pxa_set_ficp_info(&palmtx_ficp_platform_data);
556 pxa_set_keypad_info(&palmtx_keypad_platform_data);
557 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
559 platform_add_devices(devices, ARRAY_SIZE(devices));
562 MACHINE_START(PALMTX, "Palm T|X")
563 .phys_io = PALMTX_PHYS_IO_START,
564 .io_pg_offst = io_p2v(0x40000000),
565 .boot_params = 0xa0000100,
566 .map_io = palmtx_map_io,
567 .init_irq = pxa27x_init_irq,
568 .timer = &pxa_timer,
569 .init_machine = palmtx_init
570 MACHINE_END