Skip to content

Commit ca062af

Browse files
kmaincentlucaceresoli
authored andcommitted
drm/tilcdc: Add support for DRM bus flags and simplify panel config
Migrate CRTC mode configuration to use standard DRM bus flags in preparation for removing the tilcdc_panel driver and its custom tilcdc_panel_info structure. Add support for DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE and DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE flags to control pixel clock and sync signal edge polarity, while maintaining backward compatibility with the existing tilcdc panel info structure. Simplify several hardware parameters by setting them to fixed defaults based on common usage across existing device trees: - DMA burst size: 16 (previously configurable via switch statement) - AC bias frequency: 255 (previously panel-specific) - FIFO DMA request delay: 128 (previously panel-specific) These parameters show no variation in real-world usage, so hardcoding them simplifies the driver without losing functionality. Preserve FIFO threshold configurability by detecting the SoC type, as this parameter varies between AM33xx (8) and DA850 (16) platforms. Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Kory Maincent (TI.com) <kory.maincent@bootlin.com> Link: https://patch.msgid.link/20260123-feature_tilcdc-v5-4-5a44d2aa3f6f@bootlin.com Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
1 parent 332146d commit ca062af

3 files changed

Lines changed: 34 additions & 32 deletions

File tree

‎drivers/gpu/drm/tilcdc/tilcdc_crtc.c‎

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -285,27 +285,15 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
285285

286286
/* Configure the Burst Size and fifo threshold of DMA: */
287287
reg = tilcdc_read(dev, LCDC_DMA_CTRL_REG) & ~0x00000770;
288-
switch (info->dma_burst_sz) {
289-
case 1:
290-
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_1);
291-
break;
292-
case 2:
293-
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_2);
294-
break;
295-
case 4:
296-
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_4);
297-
break;
298-
case 8:
299-
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_8);
300-
break;
301-
case 16:
302-
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_16);
303-
break;
304-
default:
305-
dev_err(dev->dev, "invalid burst size\n");
306-
return;
288+
/* Use 16 bit DMA burst size by default */
289+
reg |= LCDC_DMA_BURST_SIZE(LCDC_DMA_BURST_16);
290+
if (priv->fifo_th) {
291+
int fifo_th_val = ilog2(priv->fifo_th) - 3;
292+
293+
reg |= (fifo_th_val << 8);
294+
} else {
295+
reg |= (info->fifo_th << 8);
307296
}
308-
reg |= (info->fifo_th << 8);
309297
tilcdc_write(dev, LCDC_DMA_CTRL_REG, reg);
310298

311299
/* Configure timings: */
@@ -321,8 +309,8 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
321309

322310
/* Set AC Bias Period and Number of Transitions per Interrupt: */
323311
reg = tilcdc_read(dev, LCDC_RASTER_TIMING_2_REG) & ~0x000fff00;
324-
reg |= LCDC_AC_BIAS_FREQUENCY(info->ac_bias) |
325-
LCDC_AC_BIAS_TRANSITIONS_PER_INT(info->ac_bias_intrpt);
312+
/* Use 255 AC Bias Pin Frequency by default */
313+
reg |= LCDC_AC_BIAS_FREQUENCY(255);
326314

327315
/*
328316
* subtract one from hfp, hbp, hsw because the hardware uses
@@ -392,20 +380,19 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
392380
return;
393381
}
394382
}
395-
reg |= info->fdd << 12;
383+
/* Use 128 FIFO DMA Request Delay by default */
384+
reg |= 128 << 12;
396385
tilcdc_write(dev, LCDC_RASTER_CTRL_REG, reg);
397386

398-
if (info->invert_pxl_clk)
387+
if (info->invert_pxl_clk ||
388+
mode->flags == DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE)
399389
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK);
400390
else
401391
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_INVERT_PIXEL_CLOCK);
402392

403-
if (info->sync_ctrl)
404-
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
405-
else
406-
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
407-
408-
if (info->sync_edge)
393+
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_CTRL);
394+
if (info->sync_edge ||
395+
mode->flags == DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE)
409396
tilcdc_set(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE);
410397
else
411398
tilcdc_clear(dev, LCDC_RASTER_TIMING_2_REG, LCDC_SYNC_EDGE);

‎drivers/gpu/drm/tilcdc/tilcdc_drv.c‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
#include "tilcdc_panel.h"
3232
#include "tilcdc_regs.h"
3333

34+
enum tilcdc_variant {
35+
AM33XX_TILCDC,
36+
DA850_TILCDC,
37+
};
38+
3439
static LIST_HEAD(module_list);
3540

3641
static const u32 tilcdc_rev1_formats[] = { DRM_FORMAT_RGB565 };
@@ -198,6 +203,7 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
198203
struct platform_device *pdev = to_platform_device(dev);
199204
struct device_node *node = dev->of_node;
200205
struct tilcdc_drm_private *priv;
206+
enum tilcdc_variant variant;
201207
u32 bpp = 0;
202208
int ret;
203209

@@ -209,6 +215,8 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
209215
if (IS_ERR(ddev))
210216
return PTR_ERR(ddev);
211217

218+
variant = (uintptr_t)of_device_get_match_data(dev);
219+
212220
ddev->dev_private = priv;
213221
platform_set_drvdata(pdev, ddev);
214222
drm_mode_config_init(ddev);
@@ -309,6 +317,11 @@ static int tilcdc_init(const struct drm_driver *ddrv, struct device *dev)
309317

310318
DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
311319

320+
if (variant == DA850_TILCDC)
321+
priv->fifo_th = 16;
322+
else
323+
priv->fifo_th = 8;
324+
312325
ret = tilcdc_crtc_create(ddev);
313326
if (ret < 0) {
314327
dev_err(dev, "failed to create crtc\n");
@@ -598,8 +611,8 @@ static void tilcdc_pdev_shutdown(struct platform_device *pdev)
598611
}
599612

600613
static const struct of_device_id tilcdc_of_match[] = {
601-
{ .compatible = "ti,am33xx-tilcdc", },
602-
{ .compatible = "ti,da850-tilcdc", },
614+
{ .compatible = "ti,am33xx-tilcdc", .data = (void *)AM33XX_TILCDC},
615+
{ .compatible = "ti,da850-tilcdc", .data = (void *)DA850_TILCDC},
603616
{ },
604617
};
605618
MODULE_DEVICE_TABLE(of, tilcdc_of_match);

‎drivers/gpu/drm/tilcdc/tilcdc_drv.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ struct tilcdc_drm_private {
6161
*/
6262
uint32_t max_width;
6363

64+
u32 fifo_th;
65+
6466
/* Supported pixel formats */
6567
const uint32_t *pixelformats;
6668
uint32_t num_pixelformats;

0 commit comments

Comments
 (0)