Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
max8925.h
Go to the documentation of this file.
1 /*
2  * Maxim8925 Interface
3  *
4  * Copyright (C) 2009 Marvell International Ltd.
5  * Haojian Zhuang <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  */
11 
12 #ifndef __LINUX_MFD_MAX8925_H
13 #define __LINUX_MFD_MAX8925_H
14 
15 #include <linux/mutex.h>
16 #include <linux/interrupt.h>
17 
18 /* Unified sub device IDs for MAX8925 */
19 enum {
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  */
55 };
56 
57 enum {
58  /* Fast charging current */
67 };
68 
69 /* Charger registers */
70 #define MAX8925_CHG_IRQ1 (0x7e)
71 #define MAX8925_CHG_IRQ2 (0x7f)
72 #define MAX8925_CHG_IRQ1_MASK (0x80)
73 #define MAX8925_CHG_IRQ2_MASK (0x81)
74 #define MAX8925_CHG_STATUS (0x82)
75 
76 /* GPM registers */
77 #define MAX8925_SYSENSEL (0x00)
78 #define MAX8925_ON_OFF_IRQ1 (0x01)
79 #define MAX8925_ON_OFF_IRQ1_MASK (0x02)
80 #define MAX8925_ON_OFF_STATUS (0x03)
81 #define MAX8925_ON_OFF_IRQ2 (0x0d)
82 #define MAX8925_ON_OFF_IRQ2_MASK (0x0e)
83 #define MAX8925_RESET_CNFG (0x0f)
84 
85 /* Touch registers */
86 #define MAX8925_TSC_IRQ (0x00)
87 #define MAX8925_TSC_IRQ_MASK (0x01)
88 #define MAX8925_TSC_CNFG1 (0x02)
89 #define MAX8925_ADC_SCHED (0x10)
90 #define MAX8925_ADC_RES_END (0x6f)
91 
92 #define MAX8925_NREF_OK (1 << 4)
93 
94 /* RTC registers */
95 #define MAX8925_ALARM0_CNTL (0x18)
96 #define MAX8925_ALARM1_CNTL (0x19)
97 #define MAX8925_RTC_IRQ (0x1c)
98 #define MAX8925_RTC_IRQ_MASK (0x1d)
99 #define MAX8925_MPL_CNTL (0x1e)
100 
101 /* WLED registers */
102 #define MAX8925_WLED_MODE_CNTL (0x84)
103 #define MAX8925_WLED_CNTL (0x85)
104 
105 /* MAX8925 Registers */
106 #define MAX8925_SDCTL1 (0x04)
107 #define MAX8925_SDCTL2 (0x07)
108 #define MAX8925_SDCTL3 (0x0A)
109 #define MAX8925_SDV1 (0x06)
110 #define MAX8925_SDV2 (0x09)
111 #define MAX8925_SDV3 (0x0C)
112 #define MAX8925_LDOCTL1 (0x18)
113 #define MAX8925_LDOCTL2 (0x1C)
114 #define MAX8925_LDOCTL3 (0x20)
115 #define MAX8925_LDOCTL4 (0x24)
116 #define MAX8925_LDOCTL5 (0x28)
117 #define MAX8925_LDOCTL6 (0x2C)
118 #define MAX8925_LDOCTL7 (0x30)
119 #define MAX8925_LDOCTL8 (0x34)
120 #define MAX8925_LDOCTL9 (0x38)
121 #define MAX8925_LDOCTL10 (0x3C)
122 #define MAX8925_LDOCTL11 (0x40)
123 #define MAX8925_LDOCTL12 (0x44)
124 #define MAX8925_LDOCTL13 (0x48)
125 #define MAX8925_LDOCTL14 (0x4C)
126 #define MAX8925_LDOCTL15 (0x50)
127 #define MAX8925_LDOCTL16 (0x10)
128 #define MAX8925_LDOCTL17 (0x14)
129 #define MAX8925_LDOCTL18 (0x72)
130 #define MAX8925_LDOCTL19 (0x5C)
131 #define MAX8925_LDOCTL20 (0x9C)
132 #define MAX8925_LDOVOUT1 (0x1A)
133 #define MAX8925_LDOVOUT2 (0x1E)
134 #define MAX8925_LDOVOUT3 (0x22)
135 #define MAX8925_LDOVOUT4 (0x26)
136 #define MAX8925_LDOVOUT5 (0x2A)
137 #define MAX8925_LDOVOUT6 (0x2E)
138 #define MAX8925_LDOVOUT7 (0x32)
139 #define MAX8925_LDOVOUT8 (0x36)
140 #define MAX8925_LDOVOUT9 (0x3A)
141 #define MAX8925_LDOVOUT10 (0x3E)
142 #define MAX8925_LDOVOUT11 (0x42)
143 #define MAX8925_LDOVOUT12 (0x46)
144 #define MAX8925_LDOVOUT13 (0x4A)
145 #define MAX8925_LDOVOUT14 (0x4E)
146 #define MAX8925_LDOVOUT15 (0x52)
147 #define MAX8925_LDOVOUT16 (0x12)
148 #define MAX8925_LDOVOUT17 (0x16)
149 #define MAX8925_LDOVOUT18 (0x74)
150 #define MAX8925_LDOVOUT19 (0x5E)
151 #define MAX8925_LDOVOUT20 (0x9E)
152 
153 /* bit definitions */
154 #define CHG_IRQ1_MASK (0x07)
155 #define CHG_IRQ2_MASK (0xff)
156 #define ON_OFF_IRQ1_MASK (0xff)
157 #define ON_OFF_IRQ2_MASK (0x03)
158 #define TSC_IRQ_MASK (0x03)
159 #define RTC_IRQ_MASK (0x0c)
160 
161 #define MAX8925_NAME_SIZE (32)
162 
163 /* IRQ definitions */
164 enum {
191 };
192 
193 struct max8925_chip {
194  struct device *dev;
195  struct i2c_client *i2c;
196  struct i2c_client *adc;
197  struct i2c_client *rtc;
198  struct mutex io_lock;
199  struct mutex irq_lock;
200 
201  int irq_base;
202  int core_irq;
203  int tsc_irq;
204 
205  unsigned int wakeup_flag;
206 };
207 
209  int lxw_scl; /* 0/1 -- 0.8Ohm/0.4Ohm */
210  int lxw_freq; /* 700KHz ~ 1400KHz */
211  int dual_string; /* 0/1 -- single/dual string */
212 };
213 
215  unsigned int flags;
216 };
217 
220  unsigned batt_detect:1;
221  unsigned topoff_threshold:2;
222  unsigned fast_charge:3; /* charge current */
223  unsigned no_temp_support:1; /* set if no temperature detect */
224  unsigned no_insert_detect:1; /* set if no ac insert detect */
225  char **supplied_to;
227 };
228 
229 /*
230  * irq_base: stores IRQ base number of MAX8925 in platform
231  * tsc_irq: stores IRQ number of MAX8925 TSC
232  */
260 
261  int irq_base;
262  int tsc_irq;
263 };
264 
265 extern int max8925_reg_read(struct i2c_client *, int);
266 extern int max8925_reg_write(struct i2c_client *, int, unsigned char);
267 extern int max8925_bulk_read(struct i2c_client *, int, int, unsigned char *);
268 extern int max8925_bulk_write(struct i2c_client *, int, int, unsigned char *);
269 extern int max8925_set_bits(struct i2c_client *, int, unsigned char,
270  unsigned char);
271 
272 extern int max8925_device_init(struct max8925_chip *,
273  struct max8925_platform_data *);
274 extern void max8925_device_exit(struct max8925_chip *);
275 #endif /* __LINUX_MFD_MAX8925_H */
276