summaryrefslogtreecommitdiff
path: root/include/linux/smb349-charger.h
blob: 228069e347a71a72b977f9e372e6729988bee84a (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
/*
 * include/linux/smb349-charger.h
 *
 * Battery charger driver interface for Summit SMB349
 *
 * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
 *
 * 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;
	int otg_regulator_id;
	int num_otg_consumer_supplies;
	struct regulator_consumer_supply *otg_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;

	int is_otg_enabled;
	struct regulator_dev    *rdev;
	struct regulator_desc   reg_desc;
	struct regulator_init_data      reg_init_data;
	struct regulator_dev    *otg_rdev;
	struct regulator_desc   otg_reg_desc;
	struct regulator_init_data      otg_reg_init_data;
};

int smb349_battery_online(void);
/*
 * 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 update_charger_status(void);

#endif /*__LINUX_SMB349_CHARGER_H */