blob: 16de80a2c5d091898719a77cfa29598b0ca5ef08 [file] [log] [blame]
Michael Bohana05f4552012-05-24 15:58:11 -07001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#define QPNP_PIN_DIR_IN 0
14#define QPNP_PIN_DIR_OUT 1
15#define QPNP_PIN_DIR_BOTH 2
16
17#define QPNP_PIN_INVERT_DISABLE 0
18#define QPNP_PIN_INVERT_ENABLE 1
19
20#define QPNP_PIN_OUT_BUF_CMOS 0
21#define QPNP_PIN_OUT_BUF_OPEN_DRAIN_NMOS 1
22#define QPNP_PIN_OUT_BUF_OPEN_DRAIN_PMOS 2
23
24#define QPNP_PIN_VIN0 0
25#define QPNP_PIN_VIN1 1
26#define QPNP_PIN_VIN2 2
27#define QPNP_PIN_VIN3 3
28#define QPNP_PIN_VIN4 4
29#define QPNP_PIN_VIN5 5
30#define QPNP_PIN_VIN6 6
31#define QPNP_PIN_VIN7 7
32
33#define QPNP_PIN_PULL_UP_30 0
34#define QPNP_PIN_PULL_UP_1P5 1
35#define QPNP_PIN_PULL_UP_31P5 2
36#define QPNP_PIN_PULL_UP_1P5_30 3
37#define QPNP_PIN_PULL_DN 4
38#define QPNP_PIN_PULL_NO 5
39
40#define QPNP_PIN_OUT_STRENGTH_LOW 1
41#define QPNP_PIN_OUT_STRENGTH_MED 2
42#define QPNP_PIN_OUT_STRENGTH_HIGH 3
43
44#define QPNP_PIN_SRC_FUNC_NORMAL 0
45#define QPNP_PIN_SRC_FUNC_PAIRED 1
46#define QPNP_PIN_SRC_FUNC_1 2
47#define QPNP_PIN_SRC_FUNC_2 3
48#define QPNP_PIN_SRC_DTEST1 4
49#define QPNP_PIN_SRC_DTEST2 5
50#define QPNP_PIN_SRC_DTEST3 6
51#define QPNP_PIN_SRC_DTEST4 7
52
53#define QPNP_PIN_MASTER_DISABLE 0
54#define QPNP_PIN_MASTER_ENABLE 1
55
56/**
57 * struct qpnp_pin_cfg - structure to specify pin configurtion values
58 * @direction: indicates whether the pin should be input, output, or
59 * both. Should be of the type QPNP_PIN_DIR_*
60 * @output_type: indicates pin should be configured as CMOS or open
61 * drain. Should be of the type QPNP_PIN_OUT_BUF_*
62 * @invert: Invert the signal of the line -
63 * QPNP_PIN_INVERT_DISABLE or QPNP_PIN_INVERT_ENABLE
64 * @pull: Indicates whether a pull up or pull down should be
65 * applied. If a pullup is required the current strength
66 * needs to be specified. Current values of 30uA, 1.5uA,
67 * 31.5uA, 1.5uA with 30uA boost are supported. This value
68 * should be one of the QPNP_PIN_PULL_*
69 * @vin_sel: specifies the voltage level when the output is set to 1.
70 * For an input gpio specifies the voltage level at which
71 * the input is interpreted as a logical 1.
72 * @out_strength: the amount of current supplied for an output gpio,
73 * should be of the type QPNP_PIN_STRENGTH_*
74 * @source_sel: choose alternate function for the gpio. Certain gpios
75 * can be paired (shorted) with each other. Some gpio pin
76 * can act as alternate functions. This parameter should
77 * be of type QPNP_PIN_SRC_*.
78 * @master_en: QPNP_PIN_MASTER_ENABLE = Enable features within the
79 * pin block based on configurations.
80 * QPNP_PIN_MASTER_DISABLE = Completely disable the pin
81 * block and let the pin float with high impedance
82 * regardless of other settings.
83 */
84struct qpnp_pin_cfg {
85 unsigned int direction;
86 unsigned int output_type;
87 unsigned int invert;
88 unsigned int pull;
89 unsigned int vin_sel;
90 unsigned int out_strength;
91 unsigned int src_select;
92 unsigned int master_en;
93};
94
95/**
96 * qpnp_pin_config - Apply pin configuration for Linux gpio
97 * @gpio: Linux gpio number to configure.
98 * @param: parameters to configure.
99 *
100 * This routine takes a Linux gpio number that corresponds with a
101 * PMIC pin and applies the configuration specified in 'param'.
102 * This gpio number can be ascertained by of_get_gpio_flags() or
103 * the qpnp_pin_map_gpio() API.
104 */
105int qpnp_pin_config(int gpio, struct qpnp_pin_cfg *param);
106
107/**
108 * qpnp_pin_map - Obtain Linux GPIO number from device spec
Michael Bohan6ea2cd22012-05-29 15:40:18 -0700109 * @name: Name assigned by the 'label' binding for the primary node.
Michael Bohana05f4552012-05-24 15:58:11 -0700110 * @pmic_pin: PMIC pin number to lookup.
111 *
112 * This routine is used in legacy configurations that do not support
113 * Device Tree. If you are using Device Tree, you should not use this.
Michael Bohan6ea2cd22012-05-29 15:40:18 -0700114 * For such cases, use of_get_gpio() or friends instead.
Michael Bohana05f4552012-05-24 15:58:11 -0700115 */
Michael Bohan6ea2cd22012-05-29 15:40:18 -0700116int qpnp_pin_map(const char *name, uint32_t pmic_pin);