Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ */
0002 /*
0003  * max14577.h - Driver for the Maxim 14577/77836
0004  *
0005  * Copyright (C) 2014 Samsung Electrnoics
0006  * Chanwoo Choi <cw00.choi@samsung.com>
0007  * Krzysztof Kozlowski <krzk@kernel.org>
0008  *
0009  * This driver is based on max8997.h
0010  *
0011  * MAX14577 has MUIC, Charger devices.
0012  * The devices share the same I2C bus and interrupt line
0013  * included in this mfd driver.
0014  *
0015  * MAX77836 has additional PMIC and Fuel-Gauge on different I2C slave
0016  * addresses.
0017  */
0018 
0019 #ifndef __MAX14577_H__
0020 #define __MAX14577_H__
0021 
0022 #include <linux/regulator/consumer.h>
0023 
0024 /* MAX14577 regulator IDs */
0025 enum max14577_regulators {
0026     MAX14577_SAFEOUT = 0,
0027     MAX14577_CHARGER,
0028 
0029     MAX14577_REGULATOR_NUM,
0030 };
0031 
0032 /* MAX77836 regulator IDs */
0033 enum max77836_regulators {
0034     MAX77836_SAFEOUT = 0,
0035     MAX77836_CHARGER,
0036     MAX77836_LDO1,
0037     MAX77836_LDO2,
0038 
0039     MAX77836_REGULATOR_NUM,
0040 };
0041 
0042 struct max14577_regulator_platform_data {
0043     int id;
0044     struct regulator_init_data *initdata;
0045     struct device_node *of_node;
0046 };
0047 
0048 struct max14577_charger_platform_data {
0049     u32 constant_uvolt;
0050     u32 fast_charge_uamp;
0051     u32 eoc_uamp;
0052     u32 ovp_uvolt;
0053 };
0054 
0055 /*
0056  * MAX14577 MFD platform data
0057  */
0058 struct max14577_platform_data {
0059     /* IRQ */
0060     int irq_base;
0061 
0062     /* current control GPIOs */
0063     int gpio_pogo_vbatt_en;
0064     int gpio_pogo_vbus_en;
0065 
0066     /* current control GPIO control function */
0067     int (*set_gpio_pogo_vbatt_en) (int gpio_val);
0068     int (*set_gpio_pogo_vbus_en) (int gpio_val);
0069 
0070     int (*set_gpio_pogo_cb) (int new_dev);
0071 
0072     struct max14577_regulator_platform_data *regulators;
0073 };
0074 
0075 /*
0076  * Valid limits of current for max14577 and max77836 chargers.
0077  * They must correspond to MBCICHWRCL and MBCICHWRCH fields in CHGCTRL4
0078  * register for given chipset.
0079  */
0080 struct maxim_charger_current {
0081     /* Minimal current, set in CHGCTRL4/MBCICHWRCL, uA */
0082     unsigned int min;
0083     /*
0084      * Minimal current when high setting is active,
0085      * set in CHGCTRL4/MBCICHWRCH, uA
0086      */
0087     unsigned int high_start;
0088     /* Value of one step in high setting, uA */
0089     unsigned int high_step;
0090     /* Maximum current of high setting, uA */
0091     unsigned int max;
0092 };
0093 
0094 extern const struct maxim_charger_current maxim_charger_currents[];
0095 extern int maxim_charger_calc_reg_current(const struct maxim_charger_current *limits,
0096         unsigned int min_ua, unsigned int max_ua, u8 *dst);
0097 
0098 #endif /* __MAX14577_H__ */