blob: 99186207a420a4ee59eb723edf2647899b7423b2 [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
Anirudh Ghayalc2019332011-11-12 06:29:10 +053062/* vin_sel: Voltage Input select on PM8058 */
63#define PM8058_GPIO_VIN_VPH 0
64#define PM8058_GPIO_VIN_BB 1
65#define PM8058_GPIO_VIN_S3 2
66#define PM8058_GPIO_VIN_L3 3
67#define PM8058_GPIO_VIN_L7 4
68#define PM8058_GPIO_VIN_L6 5
69#define PM8058_GPIO_VIN_L5 6
70#define PM8058_GPIO_VIN_L2 7
71
Jay Chokshi9d36a3d2011-10-26 15:57:51 -070072/* vin_sel: Voltage Input Select on PM8038*/
73#define PM8038_GPIO_VIN_VPH 0
74#define PM8038_GPIO_VIN_BB 1
75#define PM8038_GPIO_VIN_L11 2
76#define PM8038_GPIO_VIN_L15 3
77#define PM8038_GPIO_VIN_L4 4
78#define PM8038_GPIO_VIN_L3 5
79#define PM8038_GPIO_VIN_L17 6
80
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081/* out_strength */
82#define PM_GPIO_STRENGTH_NO 0
83#define PM_GPIO_STRENGTH_HIGH 1
84#define PM_GPIO_STRENGTH_MED 2
85#define PM_GPIO_STRENGTH_LOW 3
86
87/* function */
88#define PM_GPIO_FUNC_NORMAL 0
89#define PM_GPIO_FUNC_PAIRED 1
90#define PM_GPIO_FUNC_1 2
91#define PM_GPIO_FUNC_2 3
92#define PM_GPIO_DTEST1 4
93#define PM_GPIO_DTEST2 5
94#define PM_GPIO_DTEST3 6
95#define PM_GPIO_DTEST4 7
96
97/**
98 * struct pm_gpio - structure to specify gpio configurtion values
99 * @direction: indicates whether the gpio should be input, output, or
100 * both. Should be of the type PM_GPIO_DIR_*
101 * @output_buffer: indicates gpio should be configured as CMOS or open
102 * drain. Should be of the type PM_GPIO_OUT_BUF_*
103 * @output_value: The gpio output value of the gpio line - 0 or 1
104 * @pull: Indicates whether a pull up or pull down should be
105 * applied. If a pullup is required the current strength
106 * needs to be specified. Current values of 30uA, 1.5uA,
107 * 31.5uA, 1.5uA with 30uA boost are supported. This value
108 * should be one of the PM_GPIO_PULL_*
109 * @vin_sel: specifies the voltage level when the output is set to 1.
110 * For an input gpio specifies the voltage level at which
111 * the input is interpreted as a logical 1.
112 * @out_strength: the amount of current supplied for an output gpio,
113 * should be of the type PM_GPIO_STRENGTH_*
114 * @function: choose alternate function for the gpio. Certain gpios
115 * can be paired (shorted) with each other. Some gpio pin
116 * can act as alternate functions. This parameter should
117 * be of type PM_GPIO_FUNC_*
118 * @inv_int_pol: Invert polarity before feeding the line to the interrupt
119 * module in pmic. This feature will almost be never used
120 * since the pm8xxx interrupt block can detect both edges
121 * and both levels.
122 * @disable_pin: Disable the gpio by configuring it as high impedance.
123 */
124struct pm_gpio {
125 int direction;
126 int output_buffer;
127 int output_value;
128 int pull;
129 int vin_sel;
130 int out_strength;
131 int function;
132 int inv_int_pol;
133 int disable_pin;
134};
135
136#if defined(CONFIG_GPIO_PM8XXX) || defined(CONFIG_GPIO_PM8XXX_MODULE)
137/**
138 * pm8xxx_gpio_config - configure a gpio controlled by a pm8xxx chip
139 * @gpio: gpio number to configure
140 * @param: configuration values
141 *
142 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
143 */
144int pm8xxx_gpio_config(int gpio, struct pm_gpio *param);
145#else
146static inline int pm8xxx_gpio_config(int gpio, struct pm_gpio *param)
147{
148 return -ENXIO;
149}
150#endif
151
152#endif