2 * Hardware definitions for Palm Tungsten|E2
5 * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
7 * Rewrite for mainline:
8 * Marek Vasut <marek.vasut@gmail.com>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * (find more info at www.hackndev.com)
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/irq.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/pda_power.h>
24 #include <linux/pwm_backlight.h>
25 #include <linux/gpio.h>
26 #include <linux/wm97xx_batt.h>
27 #include <linux/power_supply.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
33 #include <mach/audio.h>
34 #include <mach/palmte2.h>
36 #include <mach/pxafb.h>
37 #include <mach/mfp-pxa25x.h>
38 #include <mach/irda.h>
44 /******************************************************************************
46 ******************************************************************************/
47 static unsigned long palmte2_pin_config
[] __initdata
= {
51 GPIO10_GPIO
, /* SD detect */
52 GPIO55_GPIO
, /* SD power */
53 GPIO51_GPIO
, /* SD r/o switch */
57 GPIO29_AC97_SDATA_IN_0
,
58 GPIO30_AC97_SDATA_OUT
,
65 GPIO15_GPIO
, /* usb detect */
66 GPIO53_GPIO
, /* usb power */
69 GPIO48_GPIO
, /* ir disable */
96 GPIO5_GPIO
, /* notes */
97 GPIO7_GPIO
, /* tasks */
98 GPIO11_GPIO
, /* calendar */
99 GPIO13_GPIO
, /* contacts */
100 GPIO14_GPIO
, /* center */
101 GPIO19_GPIO
, /* left */
102 GPIO20_GPIO
, /* right */
103 GPIO21_GPIO
, /* down */
104 GPIO22_GPIO
, /* up */
107 GPIO1_RST
, /* reset */
108 GPIO4_GPIO
, /* Hotsync button */
109 GPIO9_GPIO
, /* power detect */
110 GPIO37_GPIO
, /* LCD power */
111 GPIO56_GPIO
, /* Backlight power */
114 /******************************************************************************
115 * SD/MMC card controller
116 ******************************************************************************/
117 static int palmte2_mci_init(struct device
*dev
,
118 irq_handler_t palmte2_detect_int
, void *data
)
122 /* Setup an interrupt for detecting card insert/remove events */
123 err
= gpio_request(GPIO_NR_PALMTE2_SD_DETECT_N
, "SD IRQ");
126 err
= gpio_direction_input(GPIO_NR_PALMTE2_SD_DETECT_N
);
129 err
= request_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N
),
130 palmte2_detect_int
, IRQF_DISABLED
| IRQF_SAMPLE_RANDOM
|
131 IRQF_TRIGGER_FALLING
| IRQF_TRIGGER_RISING
,
132 "SD/MMC card detect", data
);
134 printk(KERN_ERR
"%s: cannot request SD/MMC card detect IRQ\n",
139 err
= gpio_request(GPIO_NR_PALMTE2_SD_POWER
, "SD_POWER");
142 err
= gpio_direction_output(GPIO_NR_PALMTE2_SD_POWER
, 0);
146 err
= gpio_request(GPIO_NR_PALMTE2_SD_READONLY
, "SD_READONLY");
149 err
= gpio_direction_input(GPIO_NR_PALMTE2_SD_READONLY
);
153 printk(KERN_DEBUG
"%s: irq registered\n", __func__
);
158 gpio_free(GPIO_NR_PALMTE2_SD_READONLY
);
160 gpio_free(GPIO_NR_PALMTE2_SD_POWER
);
162 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N
), data
);
164 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N
);
169 static void palmte2_mci_exit(struct device
*dev
, void *data
)
171 gpio_free(GPIO_NR_PALMTE2_SD_READONLY
);
172 gpio_free(GPIO_NR_PALMTE2_SD_POWER
);
173 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N
), data
);
174 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N
);
177 static void palmte2_mci_power(struct device
*dev
, unsigned int vdd
)
179 struct pxamci_platform_data
*p_d
= dev
->platform_data
;
180 gpio_set_value(GPIO_NR_PALMTE2_SD_POWER
, p_d
->ocr_mask
& (1 << vdd
));
183 static int palmte2_mci_get_ro(struct device
*dev
)
185 return gpio_get_value(GPIO_NR_PALMTE2_SD_READONLY
);
188 static struct pxamci_platform_data palmte2_mci_platform_data
= {
189 .ocr_mask
= MMC_VDD_32_33
| MMC_VDD_33_34
,
190 .setpower
= palmte2_mci_power
,
191 .get_ro
= palmte2_mci_get_ro
,
192 .init
= palmte2_mci_init
,
193 .exit
= palmte2_mci_exit
,
196 /******************************************************************************
198 ******************************************************************************/
199 static struct gpio_keys_button palmte2_pxa_buttons
[] = {
200 {KEY_F1
, GPIO_NR_PALMTE2_KEY_CONTACTS
, 1, "Contacts" },
201 {KEY_F2
, GPIO_NR_PALMTE2_KEY_CALENDAR
, 1, "Calendar" },
202 {KEY_F3
, GPIO_NR_PALMTE2_KEY_TASKS
, 1, "Tasks" },
203 {KEY_F4
, GPIO_NR_PALMTE2_KEY_NOTES
, 1, "Notes" },
204 {KEY_ENTER
, GPIO_NR_PALMTE2_KEY_CENTER
, 1, "Center" },
205 {KEY_LEFT
, GPIO_NR_PALMTE2_KEY_LEFT
, 1, "Left" },
206 {KEY_RIGHT
, GPIO_NR_PALMTE2_KEY_RIGHT
, 1, "Right" },
207 {KEY_DOWN
, GPIO_NR_PALMTE2_KEY_DOWN
, 1, "Down" },
208 {KEY_UP
, GPIO_NR_PALMTE2_KEY_UP
, 1, "Up" },
211 static struct gpio_keys_platform_data palmte2_pxa_keys_data
= {
212 .buttons
= palmte2_pxa_buttons
,
213 .nbuttons
= ARRAY_SIZE(palmte2_pxa_buttons
),
216 static struct platform_device palmte2_pxa_keys
= {
220 .platform_data
= &palmte2_pxa_keys_data
,
224 /******************************************************************************
226 ******************************************************************************/
227 static int palmte2_backlight_init(struct device
*dev
)
231 ret
= gpio_request(GPIO_NR_PALMTE2_BL_POWER
, "BL POWER");
234 ret
= gpio_direction_output(GPIO_NR_PALMTE2_BL_POWER
, 0);
237 ret
= gpio_request(GPIO_NR_PALMTE2_LCD_POWER
, "LCD POWER");
240 ret
= gpio_direction_output(GPIO_NR_PALMTE2_LCD_POWER
, 0);
246 gpio_free(GPIO_NR_PALMTE2_LCD_POWER
);
248 gpio_free(GPIO_NR_PALMTE2_BL_POWER
);
253 static int palmte2_backlight_notify(int brightness
)
255 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER
, brightness
);
256 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER
, brightness
);
260 static void palmte2_backlight_exit(struct device
*dev
)
262 gpio_free(GPIO_NR_PALMTE2_BL_POWER
);
263 gpio_free(GPIO_NR_PALMTE2_LCD_POWER
);
266 static struct platform_pwm_backlight_data palmte2_backlight_data
= {
268 .max_brightness
= PALMTE2_MAX_INTENSITY
,
269 .dft_brightness
= PALMTE2_MAX_INTENSITY
,
270 .pwm_period_ns
= PALMTE2_PERIOD_NS
,
271 .init
= palmte2_backlight_init
,
272 .notify
= palmte2_backlight_notify
,
273 .exit
= palmte2_backlight_exit
,
276 static struct platform_device palmte2_backlight
= {
277 .name
= "pwm-backlight",
279 .parent
= &pxa25x_device_pwm0
.dev
,
280 .platform_data
= &palmte2_backlight_data
,
284 /******************************************************************************
286 ******************************************************************************/
287 static int palmte2_irda_startup(struct device
*dev
)
290 err
= gpio_request(GPIO_NR_PALMTE2_IR_DISABLE
, "IR DISABLE");
293 err
= gpio_direction_output(GPIO_NR_PALMTE2_IR_DISABLE
, 1);
295 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE
);
300 static void palmte2_irda_shutdown(struct device
*dev
)
302 gpio_free(GPIO_NR_PALMTE2_IR_DISABLE
);
305 static void palmte2_irda_transceiver_mode(struct device
*dev
, int mode
)
307 gpio_set_value(GPIO_NR_PALMTE2_IR_DISABLE
, mode
& IR_OFF
);
308 pxa2xx_transceiver_mode(dev
, mode
);
311 static struct pxaficp_platform_data palmte2_ficp_platform_data
= {
312 .startup
= palmte2_irda_startup
,
313 .shutdown
= palmte2_irda_shutdown
,
314 .transceiver_cap
= IR_SIRMODE
| IR_FIRMODE
| IR_OFF
,
315 .transceiver_mode
= palmte2_irda_transceiver_mode
,
318 /******************************************************************************
320 ******************************************************************************/
321 static struct pxa2xx_udc_mach_info palmte2_udc_info __initdata
= {
322 .gpio_vbus
= GPIO_NR_PALMTE2_USB_DETECT_N
,
323 .gpio_vbus_inverted
= 1,
324 .gpio_pullup
= GPIO_NR_PALMTE2_USB_PULLUP
,
325 .gpio_pullup_inverted
= 0,
328 /******************************************************************************
330 ******************************************************************************/
331 static int power_supply_init(struct device
*dev
)
335 ret
= gpio_request(GPIO_NR_PALMTE2_POWER_DETECT
, "CABLE_STATE_AC");
338 ret
= gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT
);
345 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT
);
350 static int palmte2_is_ac_online(void)
352 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT
);
355 static void power_supply_exit(struct device
*dev
)
357 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT
);
360 static char *palmte2_supplicants
[] = {
364 static struct pda_power_pdata power_supply_info
= {
365 .init
= power_supply_init
,
366 .is_ac_online
= palmte2_is_ac_online
,
367 .exit
= power_supply_exit
,
368 .supplied_to
= palmte2_supplicants
,
369 .num_supplicants
= ARRAY_SIZE(palmte2_supplicants
),
372 static struct platform_device power_supply
= {
376 .platform_data
= &power_supply_info
,
380 /******************************************************************************
382 ******************************************************************************/
383 static struct wm97xx_batt_info wm97xx_batt_pdata
= {
384 .batt_aux
= WM97XX_AUX_ID3
,
385 .temp_aux
= WM97XX_AUX_ID2
,
387 .max_voltage
= PALMTE2_BAT_MAX_VOLTAGE
,
388 .min_voltage
= PALMTE2_BAT_MIN_VOLTAGE
,
393 .batt_tech
= POWER_SUPPLY_TECHNOLOGY_LIPO
,
394 .batt_name
= "main-batt",
397 /******************************************************************************
399 ******************************************************************************/
400 static struct pxafb_mode_info palmte2_lcd_modes
[] = {
417 static struct pxafb_mach_info palmte2_lcd_screen
= {
418 .modes
= palmte2_lcd_modes
,
419 .num_modes
= ARRAY_SIZE(palmte2_lcd_modes
),
420 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_PCLK_EDGE_FALL
,
423 /******************************************************************************
425 ******************************************************************************/
426 static struct platform_device
*devices
[] __initdata
= {
427 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
434 /* setup udc GPIOs initial state */
435 static void __init
palmte2_udc_init(void)
437 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP
, "UDC Vbus")) {
438 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP
, 1);
439 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP
);
443 static void __init
palmte2_init(void)
445 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config
));
447 set_pxa_fb_info(&palmte2_lcd_screen
);
448 pxa_set_mci_info(&palmte2_mci_platform_data
);
450 pxa_set_udc_info(&palmte2_udc_info
);
451 pxa_set_ac97_info(NULL
);
452 pxa_set_ficp_info(&palmte2_ficp_platform_data
);
453 wm97xx_bat_set_pdata(&wm97xx_batt_pdata
);
455 platform_add_devices(devices
, ARRAY_SIZE(devices
));
458 MACHINE_START(PALMTE2
, "Palm Tungsten|E2")
459 .phys_io
= 0x40000000,
460 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
461 .boot_params
= 0xa0000100,
462 .map_io
= pxa_map_io
,
463 .init_irq
= pxa25x_init_irq
,
465 .init_machine
= palmte2_init