Hello,
This patch series is a second, extended version of the code previously posted as "[PATCH/RFC 0/7] Remove the omapdrm device from platform code".
The omapdss/omapdrm initialization code is quite a mess. The physical devices are instantiated from DT, but two virtual devices named omapdrm and omapdss are instanciated from platform code to pass various pieces of platform data to the drivers.
The omapdrm and omapdss platform devices are currently used to pass data and function pointers from board code to the drivers for the purpose of
- identifying the OMAP SoC revision - controlling the DSI pads - configuring bus throughput
It turns out that all these can be handled in the omapdrm and omapdss drivers without the need for platform data.
- The SoC revision is used to identify the version of various DSS IP cores, which can instead be done through compatible string matching (with the help of soc_device_match() in two cases where ES version is needed).
- The DSI pads control can be performed by the driver directly without calling board code, accessing the related registers through syscon.
- Bus throughput control is implemented in mach-omap2 as a no-op, so we can just drop the code.
This patch series starts with a few small cleanups and unused features removal (01/28 to 04/28). It then slowly replaces all uses of the omapdrm and omapdss platform data as explained above (05/28 to 20/28).
The next step is to remove the omapdss platform driver (for the virtual omapdss platform device, also known as core code, not to be confused with the omapdss_dss driver for the DSS hardware device). Patches 21/28 to 23/28 move the useful features of the core to the omapdss_dss driver. Patch 24/28 adds omapdrm platform device registration to the omapdss_dss driver to replace board code, and patch 25/28 finally removes the omapdss platform driver.
Note that registering the omapdrm platform device from within the omapdss_dss driver is a hack, but isn't worse than the current situation. Quite the contrary, given that the omapdrm device exists for the sole purpose of supporting the omapdrm/omapdss driver architecture, moving it out of platform code can be considered as (slightly) cleaner. In any case, it will be easier to refactor the code as everything is now isolated on the driver side.
Patches 26/28 and 27/28 remove the now unnecessary platform devices from platform code, and patch 28/28 removes the now unused omapdrm platform data structure.
The series will be annoying to merge given that it touches multiple subsystems (ARM core, DRM, FBDEV and ALSA). The easiest solution would be to merge everything through the DRM tree as that's where the bulk of changes lies. This would require an ack from Bartlomiej for patch 04/28, from Peter, Liam or Mark on patch 18/28 and from Tony on patches 26/28 and 27/28.
The patches are currently based on top of v4.11.
Laurent Pinchart (28): drm: omapdrm: Remove duplicate error messages when mapping memory drm: omapdrm: Drop support for non-DT devices drm: omapdrm: Remove unused dss_get_core_pdev() function drm: omapdrm: Remove unused default display name support drm: omapdrm: Infer the OMAP version from the SoC family drm: omapdrm: dispc: Select features based on compatible string drm: omapdrm: dpi: Remove platform driver drm: omapdrm: dpi: Replace OMAP SoC model checks with DSS device type drm: omapdrm: dsi: Store DSI type and PLL hardware data in OF data drm: omapdrm: dsi: Handle pin muxing internally drm: omapdrm: dss: Select features based on compatible string drm: omapdrm: dss: Split operations out of dss_features structure drm: omapdrm: dss: Initialize DSS internal features at probe time drm: omapdrm: hdmi: Store PHY features in PHY data structure drm: omapdrm: hdmi: Store PHY features in HDMI transmitter drivers drm: omapdrm: hdmi: Store PLL hardware data in HDMI transmitter drivers drm: omapdrm: hdmi: Replace OMAP SoC model check with HDMI xmit version drm: omapdrm: hdmi: Pass HDMI core version as integer to HDMI audio drm: omapdrm: sdi: Remove platform driver drm: omapdrm: Don't forward set_min_bus_tput() to no-op platform code drm: omapdrm: Move all debugfs code from core to dss drm: omapdrm: Move shutdown() handler from core to dss drm: omapdrm: Merge the dss_features and omap_dss_features structures drm: omapdrm: Register omapdrm platform device in omapdss driver drm: omapdrm: Remove the omapdss driver ARM: OMAP2+: Remove unused omapdrm platform device ARM: OMAP2+: Don't register omapdss device for omapdrm drm: omapdrm: Remove omapdrm platform data
arch/arm/mach-omap2/Makefile | 2 +- arch/arm/mach-omap2/display.c | 118 +++++------ arch/arm/mach-omap2/display.h | 1 - arch/arm/mach-omap2/drm.c | 53 ----- drivers/gpu/drm/omapdrm/dss/core.c | 230 ++------------------- drivers/gpu/drm/omapdrm/dss/dispc.c | 96 +++------ drivers/gpu/drm/omapdrm/dss/display.c | 19 +- drivers/gpu/drm/omapdrm/dss/dpi.c | 150 +++----------- drivers/gpu/drm/omapdrm/dss/dsi.c | 298 ++++++++++++++-------------- drivers/gpu/drm/omapdrm/dss/dss.c | 274 +++++++++++-------------- drivers/gpu/drm/omapdrm/dss/dss.h | 46 +++-- drivers/gpu/drm/omapdrm/dss/dss_features.c | 220 +++++++++++++------- drivers/gpu/drm/omapdrm/dss/dss_features.h | 41 +++- drivers/gpu/drm/omapdrm/dss/hdmi.h | 16 +- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 47 ++++- drivers/gpu/drm/omapdrm/dss/hdmi4_core.c | 9 +- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 48 ++++- drivers/gpu/drm/omapdrm/dss/hdmi5_core.c | 9 +- drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 79 +------- drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 86 +------- drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 24 +-- drivers/gpu/drm/omapdrm/dss/omapdss.h | 2 - drivers/gpu/drm/omapdrm/dss/rfbi.c | 12 +- drivers/gpu/drm/omapdrm/dss/sdi.c | 54 ----- drivers/gpu/drm/omapdrm/dss/venc.c | 28 +-- drivers/gpu/drm/omapdrm/dss/video-pll.c | 20 +- drivers/gpu/drm/omapdrm/omap_drv.c | 16 +- drivers/gpu/drm/omapdrm/omap_drv.h | 1 - drivers/video/fbdev/omap2/omapfb/dss/core.c | 2 - include/linux/platform_data/omap_drm.h | 53 ----- include/linux/platform_data/omapdss.h | 1 - include/sound/omap-hdmi-audio.h | 2 +- sound/soc/omap/omap-hdmi-audio.c | 9 +- 33 files changed, 763 insertions(+), 1303 deletions(-) delete mode 100644 arch/arm/mach-omap2/drm.c delete mode 100644 include/linux/platform_data/omap_drm.h
The devm_ioremap_resource() call can handle being given a NULL resource, and prints an error message when mapping fails. Switch the remaining devm_ioremap() calls to devm_ioremap_resource() and remove all extraneous resource NULL checks and error messages printed manually by the driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 12 ++---------- drivers/gpu/drm/omapdrm/dss/dsi.c | 21 ++++++--------------- drivers/gpu/drm/omapdrm/dss/dss.c | 12 ++---------- drivers/gpu/drm/omapdrm/dss/hdmi4_core.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi5_core.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 12 +++--------- drivers/gpu/drm/omapdrm/dss/rfbi.c | 12 ++---------- drivers/gpu/drm/omapdrm/dss/venc.c | 12 ++---------- drivers/gpu/drm/omapdrm/dss/video-pll.c | 20 ++------------------ 11 files changed, 23 insertions(+), 114 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index d956e6266368..820b45a94e2f 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -4363,17 +4363,9 @@ static int dispc_bind(struct device *dev, struct device *master, void *data) return r;
dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); - if (!dispc_mem) { - DSSERR("can't get IORESOURCE_MEM DISPC\n"); - return -EINVAL; - } - - dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start, - resource_size(dispc_mem)); - if (!dispc.base) { - DSSERR("can't ioremap DISPC\n"); + dispc.base = devm_ioremap_resource(&pdev->dev, dispc_mem); + if (!dispc.base) return -ENOMEM; - }
dispc.irq = platform_get_irq(dispc.pdev, 0); if (dispc.irq < 0) { diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index f74615d005a8..58f21f2b32c2 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -5326,12 +5326,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
dsi_mem = res;
- dsi->proto_base = devm_ioremap(&dsidev->dev, res->start, - resource_size(res)); - if (!dsi->proto_base) { - DSSERR("can't ioremap DSI protocol engine\n"); + dsi->proto_base = devm_ioremap_resource(&dsidev->dev, res); + if (!dsi->proto_base) return -ENOMEM; - }
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy"); if (!res) { @@ -5346,12 +5343,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) res = &temp_res; }
- dsi->phy_base = devm_ioremap(&dsidev->dev, res->start, - resource_size(res)); - if (!dsi->phy_base) { - DSSERR("can't ioremap DSI PHY\n"); + dsi->phy_base = devm_ioremap_resource(&dsidev->dev, res); + if (!dsi->phy_base) return -ENOMEM; - }
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll"); if (!res) { @@ -5366,12 +5360,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) res = &temp_res; }
- dsi->pll_base = devm_ioremap(&dsidev->dev, res->start, - resource_size(res)); - if (!dsi->pll_base) { - DSSERR("can't ioremap DSI PLL\n"); + dsi->pll_base = devm_ioremap_resource(&dsidev->dev, res); + if (!dsi->pll_base) return -ENOMEM; - }
dsi->irq = platform_get_irq(dsi->pdev, 0); if (dsi->irq < 0) { diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 14887d5b02e5..fb57c0471000 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1201,17 +1201,9 @@ static int dss_bind(struct device *dev) return r;
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); - if (!dss_mem) { - DSSERR("can't get IORESOURCE_MEM DSS\n"); - return -EINVAL; - } - - dss.base = devm_ioremap(&pdev->dev, dss_mem->start, - resource_size(dss_mem)); - if (!dss.base) { - DSSERR("can't ioremap DSS\n"); + dss.base = devm_ioremap_resource(&pdev->dev, dss_mem); + if (!dss.base) return -ENOMEM; - }
r = dss_get_clocks(); if (r) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c index e05b7ac4f7dd..ed6001613405 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c @@ -889,16 +889,9 @@ int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core) struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); - if (!res) { - DSSERR("can't get CORE mem resource\n"); - return -EINVAL; - } - core->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(core->base)) { - DSSERR("can't ioremap CORE\n"); + if (IS_ERR(core->base)) return PTR_ERR(core->base); - }
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c index 8de1d7b2ae55..ab179ec133c0 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c @@ -910,16 +910,9 @@ int hdmi5_core_init(struct platform_device *pdev, struct hdmi_core_data *core) struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); - if (!res) { - DSSERR("can't get CORE IORESOURCE_MEM HDMI\n"); - return -EINVAL; - } - core->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(core->base)) { - DSSERR("can't ioremap HDMI core\n"); + if (IS_ERR(core->base)) return PTR_ERR(core->base); - }
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c index 3ead47cccac5..fb5e4c724b4b 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c @@ -233,16 +233,9 @@ int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) return r;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); - if (!res) { - DSSERR("can't get PHY mem resource\n"); - return -EINVAL; - } - phy->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(phy->base)) { - DSSERR("can't ioremap TX PHY\n"); + if (IS_ERR(phy->base)) return PTR_ERR(phy->base); - }
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c index b8bf6a9e5557..46239358655a 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c @@ -180,16 +180,9 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll, pll->wp = wp;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll"); - if (!res) { - DSSERR("can't get PLL mem resource\n"); - return -EINVAL; - } - pll->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(pll->base)) { - DSSERR("can't ioremap PLLCTRL\n"); + if (IS_ERR(pll->base)) return PTR_ERR(pll->base); - }
r = dsi_init_pll_data(pdev, pll); if (r) { diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c index b783d5a0750e..b1ab9e563915 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c @@ -285,17 +285,11 @@ int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp) struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wp"); - if (!res) { - DSSERR("can't get WP mem resource\n"); - return -EINVAL; - } - wp->phys_base = res->start; - wp->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(wp->base)) { - DSSERR("can't ioremap HDMI WP\n"); + if (IS_ERR(wp->base)) return PTR_ERR(wp->base); - } + + wp->phys_base = res->start;
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/rfbi.c b/drivers/gpu/drm/omapdrm/dss/rfbi.c index 09724757366a..96429fb2edf9 100644 --- a/drivers/gpu/drm/omapdrm/dss/rfbi.c +++ b/drivers/gpu/drm/omapdrm/dss/rfbi.c @@ -965,17 +965,9 @@ static int rfbi_bind(struct device *dev, struct device *master, void *data) sema_init(&rfbi.bus_lock, 1);
rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0); - if (!rfbi_mem) { - DSSERR("can't get IORESOURCE_MEM RFBI\n"); - return -EINVAL; - } - - rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start, - resource_size(rfbi_mem)); - if (!rfbi.base) { - DSSERR("can't ioremap RFBI\n"); + rfbi.base = devm_ioremap_resource(&pdev->dev, rfbi_mem); + if (!rfbi.base) return -ENOMEM; - }
clk = clk_get(&pdev->dev, "ick"); if (IS_ERR(clk)) { diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c index d74f7fcc2e46..bf39fe62c847 100644 --- a/drivers/gpu/drm/omapdrm/dss/venc.c +++ b/drivers/gpu/drm/omapdrm/dss/venc.c @@ -868,17 +868,9 @@ static int venc_bind(struct device *dev, struct device *master, void *data) venc.wss_data = 0;
venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0); - if (!venc_mem) { - DSSERR("can't get IORESOURCE_MEM VENC\n"); - return -EINVAL; - } - - venc.base = devm_ioremap(&pdev->dev, venc_mem->start, - resource_size(venc_mem)); - if (!venc.base) { - DSSERR("can't ioremap VENC\n"); + venc.base = devm_ioremap_resource(&pdev->dev, venc_mem); + if (!venc.base) return -ENOMEM; - }
r = venc_get_clocks(pdev); if (r) diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c index 7429de928d4e..fbd1263a29a4 100644 --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c @@ -150,33 +150,17 @@ struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id, /* PLL CONTROL */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, reg_name[id]); - if (!res) { - dev_err(&pdev->dev, - "missing platform resource data for pll%d\n", id); - return ERR_PTR(-ENODEV); - } - pll_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(pll_base)) { - dev_err(&pdev->dev, "failed to ioremap pll%d reg_name\n", id); + if (IS_ERR(pll_base)) return ERR_CAST(pll_base); - }
/* CLOCK CONTROL */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, clkctrl_name[id]); - if (!res) { - dev_err(&pdev->dev, - "missing platform resource data for pll%d\n", id); - return ERR_PTR(-ENODEV); - } - clkctrl_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(clkctrl_base)) { - dev_err(&pdev->dev, "failed to ioremap pll%d clkctrl\n", id); + if (IS_ERR(clkctrl_base)) return ERR_CAST(clkctrl_base); - }
/* CLKIN */
On 08/05/17 14:32, Laurent Pinchart wrote:
The devm_ioremap_resource() call can handle being given a NULL resource, and prints an error message when mapping fails. Switch the remaining devm_ioremap() calls to devm_ioremap_resource() and remove all extraneous resource NULL checks and error messages printed manually by the driver.
Looks like in some places we check for "!ret" and in some "IS_ERR(ret)"...
Tomi
Hi Tomi,
On Monday 08 May 2017 15:52:07 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
The devm_ioremap_resource() call can handle being given a NULL resource, and prints an error message when mapping fails. Switch the remaining devm_ioremap() calls to devm_ioremap_resource() and remove all extraneous resource NULL checks and error messages printed manually by the driver.
Looks like in some places we check for "!ret" and in some "IS_ERR(ret)"...
Oops :-/
From 94d2a8f445cd298d99ffc4717d2184dcf21e8889 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart laurent.pinchart@ideasonboard.com Date: Sun, 7 May 2017 00:29:09 +0300 Subject: [PATCH v2.1 01/28] drm: omapdrm: Remove duplicate error messages when mapping memory
The devm_ioremap_resource() call can handle being given a NULL resource, and prints an error message when mapping fails. Switch the remaining devm_ioremap() calls to devm_ioremap_resource() and remove all extraneous resource NULL checks and error messages printed manually by the driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- Changes since v2:
- Fix devm_ioremap_resource() return value checks --- drivers/gpu/drm/omapdrm/dss/dispc.c | 14 +++----------- drivers/gpu/drm/omapdrm/dss/dsi.c | 27 +++++++++------------------ drivers/gpu/drm/omapdrm/dss/dss.c | 14 +++----------- drivers/gpu/drm/omapdrm/dss/hdmi4_core.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi5_core.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 9 +-------- drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 12 +++--------- drivers/gpu/drm/omapdrm/dss/rfbi.c | 14 +++----------- drivers/gpu/drm/omapdrm/dss/venc.c | 14 +++----------- drivers/gpu/drm/omapdrm/dss/video-pll.c | 20 ++------------------ 11 files changed, 30 insertions(+), 121 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index d956e6266368..59fd6bac4306 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -4363,17 +4363,9 @@ static int dispc_bind(struct device *dev, struct device *master, void *data) return r;
dispc_mem = platform_get_resource(dispc.pdev, IORESOURCE_MEM, 0); - if (!dispc_mem) { - DSSERR("can't get IORESOURCE_MEM DISPC\n"); - return -EINVAL; - } - - dispc.base = devm_ioremap(&pdev->dev, dispc_mem->start, - resource_size(dispc_mem)); - if (!dispc.base) { - DSSERR("can't ioremap DISPC\n"); - return -ENOMEM; - } + dispc.base = devm_ioremap_resource(&pdev->dev, dispc_mem); + if (IS_ERR(dispc.base)) + return PTR_ERR(discp.base);
dispc.irq = platform_get_irq(dispc.pdev, 0); if (dispc.irq < 0) { diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index f74615d005a8..5388f798356a 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -5326,12 +5326,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
dsi_mem = res;
- dsi->proto_base = devm_ioremap(&dsidev->dev, res->start, - resource_size(res)); - if (!dsi->proto_base) { - DSSERR("can't ioremap DSI protocol engine\n"); - return -ENOMEM; - } + dsi->proto_base = devm_ioremap_resource(&dsidev->dev, res); + if (IS_ERR(dsi->proto_base)) + return PTR_ERR(dsi->proto_base);
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy"); if (!res) { @@ -5346,12 +5343,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) res = &temp_res; }
- dsi->phy_base = devm_ioremap(&dsidev->dev, res->start, - resource_size(res)); - if (!dsi->phy_base) { - DSSERR("can't ioremap DSI PHY\n"); - return -ENOMEM; - } + dsi->phy_base = devm_ioremap_resource(&dsidev->dev, res); + if (IS_ERR(dsi->phy_base)) + return PTR_ERR(dsi->phy_base);
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll"); if (!res) { @@ -5366,12 +5360,9 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) res = &temp_res; }
- dsi->pll_base = devm_ioremap(&dsidev->dev, res->start, - resource_size(res)); - if (!dsi->pll_base) { - DSSERR("can't ioremap DSI PLL\n"); - return -ENOMEM; - } + dsi->pll_base = devm_ioremap_resource(&dsidev->dev, res); + if (IS_ERR(dsi->pll_base)) + return PTR_ERR(dsi->pll_base);
dsi->irq = platform_get_irq(dsi->pdev, 0); if (dsi->irq < 0) { diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 14887d5b02e5..4bfdcc47b2ee 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1201,17 +1201,9 @@ static int dss_bind(struct device *dev) return r;
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); - if (!dss_mem) { - DSSERR("can't get IORESOURCE_MEM DSS\n"); - return -EINVAL; - } - - dss.base = devm_ioremap(&pdev->dev, dss_mem->start, - resource_size(dss_mem)); - if (!dss.base) { - DSSERR("can't ioremap DSS\n"); - return -ENOMEM; - } + dss.base = devm_ioremap_resource(&pdev->dev, dss_mem); + if (IS_ERR(dss.base)) + return PTR_ERR(dss.base);
r = dss_get_clocks(); if (r) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c index e05b7ac4f7dd..ed6001613405 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c @@ -889,16 +889,9 @@ int hdmi4_core_init(struct platform_device *pdev, struct hdmi_core_data *core) struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); - if (!res) { - DSSERR("can't get CORE mem resource\n"); - return -EINVAL; - } - core->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(core->base)) { - DSSERR("can't ioremap CORE\n"); + if (IS_ERR(core->base)) return PTR_ERR(core->base); - }
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c index 8de1d7b2ae55..ab179ec133c0 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5_core.c @@ -910,16 +910,9 @@ int hdmi5_core_init(struct platform_device *pdev, struct hdmi_core_data *core) struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); - if (!res) { - DSSERR("can't get CORE IORESOURCE_MEM HDMI\n"); - return -EINVAL; - } - core->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(core->base)) { - DSSERR("can't ioremap HDMI core\n"); + if (IS_ERR(core->base)) return PTR_ERR(core->base); - }
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c index 3ead47cccac5..fb5e4c724b4b 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c @@ -233,16 +233,9 @@ int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) return r;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); - if (!res) { - DSSERR("can't get PHY mem resource\n"); - return -EINVAL; - } - phy->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(phy->base)) { - DSSERR("can't ioremap TX PHY\n"); + if (IS_ERR(phy->base)) return PTR_ERR(phy->base); - }
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c index b8bf6a9e5557..46239358655a 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c @@ -180,16 +180,9 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll, pll->wp = wp;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pll"); - if (!res) { - DSSERR("can't get PLL mem resource\n"); - return -EINVAL; - } - pll->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(pll->base)) { - DSSERR("can't ioremap PLLCTRL\n"); + if (IS_ERR(pll->base)) return PTR_ERR(pll->base); - }
r = dsi_init_pll_data(pdev, pll); if (r) { diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c index b783d5a0750e..b1ab9e563915 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c @@ -285,17 +285,11 @@ int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp) struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "wp"); - if (!res) { - DSSERR("can't get WP mem resource\n"); - return -EINVAL; - } - wp->phys_base = res->start; - wp->base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(wp->base)) { - DSSERR("can't ioremap HDMI WP\n"); + if (IS_ERR(wp->base)) return PTR_ERR(wp->base); - } + + wp->phys_base = res->start;
return 0; } diff --git a/drivers/gpu/drm/omapdrm/dss/rfbi.c b/drivers/gpu/drm/omapdrm/dss/rfbi.c index 09724757366a..bf6b96877daf 100644 --- a/drivers/gpu/drm/omapdrm/dss/rfbi.c +++ b/drivers/gpu/drm/omapdrm/dss/rfbi.c @@ -965,17 +965,9 @@ static int rfbi_bind(struct device *dev, struct device *master, void *data) sema_init(&rfbi.bus_lock, 1);
rfbi_mem = platform_get_resource(rfbi.pdev, IORESOURCE_MEM, 0); - if (!rfbi_mem) { - DSSERR("can't get IORESOURCE_MEM RFBI\n"); - return -EINVAL; - } - - rfbi.base = devm_ioremap(&pdev->dev, rfbi_mem->start, - resource_size(rfbi_mem)); - if (!rfbi.base) { - DSSERR("can't ioremap RFBI\n"); - return -ENOMEM; - } + rfbi.base = devm_ioremap_resource(&pdev->dev, rfbi_mem); + if (IS_ERR(rfbi.base)) + return PTR_ERR(rfbi.base);
clk = clk_get(&pdev->dev, "ick"); if (IS_ERR(clk)) { diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c index d74f7fcc2e46..1811d360466e 100644 --- a/drivers/gpu/drm/omapdrm/dss/venc.c +++ b/drivers/gpu/drm/omapdrm/dss/venc.c @@ -868,17 +868,9 @@ static int venc_bind(struct device *dev, struct device *master, void *data) venc.wss_data = 0;
venc_mem = platform_get_resource(venc.pdev, IORESOURCE_MEM, 0); - if (!venc_mem) { - DSSERR("can't get IORESOURCE_MEM VENC\n"); - return -EINVAL; - } - - venc.base = devm_ioremap(&pdev->dev, venc_mem->start, - resource_size(venc_mem)); - if (!venc.base) { - DSSERR("can't ioremap VENC\n"); - return -ENOMEM; - } + venc.base = devm_ioremap_resource(&pdev->dev, venc_mem); + if (IS_ERR(venc.base)) + return PTR_ERR(venc.base);
r = venc_get_clocks(pdev); if (r) diff --git a/drivers/gpu/drm/omapdrm/dss/video-pll.c b/drivers/gpu/drm/omapdrm/dss/video-pll.c index 7429de928d4e..fbd1263a29a4 100644 --- a/drivers/gpu/drm/omapdrm/dss/video-pll.c +++ b/drivers/gpu/drm/omapdrm/dss/video-pll.c @@ -150,33 +150,17 @@ struct dss_pll *dss_video_pll_init(struct platform_device *pdev, int id, /* PLL CONTROL */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, reg_name[id]); - if (!res) { - dev_err(&pdev->dev, - "missing platform resource data for pll%d\n", id); - return ERR_PTR(-ENODEV); - } - pll_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(pll_base)) { - dev_err(&pdev->dev, "failed to ioremap pll%d reg_name\n", id); + if (IS_ERR(pll_base)) return ERR_CAST(pll_base); - }
/* CLOCK CONTROL */
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, clkctrl_name[id]); - if (!res) { - dev_err(&pdev->dev, - "missing platform resource data for pll%d\n", id); - return ERR_PTR(-ENODEV); - } - clkctrl_base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(clkctrl_base)) { - dev_err(&pdev->dev, "failed to ioremap pll%d clkctrl\n", id); + if (IS_ERR(clkctrl_base)) return ERR_CAST(clkctrl_base); - }
/* CLKIN */
On 08/05/17 16:55, Laurent Pinchart wrote:
Hi Tomi,
On Monday 08 May 2017 15:52:07 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
The devm_ioremap_resource() call can handle being given a NULL resource, and prints an error message when mapping fails. Switch the remaining devm_ioremap() calls to devm_ioremap_resource() and remove all extraneous resource NULL checks and error messages printed manually by the driver.
Looks like in some places we check for "!ret" and in some "IS_ERR(ret)"...
Oops :-/
From 94d2a8f445cd298d99ffc4717d2184dcf21e8889 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart laurent.pinchart@ideasonboard.com Date: Sun, 7 May 2017 00:29:09 +0300 Subject: [PATCH v2.1 01/28] drm: omapdrm: Remove duplicate error messages when mapping memory
The devm_ioremap_resource() call can handle being given a NULL resource, and prints an error message when mapping fails. Switch the remaining devm_ioremap() calls to devm_ioremap_resource() and remove all extraneous resource NULL checks and error messages printed manually by the driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
Changes since v2:
- Fix devm_ioremap_resource() return value checks
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
All OMAP platforms use DT nowadays, drop support for non-DT devices.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/display.c | 19 ++----- drivers/gpu/drm/omapdrm/dss/dsi.c | 93 +++++++---------------------------- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 8 ++- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 8 ++- drivers/gpu/drm/omapdrm/dss/venc.c | 16 ++---- 5 files changed, 35 insertions(+), 109 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/display.c b/drivers/gpu/drm/omapdrm/dss/display.c index 425a5a8dff8b..cf5f6c2ad344 100644 --- a/drivers/gpu/drm/omapdrm/dss/display.c +++ b/drivers/gpu/drm/omapdrm/dss/display.c @@ -88,26 +88,17 @@ int omapdss_register_display(struct omap_dss_device *dssdev) int id;
/* - * Note: this presumes all the displays are either using DT or non-DT, - * which normally should be the case. This also presumes that all - * displays either have an DT alias, or none has. + * Note: this presumes that all displays either have an DT alias, or + * none has. */ - - if (dssdev->dev->of_node) { - id = of_alias_get_id(dssdev->dev->of_node, "display"); - - if (id < 0) - id = disp_num_counter++; - } else { + id = of_alias_get_id(dssdev->dev->of_node, "display"); + if (id < 0) id = disp_num_counter++; - }
snprintf(dssdev->alias, sizeof(dssdev->alias), "display%d", id);
/* Use 'label' property for name, if it exists */ - if (dssdev->dev->of_node) - of_property_read_string(dssdev->dev->of_node, "label", - &dssdev->name); + of_property_read_string(dssdev->dev->of_node, "label", &dssdev->name);
if (dssdev->name == NULL) dssdev->name = dssdev->alias; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 58f21f2b32c2..3edd194d6f36 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -5276,12 +5276,12 @@ static int dsi_init_pll_data(struct platform_device *dsidev) static int dsi_bind(struct device *dev, struct device *master, void *data) { struct platform_device *dsidev = to_platform_device(dev); + const struct dsi_module_id_data *d; u32 rev; int r, i; struct dsi_data *dsi; struct resource *dsi_mem; struct resource *res; - struct resource temp_res;
dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL); if (!dsi) @@ -5311,55 +5311,17 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) dsi->te_timer.data = 0; #endif
- res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "proto"); - if (!res) { - res = platform_get_resource(dsidev, IORESOURCE_MEM, 0); - if (!res) { - DSSERR("can't get IORESOURCE_MEM DSI\n"); - return -EINVAL; - } - - temp_res.start = res->start; - temp_res.end = temp_res.start + DSI_PROTO_SZ - 1; - res = &temp_res; - } - - dsi_mem = res; - - dsi->proto_base = devm_ioremap_resource(&dsidev->dev, res); + dsi_mem = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "proto"); + dsi->proto_base = devm_ioremap_resource(&dsidev->dev, dsi_mem); if (!dsi->proto_base) return -ENOMEM;
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "phy"); - if (!res) { - res = platform_get_resource(dsidev, IORESOURCE_MEM, 0); - if (!res) { - DSSERR("can't get IORESOURCE_MEM DSI\n"); - return -EINVAL; - } - - temp_res.start = res->start + DSI_PHY_OFFSET; - temp_res.end = temp_res.start + DSI_PHY_SZ - 1; - res = &temp_res; - } - dsi->phy_base = devm_ioremap_resource(&dsidev->dev, res); if (!dsi->phy_base) return -ENOMEM;
res = platform_get_resource_byname(dsidev, IORESOURCE_MEM, "pll"); - if (!res) { - res = platform_get_resource(dsidev, IORESOURCE_MEM, 0); - if (!res) { - DSSERR("can't get IORESOURCE_MEM DSI\n"); - return -EINVAL; - } - - temp_res.start = res->start + DSI_PLL_OFFSET; - temp_res.end = temp_res.start + DSI_PLL_SZ - 1; - res = &temp_res; - } - dsi->pll_base = devm_ioremap_resource(&dsidev->dev, res); if (!dsi->pll_base) return -ENOMEM; @@ -5377,31 +5339,17 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) return r; }
- if (dsidev->dev.of_node) { - const struct of_device_id *match; - const struct dsi_module_id_data *d; - - match = of_match_node(dsi_of_match, dsidev->dev.of_node); - if (!match) { - DSSERR("unsupported DSI module\n"); - return -ENODEV; - } - - d = match->data; + d = of_match_node(dsi_of_match, dsidev->dev.of_node)->data; + while (d->address != 0 && d->address != dsi_mem->start) + d++;
- while (d->address != 0 && d->address != dsi_mem->start) - d++; - - if (d->address == 0) { - DSSERR("unsupported DSI module\n"); - return -ENODEV; - } - - dsi->module_id = d->id; - } else { - dsi->module_id = dsidev->id; + if (d->address == 0) { + DSSERR("unsupported DSI module\n"); + return -ENODEV; }
+ dsi->module_id = d->id; + /* DSI VCs initialization */ for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { dsi->vc[i].source = DSI_VC_SOURCE_L4; @@ -5437,19 +5385,16 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
dsi_init_output(dsidev);
- if (dsidev->dev.of_node) { - r = dsi_probe_of(dsidev); - if (r) { - DSSERR("Invalid DSI DT data\n"); - goto err_probe_of; - } - - r = of_platform_populate(dsidev->dev.of_node, NULL, NULL, - &dsidev->dev); - if (r) - DSSERR("Failed to populate DSI child devices: %d\n", r); + r = dsi_probe_of(dsidev); + if (r) { + DSSERR("Invalid DSI DT data\n"); + goto err_probe_of; }
+ r = of_platform_populate(dsidev->dev.of_node, NULL, NULL, &dsidev->dev); + if (r) + DSSERR("Failed to populate DSI child devices: %d\n", r); + dsi_runtime_put(dsidev);
if (dsi->module_id == 0) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index e7162c16de2e..ff4a0c04a22c 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -695,11 +695,9 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data) mutex_init(&hdmi.lock); spin_lock_init(&hdmi.audio_playing_lock);
- if (pdev->dev.of_node) { - r = hdmi_probe_of(pdev); - if (r) - return r; - } + r = hdmi_probe_of(pdev); + if (r) + return r;
r = hdmi_wp_init(pdev, &hdmi.wp); if (r) diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index 678dfb02764a..c037b61f7920 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -727,11 +727,9 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data) mutex_init(&hdmi.lock); spin_lock_init(&hdmi.audio_playing_lock);
- if (pdev->dev.of_node) { - r = hdmi_probe_of(pdev); - if (r) - return r; - } + r = hdmi_probe_of(pdev); + if (r) + return r;
r = hdmi_wp_init(pdev, &hdmi.wp); if (r) diff --git a/drivers/gpu/drm/omapdrm/dss/venc.c b/drivers/gpu/drm/omapdrm/dss/venc.c index bf39fe62c847..e50b1354b133 100644 --- a/drivers/gpu/drm/omapdrm/dss/venc.c +++ b/drivers/gpu/drm/omapdrm/dss/venc.c @@ -642,11 +642,7 @@ static int venc_init_regulator(void) if (venc.vdda_dac_reg != NULL) return 0;
- if (venc.pdev->dev.of_node) - vdda_dac = devm_regulator_get(&venc.pdev->dev, "vdda"); - else - vdda_dac = devm_regulator_get(&venc.pdev->dev, "vdda_dac"); - + vdda_dac = devm_regulator_get(&venc.pdev->dev, "vdda"); if (IS_ERR(vdda_dac)) { if (PTR_ERR(vdda_dac) != -EPROBE_DEFER) DSSERR("can't get VDDA_DAC regulator\n"); @@ -887,12 +883,10 @@ static int venc_bind(struct device *dev, struct device *master, void *data)
venc_runtime_put();
- if (pdev->dev.of_node) { - r = venc_probe_of(pdev); - if (r) { - DSSERR("Invalid DT data\n"); - goto err_probe_of; - } + r = venc_probe_of(pdev); + if (r) { + DSSERR("Invalid DT data\n"); + goto err_probe_of; }
dss_debugfs_create_file("venc", venc_dump_regs);
On 08/05/17 14:32, Laurent Pinchart wrote:
All OMAP platforms use DT nowadays, drop support for non-DT devices.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/display.c | 19 ++----- drivers/gpu/drm/omapdrm/dss/dsi.c | 93 +++++++---------------------------- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 8 ++- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 8 ++- drivers/gpu/drm/omapdrm/dss/venc.c | 16 ++---- 5 files changed, 35 insertions(+), 109 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Btw, this only drops non-DT support in a few files. We have a lot more to clean up.
Tomi
Hi Tomi,
On Tuesday 09 May 2017 11:40:01 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
All OMAP platforms use DT nowadays, drop support for non-DT devices.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/display.c | 19 ++----- drivers/gpu/drm/omapdrm/dss/dsi.c | 93 ++++++----------------------- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 8 ++- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 8 ++- drivers/gpu/drm/omapdrm/dss/venc.c | 16 ++---- 5 files changed, 35 insertions(+), 109 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Btw, this only drops non-DT support in a few files. We have a lot more to clean up.
You're right. I only took care of the code that bothered me. More patches will come :-)
The dss_get_core_pdev() function is unused, remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 5 ----- drivers/gpu/drm/omapdrm/dss/dss.h | 1 - 2 files changed, 6 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 6a3ebfcd7223..3351ce23f413 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -62,11 +62,6 @@ enum omapdss_version omapdss_get_version(void) } EXPORT_SYMBOL(omapdss_get_version);
-struct platform_device *dss_get_core_pdev(void) -{ - return core.pdev; -} - int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask) { struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 56493b290731..dfb10c9b4102 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -222,7 +222,6 @@ struct seq_file; struct platform_device;
/* core */ -struct platform_device *dss_get_core_pdev(void); int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask); void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask); int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
On 08/05/17 14:32, Laurent Pinchart wrote:
The dss_get_core_pdev() function is unused, remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 5 ----- drivers/gpu/drm/omapdrm/dss/dss.h | 1 - 2 files changed, 6 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The default display name is both unused and never set by platform data. Remove default display name module parameter, platform data field and runtime infrastructure.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- Changes since v1:
- Don't remove the platform callbacks as they're still used by the omapfb driver. --- drivers/gpu/drm/omapdrm/dss/core.c | 18 ------------------ drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 - drivers/video/fbdev/omap2/omapfb/dss/core.c | 2 -- include/linux/platform_data/omapdss.h | 1 - 4 files changed, 22 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 3351ce23f413..bc4fa4ec8557 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -41,20 +41,8 @@
static struct { struct platform_device *pdev; - - const char *default_display_name; } core;
-static char *def_disp_name; -module_param_named(def_disp, def_disp_name, charp, 0); -MODULE_PARM_DESC(def_disp, "default display name"); - -const char *omapdss_get_default_display_name(void) -{ - return core.default_display_name; -} -EXPORT_SYMBOL(omapdss_get_default_display_name); - enum omapdss_version omapdss_get_version(void) { struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; @@ -175,7 +163,6 @@ static void dss_disable_all_devices(void)
static int __init omap_dss_probe(struct platform_device *pdev) { - struct omap_dss_board_info *pdata = pdev->dev.platform_data; int r;
core.pdev = pdev; @@ -186,11 +173,6 @@ static int __init omap_dss_probe(struct platform_device *pdev) if (r) goto err_debugfs;
- if (def_disp_name) - core.default_display_name = def_disp_name; - else if (pdata->default_display_name) - core.default_display_name = pdata->default_display_name; - return 0;
err_debugfs: diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 5b3b961127bd..32eae507a669 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -781,7 +781,6 @@ void omap_dss_put_device(struct omap_dss_device *dssdev); struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from); struct omap_dss_device *omap_dss_find_device(void *data, int (*match)(struct omap_dss_device *dssdev, void *data)); -const char *omapdss_get_default_display_name(void);
int dss_feat_get_num_mgrs(void); int dss_feat_get_num_ovls(void); diff --git a/drivers/video/fbdev/omap2/omapfb/dss/core.c b/drivers/video/fbdev/omap2/omapfb/dss/core.c index 29de4827589d..eecf695c16f4 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/core.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/core.c @@ -206,8 +206,6 @@ static int __init omap_dss_probe(struct platform_device *pdev)
if (def_disp_name) core.default_display_name = def_disp_name; - else if (pdata->default_display_name) - core.default_display_name = pdata->default_display_name;
register_pm_notifier(&omap_dss_pm_notif_block);
diff --git a/include/linux/platform_data/omapdss.h b/include/linux/platform_data/omapdss.h index 679177929045..7feb011ed500 100644 --- a/include/linux/platform_data/omapdss.h +++ b/include/linux/platform_data/omapdss.h @@ -27,7 +27,6 @@ enum omapdss_version {
/* Board specific data */ struct omap_dss_board_info { - const char *default_display_name; int (*dsi_enable_pads)(int dsi_id, unsigned int lane_mask); void (*dsi_disable_pads)(int dsi_id, unsigned int lane_mask); int (*set_min_bus_tput)(struct device *dev, unsigned long r);
Hi,
On Monday, May 08, 2017 02:32:39 PM Laurent Pinchart wrote:
The default display name is both unused and never set by platform data. Remove default display name module parameter, platform data field and runtime infrastructure.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
For fbdev part:
Acked-by: Bartlomiej Zolnierkiewicz b.zolnierkie@samsung.com
Best regards, -- Bartlomiej Zolnierkiewicz Samsung R&D Institute Poland Samsung Electronics
On 08/05/17 14:32, Laurent Pinchart wrote:
The default display name is both unused and never set by platform data. Remove default display name module parameter, platform data field and runtime infrastructure.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
Changes since v1:
- Don't remove the platform callbacks as they're still used by the omapfb driver.
drivers/gpu/drm/omapdrm/dss/core.c | 18 ------------------ drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 - drivers/video/fbdev/omap2/omapfb/dss/core.c | 2 -- include/linux/platform_data/omapdss.h | 1 - 4 files changed, 22 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The omapdrm exposes the SoC version to userspace through an integer that contains the OMAP model (e.g. 0x3430 for the OMAP3430). This is an unfortunate choice of userspace API as it's both conceptually wrong (userspace nowadays should use /sys/bus/soc/ for that purpose) and inaccurate as many models with different features are reported with the same version number.
The only known user of this API is the xomap X11 driver. Even if it has been deprecated for some time we can't drop the kernel API yet. We can, however, infer the version number from the SoC family to avoid the need to pass the version number through platform data.
Do this, which makes the omapdrm platform data not needed anymore, and ready to be removed.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/omap_drv.c | 14 ++++++++++++-- drivers/gpu/drm/omapdrm/omap_drv.h | 1 - 2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 3f2554235225..343301ed4741 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -17,6 +17,7 @@ * this program. If not, see http://www.gnu.org/licenses/. */
+#include <linux/sys_soc.h> #include <linux/wait.h>
#include <drm/drm_atomic.h> @@ -753,9 +754,17 @@ static struct drm_driver omap_drm_driver = { .patchlevel = DRIVER_PATCHLEVEL, };
+static const struct soc_device_attribute dss_soc_devices[] = { + { .family = "OMAP3", .data = (void *)0x3430 }, + { .family = "OMAP4", .data = (void *)0x4430 }, + { .family = "OMAP5", .data = (void *)0x5430 }, + { .family = "DRA7", .data = (void *)0x0752 }, + { /* sentinel */ } +}; + static int pdev_probe(struct platform_device *pdev) { - struct omap_drm_platform_data *pdata = pdev->dev.platform_data; + const struct soc_device_attribute *soc; struct omap_drm_private *priv; struct drm_device *ddev; unsigned int i; @@ -779,7 +788,8 @@ static int pdev_probe(struct platform_device *pdev) goto err_disconnect_dssdevs; }
- priv->omaprev = pdata->omaprev; + soc = soc_device_match(dss_soc_devices); + priv->omaprev = soc ? (unsigned int)soc->data : 0; priv->wq = alloc_ordered_workqueue("omapdrm", 0);
init_waitqueue_head(&priv->commit.wait); diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h b/drivers/gpu/drm/omapdrm/omap_drv.h index 65977982f15f..0351d017734e 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.h +++ b/drivers/gpu/drm/omapdrm/omap_drv.h @@ -21,7 +21,6 @@ #define __OMAP_DRV_H__
#include <linux/module.h> -#include <linux/platform_data/omap_drm.h> #include <linux/types.h> #include <linux/wait.h>
On 08/05/17 14:32, Laurent Pinchart wrote:
The omapdrm exposes the SoC version to userspace through an integer that contains the OMAP model (e.g. 0x3430 for the OMAP3430). This is an unfortunate choice of userspace API as it's both conceptually wrong (userspace nowadays should use /sys/bus/soc/ for that purpose) and inaccurate as many models with different features are reported with the same version number.
The only known user of this API is the xomap X11 driver. Even if it has been deprecated for some time we can't drop the kernel API yet. We can, however, infer the version number from the SoC family to avoid the need to pass the version number through platform data.
Do this, which makes the omapdrm platform data not needed anymore, and ready to be removed.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/omap_drv.c | 14 ++++++++++++-- drivers/gpu/drm/omapdrm/omap_drv.h | 1 - 2 files changed, 12 insertions(+), 3 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
Use the compatible string instead of the OMAP SoC revision to determine device features. On OMAP34xx the features depend on the ES revision that can not be determined from the compatible string. Use soc_device_match() in that case.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dispc.c | 84 +++++++++++-------------------------- 1 file changed, 24 insertions(+), 60 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 820b45a94e2f..66982251d63d 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -39,7 +39,9 @@ #include <linux/mfd/syscon.h> #include <linux/regmap.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/component.h> +#include <linux/sys_soc.h>
#include "omapdss.h" #include "dss.h" @@ -4093,54 +4095,6 @@ static const struct dispc_features omap54xx_dispc_feats = { .has_gamma_i734_bug = true, };
-static int dispc_init_features(struct platform_device *pdev) -{ - const struct dispc_features *src; - struct dispc_features *dst; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate DISPC Features\n"); - return -ENOMEM; - } - - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP24xx: - src = &omap24xx_dispc_feats; - break; - - case OMAPDSS_VER_OMAP34xx_ES1: - src = &omap34xx_rev1_0_dispc_feats; - break; - - case OMAPDSS_VER_OMAP34xx_ES3: - case OMAPDSS_VER_OMAP3630: - case OMAPDSS_VER_AM35xx: - case OMAPDSS_VER_AM43xx: - src = &omap34xx_rev3_0_dispc_feats; - break; - - case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: - src = &omap44xx_dispc_feats; - break; - - case OMAPDSS_VER_OMAP5: - case OMAPDSS_VER_DRA7xx: - src = &omap54xx_dispc_feats; - break; - - default: - return -ENODEV; - } - - memcpy(dst, src, sizeof(*dst)); - dispc.feat = dst; - - return 0; -} - static irqreturn_t dispc_irq_handler(int irq, void *arg) { if (!dispc.is_enabled) @@ -4342,6 +4296,20 @@ static void dispc_errata_i734_wa(void) }
/* DISPC HW IP initialisation */ +static const struct of_device_id dispc_of_match[] = { + { .compatible = "ti,omap2-dispc", .data = &omap24xx_dispc_feats }, + { .compatible = "ti,omap3-dispc", .data = &omap34xx_rev3_0_dispc_feats }, + { .compatible = "ti,omap4-dispc", .data = &omap44xx_dispc_feats }, + { .compatible = "ti,omap5-dispc", .data = &omap54xx_dispc_feats }, + { .compatible = "ti,dra7-dispc", .data = &omap54xx_dispc_feats }, + {}, +}; + +static const struct soc_device_attribute dispc_soc_devices[] = { + { .machine = "OMAP3430/3530", .revision = "ES[12].?", }, + { /* sentinel */ } +}; + static int dispc_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -4354,9 +4322,14 @@ static int dispc_bind(struct device *dev, struct device *master, void *data)
spin_lock_init(&dispc.control_lock);
- r = dispc_init_features(dispc.pdev); - if (r) - return r; + /* + * The OMAP34xx ES1.x and ES2.x can't be identified through the + * compatible string, use SoC device matching. + */ + if (soc_device_match(dispc_soc_devices)) + dispc.feat = &omap34xx_rev1_0_dispc_feats; + else + dispc.feat = of_match_device(dispc_of_match, &pdev->dev)->data;
r = dispc_errata_i734_wa_init(); if (r) @@ -4481,15 +4454,6 @@ static const struct dev_pm_ops dispc_pm_ops = { .runtime_resume = dispc_runtime_resume, };
-static const struct of_device_id dispc_of_match[] = { - { .compatible = "ti,omap2-dispc", }, - { .compatible = "ti,omap3-dispc", }, - { .compatible = "ti,omap4-dispc", }, - { .compatible = "ti,omap5-dispc", }, - { .compatible = "ti,dra7-dispc", }, - {}, -}; - static struct platform_driver omap_dispchw_driver = { .probe = dispc_probe, .remove = dispc_remove,
On 08/05/17 14:32, Laurent Pinchart wrote:
Use the compatible string instead of the OMAP SoC revision to determine device features. On OMAP34xx the features depend on the ES revision that can not be determined from the compatible string. Use soc_device_match() in that case.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dispc.c | 84 +++++++++++-------------------------- 1 file changed, 24 insertions(+), 60 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
No device is ever registered that binds with the driver, the DPI port is handled manually. Remove the DPI platform driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 6 --- drivers/gpu/drm/omapdrm/dss/dpi.c | 93 -------------------------------------- drivers/gpu/drm/omapdrm/dss/dss.h | 3 -- 3 files changed, 102 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index bc4fa4ec8557..35def6fd6acd 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -208,9 +208,6 @@ static int (*dss_output_drv_reg_funcs[])(void) __initdata = { #ifdef CONFIG_OMAP2_DSS_DSI dsi_init_platform_driver, #endif -#ifdef CONFIG_OMAP2_DSS_DPI - dpi_init_platform_driver, -#endif #ifdef CONFIG_OMAP2_DSS_SDI sdi_init_platform_driver, #endif @@ -244,9 +241,6 @@ static void (*dss_output_drv_unreg_funcs[])(void) = { #ifdef CONFIG_OMAP2_DSS_SDI sdi_uninit_platform_driver, #endif -#ifdef CONFIG_OMAP2_DSS_DPI - dpi_uninit_platform_driver, -#endif #ifdef CONFIG_OMAP2_DSS_DSI dsi_uninit_platform_driver, #endif diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index e75162d26ac0..3d87f3af72bb 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -32,7 +32,6 @@ #include <linux/string.h> #include <linux/of.h> #include <linux/clk.h> -#include <linux/component.h>
#include "omapdss.h" #include "dss.h" @@ -61,12 +60,6 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev) return container_of(dssdev, struct dpi_data, output); }
-/* only used in non-DT mode */ -static struct dpi_data *dpi_get_data_from_pdev(struct platform_device *pdev) -{ - return dev_get_drvdata(&pdev->dev); -} - static enum dss_clk_source dpi_get_clk_src(enum omap_channel channel) { /* @@ -714,30 +707,6 @@ static const struct omapdss_dpi_ops dpi_ops = { .set_data_lines = dpi_set_data_lines, };
-static void dpi_init_output(struct platform_device *pdev) -{ - struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); - struct omap_dss_device *out = &dpi->output; - - out->dev = &pdev->dev; - out->id = OMAP_DSS_OUTPUT_DPI; - out->output_type = OMAP_DISPLAY_TYPE_DPI; - out->name = "dpi.0"; - out->dispc_channel = dpi_get_channel(0); - out->ops.dpi = &dpi_ops; - out->owner = THIS_MODULE; - - omapdss_register_output(out); -} - -static void dpi_uninit_output(struct platform_device *pdev) -{ - struct dpi_data *dpi = dpi_get_data_from_pdev(pdev); - struct omap_dss_device *out = &dpi->output; - - omapdss_unregister_output(out); -} - static void dpi_init_output_port(struct platform_device *pdev, struct device_node *port) { @@ -782,68 +751,6 @@ static void dpi_uninit_output_port(struct device_node *port) omapdss_unregister_output(out); }
-static int dpi_bind(struct device *dev, struct device *master, void *data) -{ - struct platform_device *pdev = to_platform_device(dev); - struct dpi_data *dpi; - - dpi = devm_kzalloc(&pdev->dev, sizeof(*dpi), GFP_KERNEL); - if (!dpi) - return -ENOMEM; - - dpi->pdev = pdev; - - dev_set_drvdata(&pdev->dev, dpi); - - mutex_init(&dpi->lock); - - dpi_init_output(pdev); - - return 0; -} - -static void dpi_unbind(struct device *dev, struct device *master, void *data) -{ - struct platform_device *pdev = to_platform_device(dev); - - dpi_uninit_output(pdev); -} - -static const struct component_ops dpi_component_ops = { - .bind = dpi_bind, - .unbind = dpi_unbind, -}; - -static int dpi_probe(struct platform_device *pdev) -{ - return component_add(&pdev->dev, &dpi_component_ops); -} - -static int dpi_remove(struct platform_device *pdev) -{ - component_del(&pdev->dev, &dpi_component_ops); - return 0; -} - -static struct platform_driver omap_dpi_driver = { - .probe = dpi_probe, - .remove = dpi_remove, - .driver = { - .name = "omapdss_dpi", - .suppress_bind_attrs = true, - }, -}; - -int __init dpi_init_platform_driver(void) -{ - return platform_driver_register(&omap_dpi_driver); -} - -void dpi_uninit_platform_driver(void) -{ - platform_driver_unregister(&omap_dpi_driver); -} - int dpi_init_port(struct platform_device *pdev, struct device_node *port) { struct dpi_data *dpi; diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index dfb10c9b4102..983838b4f45b 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -329,9 +329,6 @@ static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt) #endif
/* DPI */ -int dpi_init_platform_driver(void) __init; -void dpi_uninit_platform_driver(void); - #ifdef CONFIG_OMAP2_DSS_DPI int dpi_init_port(struct platform_device *pdev, struct device_node *port); void dpi_uninit_port(struct device_node *port);
On 08/05/17 14:32, Laurent Pinchart wrote:
No device is ever registered that binds with the driver, the DPI port is handled manually. Remove the DPI platform driver.
You could add a bit more details: the DPI platform device was used for non-DT booting, which can now be removed.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 6 --- drivers/gpu/drm/omapdrm/dss/dpi.c | 93 -------------------------------------- drivers/gpu/drm/omapdrm/dss/dss.h | 3 -- 3 files changed, 102 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
Hi Tomi,
On Tuesday 09 May 2017 12:06:58 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
No device is ever registered that binds with the driver, the DPI port is handled manually. Remove the DPI platform driver.
You could add a bit more details: the DPI platform device was used for non-DT booting, which can now be removed.
I'll reword the commit message as follows:
drm: omapdrm: dpi: Remove platform driver
The DPI platform driver was used for non-DT platforms only. On DT platforms the DPI port is handled manually. As OMAP display devices are now instantiated from DT only, remove the DPI platform driver.
(same for patch 19/28)
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 6 --- drivers/gpu/drm/omapdrm/dss/dpi.c | 93 --------------------------------- drivers/gpu/drm/omapdrm/dss/dss.h | 3 -- 3 files changed, 102 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The DPI code only needs to differentiate between major OMAP revisions, which can be obtained from the DSS compatible string. Replace the OMAP SoC model checks to prepare for removal of the OMAP SoC version platform data.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dpi.c | 59 +++++++++++++++++---------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 10 ++++++- drivers/gpu/drm/omapdrm/dss/dss.h | 13 +++++++-- 3 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index 3d87f3af72bb..b5cb23c167db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -39,6 +39,7 @@
struct dpi_data { struct platform_device *pdev; + enum dss_device_type type;
struct regulator *vdds_dsi_reg; enum dss_clk_source clk_src; @@ -60,25 +61,21 @@ static struct dpi_data *dpi_get_data_from_dssdev(struct omap_dss_device *dssdev) return container_of(dssdev, struct dpi_data, output); }
-static enum dss_clk_source dpi_get_clk_src(enum omap_channel channel) +static enum dss_clk_source dpi_get_clk_src(struct dpi_data *dpi) { + enum omap_channel channel = dpi->output.dispc_channel; + /* * XXX we can't currently use DSI PLL for DPI with OMAP3, as the DSI PLL * would also be used for DISPC fclk. Meaning, when the DPI output is * disabled, DISPC clock will be disabled, and TV out will stop. */ - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP24xx: - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - case OMAPDSS_VER_OMAP3630: - case OMAPDSS_VER_AM35xx: - case OMAPDSS_VER_AM43xx: + switch (dpi->type) { + case DSS_TYPE_OMAP2: + case DSS_TYPE_OMAP3: return DSS_CLK_SRC_FCK;
- case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: + case DSS_TYPE_OMAP4: switch (channel) { case OMAP_DSS_CHANNEL_LCD: return DSS_CLK_SRC_PLL1_1; @@ -88,7 +85,7 @@ static enum dss_clk_source dpi_get_clk_src(enum omap_channel channel) return DSS_CLK_SRC_FCK; }
- case OMAPDSS_VER_OMAP5: + case DSS_TYPE_OMAP5: switch (channel) { case OMAP_DSS_CHANNEL_LCD: return DSS_CLK_SRC_PLL1_1; @@ -99,7 +96,7 @@ static enum dss_clk_source dpi_get_clk_src(enum omap_channel channel) return DSS_CLK_SRC_FCK; }
- case OMAPDSS_VER_DRA7xx: + case DSS_TYPE_DRA7: switch (channel) { case OMAP_DSS_CHANNEL_LCD: return DSS_CLK_SRC_PLL1_1; @@ -593,7 +590,7 @@ static void dpi_init_pll(struct dpi_data *dpi) if (dpi->pll) return;
- dpi->clk_src = dpi_get_clk_src(dpi->output.dispc_channel); + dpi->clk_src = dpi_get_clk_src(dpi);
pll = dss_pll_find_by_src(dpi->clk_src); if (!pll) @@ -613,18 +610,14 @@ static void dpi_init_pll(struct dpi_data *dpi) * the channel in some more dynamic manner, or get the channel as a user * parameter. */ -static enum omap_channel dpi_get_channel(int port_num) +static enum omap_channel dpi_get_channel(struct dpi_data *dpi, int port_num) { - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP24xx: - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - case OMAPDSS_VER_OMAP3630: - case OMAPDSS_VER_AM35xx: - case OMAPDSS_VER_AM43xx: + switch (dpi->type) { + case DSS_TYPE_OMAP2: + case DSS_TYPE_OMAP3: return OMAP_DSS_CHANNEL_LCD;
- case OMAPDSS_VER_DRA7xx: + case DSS_TYPE_DRA7: switch (port_num) { case 2: return OMAP_DSS_CHANNEL_LCD3; @@ -635,12 +628,10 @@ static enum omap_channel dpi_get_channel(int port_num) return OMAP_DSS_CHANNEL_LCD; }
- case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: + case DSS_TYPE_OMAP4: return OMAP_DSS_CHANNEL_LCD2;
- case OMAPDSS_VER_OMAP5: + case DSS_TYPE_OMAP5: return OMAP_DSS_CHANNEL_LCD3;
default: @@ -707,10 +698,8 @@ static const struct omapdss_dpi_ops dpi_ops = { .set_data_lines = dpi_set_data_lines, };
-static void dpi_init_output_port(struct platform_device *pdev, - struct device_node *port) +static void dpi_init_output_port(struct dpi_data *dpi, struct device_node *port) { - struct dpi_data *dpi = port->data; struct omap_dss_device *out = &dpi->output; int r; u32 port_num; @@ -732,10 +721,10 @@ static void dpi_init_output_port(struct platform_device *pdev, break; }
- out->dev = &pdev->dev; + out->dev = &dpi->pdev->dev; out->id = OMAP_DSS_OUTPUT_DPI; out->output_type = OMAP_DISPLAY_TYPE_DPI; - out->dispc_channel = dpi_get_channel(port_num); + out->dispc_channel = dpi_get_channel(dpi, port_num); out->port_num = port_num; out->ops.dpi = &dpi_ops; out->owner = THIS_MODULE; @@ -751,7 +740,8 @@ static void dpi_uninit_output_port(struct device_node *port) omapdss_unregister_output(out); }
-int dpi_init_port(struct platform_device *pdev, struct device_node *port) +int dpi_init_port(struct platform_device *pdev, struct device_node *port, + enum dss_device_type type) { struct dpi_data *dpi; struct device_node *ep; @@ -777,11 +767,12 @@ int dpi_init_port(struct platform_device *pdev, struct device_node *port) of_node_put(ep);
dpi->pdev = pdev; + dpi->type = type; port->data = dpi;
mutex_init(&dpi->lock);
- dpi_init_output_port(pdev, port); + dpi_init_output_port(dpi, port);
dpi->port_initialized = true;
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index fb57c0471000..6196f3ab73b7 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -69,6 +69,7 @@ struct dss_reg { dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
struct dss_features { + enum dss_device_type type; u8 fck_div_max; u8 dss_fck_multiplier; const char *parent_clk_name; @@ -916,6 +917,7 @@ static const enum omap_display_type dra7xx_ports[] = { };
static const struct dss_features omap24xx_dss_feats = { + .type = DSS_TYPE_OMAP2, /* * fck div max is really 16, but the divider range has gaps. The range * from 1 to 6 has no gaps, so let's use that as a max. @@ -929,6 +931,7 @@ static const struct dss_features omap24xx_dss_feats = { };
static const struct dss_features omap34xx_dss_feats = { + .type = DSS_TYPE_OMAP3, .fck_div_max = 16, .dss_fck_multiplier = 2, .parent_clk_name = "dpll4_ck", @@ -938,6 +941,7 @@ static const struct dss_features omap34xx_dss_feats = { };
static const struct dss_features omap3630_dss_feats = { + .type = DSS_TYPE_OMAP3, .fck_div_max = 32, .dss_fck_multiplier = 1, .parent_clk_name = "dpll4_ck", @@ -947,6 +951,7 @@ static const struct dss_features omap3630_dss_feats = { };
static const struct dss_features omap44xx_dss_feats = { + .type = DSS_TYPE_OMAP4, .fck_div_max = 32, .dss_fck_multiplier = 1, .parent_clk_name = "dpll_per_x2_ck", @@ -957,6 +962,7 @@ static const struct dss_features omap44xx_dss_feats = { };
static const struct dss_features omap54xx_dss_feats = { + .type = DSS_TYPE_OMAP5, .fck_div_max = 64, .dss_fck_multiplier = 1, .parent_clk_name = "dpll_per_x2_ck", @@ -967,6 +973,7 @@ static const struct dss_features omap54xx_dss_feats = { };
static const struct dss_features am43xx_dss_feats = { + .type = DSS_TYPE_OMAP3, .fck_div_max = 0, .dss_fck_multiplier = 0, .parent_clk_name = NULL, @@ -976,6 +983,7 @@ static const struct dss_features am43xx_dss_feats = { };
static const struct dss_features dra7xx_dss_feats = { + .type = DSS_TYPE_DRA7, .fck_div_max = 64, .dss_fck_multiplier = 1, .parent_clk_name = "dpll_per_x2_ck", @@ -1070,7 +1078,7 @@ static int dss_init_ports(struct platform_device *pdev)
switch (port_type) { case OMAP_DISPLAY_TYPE_DPI: - dpi_init_port(pdev, port); + dpi_init_port(pdev, port, dss.feat->type); break; case OMAP_DISPLAY_TYPE_SDI: sdi_init_port(pdev, port); diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 983838b4f45b..6360feea87cb 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -75,6 +75,14 @@ #define FLD_MOD(orig, val, start, end) \ (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
+enum dss_device_type { + DSS_TYPE_OMAP2, + DSS_TYPE_OMAP3, + DSS_TYPE_OMAP4, + DSS_TYPE_OMAP5, + DSS_TYPE_DRA7, +}; + enum dss_io_pad_mode { DSS_IO_PAD_MODE_RESET, DSS_IO_PAD_MODE_RFBI, @@ -330,11 +338,12 @@ static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
/* DPI */ #ifdef CONFIG_OMAP2_DSS_DPI -int dpi_init_port(struct platform_device *pdev, struct device_node *port); +int dpi_init_port(struct platform_device *pdev, struct device_node *port, + enum dss_device_type type); void dpi_uninit_port(struct device_node *port); #else static inline int dpi_init_port(struct platform_device *pdev, - struct device_node *port) + struct device_node *port, enum dss_device_type type) { return 0; }
On 08/05/17 14:32, Laurent Pinchart wrote:
The DPI code only needs to differentiate between major OMAP revisions, which can be obtained from the DSS compatible string. Replace the OMAP SoC model checks to prepare for removal of the OMAP SoC version platform data.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dpi.c | 59 +++++++++++++++++---------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 10 ++++++- drivers/gpu/drm/omapdrm/dss/dss.h | 13 +++++++-- 3 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index 3d87f3af72bb..b5cb23c167db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -39,6 +39,7 @@
struct dpi_data { struct platform_device *pdev;
- enum dss_device_type type;
I really don't like "dss_device_type" or "type" here... "dss_version"? Or maybe it should be tied to DPI, so "dpi_version"?
Tomi
Hi Tomi,
On Tuesday 09 May 2017 12:23:13 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
The DPI code only needs to differentiate between major OMAP revisions, which can be obtained from the DSS compatible string. Replace the OMAP SoC model checks to prepare for removal of the OMAP SoC version platform data.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dpi.c | 59 ++++++++++++++-------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 10 ++++++- drivers/gpu/drm/omapdrm/dss/dss.h | 13 +++++++-- 3 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index 3d87f3af72bb..b5cb23c167db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -39,6 +39,7 @@
struct dpi_data { struct platform_device *pdev;
- enum dss_device_type type;
I really don't like "dss_device_type" or "type" here... "dss_version"? Or maybe it should be tied to DPI, so "dpi_version"?
I don't think it should be tied to the DPI, as it's really the DSS version that matters here. I'll rename dss_device_type to dss_version.
Note that I don't think the type field should be stored in the dpi_data structure. It should be part of the dss structure, which should become visible to the DPI code. I plan to rework the driver in this direction, but in the meantime I think we could merge this patch (after renaming the enum) as it doesn't make the current situation any worse.
Hi Tomi,
On Wednesday 10 May 2017 01:24:52 Laurent Pinchart wrote:
On Tuesday 09 May 2017 12:23:13 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
The DPI code only needs to differentiate between major OMAP revisions, which can be obtained from the DSS compatible string. Replace the OMAP SoC model checks to prepare for removal of the OMAP SoC version platform data.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dpi.c | 59 ++++++++++++++-------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 10 ++++++- drivers/gpu/drm/omapdrm/dss/dss.h | 13 +++++++-- 3 files changed, 45 insertions(+), 37 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dpi.c b/drivers/gpu/drm/omapdrm/dss/dpi.c index 3d87f3af72bb..b5cb23c167db 100644 --- a/drivers/gpu/drm/omapdrm/dss/dpi.c +++ b/drivers/gpu/drm/omapdrm/dss/dpi.c @@ -39,6 +39,7 @@
struct dpi_data {
struct platform_device *pdev;
- enum dss_device_type type;
I really don't like "dss_device_type" or "type" here... "dss_version"? Or maybe it should be tied to DPI, so "dpi_version"?
I don't think it should be tied to the DPI, as it's really the DSS version that matters here. I'll rename dss_device_type to dss_version.
Thinking about it again, how about dss_model ?
Note that I don't think the type field should be stored in the dpi_data structure. It should be part of the dss structure, which should become visible to the DPI code. I plan to rework the driver in this direction, but in the meantime I think we could merge this patch (after renaming the enum) as it doesn't make the current situation any worse.
The DSI PLL hardware data and DSS channels are selected based on the OMAP SoC model. There's no need for fine-grained model information, as the driver only needs to differentiate between OMAP3, OMAP4 and OMAP5. As this can be done through the DSI compatible string, store the corresponding information in OF match data instead to avoid accessing the OMAP SoC model.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dsi.c | 116 ++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 61 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 3edd194d6f36..400f903d8197 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -227,6 +227,12 @@ static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel); #define DSI_MAX_NR_ISRS 2 #define DSI_MAX_NR_LANES 5
+enum dsi_device_type { + DSI_TYPE_OMAP3, + DSI_TYPE_OMAP4, + DSI_TYPE_OMAP5, +}; + enum dsi_lane_function { DSI_LANE_UNUSED = 0, DSI_LANE_CLK, @@ -298,12 +304,24 @@ struct dsi_lp_clock_info { u16 lp_clk_div; };
+struct dsi_module_id_data { + u32 address; + int id; +}; + +struct dsi_of_data { + enum dsi_device_type type; + const struct dss_pll_hw *pll_hw; + const struct dsi_module_id_data *modules; +}; + struct dsi_data { struct platform_device *pdev; void __iomem *proto_base; void __iomem *phy_base; void __iomem *pll_base;
+ const struct dsi_of_data *data; int module_id;
int irq; @@ -396,11 +414,6 @@ struct dsi_packet_sent_handler_data { struct completion *completion; };
-struct dsi_module_id_data { - u32 address; - int id; -}; - static const struct of_device_id dsi_of_match[];
#ifdef DSI_PERF_MEASURE @@ -4857,24 +4870,14 @@ static int dsi_set_config(struct omap_dss_device *dssdev, * the channel in some more dynamic manner, or get the channel as a user * parameter. */ -static enum omap_channel dsi_get_channel(int module_id) +static enum omap_channel dsi_get_channel(struct dsi_data *dsi) { - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP24xx: - case OMAPDSS_VER_AM43xx: - DSSWARN("DSI not supported\n"); - return OMAP_DSS_CHANNEL_LCD; - - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - case OMAPDSS_VER_OMAP3630: - case OMAPDSS_VER_AM35xx: + switch (dsi->data->type) { + case DSI_TYPE_OMAP3: return OMAP_DSS_CHANNEL_LCD;
- case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: - switch (module_id) { + case DSI_TYPE_OMAP4: + switch (dsi->module_id) { case 0: return OMAP_DSS_CHANNEL_LCD; case 1: @@ -4884,8 +4887,8 @@ static enum omap_channel dsi_get_channel(int module_id) return OMAP_DSS_CHANNEL_LCD; }
- case OMAPDSS_VER_OMAP5: - switch (module_id) { + case DSI_TYPE_OMAP5: + switch (dsi->module_id) { case 0: return OMAP_DSS_CHANNEL_LCD; case 1: @@ -5065,7 +5068,7 @@ static void dsi_init_output(struct platform_device *dsidev)
out->output_type = OMAP_DISPLAY_TYPE_DSI; out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1"; - out->dispc_channel = dsi_get_channel(dsi->module_id); + out->dispc_channel = dsi_get_channel(dsi); out->ops.dsi = &dsi_ops; out->owner = THIS_MODULE;
@@ -5240,29 +5243,7 @@ static int dsi_init_pll_data(struct platform_device *dsidev) pll->id = dsi->module_id == 0 ? DSS_PLL_DSI1 : DSS_PLL_DSI2; pll->clkin = clk; pll->base = dsi->pll_base; - - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - case OMAPDSS_VER_OMAP3630: - case OMAPDSS_VER_AM35xx: - pll->hw = &dss_omap3_dsi_pll_hw; - break; - - case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: - pll->hw = &dss_omap4_dsi_pll_hw; - break; - - case OMAPDSS_VER_OMAP5: - pll->hw = &dss_omap5_dsi_pll_hw; - break; - - default: - return -ENODEV; - } - + pll->hw = dsi->data->pll_hw; pll->ops = &dsi_pll_ops;
r = dss_pll_register(pll); @@ -5339,7 +5320,8 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) return r; }
- d = of_match_node(dsi_of_match, dsidev->dev.of_node)->data; + dsi->data = of_match_node(dsi_of_match, dsidev->dev.of_node)->data; + d = dsi->data->modules; while (d->address != 0 && d->address != dsi_mem->start) d++;
@@ -5495,27 +5477,39 @@ static const struct dev_pm_ops dsi_pm_ops = { .runtime_resume = dsi_runtime_resume, };
-static const struct dsi_module_id_data dsi_of_data_omap3[] = { - { .address = 0x4804fc00, .id = 0, }, - { }, +static const struct dsi_of_data dsi_of_data_omap3 = { + .type = DSI_TYPE_OMAP3, + .pll_hw = &dss_omap3_dsi_pll_hw, + .modules = (const struct dsi_module_id_data[]) { + { .address = 0x4804fc00, .id = 0, }, + { }, + }, };
-static const struct dsi_module_id_data dsi_of_data_omap4[] = { - { .address = 0x58004000, .id = 0, }, - { .address = 0x58005000, .id = 1, }, - { }, +static const struct dsi_of_data dsi_of_data_omap4 = { + .type = DSI_TYPE_OMAP4, + .pll_hw = &dss_omap4_dsi_pll_hw, + .modules = (const struct dsi_module_id_data[]) { + { .address = 0x58004000, .id = 0, }, + { .address = 0x58005000, .id = 1, }, + { }, + }, };
-static const struct dsi_module_id_data dsi_of_data_omap5[] = { - { .address = 0x58004000, .id = 0, }, - { .address = 0x58009000, .id = 1, }, - { }, +static const struct dsi_of_data dsi_of_data_omap5 = { + .type = DSI_TYPE_OMAP5, + .pll_hw = &dss_omap5_dsi_pll_hw, + .modules = (const struct dsi_module_id_data[]) { + { .address = 0x58004000, .id = 0, }, + { .address = 0x58009000, .id = 1, }, + { }, + }, };
static const struct of_device_id dsi_of_match[] = { - { .compatible = "ti,omap3-dsi", .data = dsi_of_data_omap3, }, - { .compatible = "ti,omap4-dsi", .data = dsi_of_data_omap4, }, - { .compatible = "ti,omap5-dsi", .data = dsi_of_data_omap5, }, + { .compatible = "ti,omap3-dsi", .data = &dsi_of_data_omap3, }, + { .compatible = "ti,omap4-dsi", .data = &dsi_of_data_omap4, }, + { .compatible = "ti,omap5-dsi", .data = &dsi_of_data_omap5, }, {}, };
On 08/05/17 14:32, Laurent Pinchart wrote:
The DSI PLL hardware data and DSS channels are selected based on the OMAP SoC model. There's no need for fine-grained model information, as the driver only needs to differentiate between OMAP3, OMAP4 and OMAP5. As this can be done through the DSI compatible string, store the corresponding information in OF match data instead to avoid accessing the OMAP SoC model.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dsi.c | 116 ++++++++++++++++++-------------------- 1 file changed, 55 insertions(+), 61 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 3edd194d6f36..400f903d8197 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -227,6 +227,12 @@ static int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel); #define DSI_MAX_NR_ISRS 2 #define DSI_MAX_NR_LANES 5
+enum dsi_device_type {
- DSI_TYPE_OMAP3,
- DSI_TYPE_OMAP4,
- DSI_TYPE_OMAP5,
+};
Same comment here as for the DPI. At least to me "type" doesn't sound like what we're looking for here. If I read "switch (dsi->data->type)" my thought is not that we're checking the DSI version. Although "DSI version" is maybe not an exact match either... It's about how the DSI has been integrated in that particular SoC, and which PLL version we have.
Tomi
Don't rely on callback functions provided by the platform, but access the syscon internally to mux the DSI pins.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 20 ---------- drivers/gpu/drm/omapdrm/dss/dsi.c | 82 ++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 2 - 3 files changed, 79 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 35def6fd6acd..524ecdd138f4 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -50,26 +50,6 @@ enum omapdss_version omapdss_get_version(void) } EXPORT_SYMBOL(omapdss_get_version);
-int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask) -{ - struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; - - if (!board_data->dsi_enable_pads) - return -ENOENT; - - return board_data->dsi_enable_pads(dsi_id, lane_mask); -} - -void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask) -{ - struct omap_dss_board_info *board_data = core.pdev->dev.platform_data; - - if (!board_data->dsi_disable_pads) - return; - - return board_data->dsi_disable_pads(dsi_id, lane_mask); -} - int dss_set_min_bus_tput(struct device *dev, unsigned long tput) { struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 400f903d8197..d86a1ca6da00 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -20,6 +20,8 @@ #define DSS_SUBSYS_NAME "DSI"
#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include <linux/io.h> #include <linux/clk.h> #include <linux/device.h> @@ -329,6 +331,7 @@ struct dsi_data { bool is_enabled;
struct clk *dss_clk; + struct regmap *syscon;
struct dispc_clock_info user_dispc_cinfo; struct dss_pll_clock_info user_dsi_cinfo; @@ -2073,6 +2076,64 @@ static unsigned dsi_get_lane_mask(struct platform_device *dsidev) return mask; }
+/* OMAP4 CONTROL_DSIPHY */ +#define OMAP4_DSIPHY_SYSCON_OFFSET 0x78 + +#define OMAP4_DSI2_LANEENABLE_SHIFT 29 +#define OMAP4_DSI2_LANEENABLE_MASK (0x7 << 29) +#define OMAP4_DSI1_LANEENABLE_SHIFT 24 +#define OMAP4_DSI1_LANEENABLE_MASK (0x1f << 24) +#define OMAP4_DSI1_PIPD_SHIFT 19 +#define OMAP4_DSI1_PIPD_MASK (0x1f << 19) +#define OMAP4_DSI2_PIPD_SHIFT 14 +#define OMAP4_DSI2_PIPD_MASK (0x1f << 14) + +static int dsi_omap4_mux_pads(struct dsi_data *dsi, unsigned int lanes) +{ + u32 enable_mask, enable_shift; + u32 pipd_mask, pipd_shift; + u32 reg; + + if (!dsi->syscon) + return 0; + + if (dsi->module_id == 0) { + enable_mask = OMAP4_DSI1_LANEENABLE_MASK; + enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT; + pipd_mask = OMAP4_DSI1_PIPD_MASK; + pipd_shift = OMAP4_DSI1_PIPD_SHIFT; + } else if (dsi->module_id == 1) { + enable_mask = OMAP4_DSI2_LANEENABLE_MASK; + enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT; + pipd_mask = OMAP4_DSI2_PIPD_MASK; + pipd_shift = OMAP4_DSI2_PIPD_SHIFT; + } else { + return -ENODEV; + } + + regmap_read(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, ®); + + reg &= ~enable_mask; + reg &= ~pipd_mask; + + reg |= (lanes << enable_shift) & enable_mask; + reg |= (lanes << pipd_shift) & pipd_mask; + + regmap_write(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, reg); + + return 0; +} + +static int dsi_enable_pads(struct dsi_data *dsi, unsigned int lane_mask) +{ + return dsi_omap4_mux_pads(dsi, lane_mask); +} + +static void dsi_disable_pads(struct dsi_data *dsi) +{ + dsi_omap4_mux_pads(dsi, 0); +} + static int dsi_cio_init(struct platform_device *dsidev) { struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); @@ -2081,7 +2142,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
DSSDBG("DSI CIO init starts");
- r = dss_dsi_enable_pads(dsi->module_id, dsi_get_lane_mask(dsidev)); + r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsidev)); if (r) return r;
@@ -2191,7 +2252,7 @@ static int dsi_cio_init(struct platform_device *dsidev) dsi_cio_disable_lane_override(dsidev); err_scp_clk_dom: dsi_disable_scp_clk(dsidev); - dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev)); + dsi_disable_pads(dsi); return r; }
@@ -2204,7 +2265,7 @@ static void dsi_cio_uninit(struct platform_device *dsidev)
dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF); dsi_disable_scp_clk(dsidev); - dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev)); + dsi_disable_pads(dsi); }
static void dsi_config_tx_fifo(struct platform_device *dsidev, @@ -5332,6 +5393,21 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
dsi->module_id = d->id;
+ if (dsi->data->type == DSI_TYPE_OMAP4) { + struct device_node *np; + + /* + * The OMAP4 display DT bindings don't reference the padconf + * syscon. Our only option to retrieve it is to find it by name. + */ + np = of_find_node_by_name(NULL, "omap4_padconf_global"); + if (!np) + return -ENODEV; + + dsi->syscon = syscon_node_to_regmap(np); + of_node_put(np); + } + /* DSI VCs initialization */ for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { dsi->vc[i].source = DSI_VC_SOURCE_L4; diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 6360feea87cb..bc75c5f8a5fe 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -230,8 +230,6 @@ struct seq_file; struct platform_device;
/* core */ -int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask); -void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask); int dss_set_min_bus_tput(struct device *dev, unsigned long tput); int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
On 08/05/17 14:32, Laurent Pinchart wrote:
Don't rely on callback functions provided by the platform, but access the syscon internally to mux the DSI pins.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 20 ---------- drivers/gpu/drm/omapdrm/dss/dsi.c | 82 ++++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 2 - 3 files changed, 79 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 35def6fd6acd..524ecdd138f4 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -50,26 +50,6 @@ enum omapdss_version omapdss_get_version(void) } EXPORT_SYMBOL(omapdss_get_version);
-int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask) -{
- struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
- if (!board_data->dsi_enable_pads)
return -ENOENT;
- return board_data->dsi_enable_pads(dsi_id, lane_mask);
-}
-void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask) -{
- struct omap_dss_board_info *board_data = core.pdev->dev.platform_data;
- if (!board_data->dsi_disable_pads)
return;
- return board_data->dsi_disable_pads(dsi_id, lane_mask);
-}
int dss_set_min_bus_tput(struct device *dev, unsigned long tput) { struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 400f903d8197..d86a1ca6da00 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c @@ -20,6 +20,8 @@ #define DSS_SUBSYS_NAME "DSI"
#include <linux/kernel.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include <linux/io.h> #include <linux/clk.h> #include <linux/device.h> @@ -329,6 +331,7 @@ struct dsi_data { bool is_enabled;
struct clk *dss_clk;
struct regmap *syscon;
struct dispc_clock_info user_dispc_cinfo; struct dss_pll_clock_info user_dsi_cinfo;
@@ -2073,6 +2076,64 @@ static unsigned dsi_get_lane_mask(struct platform_device *dsidev) return mask; }
+/* OMAP4 CONTROL_DSIPHY */ +#define OMAP4_DSIPHY_SYSCON_OFFSET 0x78
+#define OMAP4_DSI2_LANEENABLE_SHIFT 29 +#define OMAP4_DSI2_LANEENABLE_MASK (0x7 << 29) +#define OMAP4_DSI1_LANEENABLE_SHIFT 24 +#define OMAP4_DSI1_LANEENABLE_MASK (0x1f << 24) +#define OMAP4_DSI1_PIPD_SHIFT 19 +#define OMAP4_DSI1_PIPD_MASK (0x1f << 19) +#define OMAP4_DSI2_PIPD_SHIFT 14 +#define OMAP4_DSI2_PIPD_MASK (0x1f << 14)
+static int dsi_omap4_mux_pads(struct dsi_data *dsi, unsigned int lanes) +{
- u32 enable_mask, enable_shift;
- u32 pipd_mask, pipd_shift;
- u32 reg;
- if (!dsi->syscon)
return 0;
- if (dsi->module_id == 0) {
enable_mask = OMAP4_DSI1_LANEENABLE_MASK;
enable_shift = OMAP4_DSI1_LANEENABLE_SHIFT;
pipd_mask = OMAP4_DSI1_PIPD_MASK;
pipd_shift = OMAP4_DSI1_PIPD_SHIFT;
- } else if (dsi->module_id == 1) {
enable_mask = OMAP4_DSI2_LANEENABLE_MASK;
enable_shift = OMAP4_DSI2_LANEENABLE_SHIFT;
pipd_mask = OMAP4_DSI2_PIPD_MASK;
pipd_shift = OMAP4_DSI2_PIPD_SHIFT;
- } else {
return -ENODEV;
- }
- regmap_read(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, ®);
- reg &= ~enable_mask;
- reg &= ~pipd_mask;
- reg |= (lanes << enable_shift) & enable_mask;
- reg |= (lanes << pipd_shift) & pipd_mask;
- regmap_write(dsi->syscon, OMAP4_DSIPHY_SYSCON_OFFSET, reg);
- return 0;
+}
+static int dsi_enable_pads(struct dsi_data *dsi, unsigned int lane_mask) +{
- return dsi_omap4_mux_pads(dsi, lane_mask);
+}
+static void dsi_disable_pads(struct dsi_data *dsi) +{
- dsi_omap4_mux_pads(dsi, 0);
+}
static int dsi_cio_init(struct platform_device *dsidev) { struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); @@ -2081,7 +2142,7 @@ static int dsi_cio_init(struct platform_device *dsidev)
DSSDBG("DSI CIO init starts");
- r = dss_dsi_enable_pads(dsi->module_id, dsi_get_lane_mask(dsidev));
- r = dsi_enable_pads(dsi, dsi_get_lane_mask(dsidev)); if (r) return r;
@@ -2191,7 +2252,7 @@ static int dsi_cio_init(struct platform_device *dsidev) dsi_cio_disable_lane_override(dsidev); err_scp_clk_dom: dsi_disable_scp_clk(dsidev);
- dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev));
- dsi_disable_pads(dsi); return r;
}
@@ -2204,7 +2265,7 @@ static void dsi_cio_uninit(struct platform_device *dsidev)
dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF); dsi_disable_scp_clk(dsidev);
- dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dsidev));
- dsi_disable_pads(dsi);
}
static void dsi_config_tx_fifo(struct platform_device *dsidev, @@ -5332,6 +5393,21 @@ static int dsi_bind(struct device *dev, struct device *master, void *data)
dsi->module_id = d->id;
- if (dsi->data->type == DSI_TYPE_OMAP4) {
struct device_node *np;
/*
* The OMAP4 display DT bindings don't reference the padconf
* syscon. Our only option to retrieve it is to find it by name.
*/
We could also do DT modifications at early boot phase (we do that already for a few things for tilcdc and omapdss), and then have the driver require the reference to padconf.
But I think this is fine too.
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
Hi Tomi,
On Tuesday 09 May 2017 12:37:36 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Don't rely on callback functions provided by the platform, but access the syscon internally to mux the DSI pins.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 20 ---------- drivers/gpu/drm/omapdrm/dss/dsi.c | 82 +++++++++++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 2 - 3 files changed, 79 insertions(+), 25 deletions(-)
[snip]
diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c index 400f903d8197..d86a1ca6da00 100644 --- a/drivers/gpu/drm/omapdrm/dss/dsi.c +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c
[snip]
@@ -5332,6 +5393,21 @@ static int dsi_bind(struct device *dev, struct device *master, void *data) dsi->module_id = d->id;
- if (dsi->data->type == DSI_TYPE_OMAP4) {
struct device_node *np;
/*
* The OMAP4 display DT bindings don't reference the padconf
* syscon. Our only option to retrieve it is to find it by
name.
*/
We could also do DT modifications at early boot phase (we do that already for a few things for tilcdc and omapdss), and then have the driver require the reference to padconf.
That's a good idea too, but I'd do that as a second step to avoid adding more dependencies on arch/arm/mach-omap2/ in this series.
But I think this is fine too.
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Use the compatible string instead of the OMAP SoC revision to determine device features. The various OMAP3-based SoCs can be told apart from the compatible string, use soc_device_match() to tell them apart.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dss.c | 97 ++++++++++++--------------------------- 1 file changed, 29 insertions(+), 68 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 6196f3ab73b7..5739d0d6216f 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -38,9 +38,11 @@ #include <linux/mfd/syscon.h> #include <linux/regmap.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/regulator/consumer.h> #include <linux/suspend.h> #include <linux/component.h> +#include <linux/sys_soc.h>
#include "omapdss.h" #include "dss.h" @@ -993,60 +995,6 @@ static const struct dss_features dra7xx_dss_feats = { .select_lcd_source = &dss_lcd_clk_mux_dra7, };
-static int dss_init_features(struct platform_device *pdev) -{ - const struct dss_features *src; - struct dss_features *dst; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate local DSS Features\n"); - return -ENOMEM; - } - - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP24xx: - src = &omap24xx_dss_feats; - break; - - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - case OMAPDSS_VER_AM35xx: - src = &omap34xx_dss_feats; - break; - - case OMAPDSS_VER_OMAP3630: - src = &omap3630_dss_feats; - break; - - case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: - src = &omap44xx_dss_feats; - break; - - case OMAPDSS_VER_OMAP5: - src = &omap54xx_dss_feats; - break; - - case OMAPDSS_VER_AM43xx: - src = &am43xx_dss_feats; - break; - - case OMAPDSS_VER_DRA7xx: - src = &dra7xx_dss_feats; - break; - - default: - return -ENODEV; - } - - memcpy(dst, src, sizeof(*dst)); - dss.feat = dst; - - return 0; -} - static int dss_init_ports(struct platform_device *pdev) { struct device_node *parent = pdev->dev.of_node; @@ -1195,18 +1143,42 @@ static int dss_video_pll_probe(struct platform_device *pdev) }
/* DSS HW IP initialisation */ +static const struct of_device_id dss_of_match[] = { + { .compatible = "ti,omap2-dss", .data = &omap24xx_dss_feats }, + { .compatible = "ti,omap3-dss", .data = &omap3630_dss_feats }, + { .compatible = "ti,omap4-dss", .data = &omap44xx_dss_feats }, + { .compatible = "ti,omap5-dss", .data = &omap54xx_dss_feats }, + { .compatible = "ti,dra7-dss", .data = &dra7xx_dss_feats }, + {}, +}; +MODULE_DEVICE_TABLE(of, dss_of_match); + +static const struct soc_device_attribute dss_soc_devices[] = { + { .machine = "OMAP3430/3530", .data = &omap34xx_dss_feats }, + { .machine = "AM35??", .data = &omap34xx_dss_feats }, + { .family = "AM43xx", .data = &am43xx_dss_feats }, + { /* sentinel */ } +}; + static int dss_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); + const struct soc_device_attribute *soc; struct resource *dss_mem; u32 rev; int r;
dss.pdev = pdev;
- r = dss_init_features(dss.pdev); - if (r) - return r; + /* + * The various OMAP3-based SoCs can be told apart from the compatible + * string, use SoC device matching. + */ + soc = soc_device_match(dss_soc_devices); + if (soc) + dss.feat = soc->data; + else + dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); dss.base = devm_ioremap_resource(&pdev->dev, dss_mem); @@ -1394,17 +1366,6 @@ static const struct dev_pm_ops dss_pm_ops = { .runtime_resume = dss_runtime_resume, };
-static const struct of_device_id dss_of_match[] = { - { .compatible = "ti,omap2-dss", }, - { .compatible = "ti,omap3-dss", }, - { .compatible = "ti,omap4-dss", }, - { .compatible = "ti,omap5-dss", }, - { .compatible = "ti,dra7-dss", }, - {}, -}; - -MODULE_DEVICE_TABLE(of, dss_of_match); - static struct platform_driver omap_dsshw_driver = { .probe = dss_probe, .remove = dss_remove,
On 08/05/17 14:32, Laurent Pinchart wrote:
Use the compatible string instead of the OMAP SoC revision to determine device features. The various OMAP3-based SoCs can be told apart from the compatible string, use soc_device_match() to tell them apart.
Here, and in a comment below, you probably mean "can _not_ be told apart _using_ the compatible string".
Tomi
Hi Tomi,
On Tuesday 09 May 2017 12:41:26 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Use the compatible string instead of the OMAP SoC revision to determine device features. The various OMAP3-based SoCs can be told apart from the compatible string, use soc_device_match() to tell them apart.
Here, and in a comment below, you probably mean "can _not_ be told apart _using_ the compatible string".
Oops, indeed. Anything else I need to change in this patch, or do I get your Reviewed-by if I fix the comment and the commit message ?
On 10/05/17 00:47, Laurent Pinchart wrote:
Hi Tomi,
On Tuesday 09 May 2017 12:41:26 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Use the compatible string instead of the OMAP SoC revision to determine device features. The various OMAP3-based SoCs can be told apart from the compatible string, use soc_device_match() to tell them apart.
Here, and in a comment below, you probably mean "can _not_ be told apart _using_ the compatible string".
Oops, indeed. Anything else I need to change in this patch, or do I get your Reviewed-by if I fix the comment and the commit message ?
Yes:
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
Move the two function pointers to a new dss_ops structure. This will allow merging the dss_features and omap_dss_features structures without having to expose the DPI source selection and LCD clock muxing functions in header files.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dss.c | 50 +++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 5739d0d6216f..7546ba8ab955 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -70,6 +70,12 @@ struct dss_reg { #define REG_FLD_MOD(idx, val, start, end) \ dss_write_reg(idx, FLD_MOD(dss_read_reg(idx), val, start, end))
+struct dss_ops { + int (*dpi_select_source)(int port, enum omap_channel channel); + int (*select_lcd_source)(enum omap_channel channel, + enum dss_clk_source clk_src); +}; + struct dss_features { enum dss_device_type type; u8 fck_div_max; @@ -77,9 +83,7 @@ struct dss_features { const char *parent_clk_name; const enum omap_display_type *ports; int num_ports; - int (*dpi_select_source)(int port, enum omap_channel channel); - int (*select_lcd_source)(enum omap_channel channel, - enum dss_clk_source clk_src); + const struct dss_ops *ops; };
static struct { @@ -586,7 +590,7 @@ void dss_select_lcd_clk_source(enum omap_channel channel, return; }
- r = dss.feat->select_lcd_source(channel, clk_src); + r = dss.feat->ops->select_lcd_source(channel, clk_src); if (r) return;
@@ -833,7 +837,7 @@ static int dss_dpi_select_source_dra7xx(int port, enum omap_channel channel)
int dss_dpi_select_source(int port, enum omap_channel channel) { - return dss.feat->dpi_select_source(port, channel); + return dss.feat->ops->dpi_select_source(port, channel); }
static int dss_get_clocks(void) @@ -903,6 +907,25 @@ void dss_debug_dump_clocks(struct seq_file *s) #endif
+static const struct dss_ops dss_ops_omap2_omap3 = { + .dpi_select_source = &dss_dpi_select_source_omap2_omap3, +}; + +static const struct dss_ops dss_ops_omap4 = { + .dpi_select_source = &dss_dpi_select_source_omap4, + .select_lcd_source = &dss_lcd_clk_mux_omap4, +}; + +static const struct dss_ops dss_ops_omap5 = { + .dpi_select_source = &dss_dpi_select_source_omap5, + .select_lcd_source = &dss_lcd_clk_mux_omap5, +}; + +static const struct dss_ops dss_ops_dra7 = { + .dpi_select_source = &dss_dpi_select_source_dra7xx, + .select_lcd_source = &dss_lcd_clk_mux_dra7, +}; + static const enum omap_display_type omap2plus_ports[] = { OMAP_DISPLAY_TYPE_DPI, }; @@ -927,9 +950,9 @@ static const struct dss_features omap24xx_dss_feats = { .fck_div_max = 6, .dss_fck_multiplier = 2, .parent_clk_name = "core_ck", - .dpi_select_source = &dss_dpi_select_source_omap2_omap3, .ports = omap2plus_ports, .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, };
static const struct dss_features omap34xx_dss_feats = { @@ -937,9 +960,9 @@ static const struct dss_features omap34xx_dss_feats = { .fck_div_max = 16, .dss_fck_multiplier = 2, .parent_clk_name = "dpll4_ck", - .dpi_select_source = &dss_dpi_select_source_omap2_omap3, .ports = omap34xx_ports, .num_ports = ARRAY_SIZE(omap34xx_ports), + .ops = &dss_ops_omap2_omap3, };
static const struct dss_features omap3630_dss_feats = { @@ -947,9 +970,9 @@ static const struct dss_features omap3630_dss_feats = { .fck_div_max = 32, .dss_fck_multiplier = 1, .parent_clk_name = "dpll4_ck", - .dpi_select_source = &dss_dpi_select_source_omap2_omap3, .ports = omap2plus_ports, .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, };
static const struct dss_features omap44xx_dss_feats = { @@ -957,10 +980,9 @@ static const struct dss_features omap44xx_dss_feats = { .fck_div_max = 32, .dss_fck_multiplier = 1, .parent_clk_name = "dpll_per_x2_ck", - .dpi_select_source = &dss_dpi_select_source_omap4, .ports = omap2plus_ports, .num_ports = ARRAY_SIZE(omap2plus_ports), - .select_lcd_source = &dss_lcd_clk_mux_omap4, + .ops = &dss_ops_dra7, };
static const struct dss_features omap54xx_dss_feats = { @@ -968,10 +990,9 @@ static const struct dss_features omap54xx_dss_feats = { .fck_div_max = 64, .dss_fck_multiplier = 1, .parent_clk_name = "dpll_per_x2_ck", - .dpi_select_source = &dss_dpi_select_source_omap5, .ports = omap2plus_ports, .num_ports = ARRAY_SIZE(omap2plus_ports), - .select_lcd_source = &dss_lcd_clk_mux_omap5, + .ops = &dss_ops_omap5, };
static const struct dss_features am43xx_dss_feats = { @@ -979,9 +1000,9 @@ static const struct dss_features am43xx_dss_feats = { .fck_div_max = 0, .dss_fck_multiplier = 0, .parent_clk_name = NULL, - .dpi_select_source = &dss_dpi_select_source_omap2_omap3, .ports = omap2plus_ports, .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, };
static const struct dss_features dra7xx_dss_feats = { @@ -989,10 +1010,9 @@ static const struct dss_features dra7xx_dss_feats = { .fck_div_max = 64, .dss_fck_multiplier = 1, .parent_clk_name = "dpll_per_x2_ck", - .dpi_select_source = &dss_dpi_select_source_dra7xx, .ports = dra7xx_ports, .num_ports = ARRAY_SIZE(dra7xx_ports), - .select_lcd_source = &dss_lcd_clk_mux_dra7, + .ops = &dss_ops_dra7, };
static int dss_init_ports(struct platform_device *pdev)
The DSS internal features are derived from the platform device compatible string which is available at probe time. Don't delay initialization until bind time. This prepares for the merge of the two DSS features structures that will be needed before the DSS is bound.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/dss.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 7546ba8ab955..4fdb77dd90b8 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1183,23 +1183,10 @@ static const struct soc_device_attribute dss_soc_devices[] = { static int dss_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - const struct soc_device_attribute *soc; struct resource *dss_mem; u32 rev; int r;
- dss.pdev = pdev; - - /* - * The various OMAP3-based SoCs can be told apart from the compatible - * string, use SoC device matching. - */ - soc = soc_device_match(dss_soc_devices); - if (soc) - dss.feat = soc->data; - else - dss.feat = of_match_device(dss_of_match, &pdev->dev)->data; - dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); dss.base = devm_ioremap_resource(&pdev->dev, dss_mem); if (!dss.base) @@ -1331,9 +1318,22 @@ static int dss_add_child_component(struct device *dev, void *data)
static int dss_probe(struct platform_device *pdev) { + const struct soc_device_attribute *soc; struct component_match *match = NULL; int r;
+ dss.pdev = pdev; + + /* + * The various OMAP3-based SoCs can be told apart from the compatible + * string, use SoC device matching. + */ + soc = soc_device_match(dss_soc_devices); + if (soc) + dss.feat = soc->data; + else + dss.feat = of_match_device(dss_of_match, &pdev->dev)->data; + /* add all the child devices as components */ device_for_each_child(&pdev->dev, &match, dss_add_child_component);
On 08/05/17 14:32, Laurent Pinchart wrote:
The DSS internal features are derived from the platform device compatible string which is available at probe time. Don't delay initialization until bind time. This prepares for the merge of the two DSS features structures that will be needed before the DSS is bound.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dss.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 7546ba8ab955..4fdb77dd90b8 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1183,23 +1183,10 @@ static const struct soc_device_attribute dss_soc_devices[] = { static int dss_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev);
const struct soc_device_attribute *soc; struct resource *dss_mem; u32 rev; int r;
dss.pdev = pdev;
/*
* The various OMAP3-based SoCs can be told apart from the compatible
* string, use SoC device matching.
*/
soc = soc_device_match(dss_soc_devices);
if (soc)
dss.feat = soc->data;
else
dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); dss.base = devm_ioremap_resource(&pdev->dev, dss_mem); if (!dss.base)
@@ -1331,9 +1318,22 @@ static int dss_add_child_component(struct device *dev, void *data)
static int dss_probe(struct platform_device *pdev) {
const struct soc_device_attribute *soc; struct component_match *match = NULL; int r;
dss.pdev = pdev;
/*
* The various OMAP3-based SoCs can be told apart from the compatible
* string, use SoC device matching.
*/
soc = soc_device_match(dss_soc_devices);
if (soc)
dss.feat = soc->data;
else
dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
This has the problem that we should remove the static 'dss' variable, and allocate memory for each device. We can have more than one DSS in the future.
Also, I haven't looked at the following patches yet, but dss_features was a failed attempt to manage the dss features. Since then, we've slowly been moving the bits and pieces from dss_features to each individual driver.
So if this is needed for dss_features, we should instead move everything from dss_features and remove that altogether.
Tomi
Hi Tomi,
On Tuesday 09 May 2017 12:48:57 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
The DSS internal features are derived from the platform device compatible string which is available at probe time. Don't delay initialization until bind time. This prepares for the merge of the two DSS features structures that will be needed before the DSS is bound.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/dss.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 7546ba8ab955..4fdb77dd90b8 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1183,23 +1183,10 @@ static const struct soc_device_attribute dss_soc_devices[] = {> static int dss_bind(struct device *dev) {
struct platform_device *pdev = to_platform_device(dev);
const struct soc_device_attribute *soc;
struct resource *dss_mem; u32 rev; int r;
dss.pdev = pdev;
/*
* The various OMAP3-based SoCs can be told apart from the compatible
* string, use SoC device matching.
*/
soc = soc_device_match(dss_soc_devices);
if (soc)
dss.feat = soc->data;
else
dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
dss_mem = platform_get_resource(dss.pdev, IORESOURCE_MEM, 0); dss.base = devm_ioremap_resource(&pdev->dev, dss_mem); if (!dss.base)
@@ -1331,9 +1318,22 @@ static int dss_add_child_component(struct device *dev, void *data)> static int dss_probe(struct platform_device *pdev) {
const struct soc_device_attribute *soc;
struct component_match *match = NULL; int r;
dss.pdev = pdev;
/*
* The various OMAP3-based SoCs can be told apart from the compatible
* string, use SoC device matching.
*/
soc = soc_device_match(dss_soc_devices);
if (soc)
dss.feat = soc->data;
else
dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
This has the problem that we should remove the static 'dss' variable, and allocate memory for each device. We can have more than one DSS in the future.
Sure, and that's on my to-do list, but I didn't want to make the patch series bigger than it is already.
Also, I haven't looked at the following patches yet, but dss_features was a failed attempt to manage the dss features. Since then, we've slowly been moving the bits and pieces from dss_features to each individual driver.
So if this is needed for dss_features, we should instead move everything from dss_features and remove that altogether.
I agree with you, but again, I've tried to keep the existing architecture here, we can certainly rework it as a next step.
PHY features are stored in a global variable, while they should be properties of the PHY object. As existing OMAP platforms have a single HDMI PHY this doesn't cause any issue, but doesn't follow the driver model.
Move the PHY features to the HDMI PHY data structure to follow the driver model and pave the road for multiple HDMI PHYs support.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/hdmi.h | 7 +++++++ drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 23 ++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h index fb6cccd02374..851e5e6f6820 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h @@ -245,9 +245,16 @@ struct hdmi_pll_data { struct hdmi_wp_data *wp; };
+struct hdmi_phy_features { + bool bist_ctrl; + bool ldo_voltage; + unsigned long max_phy; +}; + struct hdmi_phy_data { void __iomem *base;
+ const struct hdmi_phy_features *features; u8 lane_function[4]; u8 lane_polarity[4]; }; diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c index fb5e4c724b4b..bff1ea11ed2f 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c @@ -19,14 +19,6 @@ #include "dss.h" #include "hdmi.h"
-struct hdmi_phy_features { - bool bist_ctrl; - bool ldo_voltage; - unsigned long max_phy; -}; - -static const struct hdmi_phy_features *phy_feat; - void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s) { #define DUMPPHY(r) seq_printf(s, "%-35s %08x\n", #r,\ @@ -36,7 +28,7 @@ void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s) DUMPPHY(HDMI_TXPHY_DIGITAL_CTRL); DUMPPHY(HDMI_TXPHY_POWER_CTRL); DUMPPHY(HDMI_TXPHY_PAD_CFG_CTRL); - if (phy_feat->bist_ctrl) + if (phy->features->bist_ctrl) DUMPPHY(HDMI_TXPHY_BIST_CONTROL); }
@@ -146,7 +138,7 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk, * In OMAP5+, the HFBITCLK must be divided by 2 before issuing the * HDMI_PHYPWRCMD_LDOON command. */ - if (phy_feat->bist_ctrl) + if (phy->features->bist_ctrl) REG_FLD_MOD(phy->base, HDMI_TXPHY_BIST_CONTROL, 1, 11, 11);
/* @@ -155,7 +147,7 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk, */ if (hfbitclk != lfbitclk) freqout = 0; - else if (hfbitclk / 10 < phy_feat->max_phy) + else if (hfbitclk / 10 < phy->features->max_phy) freqout = 1; else freqout = 2; @@ -170,7 +162,7 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk, hdmi_write_reg(phy->base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000);
/* Setup max LDO voltage */ - if (phy_feat->ldo_voltage) + if (phy->features->ldo_voltage) REG_FLD_MOD(phy->base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0);
hdmi_phy_configure_lanes(phy); @@ -190,7 +182,8 @@ static const struct hdmi_phy_features omap54xx_phy_feats = { .max_phy = 186000000, };
-static int hdmi_phy_init_features(struct platform_device *pdev) +static int hdmi_phy_init_features(struct platform_device *pdev, + struct hdmi_phy_data *phy) { struct hdmi_phy_features *dst; const struct hdmi_phy_features *src; @@ -218,7 +211,7 @@ static int hdmi_phy_init_features(struct platform_device *pdev) }
memcpy(dst, src, sizeof(*dst)); - phy_feat = dst; + phy->features = dst;
return 0; } @@ -228,7 +221,7 @@ int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) int r; struct resource *res;
- r = hdmi_phy_init_features(pdev); + r = hdmi_phy_init_features(pdev, phy); if (r) return r;
On 08/05/17 14:32, Laurent Pinchart wrote:
PHY features are stored in a global variable, while they should be properties of the PHY object. As existing OMAP platforms have a single HDMI PHY this doesn't cause any issue, but doesn't follow the driver model.
Move the PHY features to the HDMI PHY data structure to follow the driver model and pave the road for multiple HDMI PHYs support.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/hdmi.h | 7 +++++++ drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 23 ++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The HDMI PHY features are dependent on the HDMI transmitter model. The PHY driver contains features for all supported transmitters, and selects the appropriate features based on the OMAP SoC version.
It makes more sense to store the features in the HDMI transmitter drivers and pass them to the HDMI PHY initialization function, as the HDMI transmitter drivers are transmitter-specific and don't need to check the OMAP SoC version.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/hdmi.h | 3 +- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 8 ++++- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 8 ++++- drivers/gpu/drm/omapdrm/dss/hdmi_phy.c | 55 ++-------------------------------- 4 files changed, 19 insertions(+), 55 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h index 851e5e6f6820..2b4312f8e97d 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h @@ -323,7 +323,8 @@ void hdmi_pll_uninit(struct hdmi_pll_data *hpll); int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk, unsigned long lfbitclk); void hdmi_phy_dump(struct hdmi_phy_data *phy, struct seq_file *s); -int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy); +int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy, + const struct hdmi_phy_features *features); int hdmi_phy_parse_lanes(struct hdmi_phy_data *phy, const u32 *lanes);
/* HDMI common funcs */ diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index ff4a0c04a22c..1feb6deab108 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -683,6 +683,12 @@ static int hdmi_audio_register(struct device *dev) }
/* HDMI HW IP initialisation */ +static const struct hdmi_phy_features hdmi4_phy_feats = { + .bist_ctrl = false, + .ldo_voltage = true, + .max_phy = 185675000, +}; + static int hdmi4_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -707,7 +713,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data) if (r) return r;
- r = hdmi_phy_init(pdev, &hdmi.phy); + r = hdmi_phy_init(pdev, &hdmi.phy, &hdmi4_phy_feats); if (r) goto err;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index c037b61f7920..529653180bfc 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -715,6 +715,12 @@ static int hdmi_audio_register(struct device *dev) }
/* HDMI HW IP initialisation */ +static const struct hdmi_phy_features hdmi5_phy_feats = { + .bist_ctrl = true, + .ldo_voltage = false, + .max_phy = 186000000, +}; + static int hdmi5_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -739,7 +745,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data) if (r) return r;
- r = hdmi_phy_init(pdev, &hdmi.phy); + r = hdmi_phy_init(pdev, &hdmi.phy, &hdmi5_phy_feats); if (r) goto err;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c index bff1ea11ed2f..87ed0bc5b146 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_phy.c @@ -12,7 +12,6 @@ #include <linux/err.h> #include <linux/io.h> #include <linux/platform_device.h> -#include <linux/slab.h> #include <linux/seq_file.h>
#include "omapdss.h" @@ -170,60 +169,12 @@ int hdmi_phy_configure(struct hdmi_phy_data *phy, unsigned long hfbitclk, return 0; }
-static const struct hdmi_phy_features omap44xx_phy_feats = { - .bist_ctrl = false, - .ldo_voltage = true, - .max_phy = 185675000, -}; - -static const struct hdmi_phy_features omap54xx_phy_feats = { - .bist_ctrl = true, - .ldo_voltage = false, - .max_phy = 186000000, -}; - -static int hdmi_phy_init_features(struct platform_device *pdev, - struct hdmi_phy_data *phy) -{ - struct hdmi_phy_features *dst; - const struct hdmi_phy_features *src; - - dst = devm_kzalloc(&pdev->dev, sizeof(*dst), GFP_KERNEL); - if (!dst) { - dev_err(&pdev->dev, "Failed to allocate HDMI PHY Features\n"); - return -ENOMEM; - } - - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: - src = &omap44xx_phy_feats; - break; - - case OMAPDSS_VER_OMAP5: - case OMAPDSS_VER_DRA7xx: - src = &omap54xx_phy_feats; - break; - - default: - return -ENODEV; - } - - memcpy(dst, src, sizeof(*dst)); - phy->features = dst; - - return 0; -} - -int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy) +int hdmi_phy_init(struct platform_device *pdev, struct hdmi_phy_data *phy, + const struct hdmi_phy_features *features) { - int r; struct resource *res;
- r = hdmi_phy_init_features(pdev, phy); - if (r) - return r; + phy->features = features;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "phy"); phy->base = devm_ioremap_resource(&pdev->dev, res);
On 08/05/17 14:32, Laurent Pinchart wrote:
The HDMI PHY features are dependent on the HDMI transmitter model. The PHY driver contains features for all supported transmitters, and selects the appropriate features based on the OMAP SoC version.
It makes more sense to store the features in the HDMI transmitter drivers and pass them to the HDMI PHY initialization function, as the HDMI transmitter drivers are transmitter-specific and don't need to check the OMAP SoC version.
I don't think this is correct. PHY and HDMI are separate components, you could swap the PHY. In theory, at least. While the PHY .c is not a separate driver, I still like that it contains information about the PHY hardware versions which it supports, like a real driver would.
The same applies to the next patch, the PLL is not part of HDMI.
In the third patch you pass 4 or 5 to the WP code as a version. So maybe rather create an HDMI_VERSION (or something) enum, which can be passed to phy, pll and wp?
Tomi
The HDMI PLL hardware data are dependent on the HDMI transmitter model. The PLL driver contains hardware data for all supported transmitters, and selects the appropriate hardware data based on the OMAP SoC version.
It makes more sense to store the PLL hardware data in the HDMI transmitter drivers and pass them to the HDMI PLL initialization function, as the HDMI transmitter drivers are transmitter-specific and don't need to check the OMAP SoC version.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/hdmi.h | 2 +- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 27 +++++++++++- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 28 ++++++++++++- drivers/gpu/drm/omapdrm/dss/hdmi_pll.c | 77 +++------------------------------- 4 files changed, 60 insertions(+), 74 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h index 2b4312f8e97d..7ae26c7c5189 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h @@ -316,7 +316,7 @@ phys_addr_t hdmi_wp_get_audio_dma_addr(struct hdmi_wp_data *wp); /* HDMI PLL funcs */ void hdmi_pll_dump(struct hdmi_pll_data *pll, struct seq_file *s); int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll, - struct hdmi_wp_data *wp); + const struct dss_pll_hw *pll_hw, struct hdmi_wp_data *wp); void hdmi_pll_uninit(struct hdmi_pll_data *hpll);
/* HDMI PHY funcs */ diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index 1feb6deab108..b34f82bb61d5 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -689,6 +689,31 @@ static const struct hdmi_phy_features hdmi4_phy_feats = { .max_phy = 185675000, };
+static const struct dss_pll_hw hdmi4_pll_hw = { + .type = DSS_PLL_TYPE_B, + + .n_max = 255, + .m_min = 20, + .m_max = 4095, + .mX_max = 127, + .fint_min = 500000, + .fint_max = 2500000, + + .clkdco_min = 500000000, + .clkdco_low = 1000000000, + .clkdco_max = 2000000000, + + .n_msb = 8, + .n_lsb = 1, + .m_msb = 20, + .m_lsb = 9, + + .mX_msb[0] = 24, + .mX_lsb[0] = 18, + + .has_selfreqdco = true, +}; + static int hdmi4_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -709,7 +734,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data) if (r) return r;
- r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp); + r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi4_pll_hw, &hdmi.wp); if (r) return r;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index 529653180bfc..54df41f24085 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -721,6 +721,32 @@ static const struct hdmi_phy_features hdmi5_phy_feats = { .max_phy = 186000000, };
+static const struct dss_pll_hw hdmi5_pll_hw = { + .type = DSS_PLL_TYPE_B, + + .n_max = 255, + .m_min = 20, + .m_max = 2045, + .mX_max = 127, + .fint_min = 620000, + .fint_max = 2500000, + + .clkdco_min = 750000000, + .clkdco_low = 1500000000, + .clkdco_max = 2500000000UL, + + .n_msb = 8, + .n_lsb = 1, + .m_msb = 20, + .m_lsb = 9, + + .mX_msb[0] = 24, + .mX_lsb[0] = 18, + + .has_selfreqdco = true, + .has_refsel = true, +}; + static int hdmi5_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -741,7 +767,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data) if (r) return r;
- r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi.wp); + r = hdmi_pll_init(pdev, &hdmi.pll, &hdmi5_pll_hw, &hdmi.wp); if (r) return r;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c index 46239358655a..870c5e633075 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_pll.c @@ -77,58 +77,9 @@ static const struct dss_pll_ops dsi_pll_ops = { .set_config = dss_pll_write_config_type_b, };
-static const struct dss_pll_hw dss_omap4_hdmi_pll_hw = { - .type = DSS_PLL_TYPE_B, - - .n_max = 255, - .m_min = 20, - .m_max = 4095, - .mX_max = 127, - .fint_min = 500000, - .fint_max = 2500000, - - .clkdco_min = 500000000, - .clkdco_low = 1000000000, - .clkdco_max = 2000000000, - - .n_msb = 8, - .n_lsb = 1, - .m_msb = 20, - .m_lsb = 9, - - .mX_msb[0] = 24, - .mX_lsb[0] = 18, - - .has_selfreqdco = true, -}; - -static const struct dss_pll_hw dss_omap5_hdmi_pll_hw = { - .type = DSS_PLL_TYPE_B, - - .n_max = 255, - .m_min = 20, - .m_max = 2045, - .mX_max = 127, - .fint_min = 620000, - .fint_max = 2500000, - - .clkdco_min = 750000000, - .clkdco_low = 1500000000, - .clkdco_max = 2500000000UL, - - .n_msb = 8, - .n_lsb = 1, - .m_msb = 20, - .m_lsb = 9, - - .mX_msb[0] = 24, - .mX_lsb[0] = 18, - - .has_selfreqdco = true, - .has_refsel = true, -}; - -static int dsi_init_pll_data(struct platform_device *pdev, struct hdmi_pll_data *hpll) +static int dsi_init_pll_data(struct platform_device *pdev, + struct hdmi_pll_data *hpll, + const struct dss_pll_hw *pll_hw) { struct dss_pll *pll = &hpll->pll; struct clk *clk; @@ -144,23 +95,7 @@ static int dsi_init_pll_data(struct platform_device *pdev, struct hdmi_pll_data pll->id = DSS_PLL_HDMI; pll->base = hpll->base; pll->clkin = clk; - - switch (omapdss_get_version()) { - case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: - pll->hw = &dss_omap4_hdmi_pll_hw; - break; - - case OMAPDSS_VER_OMAP5: - case OMAPDSS_VER_DRA7xx: - pll->hw = &dss_omap5_hdmi_pll_hw; - break; - - default: - return -ENODEV; - } - + pll->hw = pll_hw; pll->ops = &dsi_pll_ops;
r = dss_pll_register(pll); @@ -171,7 +106,7 @@ static int dsi_init_pll_data(struct platform_device *pdev, struct hdmi_pll_data }
int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll, - struct hdmi_wp_data *wp) + const struct dss_pll_hw *pll_hw, struct hdmi_wp_data *wp) { int r; struct resource *res; @@ -184,7 +119,7 @@ int hdmi_pll_init(struct platform_device *pdev, struct hdmi_pll_data *pll, if (IS_ERR(pll->base)) return PTR_ERR(pll->base);
- r = dsi_init_pll_data(pdev, pll); + r = dsi_init_pll_data(pdev, pll, pll_hw); if (r) { DSSERR("failed to init HDMI PLL\n"); return r;
The HDMI wrapper code only needs to differentiate between major OMAP revisions, which can be obtained from the HDMI transmitter compatible string. Replace the OMAP SoC model checks to prepare for removal of the OMAP SoC version platform data.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/hdmi.h | 4 +++- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 2 +- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 2 +- drivers/gpu/drm/omapdrm/dss/hdmi_wp.c | 12 +++++------- 4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi.h b/drivers/gpu/drm/omapdrm/dss/hdmi.h index 7ae26c7c5189..42d77b77bf45 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi.h +++ b/drivers/gpu/drm/omapdrm/dss/hdmi.h @@ -234,6 +234,7 @@ struct hdmi_core_audio_config { struct hdmi_wp_data { void __iomem *base; phys_addr_t phys_base; + unsigned int version; };
struct hdmi_pll_data { @@ -310,7 +311,8 @@ void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp, struct videomode *vm); void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt, struct videomode *vm, struct hdmi_config *param); -int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp); +int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp, + unsigned int version); phys_addr_t hdmi_wp_get_audio_dma_addr(struct hdmi_wp_data *wp);
/* HDMI PLL funcs */ diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index b34f82bb61d5..a1e3f33a06f0 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -730,7 +730,7 @@ static int hdmi4_bind(struct device *dev, struct device *master, void *data) if (r) return r;
- r = hdmi_wp_init(pdev, &hdmi.wp); + r = hdmi_wp_init(pdev, &hdmi.wp, 4); if (r) return r;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index 54df41f24085..67accbcf70bc 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -763,7 +763,7 @@ static int hdmi5_bind(struct device *dev, struct device *master, void *data) if (r) return r;
- r = hdmi_wp_init(pdev, &hdmi.wp); + r = hdmi_wp_init(pdev, &hdmi.wp, 5); if (r) return r;
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c index b1ab9e563915..adb6b6311ec7 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi_wp.c @@ -176,9 +176,7 @@ void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp, * However, we don't support OMAP5 ES1 at all, so we can just check for * OMAP4 here. */ - if (omapdss_get_version() == OMAPDSS_VER_OMAP4430_ES1 || - omapdss_get_version() == OMAPDSS_VER_OMAP4430_ES2 || - omapdss_get_version() == OMAPDSS_VER_OMAP4) + if (wp->version == 4) hsync_len_offset = 0;
timing_h |= FLD_VAL(vm->hback_porch, 31, 20); @@ -233,9 +231,7 @@ void hdmi_wp_audio_config_format(struct hdmi_wp_data *wp, DSSDBG("Enter hdmi_wp_audio_config_format\n");
r = hdmi_read_reg(wp->base, HDMI_WP_AUDIO_CFG); - if (omapdss_get_version() == OMAPDSS_VER_OMAP4430_ES1 || - omapdss_get_version() == OMAPDSS_VER_OMAP4430_ES2 || - omapdss_get_version() == OMAPDSS_VER_OMAP4) { + if (wp->version == 4) { r = FLD_MOD(r, aud_fmt->stereo_channels, 26, 24); r = FLD_MOD(r, aud_fmt->active_chnnls_msk, 23, 16); } @@ -280,7 +276,8 @@ int hdmi_wp_audio_core_req_enable(struct hdmi_wp_data *wp, bool enable) return 0; }
-int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp) +int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp, + unsigned int version) { struct resource *res;
@@ -290,6 +287,7 @@ int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp) return PTR_ERR(wp->base);
wp->phys_base = res->start; + wp->version = version;
return 0; }
The HDMI audio driver only needs to know which generation of HDMI transmitter it deals with, not the detailed SoC model. Pass the version number as an integer to prepare for removal of the OMAP SoC version from the omapdrm driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/hdmi4.c | 2 +- drivers/gpu/drm/omapdrm/dss/hdmi5.c | 2 +- include/sound/omap-hdmi-audio.h | 2 +- sound/soc/omap/omap-hdmi-audio.c | 9 +++------ 4 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4.c b/drivers/gpu/drm/omapdrm/dss/hdmi4.c index a1e3f33a06f0..79bbe40a2f58 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi4.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi4.c @@ -667,7 +667,7 @@ static int hdmi_audio_register(struct device *dev) { struct omap_hdmi_audio_pdata pdata = { .dev = dev, - .dss_version = omapdss_get_version(), + .version = 4, .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp), .ops = &hdmi_audio_ops, }; diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi5.c b/drivers/gpu/drm/omapdrm/dss/hdmi5.c index 67accbcf70bc..a6e88a78b8dd 100644 --- a/drivers/gpu/drm/omapdrm/dss/hdmi5.c +++ b/drivers/gpu/drm/omapdrm/dss/hdmi5.c @@ -694,7 +694,7 @@ static int hdmi_audio_register(struct device *dev) { struct omap_hdmi_audio_pdata pdata = { .dev = dev, - .dss_version = omapdss_get_version(), + .version = 5, .audio_dma_addr = hdmi_wp_get_audio_dma_addr(&hdmi.wp), .ops = &hdmi_audio_ops, }; diff --git a/include/sound/omap-hdmi-audio.h b/include/sound/omap-hdmi-audio.h index 1df2ff61a4dd..0e495ed8872e 100644 --- a/include/sound/omap-hdmi-audio.h +++ b/include/sound/omap-hdmi-audio.h @@ -39,7 +39,7 @@ struct omap_hdmi_audio_ops { /* HDMI audio initalization data */ struct omap_hdmi_audio_pdata { struct device *dev; - enum omapdss_version dss_version; + unsigned int version; phys_addr_t audio_dma_addr;
const struct omap_hdmi_audio_ops *ops; diff --git a/sound/soc/omap/omap-hdmi-audio.c b/sound/soc/omap/omap-hdmi-audio.c index 888133f9e65d..3e9cc4842a1d 100644 --- a/sound/soc/omap/omap-hdmi-audio.c +++ b/sound/soc/omap/omap-hdmi-audio.c @@ -337,14 +337,11 @@ static int omap_hdmi_audio_probe(struct platform_device *pdev) ad->dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; mutex_init(&ad->current_stream_lock);
- switch (ha->dss_version) { - case OMAPDSS_VER_OMAP4430_ES1: - case OMAPDSS_VER_OMAP4430_ES2: - case OMAPDSS_VER_OMAP4: + switch (ha->version) { + case 4: dai_drv = &omap4_hdmi_dai; break; - case OMAPDSS_VER_OMAP5: - case OMAPDSS_VER_DRA7xx: + case 5: dai_drv = &omap5_hdmi_dai; break; default:
On Mon, May 08, 2017 at 02:32:53PM +0300, Laurent Pinchart wrote:
The HDMI audio driver only needs to know which generation of HDMI transmitter it deals with, not the detailed SoC model. Pass the version number as an integer to prepare for removal of the OMAP SoC version from the omapdrm driver.
Acked-by: Mark Brown broonie@kernel.org
No device is ever registered that binds with the driver, the SDI port is handled manually. Remove the SDI platform driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 6 ----- drivers/gpu/drm/omapdrm/dss/dss.h | 3 --- drivers/gpu/drm/omapdrm/dss/sdi.c | 54 -------------------------------------- 3 files changed, 63 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 524ecdd138f4..7579de042d32 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -188,9 +188,6 @@ static int (*dss_output_drv_reg_funcs[])(void) __initdata = { #ifdef CONFIG_OMAP2_DSS_DSI dsi_init_platform_driver, #endif -#ifdef CONFIG_OMAP2_DSS_SDI - sdi_init_platform_driver, -#endif #ifdef CONFIG_OMAP2_DSS_RFBI rfbi_init_platform_driver, #endif @@ -218,9 +215,6 @@ static void (*dss_output_drv_unreg_funcs[])(void) = { #ifdef CONFIG_OMAP2_DSS_RFBI rfbi_uninit_platform_driver, #endif -#ifdef CONFIG_OMAP2_DSS_SDI - sdi_uninit_platform_driver, -#endif #ifdef CONFIG_OMAP2_DSS_DSI dsi_uninit_platform_driver, #endif diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index bc75c5f8a5fe..453b4ba0bf18 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -293,9 +293,6 @@ bool dss_div_calc(unsigned long pck, unsigned long fck_min, dss_div_calc_func func, void *data);
/* SDI */ -int sdi_init_platform_driver(void) __init; -void sdi_uninit_platform_driver(void); - #ifdef CONFIG_OMAP2_DSS_SDI int sdi_init_port(struct platform_device *pdev, struct device_node *port); void sdi_uninit_port(struct device_node *port); diff --git a/drivers/gpu/drm/omapdrm/dss/sdi.c b/drivers/gpu/drm/omapdrm/dss/sdi.c index b3bda2d3c08d..35c809d85b7a 100644 --- a/drivers/gpu/drm/omapdrm/dss/sdi.c +++ b/drivers/gpu/drm/omapdrm/dss/sdi.c @@ -27,7 +27,6 @@ #include <linux/platform_device.h> #include <linux/string.h> #include <linux/of.h> -#include <linux/component.h>
#include "omapdss.h" #include "dss.h" @@ -355,59 +354,6 @@ static void sdi_uninit_output(struct platform_device *pdev) omapdss_unregister_output(out); }
-static int sdi_bind(struct device *dev, struct device *master, void *data) -{ - struct platform_device *pdev = to_platform_device(dev); - - sdi.pdev = pdev; - - sdi_init_output(pdev); - - return 0; -} - -static void sdi_unbind(struct device *dev, struct device *master, void *data) -{ - struct platform_device *pdev = to_platform_device(dev); - - sdi_uninit_output(pdev); -} - -static const struct component_ops sdi_component_ops = { - .bind = sdi_bind, - .unbind = sdi_unbind, -}; - -static int sdi_probe(struct platform_device *pdev) -{ - return component_add(&pdev->dev, &sdi_component_ops); -} - -static int sdi_remove(struct platform_device *pdev) -{ - component_del(&pdev->dev, &sdi_component_ops); - return 0; -} - -static struct platform_driver omap_sdi_driver = { - .probe = sdi_probe, - .remove = sdi_remove, - .driver = { - .name = "omapdss_sdi", - .suppress_bind_attrs = true, - }, -}; - -int __init sdi_init_platform_driver(void) -{ - return platform_driver_register(&omap_sdi_driver); -} - -void sdi_uninit_platform_driver(void) -{ - platform_driver_unregister(&omap_sdi_driver); -} - int sdi_init_port(struct platform_device *pdev, struct device_node *port) { struct device_node *ep;
On 08/05/17 14:32, Laurent Pinchart wrote:
No device is ever registered that binds with the driver, the SDI port is handled manually. Remove the SDI platform driver.
Same comment here as for DPI: this was for non-DT. Other than that:
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The OMAP implementation of the set_min_bus_tput() API is a no-op. There's no point in forwarding the driver calls to the platform code. Remove the use of the related platform data callback, but keep the internal function as a reminder that the feature will need to be implemented when the OMAP platform will provide support.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- Changes since v1:
- Make the function inline --- drivers/gpu/drm/omapdrm/dss/core.c | 10 ---------- drivers/gpu/drm/omapdrm/dss/dss.h | 7 ++++++- 2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 7579de042d32..ff6357df0588 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -50,16 +50,6 @@ enum omapdss_version omapdss_get_version(void) } EXPORT_SYMBOL(omapdss_get_version);
-int dss_set_min_bus_tput(struct device *dev, unsigned long tput) -{ - struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; - - if (pdata->set_min_bus_tput) - return pdata->set_min_bus_tput(dev, tput); - else - return 0; -} - #if defined(CONFIG_OMAP2_DSS_DEBUGFS) static int dss_debug_show(struct seq_file *s, void *unused) { diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 453b4ba0bf18..1ef7c0e75d4c 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -230,7 +230,12 @@ struct seq_file; struct platform_device;
/* core */ -int dss_set_min_bus_tput(struct device *dev, unsigned long tput); +static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput) +{ + /* To be implemented when the OMAP platform will provide this feature */ + return 0; +} + int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
static inline bool dss_mgr_is_lcd(enum omap_channel id)
On 08/05/17 14:32, Laurent Pinchart wrote:
The OMAP implementation of the set_min_bus_tput() API is a no-op. There's no point in forwarding the driver calls to the platform code. Remove the use of the related platform data callback, but keep the internal function as a reminder that the feature will need to be implemented when the OMAP platform will provide support.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
debugfs code is spread between the core and dss drivers. In preparation for removal of the core driver, move it all to the dss driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 80 -------------------------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 77 ++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 13 +++++-- 3 files changed, 84 insertions(+), 86 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index ff6357df0588..dc2147ec78f6 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -27,8 +27,6 @@ #include <linux/clk.h> #include <linux/err.h> #include <linux/platform_device.h> -#include <linux/seq_file.h> -#include <linux/debugfs.h> #include <linux/io.h> #include <linux/device.h> #include <linux/regulator/consumer.h> @@ -50,72 +48,6 @@ enum omapdss_version omapdss_get_version(void) } EXPORT_SYMBOL(omapdss_get_version);
-#if defined(CONFIG_OMAP2_DSS_DEBUGFS) -static int dss_debug_show(struct seq_file *s, void *unused) -{ - void (*func)(struct seq_file *) = s->private; - func(s); - return 0; -} - -static int dss_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, dss_debug_show, inode->i_private); -} - -static const struct file_operations dss_debug_fops = { - .open = dss_debug_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static struct dentry *dss_debugfs_dir; - -static int dss_initialize_debugfs(void) -{ - dss_debugfs_dir = debugfs_create_dir("omapdss", NULL); - if (IS_ERR(dss_debugfs_dir)) { - int err = PTR_ERR(dss_debugfs_dir); - dss_debugfs_dir = NULL; - return err; - } - - debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir, - &dss_debug_dump_clocks, &dss_debug_fops); - - return 0; -} - -static void dss_uninitialize_debugfs(void) -{ - if (dss_debugfs_dir) - debugfs_remove_recursive(dss_debugfs_dir); -} - -int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) -{ - struct dentry *d; - - d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir, - write, &dss_debug_fops); - - return PTR_ERR_OR_ZERO(d); -} -#else /* CONFIG_OMAP2_DSS_DEBUGFS */ -static inline int dss_initialize_debugfs(void) -{ - return 0; -} -static inline void dss_uninitialize_debugfs(void) -{ -} -int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) -{ - return 0; -} -#endif /* CONFIG_OMAP2_DSS_DEBUGFS */ - /* PLATFORM DEVICE */
static void dss_disable_all_devices(void) @@ -133,27 +65,15 @@ static void dss_disable_all_devices(void)
static int __init omap_dss_probe(struct platform_device *pdev) { - int r; - core.pdev = pdev;
dss_features_init(omapdss_get_version());
- r = dss_initialize_debugfs(); - if (r) - goto err_debugfs; - return 0; - -err_debugfs: - - return r; }
static int omap_dss_remove(struct platform_device *pdev) { - dss_uninitialize_debugfs(); - return 0; }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 4fdb77dd90b8..618fd4dcbd5a 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -22,6 +22,7 @@
#define DSS_SUBSYS_NAME "DSS"
+#include <linux/debugfs.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/io.h> @@ -896,7 +897,7 @@ void dss_runtime_put(void)
/* DEBUGFS */ #if defined(CONFIG_OMAP2_DSS_DEBUGFS) -void dss_debug_dump_clocks(struct seq_file *s) +static void dss_debug_dump_clocks(struct seq_file *s) { dss_dump_clocks(s); dispc_dump_clocks(s); @@ -904,8 +905,69 @@ void dss_debug_dump_clocks(struct seq_file *s) dsi_dump_clocks(s); #endif } -#endif
+static int dss_debug_show(struct seq_file *s, void *unused) +{ + void (*func)(struct seq_file *) = s->private; + + func(s); + return 0; +} + +static int dss_debug_open(struct inode *inode, struct file *file) +{ + return single_open(file, dss_debug_show, inode->i_private); +} + +static const struct file_operations dss_debug_fops = { + .open = dss_debug_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static struct dentry *dss_debugfs_dir; + +static int dss_initialize_debugfs(void) +{ + dss_debugfs_dir = debugfs_create_dir("omapdss", NULL); + if (IS_ERR(dss_debugfs_dir)) { + int err = PTR_ERR(dss_debugfs_dir); + + dss_debugfs_dir = NULL; + return err; + } + + debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir, + &dss_debug_dump_clocks, &dss_debug_fops); + + return 0; +} + +static void dss_uninitialize_debugfs(void) +{ + if (dss_debugfs_dir) + debugfs_remove_recursive(dss_debugfs_dir); +} + +int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) +{ + struct dentry *d; + + d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir, + write, &dss_debug_fops); + + return PTR_ERR_OR_ZERO(d); +} +#else /* CONFIG_OMAP2_DSS_DEBUGFS */ +static inline int dss_initialize_debugfs(void) +{ + return 0; +} +static inline void dss_uninitialize_debugfs(void) +{ +} +#endif /* CONFIG_OMAP2_DSS_DEBUGFS */
static const struct dss_ops dss_ops_omap2_omap3 = { .dpi_select_source = &dss_dpi_select_source_omap2_omap3, @@ -1334,12 +1396,18 @@ static int dss_probe(struct platform_device *pdev) else dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
+ r = dss_initialize_debugfs(); + if (r) + return r; + /* add all the child devices as components */ device_for_each_child(&pdev->dev, &match, dss_add_child_component);
r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match); - if (r) + if (r) { + dss_initialize_debugfs(); return r; + }
return 0; } @@ -1347,6 +1415,9 @@ static int dss_probe(struct platform_device *pdev) static int dss_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &dss_component_ops); + + dss_uninitialize_debugfs(); + return 0; }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 1ef7c0e75d4c..eca7d731f5c8 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -236,8 +236,6 @@ static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput) return 0; }
-int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); - static inline bool dss_mgr_is_lcd(enum omap_channel id) { if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 || @@ -248,6 +246,16 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id) }
/* DSS */ +#if defined(CONFIG_OMAP2_DSS_DEBUGFS) +int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); +#else +static inline int dss_debugfs_create_file(const char *name, + void (*write)(struct seq_file *)) +{ + return 0; +} +#endif /* CONFIG_OMAP2_DSS_DEBUGFS */ + int dss_init_platform_driver(void) __init; void dss_uninit_platform_driver(void);
@@ -271,7 +279,6 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port); u32 dss_of_port_get_port_number(struct device_node *port);
#if defined(CONFIG_OMAP2_DSS_DEBUGFS) -void dss_debug_dump_clocks(struct seq_file *s); #endif
void dss_ctrl_pll_enable(enum dss_pll_id pll_id, bool enable);
On 08/05/17 14:32, Laurent Pinchart wrote:
debugfs code is spread between the core and dss drivers. In preparation for removal of the core driver, move it all to the dss driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 80 -------------------------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 77 ++++++++++++++++++++++++++++++++++-- drivers/gpu/drm/omapdrm/dss/dss.h | 13 +++++-- 3 files changed, 84 insertions(+), 86 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index ff6357df0588..dc2147ec78f6 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -27,8 +27,6 @@ #include <linux/clk.h> #include <linux/err.h> #include <linux/platform_device.h> -#include <linux/seq_file.h> -#include <linux/debugfs.h> #include <linux/io.h> #include <linux/device.h> #include <linux/regulator/consumer.h> @@ -50,72 +48,6 @@ enum omapdss_version omapdss_get_version(void) } EXPORT_SYMBOL(omapdss_get_version);
-#if defined(CONFIG_OMAP2_DSS_DEBUGFS) -static int dss_debug_show(struct seq_file *s, void *unused) -{
- void (*func)(struct seq_file *) = s->private;
- func(s);
- return 0;
-}
-static int dss_debug_open(struct inode *inode, struct file *file) -{
- return single_open(file, dss_debug_show, inode->i_private);
-}
-static const struct file_operations dss_debug_fops = {
- .open = dss_debug_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-static struct dentry *dss_debugfs_dir;
-static int dss_initialize_debugfs(void) -{
- dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
- if (IS_ERR(dss_debugfs_dir)) {
int err = PTR_ERR(dss_debugfs_dir);
dss_debugfs_dir = NULL;
return err;
- }
- debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
&dss_debug_dump_clocks, &dss_debug_fops);
- return 0;
-}
-static void dss_uninitialize_debugfs(void) -{
- if (dss_debugfs_dir)
debugfs_remove_recursive(dss_debugfs_dir);
-}
-int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) -{
- struct dentry *d;
- d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
write, &dss_debug_fops);
- return PTR_ERR_OR_ZERO(d);
-} -#else /* CONFIG_OMAP2_DSS_DEBUGFS */ -static inline int dss_initialize_debugfs(void) -{
- return 0;
-} -static inline void dss_uninitialize_debugfs(void) -{ -} -int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) -{
- return 0;
-} -#endif /* CONFIG_OMAP2_DSS_DEBUGFS */
/* PLATFORM DEVICE */
static void dss_disable_all_devices(void) @@ -133,27 +65,15 @@ static void dss_disable_all_devices(void)
static int __init omap_dss_probe(struct platform_device *pdev) {
int r;
core.pdev = pdev;
dss_features_init(omapdss_get_version());
r = dss_initialize_debugfs();
if (r)
goto err_debugfs;
return 0;
-err_debugfs:
- return r;
}
static int omap_dss_remove(struct platform_device *pdev) {
- dss_uninitialize_debugfs();
- return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 4fdb77dd90b8..618fd4dcbd5a 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -22,6 +22,7 @@
#define DSS_SUBSYS_NAME "DSS"
+#include <linux/debugfs.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/io.h> @@ -896,7 +897,7 @@ void dss_runtime_put(void)
/* DEBUGFS */ #if defined(CONFIG_OMAP2_DSS_DEBUGFS) -void dss_debug_dump_clocks(struct seq_file *s) +static void dss_debug_dump_clocks(struct seq_file *s) { dss_dump_clocks(s); dispc_dump_clocks(s); @@ -904,8 +905,69 @@ void dss_debug_dump_clocks(struct seq_file *s) dsi_dump_clocks(s); #endif } -#endif
+static int dss_debug_show(struct seq_file *s, void *unused) +{
- void (*func)(struct seq_file *) = s->private;
- func(s);
- return 0;
+}
+static int dss_debug_open(struct inode *inode, struct file *file) +{
- return single_open(file, dss_debug_show, inode->i_private);
+}
+static const struct file_operations dss_debug_fops = {
- .open = dss_debug_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
+};
+static struct dentry *dss_debugfs_dir;
+static int dss_initialize_debugfs(void) +{
- dss_debugfs_dir = debugfs_create_dir("omapdss", NULL);
- if (IS_ERR(dss_debugfs_dir)) {
int err = PTR_ERR(dss_debugfs_dir);
dss_debugfs_dir = NULL;
return err;
- }
- debugfs_create_file("clk", S_IRUGO, dss_debugfs_dir,
&dss_debug_dump_clocks, &dss_debug_fops);
- return 0;
+}
+static void dss_uninitialize_debugfs(void) +{
- if (dss_debugfs_dir)
debugfs_remove_recursive(dss_debugfs_dir);
+}
+int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)) +{
- struct dentry *d;
- d = debugfs_create_file(name, S_IRUGO, dss_debugfs_dir,
write, &dss_debug_fops);
- return PTR_ERR_OR_ZERO(d);
+} +#else /* CONFIG_OMAP2_DSS_DEBUGFS */ +static inline int dss_initialize_debugfs(void) +{
- return 0;
+} +static inline void dss_uninitialize_debugfs(void) +{ +} +#endif /* CONFIG_OMAP2_DSS_DEBUGFS */
static const struct dss_ops dss_ops_omap2_omap3 = { .dpi_select_source = &dss_dpi_select_source_omap2_omap3, @@ -1334,12 +1396,18 @@ static int dss_probe(struct platform_device *pdev) else dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
r = dss_initialize_debugfs();
if (r)
return r;
/* add all the child devices as components */ device_for_each_child(&pdev->dev, &match, dss_add_child_component);
r = component_master_add_with_match(&pdev->dev, &dss_component_ops, match);
- if (r)
- if (r) {
dss_initialize_debugfs();
Uninitialize.
return r;
}
return 0;
} @@ -1347,6 +1415,9 @@ static int dss_probe(struct platform_device *pdev) static int dss_remove(struct platform_device *pdev) { component_master_del(&pdev->dev, &dss_component_ops);
- dss_uninitialize_debugfs();
- return 0;
}
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index 1ef7c0e75d4c..eca7d731f5c8 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -236,8 +236,6 @@ static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput) return 0; }
-int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
static inline bool dss_mgr_is_lcd(enum omap_channel id) { if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 || @@ -248,6 +246,16 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id) }
/* DSS */ +#if defined(CONFIG_OMAP2_DSS_DEBUGFS) +int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); +#else +static inline int dss_debugfs_create_file(const char *name,
void (*write)(struct seq_file *))
+{
- return 0;
+} +#endif /* CONFIG_OMAP2_DSS_DEBUGFS */
int dss_init_platform_driver(void) __init; void dss_uninit_platform_driver(void);
@@ -271,7 +279,6 @@ struct device_node *dss_of_port_get_parent_device(struct device_node *port); u32 dss_of_port_get_port_number(struct device_node *port);
#if defined(CONFIG_OMAP2_DSS_DEBUGFS) -void dss_debug_dump_clocks(struct seq_file *s); #endif
Looks like the #if and #endif can be removed too.
Tomi
In preparation for removal of the core module, move the shutdown() handler from core to dss.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 20 -------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index dc2147ec78f6..839bfb5a2e48 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -50,19 +50,6 @@ EXPORT_SYMBOL(omapdss_get_version);
/* PLATFORM DEVICE */
-static void dss_disable_all_devices(void) -{ - struct omap_dss_device *dssdev = NULL; - - for_each_dss_dev(dssdev) { - if (!dssdev->driver) - continue; - - if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) - dssdev->driver->disable(dssdev); - } -} - static int __init omap_dss_probe(struct platform_device *pdev) { core.pdev = pdev; @@ -77,15 +64,8 @@ static int omap_dss_remove(struct platform_device *pdev) return 0; }
-static void omap_dss_shutdown(struct platform_device *pdev) -{ - DSSDBG("shutdown\n"); - dss_disable_all_devices(); -} - static struct platform_driver omap_dss_driver = { .remove = omap_dss_remove, - .shutdown = omap_dss_shutdown, .driver = { .name = "omapdss", }, diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 618fd4dcbd5a..34d5caa7d0b5 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -1421,6 +1421,21 @@ static int dss_remove(struct platform_device *pdev) return 0; }
+static void dss_shutdown(struct platform_device *pdev) +{ + struct omap_dss_device *dssdev = NULL; + + DSSDBG("shutdown\n"); + + for_each_dss_dev(dssdev) { + if (!dssdev->driver) + continue; + + if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) + dssdev->driver->disable(dssdev); + } +} + static int dss_runtime_suspend(struct device *dev) { dss_save_context(); @@ -1460,6 +1475,7 @@ static const struct dev_pm_ops dss_pm_ops = { static struct platform_driver omap_dsshw_driver = { .probe = dss_probe, .remove = dss_remove, + .shutdown = dss_shutdown, .driver = { .name = "omapdss_dss", .pm = &dss_pm_ops,
On 08/05/17 14:32, Laurent Pinchart wrote:
In preparation for removal of the core module, move the shutdown() handler from core to dss.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 20 -------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 20 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Although I wonder if shutdown is even needed... I think the DRM side should disable all the displays when being removed.
Tomi
Hi Tomi,
On Tuesday 09 May 2017 14:38:39 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
In preparation for removal of the core module, move the shutdown() handler from core to dss.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 20 -------------------- drivers/gpu/drm/omapdrm/dss/dss.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 20 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Although I wonder if shutdown is even needed... I think the DRM side should disable all the displays when being removed.
The .shutdown() handler is called when the system is shut down, including prior to a reboot. As far as I know the DRM core doesn't get involved there.
Both structures describe features of a particular OMAP DSS version, there's no reason to keep them separate. Merge them together, allowing initialization of the features based on the DSS compatible string instead of the OMAP SoC version.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 2 - drivers/gpu/drm/omapdrm/dss/dss.c | 128 +---------------- drivers/gpu/drm/omapdrm/dss/dss.h | 6 + drivers/gpu/drm/omapdrm/dss/dss_features.c | 220 ++++++++++++++++++++--------- drivers/gpu/drm/omapdrm/dss/dss_features.h | 41 +++++- 5 files changed, 204 insertions(+), 193 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 839bfb5a2e48..2a8bf441d38d 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -54,8 +54,6 @@ static int __init omap_dss_probe(struct platform_device *pdev) { core.pdev = pdev;
- dss_features_init(omapdss_get_version()); - return 0; }
diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c index 34d5caa7d0b5..edfb1ecded76 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.c +++ b/drivers/gpu/drm/omapdrm/dss/dss.c @@ -77,16 +77,6 @@ struct dss_ops { enum dss_clk_source clk_src); };
-struct dss_features { - enum dss_device_type type; - u8 fck_div_max; - u8 dss_fck_multiplier; - const char *parent_clk_name; - const enum omap_display_type *ports; - int num_ports; - const struct dss_ops *ops; -}; - static struct { struct platform_device *pdev; void __iomem *base; @@ -108,7 +98,7 @@ static struct { bool ctx_valid; u32 ctx[DSS_SZ_REGS / sizeof(u32)];
- const struct dss_features *feat; + const struct omap_dss_features *feat;
struct dss_pll *video1_pll; struct dss_pll *video2_pll; @@ -969,114 +959,25 @@ static inline void dss_uninitialize_debugfs(void) } #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
-static const struct dss_ops dss_ops_omap2_omap3 = { +const struct dss_ops dss_ops_omap2_omap3 = { .dpi_select_source = &dss_dpi_select_source_omap2_omap3, };
-static const struct dss_ops dss_ops_omap4 = { +const struct dss_ops dss_ops_omap4 = { .dpi_select_source = &dss_dpi_select_source_omap4, .select_lcd_source = &dss_lcd_clk_mux_omap4, };
-static const struct dss_ops dss_ops_omap5 = { +const struct dss_ops dss_ops_omap5 = { .dpi_select_source = &dss_dpi_select_source_omap5, .select_lcd_source = &dss_lcd_clk_mux_omap5, };
-static const struct dss_ops dss_ops_dra7 = { +const struct dss_ops dss_ops_dra7 = { .dpi_select_source = &dss_dpi_select_source_dra7xx, .select_lcd_source = &dss_lcd_clk_mux_dra7, };
-static const enum omap_display_type omap2plus_ports[] = { - OMAP_DISPLAY_TYPE_DPI, -}; - -static const enum omap_display_type omap34xx_ports[] = { - OMAP_DISPLAY_TYPE_DPI, - OMAP_DISPLAY_TYPE_SDI, -}; - -static const enum omap_display_type dra7xx_ports[] = { - OMAP_DISPLAY_TYPE_DPI, - OMAP_DISPLAY_TYPE_DPI, - OMAP_DISPLAY_TYPE_DPI, -}; - -static const struct dss_features omap24xx_dss_feats = { - .type = DSS_TYPE_OMAP2, - /* - * fck div max is really 16, but the divider range has gaps. The range - * from 1 to 6 has no gaps, so let's use that as a max. - */ - .fck_div_max = 6, - .dss_fck_multiplier = 2, - .parent_clk_name = "core_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features omap34xx_dss_feats = { - .type = DSS_TYPE_OMAP3, - .fck_div_max = 16, - .dss_fck_multiplier = 2, - .parent_clk_name = "dpll4_ck", - .ports = omap34xx_ports, - .num_ports = ARRAY_SIZE(omap34xx_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features omap3630_dss_feats = { - .type = DSS_TYPE_OMAP3, - .fck_div_max = 32, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll4_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features omap44xx_dss_feats = { - .type = DSS_TYPE_OMAP4, - .fck_div_max = 32, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll_per_x2_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_dra7, -}; - -static const struct dss_features omap54xx_dss_feats = { - .type = DSS_TYPE_OMAP5, - .fck_div_max = 64, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll_per_x2_ck", - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap5, -}; - -static const struct dss_features am43xx_dss_feats = { - .type = DSS_TYPE_OMAP3, - .fck_div_max = 0, - .dss_fck_multiplier = 0, - .parent_clk_name = NULL, - .ports = omap2plus_ports, - .num_ports = ARRAY_SIZE(omap2plus_ports), - .ops = &dss_ops_omap2_omap3, -}; - -static const struct dss_features dra7xx_dss_feats = { - .type = DSS_TYPE_DRA7, - .fck_div_max = 64, - .dss_fck_multiplier = 1, - .parent_clk_name = "dpll_per_x2_ck", - .ports = dra7xx_ports, - .num_ports = ARRAY_SIZE(dra7xx_ports), - .ops = &dss_ops_dra7, -}; - static int dss_init_ports(struct platform_device *pdev) { struct device_node *parent = pdev->dev.of_node; @@ -1225,23 +1126,6 @@ static int dss_video_pll_probe(struct platform_device *pdev) }
/* DSS HW IP initialisation */ -static const struct of_device_id dss_of_match[] = { - { .compatible = "ti,omap2-dss", .data = &omap24xx_dss_feats }, - { .compatible = "ti,omap3-dss", .data = &omap3630_dss_feats }, - { .compatible = "ti,omap4-dss", .data = &omap44xx_dss_feats }, - { .compatible = "ti,omap5-dss", .data = &omap54xx_dss_feats }, - { .compatible = "ti,dra7-dss", .data = &dra7xx_dss_feats }, - {}, -}; -MODULE_DEVICE_TABLE(of, dss_of_match); - -static const struct soc_device_attribute dss_soc_devices[] = { - { .machine = "OMAP3430/3530", .data = &omap34xx_dss_feats }, - { .machine = "AM35??", .data = &omap34xx_dss_feats }, - { .family = "AM43xx", .data = &am43xx_dss_feats }, - { /* sentinel */ } -}; - static int dss_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -1396,6 +1280,8 @@ static int dss_probe(struct platform_device *pdev) else dss.feat = of_match_device(dss_of_match, &pdev->dev)->data;
+ dss_features_init(dss.feat); + r = dss_initialize_debugfs(); if (r) return r; diff --git a/drivers/gpu/drm/omapdrm/dss/dss.h b/drivers/gpu/drm/omapdrm/dss/dss.h index eca7d731f5c8..e339874f6824 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss.h +++ b/drivers/gpu/drm/omapdrm/dss/dss.h @@ -245,6 +245,12 @@ static inline bool dss_mgr_is_lcd(enum omap_channel id) return false; }
+struct dss_ops; +extern const struct dss_ops dss_ops_omap2_omap3; +extern const struct dss_ops dss_ops_omap4; +extern const struct dss_ops dss_ops_omap5; +extern const struct dss_ops dss_ops_dra7; + /* DSS */ #if defined(CONFIG_OMAP2_DSS_DEBUGFS) int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.c b/drivers/gpu/drm/omapdrm/dss/dss_features.c index ee5b93ce2763..f92df91a9d4c 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.c +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.c @@ -21,7 +21,9 @@ #include <linux/module.h> #include <linux/types.h> #include <linux/err.h> +#include <linux/mod_devicetable.h> #include <linux/slab.h> +#include <linux/sys_soc.h>
#include "omapdss.h" #include "dss.h" @@ -36,27 +38,6 @@ struct dss_param_range { int min, max; };
-struct omap_dss_features { - const struct dss_reg_field *reg_fields; - const int num_reg_fields; - - const enum dss_feat_id *features; - const int num_features; - - const int num_mgrs; - const int num_ovls; - const enum omap_display_type *supported_displays; - const enum omap_dss_output_id *supported_outputs; - const enum omap_color_mode *supported_color_modes; - const enum omap_overlay_caps *overlay_caps; - const struct dss_param_range *dss_params; - - const enum omap_dss_rotation_type supported_rotation_types; - - const u32 buffer_size_unit; - const u32 burst_size_unit; -}; - /* This struct is assigned to one of the below during initialization */ static const struct omap_dss_features *omap_current_dss_features;
@@ -587,8 +568,35 @@ static const enum dss_feat_id omap5_dss_feat_list[] = { FEAT_MFLAG, };
+static const enum omap_display_type omap2plus_ports[] = { + OMAP_DISPLAY_TYPE_DPI, +}; + +static const enum omap_display_type omap34xx_ports[] = { + OMAP_DISPLAY_TYPE_DPI, + OMAP_DISPLAY_TYPE_SDI, +}; + +static const enum omap_display_type dra7xx_ports[] = { + OMAP_DISPLAY_TYPE_DPI, + OMAP_DISPLAY_TYPE_DPI, + OMAP_DISPLAY_TYPE_DPI, +}; + /* OMAP2 DSS Features */ -static const struct omap_dss_features omap2_dss_features = { +static const struct omap_dss_features omap24xx_dss_features = { + .type = DSS_TYPE_OMAP2, + /* + * fck div max is really 16, but the divider range has gaps. The range + * from 1 to 6 has no gaps, so let's use that as a max. + */ + .fck_div_max = 6, + .dss_fck_multiplier = 2, + .parent_clk_name = "core_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap2_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap2_dss_reg_fields),
@@ -609,6 +617,14 @@ static const struct omap_dss_features omap2_dss_features = {
/* OMAP3 DSS Features */ static const struct omap_dss_features omap3430_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 16, + .dss_fck_multiplier = 2, + .parent_clk_name = "dpll4_ck", + .ports = omap34xx_ports, + .num_ports = ARRAY_SIZE(omap34xx_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap3_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
@@ -632,6 +648,14 @@ static const struct omap_dss_features omap3430_dss_features = { * vdds_dsi regulator. */ static const struct omap_dss_features am35xx_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 16, + .dss_fck_multiplier = 2, + .parent_clk_name = "dpll4_ck", + .ports = omap34xx_ports, + .num_ports = ARRAY_SIZE(omap34xx_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap3_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
@@ -651,6 +675,14 @@ static const struct omap_dss_features am35xx_dss_features = { };
static const struct omap_dss_features am43xx_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 0, + .dss_fck_multiplier = 0, + .parent_clk_name = NULL, + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = am43xx_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(am43xx_dss_reg_fields),
@@ -670,6 +702,14 @@ static const struct omap_dss_features am43xx_dss_features = { };
static const struct omap_dss_features omap3630_dss_features = { + .type = DSS_TYPE_OMAP3, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll4_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap2_omap3, + .reg_fields = omap3_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap3_dss_reg_fields),
@@ -691,6 +731,14 @@ static const struct omap_dss_features omap3630_dss_features = { /* OMAP4 DSS Features */ /* For OMAP4430 ES 1.0 revision */ static const struct omap_dss_features omap4430_es1_0_dss_features = { + .type = DSS_TYPE_OMAP4, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_dra7, + .reg_fields = omap4_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
@@ -711,6 +759,14 @@ static const struct omap_dss_features omap4430_es1_0_dss_features = {
/* For OMAP4430 ES 2.0, 2.1 and 2.2 revisions */ static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = { + .type = DSS_TYPE_OMAP4, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_dra7, + .reg_fields = omap4_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
@@ -730,7 +786,15 @@ static const struct omap_dss_features omap4430_es2_0_1_2_dss_features = { };
/* For all the other OMAP4 versions */ -static const struct omap_dss_features omap4_dss_features = { +static const struct omap_dss_features omap44xx_dss_features = { + .type = DSS_TYPE_OMAP4, + .fck_div_max = 32, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_dra7, + .reg_fields = omap4_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap4_dss_reg_fields),
@@ -750,7 +814,15 @@ static const struct omap_dss_features omap4_dss_features = { };
/* OMAP5 DSS Features */ -static const struct omap_dss_features omap5_dss_features = { +static const struct omap_dss_features omap54xx_dss_features = { + .type = DSS_TYPE_OMAP5, + .fck_div_max = 64, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = omap2plus_ports, + .num_ports = ARRAY_SIZE(omap2plus_ports), + .ops = &dss_ops_omap5, + .reg_fields = omap5_dss_reg_fields, .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields),
@@ -769,7 +841,59 @@ static const struct omap_dss_features omap5_dss_features = { .burst_size_unit = 16, };
-/* Functions returning values related to a DSS feature */ +/* DRA7 DSS Features */ +static const struct omap_dss_features dra7xx_dss_features = { + .type = DSS_TYPE_DRA7, + .fck_div_max = 64, + .dss_fck_multiplier = 1, + .parent_clk_name = "dpll_per_x2_ck", + .ports = dra7xx_ports, + .num_ports = ARRAY_SIZE(dra7xx_ports), + .ops = &dss_ops_dra7, + + .reg_fields = omap5_dss_reg_fields, + .num_reg_fields = ARRAY_SIZE(omap5_dss_reg_fields), + + .features = omap5_dss_feat_list, + .num_features = ARRAY_SIZE(omap5_dss_feat_list), + + .num_mgrs = 4, + .num_ovls = 4, + .supported_displays = omap5_dss_supported_displays, + .supported_outputs = omap5_dss_supported_outputs, + .supported_color_modes = omap4_dss_supported_color_modes, + .overlay_caps = omap4_dss_overlay_caps, + .dss_params = omap5_dss_param_range, + .supported_rotation_types = OMAP_DSS_ROT_DMA | OMAP_DSS_ROT_TILER, + .buffer_size_unit = 16, + .burst_size_unit = 16, +}; + +const struct of_device_id dss_of_match[] = { + { .compatible = "ti,omap2-dss", .data = &omap24xx_dss_features }, + { .compatible = "ti,omap3-dss", .data = &omap3630_dss_features }, + { .compatible = "ti,omap4-dss", .data = &omap44xx_dss_features }, + { .compatible = "ti,omap5-dss", .data = &omap54xx_dss_features }, + { .compatible = "ti,dra7-dss", .data = &dra7xx_dss_features }, + {}, +}; +MODULE_DEVICE_TABLE(of, dss_of_match); + +const struct soc_device_attribute dss_soc_devices[] = { + { .machine = "OMAP3430/3530", .data = &omap3430_dss_features }, + { .machine = "OMAP4430", + .revision = "ES1.0", .data = &omap4430_es1_0_dss_features }, + { .machine = "OMAP4430", + .revision = "ES2.[012]", .data = &omap4430_es2_0_1_2_dss_features }, + { .machine = "AM35??", .data = &am35xx_dss_features }, + { .family = "AM43xx", .data = &am43xx_dss_features }, + { /* sentinel */ } +}; + +/* ----------------------------------------------------------------------------- + * Functions returning values related to a DSS feature + */ + int dss_feat_get_num_mgrs(void) { return omap_current_dss_features->num_mgrs; @@ -859,49 +983,7 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type) return omap_current_dss_features->supported_rotation_types & rot_type; }
-void dss_features_init(enum omapdss_version version) +void dss_features_init(const struct omap_dss_features *features) { - switch (version) { - case OMAPDSS_VER_OMAP24xx: - omap_current_dss_features = &omap2_dss_features; - break; - - case OMAPDSS_VER_OMAP34xx_ES1: - case OMAPDSS_VER_OMAP34xx_ES3: - omap_current_dss_features = &omap3430_dss_features; - break; - - case OMAPDSS_VER_OMAP3630: - omap_current_dss_features = &omap3630_dss_features; - break; - - case OMAPDSS_VER_OMAP4430_ES1: - omap_current_dss_features = &omap4430_es1_0_dss_features; - break; - - case OMAPDSS_VER_OMAP4430_ES2: - omap_current_dss_features = &omap4430_es2_0_1_2_dss_features; - break; - - case OMAPDSS_VER_OMAP4: - omap_current_dss_features = &omap4_dss_features; - break; - - case OMAPDSS_VER_OMAP5: - case OMAPDSS_VER_DRA7xx: - omap_current_dss_features = &omap5_dss_features; - break; - - case OMAPDSS_VER_AM35xx: - omap_current_dss_features = &am35xx_dss_features; - break; - - case OMAPDSS_VER_AM43xx: - omap_current_dss_features = &am43xx_dss_features; - break; - - default: - DSSWARN("Unsupported OMAP version"); - break; - } + omap_current_dss_features = features; } diff --git a/drivers/gpu/drm/omapdrm/dss/dss_features.h b/drivers/gpu/drm/omapdrm/dss/dss_features.h index bb4b7f0e642b..dde8f32e677f 100644 --- a/drivers/gpu/drm/omapdrm/dss/dss_features.h +++ b/drivers/gpu/drm/omapdrm/dss/dss_features.h @@ -20,6 +20,13 @@ #ifndef __OMAP2_DSS_FEATURES_H #define __OMAP2_DSS_FEATURES_H
+#include <linux/mod_devicetable.h> +#include <linux/sys_soc.h> + +struct dss_ops; +struct dss_param_range; +struct dss_reg_field; + #define MAX_DSS_MANAGERS 4 #define MAX_DSS_OVERLAYS 4 #define MAX_DSS_LCD_MANAGERS 3 @@ -85,6 +92,35 @@ enum dss_range_param { FEAT_PARAM_LINEWIDTH, };
+struct omap_dss_features { + enum dss_device_type type; + u8 fck_div_max; + u8 dss_fck_multiplier; + const char *parent_clk_name; + const enum omap_display_type *ports; + int num_ports; + const struct dss_ops *ops; + + const struct dss_reg_field *reg_fields; + int num_reg_fields; + + const enum dss_feat_id *features; + int num_features; + + int num_mgrs; + int num_ovls; + const enum omap_display_type *supported_displays; + const enum omap_dss_output_id *supported_outputs; + const enum omap_color_mode *supported_color_modes; + const enum omap_overlay_caps *overlay_caps; + const struct dss_param_range *dss_params; + + enum omap_dss_rotation_type supported_rotation_types; + + u32 buffer_size_unit; + u32 burst_size_unit; +}; + /* DSS Feature Functions */ unsigned long dss_feat_get_param_min(enum dss_range_param param); unsigned long dss_feat_get_param_max(enum dss_range_param param); @@ -99,9 +135,12 @@ bool dss_feat_rotation_type_supported(enum omap_dss_rotation_type rot_type);
bool dss_has_feature(enum dss_feat_id id); void dss_feat_get_reg_field(enum dss_feat_reg_field id, u8 *start, u8 *end); -void dss_features_init(enum omapdss_version version); +void dss_features_init(const struct omap_dss_features *features);
enum omap_display_type dss_feat_get_supported_displays(enum omap_channel channel); enum omap_dss_output_id dss_feat_get_supported_outputs(enum omap_channel channel);
+extern const struct of_device_id dss_of_match[]; +extern const struct soc_device_attribute dss_soc_devices[]; + #endif
On 08/05/17 14:32, Laurent Pinchart wrote:
Both structures describe features of a particular OMAP DSS version, there's no reason to keep them separate. Merge them together, allowing initialization of the features based on the DSS compatible string instead of the OMAP SoC version.
I don't think this is the correct way. As I mentioned earlier, dss_features should go. We should work on moving the parts from dss_features to each individual driver. I think there are probably only a very few dss-features that need to be accessed by multiple files, and those features could have a function of their own to query them.
But that may also be a bit bigger work, so... I thought about it already earlier in this series: wouldn't it be easier to first reconstruct the current OMAPDSS_VER_* with soc_device_match(), at module init time, which would allow us to keep most of the omapdss side unchanged. Then continue removing the arch/arm/ stuff.
When that's done and merged, we could have follow up patches later to clean up dss_features, and add version handling to each driver, however is best in that particular file.
I feel that this series is perhaps doing a bit too much at once.
Tomi
Hi Tomi,
On Tuesday 09 May 2017 15:02:36 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Both structures describe features of a particular OMAP DSS version, there's no reason to keep them separate. Merge them together, allowing initialization of the features based on the DSS compatible string instead of the OMAP SoC version.
I don't think this is the correct way. As I mentioned earlier, dss_features should go. We should work on moving the parts from dss_features to each individual driver. I think there are probably only a very few dss-features that need to be accessed by multiple files, and those features could have a function of their own to query them.
I don't disagree with that, but can't we do so on top of this series ? I don't think that these patches make the situation worse.
But that may also be a bit bigger work, so... I thought about it already earlier in this series: wouldn't it be easier to first reconstruct the current OMAPDSS_VER_* with soc_device_match(), at module init time, which would allow us to keep most of the omapdss side unchanged. Then continue removing the arch/arm/ stuff.
I considered that to start with, but decided it was really a hack. I instead went for cleaning things up where possible, and keeping hacks where a proper rework would require a set of new patch series. The result is a balance between a few hacks and lots of cleanup patches, which I considered was right when I realized that the series was already 28 patches long.
When that's done and merged, we could have follow up patches later to clean up dss_features, and add version handling to each driver, however is best in that particular file.
I feel that this series is perhaps doing a bit too much at once.
Then let's not add more ;-) More seriously, as lots of cleanups are here already, I think we should merge them. If there's any hack that you believe goes in the wrong direction and would make a proper rework more complex, let's discuss them. Otherwise, for the ones that either are too small improvements, or just keep the status quo, I plan to rework them later.
On 10/05/17 01:09, Laurent Pinchart wrote:
Hi Tomi,
On Tuesday 09 May 2017 15:02:36 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Both structures describe features of a particular OMAP DSS version, there's no reason to keep them separate. Merge them together, allowing initialization of the features based on the DSS compatible string instead of the OMAP SoC version.
I don't think this is the correct way. As I mentioned earlier, dss_features should go. We should work on moving the parts from dss_features to each individual driver. I think there are probably only a very few dss-features that need to be accessed by multiple files, and those features could have a function of their own to query them.
I don't disagree with that, but can't we do so on top of this series ? I don't think that these patches make the situation worse.
But that may also be a bit bigger work, so... I thought about it already earlier in this series: wouldn't it be easier to first reconstruct the current OMAPDSS_VER_* with soc_device_match(), at module init time, which would allow us to keep most of the omapdss side unchanged. Then continue removing the arch/arm/ stuff.
I considered that to start with, but decided it was really a hack. I instead
Is it? You already use the dss compat string and soc_device_match to figure out some versions. Isn't that a proper way to find out about the SoC? But I agree that a more fine grained version management in each individual driver would be better.
went for cleaning things up where possible, and keeping hacks where a proper rework would require a set of new patch series. The result is a balance between a few hacks and lots of cleanup patches, which I considered was right when I realized that the series was already 28 patches long.
Well, my concern is that these patches change a lot of things, moving stuff from here to there. And I think they would be moved or changed again later. So lots of room for conflicts and errors.
For example, in this patch you move things from dss.c to dss_features.c, but I think the dss.c is the right place for them (at least most of them), so we'd just end up moving them back. And if instead we'd move things from dss_features.c to dss.c, well, many of the things don't belong to dss.c and would be moved again later.
Then the HDMI PLL/PHY changes, well, as I mentioned, I don't fully agree with those.
So, while I think recreating the omapdss version in the dss driver would clearly be a temporary measure, still afaics it would be not that many lines of code and in just one place, and would allow us to easily move on to remove the extra platform devices and dependencies to arch/arm/.
After that we could start cleaning up the version handling inside the driver.
It is just the omapdss version and the dsi pinmuxing we get from the platform data, so getting rid of just those two should allow removal of the platform device. So, correct me if I'm wrong, but all the hdmi, dss "model" and dss_feature changes could as well be done in a separate series later.
Tomi
Hi Tomi,
On Wednesday 10 May 2017 10:43:07 Tomi Valkeinen wrote:
On 10/05/17 01:09, Laurent Pinchart wrote:
On Tuesday 09 May 2017 15:02:36 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Both structures describe features of a particular OMAP DSS version, there's no reason to keep them separate. Merge them together, allowing initialization of the features based on the DSS compatible string instead of the OMAP SoC version.
I don't think this is the correct way. As I mentioned earlier, dss_features should go. We should work on moving the parts from dss_features to each individual driver. I think there are probably only a very few dss-features that need to be accessed by multiple files, and those features could have a function of their own to query them.
I don't disagree with that, but can't we do so on top of this series ? I don't think that these patches make the situation worse.
But that may also be a bit bigger work, so... I thought about it already earlier in this series: wouldn't it be easier to first reconstruct the current OMAPDSS_VER_* with soc_device_match(), at module init time, which would allow us to keep most of the omapdss side unchanged. Then continue removing the arch/arm/ stuff.
I considered that to start with, but decided it was really a hack. I instead
Is it? You already use the dss compat string and soc_device_match to figure out some versions. Isn't that a proper way to find out about the SoC? But I agree that a more fine grained version management in each individual driver would be better.
For OMAP2, OMAP4 or OMAP5 it shouldn't be too much of a problem, but OMAP3 would be more painful to handle. The following machine names are used.
"AM3505" "AM3517" "AM437x" "OMAP3430/3530" "OMAP3525" "OMAP3515" "OMAP3503" "OMAP3611" "OMAP3615/AM3715" "OMAP3621" "OMAP3630/DM3730" "AM3703" "DM3725"
went for cleaning things up where possible, and keeping hacks where a proper rework would require a set of new patch series. The result is a balance between a few hacks and lots of cleanup patches, which I considered was right when I realized that the series was already 28 patches long.
Well, my concern is that these patches change a lot of things, moving stuff from here to there. And I think they would be moved or changed again later. So lots of room for conflicts and errors.
For example, in this patch you move things from dss.c to dss_features.c, but I think the dss.c is the right place for them (at least most of them), so we'd just end up moving them back. And if instead we'd move things from dss_features.c to dss.c, well, many of the things don't belong to dss.c and would be moved again later.
I agree with that. I've been working on patches to deconstruct dss_features and move all features to the right place. I've achieved a v1 that I still need to cleanup a bit.
Then the HDMI PLL/PHY changes, well, as I mentioned, I don't fully agree with those.
I'll reply to that mail separately.
So, while I think recreating the omapdss version in the dss driver would clearly be a temporary measure, still afaics it would be not that many lines of code and in just one place, and would allow us to easily move on to remove the extra platform devices and dependencies to arch/arm/.
After that we could start cleaning up the version handling inside the driver.
It is just the omapdss version and the dsi pinmuxing we get from the platform data, so getting rid of just those two should allow removal of the platform device. So, correct me if I'm wrong, but all the hdmi, dss "model" and dss_feature changes could as well be done in a separate series later.
But I don't think that removing the extra platform devices is so urgent. I'd rather do it when we're ready.
The omapdss driver needs major cleanup and refactoring, and that will result in a large number of patches that will cause conflicts and be sources of potential errors. I don't think that's avoidable. However, lots of those cleanups will be independent from each other, so we can start merging the less controversial ones as soon as they're ready. I'll take care of rebasing the rest of the patches as needed.
On 13/05/17 14:12, Laurent Pinchart wrote:
Is it? You already use the dss compat string and soc_device_match to figure out some versions. Isn't that a proper way to find out about the SoC? But I agree that a more fine grained version management in each individual driver would be better.
For OMAP2, OMAP4 or OMAP5 it shouldn't be too much of a problem, but OMAP3 would be more painful to handle. The following machine names are used.
"AM3505" "AM3517" "AM437x" "OMAP3430/3530" "OMAP3525" "OMAP3515" "OMAP3503" "OMAP3611" "OMAP3615/AM3715" "OMAP3621" "OMAP3630/DM3730" "AM3703" "DM3725"
Don't we need all those somewhere in any case? I mean, I presume all the current OMAPDSS_VER_* defines are used somewhere. Which means that somewhere, maybe in multiple different files, we need to handle some or all of those.
For some features, perhaps we could move them to DT. If the feature is about how DSS is integrated into the SoC, it might make sense to have that in the DT, as a property for DSS, as it's not part of DSS itself. If the data is missing, we could inject it into the DT at boot time, based on the omap revision. Though I'm not sure if that would really help that much.
I think the most annoying "feature" is the blank/porch register field size change, that they made between OMAP3430 ES1 and ES2. And didn't bother to change the DSS IP version...
But back to the topic... Are you sure this version detection should not be centralized? If we have that many OMAP3 related devices already (btw, AM4 is not really OMAP3 related, even if the DSS there is)... And if we get one more. Does it mean we need to edit that same new device into many places?
Then again, maybe it's better to handle that separately in each file that requires the information, as sometimes all you need to know is that it's DSS3 based, but sometimes you need to know that it's AM4's DSS vs OMAP3's DSS.
But I don't think that removing the extra platform devices is so urgent. I'd rather do it when we're ready.
The omapdss driver needs major cleanup and refactoring, and that will result in a large number of patches that will cause conflicts and be sources of potential errors. I don't think that's avoidable. However, lots of those cleanups will be independent from each other, so we can start merging the less controversial ones as soon as they're ready. I'll take care of rebasing the rest of the patches as needed.
Yes, no disagreements there. My hope is just that a series is as small as possible. Or, that's not correct... A series does one change at a time, e.g. here my problem was that the platform change was being done at the same time as the feature change, interleaved.
I most likely will need to backport all these to v4.9 kernel. And then manage new patches that will be applied on top of mainline and that v4.9 kernel. And I will gladly take any changes to patch serieses that possibly make that work easier =).
Tomi
Hi Tomi,
On Monday 15 May 2017 09:32:01 Tomi Valkeinen wrote:
On 13/05/17 14:12, Laurent Pinchart wrote:
Is it? You already use the dss compat string and soc_device_match to figure out some versions. Isn't that a proper way to find out about the SoC? But I agree that a more fine grained version management in each individual driver would be better.
For OMAP2, OMAP4 or OMAP5 it shouldn't be too much of a problem, but OMAP3 would be more painful to handle. The following machine names are used.
"AM3505" "AM3517" "AM437x" "OMAP3430/3530" "OMAP3525" "OMAP3515" "OMAP3503" "OMAP3611" "OMAP3615/AM3715" "OMAP3621" "OMAP3630/DM3730" "AM3703" "DM3725"
Don't we need all those somewhere in any case? I mean, I presume all the current OMAPDSS_VER_* defines are used somewhere. Which means that somewhere, maybe in multiple different files, we need to handle some or all of those.
We do, but the way we combine all the information we need in a single version isn't ideal. Most omapdrm sub-drivers use version checks in a way that combine many cases together, resulting in just a handful of different options. Different drivers use different checks, so we end up with a long list of versions that more or less describe the combination of multiple boolean (or short enum) parameters. By splitting the version into those parameters, we can simplify the code, and move the pieces where they belong to.
For some features, perhaps we could move them to DT. If the feature is about how DSS is integrated into the SoC, it might make sense to have that in the DT, as a property for DSS, as it's not part of DSS itself. If the data is missing, we could inject it into the DT at boot time, based on the omap revision. Though I'm not sure if that would really help that much.
I agree in principle, but we should probably check that on a case by case basis.
I think the most annoying "feature" is the blank/porch register field size change, that they made between OMAP3430 ES1 and ES2. And didn't bother to change the DSS IP version...
This could indeed be described in DT (either through a different compatible string or a separate DT property). Using SoC matching is a reasonable alternative in my opinion to handle past mistakes, as long as there's not too many of them.
But back to the topic... Are you sure this version detection should not be centralized? If we have that many OMAP3 related devices already (btw, AM4 is not really OMAP3 related, even if the DSS there is)... And if we get one more. Does it mean we need to edit that same new device into many places?
Yes, I'm fairly confident, as most parameters are related to versions of the individual IP cores, not about how they're integrated in a particular SoC.
Then again, maybe it's better to handle that separately in each file that requires the information, as sometimes all you need to know is that it's DSS3 based, but sometimes you need to know that it's AM4's DSS vs OMAP3's DSS.
Yes, that's definitely how I've implemented it (in patches I'm about to send). It results in simpler code in my opinion.
But I don't think that removing the extra platform devices is so urgent. I'd rather do it when we're ready.
The omapdss driver needs major cleanup and refactoring, and that will result in a large number of patches that will cause conflicts and be sources of potential errors. I don't think that's avoidable. However, lots of those cleanups will be independent from each other, so we can start merging the less controversial ones as soon as they're ready. I'll take care of rebasing the rest of the patches as needed.
Yes, no disagreements there. My hope is just that a series is as small as possible. Or, that's not correct... A series does one change at a time, e.g. here my problem was that the platform change was being done at the same time as the feature change, interleaved.
I most likely will need to backport all these to v4.9 kernel. And then manage new patches that will be applied on top of mainline and that v4.9 kernel. And I will gladly take any changes to patch serieses that possibly make that work easier =).
The omapdrm platform device is a virtual device created for the sole purpose of handling the omapdss/omapdrm driver split. It should eventually be removed. As a first step to ease refactoring move its registration from platform code to driver code.
The omapdrm driver name must be changed internally to avoid probing both the device registered in platform code and the device registered in the omapdss driver, as that would otherwise break bisection.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- Changes since v1:
- Drop the CONFIG_DRM_OMAP conditional compilation - Unregister the platform device at exit time --- drivers/gpu/drm/omapdrm/dss/core.c | 15 +++++++++++++++ drivers/gpu/drm/omapdrm/omap_drv.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index 2a8bf441d38d..e4781356de96 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -22,6 +22,7 @@
#define DSS_SUBSYS_NAME "CORE"
+#include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/clk.h> @@ -110,6 +111,14 @@ static void (*dss_output_drv_unreg_funcs[])(void) = { dss_uninit_platform_driver, };
+static struct platform_device omap_drm_device = { + .dev = { + .coherent_dma_mask = DMA_BIT_MASK(32), + }, + .name = "omapdrm_", + .id = 0, +}; + static int __init omap_dss_init(void) { int r; @@ -125,6 +134,10 @@ static int __init omap_dss_init(void) goto err_reg; }
+ r = platform_device_register(&omap_drm_device); + if (r) + goto err_reg; + return 0;
err_reg: @@ -142,6 +155,8 @@ static void __exit omap_dss_exit(void) { int i;
+ platform_device_unregister(&omap_drm_device); + for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) dss_output_drv_unreg_funcs[i]();
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c b/drivers/gpu/drm/omapdrm/omap_drv.c index 343301ed4741..6f5fddbaea65 100644 --- a/drivers/gpu/drm/omapdrm/omap_drv.c +++ b/drivers/gpu/drm/omapdrm/omap_drv.c @@ -957,7 +957,7 @@ static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
static struct platform_driver pdev = { .driver = { - .name = DRIVER_NAME, + .name = "omapdrm_", .pm = &omapdrm_pm_ops, }, .probe = pdev_probe,
On 08/05/17 14:32, Laurent Pinchart wrote:
The omapdrm platform device is a virtual device created for the sole purpose of handling the omapdss/omapdrm driver split. It should eventually be removed. As a first step to ease refactoring move its registration from platform code to driver code.
The omapdrm driver name must be changed internally to avoid probing both the device registered in platform code and the device registered in the omapdss driver, as that would otherwise break bisection.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
Changes since v1:
- Drop the CONFIG_DRM_OMAP conditional compilation
- Unregister the platform device at exit time
drivers/gpu/drm/omapdrm/dss/core.c | 15 +++++++++++++++ drivers/gpu/drm/omapdrm/omap_drv.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
I think you could rename the device back at the end of the series.
Tomi
The omapdss driver (not to be confused with the omapdss_dss driver) is now a dummy driver with empty probe and remove functions. Remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- drivers/gpu/drm/omapdrm/dss/core.c | 48 ----------------------------------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 - 2 files changed, 49 deletions(-)
diff --git a/drivers/gpu/drm/omapdrm/dss/core.c b/drivers/gpu/drm/omapdrm/dss/core.c index e4781356de96..fe176978d127 100644 --- a/drivers/gpu/drm/omapdrm/dss/core.c +++ b/drivers/gpu/drm/omapdrm/dss/core.c @@ -25,50 +25,10 @@ #include <linux/dma-mapping.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/clk.h> -#include <linux/err.h> #include <linux/platform_device.h> -#include <linux/io.h> -#include <linux/device.h> -#include <linux/regulator/consumer.h> -#include <linux/suspend.h> -#include <linux/slab.h>
#include "omapdss.h" #include "dss.h" -#include "dss_features.h" - -static struct { - struct platform_device *pdev; -} core; - -enum omapdss_version omapdss_get_version(void) -{ - struct omap_dss_board_info *pdata = core.pdev->dev.platform_data; - return pdata->version; -} -EXPORT_SYMBOL(omapdss_get_version); - -/* PLATFORM DEVICE */ - -static int __init omap_dss_probe(struct platform_device *pdev) -{ - core.pdev = pdev; - - return 0; -} - -static int omap_dss_remove(struct platform_device *pdev) -{ - return 0; -} - -static struct platform_driver omap_dss_driver = { - .remove = omap_dss_remove, - .driver = { - .name = "omapdss", - }, -};
/* INIT */ static int (*dss_output_drv_reg_funcs[])(void) __initdata = { @@ -124,10 +84,6 @@ static int __init omap_dss_init(void) int r; int i;
- r = platform_driver_probe(&omap_dss_driver, omap_dss_probe); - if (r) - return r; - for (i = 0; i < ARRAY_SIZE(dss_output_drv_reg_funcs); ++i) { r = dss_output_drv_reg_funcs[i](); if (r) @@ -146,8 +102,6 @@ static int __init omap_dss_init(void) ++i) dss_output_drv_unreg_funcs[i]();
- platform_driver_unregister(&omap_dss_driver); - return r; }
@@ -159,8 +113,6 @@ static void __exit omap_dss_exit(void)
for (i = 0; i < ARRAY_SIZE(dss_output_drv_unreg_funcs); ++i) dss_output_drv_unreg_funcs[i](); - - platform_driver_unregister(&omap_dss_driver); }
module_init(omap_dss_init); diff --git a/drivers/gpu/drm/omapdrm/dss/omapdss.h b/drivers/gpu/drm/omapdrm/dss/omapdss.h index 32eae507a669..6a9a502ac672 100644 --- a/drivers/gpu/drm/omapdrm/dss/omapdss.h +++ b/drivers/gpu/drm/omapdrm/dss/omapdss.h @@ -766,7 +766,6 @@ struct omap_dss_driver { const struct hdmi_avi_infoframe *avi); };
-enum omapdss_version omapdss_get_version(void); bool omapdss_is_initialized(void);
int omap_dss_register_driver(struct omap_dss_driver *);
On 08/05/17 14:33, Laurent Pinchart wrote:
The omapdss driver (not to be confused with the omapdss_dss driver) is now a dummy driver with empty probe and remove functions. Remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
drivers/gpu/drm/omapdrm/dss/core.c | 48 ----------------------------------- drivers/gpu/drm/omapdrm/dss/omapdss.h | 1 - 2 files changed, 49 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The omapdrm platform device is unused, as a replacement is now registered in the omapdss driver. Remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- arch/arm/mach-omap2/Makefile | 2 +- arch/arm/mach-omap2/display.c | 7 ------ arch/arm/mach-omap2/display.h | 1 - arch/arm/mach-omap2/drm.c | 53 ------------------------------------------- 4 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 arch/arm/mach-omap2/drm.c
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index c89757abb0ae..9d3ba1e0119c 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -8,7 +8,7 @@ ccflags-y := -I$(srctree)/$(src)/include \ # Common support obj-y := id.o io.o control.o devices.o fb.o timer.o pm.o \ common.o dma.o wd_timer.o display.o i2c.o hdq1w.o omap_hwmod.o \ - omap_device.o omap-headsmp.o sram.o drm.o + omap_device.o omap-headsmp.o sram.o
hwmod-common = omap_hwmod.o omap_hwmod_reset.o \ omap_hwmod_common_data.o diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index 8fa01c0ecdb2..5f5697668de8 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c @@ -384,13 +384,6 @@ int __init omapdss_init_of(void) return r; }
- /* create DRM device */ - r = omap_init_drm(); - if (r < 0) { - pr_err("Unable to register omapdrm device\n"); - return r; - } - /* create vrfb device */ r = omap_init_vrfb(); if (r < 0) { diff --git a/arch/arm/mach-omap2/display.h b/arch/arm/mach-omap2/display.h index 9a39646d4316..42ec2e99a2f4 100644 --- a/arch/arm/mach-omap2/display.h +++ b/arch/arm/mach-omap2/display.h @@ -26,7 +26,6 @@ struct omap_dss_dispc_dev_attr { bool has_framedonetv_irq; };
-int omap_init_drm(void); int omap_init_vrfb(void); int omap_init_fb(void); int omap_init_vout(void); diff --git a/arch/arm/mach-omap2/drm.c b/arch/arm/mach-omap2/drm.c deleted file mode 100644 index 44fef961bb70..000000000000 --- a/arch/arm/mach-omap2/drm.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * DRM/KMS device registration for TI OMAP platforms - * - * Copyright (C) 2012 Texas Instruments - * Author: Rob Clark rob.clark@linaro.org - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see http://www.gnu.org/licenses/. - */ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/mm.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/dma-mapping.h> -#include <linux/platform_data/omap_drm.h> - -#include "soc.h" -#include "display.h" - -#if IS_ENABLED(CONFIG_DRM_OMAP) - -static struct omap_drm_platform_data platform_data; - -static struct platform_device omap_drm_device = { - .dev = { - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &platform_data, - }, - .name = "omapdrm", - .id = 0, -}; - -int __init omap_init_drm(void) -{ - platform_data.omaprev = GET_OMAP_TYPE; - - return platform_device_register(&omap_drm_device); - -} -#else -int __init omap_init_drm(void) { return 0; } -#endif
* Laurent Pinchart laurent.pinchart@ideasonboard.com [170508 04:36]:
The omapdrm platform device is unused, as a replacement is now registered in the omapdss driver. Remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
This should be OK to merge via the drm patches as long as things have been properly tested to not cause regressions:
Acked-by: Tony Lindgren tony@atomide.com
Hi Tony,
On Monday 08 May 2017 10:09:06 Tony Lindgren wrote:
- Laurent Pinchart laurent.pinchart@ideasonboard.com [170508 04:36]:
The omapdrm platform device is unused, as a replacement is now registered in the omapdss driver. Remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
This should be OK to merge via the drm patches as long as things have been properly tested to not cause regressions:
Acked-by: Tony Lindgren tony@atomide.com
I'll do my best to ensure that. I can't test the code on all OMAP platforms, but given that this patch (and the next one) are not dependent on the particular OMAP SoC, it should be fine.
On 08/05/17 14:33, Laurent Pinchart wrote:
The omapdrm platform device is unused, as a replacement is now registered in the omapdss driver. Remove it.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
arch/arm/mach-omap2/Makefile | 2 +- arch/arm/mach-omap2/display.c | 7 ------ arch/arm/mach-omap2/display.h | 1 - arch/arm/mach-omap2/drm.c | 53 ------------------------------------------- 4 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 arch/arm/mach-omap2/drm.c
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The omapdrm driver doesn't need the omapdss device anymore. Although it can't be removed completely as the fbdev driver still requires it, we can condition its registration to the usage of the omapfb driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- arch/arm/mach-omap2/display.c | 111 +++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 51 deletions(-)
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c index 5f5697668de8..798fc718fffe 100644 --- a/arch/arm/mach-omap2/display.c +++ b/arch/arm/mach-omap2/display.c @@ -66,6 +66,7 @@ */ #define FRAMEDONE_IRQ_TIMEOUT 100
+#if defined(CONFIG_FB_OMAP2) static struct platform_device omap_display_device = { .name = "omapdss", .id = -1, @@ -163,6 +164,64 @@ static enum omapdss_version __init omap_display_get_version(void) return OMAPDSS_VER_UNKNOWN; }
+static int __init omapdss_init_fbdev(void) +{ + static struct omap_dss_board_info board_data = { + .dsi_enable_pads = omap_dsi_enable_pads, + .dsi_disable_pads = omap_dsi_disable_pads, + .set_min_bus_tput = omap_dss_set_min_bus_tput, + }; + struct device_node *node; + + board_data.version = omap_display_get_version(); + if (board_data.version == OMAPDSS_VER_UNKNOWN) { + pr_err("DSS not supported on this SoC\n"); + return -ENODEV; + } + + omap_display_device.dev.platform_data = &board_data; + + r = platform_device_register(&omap_display_device); + if (r < 0) { + pr_err("Unable to register omapdss device\n"); + return r; + } + + /* create vrfb device */ + r = omap_init_vrfb(); + if (r < 0) { + pr_err("Unable to register omapvrfb device\n"); + return r; + } + + /* create FB device */ + r = omap_init_fb(); + if (r < 0) { + pr_err("Unable to register omapfb device\n"); + return r; + } + + /* create V4L2 display device */ + r = omap_init_vout(); + if (r < 0) { + pr_err("Unable to register omap_vout device\n"); + return r; + } + + /* add DSI info for omap4 */ + node = of_find_node_by_name(NULL, "omap4_padconf_global"); + if (node) + omap4_dsi_mux_syscon = syscon_node_to_regmap(node); + + return 0; +} +#else +static inline int omapdss_init_fbdev(void) +{ + return 0; +} +#endif /* CONFIG_FB_OMAP2 */ + static void dispc_disable_outputs(void) { u32 v, irq_mask = 0; @@ -335,16 +394,9 @@ static struct device_node * __init omapdss_find_dss_of_node(void) int __init omapdss_init_of(void) { int r; - enum omapdss_version ver; struct device_node *node; struct platform_device *pdev;
- static struct omap_dss_board_info board_data = { - .dsi_enable_pads = omap_dsi_enable_pads, - .dsi_disable_pads = omap_dsi_disable_pads, - .set_min_bus_tput = omap_dss_set_min_bus_tput, - }; - /* only create dss helper devices if dss is enabled in the .dts */
node = omapdss_find_dss_of_node(); @@ -354,13 +406,6 @@ int __init omapdss_init_of(void) if (!of_device_is_available(node)) return 0;
- ver = omap_display_get_version(); - - if (ver == OMAPDSS_VER_UNKNOWN) { - pr_err("DSS not supported on this SoC\n"); - return -ENODEV; - } - pdev = of_find_device_by_node(node);
if (!pdev) { @@ -374,41 +419,5 @@ int __init omapdss_init_of(void) return r; }
- board_data.version = ver; - - omap_display_device.dev.platform_data = &board_data; - - r = platform_device_register(&omap_display_device); - if (r < 0) { - pr_err("Unable to register omapdss device\n"); - return r; - } - - /* create vrfb device */ - r = omap_init_vrfb(); - if (r < 0) { - pr_err("Unable to register omapvrfb device\n"); - return r; - } - - /* create FB device */ - r = omap_init_fb(); - if (r < 0) { - pr_err("Unable to register omapfb device\n"); - return r; - } - - /* create V4L2 display device */ - r = omap_init_vout(); - if (r < 0) { - pr_err("Unable to register omap_vout device\n"); - return r; - } - - /* add DSI info for omap4 */ - node = of_find_node_by_name(NULL, "omap4_padconf_global"); - if (node) - omap4_dsi_mux_syscon = syscon_node_to_regmap(node); - - return 0; + return omapdss_init_fbdev(); }
* Laurent Pinchart laurent.pinchart@ideasonboard.com [170508 04:36]:
The omapdrm driver doesn't need the omapdss device anymore. Although it can't be removed completely as the fbdev driver still requires it, we can condition its registration to the usage of the omapfb driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
This too:
Acked-by: Tony Lindgren tony@atomide.com
On 08/05/17 14:33, Laurent Pinchart wrote:
The omapdrm driver doesn't need the omapdss device anymore. Although it can't be removed completely as the fbdev driver still requires it, we can condition its registration to the usage of the omapfb driver.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
arch/arm/mach-omap2/display.c | 111 +++++++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 51 deletions(-)
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
The omapdrm platform data are not used anymore, remove them.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com --- include/linux/platform_data/omap_drm.h | 53 ---------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 include/linux/platform_data/omap_drm.h
diff --git a/include/linux/platform_data/omap_drm.h b/include/linux/platform_data/omap_drm.h deleted file mode 100644 index f4e4a237ebd2..000000000000 --- a/include/linux/platform_data/omap_drm.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * DRM/KMS platform data for TI OMAP platforms - * - * Copyright (C) 2012 Texas Instruments - * Author: Rob Clark rob.clark@linaro.org - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 as published by - * the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef __PLATFORM_DATA_OMAP_DRM_H__ -#define __PLATFORM_DATA_OMAP_DRM_H__ - -/* - * Optional platform data to configure the default configuration of which - * pipes/overlays/CRTCs are used.. if this is not provided, then instead the - * first CONFIG_DRM_OMAP_NUM_CRTCS are used, and they are each connected to - * one manager, with priority given to managers that are connected to - * detected devices. Remaining overlays are used as video planes. This - * should be a good default behavior for most cases, but yet there still - * might be times when you wish to do something different. - */ -struct omap_kms_platform_data { - /* overlays to use as CRTCs: */ - int ovl_cnt; - const int *ovl_ids; - - /* overlays to use as video planes: */ - int pln_cnt; - const int *pln_ids; - - int mgr_cnt; - const int *mgr_ids; - - int dev_cnt; - const char **dev_names; -}; - -struct omap_drm_platform_data { - uint32_t omaprev; - struct omap_kms_platform_data *kms_pdata; -}; - -#endif /* __PLATFORM_DATA_OMAP_DRM_H__ */
On 08/05/17 14:33, Laurent Pinchart wrote:
The omapdrm platform data are not used anymore, remove them.
Signed-off-by: Laurent Pinchart laurent.pinchart@ideasonboard.com
include/linux/platform_data/omap_drm.h | 53 ---------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 include/linux/platform_data/omap_drm.h
Reviewed-by: Tomi Valkeinen tomi.valkeinen@ti.com
Tomi
* Laurent Pinchart laurent.pinchart@ideasonboard.com [170508 04:36]:
The next step is to remove the omapdss platform driver (for the virtual omapdss platform device, also known as core code, not to be confused with the omapdss_dss driver for the DSS hardware device). Patches 21/28 to 23/28 move the useful features of the core to the omapdss_dss driver. Patch 24/28 adds omapdrm platform device registration to the omapdss_dss driver to replace board code, and patch 25/28 finally removes the omapdss platform driver.
Note that registering the omapdrm platform device from within the omapdss_dss driver is a hack, but isn't worse than the current situation. Quite the contrary, given that the omapdrm device exists for the sole purpose of supporting the omapdrm/omapdss driver architecture, moving it out of platform code can be considered as (slightly) cleaner. In any case, it will be easier to refactor the code as everything is now isolated on the driver side.
Good to see this happening. While at it, can you please also check that the struct device entries follow what's in the hardware to avoid more headaches later on.
The rule of thumb for struct device use here should be that each interconnect target module is a separate device. If a single interconnect target module has multiple IP blocks within it, then you need to have a minimal wrapper driver to deal with the shared hardware resources like the clkctrl clock ("ti,hwmods") along the lines of what we're doing in drivers/usb/musb/musb_am335x.c to wrap two musb instances and cppi41 dma all in a single interconnect target module.
You can detect the interconnect target module with SYSCONFIG and SYSSTATUS entries listed for it in the TRM. It might be already set up that way if we're lucky.
Regards,
Tony
On 08/05/17 20:07, Tony Lindgren wrote:
- Laurent Pinchart laurent.pinchart@ideasonboard.com [170508 04:36]:
The next step is to remove the omapdss platform driver (for the virtual omapdss platform device, also known as core code, not to be confused with the omapdss_dss driver for the DSS hardware device). Patches 21/28 to 23/28 move the useful features of the core to the omapdss_dss driver. Patch 24/28 adds omapdrm platform device registration to the omapdss_dss driver to replace board code, and patch 25/28 finally removes the omapdss platform driver.
Note that registering the omapdrm platform device from within the omapdss_dss driver is a hack, but isn't worse than the current situation. Quite the contrary, given that the omapdrm device exists for the sole purpose of supporting the omapdrm/omapdss driver architecture, moving it out of platform code can be considered as (slightly) cleaner. In any case, it will be easier to refactor the code as everything is now isolated on the driver side.
Good to see this happening. While at it, can you please also check that the struct device entries follow what's in the hardware to avoid more headaches later on.
This has been the case for many years. We've just had some extra stuff on top, due to legacy reasons (from time before hwmods).
Tomi
* Tomi Valkeinen tomi.valkeinen@ti.com [170509 04:56]:
On 08/05/17 20:07, Tony Lindgren wrote:
- Laurent Pinchart laurent.pinchart@ideasonboard.com [170508 04:36]:
The next step is to remove the omapdss platform driver (for the virtual omapdss platform device, also known as core code, not to be confused with the omapdss_dss driver for the DSS hardware device). Patches 21/28 to 23/28 move the useful features of the core to the omapdss_dss driver. Patch 24/28 adds omapdrm platform device registration to the omapdss_dss driver to replace board code, and patch 25/28 finally removes the omapdss platform driver.
Note that registering the omapdrm platform device from within the omapdss_dss driver is a hack, but isn't worse than the current situation. Quite the contrary, given that the omapdrm device exists for the sole purpose of supporting the omapdrm/omapdss driver architecture, moving it out of platform code can be considered as (slightly) cleaner. In any case, it will be easier to refactor the code as everything is now isolated on the driver side.
Good to see this happening. While at it, can you please also check that the struct device entries follow what's in the hardware to avoid more headaches later on.
This has been the case for many years. We've just had some extra stuff on top, due to legacy reasons (from time before hwmods).
OK thanks for confirming that.
Tony
On 08/05/17 14:32, Laurent Pinchart wrote:
Hello,
This patch series is a second, extended version of the code previously posted as "[PATCH/RFC 0/7] Remove the omapdrm device from platform code".
As this is a long series, I'd like to pick a bunch of patches from this series already:
1-5, 7, 19, 21.
I didn't test yet, but I think those should not cause conflicts with the rest of the series.
I can then push the branch, which contains also the fences and cache patches, so you can base the rest on that.
Is this ok?
Tomi
Hi,
On Tue, May 09, 2017 at 03:10:40PM +0300, Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Hello,
This patch series is a second, extended version of the code previously posted as "[PATCH/RFC 0/7] Remove the omapdrm device from platform code".
As this is a long series, I'd like to pick a bunch of patches from this series already:
1-5, 7, 19, 21.
I can't reply directly, since I was not subscribed to dri-devel when this was sent, but I also noticed, the incorrect pattern in patch 1:
foo = devm_ioremap_resource(...) if (!foo) return -ENOMEM;
The same pattern is in patch 2, so you may want a PATCHv2 of that one first. Also I have a few more notes:
patch 10: I think dsi pin muxing should be done by providing pinmux info via DT.
patch 11: There is a typo in the comment "can be told apart" => "can't be told apart".
patch 21: As far as I can see dss.h contains an empty #if defined(CONFIG_OMAP2_DSS_DEBUGFS) after the patch.
I didn't test yet, but I think those should not cause conflicts with the rest of the series.
I can then push the branch, which contains also the fences and cache patches, so you can base the rest on that.
Is this ok?
-- Sebastian
* Tomi Valkeinen tomi.valkeinen@ti.com [170510 00:26]:
On 09/05/17 18:05, Sebastian Reichel wrote:
patch 10: I think dsi pin muxing should be done by providing pinmux info via DT.
Unfortunately there's no pinmux driver for the kind of register we have for DSI. At least this was the case not that long ago.
What are the TRM names for the registers you need to mux?
AFAIK pinctrl-single should be capable of muxing anything in the padconf registers area. It should be only used for external pins though, not internal muxes.
Regards,
Tony
On 10/05/17 19:46, Tony Lindgren wrote:
- Tomi Valkeinen tomi.valkeinen@ti.com [170510 00:26]:
On 09/05/17 18:05, Sebastian Reichel wrote:
patch 10: I think dsi pin muxing should be done by providing pinmux info via DT.
Unfortunately there's no pinmux driver for the kind of register we have for DSI. At least this was the case not that long ago.
What are the TRM names for the registers you need to mux?
CONTROL_DSIPHY
Tomi
* Tomi Valkeinen tomi.valkeinen@ti.com [170510 10:44]:
On 10/05/17 19:46, Tony Lindgren wrote:
- Tomi Valkeinen tomi.valkeinen@ti.com [170510 00:26]:
On 09/05/17 18:05, Sebastian Reichel wrote:
patch 10: I think dsi pin muxing should be done by providing pinmux info via DT.
Unfortunately there's no pinmux driver for the kind of register we have for DSI. At least this was the case not that long ago.
What are the TRM names for the registers you need to mux?
CONTROL_DSIPHY
Oh just one register with few bits? That should be doable in dts with pinctrl-single,bit-per-mux and pinctrl-single,bits.
There are examples in the kernel tree:
$ git grep -e pinctrl-single,bits -e pinctrl-single,bit-per-mux \ arch/arm/boot/dts
Regards,
Tony
On 10/05/17 21:29, Tony Lindgren wrote:
- Tomi Valkeinen tomi.valkeinen@ti.com [170510 10:44]:
On 10/05/17 19:46, Tony Lindgren wrote:
- Tomi Valkeinen tomi.valkeinen@ti.com [170510 00:26]:
On 09/05/17 18:05, Sebastian Reichel wrote:
patch 10: I think dsi pin muxing should be done by providing pinmux info via DT.
Unfortunately there's no pinmux driver for the kind of register we have for DSI. At least this was the case not that long ago.
What are the TRM names for the registers you need to mux?
CONTROL_DSIPHY
Oh just one register with few bits? That should be doable in dts with pinctrl-single,bit-per-mux and pinctrl-single,bits.
No, I don't think it works. Or at least I can't figure out how.
pinctrl-single doesn't allow to freely set the bits, but requires the pins to have similar bit structure (function-mask). In CONTROL_DSIPHY, DSI1 and DSI2 have different bit structures.
I don't understand why pinctrl-single tries so hard to fit things into one mold...
tomi
* Tomi Valkeinen tomi.valkeinen@ti.com [170511 01:37]:
On 10/05/17 21:29, Tony Lindgren wrote:
- Tomi Valkeinen tomi.valkeinen@ti.com [170510 10:44]:
On 10/05/17 19:46, Tony Lindgren wrote:
- Tomi Valkeinen tomi.valkeinen@ti.com [170510 00:26]:
On 09/05/17 18:05, Sebastian Reichel wrote:
patch 10: I think dsi pin muxing should be done by providing pinmux info via DT.
Unfortunately there's no pinmux driver for the kind of register we have for DSI. At least this was the case not that long ago.
What are the TRM names for the registers you need to mux?
CONTROL_DSIPHY
Oh just one register with few bits? That should be doable in dts with pinctrl-single,bit-per-mux and pinctrl-single,bits.
No, I don't think it works. Or at least I can't figure out how.
pinctrl-single doesn't allow to freely set the bits, but requires the pins to have similar bit structure (function-mask). In CONTROL_DSIPHY, DSI1 and DSI2 have different bit structures.
OK if the register mixes different types of controllers that can't be partitioned into separate 8 or 16 bit instances then you're out of luck with pinctrl-single. If it does not fit, no point trying to force it, then you need a custom pinctrl driver.
I don't understand why pinctrl-single tries so hard to fit things into one mold...
Basically on many SoCs pinctrl is just the same exact control register repeated for each pin on the SoC:
$ git grep '"pinctrl-single"' arch/arm*/boot/dts | sort | uniq | wc -l 20
Regards,
Tony
On 11/05/17 17:16, Tony Lindgren wrote:
pinctrl-single doesn't allow to freely set the bits, but requires the pins to have similar bit structure (function-mask). In CONTROL_DSIPHY, DSI1 and DSI2 have different bit structures.
OK if the register mixes different types of controllers that can't be partitioned into separate 8 or 16 bit instances then you're out of luck with pinctrl-single. If it does not fit, no point trying to force it, then you need a custom pinctrl driver.
Writing a driver for a single register on a legacy SoC feels like an overkill... But I guess a generic pinctrl driver which allows free writes to registers would do the trick, but, then again, if so far we have a single register in a single SoC that needs this, maybe it's not worth the effort.
I don't understand why pinctrl-single tries so hard to fit things into one mold...
Basically on many SoCs pinctrl is just the same exact control register repeated for each pin on the SoC:
Right, I was just wondering why it forces one to have a function mask, versus allowing it to be left out and thus making it possible to handle also cases where the pins require different kinds of bit masks.
Tomi
* Tomi Valkeinen tomi.valkeinen@ti.com [170512 00:32]:
On 11/05/17 17:16, Tony Lindgren wrote:
pinctrl-single doesn't allow to freely set the bits, but requires the pins to have similar bit structure (function-mask). In CONTROL_DSIPHY, DSI1 and DSI2 have different bit structures.
OK if the register mixes different types of controllers that can't be partitioned into separate 8 or 16 bit instances then you're out of luck with pinctrl-single. If it does not fit, no point trying to force it, then you need a custom pinctrl driver.
Writing a driver for a single register on a legacy SoC feels like an overkill... But I guess a generic pinctrl driver which allows free writes to registers would do the trick, but, then again, if so far we have a single register in a single SoC that needs this, maybe it's not worth the effort.
Yeah..
I don't understand why pinctrl-single tries so hard to fit things into one mold...
Basically on many SoCs pinctrl is just the same exact control register repeated for each pin on the SoC:
Right, I was just wondering why it forces one to have a function mask, versus allowing it to be left out and thus making it possible to handle also cases where the pins require different kinds of bit masks.
Some of the bits are not usable typically. I think what you're describing could probably be done with a custom compatible plus struct pcs_soc_data.
Regards,
Tony
Hi Tomi,
On Tuesday 09 May 2017 15:10:40 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Hello,
This patch series is a second, extended version of the code previously posted as "[PATCH/RFC 0/7] Remove the omapdrm device from platform code".
As this is a long series, I'd like to pick a bunch of patches from this series already:
1-5, 7, 19, 21.
I didn't test yet, but I think those should not cause conflicts with the rest of the series.
I can then push the branch, which contains also the fences and cache patches, so you can base the rest on that.
Is this ok?
Patch 21 will conflict, the other ones shouldn't. For your convenience I've picked all the Reviewed-by tags, fixed a typo in patch 01/28 that broke compilation, rebased the patches with 1-5, 7 and 19 moved to the beginning of the series, tested the result and pushed it to
git://linuxtv.org/pinchartl/media.git omapdrm/platform
You can just pick the 7 first patches from there.
On 10/05/17 01:18, Laurent Pinchart wrote:
Hi Tomi,
On Tuesday 09 May 2017 15:10:40 Tomi Valkeinen wrote:
On 08/05/17 14:32, Laurent Pinchart wrote:
Hello,
This patch series is a second, extended version of the code previously posted as "[PATCH/RFC 0/7] Remove the omapdrm device from platform code".
As this is a long series, I'd like to pick a bunch of patches from this series already:
1-5, 7, 19, 21.
I didn't test yet, but I think those should not cause conflicts with the rest of the series.
I can then push the branch, which contains also the fences and cache patches, so you can base the rest on that.
Is this ok?
Patch 21 will conflict, the other ones shouldn't. For your convenience I've picked all the Reviewed-by tags, fixed a typo in patch 01/28 that broke compilation, rebased the patches with 1-5, 7 and 19 moved to the beginning of the series, tested the result and pushed it to
git://linuxtv.org/pinchartl/media.git omapdrm/platform
You can just pick the 7 first patches from there.
Thanks, I picked those. A few minor conflicts with my branch, but I fixed them.
Tomi
dri-devel@lists.freedesktop.org