linux/drivers/power/supply/axp288_charger.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * axp288_charger.c - X-power AXP288 PMIC Charger driver
 *
 * Copyright (C) 2016-2017 Hans de Goede <[email protected]>
 * Copyright (C) 2014 Intel Corporation
 * Author: Ramakrishna Pallala <[email protected]>
 */

#include <linux/acpi.h>
#include <linux/bitops.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/regmap.h>
#include <linux/workqueue.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/usb/otg.h>
#include <linux/notifier.h>
#include <linux/power_supply.h>
#include <linux/property.h>
#include <linux/mfd/axp20x.h>
#include <linux/extcon.h>
#include <linux/dmi.h>
#include <asm/iosf_mbi.h>

#define PS_STAT_VBUS_TRIGGER
#define PS_STAT_BAT_CHRG_DIR
#define PS_STAT_VBAT_ABOVE_VHOLD
#define PS_STAT_VBUS_VALID
#define PS_STAT_VBUS_PRESENT

#define CHRG_STAT_BAT_SAFE_MODE
#define CHRG_STAT_BAT_VALID
#define CHRG_STAT_BAT_PRESENT
#define CHRG_STAT_CHARGING
#define CHRG_STAT_PMIC_OTP

#define VBUS_ISPOUT_CUR_LIM_MASK
#define VBUS_ISPOUT_CUR_LIM_BIT_POS
#define VBUS_ISPOUT_CUR_LIM_900MA
#define VBUS_ISPOUT_CUR_LIM_1500MA
#define VBUS_ISPOUT_CUR_LIM_2000MA
#define VBUS_ISPOUT_CUR_NO_LIM
#define VBUS_ISPOUT_VHOLD_SET_MASK
#define VBUS_ISPOUT_VHOLD_SET_BIT_POS
#define VBUS_ISPOUT_VHOLD_SET_OFFSET
#define VBUS_ISPOUT_VHOLD_SET_LSB_RES
#define VBUS_ISPOUT_VHOLD_SET_4400MV
#define VBUS_ISPOUT_VBUS_PATH_DIS

#define CHRG_CCCV_CC_MASK
#define CHRG_CCCV_CC_BIT_POS
#define CHRG_CCCV_CC_OFFSET
#define CHRG_CCCV_CC_LSB_RES
#define CHRG_CCCV_ITERM_20P
#define CHRG_CCCV_CV_MASK
#define CHRG_CCCV_CV_BIT_POS
#define CHRG_CCCV_CV_4100MV
#define CHRG_CCCV_CV_4150MV
#define CHRG_CCCV_CV_4200MV
#define CHRG_CCCV_CV_4350MV
#define CHRG_CCCV_CHG_EN

#define CNTL2_CC_TIMEOUT_MASK
#define CNTL2_CC_TIMEOUT_OFFSET
#define CNTL2_CC_TIMEOUT_LSB_RES
#define CNTL2_CC_TIMEOUT_12HRS
#define CNTL2_CHGLED_TYPEB
#define CNTL2_CHG_OUT_TURNON
#define CNTL2_PC_TIMEOUT_MASK
#define CNTL2_PC_TIMEOUT_OFFSET
#define CNTL2_PC_TIMEOUT_LSB_RES
#define CNTL2_PC_TIMEOUT_70MINS

#define CHRG_ILIM_TEMP_LOOP_EN
#define CHRG_VBUS_ILIM_MASK
#define CHRG_VBUS_ILIM_BIT_POS
#define CHRG_VBUS_ILIM_100MA
#define CHRG_VBUS_ILIM_500MA
#define CHRG_VBUS_ILIM_900MA
#define CHRG_VBUS_ILIM_1500MA
#define CHRG_VBUS_ILIM_2000MA
#define CHRG_VBUS_ILIM_2500MA
#define CHRG_VBUS_ILIM_3000MA
#define CHRG_VBUS_ILIM_3500MA
#define CHRG_VBUS_ILIM_4000MA

#define CHRG_VLTFC_0C
#define CHRG_VHTFC_45C

#define FG_CNTL_OCV_ADJ_EN

#define CV_4100MV
#define CV_4150MV
#define CV_4200MV
#define CV_4350MV

#define AXP288_REG_UPDATE_INTERVAL

#define AXP288_EXTCON_DEV_NAME
#define USB_HOST_EXTCON_HID
#define USB_HOST_EXTCON_NAME

enum {};

struct axp288_chrg_info {};

static inline int axp288_charger_set_cc(struct axp288_chrg_info *info, int cc)
{}

static inline int axp288_charger_set_cv(struct axp288_chrg_info *info, int cv)
{}

static int axp288_charger_get_vbus_inlmt(struct axp288_chrg_info *info)
{}

static inline int axp288_charger_set_vbus_inlmt(struct axp288_chrg_info *info,
					   int inlmt)
{}

static int axp288_charger_vbus_path_select(struct axp288_chrg_info *info,
								bool enable)
{}

static int axp288_charger_enable_charger(struct axp288_chrg_info *info,
								bool enable)
{}

static int axp288_get_charger_health(struct axp288_chrg_info *info)
{}

static int axp288_charger_usb_set_property(struct power_supply *psy,
				    enum power_supply_property psp,
				    const union power_supply_propval *val)
{}

static int axp288_charger_reg_readb(struct axp288_chrg_info *info, int reg, unsigned int *ret_val)
{}

static int axp288_charger_usb_update_property(struct axp288_chrg_info *info)
{}

static int axp288_charger_usb_get_property(struct power_supply *psy,
				    enum power_supply_property psp,
				    union power_supply_propval *val)
{}

static int axp288_charger_property_is_writeable(struct power_supply *psy,
		enum power_supply_property psp)
{}

static enum power_supply_property axp288_usb_props[] =;

static const struct power_supply_desc axp288_charger_desc =;

static irqreturn_t axp288_charger_irq_thread_handler(int irq, void *dev)
{}

/*
 * The HP Pavilion x2 10 series comes in a number of variants:
 * Bay Trail SoC    + AXP288 PMIC, Micro-USB, DMI_BOARD_NAME: "8021"
 * Bay Trail SoC    + AXP288 PMIC, Type-C,    DMI_BOARD_NAME: "815D"
 * Cherry Trail SoC + AXP288 PMIC, Type-C,    DMI_BOARD_NAME: "813E"
 * Cherry Trail SoC + TI PMIC,     Type-C,    DMI_BOARD_NAME: "827C" or "82F4"
 *
 * The variants with the AXP288 + Type-C connector are all kinds of special:
 *
 * 1. They use a Type-C connector which the AXP288 does not support, so when
 * using a Type-C charger it is not recognized. Unlike most AXP288 devices,
 * this model actually has mostly working ACPI AC / Battery code, the ACPI code
 * "solves" this by simply setting the input_current_limit to 3A.
 * There are still some issues with the ACPI code, so we use this native driver,
 * and to solve the charging not working (500mA is not enough) issue we hardcode
 * the 3A input_current_limit like the ACPI code does.
 *
 * 2. If no charger is connected the machine boots with the vbus-path disabled.
 * Normally this is done when a 5V boost converter is active to avoid the PMIC
 * trying to charge from the 5V boost converter's output. This is done when
 * an OTG host cable is inserted and the ID pin on the micro-B receptacle is
 * pulled low and the ID pin has an ACPI event handler associated with it
 * which re-enables the vbus-path when the ID pin is pulled high when the
 * OTG host cable is removed. The Type-C connector has no ID pin, there is
 * no ID pin handler and there appears to be no 5V boost converter, so we
 * end up not charging because the vbus-path is disabled, until we unplug
 * the charger which automatically clears the vbus-path disable bit and then
 * on the second plug-in of the adapter we start charging. To solve the not
 * charging on first charger plugin we unconditionally enable the vbus-path at
 * probe on this model, which is safe since there is no 5V boost converter.
 */
static const struct dmi_system_id axp288_hp_x2_dmi_ids[] =;

static void axp288_charger_extcon_evt_worker(struct work_struct *work)
{}

static int axp288_charger_handle_cable_evt(struct notifier_block *nb,
					   unsigned long event, void *param)
{}

static void axp288_charger_otg_evt_worker(struct work_struct *work)
{}

static int axp288_charger_handle_otg_evt(struct notifier_block *nb,
				   unsigned long event, void *param)
{}

static int charger_init_hw_regs(struct axp288_chrg_info *info)
{}

static void axp288_charger_cancel_work(void *data)
{}

static int axp288_charger_probe(struct platform_device *pdev)
{}

static const struct platform_device_id axp288_charger_id_table[] =;
MODULE_DEVICE_TABLE(platform, axp288_charger_id_table);

static struct platform_driver axp288_charger_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();