Skip to contentSkip to conversation

add some power supply properties about wireless/wired charging

PATCH Superseded Qiwu Huang 5 participants 15 messages Jul 20, 2020 – Aug 4, 2020 Power supply

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Qiwu Huang

author
#0 lore raw

v4 cover add some power supply properties about wireless/wired charging

From: Qiwu Huang <[email protected]>

quick_charge_type reports quick charge type based on charging power. tx_adapter shows wireless charging adapter type.
signal_strength shows degree of coupling between tx and rx when wireless charging. reverse_chg_mode supply interface to enable/disable wireless reverse charging.

Qiwu Huang (4):
power: supply: core: add quick charge type property
power: supply: core: add wireless charger adapter type property
power: supply: core: add wireless signal strength property
power: supply: core: property to control reverse charge

 Documentation/ABI/testing/sysfs-class-power | 71 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  4 ++
 include/linux/power_supply.h                | 31 +++++++++
 3 files changed, 106 insertions(+)
Signature · 1 line
2.27.0
author
#1 lore raw

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

From: Qiwu Huang <[email protected]>

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

---
 Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 10 ++++++++++
 3 files changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-class-power +21 -0
index 216d61a22f1e..dd3773dcf16a 100644
@@ -708,3 +708,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+		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.
+
drivers/power/supply/power_supply_sysfs.c +1 -0
index bc79560229b5..9554d7907373 100644
@@ -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 *
include/linux/power_supply.h +10 -0
index ac1345a48ad0..f35c661a2544 100644
@@ -167,6 +167,7 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_MODEL_NAME,
 	POWER_SUPPLY_PROP_MANUFACTURER,
 	POWER_SUPPLY_PROP_SERIAL_NUMBER,
+	POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
 };
 
 enum power_supply_type {
@@ -197,6 +198,15 @@ enum power_supply_usb_type {
 	POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID,	/* Apple Charging Method */
 };
 
+enum power_supply_quick_charge_type {
+	QUICK_CHARGE_NORMAL = 0,		/* 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 */
+	QUICK_CHARGE_MAX,
+};
+
 enum power_supply_notifier_events {
 	PSY_EVENT_PROP_CHANGED,
 };
Signature · 1 line
2.27.0
#2 lore raw

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

Quoted 30 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

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

---
 Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 10 ++++++++++
 3 files changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-class-power +10 -0
index 216d61a22f1e..dd3773dcf16a 100644
@@ -708,3 +708,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+		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

Documentation/ABI/testing/sysfs-class-power Description: · line 730

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10 -0
+		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.

NAK.

Just expose value in watts or something... People are talking about > 100W charging, no need to go with fast/turbe/super/hyper/nonsense.

BTW fast charge is already "well defined", and what you call Normal is usually fast charge.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

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

Quoted 44 lines · Pavel Machek
Quoted 30 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

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

---
 Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 10 ++++++++++
 3 files changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-class-power +10 -0
index 216d61a22f1e..dd3773dcf16a 100644
@@ -708,3 +708,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+		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

Documentation/ABI/testing/sysfs-class-power Description: · line 730

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10 -0
+		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.

NAK.

Quoted 4 lines

Just expose value in watts or something... People are talking about > 100W charging, no need to go with fast/turbe/super/hyper/nonsense.

BTW fast charge is already "well defined", and what you call Normal is usually fast charge.

I think these names come from the Qi charging spec, right? So lets use what is given to us.

thanks,

greg k-h

#4 lore raw

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

Quoted 45 lines · Greg KH
Quoted 44 lines · Pavel Machek
Quoted 30 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

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

---
 Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 10 ++++++++++
 3 files changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-class-power +10 -0
index 216d61a22f1e..dd3773dcf16a 100644
@@ -708,3 +708,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+		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

Documentation/ABI/testing/sysfs-class-power Description: · line 730

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10 -0
+		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.

NAK.

Quoted 7 lines
Quoted 4 lines

Just expose value in watts or something... People are talking about > 100W charging, no need to go with fast/turbe/super/hyper/nonsense.

BTW fast charge is already "well defined", and what you call Normal is usually fast charge.

I think these names come from the Qi charging spec, right? So lets use what is given to us.

There are other standards, and this should better be generic.

Simply expose value in watts.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

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

Quoted 49 lines · Pavel Machek
Quoted 48 lines · Greg KH
Quoted 47 lines · Pavel Machek
Quoted 30 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

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

---
 Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 10 ++++++++++
 3 files changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-class-power +10 -0
index 216d61a22f1e..dd3773dcf16a 100644
@@ -708,3 +708,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+		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

Documentation/ABI/testing/sysfs-class-power Description: · line 730

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10 -0
+		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.

NAK.

Just expose value in watts or something... People are talking about > 100W charging, no need to go with fast/turbe/super/hyper/nonsense.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

BTW fast charge is already "well defined", and what you call Normal is usually fast charge.

I think these names come from the Qi charging spec, right? So lets use what is given to us.

There are other standards, and this should better be generic.

What standard? Why not go with this one, it's documented and out there and being used.

Quoted 1 line

Simply expose value in watts.

What if you do not know the watts, you just know these ranges.

thanks,

greg k-h

#6 lore raw

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

Hi,

Quoted 52 lines · Greg KH
Quoted 51 lines · Pavel Machek
Quoted 50 lines · Greg KH
Quoted 48 lines · Pavel Machek
Quoted 30 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

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

---
 Documentation/ABI/testing/sysfs-class-power | 21 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 10 ++++++++++
 3 files changed, 32 insertions(+)
Documentation/ABI/testing/sysfs-class-power +10 -0
index 216d61a22f1e..dd3773dcf16a 100644
@@ -708,3 +708,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+		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

Documentation/ABI/testing/sysfs-class-power Description: · line 730

Quoted 10 lines
Documentation/ABI/testing/sysfs-class-power +10 -0
+		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.

NAK.

Just expose value in watts or something... People are talking about > 100W charging, no need to go with fast/turbe/super/hyper/nonsense.

BTW fast charge is already "well defined", and what you call Normal is usually fast charge.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I think these names come from the Qi charging spec, right? So lets use what is given to us.

There are other standards, and this should better be generic.

What standard? Why not go with this one, it's documented and out there and being used.

Well there is Power Delivery from USB Standard, Quick Charge from Qualcomm, Super Charge from Huawei, Dash/Warp Charge from OnePlus, Pump Express from Mediatek and the Qi stuff for wireless charging. Possibly a few more, that I'm not aware of. Quickly charging devices is a huge mess :(

The naming suggests that this is for Qualcomm's "Quick Charge"?

Quoted 3 lines
Quoted 1 line

Simply expose value in watts.

What if you do not know the watts, you just know these ranges.

In general those chargers often do not know the exact watts/amps and that information can only be gained from the battery fuel gauge (which usually has a coulomb counter). Exposing the charger class means there is a way to debug problems, so it makes sense IMHO. But the classification is quite different between the vendor's proprietary quick charge algorithms, so we need to be careful with the naming. It should be clear which property should be used for given hardware.

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".

-- Sebastian

#7 lore raw

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

Quoted 6 lines · Sebastian Reichel

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?

thanks,

greg k-h

author
#8 lore raw

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

Quoted 11 lines · Greg KH
Quoted 6 lines · Sebastian Reichel

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;
+}

Quoted 4 lines

thanks,

greg k-h

Signature · 3 lines
Thanks

Qiwu
#9 lore raw

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

Quoted 23 lines · ivan
Quoted 11 lines · Greg KH
Quoted 6 lines · Sebastian Reichel

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:

(quoted diff) +2 -0
+     val->intval = smblib_get_quick_charge_type(chg);
+     break;
Quoted 1 line

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

<snip>

Great, can you submit these drivers as patches as part of this series? That's the best way for all of this to be integrated.

thanks,

greg k-h

author
#10 lore raw

PATCH v4 2/4 power: supply: core: add wireless charger adapter type property

In reply to Qiwu Huang

From: Qiwu Huang <[email protected]>

Reports what type of wireless adapter connection is currently active for the supply.
for example it can show if ADAPTER_PD capable source is attached.

---
 Documentation/ABI/testing/sysfs-class-power | 28 +++++++++++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                | 19 ++++++++++++++
 3 files changed, 48 insertions(+)
Documentation/ABI/testing/sysfs-class-power +28 -0
index dd3773dcf16a..03ab449fae8a 100644
@@ -729,3 +729,31 @@ Contact:	Fei Jiang <[email protected]>
 			3: QUICK_CHARGE_TURBE,
 			4: QUICK_CHARGE_SUPER.
 
+===== Wireless Charger Properties =====
+What:		/sys/class/power_supply/<supply_name>/tx_adapter
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+Description:
+		Reports the type of wireless adapter connection is currently active for
+		the supply, for example it can show if ADAPTER_PD capable source
+		is attached. Expect common wireless adapter type, also increase by
+		some vendor private adapter type(ex. ADAPTER_PD_40W).
+
+		Access: Read-Only
+		Valid values:
+			0: ADAPTER_NONE,
+			1: ADAPTER_SDP,
+			2: ADAPTER_DCP,
+			3: ADAPTER_CDP,
+			4: ADAPTER_OCP,
+			5: ADAPTER_QC2,
+			6: ADAPTER_QC3,
+			7: ADAPTER_PD,
+			8: ADAPTER_AUTH_FAILED,
+			9: ADAPTER_PRIVATE_QC3,
+			10: ADAPTER_PRIVATE_PD,
+			11: ADAPTER_CAR_POWER,
+			12: ADAPTER_PRIVATE_PD_40W,
+			13: ADAPTER_VOICE_BOX,
+			14: ADAPTER_PRIVATE_PD_50W.
+
drivers/power/supply/power_supply_sysfs.c +1 -0
index 9554d7907373..f2458e21d02b 100644
@@ -207,6 +207,7 @@ static struct power_supply_attr power_supply_attrs[] = {
 	POWER_SUPPLY_ATTR(MANUFACTURER),
 	POWER_SUPPLY_ATTR(SERIAL_NUMBER),
 	POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE),
+	POWER_SUPPLY_ATTR(TX_ADAPTER),
 };
 
 static struct attribute *
include/linux/power_supply.h +19 -0
index f35c661a2544..0bbdec1630a4 100644
@@ -168,6 +168,7 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_MANUFACTURER,
 	POWER_SUPPLY_PROP_SERIAL_NUMBER,
 	POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
+	POWER_SUPPLY_PROP_TX_ADAPTER,
 };
 
 enum power_supply_type {
@@ -207,6 +208,24 @@ enum power_supply_quick_charge_type {
 	QUICK_CHARGE_MAX,
 };
 
+enum power_supply_tx_adapter_type {
+	ADAPTER_NONE = 0,			/* Nothing Attached */
+	ADAPTER_SDP,				/* Standard Downstream Port */
+	ADAPTER_CDP,				/* Charging Downstream Port */
+	ADAPTER_DCP,				/* Dedicated Charging Port */
+	ADAPTER_OCP,				/* Other Charging Port */
+	ADAPTER_QC2,				/* Qualcomm Charge 2.0 */
+	ADAPTER_QC3,				/* Qualcomm Charge 3.0 */
+	ADAPTER_PD,				/* Power Delivery Port */
+	ADAPTER_AUTH_FAILED,			/* Authenticated Failed Adapter */
+	ADAPTER_PRIVATE_QC3,			/* Qualcomm Charge 3.0 with Private Protocol */
+	ADAPTER_PRIVATE_PD,			/* PD Adapter with Private Protocol */
+	ADAPTER_CAR_POWER,			/* Wireless Car Charger */
+	ADAPTER_PRIVATE_PD_40W,			/* 40W PD Adapter with Private Protocol */
+	ADAPTER_VOICE_BOX,			/* Voice Box which Support Wireless Charger */
+	ADAPTER_PRIVATE_PD_50W,			/* 50W PD Adapter with Private Protocol */
+};
+
 enum power_supply_notifier_events {
 	PSY_EVENT_PROP_CHANGED,
 };
Signature · 1 line
2.27.0
author
#11 lore raw

PATCH v4 3/4 power: supply: core: add wireless signal strength property

In reply to Qiwu Huang

From: Qiwu Huang <[email protected]>

reports wireless signal strength.
The value show degree of coupling between tx and rx.

---
 Documentation/ABI/testing/sysfs-class-power | 10 ++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                |  1 +
 3 files changed, 12 insertions(+)
Documentation/ABI/testing/sysfs-class-power +10 -0
index 03ab449fae8a..75ec7de2fe78 100644
@@ -757,3 +757,13 @@ Description:
 			13: ADAPTER_VOICE_BOX,
 			14: ADAPTER_PRIVATE_PD_50W.
 
+What:		/sys/class/power_supply/<supply_name>/signal_strength
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+Description:
+		In PING phase, RX transmits a signal strength packet as the first
+		communication packet to instruct the base to keep power signal on.
+		The value reports wireless signal strength and show degree of coupling.
+
+		Access: Read-Only
+		Valid values: 0 - 100
drivers/power/supply/power_supply_sysfs.c +1 -0
index f2458e21d02b..e420a453095e 100644
@@ -208,6 +208,7 @@ static struct power_supply_attr power_supply_attrs[] = {
 	POWER_SUPPLY_ATTR(SERIAL_NUMBER),
 	POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE),
 	POWER_SUPPLY_ATTR(TX_ADAPTER),
+	POWER_SUPPLY_ATTR(SIGNAL_STRENGTH),
 };
 
 static struct attribute *
include/linux/power_supply.h +1 -0
index 0bbdec1630a4..346c6c9c0737 100644
@@ -169,6 +169,7 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_SERIAL_NUMBER,
 	POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
 	POWER_SUPPLY_PROP_TX_ADAPTER,
+	POWER_SUPPLY_PROP_SIGNAL_STRENGTH,
 };
 
 enum power_supply_type {
Signature · 1 line
2.27.0
author
#12 lore raw

PATCH v4 4/4 power: supply: core: property to control reverse charge

In reply to Qiwu Huang

From: Qiwu Huang <[email protected]>

Interface to control wireless reverse charge.
Supply reverse charge function when enabled.

---
 Documentation/ABI/testing/sysfs-class-power | 12 ++++++++++++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h                |  1 +
 3 files changed, 14 insertions(+)
Documentation/ABI/testing/sysfs-class-power +12 -0
index 75ec7de2fe78..54647d6995d3 100644
@@ -767,3 +767,15 @@ Description:
 
 		Access: Read-Only
 		Valid values: 0 - 100
+
+What:		/sys/class/power_supply/<supply_name>/reverse_chg_mode
+Date:		Jul 2020
+Contact:	Fei Jiang <[email protected]>
+Description:
+		Some phones support wireless reverse charge function which charge other phones.
+		The property supply interface to control wireless reverse charge.
+		If enabled, start TX mode and detect RX. Disabled when timeout or manual setting.
+
+		Valid values:
+		- 1: enabled
+		- 0: disabled
drivers/power/supply/power_supply_sysfs.c +1 -0
index e420a453095e..81916b6b6ccf 100644
@@ -209,6 +209,7 @@ static struct power_supply_attr power_supply_attrs[] = {
 	POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE),
 	POWER_SUPPLY_ATTR(TX_ADAPTER),
 	POWER_SUPPLY_ATTR(SIGNAL_STRENGTH),
+	POWER_SUPPLY_ATTR(REVERSE_CHG_MODE),
 };
 
 static struct attribute *
include/linux/power_supply.h +1 -0
index 346c6c9c0737..a87ae1fff8d1 100644
@@ -170,6 +170,7 @@ enum power_supply_property {
 	POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
 	POWER_SUPPLY_PROP_TX_ADAPTER,
 	POWER_SUPPLY_PROP_SIGNAL_STRENGTH,
+	POWER_SUPPLY_PROP_REVERSE_CHG_MODE,
 };
 
 enum power_supply_type {
Signature · 1 line
2.27.0
#13 lore raw
In reply to Qiwu Huang
Quoted 7 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

quick_charge_type reports quick charge type based on charging power. tx_adapter shows wireless charging adapter type.
signal_strength shows degree of coupling between tx and rx when wireless charging. reverse_chg_mode supply interface to enable/disable wireless reverse charging.

Quoted 5 lines

Qiwu Huang (4):
power: supply: core: add quick charge type property
power: supply: core: add wireless charger adapter type property
power: supply: core: add wireless signal strength property
power: supply: core: property to control reverse charge

What changed from the previous versions of this series? Normally you either include that in the 0/X email, or in the individual patches. I don't see that in either place in this series :(

See the many examples of how this is done by looking at other patches on the mailing lists and in the submitting patches documentation.

thanks,

greg k-h

author
#14 lore raw
Quoted 15 lines · Greg KH <[email protected]> 于2020年7月20日周一 下午4:20写道:
Quoted 7 lines · Qiwu Huang

From: Qiwu Huang <[email protected]>

quick_charge_type reports quick charge type based on charging power. tx_adapter shows wireless charging adapter type.
signal_strength shows degree of coupling between tx and rx when wireless charging. reverse_chg_mode supply interface to enable/disable wireless reverse charging.

Quoted 5 lines

Qiwu Huang (4):
power: supply: core: add quick charge type property
power: supply: core: add wireless charger adapter type property
power: supply: core: add wireless signal strength property
power: supply: core: property to control reverse charge

Quoted 6 lines

What changed from the previous versions of this series? Normally you either include that in the 0/X email, or in the individual patches. I don't see that in either place in this series :(

See the many examples of how this is done by looking at other patches on the mailing lists and in the submitting patches documentation.

Sorry ,I will add it in new version

This patchset aims to provide power supply properties about wireless/wired charging.
“quick_charge_type” reports different types of quick charge based on
the charging power;
“tx_adapter” shows the type of wireless charging adapter;. “signal_strength” shows the coupling level between TX and RX;. “reverse_chg_mode” provides the interface of enabling/disabling
wireless reverse charging.

Changes in v5
- Add details in 0/X email

Changes in v4
- Exclude the patch of “power: supply: supply battery soc with decimal form”
- Fix some typo

Changes in v3
- Add enumederated for quick charge type
- Add enumederated for tx adapter type
- Update the return type and description in ABI

Changes in v2
- modify to capital letters for “power_supply_attrs”
- Update the return type and description in ABI

Qiwu Huang (4):
power: supply: core: add quick charge type property
power: supply: core: add wireless charger adapter type property
power: supply: core: add wireless signal strength property
power: supply: core: property to control reverse charge

  Documentation/ABI/testing/sysfs-class-power | 71 +++++++++++++++++++++
  drivers/power/supply/power_supply_sysfs.c   |  4 ++
  include/linux/power_supply.h                | 31 +++++++++
  3 files changed, 106 insertions(+)
Quoted 3 lines

thanks,

greg k-h

Signature · 3 lines
Thanks

Qiwu