Commit 9dc28ea2 authored by Luca Weiss's avatar Luca Weiss Committed by Greg Kroah-Hartman

usb: typec: ptn36502: switch to DRM_AUX_BRIDGE

Switch to using the new DRM_AUX_BRIDGE helper to create the transparent
DRM bridge device instead of handcoding corresponding functionality.
Signed-off-by: default avatarLuca Weiss <luca.weiss@fairphone.com>
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240315-ptn36502-aux-v1-1-c9d3c828ff2e@fairphone.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 10cfb14d
...@@ -60,7 +60,7 @@ config TYPEC_MUX_PTN36502 ...@@ -60,7 +60,7 @@ config TYPEC_MUX_PTN36502
tristate "NXP PTN36502 Type-C redriver driver" tristate "NXP PTN36502 Type-C redriver driver"
depends on I2C depends on I2C
depends on DRM || DRM=n depends on DRM || DRM=n
select DRM_PANEL_BRIDGE if DRM select DRM_AUX_BRIDGE if DRM_BRIDGE
select REGMAP_I2C select REGMAP_I2C
help help
Say Y or M if your system has a NXP PTN36502 Type-C redriver chip Say Y or M if your system has a NXP PTN36502 Type-C redriver chip
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Copyright (C) 2023 Dmitry Baryshkov <dmitry.baryshkov@linaro.org> * Copyright (C) 2023 Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
*/ */
#include <drm/drm_bridge.h> #include <drm/bridge/aux-bridge.h>
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -68,8 +68,6 @@ struct ptn36502 { ...@@ -68,8 +68,6 @@ struct ptn36502 {
struct typec_switch *typec_switch; struct typec_switch *typec_switch;
struct drm_bridge bridge;
struct mutex lock; /* protect non-concurrent retimer & switch */ struct mutex lock; /* protect non-concurrent retimer & switch */
enum typec_orientation orientation; enum typec_orientation orientation;
...@@ -283,44 +281,6 @@ static int ptn36502_detect(struct ptn36502 *ptn) ...@@ -283,44 +281,6 @@ static int ptn36502_detect(struct ptn36502 *ptn)
return 0; 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 = { static const struct regmap_config ptn36502_regmap = {
.max_register = 0x0d, .max_register = 0x0d,
.reg_bits = 8, .reg_bits = 8,
...@@ -369,7 +329,7 @@ static int ptn36502_probe(struct i2c_client *client) ...@@ -369,7 +329,7 @@ static int ptn36502_probe(struct i2c_client *client)
if (ret) if (ret)
goto err_disable_regulator; goto err_disable_regulator;
ret = ptn36502_register_bridge(ptn); ret = drm_aux_bridge_register(dev);
if (ret) if (ret)
goto err_disable_regulator; goto err_disable_regulator;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment