blob: 731528c22faa55c2a99881826f45a062c4c3c4a5 [file] [log] [blame]
Siddhartha Agrawald61f81e2012-12-17 19:20:35 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Deepa Dinamani22799652012-07-21 12:26:22 -07002
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Channagoud Kadabi0e60b7d2012-11-01 22:56:08 +053012 * * Neither the name of The Linux Foundation, Inc. nor the names of its
Deepa Dinamani22799652012-07-21 12:26:22 -070013 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef _PM8x41_H_
30#define _PM8x41_H_
31
Channagoud Kadabi0e60b7d2012-11-01 22:56:08 +053032#include <sys/types.h>
33
Deepa Dinamani9a612932012-08-14 16:15:03 -070034#define PM_GPIO_DIR_OUT 0x01
35#define PM_GPIO_DIR_IN 0x00
36#define PM_GPIO_DIR_BOTH 0x02
37
38#define PM_GPIO_PULL_UP_30 0
39#define PM_GPIO_PULL_UP_1_5 1
40#define PM_GPIO_PULL_UP_31_5 2
41/* 1.5uA + 30uA boost */
42#define PM_GPIO_PULL_UP_1_5_30 3
43#define PM_GPIO_PULL_RESV_1 4
44#define PM_GPIO_PULL_RESV_2 5
45
Siddhartha Agrawald61f81e2012-12-17 19:20:35 -080046
47#define PM_GPIO_OUT_CMOS 0x00
48#define PM_GPIO_OUT_DRAIN_NMOS 0x01
49#define PM_GPIO_OUT_DRAIN_PMOS 0x02
50
51#define PM_GPIO_OUT_DRIVE_LOW 0x01
52#define PM_GPIO_OUT_DRIVE_MED 0x02
53#define PM_GPIO_OUT_DRIVE_HIGH 0x03
54
55
56#define PM_GPIO_FUNC_LOW 0x00
57#define PM_GPIO_FUNC_HIGH 0x01
58
59#define PM_GPIO_MODE_MASK 0x70
60#define PM_GPIO_OUTPUT_MASK 0x0F
61
Neeti Desai120b55d2012-08-20 17:15:56 -070062#define PON_PSHOLD_WARM_RESET 0x1
Deepa Dinamani3c9865d2013-03-08 14:03:19 -080063#define PON_PSHOLD_SHUTDOWN 0x4
Neeti Desai120b55d2012-08-20 17:15:56 -070064
Channagoud Kadabi36c19ea2013-07-05 16:28:44 -070065enum PM8X41_VERSIONS
66{
67 PM8X41_VERSION_V1 = 0,
68 PM8X41_VERSION_V2 = 1,
69};
70
Deepa Dinamani7564f2a2013-02-05 17:55:51 -080071
sundarajan srinivasand0f59e82013-02-12 19:17:02 -080072/*Target power on reasons*/
Ameya Thakurca145d72013-07-17 16:52:02 -070073#define HARD_RST 1
sundarajan srinivasand0f59e82013-02-12 19:17:02 -080074#define DC_CHG 8
75#define USB_CHG 16
76#define PON1 32
77#define CBLPWR_N 64
78#define KPDPWR_N 128
79
Deepa Dinamani9a612932012-08-14 16:15:03 -070080struct pm8x41_gpio {
81 int direction;
82 int output_buffer;
83 int output_value;
84 int pull;
85 int vin_sel;
86 int out_strength;
87 int function;
88 int inv_int_pol;
89 int disable_pin;
90};
91
Deepa Dinamanie69ba612013-06-03 16:10:09 -070092struct pm8x41_ldo {
93 uint8_t type;
94 uint32_t base;
95};
96
97/* LDO base addresses. */
98#define PM8x41_LDO2 0x14100
99#define PM8x41_LDO4 0x14300
Ray Zhang898675f2013-05-25 23:13:40 +0800100#define PM8x41_LDO8 0x14700
Deepa Dinamanie69ba612013-06-03 16:10:09 -0700101#define PM8x41_LDO12 0x14B00
102#define PM8x41_LDO14 0x14D00
Ray Zhang898675f2013-05-25 23:13:40 +0800103#define PM8x41_LDO15 0x14E00
Deepa Dinamanie69ba612013-06-03 16:10:09 -0700104#define PM8x41_LDO19 0x15200
105#define PM8x41_LDO22 0x15500
106
107/* LDO voltage ranges */
108#define NLDO_UV_MIN 375000
109#define NLDO_UV_MAX 1537500
110#define NLDO_UV_STEP 12500
111#define NLDO_UV_VMIN_LOW 750000
112
113#define PLDO_UV_VMIN_LOW 750000
114#define PLDO_UV_VMIN_MID 1500000
115#define PLDO_UV_VMIN_HIGH 1750000
116
117#define PLDO_UV_MIN 1537500
118#define PDLO_UV_MID 3075000
119#define PLDO_UV_MAX 4900000
120#define PLDO_UV_STEP_LOW 12500
121#define PLDO_UV_STEP_MID 25000
122#define PLDO_UV_STEP_HIGH 50000
123
124#define LDO_RANGE_SEL_BIT 0
125#define LDO_VSET_SEL_BIT 0
126#define LDO_VREG_ENABLE_BIT 7
127#define LDO_NORMAL_PWR_BIT 7
128
129#define PLDO_TYPE 0
130#define NLDO_TYPE 1
131
132#define LDO(_base, _type) \
133{ \
134 .type = _type, \
135 .base = _base, \
136}
137
Deepa Dinamanic342f122013-06-12 15:41:31 -0700138enum mpp_vin_select
139{
140 MPP_VIN0,
141 MPP_VIN1,
142 MPP_VIN2,
143 MPP_VIN3,
144};
145
146enum mpp_mode_en_source_select
147{
148 MPP_LOW,
149 MPP_HIGH,
150 MPP_PAIRED_MPP,
151 MPP_NOT_PAIRED_MPP,
152 MPP_DTEST1 = 8,
153 MPP_NOT_DTEST1,
154 MPP_DTEST2,
155 MPP_NOT_DTEST2,
156 MPP_DTEST3,
157 MPP_NOT_DTEST3,
158 MPP_DTEST4,
159 MPP_NOT_DTEST4,
160};
161
162enum mpp_en_ctl
163{
164 MPP_DISABLE,
165 MPP_ENABLE,
166};
167
168enum mpp_mode
169{
170 MPP_DIGITAL_INPUT,
171 MPP_DIGITAL_OUTPUT,
172 MPP_DIGITAL_IN_AND_OUT,
173 MPP_BIDIRECTIONAL,
174 MPP_ANALOG_INPUT,
175 MPP_ANALOG_OUTPUT,
176 MPP_CURRENT_SINK,
177 MPP_RESERVED,
178};
179
180struct pm8x41_mpp
181{
182 uint32_t base;
183 enum mpp_vin_select vin;
184 enum mpp_mode_en_source_select mode;
185};
186
187#define PM8x41_MMP3_BASE 0xA200
188
Deepa Dinamani9a612932012-08-14 16:15:03 -0700189int pm8x41_gpio_get(uint8_t gpio, uint8_t *status);
Siddhartha Agrawald61f81e2012-12-17 19:20:35 -0800190int pm8x41_gpio_set(uint8_t gpio, uint8_t value);
Deepa Dinamani9a612932012-08-14 16:15:03 -0700191int pm8x41_gpio_config(uint8_t gpio, struct pm8x41_gpio *config);
Deepa Dinamani22799652012-07-21 12:26:22 -0700192void pm8x41_set_boot_done();
Channagoud Kadabi36c19ea2013-07-05 16:28:44 -0700193uint32_t pm8x41_v2_resin_status();
Deepa Dinamanic7f87582013-02-01 15:24:49 -0800194uint32_t pm8x41_resin_status();
Neeti Desai120b55d2012-08-20 17:15:56 -0700195void pm8x41_reset_configure(uint8_t);
Deepa Dinamani3c9865d2013-03-08 14:03:19 -0800196void pm8x41_v2_reset_configure(uint8_t);
Deepa Dinamanie69ba612013-06-03 16:10:09 -0700197int pm8x41_ldo_set_voltage(struct pm8x41_ldo *ldo, uint32_t voltage);
198int pm8x41_ldo_control(struct pm8x41_ldo *ldo, uint8_t enable);
Deepa Dinamani7564f2a2013-02-05 17:55:51 -0800199uint8_t pm8x41_get_pmic_rev();
sundarajan srinivasand0f59e82013-02-12 19:17:02 -0800200uint8_t pm8x41_get_pon_reason();
Deepa Dinamanic342f122013-06-12 15:41:31 -0700201void pm8x41_config_output_mpp(struct pm8x41_mpp *mpp);
202void pm8x41_enable_mpp(struct pm8x41_mpp *mpp, enum mpp_en_ctl enable);
Ameya Thakurb0a62ab2013-06-25 13:43:10 -0700203uint8_t pm8x41_get_is_cold_boot();
Deepa Dinamani22799652012-07-21 12:26:22 -0700204
Deepa Dinamani22799652012-07-21 12:26:22 -0700205#endif