Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp804492imm; Wed, 10 Oct 2018 04:42:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VbfgncxUBVo6gei6DmFr/WVXGMNCcuGJbTlu1KXccsVbH5h9KHWqE1y2pfDU5ezJ61qh+ X-Received: by 2002:a63:9712:: with SMTP id n18-v6mr11728723pge.182.1539171779802; Wed, 10 Oct 2018 04:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539171779; cv=none; d=google.com; s=arc-20160816; b=Qr/FEO23Zy+qXXjlaFxjTeT7JemGx/fYCyygJ3T8leGHsEgIpDc+gTBM5d2a7UiPhR 5bs9wZug0u5probpp0HK7yhXmlQkq8wAqeeIWj1VemT+52naG+viV5IoB1Hl8RTIyyyG LgYgJnlrWPI9uWVFgmz6N5QotxdIjNxqOsX6kpnYbd//7UXEQqQh8PoHjGvRruhQg3JK wBqgt4R7ANLbjmX6aIREuJAMFd9nfW8yNyn4zUhAPZpy/mx+YHU9KQqc6bWgxp+mNVNy NSyoUJAv2xxhVASXTiR9Ri0lU341wgQPXvfk1HLK+syWIy1nxde4hD1gByj26xkcmgtj giYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nPa0xsrAg//XvFsMOpAPjKh02TO16aVAiScufFDYrFY=; b=vVFOdZQ3xM5En2b1JmjFu1gWK9gvgybkl3o96d4SMYOt+5thpQ2+1Cl6LwgH0IaV9r feP3RWYlRGMyt89ZscN9DVShoW/q+daMLlRu3D66PEksfN6m8URxTJlWJLDQpMO3wOM3 QnUEAQCwHqPqALPyWT713gK18Suprf/MbxRF/H7cip8ioRS6uqIpIbJIiRI9w091iuKw BwdLCzm5tfugTJpFNfzsbKMcdKUqOvbDukaLRRM7RTWDLKsngKNmdG2AnwhLroORO+hj GXiG+XRdTJJvC9n0jNm+MAOtf2HDrLAnh67zk3cfzoPKRN5v6pYWGBBRctW/yFwyBvJQ C1uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si23706135plx.106.2018.10.10.04.42.44; Wed, 10 Oct 2018 04:42:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbeJJTEG (ORCPT + 99 others); Wed, 10 Oct 2018 15:04:06 -0400 Received: from leonov.paulk.fr ([185.233.101.22]:35752 "EHLO leonov.paulk.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbeJJTEG (ORCPT ); Wed, 10 Oct 2018 15:04:06 -0400 Received: from gagarine.paulk.fr (gagarine [192.168.1.127]) by leonov.paulk.fr (Postfix) with ESMTPS id F065EBFE87; Wed, 10 Oct 2018 13:42:19 +0200 (CEST) Received: by gagarine.paulk.fr (Postfix, from userid 114) id 228C5C100C; Wed, 10 Oct 2018 13:42:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on gagarine.paulk.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 Received: from localhost.localdomain (collins [192.168.1.129]) by gagarine.paulk.fr (Postfix) with ESMTP id 8F5ABC04D1; Wed, 10 Oct 2018 13:41:55 +0200 (CEST) From: Paul Kocialkowski To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: Rob Herring , Mark Rutland , Maxime Ripard , Chen-Yu Tsai , Thierry Reding , David Airlie , linux-sunxi@googlegroups.com, Mark Van den Borre , Gerry Demaret , Luc Verhaegen , Paul Kocialkowski Subject: [PATCH 1/4] drm/sun4i: tcon: Support an active-low DE signal with RGB interface Date: Wed, 10 Oct 2018 13:41:31 +0200 Message-Id: <20181010114134.8211-1-contact@paulk.fr> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some panels need an active-low data enable (DE) signal for the RGB interface. This requires flipping a bit in the TCON0 polarity register when setting up the mode for the RGB interface. Add a new helper function to match specific bus flags and use it to set the polarity inversion bit for the DE signal when required. Signed-off-by: Paul Kocialkowski --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 28 ++++++++++++++++++++++++++-- drivers/gpu/drm/sun4i/sun4i_tcon.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 3fb084f802e2..d249a462ec09 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -78,6 +78,24 @@ static int sun4i_tcon_get_pixel_depth(const struct drm_encoder *encoder) return -EINVAL; } +static bool sun4i_tcon_match_bus_flags(const struct drm_encoder *encoder, + u32 bus_flags) +{ + struct drm_connector *connector; + struct drm_display_info *info; + + connector = sun4i_tcon_get_connector(encoder); + if (!connector) + return false; + + info = &connector->display_info; + + if ((info->bus_flags & bus_flags) == bus_flags) + return true; + + return false; +} + static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel, bool enabled) { @@ -415,6 +433,7 @@ static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon, } static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, + const struct drm_encoder *encoder, const struct drm_display_mode *mode) { unsigned int bp, hsync, vsync; @@ -474,8 +493,13 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, if (mode->flags & DRM_MODE_FLAG_PVSYNC) val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; + if (sun4i_tcon_match_bus_flags(encoder, DRM_BUS_FLAG_DE_LOW)) + val |= SUN4I_TCON0_IO_POL_DE_NEGATIVE; + regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, - SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSITIVE, + SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | + SUN4I_TCON0_IO_POL_VSYNC_POSITIVE | + SUN4I_TCON0_IO_POL_DE_NEGATIVE, val); /* Map output pins to channel 0 */ @@ -596,7 +620,7 @@ void sun4i_tcon_mode_set(struct sun4i_tcon *tcon, sun4i_tcon0_mode_set_lvds(tcon, encoder, mode); break; case DRM_MODE_ENCODER_NONE: - sun4i_tcon0_mode_set_rgb(tcon, mode); + sun4i_tcon0_mode_set_rgb(tcon, encoder, mode); sun4i_tcon_set_mux(tcon, 0, encoder); break; case DRM_MODE_ENCODER_TVDAC: diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index f6a071cd5a6f..708399c80561 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -113,6 +113,7 @@ #define SUN4I_TCON0_IO_POL_REG 0x88 #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase) ((phase & 3) << 28) +#define SUN4I_TCON0_IO_POL_DE_NEGATIVE BIT(27) #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE BIT(25) #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE BIT(24) -- 2.19.0