blob: 8b3ef891ba42fa4043be74a8c1e8f862237f2dfd [file] [log] [blame]
Krzysztof Kozlowskid7d8d7a2018-08-07 18:11:23 +02001/* SPDX-License-Identifier: GPL-2.0+ */
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01002/*
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +02003 * max14577.h - Driver for the Maxim 14577/77836
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01004 *
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +02005 * Copyright (C) 2014 Samsung Electrnoics
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01006 * Chanwoo Choi <cw00.choi@samsung.com>
Krzysztof Kozlowski8c5d0572016-08-17 14:07:42 +02007 * Krzysztof Kozlowski <krzk@kernel.org>
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01008 *
Chanwoo Choi3008ddb2013-11-22 16:51:05 +01009 * This driver is based on max8997.h
10 *
11 * MAX14577 has MUIC, Charger devices.
12 * The devices share the same I2C bus and interrupt line
13 * included in this mfd driver.
Krzysztof Kozlowskiaee2a572014-04-14 11:17:18 +020014 *
15 * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave
16 * addresses.
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010017 */
18
19#ifndef __MAX14577_H__
20#define __MAX14577_H__
21
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010022#include <linux/regulator/consumer.h>
23
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010024/* MAX14577 regulator IDs */
25enum max14577_regulators {
26 MAX14577_SAFEOUT = 0,
27 MAX14577_CHARGER,
28
Krzysztof Kozlowski8a82b402014-04-14 11:17:20 +020029 MAX14577_REGULATOR_NUM,
30};
31
32/* MAX77836 regulator IDs */
33enum max77836_regulators {
34 MAX77836_SAFEOUT = 0,
35 MAX77836_CHARGER,
36 MAX77836_LDO1,
37 MAX77836_LDO2,
38
39 MAX77836_REGULATOR_NUM,
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010040};
41
42struct max14577_regulator_platform_data {
43 int id;
44 struct regulator_init_data *initdata;
45 struct device_node *of_node;
46};
47
Krzysztof Kozlowskie30110e2014-09-12 08:53:57 +020048struct max14577_charger_platform_data {
49 u32 constant_uvolt;
50 u32 fast_charge_uamp;
51 u32 eoc_uamp;
52 u32 ovp_uvolt;
53};
54
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010055/*
56 * MAX14577 MFD platform data
57 */
58struct max14577_platform_data {
59 /* IRQ */
60 int irq_base;
61
62 /* current control GPIOs */
63 int gpio_pogo_vbatt_en;
64 int gpio_pogo_vbus_en;
65
66 /* current control GPIO control function */
67 int (*set_gpio_pogo_vbatt_en) (int gpio_val);
68 int (*set_gpio_pogo_vbus_en) (int gpio_val);
69
70 int (*set_gpio_pogo_cb) (int new_dev);
71
72 struct max14577_regulator_platform_data *regulators;
73};
74
Krzysztof Kozlowskib8f139f2014-09-12 08:53:56 +020075/*
76 * Valid limits of current for max14577 and max77836 chargers.
77 * They must correspond to MBCICHWRCL and MBCICHWRCH fields in CHGCTRL4
78 * register for given chipset.
79 */
80struct maxim_charger_current {
81 /* Minimal current, set in CHGCTRL4/MBCICHWRCL, uA */
82 unsigned int min;
83 /*
84 * Minimal current when high setting is active,
85 * set in CHGCTRL4/MBCICHWRCH, uA
86 */
87 unsigned int high_start;
88 /* Value of one step in high setting, uA */
89 unsigned int high_step;
90 /* Maximum current of high setting, uA */
91 unsigned int max;
92};
93
94extern const struct maxim_charger_current maxim_charger_currents[];
95extern int maxim_charger_calc_reg_current(const struct maxim_charger_current *limits,
96 unsigned int min_ua, unsigned int max_ua, u8 *dst);
97
Chanwoo Choi3008ddb2013-11-22 16:51:05 +010098#endif /* __MAX14577_H__ */