* [PATCH v3] usb: typec: tcpm: add get max power support
@ 2023-03-22 9:31 Frank Wang
2023-06-15 9:39 ` Greg KH
2023-10-27 10:34 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Frank Wang @ 2023-03-22 9:31 UTC (permalink / raw)
To: sebastian.reichel, linux, heikki.krogerus, gregkh, heiko
Cc: linux-usb, linux-kernel, linux-rockchip, huangtao, william.wu,
jianwei.zheng, yubing.zhang, wmc, 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.
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
---
drivers/usb/typec/tcpm/tcpm.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 13830b5e2d09f..db2636ef511bc 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -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;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3] usb: typec: tcpm: add get max power support
2023-03-22 9:31 [PATCH v3] usb: typec: tcpm: add get max power support Frank Wang
@ 2023-06-15 9:39 ` Greg KH
2023-06-16 1:48 ` Frank Wang
2023-10-27 10:34 ` Greg KH
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-06-15 9:39 UTC (permalink / raw)
To: Frank Wang
Cc: sebastian.reichel, linux, heikki.krogerus, heiko, linux-usb,
linux-kernel, linux-rockchip, huangtao, william.wu, jianwei.zheng,
yubing.zhang, wmc
On Wed, Mar 22, 2023 at 05:31:20PM +0800, Frank Wang wrote:
> 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.
>
> Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] usb: typec: tcpm: add get max power support
2023-06-15 9:39 ` Greg KH
@ 2023-06-16 1:48 ` Frank Wang
0 siblings, 0 replies; 4+ messages in thread
From: Frank Wang @ 2023-06-16 1:48 UTC (permalink / raw)
To: Greg KH
Cc: sebastian.reichel, linux, heikki.krogerus, heiko, linux-usb,
linux-kernel, linux-rockchip, huangtao, william.wu, jianwei.zheng,
yubing.zhang, wmc
Hi Greg,
On 2023/6/15 17:39, Greg KH wrote:
> On Wed, Mar 22, 2023 at 05:31:20PM +0800, Frank Wang wrote:
>> 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.
>>
>> Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
>> ---
>> 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
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] usb: typec: tcpm: add get max power support
2023-03-22 9:31 [PATCH v3] usb: typec: tcpm: add get max power support Frank Wang
2023-06-15 9:39 ` Greg KH
@ 2023-10-27 10:34 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Greg KH @ 2023-10-27 10:34 UTC (permalink / raw)
To: Frank Wang
Cc: sebastian.reichel, linux, heikki.krogerus, heiko, linux-usb,
linux-kernel, linux-rockchip, huangtao, william.wu, jianwei.zheng,
yubing.zhang, wmc
On Wed, Mar 22, 2023 at 05:31:20PM +0800, Frank Wang wrote:
> 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.
>
> Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
> ---
> 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-27 10:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-22 9:31 [PATCH v3] usb: typec: tcpm: add get max power support Frank Wang
2023-06-15 9:39 ` Greg KH
2023-06-16 1:48 ` Frank Wang
2023-10-27 10:34 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox