linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v11 0/4] add some power supply properties about wireless/wired charging
@ 2021-08-04 11:01 Ting Wang
  2021-08-04 11:01 ` [PATCH v11 1/4] power: supply: core: add quick charge type property Ting Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Ting Wang @ 2021-08-04 11:01 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, gregkh, wangting11

From: wangting11 <wangting11@xiaomi.com>

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 V11
 - Fix build error on linus/master 
 - Fix build error on power-supply/for-next
 - Fix conflict

Changes in V10
 - Fix build error on linus/master v5.9-rc2 next-20200824 Reported-by: kernel test robot <lkp@intel.com>
 - Fix build error on power-supply/for-next Reported-by: kernel test robot <lkp@intel.com>

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

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

-- 
2.17.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v11 1/4] power: supply: core: add quick charge type property
  2021-08-04 11:01 [PATCH v11 0/4] add some power supply properties about wireless/wired charging Ting Wang
@ 2021-08-04 11:01 ` Ting Wang
  2021-08-05 16:31   ` Sebastian Reichel
  2021-08-04 11:01 ` [PATCH v11 2/4] power: supply: core: add wireless charger adapter " Ting Wang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Ting Wang @ 2021-08-04 11:01 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, gregkh, wangting11

From: wangting11 <wangting11@xiaomi.com>

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

Signed-off-by: wangting11 <wangting11@xiaomi.com>
---
 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 ca830c6cd809..a49e1049cd9b 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -736,3 +736,24 @@ Description:
 
 		Access: Read
 		Valid values: 1-31
+
+What:		/sys/class/power_supply/<supply_name>/quick_charge_type
+Date:		Jul 2020
+Contact:	Fei Jiang <jiangfei1@xiaomi.com>
+		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 c3d7cbcd4fad..21f0ab748e5e 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(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_FAST		BIT(7) /* Fast charging */
 #define STATUS_CHG_GONE		BIT(8) /* No charger is connected */
 
+#define IMAX_NORMAL		2000000
+#define IMAX_FAST		4000000
+#define IMAX_FLASH		6000000
+#define IMAX_TURBE		10000000
+#define IMAX_SUPER		12000000
+
 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, &prop);
+	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, &prop);
+	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++;
+	}
+
+	return 0;
+}
+
 static int smbb_usbin_get_property(struct power_supply *psy,
 		enum power_supply_property psp,
 		union power_supply_propval *val)
@@ -505,6 +564,9 @@ static int smbb_usbin_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
 		val->intval = 2500000;
 		break;
+	case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
+		val->intval = get_quick_charge_type(chg);
+		break;
 	default:
 		rc = -EINVAL;
 		break;
@@ -662,11 +724,27 @@ static int smbb_battery_set_property(struct power_supply *psy,
 		const union power_supply_propval *val)
 {
 	struct smbb_charger *chg = power_supply_get_drvdata(psy);
+	int charger_type, bat_imax;
 	int rc;
 
 	switch (psp) {
 	case POWER_SUPPLY_PROP_CURRENT_MAX:
-		rc = smbb_charger_attr_write(chg, ATTR_BAT_IMAX, val->intval);
+		charger_type = get_quick_charge_type(chg);
+		if (charger_type == QUICK_CHARGE_NORMAL)
+			bat_imax = IMAX_NORMAL;
+		else if (charger_type == QUICK_CHARGE_FAST)
+			bat_imax = IMAX_FAST;
+		else if (charger_type == QUICK_CHARGE_FLASH)
+			bat_imax = IMAX_FLASH;
+		else if (charger_type == QUICK_CHARGE_TURBE)
+			bat_imax = IMAX_TURBE;
+		else if (charger_type == QUICK_CHARGE_SUPER)
+			bat_imax = IMAX_SUPER;
+		else
+			bat_imax = IMAX_NORMAL;
+
+		bat_imax = min(val->intval, bat_imax);
+		rc = smbb_charger_attr_write(chg, ATTR_BAT_IMAX, bat_imax);
 		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
 		rc = smbb_charger_attr_write(chg, ATTR_BAT_VMAX, val->intval);
@@ -695,6 +773,7 @@ static enum power_supply_property smbb_charger_properties[] = {
 	POWER_SUPPLY_PROP_ONLINE,
 	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
 	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
+	POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
 };
 
 static enum power_supply_property smbb_battery_properties[] = {
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index be203985ecdd..3dc3e53c5df1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -171,6 +171,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 {
@@ -187,6 +188,10 @@ enum power_supply_type {
 	POWER_SUPPLY_TYPE_USB_PD_DRP,		/* PD Dual Role Port */
 	POWER_SUPPLY_TYPE_APPLE_BRICK_ID,	/* Apple Charging Method */
 	POWER_SUPPLY_TYPE_WIRELESS,		/* Wireless */
+	POWER_SUPPLY_TYPE_USB_HVDCP,		/* High Voltage DCP */
+	POWER_SUPPLY_TYPE_USB_HVDCP_3,		/* Efficient High Voltage DCP */
+	POWER_SUPPLY_TYPE_USB_HVDCP_3P5,	/* Efficient High Voltage DCP */
+	POWER_SUPPLY_TYPE_USB_FLOAT,		/* Floating charger */
 };
 
 enum power_supply_usb_type {
@@ -202,6 +207,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.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v11 2/4] power: supply: core: add wireless charger adapter type property
  2021-08-04 11:01 [PATCH v11 0/4] add some power supply properties about wireless/wired charging Ting Wang
  2021-08-04 11:01 ` [PATCH v11 1/4] power: supply: core: add quick charge type property Ting Wang
@ 2021-08-04 11:01 ` Ting Wang
  2021-08-04 11:02 ` [PATCH v11 3/4] power: supply: core: add wireless signal strength property Ting Wang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Ting Wang @ 2021-08-04 11:01 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, gregkh, wangting11

From: wangting11 <wangting11@xiaomi.com>

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: wangting11 <wangting11@xiaomi.com>
---
 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 a49e1049cd9b..36808bf8731b 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -757,3 +757,31 @@ Contact:	Fei Jiang <jiangfei1@xiaomi.com>
 			3: QUICK_CHARGE_TURBE,
 			4: QUICK_CHARGE_SUPER.
 
+===== Wireless Charger Properties =====
+What:		/sys/class/power_supply/<supply_name>/tx_adapter
+Date:		Jul 2020
+Contact:	Fei Jiang <jiangfei1@xiaomi.com>
+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 21f0ab748e5e..561cffef9d61 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(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 3dc3e53c5df1..bcfadf2a995f 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 {
@@ -216,6 +217,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.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v11 3/4] power: supply: core: add wireless signal strength property
  2021-08-04 11:01 [PATCH v11 0/4] add some power supply properties about wireless/wired charging Ting Wang
  2021-08-04 11:01 ` [PATCH v11 1/4] power: supply: core: add quick charge type property Ting Wang
  2021-08-04 11:01 ` [PATCH v11 2/4] power: supply: core: add wireless charger adapter " Ting Wang
@ 2021-08-04 11:02 ` Ting Wang
  2021-08-05 16:45   ` Sebastian Reichel
  2021-08-04 11:02 ` [PATCH v11 4/4] power: supply: core: property to control reverse charge Ting Wang
  2021-08-04 12:04 ` [PATCH v11 0/4] add some power supply properties about wireless/wired charging Greg KH
  4 siblings, 1 reply; 11+ messages in thread
From: Ting Wang @ 2021-08-04 11:02 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, gregkh, wangting11

From: wangting11 <wangting11@xiaomi.com>

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

Signed-off-by: wangting11 <wangting11@xiaomi.com>
---
 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 36808bf8731b..4a6b4970cb7d 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -785,3 +785,25 @@ Description:
 			13: ADAPTER_VOICE_BOX,
 			14: ADAPTER_PRIVATE_PD_50W.
 
+What:		/sys/class/power_supply/<supply_name>/signal_strength
+Date:		Jul 2020
+Contact:	Fei Jiang <jiangfei1@xiaomi.com>
+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 561cffef9d61..4de91dce2001 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(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 bcfadf2a995f..0dfec19cb473 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.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v11 4/4] power: supply: core: property to control reverse charge
  2021-08-04 11:01 [PATCH v11 0/4] add some power supply properties about wireless/wired charging Ting Wang
                   ` (2 preceding siblings ...)
  2021-08-04 11:02 ` [PATCH v11 3/4] power: supply: core: add wireless signal strength property Ting Wang
@ 2021-08-04 11:02 ` Ting Wang
  2021-08-05 16:37   ` Sebastian Reichel
  2021-08-04 12:04 ` [PATCH v11 0/4] add some power supply properties about wireless/wired charging Greg KH
  4 siblings, 1 reply; 11+ messages in thread
From: Ting Wang @ 2021-08-04 11:02 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, gregkh, wangting11

From: wangting11 <wangting11@xiaomi.com>

Interface to control wireless reverse charge.

Signed-off-by: wangting11 <wangting11@xiaomi.com>
---
 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 4a6b4970cb7d..59518568d594 100644
--- a/Documentation/ABI/testing/sysfs-class-power
+++ b/Documentation/ABI/testing/sysfs-class-power
@@ -807,3 +807,17 @@ Description:
 
 		Access: Read-Only
 		Valid values: 0 - 100
+
+What:		/sys/class/power_supply/<supply_name>/reverse_chg_mode
+Date:		Jul 2020
+Contact:	Fei Jiang <jiangfei1@xiaomi.com>
+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 4de91dce2001..934563eed155 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -214,6 +214,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 0dfec19cb473..3fe3f9665389 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.17.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v11 0/4] add some power supply properties about wireless/wired charging
  2021-08-04 11:01 [PATCH v11 0/4] add some power supply properties about wireless/wired charging Ting Wang
                   ` (3 preceding siblings ...)
  2021-08-04 11:02 ` [PATCH v11 4/4] power: supply: core: property to control reverse charge Ting Wang
@ 2021-08-04 12:04 ` Greg KH
  2021-08-05  2:29   ` 吧!王婷
  4 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2021-08-04 12:04 UTC (permalink / raw)
  To: Ting Wang; +Cc: sre, linux-pm, linux-kernel, wangting11

On Wed, Aug 04, 2021 at 07:01:57PM +0800, Ting Wang wrote:
> From: wangting11 <wangting11@xiaomi.com>
> 
> 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 V11
>  - Fix build error on linus/master 
>  - Fix build error on power-supply/for-next
>  - Fix conflict

Where are the users of these new properties?  Shouldn't drivers be
submitted with them as well, otherwise why would these be added?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v11 0/4] add some power supply properties about wireless/wired charging
  2021-08-04 12:04 ` [PATCH v11 0/4] add some power supply properties about wireless/wired charging Greg KH
@ 2021-08-05  2:29   ` 吧!王婷
  2021-08-05  8:14     ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: 吧!王婷 @ 2021-08-05  2:29 UTC (permalink / raw)
  To: Greg KH; +Cc: sre, linux-pm, linux-kernel, wangting11

Hi Greg,

 A demo of “The usage of quick charge type property” is uploaded in
PATCH v11 1/4 drivers/power/supply/qcom_smbb.c.


The usage of the other three properties is about wireless charging.The
code of our driver can refer to the link below.

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

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

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

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

Thanks,
Wangting

Greg KH <gregkh@linuxfoundation.org> 于2021年8月4日周三 下午8:04写道:
>
> On Wed, Aug 04, 2021 at 07:01:57PM +0800, Ting Wang wrote:
> > From: wangting11 <wangting11@xiaomi.com>
> >
> > 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 V11
> >  - Fix build error on linus/master
> >  - Fix build error on power-supply/for-next
> >  - Fix conflict
>
> Where are the users of these new properties?  Shouldn't drivers be
> submitted with them as well, otherwise why would these be added?
>
> thanks,
>
> greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v11 0/4] add some power supply properties about wireless/wired charging
  2021-08-05  2:29   ` 吧!王婷
@ 2021-08-05  8:14     ` Greg KH
  0 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2021-08-05  8:14 UTC (permalink / raw)
  To: 吧!王婷; +Cc: sre, linux-pm, linux-kernel, wangting11

A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Thu, Aug 05, 2021 at 10:29:08AM +0800, 吧!王婷 wrote:
> Hi Greg,
> 
>  A demo of “The usage of quick charge type property” is uploaded in
> PATCH v11 1/4 drivers/power/supply/qcom_smbb.c.
> 
> 
> The usage of the other three properties is about wireless charging.The
> code of our driver can refer to the link below.
> 
> POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
> https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/umi-q-oss/drivers/power/supply/qcom/qpnp-smb5.c#L1434
> 
> POWER_SUPPLY_PROP_REVERSE_CHG_MODE:
> https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/umi-q-oss/drivers/power/supply/qcom/qpnp-smb5.c#L2572
> 
> POWER_SUPPLY_PROP_TX_ADAPTER:
> https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/umi-q-oss/drivers/power/supply/qcom/qpnp-smb5.c#L2633
> 
> POWER_SUPPLY_PROP_SIGNAL_STRENGTH:
> https://github.com/MiCode/Xiaomi_Kernel_OpenSource/blob/umi-q-oss/drivers/power/supply/qcom/qpnp-smb5.c#L2609

Wonderful, please submit these drivers to be merged as part of this
patch series and all should be good.

Otherwise, please realize that we can not support out-of-tree drivers at
all, that way lies madness and a kernel that we can never support well
over time.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v11 1/4] power: supply: core: add quick charge type property
  2021-08-04 11:01 ` [PATCH v11 1/4] power: supply: core: add quick charge type property Ting Wang
@ 2021-08-05 16:31   ` Sebastian Reichel
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastian Reichel @ 2021-08-05 16:31 UTC (permalink / raw)
  To: Ting Wang; +Cc: linux-pm, linux-kernel, gregkh, wangting11

[-- Attachment #1: Type: text/plain, Size: 8878 bytes --]

Hi,

On Wed, Aug 04, 2021 at 07:01:58PM +0800, Ting Wang wrote:
> From: wangting11 <wangting11@xiaomi.com>
> 
> Reports the kind of quick charge type based on
> different adapter power.
> 
> Signed-off-by: wangting11 <wangting11@xiaomi.com>
> ---
>  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(-)

The patch description is wrong. This does not just add the quick
charge type to power-supply-core, but also enables the feature for
the qcom_smbb driver. This should be two patches!

> diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power
> index ca830c6cd809..a49e1049cd9b 100644
> --- a/Documentation/ABI/testing/sysfs-class-power
> +++ b/Documentation/ABI/testing/sysfs-class-power
> @@ -736,3 +736,24 @@ Description:
>  
>  		Access: Read
>  		Valid values: 1-31
> +
> +What:		/sys/class/power_supply/<supply_name>/quick_charge_type
> +Date:		Jul 2020
> +Contact:	Fei Jiang <jiangfei1@xiaomi.com>
> +		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

Where do these names come from? I never heard of them before (apart
from this patch series) and cannot find them when doing a quick web
search. It looks like you only use it to map USB type to current, so
can this just be dropped from public API and handled within the
Qualcomm driver?

> +
> +		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 c3d7cbcd4fad..21f0ab748e5e 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(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_FAST		BIT(7) /* Fast charging */
>  #define STATUS_CHG_GONE		BIT(8) /* No charger is connected */
>  
> +#define IMAX_NORMAL		2000000
> +#define IMAX_FAST		4000000
> +#define IMAX_FLASH		6000000
> +#define IMAX_TURBE		10000000
> +#define IMAX_SUPER		12000000
> +
>  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, &prop);
> +	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, &prop);
> +	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++;
> +	}
> +
> +	return 0;
> +}
> +
>  static int smbb_usbin_get_property(struct power_supply *psy,
>  		enum power_supply_property psp,
>  		union power_supply_propval *val)
> @@ -505,6 +564,9 @@ static int smbb_usbin_get_property(struct power_supply *psy,
>  	case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX:
>  		val->intval = 2500000;
>  		break;
> +	case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE:
> +		val->intval = get_quick_charge_type(chg);
> +		break;
>  	default:
>  		rc = -EINVAL;
>  		break;
> @@ -662,11 +724,27 @@ static int smbb_battery_set_property(struct power_supply *psy,
>  		const union power_supply_propval *val)
>  {
>  	struct smbb_charger *chg = power_supply_get_drvdata(psy);
> +	int charger_type, bat_imax;
>  	int rc;
>  
>  	switch (psp) {
>  	case POWER_SUPPLY_PROP_CURRENT_MAX:
> -		rc = smbb_charger_attr_write(chg, ATTR_BAT_IMAX, val->intval);
> +		charger_type = get_quick_charge_type(chg);
> +		if (charger_type == QUICK_CHARGE_NORMAL)
> +			bat_imax = IMAX_NORMAL;
> +		else if (charger_type == QUICK_CHARGE_FAST)
> +			bat_imax = IMAX_FAST;
> +		else if (charger_type == QUICK_CHARGE_FLASH)
> +			bat_imax = IMAX_FLASH;
> +		else if (charger_type == QUICK_CHARGE_TURBE)
> +			bat_imax = IMAX_TURBE;
> +		else if (charger_type == QUICK_CHARGE_SUPER)
> +			bat_imax = IMAX_SUPER;
> +		else
> +			bat_imax = IMAX_NORMAL;
> +
> +		bat_imax = min(val->intval, bat_imax);
> +		rc = smbb_charger_attr_write(chg, ATTR_BAT_IMAX, bat_imax);
>  		break;
>  	case POWER_SUPPLY_PROP_VOLTAGE_MAX:
>  		rc = smbb_charger_attr_write(chg, ATTR_BAT_VMAX, val->intval);
> @@ -695,6 +773,7 @@ static enum power_supply_property smbb_charger_properties[] = {
>  	POWER_SUPPLY_PROP_ONLINE,
>  	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT,
>  	POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX,
> +	POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE,
>  };
>  
>  static enum power_supply_property smbb_battery_properties[] = {
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index be203985ecdd..3dc3e53c5df1 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -171,6 +171,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 {
> @@ -187,6 +188,10 @@ enum power_supply_type {
>  	POWER_SUPPLY_TYPE_USB_PD_DRP,		/* PD Dual Role Port */
>  	POWER_SUPPLY_TYPE_APPLE_BRICK_ID,	/* Apple Charging Method */
>  	POWER_SUPPLY_TYPE_WIRELESS,		/* Wireless */
> +	POWER_SUPPLY_TYPE_USB_HVDCP,		/* High Voltage DCP */
> +	POWER_SUPPLY_TYPE_USB_HVDCP_3,		/* Efficient High Voltage DCP */
> +	POWER_SUPPLY_TYPE_USB_HVDCP_3P5,	/* Efficient High Voltage DCP */
> +	POWER_SUPPLY_TYPE_USB_FLOAT,		/* Floating charger */
>  };

USB chargers should set the type to POWER_SUPPLY_TYPE_USB and report
the exact type via POWER_SUPPLY_PROP_USB_TYPE instead, so you need
to expand 'enum power_supply_usb_type'.

-- Sebastian

>  enum power_supply_usb_type {
> @@ -202,6 +207,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.17.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v11 4/4] power: supply: core: property to control reverse charge
  2021-08-04 11:02 ` [PATCH v11 4/4] power: supply: core: property to control reverse charge Ting Wang
@ 2021-08-05 16:37   ` Sebastian Reichel
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastian Reichel @ 2021-08-05 16:37 UTC (permalink / raw)
  To: Ting Wang; +Cc: linux-pm, linux-kernel, gregkh, wangting11

[-- Attachment #1: Type: text/plain, Size: 2438 bytes --]

Hi,

On Wed, Aug 04, 2021 at 07:02:01PM +0800, Ting Wang wrote:
> From: wangting11 <wangting11@xiaomi.com>
> 
> Interface to control wireless reverse charge.
> 
> Signed-off-by: wangting11 <wangting11@xiaomi.com>
> ---

In mainline Linux this is handled by registering a regulator, see
e.g. "otg-vbus" regulator in the Qualcomm driver.

-- Sebastian

>  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 4a6b4970cb7d..59518568d594 100644
> --- a/Documentation/ABI/testing/sysfs-class-power
> +++ b/Documentation/ABI/testing/sysfs-class-power
> @@ -807,3 +807,17 @@ Description:
>  
>  		Access: Read-Only
>  		Valid values: 0 - 100
> +
> +What:		/sys/class/power_supply/<supply_name>/reverse_chg_mode
> +Date:		Jul 2020
> +Contact:	Fei Jiang <jiangfei1@xiaomi.com>
> +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 4de91dce2001..934563eed155 100644
> --- a/drivers/power/supply/power_supply_sysfs.c
> +++ b/drivers/power/supply/power_supply_sysfs.c
> @@ -214,6 +214,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 0dfec19cb473..3fe3f9665389 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.17.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v11 3/4] power: supply: core: add wireless signal strength property
  2021-08-04 11:02 ` [PATCH v11 3/4] power: supply: core: add wireless signal strength property Ting Wang
@ 2021-08-05 16:45   ` Sebastian Reichel
  0 siblings, 0 replies; 11+ messages in thread
From: Sebastian Reichel @ 2021-08-05 16:45 UTC (permalink / raw)
  To: Ting Wang; +Cc: linux-pm, linux-kernel, gregkh, wangting11

[-- Attachment #1: Type: text/plain, Size: 3236 bytes --]

Hi,

On Wed, Aug 04, 2021 at 07:02:00PM +0800, Ting Wang wrote:
> From: wangting11 <wangting11@xiaomi.com>
> 
> reports wireless signal strength.
> The value show degree of coupling between tx and rx.
> 
> Signed-off-by: wangting11 <wangting11@xiaomi.com>
> ---

You also need a user for this property.

>  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 36808bf8731b..4a6b4970cb7d 100644
> --- a/Documentation/ABI/testing/sysfs-class-power
> +++ b/Documentation/ABI/testing/sysfs-class-power
> @@ -785,3 +785,25 @@ Description:
>  			13: ADAPTER_VOICE_BOX,
>  			14: ADAPTER_PRIVATE_PD_50W.
>  
> +What:		/sys/class/power_supply/<supply_name>/signal_strength
> +Date:		Jul 2020
> +Contact:	Fei Jiang <jiangfei1@xiaomi.com>
> +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.

A lot of text, but not much information what 'signal_strength' reports.
IIUIC it could be rephrased like this simple sentence?

Reports the degree coupling between wireless RX and TX side of a
wireless charger in %.

-- Sebastian

> +		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 561cffef9d61..4de91dce2001 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(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 bcfadf2a995f..0dfec19cb473 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.17.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-08-05 16:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-04 11:01 [PATCH v11 0/4] add some power supply properties about wireless/wired charging Ting Wang
2021-08-04 11:01 ` [PATCH v11 1/4] power: supply: core: add quick charge type property Ting Wang
2021-08-05 16:31   ` Sebastian Reichel
2021-08-04 11:01 ` [PATCH v11 2/4] power: supply: core: add wireless charger adapter " Ting Wang
2021-08-04 11:02 ` [PATCH v11 3/4] power: supply: core: add wireless signal strength property Ting Wang
2021-08-05 16:45   ` Sebastian Reichel
2021-08-04 11:02 ` [PATCH v11 4/4] power: supply: core: property to control reverse charge Ting Wang
2021-08-05 16:37   ` Sebastian Reichel
2021-08-04 12:04 ` [PATCH v11 0/4] add some power supply properties about wireless/wired charging Greg KH
2021-08-05  2:29   ` 吧!王婷
2021-08-05  8:14     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).