1*3008ddbeSChanwoo Choi /* 2*3008ddbeSChanwoo Choi * max14577-private.h - Common API for the Maxim 14577 internal sub chip 3*3008ddbeSChanwoo Choi * 4*3008ddbeSChanwoo Choi * Copyright (C) 2013 Samsung Electrnoics 5*3008ddbeSChanwoo Choi * Chanwoo Choi <cw00.choi@samsung.com> 6*3008ddbeSChanwoo Choi * Krzysztof Kozlowski <k.kozlowski@samsung.com> 7*3008ddbeSChanwoo Choi * 8*3008ddbeSChanwoo Choi * This program is free software; you can redistribute it and/or modify 9*3008ddbeSChanwoo Choi * it under the terms of the GNU General Public License as published by 10*3008ddbeSChanwoo Choi * the Free Software Foundation; either version 2 of the License, or 11*3008ddbeSChanwoo Choi * (at your option) any later version. 12*3008ddbeSChanwoo Choi * 13*3008ddbeSChanwoo Choi * This program is distributed in the hope that it will be useful, 14*3008ddbeSChanwoo Choi * but WITHOUT ANY WARRANTY; without even the implied warranty of 15*3008ddbeSChanwoo Choi * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16*3008ddbeSChanwoo Choi * GNU General Public License for more details. 17*3008ddbeSChanwoo Choi */ 18*3008ddbeSChanwoo Choi 19*3008ddbeSChanwoo Choi #ifndef __MAX14577_PRIVATE_H__ 20*3008ddbeSChanwoo Choi #define __MAX14577_PRIVATE_H__ 21*3008ddbeSChanwoo Choi 22*3008ddbeSChanwoo Choi #include <linux/i2c.h> 23*3008ddbeSChanwoo Choi #include <linux/regmap.h> 24*3008ddbeSChanwoo Choi 25*3008ddbeSChanwoo Choi #define MAX14577_REG_INVALID (0xff) 26*3008ddbeSChanwoo Choi 27*3008ddbeSChanwoo Choi /* Slave addr = 0x4A: Interrupt */ 28*3008ddbeSChanwoo Choi enum max14577_reg { 29*3008ddbeSChanwoo Choi MAX14577_REG_DEVICEID = 0x00, 30*3008ddbeSChanwoo Choi MAX14577_REG_INT1 = 0x01, 31*3008ddbeSChanwoo Choi MAX14577_REG_INT2 = 0x02, 32*3008ddbeSChanwoo Choi MAX14577_REG_INT3 = 0x03, 33*3008ddbeSChanwoo Choi MAX14577_REG_STATUS1 = 0x04, 34*3008ddbeSChanwoo Choi MAX14577_REG_STATUS2 = 0x05, 35*3008ddbeSChanwoo Choi MAX14577_REG_STATUS3 = 0x06, 36*3008ddbeSChanwoo Choi MAX14577_REG_INTMASK1 = 0x07, 37*3008ddbeSChanwoo Choi MAX14577_REG_INTMASK2 = 0x08, 38*3008ddbeSChanwoo Choi MAX14577_REG_INTMASK3 = 0x09, 39*3008ddbeSChanwoo Choi MAX14577_REG_CDETCTRL1 = 0x0A, 40*3008ddbeSChanwoo Choi MAX14577_REG_RFU = 0x0B, 41*3008ddbeSChanwoo Choi MAX14577_REG_CONTROL1 = 0x0C, 42*3008ddbeSChanwoo Choi MAX14577_REG_CONTROL2 = 0x0D, 43*3008ddbeSChanwoo Choi MAX14577_REG_CONTROL3 = 0x0E, 44*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL1 = 0x0F, 45*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL2 = 0x10, 46*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL3 = 0x11, 47*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL4 = 0x12, 48*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL5 = 0x13, 49*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL6 = 0x14, 50*3008ddbeSChanwoo Choi MAX14577_REG_CHGCTRL7 = 0x15, 51*3008ddbeSChanwoo Choi 52*3008ddbeSChanwoo Choi MAX14577_REG_END, 53*3008ddbeSChanwoo Choi }; 54*3008ddbeSChanwoo Choi 55*3008ddbeSChanwoo Choi /* Slave addr = 0x4A: MUIC */ 56*3008ddbeSChanwoo Choi enum max14577_muic_reg { 57*3008ddbeSChanwoo Choi MAX14577_MUIC_REG_STATUS1 = 0x04, 58*3008ddbeSChanwoo Choi MAX14577_MUIC_REG_STATUS2 = 0x05, 59*3008ddbeSChanwoo Choi MAX14577_MUIC_REG_CONTROL1 = 0x0C, 60*3008ddbeSChanwoo Choi MAX14577_MUIC_REG_CONTROL3 = 0x0E, 61*3008ddbeSChanwoo Choi 62*3008ddbeSChanwoo Choi MAX14577_MUIC_REG_END, 63*3008ddbeSChanwoo Choi }; 64*3008ddbeSChanwoo Choi 65*3008ddbeSChanwoo Choi enum max14577_muic_charger_type { 66*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_NONE = 0, 67*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_USB, 68*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_DOWNSTREAM_PORT, 69*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_DEDICATED_CHG, 70*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_SPECIAL_500MA, 71*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_SPECIAL_1A, 72*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_RESERVED, 73*3008ddbeSChanwoo Choi MAX14577_CHARGER_TYPE_DEAD_BATTERY = 7, 74*3008ddbeSChanwoo Choi }; 75*3008ddbeSChanwoo Choi 76*3008ddbeSChanwoo Choi /* MAX14577 interrupts */ 77*3008ddbeSChanwoo Choi #define INT1_ADC_MASK (0x1 << 0) 78*3008ddbeSChanwoo Choi #define INT1_ADCLOW_MASK (0x1 << 1) 79*3008ddbeSChanwoo Choi #define INT1_ADCERR_MASK (0x1 << 2) 80*3008ddbeSChanwoo Choi 81*3008ddbeSChanwoo Choi #define INT2_CHGTYP_MASK (0x1 << 0) 82*3008ddbeSChanwoo Choi #define INT2_CHGDETRUN_MASK (0x1 << 1) 83*3008ddbeSChanwoo Choi #define INT2_DCDTMR_MASK (0x1 << 2) 84*3008ddbeSChanwoo Choi #define INT2_DBCHG_MASK (0x1 << 3) 85*3008ddbeSChanwoo Choi #define INT2_VBVOLT_MASK (0x1 << 4) 86*3008ddbeSChanwoo Choi 87*3008ddbeSChanwoo Choi #define INT3_EOC_MASK (0x1 << 0) 88*3008ddbeSChanwoo Choi #define INT3_CGMBC_MASK (0x1 << 1) 89*3008ddbeSChanwoo Choi #define INT3_OVP_MASK (0x1 << 2) 90*3008ddbeSChanwoo Choi #define INT3_MBCCHGERR_MASK (0x1 << 3) 91*3008ddbeSChanwoo Choi 92*3008ddbeSChanwoo Choi /* MAX14577 DEVICE ID register */ 93*3008ddbeSChanwoo Choi #define DEVID_VENDORID_SHIFT 0 94*3008ddbeSChanwoo Choi #define DEVID_DEVICEID_SHIFT 3 95*3008ddbeSChanwoo Choi #define DEVID_VENDORID_MASK (0x07 << DEVID_VENDORID_SHIFT) 96*3008ddbeSChanwoo Choi #define DEVID_DEVICEID_MASK (0x1f << DEVID_DEVICEID_SHIFT) 97*3008ddbeSChanwoo Choi 98*3008ddbeSChanwoo Choi /* MAX14577 STATUS1 register */ 99*3008ddbeSChanwoo Choi #define STATUS1_ADC_SHIFT 0 100*3008ddbeSChanwoo Choi #define STATUS1_ADCLOW_SHIFT 5 101*3008ddbeSChanwoo Choi #define STATUS1_ADCERR_SHIFT 6 102*3008ddbeSChanwoo Choi #define STATUS1_ADC_MASK (0x1f << STATUS1_ADC_SHIFT) 103*3008ddbeSChanwoo Choi #define STATUS1_ADCLOW_MASK (0x1 << STATUS1_ADCLOW_SHIFT) 104*3008ddbeSChanwoo Choi #define STATUS1_ADCERR_MASK (0x1 << STATUS1_ADCERR_SHIFT) 105*3008ddbeSChanwoo Choi 106*3008ddbeSChanwoo Choi /* MAX14577 STATUS2 register */ 107*3008ddbeSChanwoo Choi #define STATUS2_CHGTYP_SHIFT 0 108*3008ddbeSChanwoo Choi #define STATUS2_CHGDETRUN_SHIFT 3 109*3008ddbeSChanwoo Choi #define STATUS2_DCDTMR_SHIFT 4 110*3008ddbeSChanwoo Choi #define STATUS2_DBCHG_SHIFT 5 111*3008ddbeSChanwoo Choi #define STATUS2_VBVOLT_SHIFT 6 112*3008ddbeSChanwoo Choi #define STATUS2_CHGTYP_MASK (0x7 << STATUS2_CHGTYP_SHIFT) 113*3008ddbeSChanwoo Choi #define STATUS2_CHGDETRUN_MASK (0x1 << STATUS2_CHGDETRUN_SHIFT) 114*3008ddbeSChanwoo Choi #define STATUS2_DCDTMR_MASK (0x1 << STATUS2_DCDTMR_SHIFT) 115*3008ddbeSChanwoo Choi #define STATUS2_DBCHG_MASK (0x1 << STATUS2_DBCHG_SHIFT) 116*3008ddbeSChanwoo Choi #define STATUS2_VBVOLT_MASK (0x1 << STATUS2_VBVOLT_SHIFT) 117*3008ddbeSChanwoo Choi 118*3008ddbeSChanwoo Choi /* MAX14577 CONTROL1 register */ 119*3008ddbeSChanwoo Choi #define COMN1SW_SHIFT 0 120*3008ddbeSChanwoo Choi #define COMP2SW_SHIFT 3 121*3008ddbeSChanwoo Choi #define MICEN_SHIFT 6 122*3008ddbeSChanwoo Choi #define IDBEN_SHIFT 7 123*3008ddbeSChanwoo Choi #define COMN1SW_MASK (0x7 << COMN1SW_SHIFT) 124*3008ddbeSChanwoo Choi #define COMP2SW_MASK (0x7 << COMP2SW_SHIFT) 125*3008ddbeSChanwoo Choi #define MICEN_MASK (0x1 << MICEN_SHIFT) 126*3008ddbeSChanwoo Choi #define IDBEN_MASK (0x1 << IDBEN_SHIFT) 127*3008ddbeSChanwoo Choi #define CLEAR_IDBEN_MICEN_MASK (COMN1SW_MASK | COMP2SW_MASK) 128*3008ddbeSChanwoo Choi #define CTRL1_SW_USB ((1 << COMP2SW_SHIFT) \ 129*3008ddbeSChanwoo Choi | (1 << COMN1SW_SHIFT)) 130*3008ddbeSChanwoo Choi #define CTRL1_SW_AUDIO ((2 << COMP2SW_SHIFT) \ 131*3008ddbeSChanwoo Choi | (2 << COMN1SW_SHIFT)) 132*3008ddbeSChanwoo Choi #define CTRL1_SW_UART ((3 << COMP2SW_SHIFT) \ 133*3008ddbeSChanwoo Choi | (3 << COMN1SW_SHIFT)) 134*3008ddbeSChanwoo Choi #define CTRL1_SW_OPEN ((0 << COMP2SW_SHIFT) \ 135*3008ddbeSChanwoo Choi | (0 << COMN1SW_SHIFT)) 136*3008ddbeSChanwoo Choi 137*3008ddbeSChanwoo Choi /* MAX14577 CONTROL2 register */ 138*3008ddbeSChanwoo Choi #define CTRL2_LOWPWR_SHIFT (0) 139*3008ddbeSChanwoo Choi #define CTRL2_ADCEN_SHIFT (1) 140*3008ddbeSChanwoo Choi #define CTRL2_CPEN_SHIFT (2) 141*3008ddbeSChanwoo Choi #define CTRL2_SFOUTASRT_SHIFT (3) 142*3008ddbeSChanwoo Choi #define CTRL2_SFOUTORD_SHIFT (4) 143*3008ddbeSChanwoo Choi #define CTRL2_ACCDET_SHIFT (5) 144*3008ddbeSChanwoo Choi #define CTRL2_USBCPINT_SHIFT (6) 145*3008ddbeSChanwoo Choi #define CTRL2_RCPS_SHIFT (7) 146*3008ddbeSChanwoo Choi #define CTRL2_LOWPWR_MASK (0x1 << CTRL2_LOWPWR_SHIFT) 147*3008ddbeSChanwoo Choi #define CTRL2_ADCEN_MASK (0x1 << CTRL2_ADCEN_SHIFT) 148*3008ddbeSChanwoo Choi #define CTRL2_CPEN_MASK (0x1 << CTRL2_CPEN_SHIFT) 149*3008ddbeSChanwoo Choi #define CTRL2_SFOUTASRT_MASK (0x1 << CTRL2_SFOUTASRT_SHIFT) 150*3008ddbeSChanwoo Choi #define CTRL2_SFOUTORD_MASK (0x1 << CTRL2_SFOUTORD_SHIFT) 151*3008ddbeSChanwoo Choi #define CTRL2_ACCDET_MASK (0x1 << CTRL2_ACCDET_SHIFT) 152*3008ddbeSChanwoo Choi #define CTRL2_USBCPINT_MASK (0x1 << CTRL2_USBCPINT_SHIFT) 153*3008ddbeSChanwoo Choi #define CTRL2_RCPS_MASK (0x1 << CTR2_RCPS_SHIFT) 154*3008ddbeSChanwoo Choi 155*3008ddbeSChanwoo Choi #define CTRL2_CPEN1_LOWPWR0 ((1 << CTRL2_CPEN_SHIFT) | \ 156*3008ddbeSChanwoo Choi (0 << CTRL2_LOWPWR_SHIFT)) 157*3008ddbeSChanwoo Choi #define CTRL2_CPEN0_LOWPWR1 ((0 << CTRL2_CPEN_SHIFT) | \ 158*3008ddbeSChanwoo Choi (1 << CTRL2_LOWPWR_SHIFT)) 159*3008ddbeSChanwoo Choi 160*3008ddbeSChanwoo Choi /* MAX14577 CONTROL3 register */ 161*3008ddbeSChanwoo Choi #define CTRL3_JIGSET_SHIFT 0 162*3008ddbeSChanwoo Choi #define CTRL3_BOOTSET_SHIFT 2 163*3008ddbeSChanwoo Choi #define CTRL3_ADCDBSET_SHIFT 4 164*3008ddbeSChanwoo Choi #define CTRL3_JIGSET_MASK (0x3 << CTRL3_JIGSET_SHIFT) 165*3008ddbeSChanwoo Choi #define CTRL3_BOOTSET_MASK (0x3 << CTRL3_BOOTSET_SHIFT) 166*3008ddbeSChanwoo Choi #define CTRL3_ADCDBSET_MASK (0x3 << CTRL3_ADCDBSET_SHIFT) 167*3008ddbeSChanwoo Choi 168*3008ddbeSChanwoo Choi /* Slave addr = 0x4A: Charger */ 169*3008ddbeSChanwoo Choi enum max14577_charger_reg { 170*3008ddbeSChanwoo Choi MAX14577_CHG_REG_STATUS3 = 0x06, 171*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL1 = 0x0F, 172*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL2 = 0x10, 173*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL3 = 0x11, 174*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL4 = 0x12, 175*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL5 = 0x13, 176*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL6 = 0x14, 177*3008ddbeSChanwoo Choi MAX14577_CHG_REG_CHG_CTRL7 = 0x15, 178*3008ddbeSChanwoo Choi 179*3008ddbeSChanwoo Choi MAX14577_CHG_REG_END, 180*3008ddbeSChanwoo Choi }; 181*3008ddbeSChanwoo Choi 182*3008ddbeSChanwoo Choi /* MAX14577 STATUS3 register */ 183*3008ddbeSChanwoo Choi #define STATUS3_EOC_SHIFT 0 184*3008ddbeSChanwoo Choi #define STATUS3_CGMBC_SHIFT 1 185*3008ddbeSChanwoo Choi #define STATUS3_OVP_SHIFT 2 186*3008ddbeSChanwoo Choi #define STATUS3_MBCCHGERR_SHIFT 3 187*3008ddbeSChanwoo Choi #define STATUS3_EOC_MASK (0x1 << STATUS3_EOC_SHIFT) 188*3008ddbeSChanwoo Choi #define STATUS3_CGMBC_MASK (0x1 << STATUS3_CGMBC_SHIFT) 189*3008ddbeSChanwoo Choi #define STATUS3_OVP_MASK (0x1 << STATUS3_OVP_SHIFT) 190*3008ddbeSChanwoo Choi #define STATUS3_MBCCHGERR_MASK (0x1 << STATUS3_MBCCHGERR_SHIFT) 191*3008ddbeSChanwoo Choi 192*3008ddbeSChanwoo Choi /* MAX14577 CDETCTRL1 register */ 193*3008ddbeSChanwoo Choi #define CDETCTRL1_CHGDETEN_SHIFT 0 194*3008ddbeSChanwoo Choi #define CDETCTRL1_CHGTYPMAN_SHIFT 1 195*3008ddbeSChanwoo Choi #define CDETCTRL1_DCDEN_SHIFT 2 196*3008ddbeSChanwoo Choi #define CDETCTRL1_DCD2SCT_SHIFT 3 197*3008ddbeSChanwoo Choi #define CDETCTRL1_DCHKTM_SHIFT 4 198*3008ddbeSChanwoo Choi #define CDETCTRL1_DBEXIT_SHIFT 5 199*3008ddbeSChanwoo Choi #define CDETCTRL1_DBIDLE_SHIFT 6 200*3008ddbeSChanwoo Choi #define CDETCTRL1_CDPDET_SHIFT 7 201*3008ddbeSChanwoo Choi #define CDETCTRL1_CHGDETEN_MASK (0x1 << CDETCTRL1_CHGDETEN_SHIFT) 202*3008ddbeSChanwoo Choi #define CDETCTRL1_CHGTYPMAN_MASK (0x1 << CDETCTRL1_CHGTYPMAN_SHIFT) 203*3008ddbeSChanwoo Choi #define CDETCTRL1_DCDEN_MASK (0x1 << CDETCTRL1_DCDEN_SHIFT) 204*3008ddbeSChanwoo Choi #define CDETCTRL1_DCD2SCT_MASK (0x1 << CDETCTRL1_DCD2SCT_SHIFT) 205*3008ddbeSChanwoo Choi #define CDETCTRL1_DCHKTM_MASK (0x1 << CDETCTRL1_DCHKTM_SHIFT) 206*3008ddbeSChanwoo Choi #define CDETCTRL1_DBEXIT_MASK (0x1 << CDETCTRL1_DBEXIT_SHIFT) 207*3008ddbeSChanwoo Choi #define CDETCTRL1_DBIDLE_MASK (0x1 << CDETCTRL1_DBIDLE_SHIFT) 208*3008ddbeSChanwoo Choi #define CDETCTRL1_CDPDET_MASK (0x1 << CDETCTRL1_CDPDET_SHIFT) 209*3008ddbeSChanwoo Choi 210*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL1 register */ 211*3008ddbeSChanwoo Choi #define CHGCTRL1_TCHW_SHIFT 4 212*3008ddbeSChanwoo Choi #define CHGCTRL1_TCHW_MASK (0x7 << CHGCTRL1_TCHW_SHIFT) 213*3008ddbeSChanwoo Choi 214*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL2 register */ 215*3008ddbeSChanwoo Choi #define CHGCTRL2_MBCHOSTEN_SHIFT 6 216*3008ddbeSChanwoo Choi #define CHGCTRL2_MBCHOSTEN_MASK (0x1 << CHGCTRL2_MBCHOSTEN_SHIFT) 217*3008ddbeSChanwoo Choi #define CHGCTRL2_VCHGR_RC_SHIFT 7 218*3008ddbeSChanwoo Choi #define CHGCTRL2_VCHGR_RC_MASK (0x1 << CHGCTRL2_VCHGR_RC_SHIFT) 219*3008ddbeSChanwoo Choi 220*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL3 register */ 221*3008ddbeSChanwoo Choi #define CHGCTRL3_MBCCVWRC_SHIFT 0 222*3008ddbeSChanwoo Choi #define CHGCTRL3_MBCCVWRC_MASK (0xf << CHGCTRL3_MBCCVWRC_SHIFT) 223*3008ddbeSChanwoo Choi 224*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL4 register */ 225*3008ddbeSChanwoo Choi #define CHGCTRL4_MBCICHWRCH_SHIFT 0 226*3008ddbeSChanwoo Choi #define CHGCTRL4_MBCICHWRCH_MASK (0xf << CHGCTRL4_MBCICHWRCH_SHIFT) 227*3008ddbeSChanwoo Choi #define CHGCTRL4_MBCICHWRCL_SHIFT 4 228*3008ddbeSChanwoo Choi #define CHGCTRL4_MBCICHWRCL_MASK (0x1 << CHGCTRL4_MBCICHWRCL_SHIFT) 229*3008ddbeSChanwoo Choi 230*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL5 register */ 231*3008ddbeSChanwoo Choi #define CHGCTRL5_EOCS_SHIFT 0 232*3008ddbeSChanwoo Choi #define CHGCTRL5_EOCS_MASK (0xf << CHGCTRL5_EOCS_SHIFT) 233*3008ddbeSChanwoo Choi 234*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL6 register */ 235*3008ddbeSChanwoo Choi #define CHGCTRL6_AUTOSTOP_SHIFT 5 236*3008ddbeSChanwoo Choi #define CHGCTRL6_AUTOSTOP_MASK (0x1 << CHGCTRL6_AUTOSTOP_SHIFT) 237*3008ddbeSChanwoo Choi 238*3008ddbeSChanwoo Choi /* MAX14577 CHGCTRL7 register */ 239*3008ddbeSChanwoo Choi #define CHGCTRL7_OTPCGHCVS_SHIFT 0 240*3008ddbeSChanwoo Choi #define CHGCTRL7_OTPCGHCVS_MASK (0x3 << CHGCTRL7_OTPCGHCVS_SHIFT) 241*3008ddbeSChanwoo Choi 242*3008ddbeSChanwoo Choi /* MAX14577 regulator current limits (as in CHGCTRL4 register), uA */ 243*3008ddbeSChanwoo Choi #define MAX14577_REGULATOR_CURRENT_LIMIT_MIN 90000 244*3008ddbeSChanwoo Choi #define MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START 200000 245*3008ddbeSChanwoo Choi #define MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP 50000 246*3008ddbeSChanwoo Choi #define MAX14577_REGULATOR_CURRENT_LIMIT_MAX 950000 247*3008ddbeSChanwoo Choi 248*3008ddbeSChanwoo Choi /* MAX14577 regulator SFOUT LDO voltage, fixed, uV */ 249*3008ddbeSChanwoo Choi #define MAX14577_REGULATOR_SAFEOUT_VOLTAGE 4900000 250*3008ddbeSChanwoo Choi 251*3008ddbeSChanwoo Choi enum max14577_irq_source { 252*3008ddbeSChanwoo Choi MAX14577_IRQ_INT1 = 0, 253*3008ddbeSChanwoo Choi MAX14577_IRQ_INT2, 254*3008ddbeSChanwoo Choi MAX14577_IRQ_INT3, 255*3008ddbeSChanwoo Choi 256*3008ddbeSChanwoo Choi MAX14577_IRQ_REGS_NUM, 257*3008ddbeSChanwoo Choi }; 258*3008ddbeSChanwoo Choi 259*3008ddbeSChanwoo Choi enum max14577_irq { 260*3008ddbeSChanwoo Choi /* INT1 */ 261*3008ddbeSChanwoo Choi MAX14577_IRQ_INT1_ADC, 262*3008ddbeSChanwoo Choi MAX14577_IRQ_INT1_ADCLOW, 263*3008ddbeSChanwoo Choi MAX14577_IRQ_INT1_ADCERR, 264*3008ddbeSChanwoo Choi 265*3008ddbeSChanwoo Choi /* INT2 */ 266*3008ddbeSChanwoo Choi MAX14577_IRQ_INT2_CHGTYP, 267*3008ddbeSChanwoo Choi MAX14577_IRQ_INT2_CHGDETRUN, 268*3008ddbeSChanwoo Choi MAX14577_IRQ_INT2_DCDTMR, 269*3008ddbeSChanwoo Choi MAX14577_IRQ_INT2_DBCHG, 270*3008ddbeSChanwoo Choi MAX14577_IRQ_INT2_VBVOLT, 271*3008ddbeSChanwoo Choi 272*3008ddbeSChanwoo Choi /* INT3 */ 273*3008ddbeSChanwoo Choi MAX14577_IRQ_INT3_EOC, 274*3008ddbeSChanwoo Choi MAX14577_IRQ_INT3_CGMBC, 275*3008ddbeSChanwoo Choi MAX14577_IRQ_INT3_OVP, 276*3008ddbeSChanwoo Choi MAX14577_IRQ_INT3_MBCCHGERR, 277*3008ddbeSChanwoo Choi 278*3008ddbeSChanwoo Choi MAX14577_IRQ_NUM, 279*3008ddbeSChanwoo Choi }; 280*3008ddbeSChanwoo Choi 281*3008ddbeSChanwoo Choi struct max14577 { 282*3008ddbeSChanwoo Choi struct device *dev; 283*3008ddbeSChanwoo Choi struct i2c_client *i2c; /* Slave addr = 0x4A */ 284*3008ddbeSChanwoo Choi 285*3008ddbeSChanwoo Choi struct regmap *regmap; 286*3008ddbeSChanwoo Choi 287*3008ddbeSChanwoo Choi struct regmap_irq_chip_data *irq_data; 288*3008ddbeSChanwoo Choi int irq; 289*3008ddbeSChanwoo Choi 290*3008ddbeSChanwoo Choi /* Device ID */ 291*3008ddbeSChanwoo Choi u8 vendor_id; /* Vendor Identification */ 292*3008ddbeSChanwoo Choi u8 device_id; /* Chip Version */ 293*3008ddbeSChanwoo Choi }; 294*3008ddbeSChanwoo Choi 295*3008ddbeSChanwoo Choi /* MAX14577 shared regmap API function */ 296*3008ddbeSChanwoo Choi static inline int max14577_read_reg(struct regmap *map, u8 reg, u8 *dest) 297*3008ddbeSChanwoo Choi { 298*3008ddbeSChanwoo Choi unsigned int val; 299*3008ddbeSChanwoo Choi int ret; 300*3008ddbeSChanwoo Choi 301*3008ddbeSChanwoo Choi ret = regmap_read(map, reg, &val); 302*3008ddbeSChanwoo Choi *dest = val; 303*3008ddbeSChanwoo Choi 304*3008ddbeSChanwoo Choi return ret; 305*3008ddbeSChanwoo Choi } 306*3008ddbeSChanwoo Choi 307*3008ddbeSChanwoo Choi static inline int max14577_bulk_read(struct regmap *map, u8 reg, u8 *buf, 308*3008ddbeSChanwoo Choi int count) 309*3008ddbeSChanwoo Choi { 310*3008ddbeSChanwoo Choi return regmap_bulk_read(map, reg, buf, count); 311*3008ddbeSChanwoo Choi } 312*3008ddbeSChanwoo Choi 313*3008ddbeSChanwoo Choi static inline int max14577_write_reg(struct regmap *map, u8 reg, u8 value) 314*3008ddbeSChanwoo Choi { 315*3008ddbeSChanwoo Choi return regmap_write(map, reg, value); 316*3008ddbeSChanwoo Choi } 317*3008ddbeSChanwoo Choi 318*3008ddbeSChanwoo Choi static inline int max14577_bulk_write(struct regmap *map, u8 reg, u8 *buf, 319*3008ddbeSChanwoo Choi int count) 320*3008ddbeSChanwoo Choi { 321*3008ddbeSChanwoo Choi return regmap_bulk_write(map, reg, buf, count); 322*3008ddbeSChanwoo Choi } 323*3008ddbeSChanwoo Choi 324*3008ddbeSChanwoo Choi static inline int max14577_update_reg(struct regmap *map, u8 reg, u8 mask, 325*3008ddbeSChanwoo Choi u8 val) 326*3008ddbeSChanwoo Choi { 327*3008ddbeSChanwoo Choi return regmap_update_bits(map, reg, mask, val); 328*3008ddbeSChanwoo Choi } 329*3008ddbeSChanwoo Choi 330*3008ddbeSChanwoo Choi #endif /* __MAX14577_PRIVATE_H__ */ 331