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

2020-08-25 Thread Pavel Machek
Hi!

> > > > If we ported the full driver, we would break the existing driver
> > > > structure because we would introduce more Qualcomm code. I think
> > > > that's an unreasonable change.
> > >
> > > That doesn't make much sense.  You have a working driver for these apis,
> > > just submit it for inclusion, it should never break any existing
> > > drivers, otherwise your code wouldn't work either.
> > 
> > We're an Android device, we're working on a Qualcomm based code, and
> > from the current code tree, the current code tree is missing the QTI
> > Charger code
> 
> I don't know what that means, sorry.  Just submit your driver, and any
> needed dependencies as well.  There's no other way to evaluate this api
> addition without that, right?

Actually, there's a way to evaluate the API without the driver... if the API
is pretty obviously unacceptable.

Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


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

2020-08-24 Thread Qiwu Huang
On Mon, Aug 24, 2020 at 3:43 PM Greg KH  wrote:
>
> On Mon, Aug 24, 2020 at 08:54:56AM +0800, Qiwu Huang wrote:
> > On Tue, Aug 18, 2020 at 2:07 PM Greg KH  wrote:
> > >
> > > On Tue, Aug 18, 2020 at 09:56:28AM +0800, Qiwu Huang wrote:
> > > > On Fri, Aug 14, 2020 at 2:09 PM Greg KH  
> > > > wrote:
> > > > >
> > > > > On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> > > > > > From: Qiwu Huang 
> > > > > >
> > > > > > Reports the kind of quick charge type based on
> > > > > > different adapter power.
> > > > > >
> > > > > > Signed-off-by: Qiwu Huang 
> > > > > > ---
> > > > > >  Documentation/ABI/testing/sysfs-class-power | 21 +
> > > > > >  drivers/power/supply/power_supply_sysfs.c   |  1 +
> > > > > >  drivers/power/supply/qcom_smbb.c| 51 
> > > > > > +
> > > > > >  include/linux/power_supply.h| 14 ++
> > > > > >  4 files changed, 87 insertions(+)
> > > > >
> > > > > You should also submit your driver that uses these new attributes at 
> > > > > the
> > > > > same time.  What happened to that request?  Otherwise no one really
> > > > > knows how these are being used, or if they even are used by anyone.
> > > > >
> > > >
> > > > I don't think I can submit the whole driver because our drivers are
> > > > divided into three parts, the first part is in ADSP, the second part
> > > > is in kernel and the third part is in Android Hal.This is the second
> > > > part.
> > >
> > > WHat is "ADSP"?
> >
> > ADSP: advanced digital signal processor
>
> Ok, then just send the kernel driver.
>
> > > Just submit your kernel driver code, that's all we care about here.
> > > Userspace code is not anything we can do anything with :)
> >
> > If we ported the full driver, we would break the existing driver
> > structure because we would introduce more Qualcomm code. I think
> > that's an unreasonable change.
>
> That doesn't make much sense.  You have a working driver for these apis,
> just submit it for inclusion, it should never break any existing
> drivers, otherwise your code wouldn't work either.

We're an Android device, we're working on a Qualcomm based code, and
from the current code tree, the current code tree is missing the QTI
Charger code

>
> thanks,
>
> greg k-h



-- 
Thanks

Qiwu


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

2020-08-24 Thread Greg KH
On Mon, Aug 24, 2020 at 04:42:06PM +0800, Qiwu Huang wrote:
> On Mon, Aug 24, 2020 at 3:43 PM Greg KH  wrote:
> >
> > On Mon, Aug 24, 2020 at 08:54:56AM +0800, Qiwu Huang wrote:
> > > On Tue, Aug 18, 2020 at 2:07 PM Greg KH  
> > > wrote:
> > > >
> > > > On Tue, Aug 18, 2020 at 09:56:28AM +0800, Qiwu Huang wrote:
> > > > > On Fri, Aug 14, 2020 at 2:09 PM Greg KH  
> > > > > wrote:
> > > > > >
> > > > > > On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> > > > > > > From: Qiwu Huang 
> > > > > > >
> > > > > > > Reports the kind of quick charge type based on
> > > > > > > different adapter power.
> > > > > > >
> > > > > > > Signed-off-by: Qiwu Huang 
> > > > > > > ---
> > > > > > >  Documentation/ABI/testing/sysfs-class-power | 21 +
> > > > > > >  drivers/power/supply/power_supply_sysfs.c   |  1 +
> > > > > > >  drivers/power/supply/qcom_smbb.c| 51 
> > > > > > > +
> > > > > > >  include/linux/power_supply.h| 14 ++
> > > > > > >  4 files changed, 87 insertions(+)
> > > > > >
> > > > > > You should also submit your driver that uses these new attributes 
> > > > > > at the
> > > > > > same time.  What happened to that request?  Otherwise no one really
> > > > > > knows how these are being used, or if they even are used by anyone.
> > > > > >
> > > > >
> > > > > I don't think I can submit the whole driver because our drivers are
> > > > > divided into three parts, the first part is in ADSP, the second part
> > > > > is in kernel and the third part is in Android Hal.This is the second
> > > > > part.
> > > >
> > > > WHat is "ADSP"?
> > >
> > > ADSP: advanced digital signal processor
> >
> > Ok, then just send the kernel driver.
> >
> > > > Just submit your kernel driver code, that's all we care about here.
> > > > Userspace code is not anything we can do anything with :)
> > >
> > > If we ported the full driver, we would break the existing driver
> > > structure because we would introduce more Qualcomm code. I think
> > > that's an unreasonable change.
> >
> > That doesn't make much sense.  You have a working driver for these apis,
> > just submit it for inclusion, it should never break any existing
> > drivers, otherwise your code wouldn't work either.
> 
> We're an Android device, we're working on a Qualcomm based code, and
> from the current code tree, the current code tree is missing the QTI
> Charger code

I don't know what that means, sorry.  Just submit your driver, and any
needed dependencies as well.  There's no other way to evaluate this api
addition without that, right?

thanks,

greg k-h


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

2020-08-24 Thread Greg KH
On Mon, Aug 24, 2020 at 08:54:56AM +0800, Qiwu Huang wrote:
> On Tue, Aug 18, 2020 at 2:07 PM Greg KH  wrote:
> >
> > On Tue, Aug 18, 2020 at 09:56:28AM +0800, Qiwu Huang wrote:
> > > On Fri, Aug 14, 2020 at 2:09 PM Greg KH  
> > > wrote:
> > > >
> > > > On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> > > > > From: Qiwu Huang 
> > > > >
> > > > > Reports the kind of quick charge type based on
> > > > > different adapter power.
> > > > >
> > > > > Signed-off-by: Qiwu Huang 
> > > > > ---
> > > > >  Documentation/ABI/testing/sysfs-class-power | 21 +
> > > > >  drivers/power/supply/power_supply_sysfs.c   |  1 +
> > > > >  drivers/power/supply/qcom_smbb.c| 51 
> > > > > +
> > > > >  include/linux/power_supply.h| 14 ++
> > > > >  4 files changed, 87 insertions(+)
> > > >
> > > > You should also submit your driver that uses these new attributes at the
> > > > same time.  What happened to that request?  Otherwise no one really
> > > > knows how these are being used, or if they even are used by anyone.
> > > >
> > >
> > > I don't think I can submit the whole driver because our drivers are
> > > divided into three parts, the first part is in ADSP, the second part
> > > is in kernel and the third part is in Android Hal.This is the second
> > > part.
> >
> > WHat is "ADSP"?
> 
> ADSP: advanced digital signal processor

Ok, then just send the kernel driver.

> > Just submit your kernel driver code, that's all we care about here.
> > Userspace code is not anything we can do anything with :)
> 
> If we ported the full driver, we would break the existing driver
> structure because we would introduce more Qualcomm code. I think
> that's an unreasonable change.

That doesn't make much sense.  You have a working driver for these apis,
just submit it for inclusion, it should never break any existing
drivers, otherwise your code wouldn't work either.

thanks,

greg k-h


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

2020-08-23 Thread Qiwu Huang
On Tue, Aug 18, 2020 at 2:07 PM Greg KH  wrote:
>
> On Tue, Aug 18, 2020 at 09:56:28AM +0800, Qiwu Huang wrote:
> > On Fri, Aug 14, 2020 at 2:09 PM Greg KH  wrote:
> > >
> > > On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> > > > From: Qiwu Huang 
> > > >
> > > > Reports the kind of quick charge type based on
> > > > different adapter power.
> > > >
> > > > Signed-off-by: Qiwu Huang 
> > > > ---
> > > >  Documentation/ABI/testing/sysfs-class-power | 21 +
> > > >  drivers/power/supply/power_supply_sysfs.c   |  1 +
> > > >  drivers/power/supply/qcom_smbb.c| 51 +
> > > >  include/linux/power_supply.h| 14 ++
> > > >  4 files changed, 87 insertions(+)
> > >
> > > You should also submit your driver that uses these new attributes at the
> > > same time.  What happened to that request?  Otherwise no one really
> > > knows how these are being used, or if they even are used by anyone.
> > >
> >
> > I don't think I can submit the whole driver because our drivers are
> > divided into three parts, the first part is in ADSP, the second part
> > is in kernel and the third part is in Android Hal.This is the second
> > part.
>
> WHat is "ADSP"?

ADSP: advanced digital signal processor

>
> Just submit your kernel driver code, that's all we care about here.
> Userspace code is not anything we can do anything with :)

If we ported the full driver, we would break the existing driver
structure because we would introduce more Qualcomm code. I think
that's an unreasonable change.

>
> thanks,
>
> greg k-h



-- 
Thanks

Qiwu


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

2020-08-18 Thread Greg KH
On Tue, Aug 18, 2020 at 09:56:28AM +0800, Qiwu Huang wrote:
> On Fri, Aug 14, 2020 at 2:09 PM Greg KH  wrote:
> >
> > On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> > > From: Qiwu Huang 
> > >
> > > Reports the kind of quick charge type based on
> > > different adapter power.
> > >
> > > Signed-off-by: Qiwu Huang 
> > > ---
> > >  Documentation/ABI/testing/sysfs-class-power | 21 +
> > >  drivers/power/supply/power_supply_sysfs.c   |  1 +
> > >  drivers/power/supply/qcom_smbb.c| 51 +
> > >  include/linux/power_supply.h| 14 ++
> > >  4 files changed, 87 insertions(+)
> >
> > You should also submit your driver that uses these new attributes at the
> > same time.  What happened to that request?  Otherwise no one really
> > knows how these are being used, or if they even are used by anyone.
> >
> 
> I don't think I can submit the whole driver because our drivers are
> divided into three parts, the first part is in ADSP, the second part
> is in kernel and the third part is in Android Hal.This is the second
> part.

WHat is "ADSP"?

Just submit your kernel driver code, that's all we care about here.
Userspace code is not anything we can do anything with :)

thanks,

greg k-h


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

2020-08-17 Thread Qiwu Huang
On Fri, Aug 14, 2020 at 2:09 PM Greg KH  wrote:
>
> On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> > From: Qiwu Huang 
> >
> > Reports the kind of quick charge type based on
> > different adapter power.
> >
> > Signed-off-by: Qiwu Huang 
> > ---
> >  Documentation/ABI/testing/sysfs-class-power | 21 +
> >  drivers/power/supply/power_supply_sysfs.c   |  1 +
> >  drivers/power/supply/qcom_smbb.c| 51 +
> >  include/linux/power_supply.h| 14 ++
> >  4 files changed, 87 insertions(+)
>
> You should also submit your driver that uses these new attributes at the
> same time.  What happened to that request?  Otherwise no one really
> knows how these are being used, or if they even are used by anyone.
>

I don't think I can submit the whole driver because our drivers are
divided into three parts, the first part is in ADSP, the second part
is in kernel and the third part is in Android Hal.This is the second
part.


> thanks,
>
> greg k-h



-- 
Thanks

Qiwu


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

2020-08-14 Thread Greg KH
On Fri, Aug 14, 2020 at 11:46:54AM +0800, Qiwu Huang wrote:
> From: Qiwu Huang 
> 
> Reports the kind of quick charge type based on
> different adapter power.
> 
> Signed-off-by: Qiwu Huang 
> ---
>  Documentation/ABI/testing/sysfs-class-power | 21 +
>  drivers/power/supply/power_supply_sysfs.c   |  1 +
>  drivers/power/supply/qcom_smbb.c| 51 +
>  include/linux/power_supply.h| 14 ++
>  4 files changed, 87 insertions(+)

You should also submit your driver that uses these new attributes at the
same time.  What happened to that request?  Otherwise no one really
knows how these are being used, or if they even are used by anyone.

thanks,

greg k-h


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

2020-08-13 Thread Qiwu Huang
From: Qiwu Huang 

Reports the kind of quick charge type based on
different adapter power.

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 21 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 drivers/power/supply/qcom_smbb.c| 51 +
 include/linux/power_supply.h| 14 ++
 4 files changed, 87 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 216d61a22f1e..dd3773dcf16a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -708,3 +708,24 @@ Description:
 
Access: Read
Valid values: 1-31
+
+What:  /sys/class/power_supply//quick_charge_type
+Date:  Jul 2020
+Contact:   Fei Jiang 
+   Description:
+   Reports the kind of quick charge type based on different 
adapter power.
+   Different quick charge type represent different charging power.
+   QUICK_CHARGE_NORMAL : Charging Power <= 10W
+   QUICK_CHARGE_FAST : 10W < Charging Power <= 20W
+   QUICK_CHARGE_FLASH : 20W < Charging Power <= 30W
+   QUICK_CHARGE_TURBE : 30W < Charging Power <= 50W
+   QUICK_CHARGE_SUPER : Charging Power > 50W
+
+   Access: Read-Only
+   Valid values:
+   0: QUICK_CHARGE_NORMAL,
+   1: QUICK_CHARGE_FAST,
+   2: QUICK_CHARGE_FLASH,
+   3: QUICK_CHARGE_TURBE,
+   4: QUICK_CHARGE_SUPER.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index bc79560229b5..9554d7907373 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -206,6 +206,7 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(MODEL_NAME),
POWER_SUPPLY_ATTR(MANUFACTURER),
POWER_SUPPLY_ATTR(SERIAL_NUMBER),
+   POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE),
 };
 
 static struct attribute *
diff --git a/drivers/power/supply/qcom_smbb.c b/drivers/power/supply/qcom_smbb.c
index c890e1cec720..afd38cf38832 100644
--- a/drivers/power/supply/qcom_smbb.c
+++ b/drivers/power/supply/qcom_smbb.c
@@ -485,6 +485,53 @@ static const struct smbb_irq {
{ "dc-valid", smbb_dc_valid_handler },
 };
 
+struct quick_charge {
+   enum power_supply_type adap_type;
+   enum power_supply_quick_charge_type adap_cap;
+};
+
+static 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_USB_HVDCP_3P5,  QUICK_CHARGE_FAST },
+   {0, 0},
+};
+
+static int get_quick_charge_type(struct smbb_charger *chg)
+{
+   union power_supply_propval prop = {0, };
+   int charger_type, rc;
+   int i = 0;
+
+   rc = power_supply_get_property(chg->bat_psy,
+   POWER_SUPPLY_PROP_STATUS, );
+   if (rc < 0)
+   return rc;
+   if (prop.intval == POWER_SUPPLY_STATUS_DISCHARGING)
+   return 0;
+
+   rc = power_supply_get_property(chg->usb_psy,
+   POWER_SUPPLY_PROP_USB_TYPE, );
+   if (rc < 0)
+   return rc;
+   charger_type = prop.intval;
+
+   while (adapter_cap[i].adap_type != 0) {
+   if (charger_type == adapter_cap[i].adap_type) {
+   return adapter_cap[i].adap_cap;
+   }
+   i++;
+   }
+
+   return 0;
+}
+
 static int smbb_usbin_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
@@ -505,6 +552,9 @@ static int smbb_usbin_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
val->intval = 250;
break;
+   case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
+   val->intval = get_quick_charge_type(chg);
+   break;
default:
rc = -EINVAL;
break;
@@ -695,6 +745,7 @@ static enum power_supply_property smbb_charger_properties[] 
= {
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
+   POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
 };
 
 static enum