2 * max8998.h - Voltage regulator driver for the Maxim 8998
4 * Copyright (C) 2009-2010 Samsung Electrnoics
5 * Kyungmin Park <kyungmin.park@samsung.com>
6 * Marek Szyprowski <m.szyprowski@samsung.com>
8 * This program is not provided / owned by Maxim Integrated Products.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #ifndef __LINUX_MFD_MAX8998_PRIV_H
26 #define __LINUX_MFD_MAX8998_PRIV_H
28 #define MAX8998_NUM_IRQ_REGS 4
29 #define MAX8998_NUM_STATUS_REGS 2
31 /* MAX 8998 registers */
47 MAX8998_REG_LDO_ACTIVE_DISCHARGE1,
48 MAX8998_REG_LDO_ACTIVE_DISCHARGE2,
49 MAX8998_REG_BUCK_ACTIVE_DISCHARGE3,
54 MAX8998_REG_BUCK1_VOLTAGE1,
55 MAX8998_REG_BUCK1_VOLTAGE2,
56 MAX8998_REG_BUCK1_VOLTAGE3,
57 MAX8998_REG_BUCK1_VOLTAGE4,
58 MAX8998_REG_BUCK2_VOLTAGE1,
59 MAX8998_REG_BUCK2_VOLTAGE2,
62 MAX8998_REG_LDO2_LDO3,
67 MAX8998_REG_LDO8_LDO9,
68 MAX8998_REG_LDO10_LDO11,
104 MAX8998_STATUS_LOBAT1,
105 MAX8998_STATUS_LOBAT2,
106 MAX8998_STATUS_WTSREVNT,
107 MAX8998_STATUS_SMPLEVNT,
108 MAX8998_STATUS_ALARM1,
109 MAX8998_STATUS_ALARM0,
111 MAX8998_STATUS_PWRON,
115 MAX8998_STATUS_CHGON,
116 MAX8998_STATUS_DETBAT,
117 MAX8998_STATUS_VDCINOK,
123 /* MAX8998 various variants */
125 TYPE_MAX8998 = 0, /* Default */
126 TYPE_LP3974, /* National version of MAX8998 */
127 TYPE_LP3974_REGERR, /* National version of MAX8998 with RTC REG BUG */
128 TYPE_LP3979, /* Added AVS */
132 #define MAX8998_IRQ_DCINF_MASK (1 << 2)
133 #define MAX8998_IRQ_DCINR_MASK (1 << 3)
134 #define MAX8998_IRQ_JIGF_MASK (1 << 4)
135 #define MAX8998_IRQ_JIGR_MASK (1 << 5)
136 #define MAX8998_IRQ_PWRONF_MASK (1 << 6)
137 #define MAX8998_IRQ_PWRONR_MASK (1 << 7)
139 #define MAX8998_IRQ_WTSREVNT_MASK (1 << 0)
140 #define MAX8998_IRQ_SMPLEVNT_MASK (1 << 1)
141 #define MAX8998_IRQ_ALARM1_MASK (1 << 2)
142 #define MAX8998_IRQ_ALARM0_MASK (1 << 3)
144 #define MAX8998_IRQ_ONKEY1S_MASK (1 << 0)
145 #define MAX8998_IRQ_TOPOFFR_MASK (1 << 2)
146 #define MAX8998_IRQ_DCINOVPR_MASK (1 << 3)
147 #define MAX8998_IRQ_CHGRSTF_MASK (1 << 4)
148 #define MAX8998_IRQ_DONER_MASK (1 << 5)
149 #define MAX8998_IRQ_CHGFAULT_MASK (1 << 7)
151 #define MAX8998_IRQ_LOBAT1_MASK (1 << 0)
152 #define MAX8998_IRQ_LOBAT2_MASK (1 << 1)
154 #define MAX8998_STATUS_LOBAT1_MASK (1 << 0)
155 #define MAX8998_STATUS_LOBAT2_MASK (1 << 1)
156 #define MAX8998_STATUS_WTSREVNT_MASK (1 << 2)
157 #define MAX8998_STATUS_SMPLEVNT_MASK (1 << 3)
158 #define MAX8998_STATUS_ALARM1_MASK (1 << 4)
159 #define MAX8998_STATUS_ALARM0_MASK (1 << 5)
160 #define MAX8998_STATUS_JIG_MASK (1 << 6)
161 #define MAX8998_STATUS_PWRON_MASK (1 << 7)
163 #define MAX8998_STATUS_PQL_MASK (1 << 1)
164 #define MAX8998_STATUS_FCHG_MASK (1 << 2)
165 #define MAX8998_STATUS_CHGON_MASK (1 << 3)
166 #define MAX8998_STATUS_DETBAT_MASK (1 << 4)
167 #define MAX8998_STATUS_VDCINOK_MASK (1 << 5)
168 #define MAX8998_STATUS_DONE_MASK (1 << 6)
170 #define MAX8998_ENRAMP (1 << 4)
173 * struct max8998_dev - max8998 master device for sub-drivers
174 * @dev: master device of the chip (can be used to access platform data)
175 * @i2c: i2c client private data for regulator
176 * @rtc: i2c client private data for rtc
177 * @iolock: mutex for serializing io access
178 * @irqlock: mutex for buslock
179 * @irq_base: base IRQ number for max8998, required for IRQs
180 * @irq: generic IRQ number for max8998
181 * @ono: power onoff IRQ number for max8998
182 * @irq_masks_cur: currently active value
183 * @irq_masks_cache: cached hardware value
184 * @type: indicate which max8998 "variant" is used
185 * @battery: the max8998 battery control device
189 struct i2c_client *i2c;
190 struct i2c_client *rtc;
192 struct mutex irqlock;
197 u8 irq_masks_cur[MAX8998_NUM_IRQ_REGS + MAX8998_NUM_STATUS_REGS];
198 u8 irq_masks_cache[MAX8998_NUM_IRQ_REGS + MAX8998_NUM_STATUS_REGS];
199 u8 status_cache[MAX8998_NUM_STATUS_REGS];
202 struct platform_device *battery;
205 int max8998_irq_init(struct max8998_dev *max8998);
206 void max8998_irq_exit(struct max8998_dev *max8998);
207 int max8998_irq_resume(struct max8998_dev *max8998);
209 extern int max8998_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest);
210 extern int max8998_bulk_read(struct i2c_client *i2c, u8 reg, int count,
212 extern int max8998_write_reg(struct i2c_client *i2c, u8 reg, u8 value);
213 extern int max8998_bulk_write(struct i2c_client *i2c, u8 reg, int count,
215 extern int max8998_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask);
217 #ifdef CONFIG_CHARGERCTRL_MAX8998
218 extern void max8998_update_eoc(struct max8998_dev *mdev);
219 extern const int *charger_current_map_desc;
221 static void __maybe_unused max8998_update_eoc(struct max8998_dev *mdev) { }
224 #endif /* __LINUX_MFD_MAX8998_PRIV_H */