summaryrefslogtreecommitdiff
path: root/include/linux/smb349-charger.h
blob: 089f3976dbbe7119a25a99fdc5ed819694f605c6 (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
/*
 * include/linux/smb349-charger.h
 *
 * Battery charger driver interface for Summit SMB349
 *
 * Copyright (C) 2012 NVIDIA Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#ifndef __LINUX_SMB349_CHARGER_H
#define __LINUX_SMB349_CHARGER_H

#include <linux/regulator/machine.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/usb/otg.h>

struct smb349_charger_platform_data {
	int regulator_id;
	int max_charge_volt_mV;
	int max_charge_current_mA;
	int charging_term_current_mA;
	int num_consumer_supplies;
	struct regulator_consumer_supply *consumer_supplies;
};

enum charging_states {
	idle,
	progress,
	completed,
	stopped,
};

enum charger_type {
	NONE,
	AC,
	USB,
};

typedef void (*charging_callback_t)(enum charging_states state,
enum charger_type chrg_type, void *args);

struct smb349_charger {
	struct i2c_client	*client;
	struct device	*dev;
	void	*charger_cb_data;
	enum charging_states state;
	enum charger_type chrg_type;
	charging_callback_t	charger_cb;

	struct regulator_dev    *rdev;
	struct regulator_desc   reg_desc;
	struct regulator_init_data      reg_init_data;
};

int smb349_battery_online(void);
typedef void (*callback_t)(enum usb_otg_state to,
		enum usb_otg_state from, void *args);
/*
 * Register callback function for the client.
 * Used by fuel-gauge driver to get battery charging properties.
 */
extern int register_callback(charging_callback_t cb, void *args);
extern int register_otg_callback(callback_t cb, void *args);
extern int update_charger_status(void);

#endif /*__LINUX_SMB349_CHARGER_H */