From patchwork Sat May 18 09:15:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Prisk X-Patchwork-Id: 2588441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 1BD03DF2E5 for ; Sat, 18 May 2013 09:16:17 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UddF3-0005yR-SM; Sat, 18 May 2013 09:15:54 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UddEz-0005Vz-8E; Sat, 18 May 2013 09:15:49 +0000 Received: from server.prisktech.co.nz ([115.188.14.127]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UddEm-0005Tp-81 for linux-arm-kernel@lists.infradead.org; Sat, 18 May 2013 09:15:37 +0000 Received: from localhost.localdomain (unknown [192.168.0.102]) by server.prisktech.co.nz (Postfix) with ESMTP id 8BD20FC0ECC; Sat, 18 May 2013 21:15:16 +1200 (NZST) From: Tony Prisk To: Florian Tobias Schandinat Subject: [PATCH 3/4] fb: vt8500: Require a device clock for wm8505fb driver Date: Sat, 18 May 2013 21:15:13 +1200 Message-Id: <1368868514-18975-4-git-send-email-linux@prisktech.co.nz> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1368868514-18975-1-git-send-email-linux@prisktech.co.nz> References: <1368868514-18975-1-git-send-email-linux@prisktech.co.nz> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130518_051536_842819_D01DCFBC X-CRM114-Status: GOOD ( 17.51 ) X-Spam-Score: -2.5 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, Tony Prisk , tomi.valkeinen@ti.com, vt8500-wm8505-linux-kernel@googlegroups.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 --- .../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 #include #include #include @@ -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)