All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Prisk <linux@prisktech.co.nz>
To: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Cc: vt8500-wm8505-linux-kernel@googlegroups.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, tomi.valkeinen@ti.com,
	linux-fbdev@vger.kernel.org, Tony Prisk <linux@prisktech.co.nz>
Subject: [PATCH 3/4] fb: vt8500: Require a device clock for wm8505fb driver
Date: Sat, 18 May 2013 21:15:13 +1200	[thread overview]
Message-ID: <1368868514-18975-4-git-send-email-linux@prisktech.co.nz> (raw)
In-Reply-To: <1368868514-18975-1-git-send-email-linux@prisktech.co.nz>

The wm8505fb driver requires a clock to work properly. Without a clock,
the driver can only initialize the display resolution that was set in
uboot.
This patch updates the driver to get and use a clock, and updates
the devicetree documentation to indicate the requirement for a clock.

Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
---
 .../devicetree/bindings/video/wm,wm8505-fb.txt     |    4 ++-
 drivers/video/wm8505fb.c                           |   30 +++++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt b/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
index 0bcadb2..601416c 100644
--- a/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
+++ b/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
@@ -5,6 +5,7 @@ Required properties:
 - compatible : "wm,wm8505-fb"
 - reg : Should contain 1 register ranges(address and length)
 - bits-per-pixel : bit depth of framebuffer (16 or 32)
+- clocks : phandle to DVO clock
 
 Required subnodes:
 - display-timings: see display-timing.txt for information
@@ -15,11 +16,12 @@ Example:
 		compatible = "wm,wm8505-fb";
 		reg = <0xd8051700 0x200>;
 		bits-per-pixel = <16>;
+		clocks = <&clkdvo>;
 
 		display-timings {
 			native-mode = <&timing0>;
 			timing0: 800x480 {
-				clock-frequency = <0>; /* unused but required */
+				clock-frequency = <30000000>;
 				hactive = <800>;
 				vactive = <480>;
 				hfront-porch = <40>;
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index 167a9e2..f8bffc2 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -14,6 +14,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/fb.h>
@@ -130,9 +131,11 @@
 #define to_wm8505fb_info(__info) container_of(__info, \
 						struct wm8505fb_info, fb)
 struct wm8505fb_info {
-	struct fb_info		fb;
-	void __iomem		*regbase;
-	unsigned int		contrast;
+	struct fb_info fb;
+	void __iomem *regbase;
+	unsigned int contrast;
+	struct device *dev;
+	struct clk *clk_dvo;
 };
 
 
@@ -210,6 +213,13 @@ static int wm8505fb_set_par(struct fb_info *info)
 	if (!fbi)
 		return -EINVAL;
 
+	if (info->var.pixclock == 0) {
+		dev_err(fbi->dev, "requested pixclock = 0\n");
+		return -EINVAL;
+	}
+
+	clk_set_rate(fbi->clk_dvo, PICOS2KHZ(info->var.pixclock)*1000);
+
 	if (info->var.bits_per_pixel == 32) {
 		info->var.red.offset = 16;
 		info->var.red.length = 8;
@@ -369,6 +379,8 @@ static int wm8505fb_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	fbi->dev = &pdev->dev;
+
 	strcpy(fbi->fb.fix.id, DRIVER_NAME);
 
 	fbi->fb.fix.type	= FB_TYPE_PACKED_PIXELS;
@@ -408,6 +420,14 @@ static int wm8505fb_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	fbi->clk_dvo = of_clk_get(pdev->dev.of_node, 0);
+	if (IS_ERR(fbi->clk_dvo)) {
+		dev_err(&pdev->dev, "Error retrieving clock\n");
+		return PTR_ERR(fbi->clk_dvo);
+	}
+
+	clk_prepare_enable(fbi->clk_dvo);
+
 	fb_videomode_to_var(&fbi->fb.var, &mode);
 
 	fbi->fb.var.nonstd		= 0;
@@ -421,7 +441,7 @@ static int wm8505fb_probe(struct platform_device *pdev)
 	fb_mem_virt = dmam_alloc_coherent(&pdev->dev, fb_mem_len, &fb_mem_phys,
 				GFP_KERNEL);
 	if (!fb_mem_virt) {
-		pr_err("%s: Failed to allocate framebuffer\n", __func__);
+		dev_err(&pdev->dev, "Failed to allocate framebuffer\n");
 		return -ENOMEM;
 	}
 
@@ -480,6 +500,8 @@ static int wm8505fb_remove(struct platform_device *pdev)
 
 	unregister_framebuffer(&fbi->fb);
 
+	clk_disable_unprepare(fbi->clk_dvo);
+
 	writel(0, fbi->regbase);
 
 	if (fbi->fb.cmap.len)
-- 
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: Tony Prisk <linux@prisktech.co.nz>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] fb: vt8500: Require a device clock for wm8505fb driver
Date: Sat, 18 May 2013 09:15:13 +0000	[thread overview]
Message-ID: <1368868514-18975-4-git-send-email-linux@prisktech.co.nz> (raw)
In-Reply-To: <1368868514-18975-1-git-send-email-linux@prisktech.co.nz>

The wm8505fb driver requires a clock to work properly. Without a clock,
the driver can only initialize the display resolution that was set in
uboot.
This patch updates the driver to get and use a clock, and updates
the devicetree documentation to indicate the requirement for a clock.

Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
---
 .../devicetree/bindings/video/wm,wm8505-fb.txt     |    4 ++-
 drivers/video/wm8505fb.c                           |   30 +++++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt b/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
index 0bcadb2..601416c 100644
--- a/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
+++ b/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
@@ -5,6 +5,7 @@ Required properties:
 - compatible : "wm,wm8505-fb"
 - reg : Should contain 1 register ranges(address and length)
 - bits-per-pixel : bit depth of framebuffer (16 or 32)
+- clocks : phandle to DVO clock
 
 Required subnodes:
 - display-timings: see display-timing.txt for information
@@ -15,11 +16,12 @@ Example:
 		compatible = "wm,wm8505-fb";
 		reg = <0xd8051700 0x200>;
 		bits-per-pixel = <16>;
+		clocks = <&clkdvo>;
 
 		display-timings {
 			native-mode = <&timing0>;
 			timing0: 800x480 {
-				clock-frequency = <0>; /* unused but required */
+				clock-frequency = <30000000>;
 				hactive = <800>;
 				vactive = <480>;
 				hfront-porch = <40>;
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index 167a9e2..f8bffc2 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -14,6 +14,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/fb.h>
@@ -130,9 +131,11 @@
 #define to_wm8505fb_info(__info) container_of(__info, \
 						struct wm8505fb_info, fb)
 struct wm8505fb_info {
-	struct fb_info		fb;
-	void __iomem		*regbase;
-	unsigned int		contrast;
+	struct fb_info fb;
+	void __iomem *regbase;
+	unsigned int contrast;
+	struct device *dev;
+	struct clk *clk_dvo;
 };
 
 
@@ -210,6 +213,13 @@ static int wm8505fb_set_par(struct fb_info *info)
 	if (!fbi)
 		return -EINVAL;
 
+	if (info->var.pixclock = 0) {
+		dev_err(fbi->dev, "requested pixclock = 0\n");
+		return -EINVAL;
+	}
+
+	clk_set_rate(fbi->clk_dvo, PICOS2KHZ(info->var.pixclock)*1000);
+
 	if (info->var.bits_per_pixel = 32) {
 		info->var.red.offset = 16;
 		info->var.red.length = 8;
@@ -369,6 +379,8 @@ static int wm8505fb_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	fbi->dev = &pdev->dev;
+
 	strcpy(fbi->fb.fix.id, DRIVER_NAME);
 
 	fbi->fb.fix.type	= FB_TYPE_PACKED_PIXELS;
@@ -408,6 +420,14 @@ static int wm8505fb_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	fbi->clk_dvo = of_clk_get(pdev->dev.of_node, 0);
+	if (IS_ERR(fbi->clk_dvo)) {
+		dev_err(&pdev->dev, "Error retrieving clock\n");
+		return PTR_ERR(fbi->clk_dvo);
+	}
+
+	clk_prepare_enable(fbi->clk_dvo);
+
 	fb_videomode_to_var(&fbi->fb.var, &mode);
 
 	fbi->fb.var.nonstd		= 0;
@@ -421,7 +441,7 @@ static int wm8505fb_probe(struct platform_device *pdev)
 	fb_mem_virt = dmam_alloc_coherent(&pdev->dev, fb_mem_len, &fb_mem_phys,
 				GFP_KERNEL);
 	if (!fb_mem_virt) {
-		pr_err("%s: Failed to allocate framebuffer\n", __func__);
+		dev_err(&pdev->dev, "Failed to allocate framebuffer\n");
 		return -ENOMEM;
 	}
 
@@ -480,6 +500,8 @@ static int wm8505fb_remove(struct platform_device *pdev)
 
 	unregister_framebuffer(&fbi->fb);
 
+	clk_disable_unprepare(fbi->clk_dvo);
+
 	writel(0, fbi->regbase);
 
 	if (fbi->fb.cmap.len)
-- 
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: linux@prisktech.co.nz (Tony Prisk)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] fb: vt8500: Require a device clock for wm8505fb driver
Date: Sat, 18 May 2013 21:15:13 +1200	[thread overview]
Message-ID: <1368868514-18975-4-git-send-email-linux@prisktech.co.nz> (raw)
In-Reply-To: <1368868514-18975-1-git-send-email-linux@prisktech.co.nz>

The wm8505fb driver requires a clock to work properly. Without a clock,
the driver can only initialize the display resolution that was set in
uboot.
This patch updates the driver to get and use a clock, and updates
the devicetree documentation to indicate the requirement for a clock.

Signed-off-by: Tony Prisk <linux@prisktech.co.nz>
---
 .../devicetree/bindings/video/wm,wm8505-fb.txt     |    4 ++-
 drivers/video/wm8505fb.c                           |   30 +++++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt b/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
index 0bcadb2..601416c 100644
--- a/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
+++ b/Documentation/devicetree/bindings/video/wm,wm8505-fb.txt
@@ -5,6 +5,7 @@ Required properties:
 - compatible : "wm,wm8505-fb"
 - reg : Should contain 1 register ranges(address and length)
 - bits-per-pixel : bit depth of framebuffer (16 or 32)
+- clocks : phandle to DVO clock
 
 Required subnodes:
 - display-timings: see display-timing.txt for information
@@ -15,11 +16,12 @@ Example:
 		compatible = "wm,wm8505-fb";
 		reg = <0xd8051700 0x200>;
 		bits-per-pixel = <16>;
+		clocks = <&clkdvo>;
 
 		display-timings {
 			native-mode = <&timing0>;
 			timing0: 800x480 {
-				clock-frequency = <0>; /* unused but required */
+				clock-frequency = <30000000>;
 				hactive = <800>;
 				vactive = <480>;
 				hfront-porch = <40>;
diff --git a/drivers/video/wm8505fb.c b/drivers/video/wm8505fb.c
index 167a9e2..f8bffc2 100644
--- a/drivers/video/wm8505fb.c
+++ b/drivers/video/wm8505fb.c
@@ -14,6 +14,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/fb.h>
@@ -130,9 +131,11 @@
 #define to_wm8505fb_info(__info) container_of(__info, \
 						struct wm8505fb_info, fb)
 struct wm8505fb_info {
-	struct fb_info		fb;
-	void __iomem		*regbase;
-	unsigned int		contrast;
+	struct fb_info fb;
+	void __iomem *regbase;
+	unsigned int contrast;
+	struct device *dev;
+	struct clk *clk_dvo;
 };
 
 
@@ -210,6 +213,13 @@ static int wm8505fb_set_par(struct fb_info *info)
 	if (!fbi)
 		return -EINVAL;
 
+	if (info->var.pixclock == 0) {
+		dev_err(fbi->dev, "requested pixclock = 0\n");
+		return -EINVAL;
+	}
+
+	clk_set_rate(fbi->clk_dvo, PICOS2KHZ(info->var.pixclock)*1000);
+
 	if (info->var.bits_per_pixel == 32) {
 		info->var.red.offset = 16;
 		info->var.red.length = 8;
@@ -369,6 +379,8 @@ static int wm8505fb_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	fbi->dev = &pdev->dev;
+
 	strcpy(fbi->fb.fix.id, DRIVER_NAME);
 
 	fbi->fb.fix.type	= FB_TYPE_PACKED_PIXELS;
@@ -408,6 +420,14 @@ static int wm8505fb_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	fbi->clk_dvo = of_clk_get(pdev->dev.of_node, 0);
+	if (IS_ERR(fbi->clk_dvo)) {
+		dev_err(&pdev->dev, "Error retrieving clock\n");
+		return PTR_ERR(fbi->clk_dvo);
+	}
+
+	clk_prepare_enable(fbi->clk_dvo);
+
 	fb_videomode_to_var(&fbi->fb.var, &mode);
 
 	fbi->fb.var.nonstd		= 0;
@@ -421,7 +441,7 @@ static int wm8505fb_probe(struct platform_device *pdev)
 	fb_mem_virt = dmam_alloc_coherent(&pdev->dev, fb_mem_len, &fb_mem_phys,
 				GFP_KERNEL);
 	if (!fb_mem_virt) {
-		pr_err("%s: Failed to allocate framebuffer\n", __func__);
+		dev_err(&pdev->dev, "Failed to allocate framebuffer\n");
 		return -ENOMEM;
 	}
 
@@ -480,6 +500,8 @@ static int wm8505fb_remove(struct platform_device *pdev)
 
 	unregister_framebuffer(&fbi->fb);
 
+	clk_disable_unprepare(fbi->clk_dvo);
+
 	writel(0, fbi->regbase);
 
 	if (fbi->fb.cmap.len)
-- 
1.7.9.5

  parent reply	other threads:[~2013-05-18  9:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-18  9:15 [PATCH 0/4] FB updates for 3.11 Tony Prisk
2013-05-18  9:15 ` Tony Prisk
2013-05-18  9:15 ` Tony Prisk
2013-05-18  9:15 ` [PATCH 1/4] fb: vt8500: Move register defines inside driver Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18  9:15 ` [PATCH 2/4] fb: vt8500: Convert to use vendor register names Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18  9:15 ` Tony Prisk [this message]
2013-05-18  9:15   ` [PATCH 3/4] fb: vt8500: Require a device clock for wm8505fb driver Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18  9:15 ` [PATCH 4/4] fb: vt8500: Add VGA output support to " Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18  9:15   ` Tony Prisk
2013-05-18 13:28   ` Alexey Charkov
2013-05-18 13:28     ` Alexey Charkov
2013-05-18 13:28     ` Alexey Charkov
2013-05-18 13:41     ` Andy Chernyak
2013-05-18 13:41       ` Andy Chernyak
2013-05-18 13:41       ` Andy Chernyak
2013-05-18 19:51     ` Tony Prisk
2013-05-18 19:51       ` Tony Prisk
2013-05-18 19:51       ` Tony Prisk
2013-05-19  8:06 ` [PATCH 0/4] FB updates for 3.11 Tony Prisk
2013-05-19  8:06   ` Tony Prisk
2013-05-19  8:06   ` Tony Prisk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1368868514-18975-4-git-send-email-linux@prisktech.co.nz \
    --to=linux@prisktech.co.nz \
    --cc=FlorianSchandinat@gmx.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=vt8500-wm8505-linux-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.