1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef __CORE_PMIC_H_
25#define __CORE_PMIC_H_
26
27enum { PMIC_I2C, PMIC_SPI, };
28enum { I2C_PMIC, I2C_NUM, };
29enum { PMIC_READ, PMIC_WRITE, };
30
31struct p_i2c {
32 unsigned char addr;
33 unsigned char *buf;
34 unsigned char tx_num;
35};
36
37struct p_spi {
38 unsigned int cs;
39 unsigned int mode;
40 unsigned int bitlen;
41 unsigned int clk;
42 unsigned int flags;
43 u32 (*prepare_tx)(u32 reg, u32 *val, u32 write);
44};
45
46struct pmic {
47 const char *name;
48 unsigned char bus;
49 unsigned char interface;
50 unsigned char number_of_regs;
51 union hw {
52 struct p_i2c i2c;
53 struct p_spi spi;
54 } hw;
55};
56
57int pmic_init(void);
58int check_reg(u32 reg);
59struct pmic *get_pmic(void);
60int pmic_probe(struct pmic *p);
61int pmic_reg_read(struct pmic *p, u32 reg, u32 *val);
62int pmic_reg_write(struct pmic *p, u32 reg, u32 val);
63int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on);
64
65#define pmic_i2c_addr (p->hw.i2c.addr)
66#define pmic_i2c_tx_num (p->hw.i2c.tx_num)
67
68#define pmic_spi_bitlen (p->hw.spi.bitlen)
69#define pmic_spi_flags (p->hw.spi.flags)
70
71#endif
72