From nobody Mon Feb 9 11:47:40 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 241E715E88 for ; Thu, 15 Aug 2024 00:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723682071; cv=none; b=em6uLZPO99vNqE9iBQF5kZ6T/cSjKkIrgW+rM1rO+YLrp+kYuvMmIWYn7xjPtw7NXbT2yi2PYB/j0W7hZJar806dlzSlEhDW7WZvCcmNvTE7kGkaMFuqDhAk6jZ+22YmjEzdWbt72U9bOxLtC9ezwg2xbXvXDtIvHJ6dpq0wBtY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723682071; c=relaxed/simple; bh=BBU1xkfoU7eurOrPvpMLLeunHugd7h5FgxT2uZgKilM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C2/qbSz4mjbY0I6wU4G8LRI/wj67RPF2fIYWjPCcUIYzjXHyl6eitNMFC+Grw9btMxABVSa0xDspMtf2KbTya3EzBwvIlEdPjsjYXwaxk0dLsyOLOQco/+lKoEay+9MUeDfFIt89H/qaW9U4jTjNqApLyfTbfvg4UOWQ0Uy+x6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=lM2UJNep; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lM2UJNep" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-201d9fa899dso3632395ad.3 for ; Wed, 14 Aug 2024 17:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1723682069; x=1724286869; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gq/ZMzuLbA1llqpSY1LjTmocM7fXF6nFIOTFbEevr4E=; b=lM2UJNepXCgAimFRt7v9I3Ewr3kJm2wQ6Ms0WFrIr0OjWrRaPWKdgzxZZFg+xzzq+X bX4muyl+QxdJ8q/vNkLuoMLyW3DNGTigNhaB6k3o0TVW0ngcEvqF3X8tapkRBm3Ob6PM 6NKNeAwi+SbYyxTk+qos9MPuimU3w9L32deP4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723682069; x=1724286869; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gq/ZMzuLbA1llqpSY1LjTmocM7fXF6nFIOTFbEevr4E=; b=ZX8GabGQfzVrCD6KAnS2dvazpMjw6bVEXICao0elZSRjP4LNwfVF/wKCQMjDv/wY7v kt7JClFB02P2r3h1FIDabDd7KD21Q041/o7dKJ68EI8cO60E1QZt57h62taAVuuJx9la V4W55iRqMxn0TnWZLcNm5NSIuQ+14Lajx/UCQz0TUfrhh1OOC8XUJumwWwKUfuBzyJDJ ezZsJ+iO9wc/9QwsaNs8HB9IC8SLqNnuHxHHRGFPE7KQJk2LTWB1aJyeASjUY4/aMf01 eHyqQB5dzGW68RyZCoAyGzI1qjfVqEg+0dMkVQ7/tzY42TNjAH9bJ8OUOAS5K6a0uxdb tRrw== X-Gm-Message-State: AOJu0Yx5xjJajsSvZ9Le5Zuq85MAJ0LvFk/G4XXuNCKrnaLftXvBrFo9 MNop16wa2lnYQeMoQ7Levt9zisDUtAZsb8CRAG6ESK5BH3f7hBYHV77tDeq2Rw== X-Google-Smtp-Source: AGHT+IFq8j2VyEZ1BVNC68zp/NCCOurZ5Nog/t60mozUg9UPI/CSC7n9XcimPMI12CBkDG1lOi3FFw== X-Received: by 2002:a17:902:d507:b0:1fd:6598:613c with SMTP id d9443c01a7336-201d64b1531mr55994795ad.50.1723682069351; Wed, 14 Aug 2024 17:34:29 -0700 (PDT) Received: from localhost (210.73.125.34.bc.googleusercontent.com. [34.125.73.210]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-201f0394718sm1989155ad.226.2024.08.14.17.34.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 14 Aug 2024 17:34:28 -0700 (PDT) From: Stephen Boyd To: chrome-platform@lists.linux.dev Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, devicetree@vger.kernel.org, Douglas Anderson , Pin-yen Lin , Andrzej Hajda , Benson Leung , Conor Dooley , Daniel Vetter , David Airlie , Dmitry Baryshkov , dri-devel@lists.freedesktop.org, Guenter Roeck , Jernej Skrabec , Jonas Karlman , Krzysztof Kozlowski , Laurent Pinchart , Lee Jones , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Prashant Malani , Robert Foss , Rob Herring , Thomas Zimmermann , Tzung-Bi Shih Subject: [PATCH v2 04/11] drm/bridge: dp_typec: Support USB Type-C orientation Date: Wed, 14 Aug 2024 17:34:09 -0700 Message-ID: <20240815003417.1175506-5-swboyd@chromium.org> X-Mailer: git-send-email 2.46.0.76.ge559c4bf1a-goog In-Reply-To: <20240815003417.1175506-1-swboyd@chromium.org> References: <20240815003417.1175506-1-swboyd@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add an orientation parameter to drm_dp_typec_bridge_assign_pins() so that the DP lanes can be directed to the proper USB type-c pins on the connector when the cable is flipped. This is mostly useful for the case where the DP lanes are directly connected to the usb-c-connector and the device doesn't have an orientation switch wired down on the board between the connector and the DP controller. Flip the lanes to match the physical pin locations on the connector when the orientation is reverse. Cc: Prashant Malani Cc: Benson Leung Cc: Tzung-Bi Shih Cc: Cc: Pin-yen Lin Cc: Dmitry Baryshkov Signed-off-by: Stephen Boyd --- drivers/gpu/drm/bridge/aux-hpd-bridge.c | 44 ++++++++++++++++++------- include/drm/bridge/aux-bridge.h | 7 ++-- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/brid= ge/aux-hpd-bridge.c index 716b2220bdd5..79652d27db40 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -7,6 +7,7 @@ #include #include #include +#include #include =20 #include @@ -321,17 +322,35 @@ static int dp_lane_to_typec_lane(enum dp_lane lane) return -EINVAL; } =20 -static int typec_to_dp_lane(enum usb_ss_lane lane) +static int typec_to_dp_lane(enum usb_ss_lane lane, + enum typec_orientation orientation) { - switch (lane) { - case USB_SSRX1: - return DP_ML3; - case USB_SSTX1: - return DP_ML2; - case USB_SSTX2: - return DP_ML0; - case USB_SSRX2: - return DP_ML1; + switch (orientation) { + case TYPEC_ORIENTATION_NONE: + case TYPEC_ORIENTATION_NORMAL: + switch (lane) { + case USB_SSRX1: + return DP_ML3; + case USB_SSTX1: + return DP_ML2; + case USB_SSTX2: + return DP_ML0; + case USB_SSRX2: + return DP_ML1; + } + break; + case TYPEC_ORIENTATION_REVERSE: + switch (lane) { + case USB_SSRX1: + return DP_ML0; + case USB_SSTX1: + return DP_ML1; + case USB_SSTX2: + return DP_ML3; + case USB_SSRX2: + return DP_ML2; + } + break; } =20 return -EINVAL; @@ -341,6 +360,7 @@ static int typec_to_dp_lane(enum usb_ss_lane lane) * drm_dp_typec_bridge_assign_pins - Assign DisplayPort (DP) lanes to USB = type-C pins * @typec_bridge_dev: Device created for the type-c bridge * @conf: DisplayPort altmode configure command VDO content + * @orientation: Orientation of USB type-c port * @lane_mapping: Physical (array index) to logical (array value) USB type= -C lane mapping * * Assign DP lanes to the USB type-C pins for the DP altmode configuration @@ -351,7 +371,7 @@ static int typec_to_dp_lane(enum usb_ss_lane lane) * Return: 0 on success, negative value for failure. */ int drm_dp_typec_bridge_assign_pins(struct drm_dp_typec_bridge_dev *typec_= bridge_dev, - u32 conf, + u32 conf, enum typec_orientation orientation, enum usb_ss_lane lane_mapping[NUM_USB_SS]) { struct auxiliary_device *adev =3D &typec_bridge_dev->adev; @@ -388,7 +408,7 @@ int drm_dp_typec_bridge_assign_pins(struct drm_dp_typec= _bridge_dev *typec_bridge typec_lane =3D lane_mapping[typec_lane]; =20 /* Map logical type-c lane to logical DP lane */ - dp_lanes[i] =3D typec_to_dp_lane(typec_lane); + dp_lanes[i] =3D typec_to_dp_lane(typec_lane, orientation); } =20 return 0; diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridg= e.h index aaace808772c..258b87c93623 100644 --- a/include/drm/bridge/aux-bridge.h +++ b/include/drm/bridge/aux-bridge.h @@ -7,6 +7,8 @@ #ifndef DRM_AUX_BRIDGE_H #define DRM_AUX_BRIDGE_H =20 +#include + #include =20 struct auxiliary_device; @@ -53,7 +55,8 @@ int devm_drm_dp_typec_bridge_add(struct device *dev, stru= ct drm_dp_typec_bridge_ void drm_dp_typec_bridge_notify(struct drm_dp_typec_bridge_dev *typec_brid= ge_dev, enum drm_connector_status status); int drm_dp_typec_bridge_assign_pins(struct drm_dp_typec_bridge_dev *typec_= bridge_dev, u32 conf, - enum usb_ss_lane lane_mapping[NUM_USB_SS]); + enum typec_orientation orientation, + enum usb_ss_lane lane_mapping[NUM_USB_SS]); #else static inline struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct= device *parent, struct device_node *np) @@ -94,7 +97,7 @@ static inline void drm_dp_typec_bridge_notify(struct drm_= dp_typec_bridge_dev *ty } =20 static inline int drm_dp_typec_bridge_assign_pins(struct drm_dp_typec_brid= ge_dev *typec_bridge_dev, - u32 conf, + u32 conf, enum typec_orientation orientation, enum usb_ss_lane lane_mapping[NUM_USB_SS]) { return 0; --=20 https://chromeos.dev