[PATCH v10 3/4] power: supply: core: add wireless signal strength property

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

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 22 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 2850adbc8c58..c3a547037d07 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -758,3 +758,25 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
+   The Qi Wireless Power Transfer System is published by the
+   Wireless Power Consortium.The ping phase is the necessary stage
+   for matching transmitter and receiver. In this phase,the Power
+   Transmitter executes a Digital Ping, and listens for a response.
+   If the Power Transmitter discovers a Power Receiver, the Power
+   Transmitter may extend the Digital Ping,i.e. maintain the Power
+   Signal at the level of the Digital Ping. This causes the system
+   to proceed to the identification & configuration phase. If the
+   Power Transmitter does not extend the Digital Ping, the system
+   shall revert to the selection phase.
+
+   Access: Read-Only
+   Valid values: 0 - 100
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 76de6ae199d3..64e6bdd91edf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -212,6 +212,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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 4e161d8961c1..496d1faecdd1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -173,6 +173,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 {
-- 
2.28.0



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

2020-08-25 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| 81 -
 include/linux/power_supply.h| 14 
 4 files changed, 116 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 40213c73bc9c..a6ec1c45adee 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -709,3 +709,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 3d383086018c..67f568c88c0b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -210,6 +210,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..21ddfa39f655 100644
--- a/drivers/power/supply/qcom_smbb.c
+++ b/drivers/power/supply/qcom_smbb.c
@@ -90,6 +90,12 @@
 #define STATUS_CHG_FASTBIT(7) /* Fast charging */
 #define STATUS_CHG_GONEBIT(8) /* No charger is connected */
 
+#define IMAX_NORMAL200
+#define IMAX_FAST  400
+#define IMAX_FLASH 600
+#define IMAX_TURBE 1000
+#define IMAX_SUPER 1200
+
 enum smbb_attr {
ATTR_BAT_ISAFE,
ATTR_BAT_IMAX,
@@ -111,6 +117,7 @@ struct smbb_charger {
 
bool dc_disabled;
bool jeita_ext_temp;
+   bool pd_verifed;
unsigned long status;
struct mutex statlock;
 
@@ -485,6 +492,58 @@ 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;
+
+   /* when pd adapter is authenticated successfully */
+   if ((charger_type == POWER_SUPPLY_TYPE_USB_PD) && chg->pd_verifed) {
+   return QUICK_CHARGE_TURBE;
+   }
+
+   while (adapter_cap[i].adap_type != 0) {
+   if (charger_type == adapter_cap[i].adap_type) {
+   return adapter_cap[i].adap_cap;
+   }
+ 

[PATCH v10 4/4] power: supply: core: property to control reverse charge

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

Interface to control wireless reverse charge.

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

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index c3a547037d07..e0adb22a6648 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -780,3 +780,17 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Some devices support wireless reverse charge function which
+   charge other devices.The property provider interface to
+   enable/disable wireless reverse charge.If enabled, start TX
+   mode and detect RX. Disabled when timeout or manual setting.
+
+   Access: Read, Write
+   Valid values:
+   - 1: enabled
+   - 0: disabled
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 64e6bdd91edf..403a1787fada 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -213,6 +213,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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 496d1faecdd1..ee156492c566 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -174,6 +174,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 {
-- 
2.28.0



[PATCH v10 0/4] add some power supply properties about wireless/wired charging

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

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 V10
 - Fix build error on linus/master v5.9-rc2 next-20200824 Reported-by: kernel 
test robot 
 - Fix build error on power-supply/for-next Reported-by: kernel test robot 


Changes in v9
 - Set bat_imax When get quick charger type

Changes in v8
 - Add quick charge type driver in qcom_smbb suggested by GregKH

Changes in v7
 - Fix PATCH version error in 0/X email

Changes in v6
 - Replace "phones" with "devices" suggested by GregKH
 - Add permission statement for "reverse_chg_mode"
 - Update description for "reverse_chg_mode" in ABI suggested by GregKH
 - Update description for "PING phase" in ABI suggested by GregKH

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 | 85 +
 drivers/power/supply/power_supply_sysfs.c   |  4 +
 drivers/power/supply/qcom_smbb.c| 81 +++-
 include/linux/power_supply.h| 35 +
 4 files changed, 204 insertions(+), 1 deletion(-)


base-commit: 6a9dc5fd6170d0a41c8a14eb19e63d94bea5705a
-- 
2.28.0



[PATCH v10 2/4] power: supply: core: add wireless charger adapter type property

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

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index a6ec1c45adee..2850adbc8c58 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -730,3 +730,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 67f568c88c0b..76de6ae199d3 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -211,6 +211,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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 24b31b7e88a0..4e161d8961c1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -172,6 +172,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 {
@@ -215,6 +216,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,
 };
-- 
2.28.0



[PATCH v9 2/4] power: supply: core: add wireless charger adapter type property

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

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index bd99658c05be..00254e096a4a 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
@@ -211,6 +212,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,
 };
-- 
2.28.0



[PATCH v9 0/4] add some power supply properties about wireless/wired charging

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

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 v9
 - Set bat_imax When get quick charger type

Changes in v8
 - Add quick charge type driver in qcom_smbb suggested by GregKH

Changes in v7
 - Fix PATCH version error in 0/X email

Changes in v6
 - Replace "phones" with "devices" suggested by GregKH
 - Add permission statement for "reverse_chg_mode"
 - Update description for "reverse_chg_mode" in ABI suggested by GregKH
 - Update description for "PING phase" in ABI suggested by GregKH

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 | 85 +
 drivers/power/supply/power_supply_sysfs.c   |  4 +
 drivers/power/supply/qcom_smbb.c| 79 +++
 include/linux/power_supply.h| 35 +
 4 files changed, 203 insertions(+)

-- 
2.28.0



[PATCH v9 4/4] power: supply: core: property to control reverse charge

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

Interface to control wireless reverse charge.

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

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 4459b720feb2..8840fdf483a7 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -779,3 +779,17 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Some devices support wireless reverse charge function which
+   charge other devices.The property provider interface to
+   enable/disable wireless reverse charge.If enabled, start TX
+   mode and detect RX. Disabled when timeout or manual setting.
+
+   Access: Read, Write
+   Valid values:
+   - 1: enabled
+   - 0: disabled
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 747338118fa1..988d3f05ea1c 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.28.0



[PATCH v9 3/4] power: supply: core: add wireless signal strength property

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

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 22 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..4459b720feb2 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,25 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
+   The Qi Wireless Power Transfer System is published by the
+   Wireless Power Consortium.The ping phase is the necessary stage
+   for matching transmitter and receiver. In this phase,the Power
+   Transmitter executes a Digital Ping, and listens for a response.
+   If the Power Transmitter discovers a Power Receiver, the Power
+   Transmitter may extend the Digital Ping,i.e. maintain the Power
+   Signal at the level of the Digital Ping. This causes the system
+   to proceed to the identification & configuration phase. If the
+   Power Transmitter does not extend the Digital Ping, the system
+   shall revert to the selection phase.
+
+   Access: Read-Only
+   Valid values: 0 - 100
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 00254e096a4a..747338118fa1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.28.0



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

2020-08-25 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| 79 +
 include/linux/power_supply.h| 14 
 4 files changed, 115 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..7dbb385531ca 100644
--- a/drivers/power/supply/qcom_smbb.c
+++ b/drivers/power/supply/qcom_smbb.c
@@ -90,6 +90,12 @@
 #define STATUS_CHG_FASTBIT(7) /* Fast charging */
 #define STATUS_CHG_GONEBIT(8) /* No charger is connected */
 
+#define IMAX_NORMAL200
+#define IMAX_FAST  400
+#define IMAX_FLASH 600
+#define IMAX_TURBE 1000
+#define IMAX_SUPER 1200
+
 enum smbb_attr {
ATTR_BAT_ISAFE,
ATTR_BAT_IMAX,
@@ -111,6 +117,7 @@ struct smbb_charger {
 
bool dc_disabled;
bool jeita_ext_temp;
+   bool pd_verifed;
unsigned long status;
struct mutex statlock;
 
@@ -485,6 +492,58 @@ 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;
+
+   /* when pd adapter is authenticated successfully */
+   if ((charger_type == POWER_SUPPLY_TYPE_USB_PD) && chg->pd_verifed) {
+   return QUICK_CHARGE_TURBE;
+   }
+
+   while (adapter_cap[i].adap_type != 0) {
+   if (charger_type == adapter_cap[i].adap_type) {
+   return adapter_cap[i].adap_cap;
+   }
+   i++;
+   }
+
+

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


[PATCH v8 2/4] power: supply: core: add wireless charger adapter type property

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

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index bd99658c05be..00254e096a4a 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
@@ -211,6 +212,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,
 };
-- 
2.28.0



[PATCH v8 4/4] power: supply: core: property to control reverse charge

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

Interface to control wireless reverse charge.

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

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 4459b720feb2..8840fdf483a7 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -779,3 +779,17 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Some devices support wireless reverse charge function which
+   charge other devices.The property provider interface to
+   enable/disable wireless reverse charge.If enabled, start TX
+   mode and detect RX. Disabled when timeout or manual setting.
+
+   Access: Read, Write
+   Valid values:
+   - 1: enabled
+   - 0: disabled
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 747338118fa1..988d3f05ea1c 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.28.0



[PATCH v8 3/4] power: supply: core: add wireless signal strength property

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

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 22 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..4459b720feb2 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,25 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
+   The Qi Wireless Power Transfer System is published by the
+   Wireless Power Consortium.The ping phase is the necessary stage
+   for matching transmitter and receiver. In this phase,the Power
+   Transmitter executes a Digital Ping, and listens for a response.
+   If the Power Transmitter discovers a Power Receiver, the Power
+   Transmitter may extend the Digital Ping,i.e. maintain the Power
+   Signal at the level of the Digital Ping. This causes the system
+   to proceed to the identification & configuration phase. If the
+   Power Transmitter does not extend the Digital Ping, the system
+   shall revert to the selection phase.
+
+   Access: Read-Only
+   Valid values: 0 - 100
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 00254e096a4a..747338118fa1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.28.0



[PATCH v8 0/4] add some power supply properties about wireless/wired charging

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

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 v8
 - Add quick charge type driver in qcom_smbb suggested by GregKH

Changes in v7
 - Fix PATCH version error in 0/X email

Changes in v6
 - Replace "phones" with "devices" suggested by GregKH
 - Add permission statement for "reverse_chg_mode"
 - Update description for "reverse_chg_mode" in ABI suggested by GregKH
 - Update description for "PING phase" in ABI suggested by GregKH

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 | 85 +
 drivers/power/supply/power_supply_sysfs.c   |  4 +
 drivers/power/supply/qcom_smbb.c| 51 +
 include/linux/power_supply.h| 35 +
 4 files changed, 175 insertions(+)

-- 
2.28.0



[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,
+   POW

[PATCH v7 3/4] power: supply: core: add wireless signal strength property

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 22 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..4459b720feb2 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,25 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
+   The Qi Wireless Power Transfer System is published by the
+   Wireless Power Consortium.The ping phase is the necessary stage
+   for matching transmitter and receiver. In this phase,the Power
+   Transmitter executes a Digital Ping, and listens for a response.
+   If the Power Transmitter discovers a Power Receiver, the Power
+   Transmitter may extend the Digital Ping,i.e. maintain the Power
+   Signal at the level of the Digital Ping. This causes the system
+   to proceed to the identification & configuration phase. If the
+   Power Transmitter does not extend the Digital Ping, the system
+   shall revert to the selection phase.
+
+   Access: Read-Only
+   Valid values: 0 - 100
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0bbdec1630a4..346c6c9c0737 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v7 4/4] power: supply: core: property to control reverse charge

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

Interface to control wireless reverse charge.

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

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 4459b720feb2..8840fdf483a7 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -779,3 +779,17 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Some devices support wireless reverse charge function which
+   charge other devices.The property provider interface to
+   enable/disable wireless reverse charge.If enabled, start TX
+   mode and detect RX. Disabled when timeout or manual setting.
+
+   Access: Read, Write
+   Valid values:
+   - 1: enabled
+   - 0: disabled
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 346c6c9c0737..a87ae1fff8d1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v7 2/4] power: supply: core: add wireless charger adapter type property

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f35c661a2544..0bbdec1630a4 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v7 0/4] add some power supply properties about wireless/wired charging

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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 v7
 - Fix PATCH version error in 0/X email

Changes in v6
 - Replace "phones" with "devices" suggested by GregKH
 - Add permission statement for "reverse_chg_mode"
 - Update description for "reverse_chg_mode" in ABI suggested by GregKH
 - Update description for "PING phase" in ABI suggested by GregKH

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 | 85 +
 drivers/power/supply/power_supply_sysfs.c   |  4 +
 include/linux/power_supply.h| 31 
 3 files changed, 120 insertions(+)

-- 
2.27.0



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

2020-07-21 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 +
 include/linux/power_supply.h| 10 ++
 3 files changed, 32 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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..f35c661a2544 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



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

2020-07-21 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 +
 include/linux/power_supply.h| 10 ++
 3 files changed, 32 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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..f35c661a2544 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v6 2/4] power: supply: core: add wireless charger adapter type property

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f35c661a2544..0bbdec1630a4 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v6 4/4] power: supply: core: property to control reverse charge

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

Interface to control wireless reverse charge.

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

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 4459b720feb2..8840fdf483a7 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -779,3 +779,17 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Some devices support wireless reverse charge function which
+   charge other devices.The property provider interface to
+   enable/disable wireless reverse charge.If enabled, start TX
+   mode and detect RX. Disabled when timeout or manual setting.
+
+   Access: Read, Write
+   Valid values:
+   - 1: enabled
+   - 0: disabled
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 346c6c9c0737..a87ae1fff8d1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v6 3/4] power: supply: core: add wireless signal strength property

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 22 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..4459b720feb2 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,25 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
+   The Qi Wireless Power Transfer System is published by the
+   Wireless Power Consortium.The ping phase is the necessary stage
+   for matching transmitter and receiver. In this phase,the Power
+   Transmitter executes a Digital Ping, and listens for a response.
+   If the Power Transmitter discovers a Power Receiver, the Power
+   Transmitter may extend the Digital Ping,i.e. maintain the Power
+   Signal at the level of the Digital Ping. This causes the system
+   to proceed to the identification & configuration phase. If the
+   Power Transmitter does not extend the Digital Ping, the system
+   shall revert to the selection phase.
+
+   Access: Read-Only
+   Valid values: 0 - 100
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0bbdec1630a4..346c6c9c0737 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v5 0/4] add some power supply properties about wireless/wired charging

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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 v6
 - Replace "phones" with "devices" suggested by GregKH
 - Add permission statement for "reverse_chg_mode"
 - Update description for "reverse_chg_mode" in ABI suggested by GregKH
 - Update description for "PING phase" in ABI suggested by GregKH

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 | 85 +
 drivers/power/supply/power_supply_sysfs.c   |  4 +
 include/linux/power_supply.h| 31 
 3 files changed, 120 insertions(+)

-- 
2.27.0



[PATCH v5 4/4] power: supply: core: property to control reverse charge

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 75ec7de2fe78..54647d6995d3 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -767,3 +767,15 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 346c6c9c0737..a87ae1fff8d1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v5 2/4] power: supply: core: add wireless charger adapter type property

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f35c661a2544..0bbdec1630a4 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v5 3/4] power: supply: core: add wireless signal strength property

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..75ec7de2fe78 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,13 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0bbdec1630a4..346c6c9c0737 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v5 0/4] add some power supply properties about wireless/wired charging

2020-07-21 Thread Qiwu Huang
From: Qiwu Huang 

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(+)


-- 
2.27.0



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

2020-07-21 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 +
 include/linux/power_supply.h| 10 ++
 3 files changed, 32 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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..f35c661a2544 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



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

2020-07-19 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 75ec7de2fe78..54647d6995d3 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -767,3 +767,15 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 346c6c9c0737..a87ae1fff8d1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



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

2020-07-19 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 +
 include/linux/power_supply.h| 10 ++
 3 files changed, 32 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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..f35c661a2544 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



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

2020-07-19 Thread Qiwu Huang
From: Qiwu Huang 

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.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f35c661a2544..0bbdec1630a4 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v4 0/4] add some power supply properties about wireless/wired charging

2020-07-19 Thread Qiwu Huang
From: Qiwu Huang 

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(+)

-- 
2.27.0



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

2020-07-19 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..75ec7de2fe78 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,13 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0bbdec1630a4..346c6c9c0737 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v3 2/5] power: supply: core: add wireless charger adapter type property

2020-07-14 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index dd3773dcf16a..03ab449fae8a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,31 @@ Contact:   Fei Jiang 
3: QUICK_CHARGE_TURBE,
4: QUICK_CHARGE_SUPER.
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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.
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f35c661a2544..0bbdec1630a4 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v3 4/5] power: supply: core: property to control reverse charge

2020-07-14 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 75ec7de2fe78..54647d6995d3 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -767,3 +767,15 @@ Description:
 
Access: Read-Only
Valid values: 0 - 100
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 346c6c9c0737..a87ae1fff8d1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v3 5/5] power: supply: core: supply battery soc with decimal form

2020-07-14 Thread Qiwu Huang
From: Qiwu Huang 

Broadcast battery soc with decimal form.
soc_decimal is the decimal part of battery soc.
soc_decimal_rate is update frequency of decimal
part of battery soc.
We want to report such as 0.01 to 99.99% to
user space to improve user experience
when do very quick charging.

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 25 +
 drivers/power/supply/power_supply_sysfs.c   |  2 ++
 include/linux/power_supply.h|  2 ++
 3 files changed, 29 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 54647d6995d3..5e0bba3e1930 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -349,6 +349,31 @@ Description:
Access: Read
Valid values: Represented in microvolts
 
+What:  /sys/class/power_supply//soc_decimal,
+Date:  Jul 2020
+Contact:   jiangf...@xiaomi.com
+Description:
+   Broadcast battery soc with decimal form.Battery soc(0 - 100 
percent)
+   is fine grain representation of battery capacity.
+   soc_decimal is the start decimal part of battery soc.
+   For example, soc_decimal value is 30 for 80.30%.
+
+   Access: Read
+   Valid values: 0 - 99
+
+What:  /sys/class/power_supply//soc_decimal_rate,
+Date:  Jul 2020
+Contact:   jiangf...@xiaomi.com
+Description:
+   Broadcast battery soc with decimal form.Battery soc(0 - 100 
percent)
+   is fine grain representation of battery capacity.
+   soc_decimal_rate is update rate for decimal part of battery soc.
+   The value is depend on charging power. Soc decimal change faster
+   with larger charging power.
+
+   Access: Read
+   Valid values: 1 - 100
+
 = USB Properties =
 
 What:  /sys/class/power_supply//current_avg
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 81916b6b6ccf..a837addb4f21 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -210,6 +210,8 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(TX_ADAPTER),
POWER_SUPPLY_ATTR(SIGNAL_STRENGTH),
POWER_SUPPLY_ATTR(REVERSE_CHG_MODE),
+   POWER_SUPPLY_ATTR(SOC_DECIMAL),
+   POWER_SUPPLY_ATTR(SOC_DECIMAL_RATE),
 };
 
 static struct attribute *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index a87ae1fff8d1..71e7c8010bde 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -171,6 +171,8 @@ enum power_supply_property {
POWER_SUPPLY_PROP_TX_ADAPTER,
POWER_SUPPLY_PROP_SIGNAL_STRENGTH,
POWER_SUPPLY_PROP_REVERSE_CHG_MODE,
+   POWER_SUPPLY_PROP_SOC_DECIMAL,
+   POWER_SUPPLY_PROP_SOC_DECIMAL_RATE,
 };
 
 enum power_supply_type {
-- 
2.27.0



[PATCH v3 3/5] power: supply: core: add wireless signal strength property

2020-07-14 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 03ab449fae8a..75ec7de2fe78 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,13 @@ Description:
13: ADAPTER_VOICE_BOX,
14: ADAPTER_PRIVATE_PD_50W.
 
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+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
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 0bbdec1630a4..346c6c9c0737 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v3 1/5] power: supply: core: add quick charge type property

2020-07-14 Thread Qiwu Huang
From: Qiwu Huang 

Reports the kind of quick charge type based on
different adapter power. UI will show different
animation effect for different quick charge type.

Signed-off-by: Qiwu Huang 
---
 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(+)

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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..f35c661a2544 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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,
 };
-- 
2.27.0



[PATCH v2 5/5] power: supply: core: supply battery soc with decimal form

2020-07-12 Thread Qiwu Huang
From: Qiwu Huang 

Broadcast battery soc with decimal form.
soc_decimal is the decimal part of battery soc.
soc_decimal_rate is update frequency of decimal
part of battery soc.
We want to report such as 0.01 to 99.99% to
user space to improve user experience
when do very quick charging.

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 20 
 drivers/power/supply/power_supply_sysfs.c   |  2 ++
 include/linux/power_supply.h|  2 ++
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index f4234ba1684a..bcc8ccad8163 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -349,6 +349,26 @@ Description:
Access: Read
Valid values: Represented in microvolts
 
+What:  /sys/class/power_supply//soc_decimal,
+Date:  Jul 2020
+Contact:   jiangf...@xiaomi.com
+Description:
+   Broadcast battery soc with decimal form.
+   soc_decimal is the start decimal part of battery soc.
+
+   Access: Read
+   Valid values: 0 - 100
+
+What:  /sys/class/power_supply//soc_decimal_rate,
+Date:  Jul 2020
+Contact:   jiangf...@xiaomi.com
+Description:
+   Broadcast battery soc with decimal form.
+   soc_decimal_rate is the decimal part of battery soc update 
freqency.
+
+   Access: Read
+   Valid values: 0 - 100
+
 = USB Properties =
 
 What:  /sys/class/power_supply//current_avg
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 81916b6b6ccf..a837addb4f21 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -210,6 +210,8 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(TX_ADAPTER),
POWER_SUPPLY_ATTR(SIGNAL_STRENGTH),
POWER_SUPPLY_ATTR(REVERSE_CHG_MODE),
+   POWER_SUPPLY_ATTR(SOC_DECIMAL),
+   POWER_SUPPLY_ATTR(SOC_DECIMAL_RATE),
 };
 
 static struct attribute *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 319bf6456867..d1aa5497938e 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -171,6 +171,8 @@ enum power_supply_property {
POWER_SUPPLY_PROP_TX_ADAPTER,
POWER_SUPPLY_PROP_SIGNAL_STRENGTH,
POWER_SUPPLY_PROP_REVERSE_CHG_MODE,
+   POWER_SUPPLY_PROP_SOC_DECIMAL,
+   POWER_SUPPLY_PROP_SOC_DECIMAL_RATE,
 };
 
 enum power_supply_type {
-- 
2.27.0



[PATCH v2 3/5] power: supply: core: add wireless signal strength property

2020-07-12 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 11 +++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 13 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index cd07d3f4e8b1..f10780be2732 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -729,3 +729,14 @@ Description:
 
Access: Read-Only
Valid values: Reported as integer
+
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Reports wireless signal strength.The value show degree of 
coupling.
+   Unit is KHZ,the "value" means the working frequency of receiver
+   chip of wireless charging.
+
+   Access: Read-Only
+   Valid values: Reported as integer
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f2458e21d02b..e420a453095e 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 2de9a4c93723..397fb8e96b03 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v2 2/5] power: supply: core: add wireless charger adapter type property

2020-07-12 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 11 +++
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 13 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index d3169d47e359..cd07d3f4e8b1 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -718,3 +718,14 @@ Contact:   Fei Jiang 
Access: Read-Only
Valid values: Reported as integer
 
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   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.
+
+   Access: Read-Only
+   Valid values: Reported as integer
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 9554d7907373..f2458e21d02b 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 3fe7e9ef2f0f..2de9a4c93723 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v2 1/5] power: supply: core: add quick charge type property

2020-07-12 Thread Qiwu Huang
From: Qiwu Huang 

Reports the kind of quick charge type based on
different adapter power. UI will show different
animation effect for different quick charge type.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 216d61a22f1e..d3169d47e359 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -708,3 +708,13 @@ 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.
+
+   Access: Read-Only
+   Valid values: Reported as integer
+
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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..3fe7e9ef2f0f 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH v2 4/5] power: supply: core: property to control reverse charge

2020-07-12 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index f10780be2732..f4234ba1684a 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -740,3 +740,15 @@ Description:
 
Access: Read-Only
Valid values: Reported as integer
+
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   The property supply interface to control wireless
+   reverse charge mode.
+
+   Valid values:
+   - 1: enabled
+   - 0: disabled
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index e420a453095e..81916b6b6ccf 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 397fb8e96b03..319bf6456867 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.27.0



[PATCH 2/5] power: supply: core: add wireless charger adapter type property

2020-07-10 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 13 +
 drivers/power/supply/power_supply_sysfs.c   |  1 +
 include/linux/power_supply.h|  1 +
 3 files changed, 15 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 0d9d6b46e239..2099cf194a89 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -718,3 +718,16 @@ Contact:   Fei Jiang 
Access: Read-Only
Valid values: "QUICK_CHARGE_NORMAL", "QUICK_CHARGE_FAST", 
"QUICK_CHARGE_FLASH",
"QUICK_CHARGE_TURBE", "QUICK_CHARGE_SUPER".
+
+= Wireless Charger Properties =
+What:  /sys/class/power_supply//tx_adapter
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   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.
+
+   Access: Read-Only
+   Valid values: "ADAPTER_NONE", "ADAPTER_SDP", "ADAPTER_DCP", 
"ADAPTER_CDP",
+   "ADAPTER_QC2", "ADAPTER_QC3", "ADAPTER_PD" or other private 
adapter.
\ No newline at end of file
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index f95574c41898..c864a14829ec 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 3fe7e9ef2f0f..2de9a4c93723 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.26.0



[PATCH 4/5] power: supply: core: property to control reverse charge

2020-07-10 Thread Qiwu Huang
From: Qiwu Huang 

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

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

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 1f42aa0c071e..1f489a250c19 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -737,4 +737,15 @@ Date:  Jul 2020
 Contact:   Fei Jiang 
 Description:
Reports wireless signal strength.
-   The value show degree of coupling.
\ No newline at end of file
+   The value show degree of coupling.
+What:  /sys/class/power_supply//reverse_chg_mode
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   The property supply interface to control wireless
+   reverse charge mode.
+
+   Valid values:
+   - 1: enabled
+   - 0: disabled
+
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 42fbe1b68255..4be762abba89 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 397fb8e96b03..319bf6456867 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.26.0



[PATCH 3/5] power: supply: core: add wireless signal strength property

2020-07-10 Thread Qiwu Huang
From: Qiwu Huang 

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

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 9 -
 drivers/power/supply/power_supply_sysfs.c   | 1 +
 include/linux/power_supply.h| 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 2099cf194a89..1f42aa0c071e 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -730,4 +730,11 @@ Description:
 
Access: Read-Only
Valid values: "ADAPTER_NONE", "ADAPTER_SDP", "ADAPTER_DCP", 
"ADAPTER_CDP",
-   "ADAPTER_QC2", "ADAPTER_QC3", "ADAPTER_PD" or other private 
adapter.
\ No newline at end of file
+   "ADAPTER_QC2", "ADAPTER_QC3", "ADAPTER_PD" or other private 
adapter.
+
+What:  /sys/class/power_supply//signal_strength
+Date:  Jul 2020
+Contact:   Fei Jiang 
+Description:
+   Reports wireless signal strength.
+   The value show degree of coupling.
\ No newline at end of file
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index c864a14829ec..42fbe1b68255 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -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 *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 2de9a4c93723..397fb8e96b03 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.26.0



[PATCH 5/5] power: supply: core: supply battery soc with decimal form

2020-07-10 Thread Qiwu Huang
From: Qiwu Huang 

Broadcast battery soc with decimal form.
soc_decimal is the decimal part of battery soc.
soc_decimal_rate is update frequency of decimal
part of battery soc.

Signed-off-by: Qiwu Huang 
---
 Documentation/ABI/testing/sysfs-class-power | 20 
 drivers/power/supply/power_supply_sysfs.c   |  2 ++
 include/linux/power_supply.h|  2 ++
 3 files changed, 24 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 1f489a250c19..60c5a0dd1b98 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -349,6 +349,26 @@ Description:
Access: Read
Valid values: Represented in microvolts
 
+What:  /sys/class/power_supply//soc_decimal,
+Date:  Jul 2020
+Contact:   jiangf...@xiaomi.com
+Description:
+   Broadcast battery soc with decimal form.
+   soc_decimal is the start decimal part of battery soc.
+
+   Access: Read
+Valid values: 0 - 100
+
+What:  /sys/class/power_supply//soc_decimal_rate,
+Date:  Jul 2020
+Contact:   jiangf...@xiaomi.com
+Description:
+   Broadcast battery soc with decimal form.
+   soc_decimal_rate is the decimal part of battery soc update 
freqency.
+
+   Access: Read
+Valid values: 0 - 100
+
 = USB Properties =
 
 What:  /sys/class/power_supply//current_avg
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index 4be762abba89..8defc22e0d7f 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -210,6 +210,8 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(tx_adapter),
POWER_SUPPLY_ATTR(signal_strength),
POWER_SUPPLY_ATTR(reverse_chg_mode),
+   POWER_SUPPLY_ATTR(soc_decimal),
+   POWER_SUPPLY_ATTR(soc_decimal_rate),
 };
 
 static struct attribute *
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 319bf6456867..d1aa5497938e 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -171,6 +171,8 @@ enum power_supply_property {
POWER_SUPPLY_PROP_TX_ADAPTER,
POWER_SUPPLY_PROP_SIGNAL_STRENGTH,
POWER_SUPPLY_PROP_REVERSE_CHG_MODE,
+   POWER_SUPPLY_PROP_SOC_DECIMAL,
+   POWER_SUPPLY_PROP_SOC_DECIMAL_RATE,
 };
 
 enum power_supply_type {
-- 
2.26.0



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

2020-07-10 Thread Qiwu Huang
From: Qiwu Huang 

Reports the kind of quick charge type based on
different adapter power. UI will show different
animation effect for different quick charge type.

Signed-off-by: Qiwu Huang 
---
 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(+)

diff --git a/Documentation/ABI/testing/sysfs-class-power 
b/Documentation/ABI/testing/sysfs-class-power
index 216d61a22f1e..0d9d6b46e239 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -708,3 +708,13 @@ 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.
+
+   Access: Read-Only
+   Valid values: "QUICK_CHARGE_NORMAL", "QUICK_CHARGE_FAST", 
"QUICK_CHARGE_FLASH",
+   "QUICK_CHARGE_TURBE", "QUICK_CHARGE_SUPER".
diff --git a/drivers/power/supply/power_supply_sysfs.c 
b/drivers/power/supply/power_supply_sysfs.c
index bc79560229b5..f95574c41898 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/include/linux/power_supply.h b/include/linux/power_supply.h
index ac1345a48ad0..3fe7e9ef2f0f 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -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 {
-- 
2.26.0