summaryrefstree
path: root/kernel/include/linux/sec_batt_selfdchg_common.h
blob: bf7fbeed5637868209456c8eb9a12d0f0590ed32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
  * Samsung Mobile VE Group.
  *
  * drivers/battery/sec_batt_dischg_no_ic_by_policy.h
  *
  * Common header for for samsung batter self discharging.
  *
  * Copyright (C) 2015, Samsung Electronics.
  *
  * This program is free software. You can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation
  */

#ifndef __SDCHG_COMMON_H__
#define __SDCHG_COMMON_H__

/******************************************/
// Original Header
#include <linux/pm.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/power_supply.h>
#include <linux/cpufreq.h>
#include <linux/delay.h>
#include <linux/workqueue.h>
#include <linux/cpu.h>
#include <linux/sched.h>
#include <linux/fb.h>
#include <linux/pm_qos.h>
#include <linux/reboot.h>
#include <linux/alarmtimer.h>
#include <linux/suspend.h>

/******************************************/
/* Code Control Feature (for no discharging IC) */
/******************************************/
//#define SDCHG_SELF_TEST
//#define SDCHG_CHECK_TYPE_SOC  // for using soc(not voltage)
/******************************************/

/******************************************/
/* Condition Feature (for no discharging IC) */
/******************************************/
/* default value (applied in case of no having dt data) */
#define SDCHG_TEMP_START	600
#define SDCHG_TEMP_END		550

#ifdef SDCHG_SELF_TEST
#define SDCHG_SOC_START			96	//99	,93
#define SDCHG_SOC_END			92	//98	,92
#define SDCHG_VOLTAGE_START	4250	// 4320
#define SDCHG_VOLTAGE_END		4200	// 4300
#else
#define SDCHG_SOC_START			96
#define SDCHG_SOC_END			92
#define SDCHG_VOLTAGE_START	4250	// Soc 96
#define SDCHG_VOLTAGE_END		4200	// Soc 92
#endif
/******************************************/
#ifdef SDCHG_CHECK_TYPE_SOC
#define SDCHG_BATTCOND_START	sdchg_info->soc_start
#define SDCHG_BATTCOND_END		sdchg_info->soc_end
#else
#define SDCHG_BATTCOND_START	sdchg_info->voltage_start
#define SDCHG_BATTCOND_END		sdchg_info->voltage_end
#endif
/******************************************/
/* for no discharging IC */
/******************************************/
enum __sdchg_state__ {
	SDCHG_STATE_NONE = 0,
	SDCHG_STATE_SET,
	SDCHG_STATE_SET_DISPLAY_ON,
#ifdef SDCHG_SUB_POLICY_SET
	SDCHG_STATE_SET_LOW,
	SDCHG_STATE_SET_LOW_DISPLAY_ON,
#endif
	SDCHG_STATE_MAX
};

enum __sdchg_charger_type__ {
	SDCHG_CHARGER_NONE = 0,
	SDCHG_CHARGER_MUIC,
	SDCHG_CHARGER_WIRELESS,
	SDCHG_CHARGER_MAX
};
/******************************************/
struct sdchg_info_chip_t
{
	int factory_discharging;
	u32 adc_max;
	u32 adc_min;
	u32 ntc_limit;
	bool sdchg_en;
	struct sdchg_info_t *pinfo;
};

struct sdchg_info_nochip_t
{
	int need_state;
	int set_state;

	struct wake_lock wake_lock;
	struct wake_lock end_wake_lock;
	bool wake_lock_set;

#ifdef CONFIG_FB
	bool display_on;
	struct notifier_block fb_nb;
#endif
	bool state_machine_run;

	void (*sdchg_monitor)(void *, __kernel_time_t, bool);

	struct sdchg_info_t *pinfo;	// struct sec_battery_info

	void *pData;		// personal data
};

struct sdchg_info_t
{
	char *type;

	struct list_head info_list;

	void *battery;

	/*********************/
	/* dt data */
	u32 temp_start;
	u32 temp_end;
	u32 soc_start;
	u32 soc_end;
	u32 voltage_start;
	u32 voltage_end;	// use battery,swelling_drop_float_voltage
	/*********************/

	// func
	int (*sdchg_probe)(void *);
	int (*sdchg_remove)(void);
	void (*sdchg_parse_dt)(struct device *);

	// factory func
	void (*sdchg_adc_check)(void *);
	void (*sdchg_ntc_check)(void *);
	void (*sdchg_force_control)(void *, bool);
	void (*sdchg_discharging_check)(void *);

	int (*sdchg_force_check)(void *);

	// nochip data
	struct sdchg_info_chip_t *chip;
	struct sdchg_info_nochip_t *nochip;
};

extern struct list_head sdchg_info_head;
extern bool sdchg_nochip_support;

extern int wireless_charger_notifier_register(struct notifier_block *nb, notifier_fn_t notifier);
extern int wireless_charger_notifier_unregister(struct notifier_block *nb);

extern bool sdchg_check_polling_time(__kernel_time_t curr);
extern void sdchg_set_polling_time(int polling_time);
extern unsigned int sdchg_get_polling_time(unsigned int cur_polling_time);

#endif	// #ifndef __SDCHG_COMMON_H__