2 * Hardware definitions for PalmTX
4 * Author: Marek Vasut <marek.vasut@gmail.com>
7 * Alex Osborne <ato@meshy.org>
8 * Cristiano P. <cristianop@users.sourceforge.net>
9 * Jan Herman <2hp@seznam.cz>
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/audio.h>
36 #include <mach/palmtx.h>
38 #include <mach/pxafb.h>
39 #include <mach/pxa-regs.h>
40 #include <mach/mfp-pxa27x.h>
41 #include <mach/irda.h>
42 #include <mach/pxa27x_keypad.h>
48 /******************************************************************************
50 ******************************************************************************/
51 static unsigned long palmtx_pin_config[] __initdata = {
62 GPIO29_AC97_SDATA_IN_0,
63 GPIO30_AC97_SDATA_OUT,
89 /******************************************************************************
90 * SD/MMC card controller
91 ******************************************************************************/
92 static int palmtx_mci_init(struct device *dev, irq_handler_t palmtx_detect_int,
97 /* Setup an interrupt for detecting card insert/remove events */
98 err = request_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, palmtx_detect_int,
99 IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
100 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
101 "SD/MMC card detect", data);
103 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
108 err = gpio_request(GPIO_NR_PALMTX_SD_POWER, "SD_POWER");
112 err = gpio_request(GPIO_NR_PALMTX_SD_READONLY, "SD_READONLY");
116 printk(KERN_DEBUG "%s: irq registered\n", __func__);
121 gpio_free(GPIO_NR_PALMTX_SD_POWER);
123 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
127 static void palmtx_mci_exit(struct device *dev, void *data)
129 gpio_free(GPIO_NR_PALMTX_SD_READONLY);
130 gpio_free(GPIO_NR_PALMTX_SD_POWER);
131 free_irq(IRQ_GPIO_PALMTX_SD_DETECT_N, data);
134 static void palmtx_mci_power(struct device *dev, unsigned int vdd)
136 struct pxamci_platform_data *p_d = dev->platform_data;
137 gpio_set_value(GPIO_NR_PALMTX_SD_POWER, p_d->ocr_mask & (1 << vdd));
140 static int palmtx_mci_get_ro(struct device *dev)
142 return gpio_get_value(GPIO_NR_PALMTX_SD_READONLY);
145 static struct pxamci_platform_data palmtx_mci_platform_data = {
146 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
147 .setpower = palmtx_mci_power,
148 .get_ro = palmtx_mci_get_ro,
149 .init = palmtx_mci_init,
150 .exit = palmtx_mci_exit,
153 /******************************************************************************
155 ******************************************************************************/
156 static unsigned int palmtx_matrix_keys[] = {
157 KEY(0, 0, KEY_POWER),
159 KEY(0, 2, KEY_ENTER),
168 KEY(3, 0, KEY_RIGHT),
173 static struct pxa27x_keypad_platform_data palmtx_keypad_platform_data = {
174 .matrix_key_rows = 4,
175 .matrix_key_cols = 3,
176 .matrix_key_map = palmtx_matrix_keys,
177 .matrix_key_map_size = ARRAY_SIZE(palmtx_matrix_keys),
179 .debounce_interval = 30,
182 /******************************************************************************
184 ******************************************************************************/
185 static struct gpio_keys_button palmtx_pxa_buttons[] = {
186 {KEY_F8, GPIO_NR_PALMTX_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
189 static struct gpio_keys_platform_data palmtx_pxa_keys_data = {
190 .buttons = palmtx_pxa_buttons,
191 .nbuttons = ARRAY_SIZE(palmtx_pxa_buttons),
194 static struct platform_device palmtx_pxa_keys = {
198 .platform_data = &palmtx_pxa_keys_data,
202 /******************************************************************************
204 ******************************************************************************/
205 static int palmtx_backlight_init(struct device *dev)
209 ret = gpio_request(GPIO_NR_PALMTX_BL_POWER, "BL POWER");
212 ret = gpio_request(GPIO_NR_PALMTX_LCD_POWER, "LCD POWER");
218 gpio_free(GPIO_NR_PALMTX_BL_POWER);
223 static int palmtx_backlight_notify(int brightness)
225 gpio_set_value(GPIO_NR_PALMTX_BL_POWER, brightness);
226 gpio_set_value(GPIO_NR_PALMTX_LCD_POWER, brightness);
230 static void palmtx_backlight_exit(struct device *dev)
232 gpio_free(GPIO_NR_PALMTX_BL_POWER);
233 gpio_free(GPIO_NR_PALMTX_LCD_POWER);
236 static struct platform_pwm_backlight_data palmtx_backlight_data = {
238 .max_brightness = PALMTX_MAX_INTENSITY,
239 .dft_brightness = PALMTX_MAX_INTENSITY,
240 .pwm_period_ns = PALMTX_PERIOD_NS,
241 .init = palmtx_backlight_init,
242 .notify = palmtx_backlight_notify,
243 .exit = palmtx_backlight_exit,
246 static struct platform_device palmtx_backlight = {
247 .name = "pwm-backlight",
249 .parent = &pxa27x_device_pwm0.dev,
250 .platform_data = &palmtx_backlight_data,
254 /******************************************************************************
256 ******************************************************************************/
257 static void palmtx_irda_transceiver_mode(struct device *dev, int mode)
259 gpio_set_value(GPIO_NR_PALMTX_IR_DISABLE, mode & IR_OFF);
260 pxa2xx_transceiver_mode(dev, mode);
263 static struct pxaficp_platform_data palmtx_ficp_platform_data = {
264 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
265 .transceiver_mode = palmtx_irda_transceiver_mode,
268 /******************************************************************************
270 ******************************************************************************/
271 static void palmtx_udc_command(int cmd)
273 gpio_set_value(GPIO_NR_PALMTX_USB_POWER, !cmd);
275 gpio_set_value(GPIO_NR_PALMTX_USB_PULLUP, !cmd);
278 static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
279 .gpio_vbus = GPIO_NR_PALMTX_USB_DETECT_N,
280 .gpio_vbus_inverted = 1,
281 .udc_command = palmtx_udc_command,
284 /******************************************************************************
286 ******************************************************************************/
287 static int power_supply_init(struct device *dev)
291 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
295 ret = gpio_request(GPIO_NR_PALMTX_USB_DETECT_N, "CABLE_STATE_USB");
302 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
307 static int palmtx_is_ac_online(void)
309 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
312 static int palmtx_is_usb_online(void)
314 return !gpio_get_value(GPIO_NR_PALMTX_USB_DETECT_N);
317 static void power_supply_exit(struct device *dev)
319 gpio_free(GPIO_NR_PALMTX_USB_DETECT_N);
320 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
323 static char *palmtx_supplicants[] = {
327 static struct pda_power_pdata power_supply_info = {
328 .init = power_supply_init,
329 .is_ac_online = palmtx_is_ac_online,
330 .is_usb_online = palmtx_is_usb_online,
331 .exit = power_supply_exit,
332 .supplied_to = palmtx_supplicants,
333 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
336 static struct platform_device power_supply = {
340 .platform_data = &power_supply_info,
344 /******************************************************************************
346 ******************************************************************************/
347 static struct wm97xx_batt_info wm97xx_batt_pdata = {
348 .batt_aux = WM97XX_AUX_ID3,
349 .temp_aux = WM97XX_AUX_ID2,
351 .max_voltage = PALMTX_BAT_MAX_VOLTAGE,
352 .min_voltage = PALMTX_BAT_MIN_VOLTAGE,
357 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
358 .batt_name = "main-batt",
361 /******************************************************************************
363 ******************************************************************************/
364 static struct pxafb_mode_info palmtx_lcd_modes[] = {
381 static struct pxafb_mach_info palmtx_lcd_screen = {
382 .modes = palmtx_lcd_modes,
383 .num_modes = ARRAY_SIZE(palmtx_lcd_modes),
384 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
387 /******************************************************************************
389 ******************************************************************************/
390 static struct platform_device *devices[] __initdata = {
391 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
398 static struct map_desc palmtx_io_desc[] __initdata = {
400 .virtual = PALMTX_PCMCIA_VIRT,
401 .pfn = __phys_to_pfn(PALMTX_PCMCIA_PHYS),
402 .length = PALMTX_PCMCIA_SIZE,
407 static void __init palmtx_map_io(void)
410 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc));
413 static void __init palmtx_init(void)
415 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config));
417 set_pxa_fb_info(&palmtx_lcd_screen);
418 pxa_set_mci_info(&palmtx_mci_platform_data);
419 pxa_set_udc_info(&palmtx_udc_info);
420 pxa_set_ac97_info(NULL);
421 pxa_set_ficp_info(&palmtx_ficp_platform_data);
422 pxa_set_keypad_info(&palmtx_keypad_platform_data);
423 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
425 platform_add_devices(devices, ARRAY_SIZE(devices));
428 MACHINE_START(PALMTX, "Palm T|X")
429 .phys_io = PALMTX_PHYS_IO_START,
430 .io_pg_offst = io_p2v(0x40000000),
431 .boot_params = 0xa0000100,
432 .map_io = palmtx_map_io,
433 .init_irq = pxa27x_init_irq,
435 .init_machine = palmtx_init