Re: [PATCH] usb: typec: ptn36502: switch to DRM_AUX_BRIDGE

From: Heikki Krogerus
Date: Mon Mar 18 2024 - 07:12:55 EST


On Fri, Mar 15, 2024 at 05:04:22PM +0100, Luca Weiss wrote:
> Switch to using the new DRM_AUX_BRIDGE helper to create the transparent
> DRM bridge device instead of handcoding corresponding functionality.
>
> Signed-off-by: Luca Weiss <luca.weiss@xxxxxxxxxxxxx>

Reviewed-by: Heikki Krogerus <heikki.krogerus@xxxxxxxxxxxxxxx>

> ---
> Very similar to this patch:
> c5d296bad640 ("usb: typec: nb7vpq904m: switch to DRM_AUX_BRIDGE")
> ---
> drivers/usb/typec/mux/Kconfig | 2 +-
> drivers/usb/typec/mux/ptn36502.c | 44 ++--------------------------------------
> 2 files changed, 3 insertions(+), 43 deletions(-)
>
> diff --git a/drivers/usb/typec/mux/Kconfig b/drivers/usb/typec/mux/Kconfig
> index 399c7b0983df..4827e86fed6d 100644
> --- a/drivers/usb/typec/mux/Kconfig
> +++ b/drivers/usb/typec/mux/Kconfig
> @@ -60,7 +60,7 @@ config TYPEC_MUX_PTN36502
> tristate "NXP PTN36502 Type-C redriver driver"
> depends on I2C
> depends on DRM || DRM=n
> - select DRM_PANEL_BRIDGE if DRM
> + select DRM_AUX_BRIDGE if DRM_BRIDGE
> select REGMAP_I2C
> help
> Say Y or M if your system has a NXP PTN36502 Type-C redriver chip
> diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c
> index 72ae38a1b2be..0ec86ef32a87 100644
> --- a/drivers/usb/typec/mux/ptn36502.c
> +++ b/drivers/usb/typec/mux/ptn36502.c
> @@ -8,7 +8,7 @@
> * Copyright (C) 2023 Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx>
> */
>
> -#include <drm/drm_bridge.h>
> +#include <drm/bridge/aux-bridge.h>
> #include <linux/bitfield.h>
> #include <linux/i2c.h>
> #include <linux/kernel.h>
> @@ -68,8 +68,6 @@ struct ptn36502 {
>
> struct typec_switch *typec_switch;
>
> - struct drm_bridge bridge;
> -
> struct mutex lock; /* protect non-concurrent retimer & switch */
>
> enum typec_orientation orientation;
> @@ -283,44 +281,6 @@ static int ptn36502_detect(struct ptn36502 *ptn)
> return 0;
> }
>
> -#if IS_ENABLED(CONFIG_OF) && IS_ENABLED(CONFIG_DRM_PANEL_BRIDGE)
> -static int ptn36502_bridge_attach(struct drm_bridge *bridge,
> - enum drm_bridge_attach_flags flags)
> -{
> - struct ptn36502 *ptn = container_of(bridge, struct ptn36502, bridge);
> - struct drm_bridge *next_bridge;
> -
> - if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
> - return -EINVAL;
> -
> - next_bridge = devm_drm_of_get_bridge(&ptn->client->dev, ptn->client->dev.of_node, 0, 0);
> - if (IS_ERR(next_bridge)) {
> - dev_err(&ptn->client->dev, "failed to acquire drm_bridge: %pe\n", next_bridge);
> - return PTR_ERR(next_bridge);
> - }
> -
> - return drm_bridge_attach(bridge->encoder, next_bridge, bridge,
> - DRM_BRIDGE_ATTACH_NO_CONNECTOR);
> -}
> -
> -static const struct drm_bridge_funcs ptn36502_bridge_funcs = {
> - .attach = ptn36502_bridge_attach,
> -};
> -
> -static int ptn36502_register_bridge(struct ptn36502 *ptn)
> -{
> - ptn->bridge.funcs = &ptn36502_bridge_funcs;
> - ptn->bridge.of_node = ptn->client->dev.of_node;
> -
> - return devm_drm_bridge_add(&ptn->client->dev, &ptn->bridge);
> -}
> -#else
> -static int ptn36502_register_bridge(struct ptn36502 *ptn)
> -{
> - return 0;
> -}
> -#endif
> -
> static const struct regmap_config ptn36502_regmap = {
> .max_register = 0x0d,
> .reg_bits = 8,
> @@ -369,7 +329,7 @@ static int ptn36502_probe(struct i2c_client *client)
> if (ret)
> goto err_disable_regulator;
>
> - ret = ptn36502_register_bridge(ptn);
> + ret = drm_aux_bridge_register(dev);
> if (ret)
> goto err_disable_regulator;
>
>
> ---
> base-commit: 9bb9b28d0568991b1d63e66fe75afa5f97ad1156
> change-id: 20240315-ptn36502-aux-15dd6f289aff
>
> Best regards,
> --
> Luca Weiss <luca.weiss@xxxxxxxxxxxxx>

--
heikki