From patchwork Thu Jun 16 09:36:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 70159 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp166175qgy; Thu, 16 Jun 2016 02:36:40 -0700 (PDT) X-Received: by 10.98.62.15 with SMTP id l15mr4151826pfa.24.1466069800073; Thu, 16 Jun 2016 02:36:40 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tm9si8898798pab.108.2016.06.16.02.36.39; Thu, 16 Jun 2016 02:36:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-fbdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-fbdev-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752655AbcFPJgj (ORCPT + 2 others); Thu, 16 Jun 2016 05:36:39 -0400 Received: from mail-lf0-f41.google.com ([209.85.215.41]:33388 "EHLO mail-lf0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752217AbcFPJgi (ORCPT ); Thu, 16 Jun 2016 05:36:38 -0400 Received: by mail-lf0-f41.google.com with SMTP id f6so36750234lfg.0 for ; Thu, 16 Jun 2016 02:36:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LWeE8dM6JWb/Q4tFsP7xwqIg7gw16hIByYOQ5NL//Is=; b=EAuu/PqPjcvq0mIz2zTWIwLp06gl/U/JtvuUbS4f7f/kcgmPRqLUuDk834ufVnhKaA qTj/SCaotSLV4RjZvVJARAJVpf8/yw42a6zP8TsJm4422Ia2w1Drka/EiMH7vJgexnxC OTy2OqwzFjsTy0uv00AGjsaPexPvK86cLBNnU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LWeE8dM6JWb/Q4tFsP7xwqIg7gw16hIByYOQ5NL//Is=; b=ZzsiHw5LOF2W1Wrt5L8Y9jfUXJbyr1jJF7vtVvNsfg5GqkB+xnsVARr4rhtnHkkWyD YkIesVi69aXS3XLmsEs6S24JB4dabH81XkVer1D3A1gMDWyPJMKSNcF/8S5Klez19FKJ D5mrmXh+8pkNxRwDPKskWfBC3QyfZQH+9+8o2z/6hQ0lDzV1ZcTfc6A+bDUVYnh/PV0r 3X3Xn0pj98kxiJcIp6mnDB7tPE3T1UbcoU24L3mzu3h2Yai8YYpcEYx8nZ7nP12/t5dd AfkX4++qWH6x7bhvsfdynqyrHDHFRvzlSA/Wu31YMArXyfP6QcdqbKacnS4lByAd+47l 3PIg== X-Gm-Message-State: ALyK8tLP9qi3hG03KAUBgId/qOpRl1JvWYvjtN07J3NNiwvjaUmg4vZmggDfmfTCo2Zw/UyS X-Received: by 10.25.89.8 with SMTP id n8mr801551lfb.225.1466069796773; Thu, 16 Jun 2016 02:36:36 -0700 (PDT) Received: from localhost.localdomain.localdomain (c-cc7c71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.124.204]) by smtp.gmail.com with ESMTPSA id d8sm1884006lbc.29.2016.06.16.02.36.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jun 2016 02:36:35 -0700 (PDT) From: Linus Walleij To: linux-fbdev@vger.kernel.org, Tomi Valkeinen , Jean-Christophe Plagniol-Villard , Pawel Moll , Rob Herring , Russell King Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Ray Jui , Linus Walleij Subject: [PATCH 2/6] video: ARM CLCD: support DT signal inversion flags Date: Thu, 16 Jun 2016 11:36:14 +0200 Message-Id: <1466069778-16087-3-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1466069778-16087-1-git-send-email-linus.walleij@linaro.org> References: <1466069778-16087-1-git-send-email-linus.walleij@linaro.org> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The device tree bindings from display-timing.txt allows us to specify if data enable, hsync, vsync or the pixed clock should be inverted on the way to the display. The driver does not currently handle this so add support for those flags as it is needed for the Versatile Sanyo LCD display. Note that the previous behaviour was to invert the pixel clock for all displays, so unless the pixel clock polarity is explicitly defined in the device tree (i.e. the timings node has the "pixelclk-active" property) we fall back to inverting the pixel clock. This needs some extra compatibility code. Since the timing flags have to be set up inside the struct clcd_panel, we need to refactor the code a bit to pass around the panel rather than just the mode. Cc: Pawel Moll Cc: Rob Herring Cc: Russell King Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Check if neither DISPLAY_FLAGS_PIXDATA_NEGEDGE or DISPLAY_FLAGS_PIXDATA_POSEDGE to default to NEGEDGE and avoid poking around in the device tree. ChangeLog v1->v2: - No changes. Just reposting. --- drivers/video/fbdev/amba-clcd.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) -- 2.4.11 -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c index 52a33d3926ac..5bd20e8800bc 100644 --- a/drivers/video/fbdev/amba-clcd.c +++ b/drivers/video/fbdev/amba-clcd.c @@ -565,7 +565,7 @@ static int clcdfb_register(struct clcd_fb *fb) #ifdef CONFIG_OF static int clcdfb_of_get_dpi_panel_mode(struct device_node *node, - struct fb_videomode *mode) + struct clcd_panel *clcd_panel) { int err; struct display_timing timing; @@ -577,10 +577,31 @@ static int clcdfb_of_get_dpi_panel_mode(struct device_node *node, videomode_from_timing(&timing, &video); - err = fb_videomode_from_videomode(&video, mode); + err = fb_videomode_from_videomode(&video, &clcd_panel->mode); if (err) return err; + /* Set up some inversion flags */ + if (timing.flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE) + clcd_panel->tim2 |= TIM2_IPC; + else if (!(timing.flags & DISPLAY_FLAGS_PIXDATA_POSEDGE)) + /* + * To preserve backwards compatibility, the IPC (inverted + * pixel clock) flag needs to be set on any display that + * doesn't explicitly specify that the pixel clock is + * active on the negative or positive edge. + */ + clcd_panel->tim2 |= TIM2_IPC; + + if (timing.flags & DISPLAY_FLAGS_HSYNC_LOW) + clcd_panel->tim2 |= TIM2_IHS; + + if (timing.flags & DISPLAY_FLAGS_VSYNC_LOW) + clcd_panel->tim2 |= TIM2_IVS; + + if (timing.flags & DISPLAY_FLAGS_DE_LOW) + clcd_panel->tim2 |= TIM2_IOE; + return 0; } @@ -613,10 +634,11 @@ static int clcdfb_of_get_backlight(struct device_node *endpoint, } static int clcdfb_of_get_mode(struct device *dev, struct device_node *endpoint, - struct fb_videomode *mode) + struct clcd_panel *clcd_panel) { int err; struct device_node *panel; + struct fb_videomode *mode; char *name; int len; @@ -626,11 +648,12 @@ static int clcdfb_of_get_mode(struct device *dev, struct device_node *endpoint, /* Only directly connected DPI panels supported for now */ if (of_device_is_compatible(panel, "panel-dpi")) - err = clcdfb_of_get_dpi_panel_mode(panel, mode); + err = clcdfb_of_get_dpi_panel_mode(panel, clcd_panel); else err = -ENOENT; if (err) return err; + mode = &clcd_panel->mode; len = clcdfb_snprintf_mode(NULL, 0, mode); name = devm_kzalloc(dev, len + 1, GFP_KERNEL); @@ -661,8 +684,8 @@ static int clcdfb_of_init_tft_panel(struct clcd_fb *fb, u32 r0, u32 g0, u32 b0) }; int i; - /* Bypass pixel clock divider, data output on the falling edge */ - fb->panel->tim2 = TIM2_BCD | TIM2_IPC; + /* Bypass pixel clock divider */ + fb->panel->tim2 |= TIM2_BCD; /* TFT display, vert. comp. interrupt at the start of the back porch */ fb->panel->cntl |= CNTL_LCDTFT | CNTL_LCDVCOMP(1); @@ -702,7 +725,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb) if (err) return err; - err = clcdfb_of_get_mode(&fb->dev->dev, endpoint, &fb->panel->mode); + err = clcdfb_of_get_mode(&fb->dev->dev, endpoint, fb->panel); if (err) return err;