lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXv+5E=-=cPGSi1eEDAkTm+RvuJNU4zeZOxunpR7r4+RgzNYA@mail.gmail.com>
Date:   Mon, 9 Jan 2023 19:26:32 +0800
From:   Chen-Yu Tsai <wenst@...omium.org>
To:     Pin-yen Lin <treapking@...omium.org>
Cc:     Andrzej Hajda <andrzej.hajda@...el.com>,
        Neil Armstrong <neil.armstrong@...aro.org>,
        Robert Foss <robert.foss@...aro.org>,
        Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        Jonas Karlman <jonas@...boo.se>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        David Airlie <airlied@...il.com>,
        Daniel Vetter <daniel@...ll.ch>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Daniel Scally <djrscally@...il.com>,
        Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
        Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J . Wysocki" <rafael@...nel.org>,
        Prashant Malani <pmalani@...omium.org>,
        Benson Leung <bleung@...omium.org>,
        Guenter Roeck <groeck@...omium.org>,
        Marek Vasut <marex@...x.de>, devicetree@...r.kernel.org,
        Nícolas F . R . A . Prado 
        <nfraprado@...labora.com>, linux-acpi@...r.kernel.org,
        Allen Chen <allen.chen@....com.tw>,
        Uwe Kleine-König 
        <u.kleine-koenig@...gutronix.de>,
        Javier Martinez Canillas <javierm@...hat.com>,
        dri-devel@...ts.freedesktop.org,
        Stephen Boyd <swboyd@...omium.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Hsin-Yi Wang <hsinyi@...omium.org>,
        chrome-platform@...ts.linux.dev, Xin Ji <xji@...logixsemi.com>,
        linux-kernel@...r.kernel.org,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>
Subject: Re: [PATCH v9 6/9] drm/bridge: anx7625: Register Type C mode switches

On Mon, Jan 9, 2023 at 4:41 PM Pin-yen Lin <treapking@...omium.org> wrote:
>
> Register USB Type-C mode switches when the "mode-switch" property and
> relevant port are available in Device Tree. Configure the crosspoint
           ^ ports

> 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.

> Signed-off-by: Pin-yen Lin <treapking@...omium.org>
>
> ---
>
> (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 <linux/regulator/consumer.h>
>  #include <linux/slab.h>
>  #include <linux/types.h>
> +#include <linux/usb/typec_dp.h>
> +#include <linux/usb/typec_mux.h>
>  #include <linux/workqueue.h>
>
>  #include <linux/of_gpio.h>
> @@ -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.

Otherwise this looks OK.

Also,

Tested-by: Chen-Yu Tsai <wenst@...omium.org>
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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ