diff mbox series

[2/4] drm/panel: ilitek-ili9881c: Add support for two-lane configuration

Message ID 20250408-feature_sfto340xc-v1-2-f303d1b9a996@bootlin.com (mailing list archive)
State New, archived
Headers show
Series Add support for Saef SFTO340XC panel. | expand

Commit Message

Kory Maincent April 8, 2025, 3:27 p.m. UTC
Enable support for two-lane configuration which is done by setting the
LANSEL_SW_EN and LANSEL_SW bits in the Pad Control register.

Use the dsi-lanes device tree parameter to configure the number of lanes.
The default configuration remains set to four lanes.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 35 +++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

Comments

Dmitry Baryshkov April 10, 2025, 9:34 a.m. UTC | #1
On Tue, Apr 08, 2025 at 05:27:01PM +0200, Kory Maincent wrote:
> Enable support for two-lane configuration which is done by setting the
> LANSEL_SW_EN and LANSEL_SW bits in the Pad Control register.
> 
> Use the dsi-lanes device tree parameter to configure the number of lanes.
> The default configuration remains set to four lanes.
> 
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
>  drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 35 +++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> index 28cd7560e5db1d5734b10babdb4e4e553c6e07d0..5c429715159755df2461063dad0971642e2b9041 100644
> --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> @@ -1263,6 +1263,21 @@ static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
>  	return 0;
>  }
>  
> +static int ili9881c_set_lanes_cfg(struct ili9881c *ctx)
> +{
> +	int ret;
> +
> +	if (ctx->dsi->lanes != 2)
> +		/* Nothing to do */
> +		return 0;
> +
> +	ret = ili9881c_switch_page(ctx, 1);
> +	if (ret)
> +		return ret;
> +
> +	return ili9881c_send_cmd_data(ctx, 0xB7, 0x3);
> +}
> +
>  static int ili9881c_prepare(struct drm_panel *panel)
>  {
>  	struct ili9881c *ctx = panel_to_ili9881c(panel);
> @@ -1295,6 +1310,10 @@ static int ili9881c_prepare(struct drm_panel *panel)
>  			return ret;
>  	}
>  
> +	ret = ili9881c_set_lanes_cfg(ctx);
> +	if (ret)
> +		return ret;
> +
>  	ret = ili9881c_switch_page(ctx, 0);
>  	if (ret)
>  		return ret;
> @@ -1504,7 +1523,7 @@ static const struct drm_panel_funcs ili9881c_funcs = {
>  static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
>  {
>  	struct ili9881c *ctx;
> -	int ret;
> +	int ret, lanes;
>  
>  	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
>  	if (!ctx)
> @@ -1545,11 +1564,23 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
>  	if (ret)
>  		return ret;
>  
> +	ret = of_property_read_u32(dsi->dev.of_node, "dsi-lanes", &lanes);

Use dsi->lanes instead.

> +	if (ret == -EINVAL) {
> +		lanes = 4;
> +	} else if (ret) {
> +		dev_err(&dsi->dev, "Failed to get dsi-lanes property (%d)\n",
> +			ret);
> +		return ret;
> +	} else if (lanes < 2 || 4 < lanes) {
> +		dev_err(&dsi->dev, "Wrong number of dsi-lanes (%d)\n", lanes);
> +		return -EINVAL;
> +	}
> +
>  	drm_panel_add(&ctx->panel);
>  
>  	dsi->mode_flags = ctx->desc->mode_flags;
>  	dsi->format = MIPI_DSI_FMT_RGB888;
> -	dsi->lanes = 4;
> +	dsi->lanes = lanes;
>  
>  	return mipi_dsi_attach(dsi);
>  }
> 
> -- 
> 2.34.1
>
Dmitry Baryshkov April 10, 2025, 9:47 a.m. UTC | #2
On Thu, Apr 10, 2025 at 12:34:15PM +0300, Dmitry Baryshkov wrote:
> On Tue, Apr 08, 2025 at 05:27:01PM +0200, Kory Maincent wrote:
> > Enable support for two-lane configuration which is done by setting the
> > LANSEL_SW_EN and LANSEL_SW bits in the Pad Control register.
> > 
> > Use the dsi-lanes device tree parameter to configure the number of lanes.
> > The default configuration remains set to four lanes.
> > 
> > Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> > ---
> >  drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 35 +++++++++++++++++++++++++--
> >  1 file changed, 33 insertions(+), 2 deletions(-)
> > 
> > @@ -1504,7 +1523,7 @@ static const struct drm_panel_funcs ili9881c_funcs = {
> >  static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
> >  {
> >  	struct ili9881c *ctx;
> > -	int ret;
> > +	int ret, lanes;
> >  
> >  	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
> >  	if (!ctx)
> > @@ -1545,11 +1564,23 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
> >  	if (ret)
> >  		return ret;
> >  
> > +	ret = of_property_read_u32(dsi->dev.of_node, "dsi-lanes", &lanes);
> 
> Use dsi->lanes instead.

Please ignore this comment :-)

>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index 28cd7560e5db1d5734b10babdb4e4e553c6e07d0..5c429715159755df2461063dad0971642e2b9041 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -1263,6 +1263,21 @@  static int ili9881c_send_cmd_data(struct ili9881c *ctx, u8 cmd, u8 data)
 	return 0;
 }
 
+static int ili9881c_set_lanes_cfg(struct ili9881c *ctx)
+{
+	int ret;
+
+	if (ctx->dsi->lanes != 2)
+		/* Nothing to do */
+		return 0;
+
+	ret = ili9881c_switch_page(ctx, 1);
+	if (ret)
+		return ret;
+
+	return ili9881c_send_cmd_data(ctx, 0xB7, 0x3);
+}
+
 static int ili9881c_prepare(struct drm_panel *panel)
 {
 	struct ili9881c *ctx = panel_to_ili9881c(panel);
@@ -1295,6 +1310,10 @@  static int ili9881c_prepare(struct drm_panel *panel)
 			return ret;
 	}
 
+	ret = ili9881c_set_lanes_cfg(ctx);
+	if (ret)
+		return ret;
+
 	ret = ili9881c_switch_page(ctx, 0);
 	if (ret)
 		return ret;
@@ -1504,7 +1523,7 @@  static const struct drm_panel_funcs ili9881c_funcs = {
 static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
 {
 	struct ili9881c *ctx;
-	int ret;
+	int ret, lanes;
 
 	ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
 	if (!ctx)
@@ -1545,11 +1564,23 @@  static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
 	if (ret)
 		return ret;
 
+	ret = of_property_read_u32(dsi->dev.of_node, "dsi-lanes", &lanes);
+	if (ret == -EINVAL) {
+		lanes = 4;
+	} else if (ret) {
+		dev_err(&dsi->dev, "Failed to get dsi-lanes property (%d)\n",
+			ret);
+		return ret;
+	} else if (lanes < 2 || 4 < lanes) {
+		dev_err(&dsi->dev, "Wrong number of dsi-lanes (%d)\n", lanes);
+		return -EINVAL;
+	}
+
 	drm_panel_add(&ctx->panel);
 
 	dsi->mode_flags = ctx->desc->mode_flags;
 	dsi->format = MIPI_DSI_FMT_RGB888;
-	dsi->lanes = 4;
+	dsi->lanes = lanes;
 
 	return mipi_dsi_attach(dsi);
 }