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