Skip to contentSkip to conversation

power: supply: qcom_battmgr: Expose USB connector temperature

PATCH Applied Konrad Dybcio 2 participants 2 messages Oct 20 – Nov 9

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 power: supply: qcom_battmgr: Expose USB connector temperature

From: Konrad Dybcio <[email protected]>

The firmware is capable of reporting the temperature of the connector. Expose it at the USB supply.

---
Tested on Kodiak/FP5

---
 drivers/power/supply/qcom_battmgr.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/power/supply/qcom_battmgr.c +11 -0
index a7237ba09be1..9410a4a1387c 100644
@@ -87,6 +87,7 @@ enum qcom_battmgr_variant {
 #define USB_ADAP_TYPE			7
 #define USB_MOISTURE_DET_EN		8
 #define USB_MOISTURE_DET_STS		9
+#define USB_TEMP			10
 
 #define BATTMGR_WLS_PROPERTY_GET	0x34
 #define BATTMGR_WLS_PROPERTY_SET	0x35
@@ -298,6 +299,7 @@ struct qcom_battmgr_usb {
 	unsigned int current_max;
 	unsigned int current_limit;
 	unsigned int usb_type;
+	int temperature;
 };
 
 struct qcom_battmgr_wireless {
@@ -977,6 +979,7 @@ static const u8 sm8350_usb_prop_map[] = {
 	[POWER_SUPPLY_PROP_CURRENT_MAX] = USB_CURR_MAX,
 	[POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT] = USB_INPUT_CURR_LIMIT,
 	[POWER_SUPPLY_PROP_USB_TYPE] = USB_TYPE,
+	[POWER_SUPPLY_PROP_TEMP] = USB_TEMP,
 };
 
 static int qcom_battmgr_usb_sm8350_update(struct qcom_battmgr *battmgr,
@@ -1037,6 +1040,9 @@ static int qcom_battmgr_usb_get_property(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_USB_TYPE:
 		val->intval = battmgr->usb.usb_type;
 		break;
+	case POWER_SUPPLY_PROP_TEMP:
+		val->intval = battmgr->usb.temperature;
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1074,6 +1080,7 @@ static const enum power_supply_property sm8350_usb_props[] = {
 	POWER_SUPPLY_PROP_CURRENT_MAX,
 	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
 	POWER_SUPPLY_PROP_USB_TYPE,
+	POWER_SUPPLY_PROP_TEMP,
 };
 
 static const struct power_supply_desc sm8350_usb_psy_desc = {
@@ -1517,6 +1524,10 @@ static void qcom_battmgr_sm8350_callback(struct qcom_battmgr *battmgr,
 		case USB_TYPE:
 			battmgr->usb.usb_type = le32_to_cpu(resp->intval.value);
 			break;
+		case USB_TEMP:
+			battmgr->usb.temperature =
+				DIV_ROUND_CLOSEST((int)le32_to_cpu(resp->intval.value), 10);
+			break;
 		default:
 			dev_warn(battmgr->dev, "unknown property %#x\n", property);
 			break;

---
base-commit: 2efb7a11f1aa4d2dc285fe2680cca22cb9f72f64
change-id: 20261020-topic-usb_temp-3d56ecc9c658

Best regards,

Signature · 1 line
Konrad Dybcio <[email protected]>
#1 lore raw
Quoted 2 lines · Konrad Dybcio

The firmware is capable of reporting the temperature of the connector. Expose it at the USB supply.

Applied, thanks!

[1/1] power: supply: qcom_battmgr: Expose USB connector temperature

      commit: 23404b2678f38e8d086a127f879ba02078011393

Best regards,

Signature · 1 line
Sebastian Reichel <[email protected]>