mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 07:03:09 -04:00
QC3P:discrete turbo charger
QC3P turbo charger changes for discrete arch. Change-Id: I0beaa0a9e01133d0d2d13930ded5fc64b0d4f3d1 Signed-off-by: xuwei9 <xuwei9@lenovo.com> Reviewed-on: https://gerrit.mot.com/2139304 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Huosheng Liao <liaohs@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
2c0fe1760e
commit
ed7f50a77c
9 changed files with 159 additions and 104 deletions
|
|
@ -110,7 +110,6 @@ struct mmi_charger_ops {
|
|||
#define to_mmi_charger_device(obj) container_of(obj, struct mmi_charger_device, dev)
|
||||
#define mmi_chrg_name(x) (dev_name(&(x)->dev))
|
||||
|
||||
extern struct mmi_charger_device *get_charger_by_name(const char *name);
|
||||
extern int is_charger_exist(const char *name);
|
||||
extern int mmi_charger_class_init(void);
|
||||
extern void mmi_charger_class_exit(void);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
#include "mmi_charger_policy.h"
|
||||
#include "mmi_qc3p.h"
|
||||
#include <linux/iio/consumer.h>
|
||||
#include <linux/qti_power_supply.h>
|
||||
|
||||
static int __debug_mask = 0x85;
|
||||
module_param_named(
|
||||
|
|
@ -119,6 +118,23 @@ int mmi_charger_write_iio_chan(struct mmi_charger_manager *chip,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
int start_qc3p_policy(struct mmi_charger_manager *chip)
|
||||
{
|
||||
if(chip == NULL) {
|
||||
mmi_chrg_err(chip, "mmi_charger_manager NULL\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mmi_chrg_err(chip, "start_qc3p_policy\n");
|
||||
|
||||
schedule_work(&chip->psy_changed_work);
|
||||
cancel_delayed_work(&chip->heartbeat_work);
|
||||
schedule_delayed_work(&chip->heartbeat_work,
|
||||
msecs_to_jiffies(1000));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mmi_charger_iio_write_raw(struct iio_dev *indio_dev,
|
||||
struct iio_chan_spec const *chan, int val1,
|
||||
int val2, long mask)
|
||||
|
|
@ -134,6 +150,8 @@ static int mmi_charger_iio_write_raw(struct iio_dev *indio_dev,
|
|||
else if (chip->qc3p_active)
|
||||
mmi_qc3p_chrg_enable_all_cp(chip, val1);
|
||||
}
|
||||
case PSY_IIO_QC3P_START_POLICY:
|
||||
start_qc3p_policy(chip);
|
||||
break;
|
||||
default:
|
||||
pr_err("Unsupported mmi_charger IIO chan %d\n", chan->channel);
|
||||
|
|
@ -937,9 +955,8 @@ static void mmi_heartbeat_work(struct work_struct *work)
|
|||
{
|
||||
struct mmi_charger_manager *chip = container_of(work,
|
||||
struct mmi_charger_manager, heartbeat_work.work);
|
||||
int hb_resch_time = 0, ret = 0, i = 0;
|
||||
int hb_resch_time = 0, ret = 0;
|
||||
union power_supply_propval val;
|
||||
bool pd_active;
|
||||
|
||||
mmi_chrg_info(chip, "MMI: Heartbeat!\n");
|
||||
/* Have not been resumed so wait another 100 ms */
|
||||
|
|
@ -973,7 +990,7 @@ static void mmi_heartbeat_work(struct work_struct *work)
|
|||
|
||||
if (!chip->vbus_present)
|
||||
mmi_awake_vote(chip, false);
|
||||
|
||||
#if 0
|
||||
ret = mmi_charger_read_iio_chan(chip, SMB5_USB_PD_ACTIVE, &val.intval);
|
||||
if (ret) {
|
||||
mmi_chrg_err(chip, "Unable to read PD ACTIVE: %d\n", ret);
|
||||
|
|
@ -1024,6 +1041,7 @@ static void mmi_heartbeat_work(struct work_struct *work)
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!chip->qc3p_sm_work_running && chip->vbus_present)
|
||||
chip->qc3p_active = mmi_qc3p_power_active(chip);
|
||||
|
||||
|
|
@ -1037,7 +1055,6 @@ static void mmi_heartbeat_work(struct work_struct *work)
|
|||
kick_qc3p_sm(chip, 100);
|
||||
}
|
||||
|
||||
schedule_work:
|
||||
schedule_delayed_work(&chip->heartbeat_work,
|
||||
msecs_to_jiffies(hb_resch_time));
|
||||
}
|
||||
|
|
@ -1047,8 +1064,7 @@ static void psy_changed_work_func(struct work_struct *work)
|
|||
struct mmi_charger_manager *chip = container_of(work,
|
||||
struct mmi_charger_manager, psy_changed_work);
|
||||
union power_supply_propval val;
|
||||
bool pd_active;
|
||||
int ret, i;
|
||||
int ret;
|
||||
|
||||
mmi_chrg_info(chip, "kick psy changed work.\n");
|
||||
|
||||
|
|
@ -1068,7 +1084,7 @@ static void psy_changed_work_func(struct work_struct *work)
|
|||
return;
|
||||
}
|
||||
chip->vbus_present = val.intval;
|
||||
|
||||
#if 0
|
||||
ret = mmi_charger_read_iio_chan(chip, SMB5_USB_PD_ACTIVE, &val.intval);
|
||||
if (ret) {
|
||||
mmi_chrg_err(chip, "Unable to read PD ACTIVE: %d\n", ret);
|
||||
|
|
@ -1120,7 +1136,7 @@ static void psy_changed_work_func(struct work_struct *work)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
mmi_chrg_info(chip, "vbus present %d, pd pps support %d, "
|
||||
"pps max voltage %d, pps max curr %d\n",
|
||||
chip->vbus_present,
|
||||
|
|
@ -1624,7 +1640,7 @@ static int mmi_chrg_manager_probe(struct platform_device *pdev)
|
|||
|
||||
chip->factory_mode = mmi_factory_check();
|
||||
|
||||
chip->qcom_psy = power_supply_get_by_name("qcom_battery");
|
||||
chip->qcom_psy = power_supply_get_by_name("mmi_battery");
|
||||
chip->batt_psy = power_supply_get_by_name("battery");
|
||||
if (!chip->batt_psy) {
|
||||
mmi_chrg_err(chip, "Could not get battery power_supply\n");
|
||||
|
|
@ -1639,7 +1655,7 @@ static int mmi_chrg_manager_probe(struct platform_device *pdev)
|
|||
"mmi chrg policy init failed\n");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
#if 0
|
||||
chip->pd_handle =
|
||||
devm_usbpd_get_by_phandle(chip->dev, "qcom,usbpd-phandle");
|
||||
if (IS_ERR_OR_NULL(chip->pd_handle)) {
|
||||
|
|
@ -1647,7 +1663,7 @@ static int mmi_chrg_manager_probe(struct platform_device *pdev)
|
|||
PTR_ERR(chip->pd_handle));
|
||||
chip->pd_handle = NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (!chip->usb_psy) {
|
||||
chip->usb_psy = power_supply_get_by_name("usb");
|
||||
if (!chip->usb_psy)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
#include <linux/pm_wakeup.h>
|
||||
#include <linux/build_bug.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/mmi_discrete_charger_class.h>
|
||||
|
||||
#define mmi_chrg_err(chip, fmt, ...) \
|
||||
pr_err("%s: %s: " fmt, chip->name, \
|
||||
|
|
@ -76,13 +77,11 @@ enum print_reason {
|
|||
PR_MOTO = BIT(7),
|
||||
};
|
||||
|
||||
enum {
|
||||
POWER_SUPPLY_CHARGE_RATE_NONE = 0,
|
||||
POWER_SUPPLY_CHARGE_RATE_NORMAL,
|
||||
POWER_SUPPLY_CHARGE_RATE_WEAK,
|
||||
POWER_SUPPLY_CHARGE_RATE_TURBO,
|
||||
POWER_SUPPLY_CHARGE_RATE_TURBO_30W,
|
||||
POWER_SUPPLY_CHARGE_RATE_HYPER,
|
||||
enum mmi_qc3p_power {
|
||||
QTI_POWER_SUPPLY_QC3P_NONE,
|
||||
QTI_POWER_SUPPLY_QC3P_18W = 0x8,
|
||||
QTI_POWER_SUPPLY_QC3P_27W,
|
||||
QTI_POWER_SUPPLY_QC3P_45W,
|
||||
};
|
||||
|
||||
static inline void wakeup_source_init_internal(struct wakeup_source *ws,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ struct mmi_charger_iio_channels {
|
|||
|
||||
static const struct mmi_charger_iio_channels mmi_charger_iio_psy_channels[] = {
|
||||
MMI_CHARGER_CHAN_INDEX("cp_charging_enabled", PSY_IIO_CP_ENABLE)
|
||||
MMI_CHARGER_CHAN_INDEX("qc3p_start_policy", PSY_IIO_QC3P_START_POLICY)
|
||||
};
|
||||
enum mmi_charger_ext_iio_channels {
|
||||
/*smb5*/
|
||||
|
|
@ -48,29 +49,31 @@ enum mmi_charger_ext_iio_channels {
|
|||
CP_INPUT_VOLTAGE_NOW,
|
||||
CP_STATUS1,
|
||||
CP_CLEAR_ERROR,
|
||||
SMB5_QC3P_START_DETECT,
|
||||
/*mmi-smb5charger-iio*/
|
||||
MMI_CP_ENABLE_STATUS,
|
||||
};
|
||||
|
||||
static const char * const mmi_charger_ext_iio_chan_name[] = {
|
||||
/*smb5*/
|
||||
[SMB5_HW_CURRENT_MAX] = "usb_hw_current_max",
|
||||
/*discrete*/
|
||||
[SMB5_HW_CURRENT_MAX] = "hw_current_max",
|
||||
[SMB5_CHARGING_ENABLED] = "charging_enabled",
|
||||
[SMB5_TYPEC_MODE] = "usb_typec_mode",
|
||||
[SMB5_USB_INPUT_CURRENT_SETTLED] = "usb_input_current_settled",
|
||||
[SMB5_USB_PD_ACTIVE] = "usb_pd_active",
|
||||
[SMB5_TYPEC_MODE] = "typec_mode",
|
||||
[SMB5_USB_INPUT_CURRENT_SETTLED] = "input_current_settled",
|
||||
[SMB5_USB_PD_ACTIVE] = "pd_active",
|
||||
/*qc3p*/
|
||||
[SMB5_USB_REAL_TYPE] = "usb_real_type",
|
||||
[SMB5_DP_DM] = "battery_dp_dm",
|
||||
[SMB5_QC3P_POWER] = "usb_qc3p_power",
|
||||
[SMB5_USB_REAL_TYPE] = "wt6670_usb_real_type",
|
||||
[SMB5_DP_DM] = "wt6670_battery_dp_dm",
|
||||
[SMB5_QC3P_POWER] = "wt6670_usb_qc3p_power",
|
||||
[SMB5_QC3P_START_DETECT] = "wt6670_start_detection",
|
||||
/*cp*/
|
||||
[CP_ENABLE] = "cp_enable",
|
||||
[CP_INPUT_CURRENT_NOW] = "cp_input_current_now",
|
||||
[CP_INPUT_VOLTAGE_NOW] = "cp_input_voltage_now",
|
||||
[CP_STATUS1] = "cp_status1",
|
||||
[CP_CLEAR_ERROR] = "cp_clear_error",
|
||||
[CP_ENABLE] = "bq2597x_cp_enabled",
|
||||
[CP_INPUT_CURRENT_NOW] = "bq2597x_input_current_now",
|
||||
[CP_INPUT_VOLTAGE_NOW] = "bq2597x_input_voltage_settled",
|
||||
[CP_STATUS1] = "bq2597x_cp_status1",
|
||||
[CP_CLEAR_ERROR] = "bq2597x_cp_clear_error",
|
||||
/*mmi-smb5charger-iio*/
|
||||
[MMI_CP_ENABLE_STATUS] = "mmi_cp_enabled_status",
|
||||
[MMI_CP_ENABLE_STATUS] = "bq2597x_cp_enabled",
|
||||
};
|
||||
|
||||
int mmi_charger_read_iio_chan(struct mmi_charger_manager *chip,
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ void mmi_chrg_sm_work_func(struct work_struct *work)
|
|||
mmi_enable_charging(chrg_list->chrg_dev[PMIC_SW], true);
|
||||
}
|
||||
mmi_chrg_info(chip, "Check all effective pdo info again\n");
|
||||
usbpd_get_pdo_info(chip->pd_handle, chip->mmi_pdo_info,PD_MAX_PDO_NUM);
|
||||
usbpd_get_pdo_info(chip->pd_handle, chip->mmi_pdo_info);
|
||||
mmi_chrg_info(chip, "Select FIXED pdo for switch charging !\n");
|
||||
for (i = 0; i < PD_MAX_PDO_NUM; i++) {
|
||||
mmi_chrg_info(chip,"find pdo %d, max volt %d, max curr %d\n",
|
||||
|
|
@ -644,7 +644,7 @@ void mmi_chrg_sm_work_func(struct work_struct *work)
|
|||
}
|
||||
|
||||
mmi_chrg_info(chip, "Check all effective pdo info again\n");
|
||||
usbpd_get_pdo_info(chip->pd_handle, chip->mmi_pdo_info,PD_MAX_PDO_NUM);
|
||||
usbpd_get_pdo_info(chip->pd_handle, chip->mmi_pdo_info);
|
||||
for (i = 0; i < PD_MAX_PDO_NUM; i++) {
|
||||
if ((chip->mmi_pdo_info[i].type ==
|
||||
PD_SRC_PDO_TYPE_AUGMENTED)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ static int cp_enable_charging(struct mmi_charger_device *chrg, bool en)
|
|||
} else
|
||||
chrg->charger_enabled = false;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, en:%d\n",__func__,en);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +74,7 @@ static int cp_is_charging_enabled(struct mmi_charger_device *chrg, bool *en)
|
|||
chrg->charger_enabled = false;
|
||||
|
||||
*en = chrg->charger_enabled;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, en:%d\n",__func__,*en);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +90,7 @@ static int cp_get_charging_current(struct mmi_charger_device *chrg, u32 *uA)
|
|||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
*uA = !!prop.intval;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, uA:%d\n",__func__,*uA);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +104,7 @@ static int cp_get_vbus(struct mmi_charger_device *chrg, u32 *mv)
|
|||
rc = mmi_charger_read_iio_chan(chip, CP_INPUT_VOLTAGE_NOW, &val);
|
||||
if (!rc)
|
||||
*mv = val;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, mv:%d\n",__func__,*mv);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +121,7 @@ static int cp_get_input_current(struct mmi_charger_device *chrg, u32 *uA) //ibus
|
|||
|
||||
if (!rc)
|
||||
*uA = value;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, uA:%d\n",__func__,*uA);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -129,10 +130,16 @@ static int cp_update_charger_status(struct mmi_charger_device *chrg)
|
|||
int rc;
|
||||
struct mmi_charger_manager *chip = dev_get_drvdata(&chrg->dev);
|
||||
union power_supply_propval prop = {0,};
|
||||
static struct power_supply *battery_psy = NULL;
|
||||
|
||||
if (!chrg->chrg_psy)
|
||||
return -ENODEV;
|
||||
|
||||
if (!battery_psy)
|
||||
battery_psy = power_supply_get_by_name("battery");
|
||||
if (!battery_psy)
|
||||
return -ENODEV;
|
||||
|
||||
rc = power_supply_get_property(chrg->chrg_psy,
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &prop);
|
||||
if (!rc)
|
||||
|
|
@ -148,7 +155,7 @@ static int cp_update_charger_status(struct mmi_charger_device *chrg)
|
|||
if (!rc)
|
||||
chrg->charger_data.ibatt_curr = prop.intval;
|
||||
|
||||
rc = power_supply_get_property(chrg->chrg_psy,
|
||||
rc = power_supply_get_property(battery_psy,
|
||||
POWER_SUPPLY_PROP_TEMP, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.batt_temp = prop.intval;
|
||||
|
|
@ -195,6 +202,7 @@ static int cp_update_charger_error_status(struct mmi_charger_device *chrg)
|
|||
if (!rc) {
|
||||
chrg->charger_error.chrg_err_type = value;
|
||||
}
|
||||
chrg_dev_info(chrg, "%s end, status:%d\n",__func__,value);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -208,7 +216,7 @@ static int cp_clear_charger_error(struct mmi_charger_device *chrg)
|
|||
return -ENODEV;
|
||||
|
||||
rc = mmi_charger_write_iio_chan(chip, CP_CLEAR_ERROR, value);
|
||||
|
||||
chrg_dev_info(chrg, "%s end, status:%d\n",__func__,value);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,32 @@
|
|||
*/
|
||||
#include "mmi_charger_core.h"
|
||||
#include "mmi_charger_core_iio.h"
|
||||
#include <linux/qti_power_supply.h>
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_gpio.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
bool mmi_qc3p_start_detection(struct mmi_charger_manager *chg)
|
||||
{
|
||||
int ret, iio_val;
|
||||
|
||||
ret = mmi_charger_read_iio_chan(chg, SMB5_QC3P_START_DETECT, &iio_val);
|
||||
if (ret < 0) {
|
||||
mmi_chrg_err(chg, "Couldn't operate qc3p detection rc=%d\n", ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mmi_qc3p_power_active(struct mmi_charger_manager *chg)
|
||||
{
|
||||
|
|
@ -38,7 +63,7 @@ bool mmi_qc3p_power_active(struct mmi_charger_manager *chg)
|
|||
mmi_chrg_err(chg, "Couldn't read charger type rc=%d\n", ret);
|
||||
return false;
|
||||
}
|
||||
if (iio_val != QTI_POWER_SUPPLY_TYPE_USB_HVDCP_3P5)
|
||||
if (iio_val != QTI_POWER_SUPPLY_QC3P_27W && iio_val != QTI_POWER_SUPPLY_QC3P_45W)
|
||||
return false;
|
||||
|
||||
ret = mmi_charger_read_iio_chan(chg, SMB5_QC3P_POWER, &iio_val);
|
||||
|
|
@ -56,21 +81,12 @@ bool mmi_qc3p_power_active(struct mmi_charger_manager *chg)
|
|||
return false;
|
||||
}
|
||||
|
||||
#define QC3P_PULSE_COUNT_MAX ((11000 - 5000) / 20 + 10)
|
||||
int mmi_qc3p_set_vbus_voltage(struct mmi_charger_manager *chg, int target_mv)
|
||||
{
|
||||
int rc = -EINVAL;
|
||||
union power_supply_propval val = {0, };
|
||||
int pulse_cnt, curr_vbus_mv, step, i;
|
||||
|
||||
rc = mmi_charger_read_iio_chan(chg, SMB5_DP_DM, &val.intval);
|
||||
if (rc < 0) {
|
||||
mmi_chrg_err(chg, "Couldn't read dpdm pulse count rc=%d\n", rc);
|
||||
return -EINVAL;
|
||||
} else {
|
||||
mmi_chrg_info(chg, "DP DM pulse count = %d\n", val.intval);
|
||||
pulse_cnt = val.intval;
|
||||
}
|
||||
int curr_vbus_mv = 0, step = 0,curr_vbus_ma = 0;
|
||||
int impendance_vubs_volt = 0;
|
||||
int sleep_ms_wt = 0;
|
||||
|
||||
rc = mmi_get_vbus(chg->chrg_list[CP_MASTER],
|
||||
&curr_vbus_mv);
|
||||
|
|
@ -79,30 +95,35 @@ int mmi_qc3p_set_vbus_voltage(struct mmi_charger_manager *chg, int target_mv)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = mmi_get_input_current(chg->chrg_list[CP_MASTER],
|
||||
&curr_vbus_ma);
|
||||
if (rc) {
|
||||
mmi_chrg_err(chg, "Unable to read USB ma: %d\n", rc);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
// impendance_vubs_volt = (DEFAULT_VBUS_RESISTANCE * curr_vbus_ma) / 1000;
|
||||
impendance_vubs_volt = 200;
|
||||
curr_vbus_mv -= impendance_vubs_volt ;
|
||||
|
||||
if(target_mv < curr_vbus_mv) {
|
||||
step = (curr_vbus_mv - target_mv) / 20;
|
||||
val.intval = QTI_POWER_SUPPLY_DP_DM_DM_PULSE;
|
||||
if (pulse_cnt <= step)
|
||||
step = pulse_cnt;
|
||||
step = step *-1;
|
||||
} else {
|
||||
step = (target_mv - curr_vbus_mv) / 20;
|
||||
val.intval = QTI_POWER_SUPPLY_DP_DM_DP_PULSE;
|
||||
if (step + pulse_cnt > QC3P_PULSE_COUNT_MAX)
|
||||
step = QC3P_PULSE_COUNT_MAX - pulse_cnt;
|
||||
}
|
||||
|
||||
mmi_chrg_info(chg, "curr_vbus= %d, target_vbus = %d, step = %d\n",curr_vbus_mv, target_mv, step);
|
||||
for (i = 0; i < step; i++) {
|
||||
rc = mmi_charger_write_iio_chan(chg, SMB5_DP_DM, val.intval);
|
||||
if (rc < 0) {
|
||||
mmi_chrg_err(chg, "Couldn't set dpdm pulse rc=%d\n", rc);
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < step - 1)
|
||||
udelay(5000);
|
||||
mmi_chrg_info(chg, "curr_vbus= %d, target_vbus = %d, step = %d, impent_v:%d\n",curr_vbus_mv, target_mv, step,impendance_vubs_volt);
|
||||
rc = mmi_charger_write_iio_chan(chg, SMB5_DP_DM, step);
|
||||
if (rc < 0) {
|
||||
mmi_chrg_err(chg, "Couldn't set dpdm pulse rc=%d\n", rc);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
//need wait dp/dm send out
|
||||
sleep_ms_wt = abs(step) * 10;
|
||||
msleep(sleep_ms_wt);
|
||||
|
||||
rc = mmi_get_vbus(chg->chrg_list[CP_MASTER],
|
||||
&curr_vbus_mv);
|
||||
if (rc) {
|
||||
|
|
@ -111,4 +132,4 @@ int mmi_qc3p_set_vbus_voltage(struct mmi_charger_manager *chg, int target_mv)
|
|||
}
|
||||
mmi_chrg_info(chg, "result_vbus= %d\n",curr_vbus_mv);
|
||||
return curr_vbus_mv;
|
||||
}
|
||||
}
|
||||
|
|
@ -314,10 +314,7 @@ void mmi_qc3p_chrg_sm_work_func(struct work_struct *work)
|
|||
if (!rc)
|
||||
pmic_sys_therm_level = prop.intval;
|
||||
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
ibatt_curr = prop.intval;
|
||||
ibatt_curr = chrg_list->chrg_dev[PMIC_SW]->charger_data.ibatt_curr;
|
||||
|
||||
rc = power_supply_get_property(chip->batt_psy,
|
||||
POWER_SUPPLY_PROP_TEMP, &prop);
|
||||
|
|
@ -654,7 +651,7 @@ void mmi_qc3p_chrg_sm_work_func(struct work_struct *work)
|
|||
|
||||
if (chrg_list->cp_master
|
||||
&& (!chrg_list->chrg_dev[CP_MASTER]->charger_enabled
|
||||
|| !(chrg_list->chrg_dev[CP_MASTER]->charger_error.chrg_err_type & (1<< MMI_CP_SWITCH_BIT)))) {
|
||||
|| (chrg_list->chrg_dev[CP_MASTER]->charger_error.chrg_err_type & (1<< MMI_CP_SWITCH_BIT)))) {
|
||||
mmi_chrg_info(chip,"CP MASTER was disabled, "
|
||||
"Enter into SW directly\n");
|
||||
chip->qc3p_volt_comp = QC3P_INIT_VOLT_COMP;
|
||||
|
|
@ -713,7 +710,7 @@ void mmi_qc3p_chrg_sm_work_func(struct work_struct *work)
|
|||
chrg_step->chrg_step_cv_volt);
|
||||
if (chrg_list->cp_master
|
||||
&& (!chrg_list->chrg_dev[CP_MASTER]->charger_enabled
|
||||
|| !(chrg_list->chrg_dev[CP_MASTER]->charger_error.chrg_err_type & (1<< MMI_CP_SWITCH_BIT)))) {
|
||||
|| (chrg_list->chrg_dev[CP_MASTER]->charger_error.chrg_err_type & (1<< MMI_CP_SWITCH_BIT)))) {
|
||||
mmi_chrg_info(chip,"CP MASTER was disabled, Enter into SW directly\n");
|
||||
chip->qc3p_volt_comp = QC3P_INIT_VOLT_COMP;
|
||||
mmi_chrg_qc3p_sm_move_state(chip, PM_QC3P_STATE_SW_ENTRY);
|
||||
|
|
@ -791,7 +788,7 @@ void mmi_qc3p_chrg_sm_work_func(struct work_struct *work)
|
|||
chrg_step->chrg_step_cv_tapper_curr);
|
||||
if (chrg_list->cp_master
|
||||
&& (!chrg_list->chrg_dev[CP_MASTER]->charger_enabled
|
||||
|| !(chrg_list->chrg_dev[CP_MASTER]->charger_error.chrg_err_type & (1<< MMI_CP_SWITCH_BIT)))) {
|
||||
|| (chrg_list->chrg_dev[CP_MASTER]->charger_error.chrg_err_type & (1<< MMI_CP_SWITCH_BIT)))) {
|
||||
mmi_chrg_info(chip,"CP MASTER was disabled, Enter into SW directly\n");
|
||||
chip->qc3p_volt_comp = QC3P_INIT_VOLT_COMP;
|
||||
mmi_chrg_qc3p_sm_move_state(chip, PM_QC3P_STATE_SW_ENTRY);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ static int qpnp_pmic_enable_charging(struct mmi_charger_device *chrg, bool en)
|
|||
} else {
|
||||
chrg->charger_enabled = false;
|
||||
}
|
||||
|
||||
chrg_dev_info(chrg, "%s end, en:%d\n",__func__,en);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ static int qpnp_pmic_is_charging_enabled(struct mmi_charger_device *chrg, bool *
|
|||
chrg->charger_enabled = false;
|
||||
|
||||
*en = chrg->charger_enabled;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, en:%d\n",__func__,*en);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -80,15 +80,19 @@ static int qpnp_pmic_get_charging_current(struct mmi_charger_device *chrg, u32 *
|
|||
{
|
||||
int rc;
|
||||
union power_supply_propval prop = {0,};
|
||||
static struct power_supply *bms_psy;
|
||||
|
||||
if (!chrg->chrg_psy)
|
||||
if (!bms_psy)
|
||||
bms_psy = power_supply_get_by_name("bms");
|
||||
if (!bms_psy)
|
||||
return -ENODEV;
|
||||
|
||||
rc = power_supply_get_property(chrg->chrg_psy,
|
||||
|
||||
rc = power_supply_get_property(bms_psy,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
*uA = prop.intval;
|
||||
*uA = prop.intval * -1;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, uA:%d\n",__func__,*uA);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +111,7 @@ static int qpnp_pmic_get_ibus(struct mmi_charger_device *chrg, u32 *uA)
|
|||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
*uA = prop.intval;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, uA:%d\n",__func__,*uA);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -124,24 +128,25 @@ static int qpnp_pmic_set_charging_current(struct mmi_charger_device *chrg, u32 u
|
|||
POWER_SUPPLY_PROP_CURRENT_MAX, &prop);
|
||||
// if (!rc)
|
||||
// chrg->charger_limited = true;
|
||||
|
||||
chrg_dev_info(chrg, "%s end, uA:%d\n",__func__,uA);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int qpnp_pmic_get_input_current_settled(struct mmi_charger_device *chrg, u32 *uA)
|
||||
{
|
||||
int rc = 0;
|
||||
int value;
|
||||
struct mmi_charger_manager *chip = dev_get_drvdata(&chrg->dev);
|
||||
union power_supply_propval prop = {0,};
|
||||
static struct power_supply *charger_psy = NULL;
|
||||
|
||||
if (!chip)
|
||||
charger_psy = power_supply_get_by_name("charger");
|
||||
if (!charger_psy)
|
||||
return -ENODEV;
|
||||
|
||||
rc = mmi_charger_read_iio_chan(chip, SMB5_HW_CURRENT_MAX, &value);
|
||||
rc = power_supply_get_property(charger_psy,
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, &prop);
|
||||
if (!rc)
|
||||
chrg->input_curr_setted = value;
|
||||
*uA = chrg->input_curr_setted;
|
||||
|
||||
*uA = prop.intval;
|
||||
chrg_dev_info(chrg, "%s end, uA:%d\n",__func__,*uA);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +156,14 @@ static int qpnp_pmic_update_charger_status(struct mmi_charger_device *chrg)
|
|||
bool value = 0;
|
||||
static struct power_supply *usb_psy = NULL;
|
||||
union power_supply_propval prop = {0,};
|
||||
static struct power_supply *cp_psy = NULL;
|
||||
static struct power_supply *bms_psy;
|
||||
|
||||
if (!bms_psy)
|
||||
bms_psy = power_supply_get_by_name("bms");
|
||||
if (!bms_psy)
|
||||
return -ENODEV;
|
||||
|
||||
if (!chrg->chrg_psy)
|
||||
return -ENODEV;
|
||||
|
||||
|
|
@ -160,35 +172,35 @@ static int qpnp_pmic_update_charger_status(struct mmi_charger_device *chrg)
|
|||
if (!usb_psy)
|
||||
return -ENODEV;
|
||||
|
||||
rc = power_supply_get_property(usb_psy,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.ibus_curr= prop.intval;
|
||||
if (!cp_psy)
|
||||
cp_psy = power_supply_get_by_name("cp-standalone");
|
||||
if (!cp_psy)
|
||||
return -ENODEV;
|
||||
|
||||
rc = power_supply_get_property(chrg->chrg_psy,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.vbatt_volt = prop.intval;
|
||||
|
||||
rc = power_supply_get_property(chrg->chrg_psy,
|
||||
rc = power_supply_get_property(bms_psy,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.ibatt_curr = prop.intval;
|
||||
chrg->charger_data.ibatt_curr = prop.intval * -1;
|
||||
|
||||
rc = power_supply_get_property(chrg->chrg_psy,
|
||||
POWER_SUPPLY_PROP_TEMP, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.batt_temp = prop.intval / 10;
|
||||
|
||||
rc = power_supply_get_property(usb_psy,
|
||||
rc = power_supply_get_property(cp_psy,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.vbus_volt = prop.intval;
|
||||
|
||||
rc = power_supply_get_property(usb_psy,
|
||||
rc = power_supply_get_property(cp_psy,
|
||||
POWER_SUPPLY_PROP_CURRENT_NOW, &prop);
|
||||
if (!rc)
|
||||
chrg->charger_data.ibus_curr = prop.intval;
|
||||
chrg->charger_data.ibus_curr = 500000;//prop.intval;
|
||||
|
||||
rc = power_supply_get_property(usb_psy,
|
||||
POWER_SUPPLY_PROP_PRESENT, &prop);
|
||||
|
|
|
|||
Loading…
Reference in a new issue