diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2010-02-05 10:07:54 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-03-07 16:17:16 -0500 |
commit | 1f1cf8f98cf6588365efeaab8e7e7758aaa77f6e (patch) | |
tree | f2e17f85409bb6e2f75e152983e62fd2c4372859 /include/linux/mfd | |
parent | b13c0df517bedbc40cff4ab5f797b08b1111918b (diff) |
mfd: Update irq handler in max8925
Update thread irq handler. Simply the interface of using thread irq.
Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/linux/mfd')
-rw-r--r-- | include/linux/mfd/max8925.h | 139 |
1 files changed, 97 insertions, 42 deletions
diff --git a/include/linux/mfd/max8925.h b/include/linux/mfd/max8925.h index b72dbe174d51..18c1844ed472 100644 --- a/include/linux/mfd/max8925.h +++ b/include/linux/mfd/max8925.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #ifndef __LINUX_MFD_MAX8925_H | 12 | #ifndef __LINUX_MFD_MAX8925_H |
13 | #define __LINUX_MFD_MAX8925_H | 13 | #define __LINUX_MFD_MAX8925_H |
14 | 14 | ||
15 | #include <linux/mutex.h> | ||
15 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
16 | 17 | ||
17 | /* Unified sub device IDs for MAX8925 */ | 18 | /* Unified sub device IDs for MAX8925 */ |
@@ -39,6 +40,30 @@ enum { | |||
39 | MAX8925_ID_LDO18, | 40 | MAX8925_ID_LDO18, |
40 | MAX8925_ID_LDO19, | 41 | MAX8925_ID_LDO19, |
41 | MAX8925_ID_LDO20, | 42 | MAX8925_ID_LDO20, |
43 | MAX8925_ID_MAX, | ||
44 | }; | ||
45 | |||
46 | enum { | ||
47 | /* | ||
48 | * Charging current threshold trigger going from fast charge | ||
49 | * to TOPOFF charge. From 5% to 20% of fasting charging current. | ||
50 | */ | ||
51 | MAX8925_TOPOFF_THR_5PER, | ||
52 | MAX8925_TOPOFF_THR_10PER, | ||
53 | MAX8925_TOPOFF_THR_15PER, | ||
54 | MAX8925_TOPOFF_THR_20PER, | ||
55 | }; | ||
56 | |||
57 | enum { | ||
58 | /* Fast charging current */ | ||
59 | MAX8925_FCHG_85MA, | ||
60 | MAX8925_FCHG_300MA, | ||
61 | MAX8925_FCHG_460MA, | ||
62 | MAX8925_FCHG_600MA, | ||
63 | MAX8925_FCHG_700MA, | ||
64 | MAX8925_FCHG_800MA, | ||
65 | MAX8925_FCHG_900MA, | ||
66 | MAX8925_FCHG_1000MA, | ||
42 | }; | 67 | }; |
43 | 68 | ||
44 | /* Charger registers */ | 69 | /* Charger registers */ |
@@ -46,12 +71,13 @@ enum { | |||
46 | #define MAX8925_CHG_IRQ2 (0x7f) | 71 | #define MAX8925_CHG_IRQ2 (0x7f) |
47 | #define MAX8925_CHG_IRQ1_MASK (0x80) | 72 | #define MAX8925_CHG_IRQ1_MASK (0x80) |
48 | #define MAX8925_CHG_IRQ2_MASK (0x81) | 73 | #define MAX8925_CHG_IRQ2_MASK (0x81) |
74 | #define MAX8925_CHG_STATUS (0x82) | ||
49 | 75 | ||
50 | /* GPM registers */ | 76 | /* GPM registers */ |
51 | #define MAX8925_SYSENSEL (0x00) | 77 | #define MAX8925_SYSENSEL (0x00) |
52 | #define MAX8925_ON_OFF_IRQ1 (0x01) | 78 | #define MAX8925_ON_OFF_IRQ1 (0x01) |
53 | #define MAX8925_ON_OFF_IRQ1_MASK (0x02) | 79 | #define MAX8925_ON_OFF_IRQ1_MASK (0x02) |
54 | #define MAX8925_ON_OFF_STAT (0x03) | 80 | #define MAX8925_ON_OFF_STATUS (0x03) |
55 | #define MAX8925_ON_OFF_IRQ2 (0x0d) | 81 | #define MAX8925_ON_OFF_IRQ2 (0x0d) |
56 | #define MAX8925_ON_OFF_IRQ2_MASK (0x0e) | 82 | #define MAX8925_ON_OFF_IRQ2_MASK (0x0e) |
57 | #define MAX8925_RESET_CNFG (0x0f) | 83 | #define MAX8925_RESET_CNFG (0x0f) |
@@ -59,12 +85,18 @@ enum { | |||
59 | /* Touch registers */ | 85 | /* Touch registers */ |
60 | #define MAX8925_TSC_IRQ (0x00) | 86 | #define MAX8925_TSC_IRQ (0x00) |
61 | #define MAX8925_TSC_IRQ_MASK (0x01) | 87 | #define MAX8925_TSC_IRQ_MASK (0x01) |
88 | #define MAX8925_TSC_CNFG1 (0x02) | ||
89 | #define MAX8925_ADC_SCHED (0x10) | ||
62 | #define MAX8925_ADC_RES_END (0x6f) | 90 | #define MAX8925_ADC_RES_END (0x6f) |
63 | 91 | ||
92 | #define MAX8925_NREF_OK (1 << 4) | ||
93 | |||
64 | /* RTC registers */ | 94 | /* RTC registers */ |
65 | #define MAX8925_RTC_STATUS (0x1a) | 95 | #define MAX8925_ALARM0_CNTL (0x18) |
96 | #define MAX8925_ALARM1_CNTL (0x19) | ||
66 | #define MAX8925_RTC_IRQ (0x1c) | 97 | #define MAX8925_RTC_IRQ (0x1c) |
67 | #define MAX8925_RTC_IRQ_MASK (0x1d) | 98 | #define MAX8925_RTC_IRQ_MASK (0x1d) |
99 | #define MAX8925_MPL_CNTL (0x1e) | ||
68 | 100 | ||
69 | /* WLED registers */ | 101 | /* WLED registers */ |
70 | #define MAX8925_WLED_MODE_CNTL (0x84) | 102 | #define MAX8925_WLED_MODE_CNTL (0x84) |
@@ -126,45 +158,48 @@ enum { | |||
126 | #define TSC_IRQ_MASK (0x03) | 158 | #define TSC_IRQ_MASK (0x03) |
127 | #define RTC_IRQ_MASK (0x0c) | 159 | #define RTC_IRQ_MASK (0x0c) |
128 | 160 | ||
129 | #define MAX8925_NUM_IRQ (32) | 161 | #define MAX8925_GPM_NUM_IRQ (40) |
162 | #define MAX8925_ADC_NUM_IRQ (8) | ||
163 | #define MAX8925_NUM_IRQ (MAX8925_GPM_NUM_IRQ \ | ||
164 | + MAX8925_ADC_NUM_IRQ) | ||
165 | |||
166 | #define MAX8925_MAX_REGULATOR (23) | ||
130 | 167 | ||
131 | #define MAX8925_NAME_SIZE (32) | 168 | #define MAX8925_NAME_SIZE (32) |
132 | 169 | ||
170 | /* IRQ definitions */ | ||
133 | enum { | 171 | enum { |
134 | MAX8925_INVALID = 0, | 172 | MAX8925_IRQ_VCHG_DC_OVP, |
135 | MAX8925_RTC, | 173 | MAX8925_IRQ_VCHG_DC_F, |
136 | MAX8925_ADC, | 174 | MAX8925_IRQ_VCHG_DC_R, |
137 | MAX8925_GPM, /* general power management */ | 175 | MAX8925_IRQ_VCHG_USB_OVP, |
138 | MAX8925_MAX, | 176 | MAX8925_IRQ_VCHG_USB_F, |
177 | MAX8925_IRQ_VCHG_USB_R, | ||
178 | MAX8925_IRQ_VCHG_THM_OK_R, | ||
179 | MAX8925_IRQ_VCHG_THM_OK_F, | ||
180 | MAX8925_IRQ_VCHG_SYSLOW_F, | ||
181 | MAX8925_IRQ_VCHG_SYSLOW_R, | ||
182 | MAX8925_IRQ_VCHG_RST, | ||
183 | MAX8925_IRQ_VCHG_DONE, | ||
184 | MAX8925_IRQ_VCHG_TOPOFF, | ||
185 | MAX8925_IRQ_VCHG_TMR_FAULT, | ||
186 | MAX8925_IRQ_GPM_RSTIN, | ||
187 | MAX8925_IRQ_GPM_MPL, | ||
188 | MAX8925_IRQ_GPM_SW_3SEC, | ||
189 | MAX8925_IRQ_GPM_EXTON_F, | ||
190 | MAX8925_IRQ_GPM_EXTON_R, | ||
191 | MAX8925_IRQ_GPM_SW_1SEC, | ||
192 | MAX8925_IRQ_GPM_SW_F, | ||
193 | MAX8925_IRQ_GPM_SW_R, | ||
194 | MAX8925_IRQ_GPM_SYSCKEN_F, | ||
195 | MAX8925_IRQ_GPM_SYSCKEN_R, | ||
196 | MAX8925_IRQ_RTC_ALARM1, | ||
197 | MAX8925_IRQ_RTC_ALARM0, | ||
198 | MAX8925_IRQ_TSC_STICK, | ||
199 | MAX8925_IRQ_TSC_NSTICK, | ||
200 | MAX8925_NR_IRQS, | ||
139 | }; | 201 | }; |
140 | 202 | ||
141 | #define MAX8925_IRQ_VCHG_OVP (0) | ||
142 | #define MAX8925_IRQ_VCHG_F (1) | ||
143 | #define MAX8925_IRQ_VCHG_R (2) | ||
144 | #define MAX8925_IRQ_VCHG_THM_OK_R (8) | ||
145 | #define MAX8925_IRQ_VCHG_THM_OK_F (9) | ||
146 | #define MAX8925_IRQ_VCHG_BATTLOW_F (10) | ||
147 | #define MAX8925_IRQ_VCHG_BATTLOW_R (11) | ||
148 | #define MAX8925_IRQ_VCHG_RST (12) | ||
149 | #define MAX8925_IRQ_VCHG_DONE (13) | ||
150 | #define MAX8925_IRQ_VCHG_TOPOFF (14) | ||
151 | #define MAX8925_IRQ_VCHG_TMR_FAULT (15) | ||
152 | #define MAX8925_IRQ_GPM_RSTIN (16) | ||
153 | #define MAX8925_IRQ_GPM_MPL (17) | ||
154 | #define MAX8925_IRQ_GPM_SW_3SEC (18) | ||
155 | #define MAX8925_IRQ_GPM_EXTON_F (19) | ||
156 | #define MAX8925_IRQ_GPM_EXTON_R (20) | ||
157 | #define MAX8925_IRQ_GPM_SW_1SEC (21) | ||
158 | #define MAX8925_IRQ_GPM_SW_F (22) | ||
159 | #define MAX8925_IRQ_GPM_SW_R (23) | ||
160 | #define MAX8925_IRQ_GPM_SYSCKEN_F (24) | ||
161 | #define MAX8925_IRQ_GPM_SYSCKEN_R (25) | ||
162 | |||
163 | #define MAX8925_IRQ_TSC_STICK (0) | ||
164 | #define MAX8925_IRQ_TSC_NSTICK (1) | ||
165 | |||
166 | #define MAX8925_MAX_REGULATOR (23) | ||
167 | |||
168 | struct max8925_irq { | 203 | struct max8925_irq { |
169 | irq_handler_t handler; | 204 | irq_handler_t handler; |
170 | void *data; | 205 | void *data; |
@@ -172,14 +207,16 @@ struct max8925_irq { | |||
172 | 207 | ||
173 | struct max8925_chip { | 208 | struct max8925_chip { |
174 | struct device *dev; | 209 | struct device *dev; |
210 | struct i2c_client *i2c; | ||
211 | struct i2c_client *adc; | ||
212 | struct i2c_client *rtc; | ||
213 | struct max8925_irq irqs[MAX8925_NUM_IRQ]; | ||
175 | struct mutex io_lock; | 214 | struct mutex io_lock; |
176 | struct mutex irq_lock; | 215 | struct mutex irq_lock; |
177 | struct i2c_client *i2c; | ||
178 | struct max8925_irq irq[MAX8925_NUM_IRQ]; | ||
179 | 216 | ||
180 | const char *name; | 217 | int irq_base; |
181 | int chip_id; | 218 | int core_irq; |
182 | int chip_irq; | 219 | int tsc_irq; |
183 | }; | 220 | }; |
184 | 221 | ||
185 | struct max8925_backlight_pdata { | 222 | struct max8925_backlight_pdata { |
@@ -192,13 +229,25 @@ struct max8925_touch_pdata { | |||
192 | unsigned int flags; | 229 | unsigned int flags; |
193 | }; | 230 | }; |
194 | 231 | ||
232 | struct max8925_power_pdata { | ||
233 | int (*set_charger)(int); | ||
234 | unsigned batt_detect:1; | ||
235 | unsigned topoff_threshold:2; | ||
236 | unsigned fast_charge:3; /* charge current */ | ||
237 | }; | ||
238 | |||
239 | /* | ||
240 | * irq_base: stores IRQ base number of MAX8925 in platform | ||
241 | * tsc_irq: stores IRQ number of MAX8925 TSC | ||
242 | */ | ||
195 | struct max8925_platform_data { | 243 | struct max8925_platform_data { |
196 | struct max8925_backlight_pdata *backlight; | 244 | struct max8925_backlight_pdata *backlight; |
197 | struct max8925_touch_pdata *touch; | 245 | struct max8925_touch_pdata *touch; |
246 | struct max8925_power_pdata *power; | ||
198 | struct regulator_init_data *regulator[MAX8925_MAX_REGULATOR]; | 247 | struct regulator_init_data *regulator[MAX8925_MAX_REGULATOR]; |
199 | 248 | ||
200 | int chip_id; | 249 | int irq_base; |
201 | int chip_irq; | 250 | int tsc_irq; |
202 | }; | 251 | }; |
203 | 252 | ||
204 | extern int max8925_reg_read(struct i2c_client *, int); | 253 | extern int max8925_reg_read(struct i2c_client *, int); |
@@ -208,6 +257,12 @@ extern int max8925_bulk_write(struct i2c_client *, int, int, unsigned char *); | |||
208 | extern int max8925_set_bits(struct i2c_client *, int, unsigned char, | 257 | extern int max8925_set_bits(struct i2c_client *, int, unsigned char, |
209 | unsigned char); | 258 | unsigned char); |
210 | 259 | ||
260 | extern int max8925_request_irq(struct max8925_chip *, int, | ||
261 | irq_handler_t, void *); | ||
262 | extern int max8925_free_irq(struct max8925_chip *, int); | ||
263 | extern int max8925_mask_irq(struct max8925_chip *, int); | ||
264 | extern int max8925_unmask_irq(struct max8925_chip *, int); | ||
265 | |||
211 | extern int max8925_device_init(struct max8925_chip *, | 266 | extern int max8925_device_init(struct max8925_chip *, |
212 | struct max8925_platform_data *); | 267 | struct max8925_platform_data *); |
213 | extern void max8925_device_exit(struct max8925_chip *); | 268 | extern void max8925_device_exit(struct max8925_chip *); |