From: Jun Li <jun.li@nxp.com>
To: gregkh@linuxfoundation.org, hdegoede@redhat.com,
linux@roeck-us.net, heikki.krogerus@linux.intel.com,
Adam.Thomson.Opensource@diasemi.com, Badhri@google.com
Cc: linux-usb@vger.kernel.org, linux-imx@nxp.com
Subject: [RFC] usb: typec: tcpm: match source fixed pdo with sink variable pdo
Date: Tue, 13 Mar 2018 08:02:50 +0800 [thread overview]
Message-ID: <1520899370-11408-1-git-send-email-jun.li@nxp.com> (raw)
This patch tries to fix the problem describled on revert patch commit[1],
suppose any supported voltage ranges of sink should be describled by
variable pdo, so instead of revert the patch of only comparing source and
sink pdo to select one source pdo, this patch adds the match between source
fixed pdo and sink variable pdo.
[1] https://www.spinics.net/lists/linux-usb/msg166366.html
CC: Hans de Goede <hdegoede@redhat.com>
CC: Guenter Roeck <linux@roeck-us.net>
CC: Heikki Krogerus <heikki.krogerus@linux.intel.com>
CC: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
CC: Badhri Jagan Sridharan <Badhri@google.com>
Signed-off-by: Li Jun <jun.li@nxp.com>
---
drivers/usb/typec/tcpm.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c
index ef3a60d..8a74a43 100644
--- a/drivers/usb/typec/tcpm.c
+++ b/drivers/usb/typec/tcpm.c
@@ -1815,6 +1815,37 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo,
break;
}
}
+
+ /*
+ * If the source pdo has the same voltage with one
+ * fixed pdo, no need check variable pdo for it.
+ */
+ if (j < port->nr_fixed)
+ continue;
+
+ for (j = port->nr_fixed +
+ port->nr_batt;
+ j < port->nr_fixed +
+ port->nr_batt +
+ port->nr_var;
+ j++) {
+ if (pdo_fixed_voltage(pdo) >=
+ pdo_min_voltage(port->snk_pdo[j]) &&
+ pdo_fixed_voltage(pdo) <=
+ pdo_max_voltage(port->snk_pdo[j])) {
+ ma = min_current(pdo, port->snk_pdo[j]);
+ mv = pdo_fixed_voltage(pdo);
+ mw = ma * mv / 1000;
+ if (mw > max_mw ||
+ (mw == max_mw && mv > max_mv)) {
+ ret = 0;
+ *src_pdo = i;
+ *sink_pdo = j;
+ max_mw = mw;
+ max_mv = mv;
+ }
+ }
+ }
} else if (type == PDO_TYPE_BATT) {
for (j = port->nr_fixed;
j < port->nr_fixed +
next reply other threads:[~2018-03-13 0:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 0:02 Jun Li [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-03-13 11:36 [RFC] usb: typec: tcpm: match source fixed pdo with sink variable pdo Hans de Goede
2018-03-13 11:41 Hans de Goede
2018-03-14 9:32 Jun Li
2018-03-14 10:38 Hans de Goede
2018-03-19 9:43 Jun Li
2018-03-19 9:45 Hans de Goede
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=1520899370-11408-1-git-send-email-jun.li@nxp.com \
--to=jun.li@nxp.com \
--cc=Adam.Thomson.Opensource@diasemi.com \
--cc=Badhri@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-imx@nxp.com \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
/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;
as well as URLs for NNTP newsgroup(s).