1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef __DA9150_CORE_H
15#define __DA9150_CORE_H
16
17#include <linux/device.h>
18#include <linux/i2c.h>
19#include <linux/interrupt.h>
20#include <linux/regmap.h>
21
22
23#define DA9150_REG_PAGE_SHIFT 8
24#define DA9150_REG_PAGE_MASK 0xFF
25
26
27#define DA9150_NUM_IRQ_REGS 4
28#define DA9150_IRQ_VBUS 0
29#define DA9150_IRQ_CHG 1
30#define DA9150_IRQ_TCLASS 2
31#define DA9150_IRQ_TJUNC 3
32#define DA9150_IRQ_VFAULT 4
33#define DA9150_IRQ_CONF 5
34#define DA9150_IRQ_DAT 6
35#define DA9150_IRQ_DTYPE 7
36#define DA9150_IRQ_ID 8
37#define DA9150_IRQ_ADP 9
38#define DA9150_IRQ_SESS_END 10
39#define DA9150_IRQ_SESS_VLD 11
40#define DA9150_IRQ_FG 12
41#define DA9150_IRQ_GP 13
42#define DA9150_IRQ_TBAT 14
43#define DA9150_IRQ_GPIOA 15
44#define DA9150_IRQ_GPIOB 16
45#define DA9150_IRQ_GPIOC 17
46#define DA9150_IRQ_GPIOD 18
47#define DA9150_IRQ_GPADC 19
48#define DA9150_IRQ_WKUP 20
49
50
51#define DA9150_QIF_I2C_ADDR_LSB 0x5
52
53struct da9150_fg_pdata {
54 u32 update_interval;
55 u8 warn_soc_lvl;
56 u8 crit_soc_lvl;
57};
58
59struct da9150_pdata {
60 int irq_base;
61 struct da9150_fg_pdata *fg_pdata;
62};
63
64struct da9150 {
65 struct device *dev;
66 struct regmap *regmap;
67 struct i2c_client *core_qif;
68
69 struct regmap_irq_chip_data *regmap_irq_data;
70 int irq;
71 int irq_base;
72};
73
74
75void da9150_read_qif(struct da9150 *da9150, u8 addr, int count, u8 *buf);
76void da9150_write_qif(struct da9150 *da9150, u8 addr, int count, const u8 *buf);
77
78u8 da9150_reg_read(struct da9150 *da9150, u16 reg);
79void da9150_reg_write(struct da9150 *da9150, u16 reg, u8 val);
80void da9150_set_bits(struct da9150 *da9150, u16 reg, u8 mask, u8 val);
81
82void da9150_bulk_read(struct da9150 *da9150, u16 reg, int count, u8 *buf);
83void da9150_bulk_write(struct da9150 *da9150, u16 reg, int count, const u8 *buf);
84
85#endif
86