Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp834644ybv; Wed, 19 Feb 2020 10:11:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwI14OnNI28zAid/Q0r6xJGil68TyqjHjEF0WLlo4cheH2snVmbWhyH+g4rBZPTu0NemAFP X-Received: by 2002:aca:2b04:: with SMTP id i4mr5458135oik.21.1582135874053; Wed, 19 Feb 2020 10:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582135874; cv=none; d=google.com; s=arc-20160816; b=a4+/i0+p+js5nY33Vsktev5bGj0k4hOqtufKY20PJ3Iv6oOhswsbXiZAlfwgSlZi/I lK4LARSl/4rtGbPJMd5Ewb1TIxio2+BPL3O52wSUXKtAACzQdiVAYfpj/WqKgPMzzRjM 7BatSTZ0/z9gTJc1UqIeHa8EHUdP6k3TbDtSng9cBI7R3jZNcJ7urHmHnfdvUUayfnsk Re4VLstmji52jfWSnBsWRkkyEbLcaQkS8pu6KAqK3be1HDoquNN4buCnCZ3PllOxATx8 aU+ZTbH1jgjUf/N5YEiYHvw0w0NH/HJ3zH5PNPiiQ+S48VCGXcL4Aa/FAsnfXsTqsMf+ rGGA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=w8AByD+ELp+U0fkzTE0l2V9pOyhi/BIhszCAehVAQ1E=; b=Ze7BBg3+31fSoLCRgiBzpewLFuLKWrsdO/lnC2MxnBKWEzXKEYciZi3SSTMBi5jAHF XBLoXhyqoVY85+9r8DY4AfGJvWmmw0GrSjxKJeDeN1dTzd0nwtsvEJcYrdrp55AbnCUg hfNWpoAj9Snb527VEhcvnVVwuqoSKaGQ8lfgKtycCAmK3vZI5PjIQIA0uDDGUf5u7yq/ 50qgPiIfm4oRAhviaMtonLGjN1eK7aHLp5gtTdo0LIqDWqBZlW+qV02jQXMVltnCaOyK eiPTdJNv41XCA4ZfwapAZ6h4LhKmuNNpLowlQd4Eotb0X2TwmEKFQKmEf9sz0cV0hHDQ 6yVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mm4oywX2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si267532otp.25.2020.02.19.10.11.01; Wed, 19 Feb 2020 10:11:14 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mm4oywX2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbgBSSKO (ORCPT + 99 others); Wed, 19 Feb 2020 13:10:14 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46304 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726664AbgBSSKG (ORCPT ); Wed, 19 Feb 2020 13:10:06 -0500 Received: by mail-lj1-f193.google.com with SMTP id x14so1307346ljd.13 for ; Wed, 19 Feb 2020 10:10:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w8AByD+ELp+U0fkzTE0l2V9pOyhi/BIhszCAehVAQ1E=; b=mm4oywX2Nv0gEUy5q5BvavEnr/9cwOu5HwoESNSpYK9r5qLMd3qpGpucotlo0pJcKC bHsU5KbAYFVhaQRRgPJx6Cdn6diDXHkl5KsHi062Tp48Sz9XJaH5qpshjYYP9OvgTtPh vz+mVfsRNZZ4D86DoWA2h/RUpqhboXlxuYEJpXJfeXPuPmAP8MQzfqBR4fkF91h76dJ7 XfCOSzF+gF7Ww7kbsxqJU+p+Ahq5oqM79Mym4v2xpMotE4w2iaxTzC1Ecd5UIRlXxAvf dZJUhriRCRKhcbEHYvnjaPXRTki6XPCvezD3RMJ6baXq/Im1N432midsBFMY/6muy9JH QtFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w8AByD+ELp+U0fkzTE0l2V9pOyhi/BIhszCAehVAQ1E=; b=ARUPLDKVxt0XLvMVopeKIzbDOpvMCPoCp2bFB2iADwYrS92QoaGTl5X4vfxHHYC3nd wuAohbxJXCOJeEEXNcwlraVxIjiBQw9sgTUtzQpRT9o41S0JlLzx/zWGFoExFGrsMS4H qW8tEC/ice8IIybexwWnNiVcH0t1bst+vhDhdElmodA+r5z8cib9i/8qtiFtHCyJfW9E cP1MxWaZ3TZRMBj53giYbupTbNb6TvpBdX2JJ2QSWF8YndwQbGviHMvbXq5Ka/OBtti8 AeQlODisCqsfcQP6+7oBx/usTkPLKViQVCBq+Bv99cmSD9rF9cuJPEUhPfjMKK1Hm9d2 ymBA== X-Gm-Message-State: APjAAAVizDolhlb+fi85awZ7MwhRa2T6Xxo/9aCAfLdqbvC2ppfXkXm6 y2+nqGRQLcWMDN2apZK28kA= X-Received: by 2002:a2e:8702:: with SMTP id m2mr16967294lji.278.1582135804086; Wed, 19 Feb 2020 10:10:04 -0800 (PST) Received: from localhost.localdomain ([5.20.204.163]) by smtp.gmail.com with ESMTPSA id 14sm183942lfz.47.2020.02.19.10.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 10:10:03 -0800 (PST) From: Andrey Lebedev To: mripard@kernel.org, wens@csie.org, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linux-sunxi@googlegroups.com, Andrey Lebedev Subject: [PATCH 5/5] drm/sun4i: tcon: Support LVDS output on Allwinner A20 Date: Wed, 19 Feb 2020 20:08:58 +0200 Message-Id: <20200219180858.4806-6-andrey.lebedev@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200219180858.4806-1-andrey.lebedev@gmail.com> References: <20200210195633.GA21832@kedthinkpad> <20200219180858.4806-1-andrey.lebedev@gmail.com> 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 From: Andrey Lebedev A20 SoC (found in Cubieboard 2 among others) requires different LVDS set up procedure than A33. Timing controller (tcon) driver only implements sun6i-style procedure, that doesn't work on A20 (sun7i). Signed-off-by: Andrey Lebedev --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 37 +++++++++++++++++++++++++++++- drivers/gpu/drm/sun4i/sun4i_tcon.h | 11 +++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index b7234eef3c7b..09ee6e8c6914 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -114,6 +114,30 @@ static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel, } } +static void sun4i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon, + const struct drm_encoder *encoder) +{ + regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG, + SUN4I_TCON0_LVDS_ANA0_CK_EN | + SUN4I_TCON0_LVDS_ANA0_REG_V | + SUN4I_TCON0_LVDS_ANA0_REG_C | + SUN4I_TCON0_LVDS_ANA0_EN_MB | + SUN4I_TCON0_LVDS_ANA0_PD | + SUN4I_TCON0_LVDS_ANA0_DCHS); + + udelay(2); /* delay at least 1200 ns */ + regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG, + SUN4I_TCON0_LVDS_ANA1_INIT, + SUN4I_TCON0_LVDS_ANA1_INIT); + udelay(1); /* delay at least 120 ns */ + regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG, + SUN4I_TCON0_LVDS_ANA1_UPDATE, + SUN4I_TCON0_LVDS_ANA1_UPDATE); + regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG, + SUN4I_TCON0_LVDS_ANA0_EN_MB, + SUN4I_TCON0_LVDS_ANA0_EN_MB); +} + static void sun6i_tcon_setup_lvds_phy(struct sun4i_tcon *tcon, const struct drm_encoder *encoder) { @@ -1455,7 +1479,18 @@ static const struct sun4i_tcon_quirks sun6i_a31s_quirks = { .dclk_min_div = 1, }; +static const struct sun4i_tcon_quirks sun7i_a20_tcon0_quirks = { + .supports_lvds = true, + .has_channel_0 = true, + .has_channel_1 = true, + .dclk_min_div = 4, + /* Same display pipeline structure as A10 */ + .set_mux = sun4i_a10_tcon_set_mux, + .setup_lvds_phy = sun4i_tcon_setup_lvds_phy, +}; + static const struct sun4i_tcon_quirks sun7i_a20_quirks = { + .supports_lvds = false, .has_channel_0 = true, .has_channel_1 = true, .dclk_min_div = 4, @@ -1508,7 +1543,7 @@ const struct of_device_id sun4i_tcon_of_table[] = { { .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks }, { .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks }, { .compatible = "allwinner,sun6i-a31s-tcon", .data = &sun6i_a31s_quirks }, - { .compatible = "allwinner,sun7i-a20-tcon0", .data = &sun7i_a20_quirks }, + { .compatible = "allwinner,sun7i-a20-tcon0", .data = &sun7i_a20_tcon0_quirks }, { .compatible = "allwinner,sun7i-a20-tcon1", .data = &sun7i_a20_quirks }, { .compatible = "allwinner,sun7i-a20-tcon", .data = &sun7i_a20_quirks }, { .compatible = "allwinner,sun8i-a23-tcon", .data = &sun8i_a33_quirks }, diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index 2974e59ef9f2..cfbf4e6c1679 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -193,6 +193,13 @@ #define SUN4I_TCON_MUX_CTRL_REG 0x200 #define SUN4I_TCON0_LVDS_ANA0_REG 0x220 +#define SUN4I_TCON0_LVDS_ANA0_DCHS BIT(16) +#define SUN4I_TCON0_LVDS_ANA0_PD (BIT(20) | BIT(21)) +#define SUN4I_TCON0_LVDS_ANA0_EN_MB BIT(22) +#define SUN4I_TCON0_LVDS_ANA0_REG_C (BIT(24) | BIT(25)) +#define SUN4I_TCON0_LVDS_ANA0_REG_V (BIT(26) | BIT(27)) +#define SUN4I_TCON0_LVDS_ANA0_CK_EN (BIT(29) | BIT(28)) + #define SUN6I_TCON0_LVDS_ANA0_EN_MB BIT(31) #define SUN6I_TCON0_LVDS_ANA0_EN_LDO BIT(30) #define SUN6I_TCON0_LVDS_ANA0_EN_DRVC BIT(24) @@ -201,6 +208,10 @@ #define SUN6I_TCON0_LVDS_ANA0_V(x) (((x) & 3) << 8) #define SUN6I_TCON0_LVDS_ANA0_PD(x) (((x) & 3) << 4) +#define SUN4I_TCON0_LVDS_ANA1_REG 0x224 +#define SUN4I_TCON0_LVDS_ANA1_INIT (0x1f << 26 | 0x1f << 10) +#define SUN4I_TCON0_LVDS_ANA1_UPDATE (0x1f << 16 | 0x1f << 00) + #define SUN4I_TCON1_FILL_CTL_REG 0x300 #define SUN4I_TCON1_FILL_BEG0_REG 0x304 #define SUN4I_TCON1_FILL_END0_REG 0x308 -- 2.20.1