diff options
Diffstat (limited to 'include/linux/mfd/max8998-private.h')
-rw-r--r-- | include/linux/mfd/max8998-private.h | 129 |
1 files changed, 96 insertions, 33 deletions
diff --git a/include/linux/mfd/max8998-private.h b/include/linux/mfd/max8998-private.h index 6dc75b3e2d33..7363dea6bbcd 100644 --- a/include/linux/mfd/max8998-private.h +++ b/include/linux/mfd/max8998-private.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * max8698.h - Voltage regulator driver for the Maxim 8998 | 2 | * max8998.h - Voltage regulator driver for the Maxim 8998 |
3 | * | 3 | * |
4 | * Copyright (C) 2009-2010 Samsung Electrnoics | 4 | * Copyright (C) 2009-2010 Samsung Electrnoics |
5 | * Kyungmin Park <kyungmin.park@samsung.com> | 5 | * Kyungmin Park <kyungmin.park@samsung.com> |
@@ -23,6 +23,8 @@ | |||
23 | #ifndef __LINUX_MFD_MAX8998_PRIV_H | 23 | #ifndef __LINUX_MFD_MAX8998_PRIV_H |
24 | #define __LINUX_MFD_MAX8998_PRIV_H | 24 | #define __LINUX_MFD_MAX8998_PRIV_H |
25 | 25 | ||
26 | #define MAX8998_NUM_IRQ_REGS 4 | ||
27 | |||
26 | /* MAX 8998 registers */ | 28 | /* MAX 8998 registers */ |
27 | enum { | 29 | enum { |
28 | MAX8998_REG_IRQ1, | 30 | MAX8998_REG_IRQ1, |
@@ -46,12 +48,12 @@ enum { | |||
46 | MAX8998_REG_ONOFF2, | 48 | MAX8998_REG_ONOFF2, |
47 | MAX8998_REG_ONOFF3, | 49 | MAX8998_REG_ONOFF3, |
48 | MAX8998_REG_ONOFF4, | 50 | MAX8998_REG_ONOFF4, |
49 | MAX8998_REG_BUCK1_DVSARM1, | 51 | MAX8998_REG_BUCK1_VOLTAGE1, |
50 | MAX8998_REG_BUCK1_DVSARM2, | 52 | MAX8998_REG_BUCK1_VOLTAGE2, |
51 | MAX8998_REG_BUCK1_DVSARM3, | 53 | MAX8998_REG_BUCK1_VOLTAGE3, |
52 | MAX8998_REG_BUCK1_DVSARM4, | 54 | MAX8998_REG_BUCK1_VOLTAGE4, |
53 | MAX8998_REG_BUCK2_DVSINT1, | 55 | MAX8998_REG_BUCK2_VOLTAGE1, |
54 | MAX8998_REG_BUCK2_DVSINT2, | 56 | MAX8998_REG_BUCK2_VOLTAGE2, |
55 | MAX8998_REG_BUCK3, | 57 | MAX8998_REG_BUCK3, |
56 | MAX8998_REG_BUCK4, | 58 | MAX8998_REG_BUCK4, |
57 | MAX8998_REG_LDO2_LDO3, | 59 | MAX8998_REG_LDO2_LDO3, |
@@ -72,41 +74,102 @@ enum { | |||
72 | MAX8998_REG_LBCNFG2, | 74 | MAX8998_REG_LBCNFG2, |
73 | }; | 75 | }; |
74 | 76 | ||
77 | /* IRQ definitions */ | ||
78 | enum { | ||
79 | MAX8998_IRQ_DCINF, | ||
80 | MAX8998_IRQ_DCINR, | ||
81 | MAX8998_IRQ_JIGF, | ||
82 | MAX8998_IRQ_JIGR, | ||
83 | MAX8998_IRQ_PWRONF, | ||
84 | MAX8998_IRQ_PWRONR, | ||
85 | |||
86 | MAX8998_IRQ_WTSREVNT, | ||
87 | MAX8998_IRQ_SMPLEVNT, | ||
88 | MAX8998_IRQ_ALARM1, | ||
89 | MAX8998_IRQ_ALARM0, | ||
90 | |||
91 | MAX8998_IRQ_ONKEY1S, | ||
92 | MAX8998_IRQ_TOPOFFR, | ||
93 | MAX8998_IRQ_DCINOVPR, | ||
94 | MAX8998_IRQ_CHGRSTF, | ||
95 | MAX8998_IRQ_DONER, | ||
96 | MAX8998_IRQ_CHGFAULT, | ||
97 | |||
98 | MAX8998_IRQ_LOBAT1, | ||
99 | MAX8998_IRQ_LOBAT2, | ||
100 | |||
101 | MAX8998_IRQ_NR, | ||
102 | }; | ||
103 | |||
104 | /* MAX8998 various variants */ | ||
105 | enum { | ||
106 | TYPE_MAX8998 = 0, /* Default */ | ||
107 | TYPE_LP3974, /* National version of MAX8998 */ | ||
108 | TYPE_LP3979, /* Added AVS */ | ||
109 | }; | ||
110 | |||
111 | #define MAX8998_IRQ_DCINF_MASK (1 << 2) | ||
112 | #define MAX8998_IRQ_DCINR_MASK (1 << 3) | ||
113 | #define MAX8998_IRQ_JIGF_MASK (1 << 4) | ||
114 | #define MAX8998_IRQ_JIGR_MASK (1 << 5) | ||
115 | #define MAX8998_IRQ_PWRONF_MASK (1 << 6) | ||
116 | #define MAX8998_IRQ_PWRONR_MASK (1 << 7) | ||
117 | |||
118 | #define MAX8998_IRQ_WTSREVNT_MASK (1 << 0) | ||
119 | #define MAX8998_IRQ_SMPLEVNT_MASK (1 << 1) | ||
120 | #define MAX8998_IRQ_ALARM1_MASK (1 << 2) | ||
121 | #define MAX8998_IRQ_ALARM0_MASK (1 << 3) | ||
122 | |||
123 | #define MAX8998_IRQ_ONKEY1S_MASK (1 << 0) | ||
124 | #define MAX8998_IRQ_TOPOFFR_MASK (1 << 2) | ||
125 | #define MAX8998_IRQ_DCINOVPR_MASK (1 << 3) | ||
126 | #define MAX8998_IRQ_CHGRSTF_MASK (1 << 4) | ||
127 | #define MAX8998_IRQ_DONER_MASK (1 << 5) | ||
128 | #define MAX8998_IRQ_CHGFAULT_MASK (1 << 7) | ||
129 | |||
130 | #define MAX8998_IRQ_LOBAT1_MASK (1 << 0) | ||
131 | #define MAX8998_IRQ_LOBAT2_MASK (1 << 1) | ||
132 | |||
133 | #define MAX8998_ENRAMP (1 << 4) | ||
134 | |||
75 | /** | 135 | /** |
76 | * struct max8998_dev - max8998 master device for sub-drivers | 136 | * struct max8998_dev - max8998 master device for sub-drivers |
77 | * @dev: master device of the chip (can be used to access platform data) | 137 | * @dev: master device of the chip (can be used to access platform data) |
78 | * @i2c_client: i2c client private data | 138 | * @i2c: i2c client private data for regulator |
79 | * @dev_read(): chip register read function | 139 | * @rtc: i2c client private data for rtc |
80 | * @dev_write(): chip register write function | ||
81 | * @dev_update(): chip register update function | ||
82 | * @iolock: mutex for serializing io access | 140 | * @iolock: mutex for serializing io access |
141 | * @irqlock: mutex for buslock | ||
142 | * @irq_base: base IRQ number for max8998, required for IRQs | ||
143 | * @irq: generic IRQ number for max8998 | ||
144 | * @ono: power onoff IRQ number for max8998 | ||
145 | * @irq_masks_cur: currently active value | ||
146 | * @irq_masks_cache: cached hardware value | ||
147 | * @type: indicate which max8998 "variant" is used | ||
83 | */ | 148 | */ |
84 | |||
85 | struct max8998_dev { | 149 | struct max8998_dev { |
86 | struct device *dev; | 150 | struct device *dev; |
87 | struct i2c_client *i2c_client; | 151 | struct i2c_client *i2c; |
88 | int (*dev_read)(struct max8998_dev *max8998, u8 reg, u8 *dest); | 152 | struct i2c_client *rtc; |
89 | int (*dev_write)(struct max8998_dev *max8998, u8 reg, u8 val); | ||
90 | int (*dev_update)(struct max8998_dev *max8998, u8 reg, u8 val, u8 mask); | ||
91 | struct mutex iolock; | 153 | struct mutex iolock; |
154 | struct mutex irqlock; | ||
155 | |||
156 | int irq_base; | ||
157 | int irq; | ||
158 | int ono; | ||
159 | u8 irq_masks_cur[MAX8998_NUM_IRQ_REGS]; | ||
160 | u8 irq_masks_cache[MAX8998_NUM_IRQ_REGS]; | ||
161 | int type; | ||
92 | }; | 162 | }; |
93 | 163 | ||
94 | static inline int max8998_read_reg(struct max8998_dev *max8998, u8 reg, | 164 | int max8998_irq_init(struct max8998_dev *max8998); |
95 | u8 *value) | 165 | void max8998_irq_exit(struct max8998_dev *max8998); |
96 | { | 166 | |
97 | return max8998->dev_read(max8998, reg, value); | 167 | extern int max8998_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest); |
98 | } | 168 | extern int max8998_bulk_read(struct i2c_client *i2c, u8 reg, int count, |
99 | 169 | u8 *buf); | |
100 | static inline int max8998_write_reg(struct max8998_dev *max8998, u8 reg, | 170 | extern int max8998_write_reg(struct i2c_client *i2c, u8 reg, u8 value); |
101 | u8 value) | 171 | extern int max8998_bulk_write(struct i2c_client *i2c, u8 reg, int count, |
102 | { | 172 | u8 *buf); |
103 | return max8998->dev_write(max8998, reg, value); | 173 | extern int max8998_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask); |
104 | } | ||
105 | |||
106 | static inline int max8998_update_reg(struct max8998_dev *max8998, u8 reg, | ||
107 | u8 value, u8 mask) | ||
108 | { | ||
109 | return max8998->dev_update(max8998, reg, value, mask); | ||
110 | } | ||
111 | 174 | ||
112 | #endif /* __LINUX_MFD_MAX8998_PRIV_H */ | 175 | #endif /* __LINUX_MFD_MAX8998_PRIV_H */ |