blob: 333d13f8a43a673f2da82852e4a829a7cbaf6490 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/*
Duy Truonge833aca2013-02-12 13:35:08 -08002 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07003 *
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
Jay Chokshic5790202012-04-26 15:24:11 -070081/* vin_sel: Voltage Input Select on PM8018*/
82#define PM8018_GPIO_VIN_L4 0
83#define PM8018_GPIO_VIN_L14 1
84#define PM8018_GPIO_VIN_S3 2
85#define PM8018_GPIO_VIN_L6 3
86#define PM8018_GPIO_VIN_L2 4
87#define PM8018_GPIO_VIN_L5 5
88#define PM8018_GPIO_VIN_L8 6
89#define PM8018_GPIO_VIN_VPH 7
90
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070091/* out_strength */
92#define PM_GPIO_STRENGTH_NO 0
93#define PM_GPIO_STRENGTH_HIGH 1
94#define PM_GPIO_STRENGTH_MED 2
95#define PM_GPIO_STRENGTH_LOW 3
96
97/* function */
98#define PM_GPIO_FUNC_NORMAL 0
99#define PM_GPIO_FUNC_PAIRED 1
100#define PM_GPIO_FUNC_1 2
101#define PM_GPIO_FUNC_2 3
102#define PM_GPIO_DTEST1 4
103#define PM_GPIO_DTEST2 5
104#define PM_GPIO_DTEST3 6
105#define PM_GPIO_DTEST4 7
106
107/**
108 * struct pm_gpio - structure to specify gpio configurtion values
109 * @direction: indicates whether the gpio should be input, output, or
110 * both. Should be of the type PM_GPIO_DIR_*
111 * @output_buffer: indicates gpio should be configured as CMOS or open
112 * drain. Should be of the type PM_GPIO_OUT_BUF_*
113 * @output_value: The gpio output value of the gpio line - 0 or 1
114 * @pull: Indicates whether a pull up or pull down should be
115 * applied. If a pullup is required the current strength
116 * needs to be specified. Current values of 30uA, 1.5uA,
117 * 31.5uA, 1.5uA with 30uA boost are supported. This value
118 * should be one of the PM_GPIO_PULL_*
119 * @vin_sel: specifies the voltage level when the output is set to 1.
120 * For an input gpio specifies the voltage level at which
121 * the input is interpreted as a logical 1.
122 * @out_strength: the amount of current supplied for an output gpio,
123 * should be of the type PM_GPIO_STRENGTH_*
124 * @function: choose alternate function for the gpio. Certain gpios
125 * can be paired (shorted) with each other. Some gpio pin
126 * can act as alternate functions. This parameter should
127 * be of type PM_GPIO_FUNC_*
128 * @inv_int_pol: Invert polarity before feeding the line to the interrupt
129 * module in pmic. This feature will almost be never used
130 * since the pm8xxx interrupt block can detect both edges
131 * and both levels.
132 * @disable_pin: Disable the gpio by configuring it as high impedance.
133 */
134struct pm_gpio {
135 int direction;
136 int output_buffer;
137 int output_value;
138 int pull;
139 int vin_sel;
140 int out_strength;
141 int function;
142 int inv_int_pol;
143 int disable_pin;
144};
145
146#if defined(CONFIG_GPIO_PM8XXX) || defined(CONFIG_GPIO_PM8XXX_MODULE)
147/**
148 * pm8xxx_gpio_config - configure a gpio controlled by a pm8xxx chip
149 * @gpio: gpio number to configure
150 * @param: configuration values
151 *
152 * RETURNS: an appropriate -ERRNO error value on error, or zero for success.
153 */
154int pm8xxx_gpio_config(int gpio, struct pm_gpio *param);
155#else
156static inline int pm8xxx_gpio_config(int gpio, struct pm_gpio *param)
157{
158 return -ENXIO;
159}
160#endif
161
162#endif