Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 1 | /* |
Krzysztof Kozlowski | aee2a57 | 2014-04-14 11:17:18 +0200 | [diff] [blame] | 2 | * max14577.h - Driver for the Maxim 14577/77836 |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 3 | * |
Krzysztof Kozlowski | aee2a57 | 2014-04-14 11:17:18 +0200 | [diff] [blame] | 4 | * Copyright (C) 2014 Samsung Electrnoics |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 5 | * Chanwoo Choi <cw00.choi@samsung.com> |
Krzysztof Kozlowski | 8c5d057 | 2016-08-17 14:07:42 +0200 | [diff] [blame] | 6 | * Krzysztof Kozlowski <krzk@kernel.org> |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * This driver is based on max8997.h |
| 19 | * |
| 20 | * MAX14577 has MUIC, Charger devices. |
| 21 | * The devices share the same I2C bus and interrupt line |
| 22 | * included in this mfd driver. |
Krzysztof Kozlowski | aee2a57 | 2014-04-14 11:17:18 +0200 | [diff] [blame] | 23 | * |
| 24 | * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave |
| 25 | * addresses. |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef __MAX14577_H__ |
| 29 | #define __MAX14577_H__ |
| 30 | |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 31 | #include <linux/regulator/consumer.h> |
| 32 | |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 33 | /* MAX14577 regulator IDs */ |
| 34 | enum max14577_regulators { |
| 35 | MAX14577_SAFEOUT = 0, |
| 36 | MAX14577_CHARGER, |
| 37 | |
Krzysztof Kozlowski | 8a82b40 | 2014-04-14 11:17:20 +0200 | [diff] [blame] | 38 | MAX14577_REGULATOR_NUM, |
| 39 | }; |
| 40 | |
| 41 | /* MAX77836 regulator IDs */ |
| 42 | enum max77836_regulators { |
| 43 | MAX77836_SAFEOUT = 0, |
| 44 | MAX77836_CHARGER, |
| 45 | MAX77836_LDO1, |
| 46 | MAX77836_LDO2, |
| 47 | |
| 48 | MAX77836_REGULATOR_NUM, |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct max14577_regulator_platform_data { |
| 52 | int id; |
| 53 | struct regulator_init_data *initdata; |
| 54 | struct device_node *of_node; |
| 55 | }; |
| 56 | |
Krzysztof Kozlowski | e30110e | 2014-09-12 08:53:57 +0200 | [diff] [blame] | 57 | struct max14577_charger_platform_data { |
| 58 | u32 constant_uvolt; |
| 59 | u32 fast_charge_uamp; |
| 60 | u32 eoc_uamp; |
| 61 | u32 ovp_uvolt; |
| 62 | }; |
| 63 | |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 64 | /* |
| 65 | * MAX14577 MFD platform data |
| 66 | */ |
| 67 | struct max14577_platform_data { |
| 68 | /* IRQ */ |
| 69 | int irq_base; |
| 70 | |
| 71 | /* current control GPIOs */ |
| 72 | int gpio_pogo_vbatt_en; |
| 73 | int gpio_pogo_vbus_en; |
| 74 | |
| 75 | /* current control GPIO control function */ |
| 76 | int (*set_gpio_pogo_vbatt_en) (int gpio_val); |
| 77 | int (*set_gpio_pogo_vbus_en) (int gpio_val); |
| 78 | |
| 79 | int (*set_gpio_pogo_cb) (int new_dev); |
| 80 | |
| 81 | struct max14577_regulator_platform_data *regulators; |
| 82 | }; |
| 83 | |
Krzysztof Kozlowski | b8f139f | 2014-09-12 08:53:56 +0200 | [diff] [blame] | 84 | /* |
| 85 | * Valid limits of current for max14577 and max77836 chargers. |
| 86 | * They must correspond to MBCICHWRCL and MBCICHWRCH fields in CHGCTRL4 |
| 87 | * register for given chipset. |
| 88 | */ |
| 89 | struct maxim_charger_current { |
| 90 | /* Minimal current, set in CHGCTRL4/MBCICHWRCL, uA */ |
| 91 | unsigned int min; |
| 92 | /* |
| 93 | * Minimal current when high setting is active, |
| 94 | * set in CHGCTRL4/MBCICHWRCH, uA |
| 95 | */ |
| 96 | unsigned int high_start; |
| 97 | /* Value of one step in high setting, uA */ |
| 98 | unsigned int high_step; |
| 99 | /* Maximum current of high setting, uA */ |
| 100 | unsigned int max; |
| 101 | }; |
| 102 | |
| 103 | extern const struct maxim_charger_current maxim_charger_currents[]; |
| 104 | extern int maxim_charger_calc_reg_current(const struct maxim_charger_current *limits, |
| 105 | unsigned int min_ua, unsigned int max_ua, u8 *dst); |
| 106 | |
Chanwoo Choi | 3008ddb | 2013-11-22 16:51:05 +0100 | [diff] [blame] | 107 | #endif /* __MAX14577_H__ */ |