aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/mfd
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>2014-04-14 05:17:18 -0400
committerLee Jones <lee.jones@linaro.org>2014-04-23 09:08:54 -0400
commitaee2a57c7482c712052b877218aa2c5bc0fe8626 (patch)
tree875184a014f637ddc88637ec85012be9f2131f6b /include/linux/mfd
parentc7846852ec8f304c629963202fa565452e8fe34c (diff)
mfd: max77836: Add MAX77836 support to max14577 driver
Add Maxim 77836 support to max14577 driver. The chipsets have same MUIC component so the extcon, charger and regulators are almost the same. The MAX77836 however has also PMIC and Fuel Gauge. The MAX77836 uses three I2C slave addresses and has additional interrupts (related to PMIC and Fuel Gauge). It has also Interrupt Source register, just like MAX77686 and MAX77693. The MAX77836 PMIC's TOPSYS and INTSRC interrupts are reported in the PMIC block. The PMIC block has different I2C slave address and uses own regmap so another regmap_irq_chip is needed. Since we have two regmap_irq_chip, use shared interrupts on MAX77836. This patch adds additional defines and functions to the max14577 MFD core driver so the driver will handle both chipsets. Also this patch replaces "0x1 << N" with BIT(N) in defines for register masks. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
-rw-r--r--include/linux/mfd/max14577-private.h145
-rw-r--r--include/linux/mfd/max14577.h7
2 files changed, 118 insertions, 34 deletions
diff --git a/include/linux/mfd/max14577-private.h b/include/linux/mfd/max14577-private.h
index 989183d232cd..e301bd19b067 100644
--- a/include/linux/mfd/max14577-private.h
+++ b/include/linux/mfd/max14577-private.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * max14577-private.h - Common API for the Maxim 14577 internal sub chip 2 * max14577-private.h - Common API for the Maxim 14577/77836 internal sub chip
3 * 3 *
4 * Copyright (C) 2013 Samsung Electrnoics 4 * Copyright (C) 2014 Samsung Electrnoics
5 * Chanwoo Choi <cw00.choi@samsung.com> 5 * Chanwoo Choi <cw00.choi@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski@samsung.com> 6 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
7 * 7 *
@@ -22,9 +22,14 @@
22#include <linux/i2c.h> 22#include <linux/i2c.h>
23#include <linux/regmap.h> 23#include <linux/regmap.h>
24 24
25#define I2C_ADDR_PMIC (0x46 >> 1)
26#define I2C_ADDR_MUIC (0x4A >> 1)
27#define I2C_ADDR_FG (0x6C >> 1)
28
25enum maxim_device_type { 29enum maxim_device_type {
26 MAXIM_DEVICE_TYPE_UNKNOWN = 0, 30 MAXIM_DEVICE_TYPE_UNKNOWN = 0,
27 MAXIM_DEVICE_TYPE_MAX14577, 31 MAXIM_DEVICE_TYPE_MAX14577,
32 MAXIM_DEVICE_TYPE_MAX77836,
28 33
29 MAXIM_DEVICE_TYPE_NUM, 34 MAXIM_DEVICE_TYPE_NUM,
30}; 35};
@@ -88,6 +93,7 @@ enum max14577_muic_charger_type {
88#define MAX14577_INT2_DCDTMR_MASK BIT(2) 93#define MAX14577_INT2_DCDTMR_MASK BIT(2)
89#define MAX14577_INT2_DBCHG_MASK BIT(3) 94#define MAX14577_INT2_DBCHG_MASK BIT(3)
90#define MAX14577_INT2_VBVOLT_MASK BIT(4) 95#define MAX14577_INT2_VBVOLT_MASK BIT(4)
96#define MAX77836_INT2_VIDRM_MASK BIT(5)
91 97
92#define MAX14577_INT3_EOC_MASK BIT(0) 98#define MAX14577_INT3_EOC_MASK BIT(0)
93#define MAX14577_INT3_CGMBC_MASK BIT(1) 99#define MAX14577_INT3_CGMBC_MASK BIT(1)
@@ -104,9 +110,11 @@ enum max14577_muic_charger_type {
104#define STATUS1_ADC_SHIFT 0 110#define STATUS1_ADC_SHIFT 0
105#define STATUS1_ADCLOW_SHIFT 5 111#define STATUS1_ADCLOW_SHIFT 5
106#define STATUS1_ADCERR_SHIFT 6 112#define STATUS1_ADCERR_SHIFT 6
113#define MAX77836_STATUS1_ADC1K_SHIFT 7
107#define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) 114#define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT)
108#define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) 115#define STATUS1_ADCLOW_MASK BIT(STATUS1_ADCLOW_SHIFT)
109#define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) 116#define STATUS1_ADCERR_MASK BIT(STATUS1_ADCERR_SHIFT)
117#define MAX77836_STATUS1_ADC1K_MASK BIT(MAX77836_STATUS1_ADC1K_SHIFT)
110 118
111/* MAX14577 STATUS2 register */ 119/* MAX14577 STATUS2 register */
112#define STATUS2_CHGTYP_SHIFT 0 120#define STATUS2_CHGTYP_SHIFT 0
@@ -114,11 +122,13 @@ enum max14577_muic_charger_type {
114#define STATUS2_DCDTMR_SHIFT 4 122#define STATUS2_DCDTMR_SHIFT 4
115#define STATUS2_DBCHG_SHIFT 5 123#define STATUS2_DBCHG_SHIFT 5
116#define STATUS2_VBVOLT_SHIFT 6 124#define STATUS2_VBVOLT_SHIFT 6
125#define MAX77836_STATUS2_VIDRM_SHIFT 7
117#define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) 126#define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT)
118#define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) 127#define STATUS2_CHGDETRUN_MASK BIT(STATUS2_CHGDETRUN_SHIFT)
119#define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) 128#define STATUS2_DCDTMR_MASK BIT(STATUS2_DCDTMR_SHIFT)
120#define STATUS2_DBCHG_MASK (0x1 << STATUS2_DBCHG_SHIFT) 129#define STATUS2_DBCHG_MASK BIT(STATUS2_DBCHG_SHIFT)
121#define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) 130#define STATUS2_VBVOLT_MASK BIT(STATUS2_VBVOLT_SHIFT)
131#define MAX77836_STATUS2_VIDRM_MASK BIT(MAX77836_STATUS2_VIDRM_SHIFT)
122 132
123/* MAX14577 CONTROL1 register */ 133/* MAX14577 CONTROL1 register */
124#define COMN1SW_SHIFT 0 134#define COMN1SW_SHIFT 0
@@ -127,8 +137,8 @@ enum max14577_muic_charger_type {
127#define IDBEN_SHIFT 7 137#define IDBEN_SHIFT 7
128#define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) 138#define COMN1SW_MASK (0x7 << COMN1SW_SHIFT)
129#define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) 139#define COMP2SW_MASK (0x7 << COMP2SW_SHIFT)
130#define MICEN_MASK (0x1 << MICEN_SHIFT) 140#define MICEN_MASK BIT(MICEN_SHIFT)
131#define IDBEN_MASK (0x1 << IDBEN_SHIFT) 141#define IDBEN_MASK BIT(IDBEN_SHIFT)
132#define CLEAR_IDBEN_MICEN_MASK (COMN1SW_MASK | COMP2SW_MASK) 142#define CLEAR_IDBEN_MICEN_MASK (COMN1SW_MASK | COMP2SW_MASK)
133#define CTRL1_SW_USB ((1 << COMP2SW_SHIFT) \ 143#define CTRL1_SW_USB ((1 << COMP2SW_SHIFT) \
134 | (1 << COMN1SW_SHIFT)) 144 | (1 << COMN1SW_SHIFT))
@@ -148,14 +158,14 @@ enum max14577_muic_charger_type {
148#define CTRL2_ACCDET_SHIFT (5) 158#define CTRL2_ACCDET_SHIFT (5)
149#define CTRL2_USBCPINT_SHIFT (6) 159#define CTRL2_USBCPINT_SHIFT (6)
150#define CTRL2_RCPS_SHIFT (7) 160#define CTRL2_RCPS_SHIFT (7)
151#define CTRL2_LOWPWR_MASK (0x1 << CTRL2_LOWPWR_SHIFT) 161#define CTRL2_LOWPWR_MASK BIT(CTRL2_LOWPWR_SHIFT)
152#define CTRL2_ADCEN_MASK (0x1 << CTRL2_ADCEN_SHIFT) 162#define CTRL2_ADCEN_MASK BIT(CTRL2_ADCEN_SHIFT)
153#define CTRL2_CPEN_MASK (0x1 << CTRL2_CPEN_SHIFT) 163#define CTRL2_CPEN_MASK BIT(CTRL2_CPEN_SHIFT)
154#define CTRL2_SFOUTASRT_MASK (0x1 << CTRL2_SFOUTASRT_SHIFT) 164#define CTRL2_SFOUTASRT_MASK BIT(CTRL2_SFOUTASRT_SHIFT)
155#define CTRL2_SFOUTORD_MASK (0x1 << CTRL2_SFOUTORD_SHIFT) 165#define CTRL2_SFOUTORD_MASK BIT(CTRL2_SFOUTORD_SHIFT)
156#define CTRL2_ACCDET_MASK (0x1 << CTRL2_ACCDET_SHIFT) 166#define CTRL2_ACCDET_MASK BIT(CTRL2_ACCDET_SHIFT)
157#define CTRL2_USBCPINT_MASK (0x1 << CTRL2_USBCPINT_SHIFT) 167#define CTRL2_USBCPINT_MASK BIT(CTRL2_USBCPINT_SHIFT)
158#define CTRL2_RCPS_MASK (0x1 << CTR2_RCPS_SHIFT) 168#define CTRL2_RCPS_MASK BIT(CTRL2_RCPS_SHIFT)
159 169
160#define CTRL2_CPEN1_LOWPWR0 ((1 << CTRL2_CPEN_SHIFT) | \ 170#define CTRL2_CPEN1_LOWPWR0 ((1 << CTRL2_CPEN_SHIFT) | \
161 (0 << CTRL2_LOWPWR_SHIFT)) 171 (0 << CTRL2_LOWPWR_SHIFT))
@@ -203,14 +213,14 @@ enum max14577_charger_reg {
203#define CDETCTRL1_DBEXIT_SHIFT 5 213#define CDETCTRL1_DBEXIT_SHIFT 5
204#define CDETCTRL1_DBIDLE_SHIFT 6 214#define CDETCTRL1_DBIDLE_SHIFT 6
205#define CDETCTRL1_CDPDET_SHIFT 7 215#define CDETCTRL1_CDPDET_SHIFT 7
206#define CDETCTRL1_CHGDETEN_MASK (0x1 << CDETCTRL1_CHGDETEN_SHIFT) 216#define CDETCTRL1_CHGDETEN_MASK BIT(CDETCTRL1_CHGDETEN_SHIFT)
207#define CDETCTRL1_CHGTYPMAN_MASK (0x1 << CDETCTRL1_CHGTYPMAN_SHIFT) 217#define CDETCTRL1_CHGTYPMAN_MASK BIT(CDETCTRL1_CHGTYPMAN_SHIFT)
208#define CDETCTRL1_DCDEN_MASK (0x1 << CDETCTRL1_DCDEN_SHIFT) 218#define CDETCTRL1_DCDEN_MASK BIT(CDETCTRL1_DCDEN_SHIFT)
209#define CDETCTRL1_DCD2SCT_MASK (0x1 << CDETCTRL1_DCD2SCT_SHIFT) 219#define CDETCTRL1_DCD2SCT_MASK BIT(CDETCTRL1_DCD2SCT_SHIFT)
210#define CDETCTRL1_DCHKTM_MASK (0x1 << CDETCTRL1_DCHKTM_SHIFT) 220#define CDETCTRL1_DCHKTM_MASK BIT(CDETCTRL1_DCHKTM_SHIFT)
211#define CDETCTRL1_DBEXIT_MASK (0x1 << CDETCTRL1_DBEXIT_SHIFT) 221#define CDETCTRL1_DBEXIT_MASK BIT(CDETCTRL1_DBEXIT_SHIFT)
212#define CDETCTRL1_DBIDLE_MASK (0x1 << CDETCTRL1_DBIDLE_SHIFT) 222#define CDETCTRL1_DBIDLE_MASK BIT(CDETCTRL1_DBIDLE_SHIFT)
213#define CDETCTRL1_CDPDET_MASK (0x1 << CDETCTRL1_CDPDET_SHIFT) 223#define CDETCTRL1_CDPDET_MASK BIT(CDETCTRL1_CDPDET_SHIFT)
214 224
215/* MAX14577 CHGCTRL1 register */ 225/* MAX14577 CHGCTRL1 register */
216#define CHGCTRL1_TCHW_SHIFT 4 226#define CHGCTRL1_TCHW_SHIFT 4
@@ -218,9 +228,9 @@ enum max14577_charger_reg {
218 228
219/* MAX14577 CHGCTRL2 register */ 229/* MAX14577 CHGCTRL2 register */
220#define CHGCTRL2_MBCHOSTEN_SHIFT 6 230#define CHGCTRL2_MBCHOSTEN_SHIFT 6
221#define CHGCTRL2_MBCHOSTEN_MASK (0x1 << CHGCTRL2_MBCHOSTEN_SHIFT) 231#define CHGCTRL2_MBCHOSTEN_MASK BIT(CHGCTRL2_MBCHOSTEN_SHIFT)
222#define CHGCTRL2_VCHGR_RC_SHIFT 7 232#define CHGCTRL2_VCHGR_RC_SHIFT 7
223#define CHGCTRL2_VCHGR_RC_MASK (0x1 << CHGCTRL2_VCHGR_RC_SHIFT) 233#define CHGCTRL2_VCHGR_RC_MASK BIT(CHGCTRL2_VCHGR_RC_SHIFT)
224 234
225/* MAX14577 CHGCTRL3 register */ 235/* MAX14577 CHGCTRL3 register */
226#define CHGCTRL3_MBCCVWRC_SHIFT 0 236#define CHGCTRL3_MBCCVWRC_SHIFT 0
@@ -230,7 +240,7 @@ enum max14577_charger_reg {
230#define CHGCTRL4_MBCICHWRCH_SHIFT 0 240#define CHGCTRL4_MBCICHWRCH_SHIFT 0
231#define CHGCTRL4_MBCICHWRCH_MASK (0xf << CHGCTRL4_MBCICHWRCH_SHIFT) 241#define CHGCTRL4_MBCICHWRCH_MASK (0xf << CHGCTRL4_MBCICHWRCH_SHIFT)
232#define CHGCTRL4_MBCICHWRCL_SHIFT 4 242#define CHGCTRL4_MBCICHWRCL_SHIFT 4
233#define CHGCTRL4_MBCICHWRCL_MASK (0x1 << CHGCTRL4_MBCICHWRCL_SHIFT) 243#define CHGCTRL4_MBCICHWRCL_MASK BIT(CHGCTRL4_MBCICHWRCL_SHIFT)
234 244
235/* MAX14577 CHGCTRL5 register */ 245/* MAX14577 CHGCTRL5 register */
236#define CHGCTRL5_EOCS_SHIFT 0 246#define CHGCTRL5_EOCS_SHIFT 0
@@ -238,7 +248,7 @@ enum max14577_charger_reg {
238 248
239/* MAX14577 CHGCTRL6 register */ 249/* MAX14577 CHGCTRL6 register */
240#define CHGCTRL6_AUTOSTOP_SHIFT 5 250#define CHGCTRL6_AUTOSTOP_SHIFT 5
241#define CHGCTRL6_AUTOSTOP_MASK (0x1 << CHGCTRL6_AUTOSTOP_SHIFT) 251#define CHGCTRL6_AUTOSTOP_MASK BIT(CHGCTRL6_AUTOSTOP_SHIFT)
242 252
243/* MAX14577 CHGCTRL7 register */ 253/* MAX14577 CHGCTRL7 register */
244#define CHGCTRL7_OTPCGHCVS_SHIFT 0 254#define CHGCTRL7_OTPCGHCVS_SHIFT 0
@@ -253,6 +263,70 @@ enum max14577_charger_reg {
253/* MAX14577 regulator SFOUT LDO voltage, fixed, uV */ 263/* MAX14577 regulator SFOUT LDO voltage, fixed, uV */
254#define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000 264#define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000
255 265
266/* Slave addr = 0x46: PMIC */
267enum max77836_pmic_reg {
268 MAX77836_PMIC_REG_PMIC_ID = 0x20,
269 MAX77836_PMIC_REG_PMIC_REV = 0x21,
270 MAX77836_PMIC_REG_INTSRC = 0x22,
271 MAX77836_PMIC_REG_INTSRC_MASK = 0x23,
272 MAX77836_PMIC_REG_TOPSYS_INT = 0x24,
273 MAX77836_PMIC_REG_TOPSYS_INT_MASK = 0x26,
274 MAX77836_PMIC_REG_TOPSYS_STAT = 0x28,
275 MAX77836_PMIC_REG_MRSTB_CNTL = 0x2A,
276 MAX77836_PMIC_REG_LSCNFG = 0x2B,
277
278 MAX77836_LDO_REG_CNFG1_LDO1 = 0x51,
279 MAX77836_LDO_REG_CNFG2_LDO1 = 0x52,
280 MAX77836_LDO_REG_CNFG1_LDO2 = 0x53,
281 MAX77836_LDO_REG_CNFG2_LDO2 = 0x54,
282 MAX77836_LDO_REG_CNFG_LDO_BIAS = 0x55,
283
284 MAX77836_COMP_REG_COMP1 = 0x60,
285
286 MAX77836_PMIC_REG_END,
287};
288
289#define MAX77836_INTSRC_MASK_TOP_INT_SHIFT 1
290#define MAX77836_INTSRC_MASK_MUIC_CHG_INT_SHIFT 3
291#define MAX77836_INTSRC_MASK_TOP_INT_MASK BIT(MAX77836_INTSRC_MASK_TOP_INT_SHIFT)
292#define MAX77836_INTSRC_MASK_MUIC_CHG_INT_MASK BIT(MAX77836_INTSRC_MASK_MUIC_CHG_INT_SHIFT)
293
294/* MAX77836 PMIC interrupts */
295#define MAX77836_TOPSYS_INT_T120C_SHIFT 0
296#define MAX77836_TOPSYS_INT_T140C_SHIFT 1
297#define MAX77836_TOPSYS_INT_T120C_MASK BIT(MAX77836_TOPSYS_INT_T120C_SHIFT)
298#define MAX77836_TOPSYS_INT_T140C_MASK BIT(MAX77836_TOPSYS_INT_T140C_SHIFT)
299
300/* Slave addr = 0x6C: Fuel-Gauge/Battery */
301enum max77836_fg_reg {
302 MAX77836_FG_REG_VCELL_MSB = 0x02,
303 MAX77836_FG_REG_VCELL_LSB = 0x03,
304 MAX77836_FG_REG_SOC_MSB = 0x04,
305 MAX77836_FG_REG_SOC_LSB = 0x05,
306 MAX77836_FG_REG_MODE_H = 0x06,
307 MAX77836_FG_REG_MODE_L = 0x07,
308 MAX77836_FG_REG_VERSION_MSB = 0x08,
309 MAX77836_FG_REG_VERSION_LSB = 0x09,
310 MAX77836_FG_REG_HIBRT_H = 0x0A,
311 MAX77836_FG_REG_HIBRT_L = 0x0B,
312 MAX77836_FG_REG_CONFIG_H = 0x0C,
313 MAX77836_FG_REG_CONFIG_L = 0x0D,
314 MAX77836_FG_REG_VALRT_MIN = 0x14,
315 MAX77836_FG_REG_VALRT_MAX = 0x15,
316 MAX77836_FG_REG_CRATE_MSB = 0x16,
317 MAX77836_FG_REG_CRATE_LSB = 0x17,
318 MAX77836_FG_REG_VRESET = 0x18,
319 MAX77836_FG_REG_FGID = 0x19,
320 MAX77836_FG_REG_STATUS_H = 0x1A,
321 MAX77836_FG_REG_STATUS_L = 0x1B,
322 /*
323 * TODO: TABLE registers
324 * TODO: CMD register
325 */
326
327 MAX77836_FG_REG_END,
328};
329
256enum max14577_irq { 330enum max14577_irq {
257 /* INT1 */ 331 /* INT1 */
258 MAX14577_IRQ_INT1_ADC, 332 MAX14577_IRQ_INT1_ADC,
@@ -272,17 +346,24 @@ enum max14577_irq {
272 MAX14577_IRQ_INT3_OVP, 346 MAX14577_IRQ_INT3_OVP,
273 MAX14577_IRQ_INT3_MBCCHGERR, 347 MAX14577_IRQ_INT3_MBCCHGERR,
274 348
349 /* TOPSYS_INT, only MAX77836 */
350 MAX77836_IRQ_TOPSYS_T140C,
351 MAX77836_IRQ_TOPSYS_T120C,
352
275 MAX14577_IRQ_NUM, 353 MAX14577_IRQ_NUM,
276}; 354};
277 355
278struct max14577 { 356struct max14577 {
279 struct device *dev; 357 struct device *dev;
280 struct i2c_client *i2c; /* Slave addr = 0x4A */ 358 struct i2c_client *i2c; /* Slave addr = 0x4A */
359 struct i2c_client *i2c_pmic; /* Slave addr = 0x46 */
281 enum maxim_device_type dev_type; 360 enum maxim_device_type dev_type;
282 361
283 struct regmap *regmap; 362 struct regmap *regmap; /* For MUIC and Charger */
363 struct regmap *regmap_pmic;
284 364
285 struct regmap_irq_chip_data *irq_data; 365 struct regmap_irq_chip_data *irq_data; /* For MUIC and Charger */
366 struct regmap_irq_chip_data *irq_data_pmic;
286 int irq; 367 int irq;
287}; 368};
288 369
diff --git a/include/linux/mfd/max14577.h b/include/linux/mfd/max14577.h
index 736d39c3ec0d..08b449159fd1 100644
--- a/include/linux/mfd/max14577.h
+++ b/include/linux/mfd/max14577.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * max14577.h - Driver for the Maxim 14577 2 * max14577.h - Driver for the Maxim 14577/77836
3 * 3 *
4 * Copyright (C) 2013 Samsung Electrnoics 4 * Copyright (C) 2014 Samsung Electrnoics
5 * Chanwoo Choi <cw00.choi@samsung.com> 5 * Chanwoo Choi <cw00.choi@samsung.com>
6 * Krzysztof Kozlowski <k.kozlowski@samsung.com> 6 * Krzysztof Kozlowski <k.kozlowski@samsung.com>
7 * 7 *
@@ -20,6 +20,9 @@
20 * MAX14577 has MUIC, Charger devices. 20 * MAX14577 has MUIC, Charger devices.
21 * The devices share the same I2C bus and interrupt line 21 * The devices share the same I2C bus and interrupt line
22 * included in this mfd driver. 22 * included in this mfd driver.
23 *
24 * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave
25 * addresses.
23 */ 26 */
24 27
25#ifndef __MAX14577_H__ 28#ifndef __MAX14577_H__