2 * include/linux/mfd/rt5025/rt5025.h
3 * Include header file for Richtek RT5025 Core file
5 * Copyright (C) 2013 Richtek Technology Corp.
6 * cy_huang <cy_huang@richtek.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
14 #ifndef __LINUX_MFD_RT5025_H
15 #define __LINUX_MFD_RT5025_H
17 #include <linux/power_supply.h>
18 #include <linux/alarmtimer.h>
19 #include <linux/wakelock.h>
20 #ifdef CONFIG_HAS_EARLYSUSPEND
21 #include <linux/earlysuspend.h>
22 #endif /* CONFIG_HAS_EARLYSUSPEND */
24 #define RT5025_DEV_NAME "rt5025"
25 #define RT5025_DRV_VER "1.1.0_R"
27 #define RT_BATT_NAME "rt-battery"
31 RT5025_REG_RANGE1START = RT5025_REG_DEVID,
62 RT5025_REG_RANGE1END = RT5025_REG_GPIO2,
63 RT5025_REG_OFFEVENT = 0x20,
64 RT5025_REG_RANGE2START = RT5025_REG_OFFEVENT,
90 RT5025_REG_RANGE2END = RT5025_REG_IRQSTAT5,
91 RT5025_REG_IRQCTL = 0x50,
92 RT5025_REG_RANGE3START = RT5025_REG_IRQCTL,
114 RT5025_REG_INUSBVLTH,
115 RT5025_REG_INUSBVLTL,
118 RT5025_REG_GPIO0VLTH,
119 RT5025_REG_GPIO0VLTL,
120 RT5025_REG_GPIO1VLTH,
121 RT5025_REG_GPIO1VLTL,
122 RT5025_REG_GPIO2VLTH,
123 RT5025_REG_GPIO2VLTL,
124 RT5025_REG_DCDC1VLTH,
125 RT5025_REG_DCDC1VLTL,
126 RT5025_REG_DCDC2VLTH,
127 RT5025_REG_DCDC2VLTL,
128 RT5025_REG_DCDC3VLTH,
129 RT5025_REG_DCDC3VLTL,
140 RT5025_REG_RANGE3END = RT5025_REG_QDCHGLL,
141 RT5025_REG_DCDC4OVP = 0xA9,
142 RT5025_REG_RANGE4START = RT5025_REG_DCDC4OVP,
143 RT5025_REG_RANGE4END = RT5025_REG_DCDC4OVP,
156 RT5025_VOFF_MAX = RT5025_VOFF_3P5V,
160 RT5025_STARTIME_100MS,
164 RT5025_STARTIME_MAX = RT5025_STARTIME_3S,
171 RT5025_SHDNPRESS_10S,
172 RT5025_SHDNPRESS_MAX = RT5025_SHDNPRESS_10S,
180 RT5025_VDPM_MAX = RT5025_VDPM_DIS,
186 RT5025_IEOC_MAX = RT5025_IEOC_20P,
196 RT5025_VPREC_MAX = RT5025_VPREC_3V,
202 RT5025_IPREC_MAX = RT5025_IPREC_20P,
216 RT5025_MAX_REGULATOR,
219 typedef void (*rt_irq_handler)(void *info, int eventno);
221 #define RT5025_DCDCRAMP_MAX 0x03
222 struct rt5025_regulator_ramp {
223 unsigned char ramp_sel:2;
226 struct rt5025_charger_info {
227 struct i2c_client *i2c;
229 struct power_supply psy;
230 #ifdef CONFIG_HAS_EARLYSUSPEND
231 struct early_suspend early_suspend;
232 #endif /* CONFIG_HAS_EARLYSUSPEND */
233 struct delayed_work tempmon_work;
236 unsigned int te_en:1;
237 unsigned int online:1;
238 unsigned int batabs:1;
239 unsigned int battemp_region:3;
240 unsigned int inttemp_region:2;
241 unsigned int otg_en:1;
242 unsigned int init_once:1;
243 unsigned int suspend:1;
244 unsigned int screenon_adjust:1;
245 unsigned int screen_on:1;
255 struct rt5025_battery_info {
256 struct i2c_client *client;
257 struct power_supply battery;
258 struct delayed_work monitor_work;
259 struct wake_lock monitor_wake_lock;
260 struct wake_lock low_battery_wake_lock;
261 struct wake_lock status_wake_lock;
262 struct wake_lock smooth0_wake_lock;
263 struct wake_lock smooth100_wake_lock;
264 struct wake_lock full_battery_wake_lock;
265 /*#if RT5025_TEST_WAKE_LOCK
266 // struct wake_lock test_wake_lock;
268 struct mutex status_change_lock;
269 struct alarm wakeup_alarm;
272 bool temp_range_5_10;
273 bool temp_range_10_15;
274 bool temp_range_15_20;
275 bool temp_range_20_30;
276 bool temp_range_30_35;
277 bool temp_range_35_40;
278 bool temp_range_40_45;
279 bool temp_range_45_50;
282 bool range_5_10_done;
283 bool range_10_15_done;
284 bool range_15_20_done;
285 bool range_20_30_done;
286 bool range_30_35_done;
287 bool range_35_40_done;
288 bool range_40_45_done;
289 bool range_45_50_done;
293 /* ktime_t last_event;*/
294 struct timespec last_event;
298 /* previous battery voltage */
300 /* previous battery current */
302 /* battery voltage */
304 /* battery current */
306 /* battery current offset */
310 /* battery internal temperature */
312 /* battery external temperature */
314 /* charge coulomb counter */
317 /* discharge coulomb counter */
320 /* battery capacity */
338 /* max voltage IRQ flag */
340 /* min voltage1 IRQ flag */
342 /* min voltage2 IRQ flag */
344 /* max temperature IRQ flag */
346 /* min temperature IRQ flag */
349 bool min_volt2_alert;
358 /* remain capacity */
391 bool fcc_update_flag;
400 struct rt5025_charger_data {
410 unsigned int te_en:1;
411 unsigned int vprec:3;
412 unsigned int iprec:1;
413 unsigned int screenon_adjust:1;
416 struct rt5025_gpio_data {
420 struct rt5025_misc_data {
421 unsigned char vsyslv:3;
422 unsigned char shdnlpress_time:2;
423 unsigned char startlpress_time:2;
424 unsigned char vsyslv_enshdn:1;
427 struct rt5025_irq_data {
432 struct rt5025_platform_data {
433 struct regulator_init_data *regulator[RT5025_MAX_REGULATOR];
434 struct rt5025_charger_data *chg_pdata;
435 struct rt5025_gpio_data *gpio_pdata;
436 struct rt5025_misc_data *misc_pdata;
437 struct rt5025_irq_data *irq_pdata;
438 int (*pre_init)(struct rt5025_chip *rt5025_chip);
439 /** Called after subdevices are set up */
440 int (*post_init)(void);
443 struct rt5025_misc_info {
444 struct i2c_client *i2c;
449 struct i2c_client *i2c;
451 struct rt5025_charger_info *charger_info;
452 struct rt5025_battery_info *battery_info;
453 struct rt5025_misc_info *misc_info;
454 struct mutex io_lock;
458 #ifdef CONFIG_CHARGER_RT5025
459 void rt5025_charger_irq_handler(struct rt5025_charger_info *ci, unsigned int event);
460 #endif /* #ifdef CONFIG_CHARGER_RT5025 */
461 #ifdef CONFIG_MISC_RT5025
462 void rt5025_misc_irq_handler(struct rt5025_misc_info *mi, unsigned int event);
463 #endif /* #ifdef CONFIG_MISC_RT5025 */
464 #ifdef CONFIG_BATTERY_RT5025
465 void rt5025_gauge_irq_handler(struct rt5025_battery_info *bi, unsigned int event);
466 #endif /* #ifdef CONFIG_BATTERY_RT5025 */
468 extern int rt5025_reg_block_read(struct i2c_client *, int, int, void *);
469 extern int rt5025_reg_block_write(struct i2c_client *, int, int, void *);
470 extern int rt5025_reg_read(struct i2c_client *, int);
471 extern int rt5025_reg_write(struct i2c_client *, int, unsigned char);
472 extern int rt5025_assign_bits(struct i2c_client *, int, unsigned char, unsigned char);
473 extern int rt5025_set_bits(struct i2c_client *, int, unsigned char);
474 extern int rt5025_clr_bits(struct i2c_client *, int, unsigned char);
476 extern int rt5025_core_init(struct rt5025_chip *, struct rt5025_platform_data *);
477 extern int rt5025_core_deinit(struct rt5025_chip *);
479 #ifdef CONFIG_MFD_RT_SHOW_INFO
480 #define RTINFO(format, args...) \
481 printk(KERN_INFO "%s:%s() line-%d: " format, RT5025_DEV_NAME, __FUNCTION__, __LINE__, ##args)
483 #define RTINFO(format, args...)
484 #endif /* CONFIG_MFD_RT_SHOW_INFO */
486 #endif /* __LINUX_MFD_RT5025_H */