Re: [PATCH v2 2/2] drm/bridge: add support for TI TDP158

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 25, 2024 at 06:38:13PM GMT, Marc Gonzalez wrote:
> The TI TDP158 is an AC-Coupled HDMI signal to TMDS Redriver supporting
> DVI 1.0 and HDMI 1.4b and 2.0b output signals.
> 
> The default settings work fine for our use-case.
> 
> Signed-off-by: Marc Gonzalez <mgonzalez@xxxxxxxxxx>
> ---
>  drivers/gpu/drm/bridge/Kconfig     |   6 +++
>  drivers/gpu/drm/bridge/Makefile    |   1 +
>  drivers/gpu/drm/bridge/ti-tdp158.c | 103 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 110 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
> index c621be1a99a89..0859f85cb4b69 100644
> --- a/drivers/gpu/drm/bridge/Kconfig
> +++ b/drivers/gpu/drm/bridge/Kconfig
> @@ -368,6 +368,12 @@ config DRM_TI_DLPC3433
>  	  It supports up to 720p resolution with 60 and 120 Hz refresh
>  	  rates.
>  
> +config DRM_TI_TDP158
> +	tristate "TI TDP158 HDMI/TMDS bridge"
> +	depends on OF
> +	help
> +	  Texas Instruments TDP158 HDMI/TMDS Bridge driver

Please run ./scripts/checkpatch.pl on your patch.

> +
>  config DRM_TI_TFP410
>  	tristate "TI TFP410 DVI/HDMI bridge"
>  	depends on OF
> diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
> index 7df87b582dca3..3daf803ce80b6 100644
> --- a/drivers/gpu/drm/bridge/Makefile
> +++ b/drivers/gpu/drm/bridge/Makefile
> @@ -32,6 +32,7 @@ obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
>  obj-$(CONFIG_DRM_TI_DLPC3433) += ti-dlpc3433.o
>  obj-$(CONFIG_DRM_TI_SN65DSI83) += ti-sn65dsi83.o
>  obj-$(CONFIG_DRM_TI_SN65DSI86) += ti-sn65dsi86.o
> +obj-$(CONFIG_DRM_TI_TDP158) += ti-tdp158.o
>  obj-$(CONFIG_DRM_TI_TFP410) += ti-tfp410.o
>  obj-$(CONFIG_DRM_TI_TPD12S015) += ti-tpd12s015.o
>  obj-$(CONFIG_DRM_NWL_MIPI_DSI) += nwl-dsi.o
> diff --git a/drivers/gpu/drm/bridge/ti-tdp158.c b/drivers/gpu/drm/bridge/ti-tdp158.c
> new file mode 100644
> index 0000000000000..b65132e3598fc
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/ti-tdp158.c
> @@ -0,0 +1,103 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright 2024 Freebox SAS
> + */
> +#include <drm/drm_bridge.h>
> +#include <drm/drm_atomic_helper.h>
> +#include <linux/i2c.h>
> +
> +struct tdp158 {
> +	struct drm_bridge bridge;
> +	struct drm_bridge *next;
> +	struct gpio_desc *enable; // Operation Enable - pin 36
> +	struct regulator *vcc; // 3.3V
> +	struct regulator *vdd; // 1.1V
> +};
> +
> +static void tdp158_enable(struct drm_bridge *bridge, struct drm_bridge_state *prev)
> +{
> +	int err;
> +	struct tdp158 *tdp158 = bridge->driver_private;
> +
> +	if ((err = regulator_enable(tdp158->vcc)))
> +		pr_err("%s: vcc: %d", __func__, err);

- dev_err
- please expand error messages
- ERROR: do not use assignment in if condition

> +
> +	if ((err = regulator_enable(tdp158->vdd)))
> +		pr_err("%s: vdd: %d", __func__, err);
> +
> +	gpiod_set_value_cansleep(tdp158->enable, 1);
> +}
> +
> +static void tdp158_disable(struct drm_bridge *bridge, struct drm_bridge_state *prev)
> +{
> +	struct tdp158 *tdp158 = bridge->driver_private;
> +
> +	gpiod_set_value_cansleep(tdp158->enable, 0);
> +	regulator_disable(tdp158->vdd);
> +	regulator_disable(tdp158->vcc);
> +}
> +
> +static int tdp158_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags)
> +{
> +	struct tdp158 *tdp158 = bridge->driver_private;

empty line

> +	return drm_bridge_attach(bridge->encoder, tdp158->next, bridge, DRM_BRIDGE_ATTACH_NO_CONNECTOR);

No. Pass flags directly.

> +}
> +
> +static const struct drm_bridge_funcs tdp158_bridge_funcs = {
> +	.attach = tdp158_attach,
> +	.atomic_enable = tdp158_enable,
> +	.atomic_disable = tdp158_disable,
> +	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
> +	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
> +	.atomic_reset = drm_atomic_helper_bridge_reset,
> +};
> +
> +static int tdp158_bridge_probe(struct i2c_client *client)
> +{
> +	struct tdp158 *tdp158;
> +	struct device *dev = &client->dev;
> +
> +	tdp158 = devm_kzalloc(dev, sizeof(*tdp158), GFP_KERNEL);
> +	if (!tdp158)
> +		return -ENOMEM;
> +
> +	tdp158->next = devm_drm_of_get_bridge(dev, dev->of_node, 1, 0);

Missing `select DRM_PANEL_BRIDGE`

> +	if (IS_ERR(tdp158->next))
> +		return dev_err_probe(dev, PTR_ERR(tdp158->next), "next");

This results in a cryptic message 'foo: ESOMETHING: next'. Please
expand.

> +
> +	tdp158->vcc = devm_regulator_get(dev, "vcc");
> +	if (IS_ERR(tdp158->vcc))
> +		return dev_err_probe(dev, PTR_ERR(tdp158->vcc), "vcc");
> +
> +	tdp158->vdd = devm_regulator_get(dev, "vdd");
> +	if (IS_ERR(tdp158->vdd))
> +		return dev_err_probe(dev, PTR_ERR(tdp158->vdd), "vdd");
> +
> +	tdp158->enable = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
> +	if (IS_ERR(tdp158->enable))
> +		return dev_err_probe(dev, PTR_ERR(tdp158->enable), "enable");
> +
> +	tdp158->bridge.of_node = dev->of_node;
> +	tdp158->bridge.funcs = &tdp158_bridge_funcs;
> +	tdp158->bridge.driver_private = tdp158;
> +
> +	return devm_drm_bridge_add(dev, &tdp158->bridge);
> +}
> +
> +static const struct of_device_id tdp158_bridge_match_table[] = {
> +	{ .compatible = "ti,tdp158" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, tdp158_bridge_match_table);
> +
> +static struct i2c_driver tdp158_bridge_driver = {
> +	.probe = tdp158_bridge_probe,
> +	.driver = {
> +		.name = "tdp158-bridge",
> +		.of_match_table = tdp158_bridge_match_table,
> +	},
> +};
> +module_i2c_driver(tdp158_bridge_driver);
> +
> +MODULE_DESCRIPTION("TI TDP158 driver");
> +MODULE_LICENSE("GPL");
> 
> -- 
> 2.34.1
> 

-- 
With best wishes
Dmitry



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux