Lines Matching refs:p

17 static int fg_write_regs(struct pmic *p, u8 addr, u16 *data, int num)  in fg_write_regs()  argument
23 ret = pmic_reg_write(p, addr, *(data + i)); in fg_write_regs()
31 static int fg_read_regs(struct pmic *p, u8 addr, u16 *data, int num) in fg_read_regs() argument
38 ret = pmic_reg_read(p, addr, &dat); in fg_read_regs()
48 static int fg_write_and_verify(struct pmic *p, u8 addr, u16 data) in fg_write_and_verify() argument
53 ret |= pmic_reg_write(p, addr, val); in fg_write_and_verify()
54 ret |= pmic_reg_read(p, addr, &val); in fg_write_and_verify()
65 static void por_fuelgauge_init(struct pmic *p) in por_fuelgauge_init() argument
79 pmic_reg_write(p, MAX17042_CONFIG, 0x2310); in por_fuelgauge_init()
91 pmic_reg_write(p, MAX17042_MLOCKReg1, MODEL_UNLOCK1); in por_fuelgauge_init()
92 pmic_reg_write(p, MAX17042_MLOCKReg2, MODEL_UNLOCK2); in por_fuelgauge_init()
95 ret = fg_write_regs(p, MAX17042_MODEL1, cell_character0, in por_fuelgauge_init()
100 ret = fg_write_regs(p, MAX17042_MODEL2, cell_character1, in por_fuelgauge_init()
105 ret = fg_write_regs(p, MAX17042_MODEL3, cell_character2, in por_fuelgauge_init()
120 ret = fg_read_regs(p, MAX17042_MODEL1, r_data0, ARRAY_SIZE(r_data0)); in por_fuelgauge_init()
124 ret = fg_read_regs(p, MAX17042_MODEL2, r_data1, ARRAY_SIZE(r_data1)); in por_fuelgauge_init()
128 ret = fg_read_regs(p, MAX17042_MODEL3, r_data2, ARRAY_SIZE(r_data2)); in por_fuelgauge_init()
150 pmic_reg_write(p, MAX17042_MLOCKReg1, MODEL_LOCK1); in por_fuelgauge_init()
151 pmic_reg_write(p, MAX17042_MLOCKReg2, MODEL_LOCK2); in por_fuelgauge_init()
154 ret = fg_read_regs(p, MAX17042_MODEL1, r_data0, ARRAY_SIZE(r_data0)); in por_fuelgauge_init()
158 ret = fg_read_regs(p, MAX17042_MODEL2, r_data1, ARRAY_SIZE(r_data1)); in por_fuelgauge_init()
162 ret = fg_read_regs(p, MAX17042_MODEL3, r_data2, ARRAY_SIZE(r_data2)); in por_fuelgauge_init()
173 fg_write_and_verify(p, MAX17042_RCOMP0, RCOMP0); in por_fuelgauge_init()
174 fg_write_and_verify(p, MAX17042_TEMPCO, TempCo); in por_fuelgauge_init()
180 pmic_reg_read(p, MAX17042_STATUS, &val); in por_fuelgauge_init()
182 fg_write_and_verify(p, MAX17042_STATUS, val & ~MAX17042_POR); in por_fuelgauge_init()
189 debug("%s: model init status: %s\n", p->name, status_msg); in por_fuelgauge_init()
193 static int power_update_battery(struct pmic *p, struct pmic *bat) in power_update_battery() argument
199 if (pmic_probe(p)) { in power_update_battery()
204 ret |= pmic_reg_read(p, MAX17042_VFSOC, &val); in power_update_battery()
207 pmic_reg_read(p, MAX17042_VCELL, &val); in power_update_battery()
212 pmic_reg_read(p, 0x05, &val); in power_update_battery()
218 static int power_check_battery(struct pmic *p, struct pmic *bat) in power_check_battery() argument
224 if (pmic_probe(p)) { in power_check_battery()
229 ret |= pmic_reg_read(p, MAX17042_STATUS, &val); in power_check_battery()
233 por_fuelgauge_init(p); in power_check_battery()
235 ret |= pmic_reg_read(p, MAX17042_VERSION, &val); in power_check_battery()
238 power_update_battery(p, bat); in power_check_battery()
266 struct pmic *p = pmic_alloc(); in power_fg_init() local
268 if (!p) { in power_fg_init()
275 p->name = name; in power_fg_init()
276 p->interface = PMIC_I2C; in power_fg_init()
277 p->number_of_regs = FG_NUM_OF_REGS; in power_fg_init()
278 p->hw.i2c.addr = MAX17042_I2C_ADDR; in power_fg_init()
279 p->hw.i2c.tx_num = 2; in power_fg_init()
280 p->sensor_byte_order = PMIC_SENSOR_BYTE_ORDER_BIG; in power_fg_init()
281 p->bus = bus; in power_fg_init()
283 p->fg = &power_fg_ops; in power_fg_init()