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/pwm_backlight.h>
24 #include <linux/gpio.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
30 #include <mach/audio.h>
31 #include <mach/palmte2.h>
33 #include <mach/pxafb.h>
34 #include <mach/mfp-pxa25x.h>
39 /******************************************************************************
41 ******************************************************************************/
42 static unsigned long palmte2_pin_config[] __initdata = {
46 GPIO10_GPIO, /* SD detect */
47 GPIO55_GPIO, /* SD power */
48 GPIO51_GPIO, /* SD r/o switch */
52 GPIO29_AC97_SDATA_IN_0,
53 GPIO30_AC97_SDATA_OUT,
81 GPIO5_GPIO, /* notes */
82 GPIO7_GPIO, /* tasks */
83 GPIO11_GPIO, /* calendar */
84 GPIO13_GPIO, /* contacts */
85 GPIO14_GPIO, /* center */
86 GPIO19_GPIO, /* left */
87 GPIO20_GPIO, /* right */
88 GPIO21_GPIO, /* down */
92 GPIO1_RST, /* reset */
95 /******************************************************************************
96 * SD/MMC card controller
97 ******************************************************************************/
98 static int palmte2_mci_init(struct device *dev,
99 irq_handler_t palmte2_detect_int, void *data)
103 /* Setup an interrupt for detecting card insert/remove events */
104 err = gpio_request(GPIO_NR_PALMTE2_SD_DETECT_N, "SD IRQ");
107 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_DETECT_N);
110 err = request_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N),
111 palmte2_detect_int, IRQF_DISABLED | IRQF_SAMPLE_RANDOM |
112 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
113 "SD/MMC card detect", data);
115 printk(KERN_ERR "%s: cannot request SD/MMC card detect IRQ\n",
120 err = gpio_request(GPIO_NR_PALMTE2_SD_POWER, "SD_POWER");
123 err = gpio_direction_output(GPIO_NR_PALMTE2_SD_POWER, 0);
127 err = gpio_request(GPIO_NR_PALMTE2_SD_READONLY, "SD_READONLY");
130 err = gpio_direction_input(GPIO_NR_PALMTE2_SD_READONLY);
134 printk(KERN_DEBUG "%s: irq registered\n", __func__);
139 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
141 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
143 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
145 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
150 static void palmte2_mci_exit(struct device *dev, void *data)
152 gpio_free(GPIO_NR_PALMTE2_SD_READONLY);
153 gpio_free(GPIO_NR_PALMTE2_SD_POWER);
154 free_irq(gpio_to_irq(GPIO_NR_PALMTE2_SD_DETECT_N), data);
155 gpio_free(GPIO_NR_PALMTE2_SD_DETECT_N);
158 static void palmte2_mci_power(struct device *dev, unsigned int vdd)
160 struct pxamci_platform_data *p_d = dev->platform_data;
161 gpio_set_value(GPIO_NR_PALMTE2_SD_POWER, p_d->ocr_mask & (1 << vdd));
164 static int palmte2_mci_get_ro(struct device *dev)
166 return gpio_get_value(GPIO_NR_PALMTE2_SD_READONLY);
169 static struct pxamci_platform_data palmte2_mci_platform_data = {
170 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
171 .setpower = palmte2_mci_power,
172 .get_ro = palmte2_mci_get_ro,
173 .init = palmte2_mci_init,
174 .exit = palmte2_mci_exit,
177 /******************************************************************************
179 ******************************************************************************/
180 static struct gpio_keys_button palmte2_pxa_buttons[] = {
181 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
182 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
183 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
184 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
185 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
186 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
187 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
188 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
189 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
192 static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
193 .buttons = palmte2_pxa_buttons,
194 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
197 static struct platform_device palmte2_pxa_keys = {
201 .platform_data = &palmte2_pxa_keys_data,
205 /******************************************************************************
207 ******************************************************************************/
208 static struct platform_pwm_backlight_data palmte2_backlight_data = {
210 .max_brightness = PALMTE2_MAX_INTENSITY,
211 .dft_brightness = PALMTE2_MAX_INTENSITY,
212 .pwm_period_ns = PALMTE2_PERIOD_NS,
215 static struct platform_device palmte2_backlight = {
216 .name = "pwm-backlight",
218 .parent = &pxa25x_device_pwm0.dev,
219 .platform_data = &palmte2_backlight_data,
223 /******************************************************************************
225 ******************************************************************************/
226 static struct pxafb_mode_info palmte2_lcd_modes[] = {
243 static struct pxafb_mach_info palmte2_lcd_screen = {
244 .modes = palmte2_lcd_modes,
245 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
246 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
249 /******************************************************************************
251 ******************************************************************************/
252 static struct platform_device *devices[] __initdata = {
253 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
259 static void __init palmte2_init(void)
261 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
263 set_pxa_fb_info(&palmte2_lcd_screen);
264 pxa_set_mci_info(&palmte2_mci_platform_data);
265 pxa_set_ac97_info(NULL);
267 platform_add_devices(devices, ARRAY_SIZE(devices));
270 MACHINE_START(PALMTE2, "Palm Tungsten|E2")
271 .phys_io = 0x40000000,
272 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
273 .boot_params = 0xa0000100,
274 .map_io = pxa_map_io,
275 .init_irq = pxa25x_init_irq,
277 .init_machine = palmte2_init