From: Frank Wang <frank.wang@rock-chips.com>
To: Guenter Roeck <linux@roeck-us.net>,
heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org,
sebastian.reichel@collabora.com, heiko@sntech.de
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rockchip@lists.infradead.org, huangtao@rock-chips.com,
william.wu@rock-chips.com, jianwei.zheng@rock-chips.com,
yubing.zhang@rock-chips.com, wmc@rock-chips.com
Subject: Re: usb: typec: tcpm: add get max power support
Date: Fri, 16 Jun 2023 11:13:08 +0800 [thread overview]
Message-ID: <45886fef-b84a-5704-0a08-100a20296323@rock-chips.com> (raw)
In-Reply-To: <f6c9fc11-df51-5ff8-c744-3325c20643b0@roeck-us.net>
Hi Guenter,
On 2023/6/16 10:26, Guenter Roeck wrote:
> On 6/15/23 19:21, Frank Wang wrote:
>> Traverse fixed pdos to calculate the maximum power that the charger
>> can provide, and it can be got by POWER_SUPPLY_PROP_INPUT_POWER_LIMIT
>> property.
>>
>
> Wasn't this already v3 before ? What happened to the version, and the
> change log ?
> Or is this a completely different/new patch ?
>
Yes, it is the v3 patch before which has been hold for a long time,
Gregkh asked me to rebase it and resubmit, so should I also add an
"RESEND" tag in subject?
BR.
Frank
> Guenter
>
>> 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 9f6aaa3e70ca8..829d75ebab422 100644
>> --- a/drivers/usb/typec/tcpm/tcpm.c
>> +++ b/drivers/usb/typec/tcpm/tcpm.c
>> @@ -6340,6 +6340,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)
>> @@ -6369,6 +6390,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;
>
next prev parent reply other threads:[~2023-06-16 3:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 2:21 Frank Wang
2023-06-16 2:26 ` Guenter Roeck
2023-06-16 3:13 ` Frank Wang [this message]
2023-06-16 6:05 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45886fef-b84a-5704-0a08-100a20296323@rock-chips.com \
--to=frank.wang@rock-chips.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=heiko@sntech.de \
--cc=huangtao@rock-chips.com \
--cc=jianwei.zheng@rock-chips.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sebastian.reichel@collabora.com \
--cc=william.wu@rock-chips.com \
--cc=wmc@rock-chips.com \
--cc=yubing.zhang@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®