Skip to contentSkip to conversation

usb: typec: tcpm: add get max power support

PATCH In review Frank Wang 2 participants 4 messages Mar 22, 2023 – Oct 27, 2023

Subsystems (4)
lore
Share & tools
lore

Frank Wang

author
#0 lore raw

PATCH v3 1/1 usb: typec: tcpm: add get max power support

Traverse fixed pdos to calculate the maximum power that the charger can provide, and it can be get by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT property.

---
 drivers/usb/typec/tcpm/tcpm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +24 -0
index 13830b5e2d09f..db2636ef511bc 100644
@@ -6320,6 +6320,27 @@ static int tcpm_psy_get_current_now(struct tcpm_port *port,
 	return 0;
 }
 
+static int tcpm_psy_get_input_power_limit(struct tcpm_port *port,
+					  union power_supply_propval *val)
+{
+	unsigned int src_mv, src_ma, max_src_uw = 0;
+	unsigned int i, tmp;
+
+	for (i = 0; i < port->nr_source_caps; i++) {
+		u32 pdo = port->source_caps[i];
+
+		if (pdo_type(pdo) == PDO_TYPE_FIXED) {
+			src_mv = pdo_fixed_voltage(pdo);
+			src_ma = pdo_max_current(pdo);
+			tmp = src_mv * src_ma;
+			max_src_uw = tmp > max_src_uw ? tmp : max_src_uw;
+		}
+	}
+
+	val->intval = max_src_uw;
+	return 0;
+}
+
 static int tcpm_psy_get_prop(struct power_supply *psy,
 			     enum power_supply_property psp,
 			     union power_supply_propval *val)
@@ -6349,6 +6370,9 @@ static int tcpm_psy_get_prop(struct power_supply *psy,
 	case POWER_SUPPLY_PROP_CURRENT_NOW:
 		ret = tcpm_psy_get_current_now(port, val);
 		break;
+	case POWER_SUPPLY_PROP_INPUT_POWER_LIMIT:
+		tcpm_psy_get_input_power_limit(port, val);
+		break;
 	default:
 		ret = -EINVAL;
 		break;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · Frank Wang

Traverse fixed pdos to calculate the maximum power that the charger can provide, and it can be get by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT property.

---
 drivers/usb/typec/tcpm/tcpm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

What ever happened to this patch?

Frank, can you rebase it and resubmit?

thanks,

greg k-h

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

author
#2 lore raw

Hi Greg,

Quoted 5 lines · Greg KH
Quoted 4 lines · Frank Wang

Traverse fixed pdos to calculate the maximum power that the charger can provide, and it can be get by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT property.

Quoted 7 lines
Quoted 4 lines
---
  drivers/usb/typec/tcpm/tcpm.c | 24 ++++++++++++++++++++++++
  1 file changed, 24 insertions(+)

What ever happened to this patch?

Frank, can you rebase it and resubmit?

Thanks for your reply, I shall resubmit it later.

BR.
Frank

Quoted 3 lines

thanks,

greg k-h

_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip

maintainer
#3 lore raw
In reply to Frank Wang
Quoted 8 lines · Frank Wang

Traverse fixed pdos to calculate the maximum power that the charger can provide, and it can be get by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT property.

---
 drivers/usb/typec/tcpm/tcpm.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

What ever happened to this change? Can you rebase and resubmit it please?

thanks,

greg k-h