Re: [PATCH v4 1/4] power: supply: core: add quick charge type property

ivan
2020-08-04T02:11:34Z

On Mon, Aug 3, 2020 at 7:57 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Aug 03, 2020 at 01:49:50PM +0200, Sebastian Reichel wrote:
> > More importantely I prefer not to merge new APIs without any users
> > (i.e. a driver making use of those values). Having a reference
> > driver means, that there is an example how to use the values
> > correctly and proves it is actually needed upstream. Right now
> > this looks like "let's modify the upstream kernel, so that we can
> > easily maintain our out of tree driver".
>
> Agreed. Qiwu, can you also submit your driver so we can see these
> values be used?

Our driver is based on qualcomm's driver secondary development.

The driver code is for mi 10.

https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/umi-q-oss/drivers/power/supply/qcom/qpnp-smb5.c#L1434

+ case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
+ val->intval = smblib_get_quick_charge_type(chg);
+ break;

https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/umi-q-oss/drivers/power/supply/qcom/smb5-lib.c#L7713

+struct quick_charge adapter_cap[10] = {
+ { POWER_SUPPLY_TYPE_USB, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_DCP, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_CDP, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_ACA, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_FLOAT, QUICK_CHARGE_NORMAL },
+ { POWER_SUPPLY_TYPE_USB_PD, QUICK_CHARGE_FAST },
+ { POWER_SUPPLY_TYPE_USB_HVDCP, QUICK_CHARGE_FAST },
+ { POWER_SUPPLY_TYPE_USB_HVDCP_3, QUICK_CHARGE_FAST },
+ { POWER_SUPPLY_TYPE_WIRELESS, QUICK_CHARGE_FAST },
+ {0, 0},
+};
+
+int smblib_get_quick_charge_type(struct smb_charger *chg)
+{
+ int i = 0, rc;
+ union power_supply_propval pval = {0, };
+
+ if (!chg) {
+ dev_err(chg->dev, "get quick charge type faied\n");
+ return -EINVAL;
+ }
+
+ rc = smblib_get_prop_batt_health(chg, &pval);
+ if (rc < 0)
+ smblib_err(chg, "Couldn't get batt health rc=%d\n", rc);
+
+ if ((pval.intval == POWER_SUPPLY_HEALTH_COLD) || (pval.intval
== POWER_SUPPLY_HEALTH_HOT))
+ return 0;
+
+ if ((chg->real_charger_type == POWER_SUPPLY_TYPE_USB_PD) &&
chg->pd_verifed) {
+ return QUICK_CHARGE_TURBE;
+ }
+
+ if (chg->is_qc_class_b)
+ return QUICK_CHARGE_FLASH;
+
+ if ((chg->real_charger_type == POWER_SUPPLY_TYPE_USB_DCP) &&
+ (chg->hvdcp_recheck_status ||
chg->fake_plug_out == true))
+ return QUICK_CHARGE_FLASH;
+
+ while (adapter_cap[i].adap_type != 0) {
+ if (chg->real_charger_type == adapter_cap[i].adap_type) {
+ return adapter_cap[i].adap_cap;
+ }
+ i++;
+ }
+
+ return 0;
+}

>
> thanks,
>
> greg k-h

--
Thanks

Qiwu