Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1823480imm; Sun, 23 Sep 2018 12:30:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZtUDvddOo/ZEqwTRPraez9ZPGR5CeDV8OfUzJTX5wrIznsrI6MhTO373ivKjGajxtVlNPi X-Received: by 2002:a62:8208:: with SMTP id w8-v6mr7278728pfd.215.1537731011535; Sun, 23 Sep 2018 12:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537731011; cv=none; d=google.com; s=arc-20160816; b=wbxixCMqv6s+2wzzWwpYGng9/cJ72ik24Y682/RPiDp/QJ2qfUj9rKG3nd0uNxdXrk +QkN5acVOCXzL6qI/l85FyC93MCzx+GYOUnVyaqGlb7R8mH9JKAI2s4n4S9XSleUeS6b xL+S6ioqWQLHFFK07bETI5M22WtuQ+FsCsd4S4Wiw3oetdlaS6hYgaZ7/k3rqdT9/QS7 jnfO78njq0FPHWpC4GxerzIX4Y4MT1J9UCXs78UARlA1W6Jc6noSh8lQyOkstvXoSF1g McSvJ01WfNUCZh31ROjeXivniuRx73G1m2R1p0GScE3+SECFKSQfm++/7VOdbmQwDHsU KtoQ== 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; bh=RvzFRNtMj839AHx/7NXDLLVDrtPF3YY0td/A4HRcaJo=; b=q/Y8s/vDGuA0zibbUjQkzHgwxDPqQc/ofthGtUkH15KZ+LphNjPc1sj2pe07EJNKho z6ncBDRUNwoctanhmrzH38BUfasHALWexCg6F9CMqowVKHE8MPVL/QCRIZqmhb2+OqAC Qr80NnlC5tT2oVc/9jfHx5N1hUjkMepiONWES/87e4DSS3jD2nKPSw4E+MtD3JCv9nJS AeAudTYaOJnpJZL4VrX2FhT2B92wake0bo82Lex/CYAmYOiTT/L/3v+uQLOw0AgTiBN+ +Mqca7DE0jsF10ElI9jJSjTZwxK0WaDRsagYQkimyT+4+zSsOdbHT8fNnngvGFO3Mzg/ oGiw== 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 u1-v6si32415364pgl.669.2018.09.23.12.29.55; Sun, 23 Sep 2018 12:30:11 -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 S1727062AbeIXB2O (ORCPT + 99 others); Sun, 23 Sep 2018 21:28:14 -0400 Received: from mailoutvs26.siol.net ([185.57.226.217]:59976 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726437AbeIXB2O (ORCPT ); Sun, 23 Sep 2018 21:28:14 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id B83595212F6; Sun, 23 Sep 2018 21:29:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta11.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta11.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id foB23Ch5Y_WU; Sun, 23 Sep 2018 21:29:57 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id 58824521256; Sun, 23 Sep 2018 21:29:57 +0200 (CEST) Received: from jernej-laptop.localnet (cpe1-8-82.cable.triera.net [213.161.8.82]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPA id 89C385211EF; Sun, 23 Sep 2018 21:29:55 +0200 (CEST) From: Jernej =?utf-8?B?xaBrcmFiZWM=?= To: Chen-Yu Tsai Cc: Rob Herring , Maxime Ripard , Mark Rutland , Mike Turquette , Stephen Boyd , David Airlie , Archit Taneja , Andrzej Hajda , devicetree , linux-arm-kernel , linux-kernel , linux-clk , dri-devel , linux-sunxi Subject: Re: [PATCH 21/27] drm/sun4i: Add support for H6 HDMI PHY Date: Sun, 23 Sep 2018 21:29:33 +0200 Message-ID: <3593541.d8rxrvbqPe@jernej-laptop> In-Reply-To: References: <20180902072643.4917-1-jernej.skrabec@siol.net> <20180902072643.4917-22-jernej.skrabec@siol.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne sobota, 22. september 2018 ob 17:55:35 CEST je Chen-Yu Tsai napisal(a): > On Sun, Sep 2, 2018 at 3:28 PM Jernej Skrabec wrote: > > H6 has Synopsys DWC HDMI 2.0 TX PHY. > > > > mpll settings were calculated from specifications of similar Synopsys > > HDMI PHY found in i.MX6. Other PHY settings were derived from BSP PHY > > driver code. > > > > Signed-off-by: Jernej Skrabec > > --- > > > > drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 137 +++++++++++++++++++++++++ > > 1 file changed, 137 insertions(+) > > > > diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > > b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index ee2bf61cd4d2..2f5499bd35ec > > 100644 > > --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > > +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > > @@ -14,6 +14,122 @@ > > > > */ > > > > #define I2C_ADDR 0x69 > > > > +static const struct dw_hdmi_mpll_config sun50i_h6_mpll_cfg[] = { > > How did you choose the pixel clock points for this table? The values > sort of match up with the BSP. I used this script: https://chromium.googlesource.com/chromiumos/platform/drm-tests/+/master/ rk3288_hdmitables.py I forgot already how I came to conclusion that there are identical register settings. After all, imx6 manual describes DWC HDMI PHY and it seems that settings are identical for DWC HDMI PHY contained in imx6, rk3288 and h6. Check out that script, it has some explanation how values are calculated. Part of the reason why I didn't use original settings is that it is pain to convert BSP PHY settings table to this form. Not all frequencies have settings for 8, 10 and 12 bit depth. > > > + { > > + 30666000, { > > + { 0x00b3, 0x0000 }, > > + { 0x2153, 0x0000 }, > > + { 0x40f3, 0x0000 }, > > + }, > > + }, { > > + 36800000, { > > + { 0x00b3, 0x0000 }, > > + { 0x2153, 0x0000 }, > > + { 0x40a2, 0x0001 }, > > + }, > > + }, { > > + 46000000, { > > + { 0x00b3, 0x0000 }, > > + { 0x2142, 0x0001 }, > > + { 0x40a2, 0x0001 }, > > + }, > > + }, { > > + 61333000, { > > + { 0x0072, 0x0001 }, > > + { 0x2142, 0x0001 }, > > + { 0x40a2, 0x0001 }, > > + }, > > + }, { > > + 73600000, { > > + { 0x0072, 0x0001 }, > > + { 0x2142, 0x0001 }, > > + { 0x4061, 0x0002 }, > > + }, > > + }, { > > + 92000000, { > > + { 0x0072, 0x0001 }, > > + { 0x2145, 0x0002 }, > > + { 0x4061, 0x0002 }, > > + }, > > + }, { > > + 122666000, { > > + { 0x0051, 0x0002 }, > > + { 0x2145, 0x0002 }, > > + { 0x4061, 0x0002 }, > > + }, > > + }, { > > + 147200000, { > > + { 0x0051, 0x0002 }, > > + { 0x2145, 0x0002 }, > > + { 0x4064, 0x0003 }, > > + }, > > + }, { > > + 184000000, { > > + { 0x0051, 0x0002 }, > > + { 0x214c, 0x0003 }, > > + { 0x4064, 0x0003 }, > > + }, > > + }, { > > + 226666000, { > > + { 0x0040, 0x0003 }, > > + { 0x214c, 0x0003 }, > > + { 0x4064, 0x0003 }, > > + }, > > + }, { > > + 272000000, { > > + { 0x0040, 0x0003 }, > > + { 0x214c, 0x0003 }, > > + { 0x5a64, 0x0003 }, > > + }, > > + }, { > > + 340000000, { > > + { 0x0040, 0x0003 }, > > + { 0x3b4c, 0x0003 }, > > + { 0x5a64, 0x0003 }, > > + }, > > + }, { > > + 600000000, { > > 594000000 is the proper clock rate. > > > + { 0x1a40, 0x0003 }, > > + { 0x3b4c, 0x0003 }, > > + { 0x5a64, 0x0003 }, > > + }, > > + }, { > > + ~0UL, { > > + { 0x0000, 0x0000 }, > > + { 0x0000, 0x0000 }, > > + { 0x0000, 0x0000 }, > > + }, > > + } > > +}; > > + > > +static const struct dw_hdmi_curr_ctrl sun50i_h6_cur_ctr[] = { > > The BSP sometimes uses different settings depending on the pixel repetition. > Any ideas about this? I assume it's because the TMDS clock changes as a > result of pixel repetition, as is the same with different bit depths. No, no idea. As I said before, I went easy way out using script mentioned before. > > + /* pixelclk bpp8 bpp10 bpp12 */ > > + { 25175000, { 0x0000, 0x0000, 0x0000 }, }, > > + { 27000000, { 0x0012, 0x0000, 0x0000 }, }, > > + { 59400000, { 0x0008, 0x0008, 0x0008 }, }, > > + { 72000000, { 0x0008, 0x0008, 0x001b }, }, > > + { 74250000, { 0x0013, 0x0013, 0x0013 }, }, > > + { 90000000, { 0x0008, 0x001a, 0x001b }, }, > > + { 118800000, { 0x001b, 0x001a, 0x001b }, }, > > + { 144000000, { 0x001b, 0x001a, 0x0034 }, }, > > + { 180000000, { 0x001b, 0x0033, 0x0034 }, }, > > + { 216000000, { 0x0036, 0x0033, 0x0034 }, }, > > + { 237600000, { 0x0036, 0x0033, 0x001b }, }, > > + { 288000000, { 0x0036, 0x001b, 0x001b }, }, > > + { 297000000, { 0x0019, 0x001b, 0x0019 }, }, > > + { 330000000, { 0x0036, 0x001b, 0x001b }, }, > > + { 600000000, { 0x003f, 0x001b, 0x001b }, }, > > + { ~0UL, { 0x0000, 0x0000, 0x0000 }, } > > +}; > > + > > +static const struct dw_hdmi_phy_config sun50i_h6_phy_config[] = { > > + /*pixelclk symbol term vlev*/ > > I see a slightly different setting for 27000000, and this frequency > below 74250000 > only, and even different for all three bit depths (not listed here). So: > > { 25175000, 0x8009, 0x0004, 0x0232 }, > { 27000000, 0x8009, 0x0007, 0x02b0 }, > > And, > > > + { 74250000, 0x8009, 0x0004, 0x0232}, > > + { 148500000, 0x8029, 0x0004, 0x0273}, > > These two don't match what I see in the BSP. BTW, which table did you use? > phy301 or phy303? The code seems to indicate that model 301 is the one. > yes, BSP uses 301. Best regards, Jernej > > + { 600000000, 0x8039, 0x0004, 0x014a}, > > 594000000 is the proper pixel clock you're after. > > > + { ~0UL, 0x0000, 0x0000, 0x0000} > > +}; > > + > > > > static int sun8i_hdmi_phy_config_a83t(struct dw_hdmi *hdmi, > > > > struct sun8i_hdmi_phy *phy, > > unsigned int clk_rate) > > > > @@ -290,6 +406,16 @@ static void sun8i_hdmi_phy_unlock(struct > > sun8i_hdmi_phy *phy)> > > SUN8I_HDMI_PHY_UNSCRAMBLE_MAGIC); > > > > } > > > > +static void sun50i_hdmi_phy_init_h6(struct sun8i_hdmi_phy *phy) > > +{ > > + regmap_update_bits(phy->regs, SUN8I_HDMI_PHY_REXT_CTRL_REG, > > + SUN8I_HDMI_PHY_REXT_CTRL_REXT_EN, > > + SUN8I_HDMI_PHY_REXT_CTRL_REXT_EN); > > + > > + regmap_update_bits(phy->regs, SUN8I_HDMI_PHY_REXT_CTRL_REG, > > + 0xffff0000, 0x80c00000); > > +} > > + > > > > static void sun8i_hdmi_phy_init_a83t(struct sun8i_hdmi_phy *phy) > > { > > > > sun8i_hdmi_phy_unlock(phy); > > > > @@ -423,6 +549,13 @@ static const struct sun8i_hdmi_phy_variant > > sun50i_a64_hdmi_phy = {> > > .phy_config = &sun8i_hdmi_phy_config_h3, > > > > }; > > > > +static const struct sun8i_hdmi_phy_variant sun50i_h6_hdmi_phy = { > > + .cur_ctr = sun50i_h6_cur_ctr, > > + .mpll_cfg = sun50i_h6_mpll_cfg, > > + .phy_cfg = sun50i_h6_phy_config, > > + .phy_init = &sun50i_hdmi_phy_init_h6, > > +}; > > + > > > > static const struct sun8i_hdmi_phy_variant sun8i_a83t_hdmi_phy = { > > > > .is_custom_phy = true, > > .phy_init = &sun8i_hdmi_phy_init_a83t, > > > > @@ -443,6 +576,10 @@ static const struct of_device_id > > sun8i_hdmi_phy_of_table[] = {> > > .compatible = "allwinner,sun50i-a64-hdmi-phy", > > .data = &sun50i_a64_hdmi_phy, > > > > }, > > > > + { > > + .compatible = "allwinner,sun50i-h6-hdmi-phy", > > + .data = &sun50i_h6_hdmi_phy, > > + }, > > Version sort please. > > Regards > ChenYu > > > { > > > > .compatible = "allwinner,sun8i-a83t-hdmi-phy", > > .data = &sun8i_a83t_hdmi_phy, > > > > -- > > 2.18.0 > > On Sun, Sep 2, 2018 at 3:28 PM Jernej Skrabec wrote: > > H6 has Synopsys DWC HDMI 2.0 TX PHY. > > > > mpll settings were calculated from specifications of similar Synopsys > > HDMI PHY found in i.MX6. Other PHY settings were derived from BSP PHY > > driver code. > > > > Signed-off-by: Jernej Skrabec > > --- > > > > drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c | 137 +++++++++++++++++++++++++ > > 1 file changed, 137 insertions(+) > > > > diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > > b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c index ee2bf61cd4d2..2f5499bd35ec > > 100644 > > --- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > > +++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c > > @@ -14,6 +14,122 @@ > > > > */ > > > > #define I2C_ADDR 0x69 > > > > +static const struct dw_hdmi_mpll_config sun50i_h6_mpll_cfg[] = { > > + { > > + 30666000, { > > + { 0x00b3, 0x0000 }, > > + { 0x2153, 0x0000 }, > > + { 0x40f3, 0x0000 }, > > + }, > > + }, { > > + 36800000, { > > + { 0x00b3, 0x0000 }, > > + { 0x2153, 0x0000 }, > > + { 0x40a2, 0x0001 }, > > + }, > > + }, { > > + 46000000, { > > + { 0x00b3, 0x0000 }, > > + { 0x2142, 0x0001 }, > > + { 0x40a2, 0x0001 }, > > + }, > > + }, { > > + 61333000, { > > + { 0x0072, 0x0001 }, > > + { 0x2142, 0x0001 }, > > + { 0x40a2, 0x0001 }, > > + }, > > + }, { > > + 73600000, { > > + { 0x0072, 0x0001 }, > > + { 0x2142, 0x0001 }, > > + { 0x4061, 0x0002 }, > > + }, > > + }, { > > + 92000000, { > > + { 0x0072, 0x0001 }, > > + { 0x2145, 0x0002 }, > > + { 0x4061, 0x0002 }, > > + }, > > + }, { > > + 122666000, { > > + { 0x0051, 0x0002 }, > > + { 0x2145, 0x0002 }, > > + { 0x4061, 0x0002 }, > > + }, > > + }, { > > + 147200000, { > > + { 0x0051, 0x0002 }, > > + { 0x2145, 0x0002 }, > > + { 0x4064, 0x0003 }, > > + }, > > + }, { > > + 184000000, { > > + { 0x0051, 0x0002 }, > > + { 0x214c, 0x0003 }, > > + { 0x4064, 0x0003 }, > > + }, > > + }, { > > + 226666000, { > > + { 0x0040, 0x0003 }, > > + { 0x214c, 0x0003 }, > > + { 0x4064, 0x0003 }, > > + }, > > + }, { > > + 272000000, { > > + { 0x0040, 0x0003 }, > > + { 0x214c, 0x0003 }, > > + { 0x5a64, 0x0003 }, > > + }, > > + }, { > > + 340000000, { > > + { 0x0040, 0x0003 }, > > + { 0x3b4c, 0x0003 }, > > + { 0x5a64, 0x0003 }, > > + }, > > + }, { > > + 600000000, { > > + { 0x1a40, 0x0003 }, > > + { 0x3b4c, 0x0003 }, > > + { 0x5a64, 0x0003 }, > > + }, > > + }, { > > + ~0UL, { > > + { 0x0000, 0x0000 }, > > + { 0x0000, 0x0000 }, > > + { 0x0000, 0x0000 }, > > + }, > > + } > > +}; > > + > > +static const struct dw_hdmi_curr_ctrl sun50i_h6_cur_ctr[] = { > > + /* pixelclk bpp8 bpp10 bpp12 */ > > + { 25175000, { 0x0000, 0x0000, 0x0000 }, }, > > + { 27000000, { 0x0012, 0x0000, 0x0000 }, }, > > + { 59400000, { 0x0008, 0x0008, 0x0008 }, }, > > + { 72000000, { 0x0008, 0x0008, 0x001b }, }, > > + { 74250000, { 0x0013, 0x0013, 0x0013 }, }, > > + { 90000000, { 0x0008, 0x001a, 0x001b }, }, > > + { 118800000, { 0x001b, 0x001a, 0x001b }, }, > > + { 144000000, { 0x001b, 0x001a, 0x0034 }, }, > > + { 180000000, { 0x001b, 0x0033, 0x0034 }, }, > > + { 216000000, { 0x0036, 0x0033, 0x0034 }, }, > > + { 237600000, { 0x0036, 0x0033, 0x001b }, }, > > + { 288000000, { 0x0036, 0x001b, 0x001b }, }, > > + { 297000000, { 0x0019, 0x001b, 0x0019 }, }, > > + { 330000000, { 0x0036, 0x001b, 0x001b }, }, > > + { 600000000, { 0x003f, 0x001b, 0x001b }, }, > > + { ~0UL, { 0x0000, 0x0000, 0x0000 }, } > > +}; > > + > > +static const struct dw_hdmi_phy_config sun50i_h6_phy_config[] = { > > + /*pixelclk symbol term vlev*/ > > + { 74250000, 0x8009, 0x0004, 0x0232}, > > + { 148500000, 0x8029, 0x0004, 0x0273}, > > + { 600000000, 0x8039, 0x0004, 0x014a}, > > + { ~0UL, 0x0000, 0x0000, 0x0000} > > +}; > > + > > > > static int sun8i_hdmi_phy_config_a83t(struct dw_hdmi *hdmi, > > > > struct sun8i_hdmi_phy *phy, > > unsigned int clk_rate) > > > > @@ -290,6 +406,16 @@ static void sun8i_hdmi_phy_unlock(struct > > sun8i_hdmi_phy *phy)> > > SUN8I_HDMI_PHY_UNSCRAMBLE_MAGIC); > > > > } > > > > +static void sun50i_hdmi_phy_init_h6(struct sun8i_hdmi_phy *phy) > > +{ > > + regmap_update_bits(phy->regs, SUN8I_HDMI_PHY_REXT_CTRL_REG, > > + SUN8I_HDMI_PHY_REXT_CTRL_REXT_EN, > > + SUN8I_HDMI_PHY_REXT_CTRL_REXT_EN); > > + > > + regmap_update_bits(phy->regs, SUN8I_HDMI_PHY_REXT_CTRL_REG, > > + 0xffff0000, 0x80c00000); > > +} > > + > > > > static void sun8i_hdmi_phy_init_a83t(struct sun8i_hdmi_phy *phy) > > { > > > > sun8i_hdmi_phy_unlock(phy); > > > > @@ -423,6 +549,13 @@ static const struct sun8i_hdmi_phy_variant > > sun50i_a64_hdmi_phy = {> > > .phy_config = &sun8i_hdmi_phy_config_h3, > > > > }; > > > > +static const struct sun8i_hdmi_phy_variant sun50i_h6_hdmi_phy = { > > + .cur_ctr = sun50i_h6_cur_ctr, > > + .mpll_cfg = sun50i_h6_mpll_cfg, > > + .phy_cfg = sun50i_h6_phy_config, > > + .phy_init = &sun50i_hdmi_phy_init_h6, > > +}; > > + > > > > static const struct sun8i_hdmi_phy_variant sun8i_a83t_hdmi_phy = { > > > > .is_custom_phy = true, > > .phy_init = &sun8i_hdmi_phy_init_a83t, > > > > @@ -443,6 +576,10 @@ static const struct of_device_id > > sun8i_hdmi_phy_of_table[] = {> > > .compatible = "allwinner,sun50i-a64-hdmi-phy", > > .data = &sun50i_a64_hdmi_phy, > > > > }, > > > > + { > > + .compatible = "allwinner,sun50i-h6-hdmi-phy", > > + .data = &sun50i_h6_hdmi_phy, > > + }, > > > > { > > > > .compatible = "allwinner,sun8i-a83t-hdmi-phy", > > .data = &sun8i_a83t_hdmi_phy, > > > > -- > > 2.18.0