blob: 0a9c95df3f6e3ef0a23045d7d373c2e8f8425289 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
2 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14/*
15 * Qualcomm PMIC8XXX gpio driver header file
16 *
17 */
18
19#ifndef __PM8XXX_GPIO_H
20#define __PM8XXX_GPIO_H
21
22#include <linux/errno.h>
23
24#define PM8XXX_GPIO_DEV_NAME "pm8xxx-gpio"
25
26struct pm8xxx_gpio_core_data {
27 int ngpios;
28};
29
30struct pm8xxx_gpio_platform_data {
31 struct pm8xxx_gpio_core_data gpio_cdata;
32 int gpio_base;
33};
34
35/* GPIO parameters */
36/* direction */
37#define PM_GPIO_DIR_OUT 0x01
38#define PM_GPIO_DIR_IN 0x02
39#define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN)
40
41/* output_buffer */
42#define PM_GPIO_OUT_BUF_OPEN_DRAIN 1
43#define PM_GPIO_OUT_BUF_CMOS 0
44
45/* pull */
46#define PM_GPIO_PULL_UP_30 0
47#define PM_GPIO_PULL_UP_1P5 1
48#define PM_GPIO_PULL_UP_31P5 2
49#define PM_GPIO_PULL_UP_1P5_30 3
50#define PM_GPIO_PULL_DN 4
51#define PM_GPIO_PULL_NO 5
52
53/* vin_sel: Voltage Input Select */
54#define PM_GPIO_VIN_VPH 0 /* 3v ~ 4.4v */
55#define PM_GPIO_VIN_BB 1 /* ~3.3v */
56#define PM_GPIO_VIN_S4 2 /* 1.8v */
57#define PM_GPIO_VIN_L15 3
58#define PM_GPIO_VIN_L4 4
59#define PM_GPIO_VIN_L3 5
60#define PM_GPIO_VIN_L17 6
61
62/* out_strength */
63#define PM_GPIO_STRENGTH_NO 0
64#define PM_GPIO_STRENGTH_HIGH 1
65#define PM_GPIO_STRENGTH_MED 2
66#define PM_GPIO_STRENGTH_LOW 3
67
68/* function */
69#define PM_GPIO_FUNC_NORMAL 0
70#define PM_GPIO_FUNC_PAIRED 1
71#define PM_GPIO_FUNC_1 2
72#define PM_GPIO_FUNC_2 3
73#define PM_GPIO_DTEST1 4
74#define PM_GPIO_DTEST2 5
75#define PM_GPIO_DTEST3 6
76#define PM_GPIO_DTEST4 7
77
78/**
79 * struct pm_gpio - structure to specify gpio configurtion values
80 * @direction: indicates whether the gpio should be input, output, or
81 * both. Should be of the type PM_GPIO_DIR_*
82 * @output_buffer: indicates gpio should be configured as CMOS or open
83 * drain. Should be of the type PM_GPIO_OUT_BUF_*
84 * @output_value: The gpio output value of the gpio line - 0 or 1
85 * @pull: Indicates whether a pull up or pull down should be
86 * applied. If a pullup is required the current strength
87 * needs to be specified. Current values of 30uA, 1.5uA,
88 * 31.5uA, 1.5uA with 30uA boost are supported. This value
89 * should be one of the PM_GPIO_PULL_*
90 * @vin_sel: specifies the voltage level when the output is set to 1.
91 * For an input gpio specifies the voltage level at which
92 * the input is interpreted as a logical 1.
93 * @out_strength: the amount of current supplied for an output gpio,
94 * should be of the type PM_GPIO_STRENGTH_*
95 * @function: choose alternate function for the gpio. Certain gpios
96 * can be paired (shorted) with each other. Some gpio pin
97 * can act as alternate functions. This parameter should
98 * be of type PM_GPIO_FUNC_*
99 * @inv_int_pol: Invert polarity before feeding the line to the interrupt
100 * module in pmic. This feature will almost be never used
101 * since the pm8xxx interrupt block can detect both edges
102 * and both levels.
103 * @disable_pin: Disable the gpio by configuring it as high impedance.
104 */
105struct pm_gpio {
106 int direction;
107 int output_buffer;
108 int output_value;
109 int pull;
110 int vin_sel;
111 int out_strength;
112 int function;
113 int inv_int_pol;
114 int disable_pin;
115};
116
117#if defined(CONFIG_GPIO_PM8XXX) || defined(CONFIG_GPIO_PM8XXX_MODULE)
118/**
119 * pm8xxx_gpio_config - configure a gpio controlled by a pm8xxx chip
120 * @gpio: gpio number to configure
121 * @param: configuration values
122 *
123 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
124 */
125int pm8xxx_gpio_config(int gpio, struct pm_gpio *param);
126#else
127static inline int pm8xxx_gpio_config(int gpio, struct pm_gpio *param)
128{
129 return -ENXIO;
130}
131#endif
132
133#endif