2 * Copyright (C) 2011-2012 Samsung Electronics
3 * Lukasz Majewski <l.majewski@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <linux/list.h>
13 #include <power/power_chrg.h>
15 enum { PMIC_I2C, PMIC_SPI, PMIC_NONE};
16 enum { I2C_PMIC, I2C_NUM, };
17 enum { PMIC_READ, PMIC_WRITE, };
18 enum { PMIC_SENSOR_BYTE_ORDER_LITTLE, PMIC_SENSOR_BYTE_ORDER_BIG, };
37 u32 (*prepare_tx)(u32 reg, u32 *val, u32 write);
42 int (*fg_battery_check) (struct pmic *p, struct pmic *bat);
43 int (*fg_battery_update) (struct pmic *p, struct pmic *bat);
47 int (*chrg_type) (struct pmic *p);
48 int (*chrg_bat_present) (struct pmic *p);
49 int (*chrg_state) (struct pmic *p, int state, int current);
52 struct power_battery {
54 int (*battery_init) (struct pmic *bat, struct pmic *p1,
55 struct pmic *p2, struct pmic *p3);
56 int (*battery_charge) (struct pmic *bat);
57 /* Keep info about power devices involved with battery operation */
58 struct pmic *chrg, *fg, *muic;
64 unsigned char interface;
65 unsigned char sensor_byte_order;
66 unsigned int number_of_regs;
72 void (*low_power_mode) (void);
73 struct power_battery *pbat;
74 struct power_chrg *chrg;
78 struct list_head list;
81 int pmic_init(unsigned char bus);
82 int power_init_board(void);
83 int pmic_dialog_init(unsigned char bus);
84 int check_reg(struct pmic *p, u32 reg);
85 struct pmic *pmic_alloc(void);
86 struct pmic *pmic_get(const char *s);
87 int pmic_probe(struct pmic *p);
88 int pmic_reg_read(struct pmic *p, u32 reg, u32 *val);
89 int pmic_reg_write(struct pmic *p, u32 reg, u32 val);
90 int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on);
92 #define pmic_i2c_addr (p->hw.i2c.addr)
93 #define pmic_i2c_tx_num (p->hw.i2c.tx_num)
95 #define pmic_spi_bitlen (p->hw.spi.bitlen)
96 #define pmic_spi_flags (p->hw.spi.flags)
98 #endif /* __CORE_PMIC_H_ */