Skip to contentSkip to conversation

drm/pl111: Register the clock divider and use it.

PATCH In review Eric Anholt 3 participants 6 messages May 8, 2017 – May 19, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/pl111: Register the clock divider and use it.

This is required for the panel to work on bcm911360, where CLCDCLK is the fixed 200Mhz AXI41 clock. The rate set is still passed up to the CLCDCLK, for platforms that have a settable rate on that one.

v2: Set SET_RATE_PARENT (caught by Linus Walleij), depend on
COMMON_CLK.

---
 drivers/gpu/drm/pl111/Kconfig         |   1 +
 drivers/gpu/drm/pl111/pl111_display.c | 162 ++++++++++++++++++++++++++++++----
 drivers/gpu/drm/pl111/pl111_drm.h     |   8 ++
 drivers/gpu/drm/pl111/pl111_drv.c     |  11 +--
 include/linux/amba/clcd-regs.h        |   5 ++
 5 files changed, 163 insertions(+), 24 deletions(-)
drivers/gpu/drm/pl111/Kconfig +1 -0
index ede49efd531f..309f4fd52de7 100644
@@ -2,6 +2,7 @@ config DRM_PL111
 	tristate "DRM Support for PL111 CLCD Controller"
 	depends on DRM
 	depends on ARM || ARM64 || COMPILE_TEST
+	depends on COMMON_CLK
 	select DRM_KMS_HELPER
 	select DRM_KMS_CMA_HELPER
 	select DRM_GEM_CMA_HELPER
drivers/gpu/drm/pl111/pl111_display.c +147 -15

186 lines not on this page · raw message

drivers/gpu/drm/pl111/pl111_drm.h +8 -0
index f381593921b7..4162c6aa5dbb 100644
@@ -21,6 +21,7 @@
 
 #include <drm/drm_gem.h>
 #include <drm/drm_simple_kms_helper.h>
+#include <linux/clk-provider.h>
 
 #define CLCD_IRQ_NEXTBASE_UPDATE BIT(2)
 
@@ -37,7 +38,14 @@ struct pl111_drm_dev_private {
 	struct drm_fbdev_cma *fbdev;
 
 	void *regs;
+	/* The pixel clock (a reference to our clock divider off of CLCDCLK). */
 	struct clk *clk;
+	/* pl111's internal clock divider. */
+	struct clk_hw clk_div;
+	/* Lock to sync access to CLCD_TIM2 between the common clock
+	 * subsystem and pl111_display_enable().
+	 */
+	spinlock_t tim2_lock;
 };
 
 #define to_pl111_connector(x) \
drivers/gpu/drm/pl111/pl111_drv.c +2 -9
index 936403f65508..9d1467492cb9 100644
@@ -50,8 +50,8 @@
  * - Read back hardware state at boot to skip reprogramming the
  *   hardware when doing a no-op modeset.
  *
- * - Use the internal clock divisor to reduce power consumption by
- *   using HCLK (apb_pclk) when appropriate.
+ * - Use the CLKSEL bit to support switching between the two external
+ *   clock parents.
  */
 
 #include <linux/amba/bus.h>
@@ -195,13 +195,6 @@ static int pl111_amba_probe(struct amba_device *amba_dev,
 	priv->drm = drm;
 	drm->dev_private = priv;
 
-	priv->clk = devm_clk_get(dev, "clcdclk");
-	if (IS_ERR(priv->clk)) {
-		dev_err(dev, "CLCD: unable to get clk.\n");
-		ret = PTR_ERR(priv->clk);
-		goto dev_unref;
-	}
-
 	priv->regs = devm_ioremap_resource(dev, &amba_dev->res);
 	if (!priv->regs) {
 		dev_err(dev, "%s failed mmio\n", __func__);
include/linux/amba/clcd-regs.h +5 -0
index 69c0e2143003..516a6fda83c5 100644
@@ -39,12 +39,17 @@
 #define CLCD_PALL 		0x00000200
 #define CLCD_PALETTE		0x00000200
 
+#define TIM2_PCD_LO_MASK	GENMASK(4, 0)
+#define TIM2_PCD_LO_BITS	5
 #define TIM2_CLKSEL		(1 << 5)
 #define TIM2_IVS		(1 << 11)
 #define TIM2_IHS		(1 << 12)
 #define TIM2_IPC		(1 << 13)
 #define TIM2_IOE		(1 << 14)
 #define TIM2_BCD		(1 << 26)
+#define TIM2_PCD_HI_MASK	GENMASK(31, 27)
+#define TIM2_PCD_HI_BITS	5
+#define TIM2_PCD_HI_SHIFT	27
 
 #define CNTL_LCDEN		(1 << 0)
 #define CNTL_LCDBPP1		(0 << 1)
Signature · 1 line
2.11.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Eric Anholt

This is required for the panel to work on bcm911360, where CLCDCLK is the fixed 200Mhz AXI41 clock. The rate set is still passed up to the CLCDCLK, for platforms that have a settable rate on that one.

v2: Set SET_RATE_PARENT (caught by Linus Walleij), depend on
COMMON_CLK.

Yours,
Linus Walleij

#2 lore raw
Quoted 6 lines · Linus Walleij
Quoted 4 lines · Eric Anholt

This is required for the panel to work on bcm911360, where CLCDCLK is the fixed 200Mhz AXI41 clock. The rate set is still passed up to the CLCDCLK, for platforms that have a settable rate on that one.

Quoted 6 lines
Quoted 4 lines

v2: Set SET_RATE_PARENT (caught by Linus Walleij), depend on
COMMON_CLK.

Thanks. Waiting on an ack from clock folks, then we'll be ready to go, I think.

#3 lore raw
Quoted 11 lines · Eric Anholt
Quoted 9 lines · Linus Walleij
Quoted 7 lines · Eric Anholt

This is required for the panel to work on bcm911360, where CLCDCLK is the fixed 200Mhz AXI41 clock. The rate set is still passed up to the CLCDCLK, for platforms that have a settable rate on that one.

v2: Set SET_RATE_PARENT (caught by Linus Walleij), depend on
COMMON_CLK.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Thanks. Waiting on an ack from clock folks, then we'll be ready to go, I think.

Mike/Stephen?

It would be nice to have this queued in -next quite early in the v4.13 development cycle, so I can start looking into migrating the rest of the old fbdev users to this.

BCM911360 seems like some oddity, there is not even a pictur of it online, but I guess it's a cool little gadget :)

Yours,
Linus Walleij

Reviewed-by on v2 1/1
#4 lore raw
In reply to Eric Anholt
Quoted 8 lines · Eric Anholt

This is required for the panel to work on bcm911360, where CLCDCLK is the fixed 200Mhz AXI41 clock. The rate set is still passed up to the CLCDCLK, for platforms that have a settable rate on that one.

v2: Set SET_RATE_PARENT (caught by Linus Walleij), depend on
COMMON_CLK.

One minor comment below

Quoted 5 lines
drivers/gpu/drm/pl111/pl111_display.c +0 -0
index 39a5c33bce7d..2d924a6bf43c 100644
@@ -288,6 +296,126 @@ const struct drm_simple_display_pipe_funcs pl111_display_funcs = {

[...]

drivers/gpu/drm/pl111/pl111_display.c const struct drm_simple_display_pipe_funcs pl111_display_funcs = { · line 382

Quoted 5 lines
drivers/gpu/drm/pl111/pl111_display.c +5 -0
+
+	return 0;
+}
+
+const struct clk_ops pl111_clk_div_ops = {

static?

Quoted 6 lines
drivers/gpu/drm/pl111/pl111_display.c +6 -0
+	.recalc_rate = pl111_clk_div_recalc_rate,
+	.round_rate = pl111_clk_div_round_rate,
+	.set_rate = pl111_clk_div_set_rate,
+};
+
+static int
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#5 lore raw
Quoted 20 lines · Stephen Boyd
Quoted 8 lines · Eric Anholt

This is required for the panel to work on bcm911360, where CLCDCLK is the fixed 200Mhz AXI41 clock. The rate set is still passed up to the CLCDCLK, for platforms that have a settable rate on that one.

v2: Set SET_RATE_PARENT (caught by Linus Walleij), depend on
COMMON_CLK.

One minor comment below

Quoted 5 lines
drivers/gpu/drm/pl111/pl111_display.c +0 -0
index 39a5c33bce7d..2d924a6bf43c 100644
@@ -288,6 +296,126 @@ const struct drm_simple_display_pipe_funcs pl111_display_funcs = {

[...]

Quoted 7 lines

drivers/gpu/drm/pl111/pl111_display.c const struct drm_simple_display_pipe_funcs pl111_display_funcs = { · line 382

Quoted 5 lines
drivers/gpu/drm/pl111/pl111_display.c +5 -0
+
+	return 0;
+}
+
+const struct clk_ops pl111_clk_div_ops = {

static?

Fixed, thanks.