public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jameson Thies <jthies@google.com>
To: heikki.krogerus@linux.intel.com, linux-usb@vger.kernel.org
Cc: jthies@google.com, bleung@google.com,
	abhishekpandit@chromium.org,  andersson@kernel.org,
	dmitry.baryshkov@linaro.org,  fabrice.gasnier@foss.st.com,
	gregkh@linuxfoundation.org, hdegoede@redhat.com,
	 neil.armstrong@linaro.org, rajaram.regupathy@intel.com,
	 saranya.gopal@intel.com, linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/4] usb: typec: ucsi: Add USB PD DRP to USB type
Date: Wed, 24 Jul 2024 20:11:14 +0000	[thread overview]
Message-ID: <20240724201116.2094059-3-jthies@google.com> (raw)
In-Reply-To: <20240724201116.2094059-1-jthies@google.com>

Add POWER_SUPPLY_USB_TYPE_PD_DRP as a USB type in the UCSI power supply
driver. The DRP type is set when the partner sets the DRP bit in one of
the source PDOs.

Signed-off-by: Jameson Thies <jthies@google.com>
---
Changes in V2:
- Using DRP bit of source PDOs to determine USB type. Updated commit
message.

 drivers/usb/typec/ucsi/psy.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/psy.c b/drivers/usb/typec/ucsi/psy.c
index d0b52cee41d2..d708f9eb1654 100644
--- a/drivers/usb/typec/ucsi/psy.c
+++ b/drivers/usb/typec/ucsi/psy.c
@@ -204,8 +204,17 @@ static int ucsi_psy_get_usb_type(struct ucsi_connector *con,
 
 	val->intval = POWER_SUPPLY_USB_TYPE_C;
 	if (flags & UCSI_CONSTAT_CONNECTED &&
-	    UCSI_CONSTAT_PWR_OPMODE(flags) == UCSI_CONSTAT_PWR_OPMODE_PD)
+	    UCSI_CONSTAT_PWR_OPMODE(flags) == UCSI_CONSTAT_PWR_OPMODE_PD) {
+		for (int i = 0; i < con->num_pdos; i++) {
+			if (pdo_type(con->src_pdos[i]) == PDO_TYPE_FIXED &&
+			    con->src_pdos[i] & PDO_FIXED_DUAL_ROLE) {
+				val->intval = POWER_SUPPLY_USB_TYPE_PD_DRP;
+				return 0;
+			}
+		}
+
 		val->intval = POWER_SUPPLY_USB_TYPE_PD;
+	}
 
 	return 0;
 }
@@ -275,6 +284,7 @@ static enum power_supply_usb_type ucsi_psy_usb_types[] = {
 	POWER_SUPPLY_USB_TYPE_C,
 	POWER_SUPPLY_USB_TYPE_PD,
 	POWER_SUPPLY_USB_TYPE_PD_PPS,
+	POWER_SUPPLY_USB_TYPE_PD_DRP,
 };
 
 int ucsi_register_port_psy(struct ucsi_connector *con)
-- 
2.45.2.1089.g2a221341d9-goog


  parent reply	other threads:[~2024-07-24 20:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-24 20:11 [PATCH v2 0/4] usb: typec: ucsi: Expand power supply support Jameson Thies
2024-07-24 20:11 ` [PATCH v2 1/4] usb: typec: ucsi: Add status to UCSI power supply driver Jameson Thies
2024-07-25  3:31   ` Dmitry Baryshkov
2024-07-26 21:30     ` Sebastian Reichel
2024-07-27 11:02       ` Dmitry Baryshkov
2024-07-24 20:11 ` Jameson Thies [this message]
2024-07-24 20:11 ` [PATCH v2 3/4] usb: typec: ucsi: Set sink path based on UCSI charge control Jameson Thies
2024-07-25  4:07   ` Dmitry Baryshkov
2024-07-25 19:11     ` Jameson Thies
2024-07-24 20:11 ` [PATCH v2 4/4] usb: typec: ucsi: Fix SET_PDR typo in UCSI header file Jameson Thies
2024-07-25  3:51   ` Dmitry Baryshkov
2024-07-25 18:04     ` Jameson Thies

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=20240724201116.2094059-3-jthies@google.com \
    --to=jthies@google.com \
    --cc=abhishekpandit@chromium.org \
    --cc=andersson@kernel.org \
    --cc=bleung@google.com \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=fabrice.gasnier@foss.st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rajaram.regupathy@intel.com \
    --cc=saranya.gopal@intel.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