root/arch/arm/mach-pxa/palmte2.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. palmte2_backlight_init
  2. palmte2_backlight_notify
  3. palmte2_backlight_exit
  4. power_supply_init
  5. palmte2_is_ac_online
  6. power_supply_exit
  7. palmte2_udc_init
  8. palmte2_init

   1 // SPDX-License-Identifier: GPL-2.0-only
   2 /*
   3  * Hardware definitions for Palm Tungsten|E2
   4  *
   5  * Author:
   6  *      Carlos Eduardo Medaglia Dyonisio <cadu@nerdfeliz.com>
   7  *
   8  * Rewrite for mainline:
   9  *      Marek Vasut <marek.vasut@gmail.com>
  10  *
  11  * (find more info at www.hackndev.com)
  12  */
  13 
  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>
  26 #include <linux/usb/gpio_vbus.h>
  27 
  28 #include <asm/mach-types.h>
  29 #include <asm/mach/arch.h>
  30 #include <asm/mach/map.h>
  31 
  32 #include "pxa25x.h"
  33 #include <mach/audio.h>
  34 #include "palmte2.h"
  35 #include <linux/platform_data/mmc-pxamci.h>
  36 #include <linux/platform_data/video-pxafb.h>
  37 #include <linux/platform_data/irda-pxaficp.h>
  38 #include "udc.h"
  39 #include <linux/platform_data/asoc-palm27x.h>
  40 
  41 #include "generic.h"
  42 #include "devices.h"
  43 
  44 /******************************************************************************
  45  * Pin configuration
  46  ******************************************************************************/
  47 static unsigned long palmte2_pin_config[] __initdata = {
  48         /* MMC */
  49         GPIO6_MMC_CLK,
  50         GPIO8_MMC_CS0,
  51         GPIO10_GPIO,    /* SD detect */
  52         GPIO55_GPIO,    /* SD power */
  53         GPIO51_GPIO,    /* SD r/o switch */
  54 
  55         /* AC97 */
  56         GPIO28_AC97_BITCLK,
  57         GPIO29_AC97_SDATA_IN_0,
  58         GPIO30_AC97_SDATA_OUT,
  59         GPIO31_AC97_SYNC,
  60 
  61         /* PWM */
  62         GPIO16_PWM0_OUT,
  63 
  64         /* USB */
  65         GPIO15_GPIO,    /* usb detect */
  66         GPIO53_GPIO,    /* usb power */
  67 
  68         /* IrDA */
  69         GPIO48_GPIO,    /* ir disable */
  70         GPIO46_FICP_RXD,
  71         GPIO47_FICP_TXD,
  72 
  73         /* LCD */
  74         GPIOxx_LCD_TFT_16BPP,
  75 
  76         /* GPIO KEYS */
  77         GPIO5_GPIO,     /* notes */
  78         GPIO7_GPIO,     /* tasks */
  79         GPIO11_GPIO,    /* calendar */
  80         GPIO13_GPIO,    /* contacts */
  81         GPIO14_GPIO,    /* center */
  82         GPIO19_GPIO,    /* left */
  83         GPIO20_GPIO,    /* right */
  84         GPIO21_GPIO,    /* down */
  85         GPIO22_GPIO,    /* up */
  86 
  87         /* MISC */
  88         GPIO1_RST,      /* reset */
  89         GPIO4_GPIO,     /* Hotsync button */
  90         GPIO9_GPIO,     /* power detect */
  91         GPIO15_GPIO,    /* earphone detect */
  92         GPIO37_GPIO,    /* LCD power */
  93         GPIO56_GPIO,    /* Backlight power */
  94 };
  95 
  96 /******************************************************************************
  97  * SD/MMC card controller
  98  ******************************************************************************/
  99 static struct pxamci_platform_data palmte2_mci_platform_data = {
 100         .ocr_mask               = MMC_VDD_32_33 | MMC_VDD_33_34,
 101 };
 102 
 103 static struct gpiod_lookup_table palmte2_mci_gpio_table = {
 104         .dev_id = "pxa2xx-mci.0",
 105         .table = {
 106                 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_DETECT_N,
 107                             "cd", GPIO_ACTIVE_LOW),
 108                 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_READONLY,
 109                             "wp", GPIO_ACTIVE_LOW),
 110                 GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_POWER,
 111                             "power", GPIO_ACTIVE_HIGH),
 112                 { },
 113         },
 114 };
 115 
 116 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
 117 /******************************************************************************
 118  * GPIO keys
 119  ******************************************************************************/
 120 static struct gpio_keys_button palmte2_pxa_buttons[] = {
 121         {KEY_F1,        GPIO_NR_PALMTE2_KEY_CONTACTS,   1, "Contacts" },
 122         {KEY_F2,        GPIO_NR_PALMTE2_KEY_CALENDAR,   1, "Calendar" },
 123         {KEY_F3,        GPIO_NR_PALMTE2_KEY_TASKS,      1, "Tasks" },
 124         {KEY_F4,        GPIO_NR_PALMTE2_KEY_NOTES,      1, "Notes" },
 125         {KEY_ENTER,     GPIO_NR_PALMTE2_KEY_CENTER,     1, "Center" },
 126         {KEY_LEFT,      GPIO_NR_PALMTE2_KEY_LEFT,       1, "Left" },
 127         {KEY_RIGHT,     GPIO_NR_PALMTE2_KEY_RIGHT,      1, "Right" },
 128         {KEY_DOWN,      GPIO_NR_PALMTE2_KEY_DOWN,       1, "Down" },
 129         {KEY_UP,        GPIO_NR_PALMTE2_KEY_UP,         1, "Up" },
 130 };
 131 
 132 static struct gpio_keys_platform_data palmte2_pxa_keys_data = {
 133         .buttons        = palmte2_pxa_buttons,
 134         .nbuttons       = ARRAY_SIZE(palmte2_pxa_buttons),
 135 };
 136 
 137 static struct platform_device palmte2_pxa_keys = {
 138         .name   = "gpio-keys",
 139         .id     = -1,
 140         .dev    = {
 141                 .platform_data = &palmte2_pxa_keys_data,
 142         },
 143 };
 144 #endif
 145 
 146 /******************************************************************************
 147  * Backlight
 148  ******************************************************************************/
 149 static struct pwm_lookup palmte2_pwm_lookup[] = {
 150         PWM_LOOKUP("pxa25x-pwm.0", 0, "pwm-backlight.0", NULL,
 151                    PALMTE2_PERIOD_NS, PWM_POLARITY_NORMAL),
 152 };
 153 
 154 static struct gpio palmte_bl_gpios[] = {
 155         { GPIO_NR_PALMTE2_BL_POWER, GPIOF_INIT_LOW, "Backlight power" },
 156         { GPIO_NR_PALMTE2_LCD_POWER, GPIOF_INIT_LOW, "LCD power" },
 157 };
 158 
 159 static int palmte2_backlight_init(struct device *dev)
 160 {
 161         return gpio_request_array(ARRAY_AND_SIZE(palmte_bl_gpios));
 162 }
 163 
 164 static int palmte2_backlight_notify(struct device *dev, int brightness)
 165 {
 166         gpio_set_value(GPIO_NR_PALMTE2_BL_POWER, brightness);
 167         gpio_set_value(GPIO_NR_PALMTE2_LCD_POWER, brightness);
 168         return brightness;
 169 }
 170 
 171 static void palmte2_backlight_exit(struct device *dev)
 172 {
 173         gpio_free_array(ARRAY_AND_SIZE(palmte_bl_gpios));
 174 }
 175 
 176 static struct platform_pwm_backlight_data palmte2_backlight_data = {
 177         .max_brightness = PALMTE2_MAX_INTENSITY,
 178         .dft_brightness = PALMTE2_MAX_INTENSITY,
 179         .enable_gpio    = -1,
 180         .init           = palmte2_backlight_init,
 181         .notify         = palmte2_backlight_notify,
 182         .exit           = palmte2_backlight_exit,
 183 };
 184 
 185 static struct platform_device palmte2_backlight = {
 186         .name   = "pwm-backlight",
 187         .dev    = {
 188                 .parent         = &pxa25x_device_pwm0.dev,
 189                 .platform_data  = &palmte2_backlight_data,
 190         },
 191 };
 192 
 193 /******************************************************************************
 194  * IrDA
 195  ******************************************************************************/
 196 static struct pxaficp_platform_data palmte2_ficp_platform_data = {
 197         .gpio_pwdown            = GPIO_NR_PALMTE2_IR_DISABLE,
 198         .transceiver_cap        = IR_SIRMODE | IR_OFF,
 199 };
 200 
 201 /******************************************************************************
 202  * UDC
 203  ******************************************************************************/
 204 static struct gpio_vbus_mach_info palmte2_udc_info = {
 205         .gpio_vbus              = GPIO_NR_PALMTE2_USB_DETECT_N,
 206         .gpio_vbus_inverted     = 1,
 207         .gpio_pullup            = GPIO_NR_PALMTE2_USB_PULLUP,
 208 };
 209 
 210 static struct platform_device palmte2_gpio_vbus = {
 211         .name   = "gpio-vbus",
 212         .id     = -1,
 213         .dev    = {
 214                 .platform_data  = &palmte2_udc_info,
 215         },
 216 };
 217 
 218 /******************************************************************************
 219  * Power supply
 220  ******************************************************************************/
 221 static int power_supply_init(struct device *dev)
 222 {
 223         int ret;
 224 
 225         ret = gpio_request(GPIO_NR_PALMTE2_POWER_DETECT, "CABLE_STATE_AC");
 226         if (ret)
 227                 goto err1;
 228         ret = gpio_direction_input(GPIO_NR_PALMTE2_POWER_DETECT);
 229         if (ret)
 230                 goto err2;
 231 
 232         return 0;
 233 
 234 err2:
 235         gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
 236 err1:
 237         return ret;
 238 }
 239 
 240 static int palmte2_is_ac_online(void)
 241 {
 242         return gpio_get_value(GPIO_NR_PALMTE2_POWER_DETECT);
 243 }
 244 
 245 static void power_supply_exit(struct device *dev)
 246 {
 247         gpio_free(GPIO_NR_PALMTE2_POWER_DETECT);
 248 }
 249 
 250 static char *palmte2_supplicants[] = {
 251         "main-battery",
 252 };
 253 
 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),
 260 };
 261 
 262 static struct platform_device power_supply = {
 263         .name = "pda-power",
 264         .id   = -1,
 265         .dev  = {
 266                 .platform_data = &power_supply_info,
 267         },
 268 };
 269 
 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,
 276         .charge_gpio    = -1,
 277         .max_voltage    = PALMTE2_BAT_MAX_VOLTAGE,
 278         .min_voltage    = PALMTE2_BAT_MIN_VOLTAGE,
 279         .batt_mult      = 1000,
 280         .batt_div       = 414,
 281         .temp_mult      = 1,
 282         .temp_div       = 1,
 283         .batt_tech      = POWER_SUPPLY_TECHNOLOGY_LIPO,
 284         .batt_name      = "main-batt",
 285 };
 286 
 287 static struct wm97xx_pdata palmte2_wm97xx_pdata = {
 288         .batt_pdata     = &palmte2_batt_pdata,
 289 };
 290 
 291 static pxa2xx_audio_ops_t palmte2_ac97_pdata = {
 292         .codec_pdata    = { &palmte2_wm97xx_pdata, },
 293 };
 294 
 295 static struct palm27x_asoc_info palmte2_asoc_pdata = {
 296         .jack_gpio      = GPIO_NR_PALMTE2_EARPHONE_DETECT,
 297 };
 298 
 299 static struct platform_device palmte2_asoc = {
 300         .name = "palm27x-asoc",
 301         .id   = -1,
 302         .dev  = {
 303                 .platform_data = &palmte2_asoc_pdata,
 304         },
 305 };
 306 
 307 /******************************************************************************
 308  * Framebuffer
 309  ******************************************************************************/
 310 static struct pxafb_mode_info palmte2_lcd_modes[] = {
 311 {
 312         .pixclock       = 77757,
 313         .xres           = 320,
 314         .yres           = 320,
 315         .bpp            = 16,
 316 
 317         .left_margin    = 28,
 318         .right_margin   = 7,
 319         .upper_margin   = 7,
 320         .lower_margin   = 5,
 321 
 322         .hsync_len      = 4,
 323         .vsync_len      = 1,
 324 },
 325 };
 326 
 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,
 331 };
 332 
 333 /******************************************************************************
 334  * Machine init
 335  ******************************************************************************/
 336 static struct platform_device *devices[] __initdata = {
 337 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
 338         &palmte2_pxa_keys,
 339 #endif
 340         &palmte2_backlight,
 341         &power_supply,
 342         &palmte2_asoc,
 343         &palmte2_gpio_vbus,
 344 };
 345 
 346 /* setup udc GPIOs initial state */
 347 static void __init palmte2_udc_init(void)
 348 {
 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);
 352         }
 353 }
 354 
 355 static void __init palmte2_init(void)
 356 {
 357         pxa2xx_mfp_config(ARRAY_AND_SIZE(palmte2_pin_config));
 358 
 359         pxa_set_ffuart_info(NULL);
 360         pxa_set_btuart_info(NULL);
 361         pxa_set_stuart_info(NULL);
 362 
 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);
 366         palmte2_udc_init();
 367         pxa_set_ac97_info(&palmte2_ac97_pdata);
 368         pxa_set_ficp_info(&palmte2_ficp_platform_data);
 369 
 370         pwm_add_table(palmte2_pwm_lookup, ARRAY_SIZE(palmte2_pwm_lookup));
 371         platform_add_devices(devices, ARRAY_SIZE(devices));
 372 }
 373 
 374 MACHINE_START(PALMTE2, "Palm Tungsten|E2")
 375         .atag_offset    = 0x100,
 376         .map_io         = pxa25x_map_io,
 377         .nr_irqs        = PXA_NR_IRQS,
 378         .init_irq       = pxa25x_init_irq,
 379         .handle_irq     = pxa25x_handle_irq,
 380         .init_time      = pxa_timer_init,
 381         .init_machine   = palmte2_init,
 382         .restart        = pxa_restart,
 383 MACHINE_END

/* [<][>][^][v][top][bottom][index][help] */