Loading Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt +6 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,12 @@ Charger specific properties: Value type: <u32> Definition: Specifies the DC input current limit in micro-amps. - qcom,wipower-max-uw Usage: optional Value type: <u32> Definition: Specifies the DC input power limit in micro-watts. If the value is not present, 8W is used as default. ============================================= Second Level Nodes - SMB2 Charger Peripherals ============================================= Loading Loading @@ -80,9 +86,7 @@ pmicobalt_charger: qcom,qpnp-smb2 { #address-cells = <1>; #size-cells = <1>; qcom,pmic-revid = <&pmicobalt_revid>; qcom,suspend-input; qcom,disable-charging; dpdm-supply = <&qusb_phy0>; qcom,chgr@1000 { Loading drivers/power/qcom-charger/qpnp-smb2.c +124 −17 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #define SMB2_DEFAULT_FCC_UA 3000000 #define SMB2_DEFAULT_FV_UV 4350000 #define SMB2_DEFAULT_ICL_UA 3000000 #define SMB2_DEFAULT_WPWR_UW 8000000 static struct smb_params v1_params = { .fcc = { Loading @@ -40,15 +41,15 @@ static struct smb_params v1_params = { .fv = { .name = "float voltage", .reg = FLOAT_VOLTAGE_CFG_REG, .min_u = 3487500, .max_u = 4920000, .step_u = 7500, .min_u = 2500000, .max_u = 5000000, .step_u = 10000, }, .usb_icl = { .name = "usb input current limit", .reg = USBIN_CURRENT_LIMIT_CFG_REG, .min_u = 0, .max_u = 4800000, .max_u = 6000000, .step_u = 25000, }, .icl_stat = { Loading @@ -62,6 +63,48 @@ static struct smb_params v1_params = { .name = "dc input current limit", .reg = DCIN_CURRENT_LIMIT_CFG_REG, .min_u = 0, .max_u = 6000000, .step_u = 25000, }, .dc_icl_pt_lv = { .name = "dc icl PT <8V", .reg = ZIN_ICL_PT_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_pt_hv = { .name = "dc icl PT >8V", .reg = ZIN_ICL_PT_HV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_lv = { .name = "dc icl div2 <5.5V", .reg = ZIN_ICL_LV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_mid_lv = { .name = "dc icl div2 5.5-6.5V", .reg = ZIN_ICL_MID_LV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_mid_hv = { .name = "dc icl div2 6.5-8.0V", .reg = ZIN_ICL_MID_HV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_hv = { .name = "dc icl div2 >8.0V", .reg = ZIN_ICL_HV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, Loading @@ -73,6 +116,7 @@ struct smb_dt_props { int usb_icl_ua; int dc_icl_ua; int fv_uv; int wipower_max_uw; }; struct smb2 { Loading Loading @@ -125,6 +169,11 @@ static int smb2_parse_dt(struct smb2 *chip) if (rc < 0) chip->dt.dc_icl_ua = SMB2_DEFAULT_ICL_UA; rc = of_property_read_u32(node, "qcom,wipower-max-uw", &chip->dt.wipower_max_uw); if (rc < 0) chip->dt.wipower_max_uw = SMB2_DEFAULT_WPWR_UW; return 0; } Loading Loading @@ -486,6 +535,57 @@ static int smb2_init_vconn_regulator(struct smb2 *chip) /*************************** * HARDWARE INITIALIZATION * ***************************/ static int smb2_config_wipower_input_power(struct smb2 *chip, int uw) { int rc; int ua; struct smb_charger *chg = &chip->chg; s64 nw = (s64)uw * 1000; ua = div_s64(nw, ZIN_ICL_PT_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_pt_lv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_pt_lv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_PT_HV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_pt_hv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_pt_hv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_LV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_lv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_lv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_MID_LV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_mid_lv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_mid_lv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_MID_HV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_mid_hv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_mid_hv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_HV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_hv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_hv rc = %d\n", rc); return rc; } return 0; } static int smb2_init_hw(struct smb2 *chip) { Loading Loading @@ -582,6 +682,13 @@ static int smb2_init_hw(struct smb2 *chip) return rc; } /* configure wipower watts */ rc = smb2_config_wipower_input_power(chip, chip->dt.wipower_max_uw); if (rc < 0) { dev_err(chg->dev, "Couldn't configure wipower rc=%d\n", rc); return rc; } return rc; } Loading drivers/power/qcom-charger/smb-lib.h +6 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,12 @@ struct smb_params { struct smb_chg_param usb_icl; struct smb_chg_param icl_stat; struct smb_chg_param dc_icl; struct smb_chg_param dc_icl_pt_lv; struct smb_chg_param dc_icl_pt_hv; struct smb_chg_param dc_icl_div2_lv; struct smb_chg_param dc_icl_div2_mid_lv; struct smb_chg_param dc_icl_div2_mid_hv; struct smb_chg_param dc_icl_div2_hv; }; struct parallel_params { Loading drivers/power/qcom-charger/smb-reg.h +9 −0 Original line number Diff line number Diff line Loading @@ -719,6 +719,15 @@ enum { #define ZIN_ICL_MID_HV_REG (DCIN_BASE + 0x98) #define ZIN_ICL_MID_HV_MASK GENMASK(7, 0) enum { ZIN_ICL_PT_MAX_MV = 8000, ZIN_ICL_PT_HV_MAX_MV = 9000, ZIN_ICL_LV_MAX_MV = 5500, ZIN_ICL_MID_LV_MAX_MV = 6500, ZIN_ICL_MID_HV_MAX_MV = 8000, ZIN_ICL_HV_MAX_MV = 11000, }; /* MISC Peripheral Registers */ #define REVISION1_REG (MISC_BASE + 0x00) #define DIG_MINOR_MASK GENMASK(7, 0) Loading Loading
Documentation/devicetree/bindings/power/qcom-charger/qpnp-smb2.txt +6 −2 Original line number Diff line number Diff line Loading @@ -50,6 +50,12 @@ Charger specific properties: Value type: <u32> Definition: Specifies the DC input current limit in micro-amps. - qcom,wipower-max-uw Usage: optional Value type: <u32> Definition: Specifies the DC input power limit in micro-watts. If the value is not present, 8W is used as default. ============================================= Second Level Nodes - SMB2 Charger Peripherals ============================================= Loading Loading @@ -80,9 +86,7 @@ pmicobalt_charger: qcom,qpnp-smb2 { #address-cells = <1>; #size-cells = <1>; qcom,pmic-revid = <&pmicobalt_revid>; qcom,suspend-input; qcom,disable-charging; dpdm-supply = <&qusb_phy0>; qcom,chgr@1000 { Loading
drivers/power/qcom-charger/qpnp-smb2.c +124 −17 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #define SMB2_DEFAULT_FCC_UA 3000000 #define SMB2_DEFAULT_FV_UV 4350000 #define SMB2_DEFAULT_ICL_UA 3000000 #define SMB2_DEFAULT_WPWR_UW 8000000 static struct smb_params v1_params = { .fcc = { Loading @@ -40,15 +41,15 @@ static struct smb_params v1_params = { .fv = { .name = "float voltage", .reg = FLOAT_VOLTAGE_CFG_REG, .min_u = 3487500, .max_u = 4920000, .step_u = 7500, .min_u = 2500000, .max_u = 5000000, .step_u = 10000, }, .usb_icl = { .name = "usb input current limit", .reg = USBIN_CURRENT_LIMIT_CFG_REG, .min_u = 0, .max_u = 4800000, .max_u = 6000000, .step_u = 25000, }, .icl_stat = { Loading @@ -62,6 +63,48 @@ static struct smb_params v1_params = { .name = "dc input current limit", .reg = DCIN_CURRENT_LIMIT_CFG_REG, .min_u = 0, .max_u = 6000000, .step_u = 25000, }, .dc_icl_pt_lv = { .name = "dc icl PT <8V", .reg = ZIN_ICL_PT_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_pt_hv = { .name = "dc icl PT >8V", .reg = ZIN_ICL_PT_HV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_lv = { .name = "dc icl div2 <5.5V", .reg = ZIN_ICL_LV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_mid_lv = { .name = "dc icl div2 5.5-6.5V", .reg = ZIN_ICL_MID_LV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_mid_hv = { .name = "dc icl div2 6.5-8.0V", .reg = ZIN_ICL_MID_HV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, .dc_icl_div2_hv = { .name = "dc icl div2 >8.0V", .reg = ZIN_ICL_HV_REG, .min_u = 0, .max_u = 3000000, .step_u = 25000, }, Loading @@ -73,6 +116,7 @@ struct smb_dt_props { int usb_icl_ua; int dc_icl_ua; int fv_uv; int wipower_max_uw; }; struct smb2 { Loading Loading @@ -125,6 +169,11 @@ static int smb2_parse_dt(struct smb2 *chip) if (rc < 0) chip->dt.dc_icl_ua = SMB2_DEFAULT_ICL_UA; rc = of_property_read_u32(node, "qcom,wipower-max-uw", &chip->dt.wipower_max_uw); if (rc < 0) chip->dt.wipower_max_uw = SMB2_DEFAULT_WPWR_UW; return 0; } Loading Loading @@ -486,6 +535,57 @@ static int smb2_init_vconn_regulator(struct smb2 *chip) /*************************** * HARDWARE INITIALIZATION * ***************************/ static int smb2_config_wipower_input_power(struct smb2 *chip, int uw) { int rc; int ua; struct smb_charger *chg = &chip->chg; s64 nw = (s64)uw * 1000; ua = div_s64(nw, ZIN_ICL_PT_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_pt_lv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_pt_lv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_PT_HV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_pt_hv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_pt_hv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_LV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_lv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_lv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_MID_LV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_mid_lv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_mid_lv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_MID_HV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_mid_hv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_mid_hv rc = %d\n", rc); return rc; } ua = div_s64(nw, ZIN_ICL_HV_MAX_MV); rc = smblib_set_charge_param(chg, &chg->param.dc_icl_div2_hv, ua); if (rc < 0) { pr_err("Couldn't configure dc_icl_div2_hv rc = %d\n", rc); return rc; } return 0; } static int smb2_init_hw(struct smb2 *chip) { Loading Loading @@ -582,6 +682,13 @@ static int smb2_init_hw(struct smb2 *chip) return rc; } /* configure wipower watts */ rc = smb2_config_wipower_input_power(chip, chip->dt.wipower_max_uw); if (rc < 0) { dev_err(chg->dev, "Couldn't configure wipower rc=%d\n", rc); return rc; } return rc; } Loading
drivers/power/qcom-charger/smb-lib.h +6 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,12 @@ struct smb_params { struct smb_chg_param usb_icl; struct smb_chg_param icl_stat; struct smb_chg_param dc_icl; struct smb_chg_param dc_icl_pt_lv; struct smb_chg_param dc_icl_pt_hv; struct smb_chg_param dc_icl_div2_lv; struct smb_chg_param dc_icl_div2_mid_lv; struct smb_chg_param dc_icl_div2_mid_hv; struct smb_chg_param dc_icl_div2_hv; }; struct parallel_params { Loading
drivers/power/qcom-charger/smb-reg.h +9 −0 Original line number Diff line number Diff line Loading @@ -719,6 +719,15 @@ enum { #define ZIN_ICL_MID_HV_REG (DCIN_BASE + 0x98) #define ZIN_ICL_MID_HV_MASK GENMASK(7, 0) enum { ZIN_ICL_PT_MAX_MV = 8000, ZIN_ICL_PT_HV_MAX_MV = 9000, ZIN_ICL_LV_MAX_MV = 5500, ZIN_ICL_MID_LV_MAX_MV = 6500, ZIN_ICL_MID_HV_MAX_MV = 8000, ZIN_ICL_HV_MAX_MV = 11000, }; /* MISC Peripheral Registers */ #define REVISION1_REG (MISC_BASE + 0x00) #define DIG_MINOR_MASK GENMASK(7, 0) Loading