Linux-PM Archive on lore.kernel.org
 help / color / Atom feed
From: ivan <yanziily@gmail.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Sebastian Reichel <sre@kernel.org>, Pavel Machek <pavel@denx.de>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	jiangfei1@xiaomi.com, Qiwu Huang <huangqiwu@xiaomi.com>
Subject: Re: [PATCH v4 1/4] power: supply: core: add quick charge type property
Date: Tue, 4 Aug 2020 10:11:19 +0800
Message-ID: <CAPtXDt1hMrgJ_9Zs6Zmkzf4b1-QfEcZPp7dKG26G6ZEqBxCgBw@mail.gmail.com> (raw)
In-Reply-To: <20200803115644.GC955269@kroah.com>

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

  reply index

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20  5:47 [PATCH v4 0/4] add some power supply properties about wireless/wired charging Qiwu Huang
2020-07-20  5:47 ` [PATCH v4 1/4] power: supply: core: add quick charge type property Qiwu Huang
2020-08-02 12:00   ` Pavel Machek
2020-08-02 12:37     ` Greg KH
2020-08-02 14:28       ` Pavel Machek
2020-08-02 16:57         ` Greg KH
2020-08-03 11:49           ` Sebastian Reichel
2020-08-03 11:56             ` Greg KH
2020-08-04  2:11               ` ivan [this message]
2020-08-04  7:49                 ` Greg KH
2020-07-20  5:47 ` [PATCH v4 2/4] power: supply: core: add wireless charger adapter " Qiwu Huang
2020-07-20  5:47 ` [PATCH v4 3/4] power: supply: core: add wireless signal strength property Qiwu Huang
2020-07-20  5:47 ` [PATCH v4 4/4] power: supply: core: property to control reverse charge Qiwu Huang
2020-07-20  8:21 ` [PATCH v4 0/4] add some power supply properties about wireless/wired charging Greg KH
2020-07-21  3:12   ` ivan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAPtXDt1hMrgJ_9Zs6Zmkzf4b1-QfEcZPp7dKG26G6ZEqBxCgBw@mail.gmail.com \
    --to=yanziily@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=huangqiwu@xiaomi.com \
    --cc=jiangfei1@xiaomi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@denx.de \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-PM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pm/0 linux-pm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pm linux-pm/ https://lore.kernel.org/linux-pm \
		linux-pm@vger.kernel.org
	public-inbox-index linux-pm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git