Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8818363rwl; Tue, 10 Jan 2023 20:11:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvsueTcfQZ688UJStp614/EIm42CA6R7ldjGB12mPySK9w88LWuF4+6sGL6N2NLf1gue1s3 X-Received: by 2002:a17:906:aec3:b0:7c0:f719:838d with SMTP id me3-20020a170906aec300b007c0f719838dmr67699234ejb.36.1673410293439; Tue, 10 Jan 2023 20:11:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673410293; cv=none; d=google.com; s=arc-20160816; b=GNFMPiN7Wj5sc5+CTHhgEtNu/4NLznsyuLnWDfCBHzYWDE25MR9EAeNxtdFF5j0QeU OU8pD6+dFUVNXNH05EnLr9maAvmxrz6hnp6WTjiEiVovH3Gh/FG47q9fd3ic+mD7WUlG gxwEJbAnV3tAuuih4qEchk2BB/0aYZxBoG26CllEtlzdPO9Xku3d+LD+gqbk1ZaXRbPR zNpmbHbkVDdKyZKuwHZbj2UBL+VGIJLaU6tZsDez5C6kGCc4XG3j9a9dXVaC6AjAJJ0M DkuElmD2y1CrfEF+V5xt+cGywrsmFV5NgeTDUT2RaZho4/ZdxxDrMRurAStQvgkKPob/ H9Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jqmRSD6VKdYWZ+SJv6ehJPDhj3p2v9Nk0+3Tds66tis=; b=z+4vGYkHKpACraZfKqhGy1XNn/6JZD261DbPgvbelVDpQBSFmrUbP/Ev33jsx5C6xu rETSSakQ0Be0p7/fbQaTA6QZ8nn7pKdTGLHYDbDXfGU2gxCVeOkSEXGRsEiBF9f1tk1E +JyMM+Z+q1R1nm2rI6xHoeRlBVLPzfcs9EugpDXoTQCwIrsQafpCS60Y9vDDo2eN1BXp wR8egjzN+C5Cj/jFImHQEECmZup3pfs1wuKEZuxH6D1Gcwm+Pvkb846OLo/eMVC+Qwmb RUsP3z5hi3o5v6inWCNRtqarzPINEVwiz7TSq4cLo1xsAYPFPwVRvEADgl5nXp1w4hmH iRSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hYrLw3Cw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb9-20020a170907160900b008546dff75e0si3933059ejc.901.2023.01.10.20.11.18; Tue, 10 Jan 2023 20:11:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=hYrLw3Cw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235715AbjAKDcC (ORCPT + 54 others); Tue, 10 Jan 2023 22:32:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235716AbjAKDbj (ORCPT ); Tue, 10 Jan 2023 22:31:39 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90D3217588 for ; Tue, 10 Jan 2023 19:31:23 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id 3so7061574iou.12 for ; Tue, 10 Jan 2023 19:31:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jqmRSD6VKdYWZ+SJv6ehJPDhj3p2v9Nk0+3Tds66tis=; b=hYrLw3Cw5Sm66XPWhcU5vNYulWczhbyiQqdcFNuy+4k/u6bm/NzuBZNNsI/Yenxhvx O6mOhYJcQFwaJmYLCeAs1cL1EB+eYs/h5RlLVFsNM/PCz9QvNfvVQpR/h+32PBrmZTW7 iHwR3xCpoeq+pHQ7+PHCBOkydqGoLGFgP2SAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jqmRSD6VKdYWZ+SJv6ehJPDhj3p2v9Nk0+3Tds66tis=; b=D01CweYPAI1YpPH6cuiQ82TQ2GjLlDerGkH4WW81l17gnd/eT2BVyoLkJjPzNQTG8Q X2CuKL15q9pOU3QtBA2b1hlklzwaJmpRTYEBrhedF6u2DOnxLF8b0n2p5RKqbXLERJQ1 ehoqDdclYYHylVb8YJExxSTuTFNJNHJwUAA9NcJFfsb3XCWKsAZ0AX1Tx/6rmLTVegys mD6+D+hHSPcnMLAFRUb58B9T7PMI8fiJEx4hKhzgXpbKYKj4Jw/5VEHdTvJP54TmZYC7 zKAPuINMGy/dY8GdoLAuPE8fKe1hQs5y7O0KdVdlVOb/b/RAoc1r0g9ZX86CERCChRz6 7s/Q== X-Gm-Message-State: AFqh2kqEkLRj12at8N48UxmWbCEOKpT9JdEx3xL37sjqD9mg5Ppvl6BZ HtlDDo+BUqIBRy7NxkiW29sCvODH2GLTK8az/jwYqw== X-Received: by 2002:a5e:c00f:0:b0:6e3:38c6:e35f with SMTP id u15-20020a5ec00f000000b006e338c6e35fmr6266793iol.153.1673407882942; Tue, 10 Jan 2023 19:31:22 -0800 (PST) MIME-Version: 1.0 References: <20230109084101.265664-1-treapking@chromium.org> <20230109084101.265664-7-treapking@chromium.org> In-Reply-To: From: Pin-yen Lin Date: Wed, 11 Jan 2023 11:31:12 +0800 Message-ID: Subject: Re: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches To: Chen-Yu Tsai Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Prashant Malani , Benson Leung , Guenter Roeck , Marek Vasut , devicetree@vger.kernel.org, =?UTF-8?B?TsOtY29sYXMgRiAuIFIgLiBBIC4gUHJhZG8=?= , linux-acpi@vger.kernel.org, Allen Chen , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Javier Martinez Canillas , dri-devel@lists.freedesktop.org, Stephen Boyd , Thomas Zimmermann , Hsin-Yi Wang , chrome-platform@lists.linux.dev, Xin Ji , linux-kernel@vger.kernel.org, AngeloGioacchino Del Regno Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Chen-Yu, Thanks for the review. On Mon, Jan 9, 2023 at 7:26 PM Chen-Yu Tsai wrote: > > On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin wrote: > > > > Register USB Type-C mode switches when the "mode-switch" property and > > relevant port are available in Device Tree. Configure the crosspoint > ^ ports > Thanks for catching this. I'll fix in v10. > > switch based on the entered alternate mode for a specific Type-C > > connector. > > You should also mention that the "one mode switch" scenario is not > covered in this implementation, due to lack of actual hardware. If I understand correctly, we should use "orientation-switch"[1] instead when the crosspoint switch on anx7625 is used to support different orientations of the Type-C connector. I'll add some explanations around this in the commit message in v10. [1]: https://docs.kernel.org/driver-api/usb/typec.html#multiplexer-demultiplexer-switches > > > Signed-off-by: Pin-yen Lin > > > > --- > > > > (no changes since v7) > > > > Changes in v7: > > - Fixed style issues in anx7625 driver > > - Removed DT property validation in anx7625 driver. > > - Extracted common codes to another commit. > > > > Changes in v6: > > - Squashed to a single patch > > > > drivers/gpu/drm/bridge/analogix/Kconfig | 1 + > > drivers/gpu/drm/bridge/analogix/anx7625.c | 88 +++++++++++++++++++++++ > > drivers/gpu/drm/bridge/analogix/anx7625.h | 13 ++++ > > 3 files changed, 102 insertions(+) > > > > diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig > > index 173dada218ec..992b43ed1dd7 100644 > > --- a/drivers/gpu/drm/bridge/analogix/Kconfig > > +++ b/drivers/gpu/drm/bridge/analogix/Kconfig > > @@ -34,6 +34,7 @@ config DRM_ANALOGIX_ANX7625 > > tristate "Analogix Anx7625 MIPI to DP interface support" > > depends on DRM > > depends on OF > > + depends on TYPEC || TYPEC=n > > select DRM_DISPLAY_DP_HELPER > > select DRM_DISPLAY_HDCP_HELPER > > select DRM_DISPLAY_HELPER > > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c > > index 1cf242130b91..2bb504a8d789 100644 > > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c > > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c > > @@ -15,6 +15,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > #include > > > > #include > > @@ -2572,6 +2574,86 @@ static void anx7625_runtime_disable(void *data) > > pm_runtime_disable(data); > > } > > > > +static void anx7625_set_crosspoint_switch(struct anx7625_data *ctx, > > + enum typec_orientation orientation) > > +{ > > + if (orientation == TYPEC_ORIENTATION_NORMAL) { > > + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_0, > > + SW_SEL1_SSRX_RX1 | SW_SEL1_DPTX0_RX2); > > + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_1, > > + SW_SEL2_SSTX_TX1 | SW_SEL2_DPTX1_TX2); > > + } else if (orientation == TYPEC_ORIENTATION_REVERSE) { > > + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_0, > > + SW_SEL1_SSRX_RX2 | SW_SEL1_DPTX0_RX1); > > + anx7625_reg_write(ctx, ctx->i2c.tcpc_client, TCPC_SWITCH_1, > > + SW_SEL2_SSTX_TX2 | SW_SEL2_DPTX1_TX1); > > + } > > +} > > + > > +static void anx7625_typec_two_ports_update(struct anx7625_data *ctx) > > +{ > > + struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; > > + /* Check if both ports available and do nothing to retain the current one */ > > + if (switch_desc.typec_ports[0].dp_connected && switch_desc.typec_ports[1].dp_connected) > > + return; > > + > > + if (switch_desc.typec_ports[0].dp_connected) > > + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_NORMAL); > > + else if (switch_desc.typec_ports[1].dp_connected) > > + anx7625_set_crosspoint_switch(ctx, TYPEC_ORIENTATION_REVERSE); > > +} > > + > > +static int anx7625_typec_mux_set(struct typec_mux_dev *mux, > > + struct typec_mux_state *state) > > +{ > > + struct drm_dp_typec_port_data *port_data = typec_mux_get_drvdata(mux); > > + struct anx7625_data *ctx = (struct anx7625_data *) port_data->data; > > + struct device *dev = &ctx->client->dev; > > + struct drm_dp_typec_switch_desc switch_desc = ctx->switch_desc; > > + bool new_dp_connected, old_dp_connected; > > + > > And place a TODO note here. I'll add it in v10. > > Otherwise this looks OK. > > Also, > > Tested-by: Chen-Yu Tsai > on MT8192 based Hayato (ASUS Chromebook Flip CM3200). > > And this also uncovered a deadlock in the unplug & disable path. > I'll send a fix for that later once I figure out all the details. Thank you so much for this!