1 // SPDX-License-Identifier: GPL-2.0-only
3 * Hardware definitions for Palm Tungsten|E2
6 * Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
8 * Rewrite for mainline:
9 * Marek Vasut <marek.vasut@gmail.com>
11 * (find more info at www.hackndev.com)
14 #include <linux/platform_device.h>
15 #include <linux/delay.h>
16 #include <linux/irq.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/gpio/machine.h>
19 #include <linux/input.h>
20 #include <linux/pda_power.h>
21 #include <linux/pwm.h>
22 #include <linux/pwm_backlight.h>
23 #include <linux/gpio.h>
24 #include <linux/wm97xx.h>
25 #include <linux/power_supply.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
32 #include <mach/audio.h>
34 #include <linux/platform_data/mmc-pxamci.h>
35 #include <linux/platform_data/video-pxafb.h>
36 #include <linux/platform_data/irda-pxaficp.h>
38 #include <linux/platform_data/asoc-palm27x.h>
43 /******************************************************************************
45 ******************************************************************************/
46 static unsigned long palmte2_pin_config[] __initdata = {
50 GPIO10_GPIO, /* SD detect */
51 GPIO55_GPIO, /* SD power */
52 GPIO51_GPIO, /* SD r/o switch */
56 GPIO29_AC97_SDATA_IN_0,
57 GPIO30_AC97_SDATA_OUT,
64 GPIO15_GPIO, /* usb detect */
65 GPIO53_GPIO, /* usb power */
68 GPIO48_GPIO, /* ir disable */
76 GPIO5_GPIO, /* notes */
77 GPIO7_GPIO, /* tasks */
78 GPIO11_GPIO, /* calendar */
79 GPIO13_GPIO, /* contacts */
80 GPIO14_GPIO, /* center */
81 GPIO19_GPIO, /* left */
82 GPIO20_GPIO, /* right */
83 GPIO21_GPIO, /* down */
87 GPIO1_RST, /* reset */
88 GPIO4_GPIO, /* Hotsync button */
89 GPIO9_GPIO, /* power detect */
90 GPIO15_GPIO, /* earphone detect */
91 GPIO37_GPIO, /* LCD power */
92 GPIO56_GPIO, /* Backlight power */
95 /******************************************************************************
96 * SD/MMC card controller
97 ******************************************************************************/
98 static struct pxamci_platform_data palmte2_mci_platform_data = {
99 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
102 static struct gpiod_lookup_table palmte2_mci_gpio_table = {
103 .dev_id = "pxa2xx-mci.0",
105 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_DETECT_N,
106 "cd", GPIO_ACTIVE_LOW),
107 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_READONLY,
108 "wp", GPIO_ACTIVE_LOW),
109 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_POWER,
110 "power", GPIO_ACTIVE_HIGH),
115 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
116 /******************************************************************************
118 ******************************************************************************/
119 static struct gpio_keys_button palmte2_pxa_buttons[] = {
120 {KEY_F1, GPIO_NR_PALMTE2_KEY_CONTACTS, 1, "Contacts" },
121 {KEY_F2, GPIO_NR_PALMTE2_KEY_CALENDAR, 1, "Calendar" },
122 {KEY_F3, GPIO_NR_PALMTE2_KEY_TASKS, 1, "Tasks" },
123 {KEY_F4, GPIO_NR_PALMTE2_KEY_NOTES, 1, "Notes" },
124 {KEY_ENTER, GPIO_NR_PALMTE2_KEY_CENTER, 1, "Center" },
125 {KEY_LEFT, GPIO_NR_PALMTE2_KEY_LEFT, 1, "Left" },
126 {KEY_RIGHT, GPIO_NR_PALMTE2_KEY_RIGHT, 1, "Right" },
127 {KEY_DOWN, GPIO_NR_PALMTE2_KEY_DOWN, 1, "Down" },
128 {KEY_UP, GPIO_NR_PALMTE2_KEY_UP, 1, "Up" },
131 static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
132 .buttons = palmte2_pxa_buttons,
133 .nbuttons = ARRAY_SIZE(palmte2_pxa_buttons),
136 static struct platform_device palmte2_pxa_keys = {
140 .platform_data = &palmte2_pxa_keys_data,
145 /******************************************************************************
147 ******************************************************************************/
148 static struct pwm_lookup palmte2_pwm_lookup[] = {
149 PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL,
150 PALMTE2_PERIOD_NS, PWM_POLARITY_NORMAL),
153 static struct gpio palmte_bl_gpios[] = {
154 { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
155 { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
158 static int palmte2_backlight_init(struct device *dev)
160 return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
163 static int palmte2_backlight_notify(struct device *dev, int brightness)
165 gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
166 gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
170 static void palmte2_backlight_exit(struct device *dev)
172 gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
175 static struct platform_pwm_backlight_data palmte2_backlight_data = {
176 .max_brightness = PALMTE2_MAX_INTENSITY,
177 .dft_brightness = PALMTE2_MAX_INTENSITY,
178 .init = palmte2_backlight_init,
179 .notify = palmte2_backlight_notify,
180 .exit = palmte2_backlight_exit,
183 static struct platform_device palmte2_backlight = {
184 .name = "pwm-backlight",
186 .parent = &pxa25x_device_pwm0.dev,
187 .platform_data = &palmte2_backlight_data,
191 /******************************************************************************
193 ******************************************************************************/
194 static struct pxaficp_platform_data palmte2_ficp_platform_data = {
195 .gpio_pwdown = GPIO_NR_PALMTE2_IR_DISABLE,
196 .transceiver_cap = IR_SIRMODE | IR_OFF,
199 /******************************************************************************
201 ******************************************************************************/
202 static struct gpiod_lookup_table palmte2_udc_gpiod_table = {
203 .dev_id = "gpio-vbus",
205 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_USB_DETECT_N,
206 "vbus", GPIO_ACTIVE_LOW),
207 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_USB_PULLUP,
208 "pullup", GPIO_ACTIVE_HIGH),
213 static struct platform_device palmte2_gpio_vbus = {
218 /******************************************************************************
220 ******************************************************************************/
221 static int power_supply_init(struct device *dev)
225 ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
228 ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
235 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
240 static int palmte2_is_ac_online(void)
242 return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
245 static void power_supply_exit(struct device *dev)
247 gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
250 static char *palmte2_supplicants[] = {
254 static struct pda_power_pdata power_supply_info = {
255 .init = power_supply_init,
256 .is_ac_online = palmte2_is_ac_online,
257 .exit = power_supply_exit,
258 .supplied_to = palmte2_supplicants,
259 .num_supplicants = ARRAY_SIZE(palmte2_supplicants),
262 static struct platform_device power_supply = {
266 .platform_data = &power_supply_info,
270 /******************************************************************************
271 * WM97xx audio, battery
272 ******************************************************************************/
273 static struct wm97xx_batt_pdata palmte2_batt_pdata = {
274 .batt_aux = WM97XX_AUX_ID3,
275 .temp_aux = WM97XX_AUX_ID2,
277 .max_voltage = PALMTE2_BAT_MAX_VOLTAGE,
278 .min_voltage = PALMTE2_BAT_MIN_VOLTAGE,
283 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
284 .batt_name = "main-batt",
287 static struct wm97xx_pdata palmte2_wm97xx_pdata = {
288 .batt_pdata = &palmte2_batt_pdata,
291 static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
292 .codec_pdata = { &palmte2_wm97xx_pdata, },
295 static struct palm27x_asoc_info palmte2_asoc_pdata = {
296 .jack_gpio = GPIO_NR_PALMTE2_EARPHONE_DETECT,
299 static struct platform_device palmte2_asoc = {
300 .name = "palm27x-asoc",
303 .platform_data = &palmte2_asoc_pdata,
307 /******************************************************************************
309 ******************************************************************************/
310 static struct pxafb_mode_info palmte2_lcd_modes[] = {
327 static struct pxafb_mach_info palmte2_lcd_screen = {
328 .modes = palmte2_lcd_modes,
329 .num_modes = ARRAY_SIZE(palmte2_lcd_modes),
330 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
333 /******************************************************************************
335 ******************************************************************************/
336 static struct platform_device *devices[] __initdata = {
337 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
346 /* setup udc GPIOs initial state */
347 static void __init palmte2_udc_init(void)
349 if (!gpio_request(GPIO_NR_PALMTE2_USB_PULLUP, "UDC Vbus")) {
350 gpio_direction_output(GPIO_NR_PALMTE2_USB_PULLUP, 1);
351 gpio_free(GPIO_NR_PALMTE2_USB_PULLUP);
355 static void __init palmte2_init(void)
357 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
359 pxa_set_ffuart_info(NULL);
360 pxa_set_btuart_info(NULL);
361 pxa_set_stuart_info(NULL);
363 pxa_set_fb_info(NULL, &palmte2_lcd_screen);
364 gpiod_add_lookup_table(&palmte2_mci_gpio_table);
365 pxa_set_mci_info(&palmte2_mci_platform_data);
367 pxa_set_ac97_info(&palmte2_ac97_pdata);
368 pxa_set_ficp_info(&palmte2_ficp_platform_data);
370 pwm_add_table(palmte2_pwm_lookup, ARRAY_SIZE(palmte2_pwm_lookup));
371 gpiod_add_lookup_table(&palmte2_udc_gpiod_table);
372 platform_add_devices(devices, ARRAY_SIZE(devices));
375 MACHINE_START(PALMTE2, "Palm Tungsten|E2")
376 .atag_offset = 0x100,
377 .map_io = pxa25x_map_io,
378 .nr_irqs = PXA_NR_IRQS,
379 .init_irq = pxa25x_init_irq,
380 .handle_irq = pxa25x_handle_irq,
381 .init_time = pxa_timer_init,
382 .init_machine = palmte2_init,
383 .restart = pxa_restart,