drm/pl111: Initial drm/kms driver for pl111
Subsystems (5)
PATCH v5 1/1 drm/pl111: Initial drm/kms driver for pl111
From: Tom Cooksey <[email protected]>
This is a modesetting driver for the pl111 CLCD display controller found on various ARM platforms such as the Versatile Express. The driver has only been tested on the bcm911360_entphn platform so far, with PRIME-based buffer sharing between vc4 and clcd.
It reuses the existing devicetree binding, while not using quite as many of its properties as the fbdev driver does (those are left for future work).
v2: Nearly complete rewrite by anholt, cutting 2/3 of the code thanks
to DRM core's excellent new helpers.
v3: Don't match pl110 any more, don't attach if we don't have a DRM
panel, use DRM_GEM_CMA_FOPS, update MAINTAINERS, use the simple display helper, use drm_gem_cma_dumb_create (same as our wrapper).
v4: Change the driver's .name to not clash with fbdev in sysfs, drop
platform alias, drop redundant "drm" in DRM driver name, hook up .prepare_fb to the CMA helper so that DMA fences should work.
v5: Move register definitions inside the driver directory, fix build
in COMPILE_TEST and !AMBA mode.
--- Documentation/gpu/index.rst | 1 + Documentation/gpu/pl111.rst | 6 + MAINTAINERS | 6 + drivers/gpu/drm/Kconfig | 2 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/pl111/Kconfig | 12 ++ drivers/gpu/drm/pl111/Makefile | 5 + drivers/gpu/drm/pl111/pl111_connector.c | 127 ++++++++++++ drivers/gpu/drm/pl111/pl111_display.c | 345 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/pl111/pl111_drm.h | 56 ++++++ drivers/gpu/drm/pl111/pl111_drv.c | 272 +++++++++++++++++++++++++ drivers/gpu/drm/pl111/pl111_regs.h | 76 +++++++ 12 files changed, 909 insertions(+) create mode 100644 Documentation/gpu/pl111.rst create mode 100644 drivers/gpu/drm/pl111/Kconfig create mode 100644 drivers/gpu/drm/pl111/Makefile create mode 100644 drivers/gpu/drm/pl111/pl111_connector.c create mode 100644 drivers/gpu/drm/pl111/pl111_display.c create mode 100644 drivers/gpu/drm/pl111/pl111_drm.h create mode 100644 drivers/gpu/drm/pl111/pl111_drv.c create mode 100644 drivers/gpu/drm/pl111/pl111_regs.h
Documentation/gpu/index.rst +1 -0
@@ -11,6 +11,7 @@ Linux GPU Driver Developer's Guide drm-kms-helpers drm-uapi i915 + pl111 tinydrm vc4 vga-switcheroo
Documentation/gpu/pl111.rst new file +6 -0
@@ -0,0 +1,6 @@ +========================================== + drm/pl111 ARM PrimeCell PL111 CLCD Driver +========================================== + +.. kernel-doc:: drivers/gpu/drm/pl111/pl111_drv.c + :doc: ARM PrimeCell PL111 CLCD Driver
MAINTAINERS +6 -0
@@ -4160,6 +4160,12 @@ F: drivers/gpu/drm/* F: include/drm/drm* F: include/uapi/drm/drm* +DRM DRIVER FOR ARM PL111 CLCD +M: Eric Anholt <[email protected]> +T: git git://anongit.freedesktop.org/drm/drm-misc +S: Supported +F: drivers/gpu/drm/pl111/ + DRM DRIVER FOR AST SERVER GRAPHICS CHIPS M: Dave Airlie <[email protected]> S: Odd Fixes
drivers/gpu/drm/Kconfig +2 -0
@@ -274,6 +274,8 @@ source "drivers/gpu/drm/meson/Kconfig" source "drivers/gpu/drm/tinydrm/Kconfig" +source "drivers/gpu/drm/pl111/Kconfig" + # Keep legacy drivers last menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
@@ -96,3 +96,4 @@ obj-y += hisilicon/ obj-$(CONFIG_DRM_ZTE) += zte/ obj-$(CONFIG_DRM_MXSFB) += mxsfb/ obj-$(CONFIG_DRM_TINYDRM) += tinydrm/ +obj-$(CONFIG_DRM_PL111) += pl111/
drivers/gpu/drm/pl111/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +config DRM_PL111 + tristate "DRM Support for PL111 CLCD Controller" + depends on DRM + depends on ARM || ARM64 || COMPILE_TEST + select DRM_KMS_HELPER + select DRM_KMS_CMA_HELPER + select DRM_GEM_CMA_HELPER + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE + help + Choose this option for DRM support for the PL111 CLCD controller. + If M is selected the module will be called pl111_drm. +
drivers/gpu/drm/pl111/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +pl111_drm-y += pl111_connector.o \ + pl111_display.o \ + pl111_drv.o + +obj-$(CONFIG_DRM_PL111) += pl111_drm.o
drivers/gpu/drm/pl111/pl111_connector.c new file +127 -0
127 lines not on this page · raw message
drivers/gpu/drm/pl111/pl111_display.c new file +345 -0
345 lines not on this page · raw message
drivers/gpu/drm/pl111/pl111_drm.h new file +56 -0
56 lines not on this page · raw message
drivers/gpu/drm/pl111/pl111_drv.c new file +272 -0
272 lines not on this page · raw message
drivers/gpu/drm/pl111/pl111_regs.h new file +76 -0
76 lines not on this page · raw message
Signature · 6 lines
2.11.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 1 line · Eric Anholt
From: Tom Cooksey <[email protected]>
Well that can be debated at this point. I think it should have your Author: tag and just Tom in the Signed-off-by, then mention the history in the commit message.
Quoted 20 lines
This is a modesetting driver for the pl111 CLCD display controller found on various ARM platforms such as the Versatile Express. The driver has only been tested on the
bcm911360_entphnplatform so far, with PRIME-based buffer sharing between vc4 and clcd.It reuses the existing devicetree binding, while not using quite as many of its properties as the fbdev driver does (those are left for future work).
v2: Nearly complete rewrite by anholt, cutting 2/3 of the code thanks
to DRM core's excellent new helpers.
v3: Don't match pl110 any more, don't attach if we don't have a DRM
panel, useDRM_GEM_CMA_FOPS, updateMAINTAINERS, use the simple display helper, usedrm_gem_cma_dumb_create(same as our wrapper).
v4: Change the driver's .name to not clash with fbdev in sysfs, drop
platform alias, drop redundant "drm" in DRM driver name, hook up .prepare_fb to the CMA helper so that DMA fences should work.
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.
Quoted 2 lines
Signed-off-by Tom Cooksey <[email protected]>Signed-off-by Eric Anholt <[email protected]>
This is as good starting point as any. We need to get moving with this. Some minor things below that can just as well be fixed later.
Quoted 1 line
create mode 100644 drivers/gpu/drm/pl111/Kconfig
Maybe someone would want to place this under drivers/gpu/drm/arm since it is obviously an ARM block. But since ARM has pretty much dropped the ball on this IP it is probably best to keep it separate like this.
drivers/gpu/drm/pl111/Kconfig line 11
Quoted 13 lines
+++ b/drivers/gpu/drm/pl111/Kconfig
drivers/gpu/drm/pl111/Kconfig new file +11
-0@@ -0,0 +1,12 @@ +config DRM_PL111 + tristate "DRM Support for PL111 CLCD Controller" + depends on DRM + depends on ARM || ARM64 || COMPILE_TEST + select DRM_KMS_HELPER + select DRM_KMS_CMA_HELPER + select DRM_GEM_CMA_HELPER + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE + help + Choose this option for DRM support for the PL111 CLCD controller. + If M is selected the module will be called pl111_drm.
I must say the driver is *really* slim and readable with all the new helpers from DRM, good job all who refactored the DRM support for simple framebuffer systems.
drivers/gpu/drm/pl111/pl111_connector.c line 106
Quoted 2 lines
drivers/gpu/drm/pl111/pl111_connector.c new file +2
-0+ panel =of_drm_find_panel (panel_node); +of_node_put (panel_node);
Was meaning to ask whether the panel bindings used by the fbdev drivers are 100% compatible with what DRM is using and from your code it seems like yes, they are?
Quoted 12 lines
drivers/gpu/drm/pl111/pl111_display.c new file +12
-0+irqreturn_t pl111_irq (int irq,void *data) +{ +struct pl111_drm_dev_private *priv = data; +u32 irq_stat; +irqreturn_t status =IRQ_NONE ; + + irq_stat =readl (priv->regs +CLCD_PL111_MIS ); + +if (!irq_stat) +return IRQ_NONE ; + +if (irq_stat &CLCD_IRQ_NEXTBASE_UPDATE ) {
drivers/gpu/drm/pl111/pl111_display.c line 51
Quoted 10 lines
drivers/gpu/drm/pl111/pl111_display.c new file +10
-0+drm_crtc_handle_vblank (&priv->pipe.crtc); + + status =IRQ_HANDLED ; + } + +/* Clear the interrupt once done */ +writel (irq_stat, priv->regs +CLCD_PL111_ICR ); + +return status; +}
And this is the first time in history that the vblank interrupt on PL11x is actually used for something, which in itself is a good reason to migrate to this driver.
Yours,
Linus Walleij
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · Linus Walleij
Quoted 9 lines
+++ b/drivers/gpu/drm/pl111/Kconfig
drivers/gpu/drm/pl111/Kconfig new file +7
-0@@ -0,0 +1,12 @@ +config DRM_PL111 + tristate "DRM Support for PL111 CLCD Controller" + depends on DRM + depends on ARM || ARM64 || COMPILE_TEST + select DRM_KMS_HELPER + select DRM_KMS_CMA_HELPER + select DRM_GEM_CMA_HELPER
Quoted 8 lines
drivers/gpu/drm/pl111/Kconfig line 11
Quoted 4 lines
drivers/gpu/drm/pl111/Kconfig new file +4
-0+ select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE + help + Choose this option for DRM support for the PL111 CLCD controller. + If M is selected the module will be called pl111_drm.I must say the driver is *really* slim and readable with all the new helpers from DRM, good job all who refactored the DRM support for simple framebuffer systems.
Mission accomplished, thanks a lot for the kudos. Also adding Noralf, so he knows people really value his work (he's done the simple pipe helpers used by pl111 here).
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 2 lines · Eric Anholt
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.
Why is it necessary to move the register definitions there, when they're already available in linux/amba/clcd.h and are required for the FB driver?
It is absurd to have driver specific register definitions.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 9 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Anholt
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.Why is it necessary to move the register definitions there, when they're already available in
linux/amba/clcd.hand are required for the FB driver?It is absurd to have driver specific register definitions.
Because after v2, v3, and v4, I still didn't have an ack on the patch to move the register definitions from linux/amba/clcd.h to linux/amba/clcd-reg.h. If you'd like to go back and ack that, I'd reuse them.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Linus Walleij
Quoted 1 line · Eric Anholt
From: Tom Cooksey <[email protected]>
Well that can be debated at this point. I think it should have your Author: tag and just Tom in the Signed-off-by, then mention the history in the commit message.
I'm happy giving credit to the original author, unless he wants to duck responsibility at this point. I probably wouldn't have done this work if I didn't have his to start from.
Quoted 20 lines
Quoted 20 lines
This is a modesetting driver for the pl111 CLCD display controller found on various ARM platforms such as the Versatile Express. The driver has only been tested on the
bcm911360_entphnplatform so far, with PRIME-based buffer sharing between vc4 and clcd.It reuses the existing devicetree binding, while not using quite as many of its properties as the fbdev driver does (those are left for future work).
v2: Nearly complete rewrite by anholt, cutting 2/3 of the code thanks
to DRM core's excellent new helpers.
v3: Don't match pl110 any more, don't attach if we don't have a DRM
panel, useDRM_GEM_CMA_FOPS, updateMAINTAINERS, use the simple display helper, usedrm_gem_cma_dumb_create(same as our wrapper).
v4: Change the driver's .name to not clash with fbdev in sysfs, drop
platform alias, drop redundant "drm" in DRM driver name, hook up .prepare_fb to the CMA helper so that DMA fences should work.
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Tom Cooksey <[email protected]>Signed-off-by Eric Anholt <[email protected]>Reviewed-by Linus Walleij <[email protected]>This is as good starting point as any. We need to get moving with this. Some minor things below that can just as well be fixed later.
Thanks!
Quoted 25 lines
Quoted 1 line
create mode 100644 drivers/gpu/drm/pl111/KconfigMaybe someone would want to place this under
drivers/gpu/drm/armsince it is obviously an ARM block. But since ARM has pretty much dropped the ball on this IP it is probably best to keep it separate like this.drivers/gpu/drm/pl111/Kconfig line 11
Quoted 13 lines
+++ b/drivers/gpu/drm/pl111/Kconfig
drivers/gpu/drm/pl111/Kconfig new file +11
-0@@ -0,0 +1,12 @@ +config DRM_PL111 + tristate "DRM Support for PL111 CLCD Controller" + depends on DRM + depends on ARM || ARM64 || COMPILE_TEST + select DRM_KMS_HELPER + select DRM_KMS_CMA_HELPER + select DRM_GEM_CMA_HELPER + select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE + help + Choose this option for DRM support for the PL111 CLCD controller. + If M is selected the module will be called pl111_drm.I must say the driver is *really* slim and readable with all the new helpers from DRM, good job all who refactored the DRM support for simple framebuffer systems.
Quoted 6 lines
drivers/gpu/drm/pl111/pl111_connector.c line 106
Quoted 2 lines
drivers/gpu/drm/pl111/pl111_connector.c new file +2
-0+ panel =of_drm_find_panel (panel_node); +of_node_put (panel_node);Was meaning to ask whether the panel bindings used by the fbdev drivers are 100% compatible with what DRM is using and from your code it seems like yes, they are?
Yeah, the panel bindings seem fine. We'll need to build equivalent panel drivers within DRM for anyone that wants to switch over, but that's not hard.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Eric Anholt
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Anholt
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.Why is it necessary to move the register definitions there, when they're already available in
linux/amba/clcd.hand are required for the FB driver?
Quoted 6 lines
Quoted 1 line
It is absurd to have driver specific register definitions.
Because after v2, v3, and v4, I still didn't have an ack on the patch to move the register definitions from
linux/amba/clcd.htolinux/amba/clcd-reg.h. If you'd like to go back and ack that, I'd reuse them.
I don't remember seeing such a patch, sorry.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 11 lines · Russell King - ARM Linux
Quoted 10 lines · Eric Anholt
Quoted 8 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Anholt
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.Why is it necessary to move the register definitions there, when they're already available in
linux/amba/clcd.hand are required for the FB driver?
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
It is absurd to have driver specific register definitions.
Because after v2, v3, and v4, I still didn't have an ack on the patch to move the register definitions from
linux/amba/clcd.htolinux/amba/clcd-reg.h. If you'd like to go back and ack that, I'd reuse them.I don't remember seeing such a patch, sorry.
https://patchwork.kernel.org/patch/9654991/
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 28 lines · Linus Walleij
Quoted 1 line · Eric Anholt
From: Tom Cooksey <[email protected]>
Well that can be debated at this point. I think it should have your Author: tag and just Tom in the Signed-off-by, then mention the history in the commit message.
Quoted 20 lines
This is a modesetting driver for the pl111 CLCD display controller found on various ARM platforms such as the Versatile Express. The driver has only been tested on the
bcm911360_entphnplatform so far, with PRIME-based buffer sharing between vc4 and clcd.It reuses the existing devicetree binding, while not using quite as many of its properties as the fbdev driver does (those are left for future work).
v2: Nearly complete rewrite by anholt, cutting 2/3 of the code thanks
to DRM core's excellent new helpers.
v3: Don't match pl110 any more, don't attach if we don't have a DRM
panel, useDRM_GEM_CMA_FOPS, updateMAINTAINERS, use the simple display helper, usedrm_gem_cma_dumb_create(same as our wrapper).
v4: Change the driver's .name to not clash with fbdev in sysfs, drop
platform alias, drop redundant "drm" in DRM driver name, hook up .prepare_fb to the CMA helper so that DMA fences should work.
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Tom Cooksey <[email protected]>Signed-off-by Eric Anholt <[email protected]>Reviewed-by Linus Walleij <[email protected]>This is as good starting point as any. We need to get moving with this. Some minor things below that can just as well be fixed later.
Oh, one last thing I think we need to figure out: I'm using TIM2_CLKSEL, which seems to be necessary on this platform. My understanding is that this means that the pixel clock is divided from clcdclk instead of apb_pclk. Do you agree? The fbdev driver is using clk_get(&fb->dev->dev, NULL) and not TIM2_CLKSEL, which I'm surprised by because I would have thought that would give us the first clock from the DT node (also clcdclk).
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Eric Anholt
Oh, one last thing I think we need to figure out: I'm using
TIM2_CLKSEL, which seems to be necessary on this platform. My understanding is that this means that the pixel clock is divided from clcdclk instead ofapb_pclk. Do you agree?
Yes the pixed clock is always derived from clcdclk.
In most older ARM reference designs this is a VCO so that is why there is a clk_set_rate() on this in the fbdev code. (On some platforms that even has no effect I guess.)
Quoted 4 lines
The fbdev driver is using
clk_get(&fb->dev->dev, NULL)and notTIM2_CLKSEL, which I'm surprised by because I would have thought that would give us the first clock from the DT node (also clcdclk).
So that thing is a 1-bit line that can select one of two clocks to be muxed into the PL111/CLCD.
I guess that up until now all platforms just left that line dangling in the silicon. Congratulations, you came here first ;)
Though when I look at the Nomadik it seems that it might be muxing the clock between 48 and 72 MHz, and I've been using 48MHz all along ooopsie.
The current assumption in the bindings is that we have only one clock and TIM2_CLKSEL is N/A.
If we want proper clcdclk handling with CLKSEL you should probably add some code to implement a real mux clock for this using <linux/clock-provider.h> and drivers/clk/clk-mux.c with select COMMON_CLK
so that the driver still only sees clcdclk but that in turn is a mux that can select one of two sources and will react to the clk_set_rate() call by selecting the clock which is closest in frequency to what you want.
This needs a small patch to alter the bindings too I guess. A small clock node inside the CLCD, just like PCI bridges have irqchips inside them etc:
clcd@10120000 {
compatible = "arm,pl110", "arm,primecell";
reg = <0x10120000 0x1000>;
(...)
clocks = <&clcdclk>, <&foo>;
clock-names = "clcdclk", "apb_pclk";
clcdclk: clock-controller@0 {
compatible = "arm,pl11x-clock-mux";
clocks = <&source_a>, <&source_b>;
};
};This can be set up easily in the OF probe path since that is what we're doing: just look for this subnode, if it is there create the clock controller.
I do not think the clk maintainers would mind a small mux clock controller inside the CLCD driver to handle this mux if we need it.
It would *maybe* also be possible to add a second "clcdclk2" to the block and make an educated decision on which clock to use in the driver but that is not as elegant as using the clock framework mux clock I think.
Yours,
Linus Walleij
Quoted 57 lines · Linus Walleij
Quoted 4 lines · Eric Anholt
Oh, one last thing I think we need to figure out: I'm using
TIM2_CLKSEL, which seems to be necessary on this platform. My understanding is that this means that the pixel clock is divided from clcdclk instead ofapb_pclk. Do you agree?Yes the pixed clock is always derived from clcdclk.
In most older ARM reference designs this is a VCO so that is why there is a
clk_set_rate()on this in the fbdev code. (On some platforms that even has no effect I guess.)Quoted 4 lines
The fbdev driver is using
clk_get(&fb->dev->dev, NULL)and notTIM2_CLKSEL, which I'm surprised by because I would have thought that would give us the first clock from the DT node (also clcdclk).So that thing is a 1-bit line that can select one of two clocks to be muxed into the PL111/CLCD.
I guess that up until now all platforms just left that line dangling in the silicon. Congratulations, you came here first ;)
Though when I look at the Nomadik it seems that it might be muxing the clock between 48 and 72 MHz, and I've been using 48MHz all along ooopsie.
The current assumption in the bindings is that we have only one clock and
TIM2_CLKSELis N/A.If we want proper clcdclk handling with CLKSEL you should probably add some code to implement a real mux clock for this using <
linux/clock-provider.h> anddrivers/clk/clk-mux.cwith selectCOMMON_CLK
so that the driver still only sees clcdclk but that in turn is a mux that can select one of two sources and will react to theclk_set_rate()call by selecting the clock which is closest in frequency to what you want.This needs a small patch to alter the bindings too I guess. A small clock node inside the CLCD, just like PCI bridges have irqchips inside them etc:
clcd@10120000 { compatible = "arm,pl110", "arm,primecell"; reg = <0x10120000 0x1000>; (...) clocks = <&clcdclk>, <&foo>; clock-names = "clcdclk", "apb_pclk"; clcdclk: clock-controller@0 { compatible = "arm,pl11x-clock-mux"; clocks = <&source_a>, <&source_b>; }; };
Quoted 7 lines
This can be set up easily in the OF probe path since that is what we're doing: just look for this subnode, if it is there create the clock controller.
I do not think the clk maintainers would mind a small mux clock controller inside the CLCD driver to handle this mux if we need it.
Hi Linus,
Indeed it's the way of handling this use case, but no need to add a clk node here, you can copy what we did in pwm-meson, meson-gx-mmc.c, or dwmac-meson8b.c (we went further by also adding clk dividers).
In the probe code, simply add a clock mux provider with the two parents clock names (these can and should be platform specific) and only call a clk_set_parent() with the clock specified in the node clocks cell.
Quoted 8 lines
It would *maybe* also be possible to add a second "clcdclk2" to the block and make an educated decision on which clock to use in the driver but that is not as elegant as using the clock framework mux clock I think.
Yours,
Linus Walleij
Neil
Quoted 68 lines · Neil Armstrong
Quoted 57 lines · Linus Walleij
Quoted 4 lines · Eric Anholt
Oh, one last thing I think we need to figure out: I'm using
TIM2_CLKSEL, which seems to be necessary on this platform. My understanding is that this means that the pixel clock is divided from clcdclk instead ofapb_pclk. Do you agree?Yes the pixed clock is always derived from clcdclk.
In most older ARM reference designs this is a VCO so that is why there is a
clk_set_rate()on this in the fbdev code. (On some platforms that even has no effect I guess.)Quoted 4 lines
The fbdev driver is using
clk_get(&fb->dev->dev, NULL)and notTIM2_CLKSEL, which I'm surprised by because I would have thought that would give us the first clock from the DT node (also clcdclk).So that thing is a 1-bit line that can select one of two clocks to be muxed into the PL111/CLCD.
I guess that up until now all platforms just left that line dangling in the silicon. Congratulations, you came here first ;)
Though when I look at the Nomadik it seems that it might be muxing the clock between 48 and 72 MHz, and I've been using 48MHz all along ooopsie.
The current assumption in the bindings is that we have only one clock and
TIM2_CLKSELis N/A.If we want proper clcdclk handling with CLKSEL you should probably add some code to implement a real mux clock for this using <
linux/clock-provider.h> anddrivers/clk/clk-mux.cwith selectCOMMON_CLK
so that the driver still only sees clcdclk but that in turn is a mux that can select one of two sources and will react to theclk_set_rate()call by selecting the clock which is closest in frequency to what you want.This needs a small patch to alter the bindings too I guess. A small clock node inside the CLCD, just like PCI bridges have irqchips inside them etc:
clcd@10120000 { compatible = "arm,pl110", "arm,primecell"; reg = <0x10120000 0x1000>; (...) clocks = <&clcdclk>, <&foo>; clock-names = "clcdclk", "apb_pclk"; clcdclk: clock-controller@0 { compatible = "arm,pl11x-clock-mux"; clocks = <&source_a>, <&source_b>; }; };Quoted 7 lines
This can be set up easily in the OF probe path since that is what we're doing: just look for this subnode, if it is there create the clock controller.
I do not think the clk maintainers would mind a small mux clock controller inside the CLCD driver to handle this mux if we need it.
Hi Linus,
Quoted 8 lines
Indeed it's the way of handling this use case, but no need to add a clk node here, you can copy what we did in pwm-meson,
meson-gx-mmc.c, ordwmac-meson8b.c(we went further by also adding clk dividers).In the probe code, simply add a clock mux provider with the two parents clock names (these can and should be platform specific) and only call a
clk_set_parent()with the clock specified in the node clocks cell.
+1
Avoiding a binding update is nice.
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 15 lines · Eric Anholt
Quoted 13 lines · Russell King - ARM Linux
Quoted 12 lines · Eric Anholt
Quoted 9 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Anholt
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.Why is it necessary to move the register definitions there, when they're already available in
linux/amba/clcd.hand are required for the FB driver?It is absurd to have driver specific register definitions.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Because after v2, v3, and v4, I still didn't have an ack on the patch to move the register definitions from
linux/amba/clcd.htolinux/amba/clcd-reg.h. If you'd like to go back and ack that, I'd reuse them.I don't remember seeing such a patch, sorry.
Looks fine, apart from the missing #ifndef...#endif guard around the header file.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 60 lines · Linus Walleij
Quoted 4 lines · Eric Anholt
Oh, one last thing I think we need to figure out: I'm using
TIM2_CLKSEL, which seems to be necessary on this platform. My understanding is that this means that the pixel clock is divided from clcdclk instead ofapb_pclk. Do you agree?Yes the pixed clock is always derived from clcdclk.
In most older ARM reference designs this is a VCO so that is why there is a
clk_set_rate()on this in the fbdev code. (On some platforms that even has no effect I guess.)Quoted 4 lines
The fbdev driver is using
clk_get(&fb->dev->dev, NULL)and notTIM2_CLKSEL, which I'm surprised by because I would have thought that would give us the first clock from the DT node (also clcdclk).So that thing is a 1-bit line that can select one of two clocks to be muxed into the PL111/CLCD.
I guess that up until now all platforms just left that line dangling in the silicon. Congratulations, you came here first ;)
Though when I look at the Nomadik it seems that it might be muxing the clock between 48 and 72 MHz, and I've been using 48MHz all along ooopsie.
The current assumption in the bindings is that we have only one clock and
TIM2_CLKSELis N/A.If we want proper clcdclk handling with CLKSEL you should probably add some code to implement a real mux clock for this using <
linux/clock-provider.h> anddrivers/clk/clk-mux.cwith selectCOMMON_CLK
so that the driver still only sees clcdclk but that in turn is a mux that can select one of two sources and will react to theclk_set_rate()call by selecting the clock which is closest in frequency to what you want.This needs a small patch to alter the bindings too I guess. A small clock node inside the CLCD, just like PCI bridges have irqchips inside them etc:
clcd@10120000 { compatible = "arm,pl110", "arm,primecell"; reg = <0x10120000 0x1000>; (...) clocks = <&clcdclk>, <&foo>; clock-names = "clcdclk", "apb_pclk"; clcdclk: clock-controller@0 { compatible = "arm,pl11x-clock-mux"; clocks = <&source_a>, <&source_b>; }; };This can be set up easily in the OF probe path since that is what we're doing: just look for this subnode, if it is there create the clock controller.
Quoted 8 lines
I do not think the clk maintainers would mind a small mux clock controller inside the CLCD driver to handle this mux if we need it.
It would *maybe* also be possible to add a second "clcdclk2" to the block and make an educated decision on which clock to use in the driver but that is not as elegant as using the clock framework mux clock I think.
We've had drivers (like imx-drm) embedding clk stuff within itself in a similar manner to what you're suggesting, and it ended up being a problem when it came to working out which is the correct clock to use. That stuff got ripped out of imx-drm and replaced with a saner solution (that doesn't use CCF) before imx-drm moved out of staging. The reason for this was to get a saner solution to "I want a clock running at X MHz, which clock gives me the closest to the requested rate" without using the problematical fractional divider^w^wfrequency modulator that severely upsets HDMI.
What I think you need to ask here is not how you should be modelling it in DT, but how you're going to control it in the driver. Under what circumstance will you select one CLKSEL state or the other?
There's also consideration of the effect CLKSEL has - it's effectively a GPIO output from the module that is available for the system integrator to do whatever they choose with. It just happens to have the name "CLKSEL" - but it doesn't have to select a clock.
So, I don't think it's clear cut whether it should be exposed as a GPIO and the GPIO based clk-mux used with it, or whether we should update the binding to allow a second clock to be specified, giving the driver the ability to make its own choice about which clock should be selected.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Quoted 21 lines · Russell King - ARM Linux
Quoted 20 lines · Eric Anholt
Quoted 18 lines · Russell King - ARM Linux
Quoted 16 lines · Eric Anholt
Quoted 9 lines · Russell King - ARM Linux
Quoted 2 lines · Eric Anholt
v5: Move register definitions inside the driver directory, fix build
inCOMPILE_TESTand !AMBA mode.Why is it necessary to move the register definitions there, when they're already available in
linux/amba/clcd.hand are required for the FB driver?It is absurd to have driver specific register definitions.
Because after v2, v3, and v4, I still didn't have an ack on the patch to move the register definitions from
linux/amba/clcd.htolinux/amba/clcd-reg.h. If you'd like to go back and ack that, I'd reuse them.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
I don't remember seeing such a patch, sorry.
Looks fine, apart from the missing #ifndef...#endif guard around the header file.
Are you good with the current version with the ifdef guards? I'd like to merge it through drm-misc.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel