2 * Hardware definitions for Palm Tungsten|T5
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Ales Snuparek <snuparek@atlas.cz>
8 * Justin Kendrick <twilightsentry@gmail.com>
9 * RichardT5 <richard_t5@users.sourceforge.net>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * (find more info at www.hackndev.com)
19 #include <linux/platform_device.h>
20 #include <linux/delay.h>
21 #include <linux/irq.h>
22 #include <linux/gpio_keys.h>
23 #include <linux/input.h>
24 #include <linux/pda_power.h>
25 #include <linux/pwm_backlight.h>
26 #include <linux/gpio.h>
27 #include <linux/wm97xx_batt.h>
28 #include <linux/power_supply.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <mach/audio.h>
35 #include <mach/palmt5.h>
37 #include <mach/pxafb.h>
38 #include <mach/pxa-regs.h>
39 #include <mach/mfp-pxa27x.h>
40 #include <mach/irda.h>
41 #include <mach/pxa27x_keypad.h>
43 #include <mach/palmasoc.h>
48 /******************************************************************************
50 ******************************************************************************/
51 static unsigned long palmt5_pin_config[] __initdata = {
59 GPIO14_GPIO, /* SD detect */
60 GPIO114_GPIO, /* SD power */
61 GPIO115_GPIO, /* SD r/o switch */
65 GPIO29_AC97_SDATA_IN_0,
66 GPIO30_AC97_SDATA_OUT,
70 GPIO40_GPIO, /* ir disable */
75 GPIO15_GPIO, /* usb detect */
76 GPIO95_GPIO, /* usb power */
113 GPIO10_GPIO, /* hotsync button */
114 GPIO90_GPIO, /* power detect */
115 GPIO107_GPIO, /* earphone detect */
118 /******************************************************************************
119 * SD/MMC card controller
120 ******************************************************************************/
121 static int palmt5_mci_init(struct device *dev, irq_handler_t palmt5_detect_int,
126 /* Setup an interrupt for detecting card insert/remove events */
127 err = gpio_request(GPIO_NR_PALMT5_SD_DETECT_N, "SD IRQ");
130 err = gpio_direction_input(GPIO_NR_PALMT5_SD_DETECT_N);
133 err = request_irq(gpio_to_irq(GPIO_NR_PALMT5_SD_DETECT_N),
134 palmt5_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
135 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
136 "SD/MMC card detect", data);
138 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
143 err = gpio_request(GPIO_NR_PALMT5_SD_POWER, "SD_POWER");
146 err = gpio_direction_output(GPIO_NR_PALMT5_SD_POWER, 0);
150 err = gpio_request(GPIO_NR_PALMT5_SD_READONLY, "SD_READONLY");
153 err = gpio_direction_input(GPIO_NR_PALMT5_SD_READONLY);
157 printk(KERN_DEBUG "%s: irq registered\n", __func__);
162 gpio_free(GPIO_NR_PALMT5_SD_READONLY);
164 gpio_free(GPIO_NR_PALMT5_SD_POWER);
166 free_irq(gpio_to_irq(GPIO_NR_PALMT5_SD_DETECT_N), data);
168 gpio_free(GPIO_NR_PALMT5_SD_DETECT_N);
173 static void palmt5_mci_exit(struct device *dev, void *data)
175 gpio_free(GPIO_NR_PALMT5_SD_READONLY);
176 gpio_free(GPIO_NR_PALMT5_SD_POWER);
177 free_irq(IRQ_GPIO_PALMT5_SD_DETECT_N, data);
178 gpio_free(GPIO_NR_PALMT5_SD_DETECT_N);
181 static void palmt5_mci_power(struct device *dev, unsigned int vdd)
183 struct pxamci_platform_data *p_d = dev->platform_data;
184 gpio_set_value(GPIO_NR_PALMT5_SD_POWER, p_d->ocr_mask & (1 << vdd));
187 static int palmt5_mci_get_ro(struct device *dev)
189 return gpio_get_value(GPIO_NR_PALMT5_SD_READONLY);
192 static struct pxamci_platform_data palmt5_mci_platform_data = {
193 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
194 .setpower = palmt5_mci_power,
195 .get_ro = palmt5_mci_get_ro,
196 .init = palmt5_mci_init,
197 .exit = palmt5_mci_exit,
200 /******************************************************************************
202 ******************************************************************************/
203 static unsigned int palmt5_matrix_keys[] = {
204 KEY(0, 0, KEY_POWER),
206 KEY(0, 2, KEY_ENTER),
215 KEY(3, 0, KEY_RIGHT),
219 static struct pxa27x_keypad_platform_data palmt5_keypad_platform_data = {
220 .matrix_key_rows = 4,
221 .matrix_key_cols = 3,
222 .matrix_key_map = palmt5_matrix_keys,
223 .matrix_key_map_size = ARRAY_SIZE(palmt5_matrix_keys),
225 .debounce_interval = 30,
228 /******************************************************************************
230 ******************************************************************************/
231 static struct gpio_keys_button palmt5_pxa_buttons[] = {
232 {KEY_F8, GPIO_NR_PALMT5_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
235 static struct gpio_keys_platform_data palmt5_pxa_keys_data = {
236 .buttons = palmt5_pxa_buttons,
237 .nbuttons = ARRAY_SIZE(palmt5_pxa_buttons),
240 static struct platform_device palmt5_pxa_keys = {
244 .platform_data = &palmt5_pxa_keys_data,
248 /******************************************************************************
250 ******************************************************************************/
251 static int palmt5_backlight_init(struct device *dev)
255 ret = gpio_request(GPIO_NR_PALMT5_BL_POWER, "BL POWER");
258 ret = gpio_direction_output(GPIO_NR_PALMT5_BL_POWER, 0);
261 ret = gpio_request(GPIO_NR_PALMT5_LCD_POWER, "LCD POWER");
264 ret = gpio_direction_output(GPIO_NR_PALMT5_LCD_POWER, 0);
270 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
272 gpio_free(GPIO_NR_PALMT5_BL_POWER);
277 static int palmt5_backlight_notify(int brightness)
279 gpio_set_value(GPIO_NR_PALMT5_BL_POWER, brightness);
280 gpio_set_value(GPIO_NR_PALMT5_LCD_POWER, brightness);
284 static void palmt5_backlight_exit(struct device *dev)
286 gpio_free(GPIO_NR_PALMT5_BL_POWER);
287 gpio_free(GPIO_NR_PALMT5_LCD_POWER);
290 static struct platform_pwm_backlight_data palmt5_backlight_data = {
292 .max_brightness = PALMT5_MAX_INTENSITY,
293 .dft_brightness = PALMT5_MAX_INTENSITY,
294 .pwm_period_ns = PALMT5_PERIOD_NS,
295 .init = palmt5_backlight_init,
296 .notify = palmt5_backlight_notify,
297 .exit = palmt5_backlight_exit,
300 static struct platform_device palmt5_backlight = {
301 .name = "pwm-backlight",
303 .parent = &pxa27x_device_pwm0.dev,
304 .platform_data = &palmt5_backlight_data,
308 /******************************************************************************
310 ******************************************************************************/
311 static int palmt5_irda_startup(struct device *dev)
314 err = gpio_request(GPIO_NR_PALMT5_IR_DISABLE, "IR DISABLE");
317 err = gpio_direction_output(GPIO_NR_PALMT5_IR_DISABLE, 1);
319 gpio_free(GPIO_NR_PALMT5_IR_DISABLE);
324 static void palmt5_irda_shutdown(struct device *dev)
326 gpio_free(GPIO_NR_PALMT5_IR_DISABLE);
329 static void palmt5_irda_transceiver_mode(struct device *dev, int mode)
331 gpio_set_value(GPIO_NR_PALMT5_IR_DISABLE, mode & IR_OFF);
332 pxa2xx_transceiver_mode(dev, mode);
335 static struct pxaficp_platform_data palmt5_ficp_platform_data = {
336 .startup = palmt5_irda_startup,
337 .shutdown = palmt5_irda_shutdown,
338 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
339 .transceiver_mode = palmt5_irda_transceiver_mode,
342 /******************************************************************************
344 ******************************************************************************/
345 static struct pxa2xx_udc_mach_info palmt5_udc_info __initdata = {
346 .gpio_vbus = GPIO_NR_PALMT5_USB_DETECT_N,
347 .gpio_vbus_inverted = 1,
348 .gpio_pullup = GPIO_NR_PALMT5_USB_POWER,
349 .gpio_pullup_inverted = 0,
352 /******************************************************************************
354 ******************************************************************************/
355 static int power_supply_init(struct device *dev)
359 ret = gpio_request(GPIO_NR_PALMT5_POWER_DETECT, "CABLE_STATE_AC");
362 ret = gpio_direction_input(GPIO_NR_PALMT5_POWER_DETECT);
368 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
373 static int palmt5_is_ac_online(void)
375 return gpio_get_value(GPIO_NR_PALMT5_POWER_DETECT);
378 static void power_supply_exit(struct device *dev)
380 gpio_free(GPIO_NR_PALMT5_POWER_DETECT);
383 static char *palmt5_supplicants[] = {
387 static struct pda_power_pdata power_supply_info = {
388 .init = power_supply_init,
389 .is_ac_online = palmt5_is_ac_online,
390 .exit = power_supply_exit,
391 .supplied_to = palmt5_supplicants,
392 .num_supplicants = ARRAY_SIZE(palmt5_supplicants),
395 static struct platform_device power_supply = {
399 .platform_data = &power_supply_info,
403 /******************************************************************************
405 ******************************************************************************/
406 static struct wm97xx_batt_info wm97xx_batt_pdata = {
407 .batt_aux = WM97XX_AUX_ID3,
408 .temp_aux = WM97XX_AUX_ID2,
410 .max_voltage = PALMT5_BAT_MAX_VOLTAGE,
411 .min_voltage = PALMT5_BAT_MIN_VOLTAGE,
416 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
417 .batt_name = "main-batt",
420 /******************************************************************************
422 ******************************************************************************/
423 static struct palm27x_asoc_info palm27x_asoc_pdata = {
424 .jack_gpio = GPIO_NR_PALMT5_EARPHONE_DETECT,
427 /******************************************************************************
429 ******************************************************************************/
430 static struct pxafb_mode_info palmt5_lcd_modes[] = {
447 static struct pxafb_mach_info palmt5_lcd_screen = {
448 .modes = palmt5_lcd_modes,
449 .num_modes = ARRAY_SIZE(palmt5_lcd_modes),
450 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
453 /******************************************************************************
455 ******************************************************************************/
456 static struct platform_device *devices[] __initdata = {
457 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
464 /* setup udc GPIOs initial state */
465 static void __init palmt5_udc_init(void)
467 if (!gpio_request(GPIO_NR_PALMT5_USB_POWER, "UDC Vbus")) {
468 gpio_direction_output(GPIO_NR_PALMT5_USB_POWER, 1);
469 gpio_free(GPIO_NR_PALMT5_USB_POWER);
473 static void __init palmt5_init(void)
475 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config));
477 set_pxa_fb_info(&palmt5_lcd_screen);
478 pxa_set_mci_info(&palmt5_mci_platform_data);
480 pxa_set_udc_info(&palmt5_udc_info);
481 pxa_set_ac97_info(NULL);
482 pxa_set_ficp_info(&palmt5_ficp_platform_data);
483 pxa_set_keypad_info(&palmt5_keypad_platform_data);
484 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
485 palm27x_asoc_set_pdata(&palm27x_asoc_pdata);
486 platform_add_devices(devices, ARRAY_SIZE(devices));
489 MACHINE_START(PALMT5, "Palm Tungsten|T5")
490 .phys_io = PALMT5_PHYS_IO_START,
491 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
492 .boot_params = 0xa0000100,
493 .map_io = pxa_map_io,
494 .init_irq = pxa27x_init_irq,
496 .init_machine = palmt5_init