Received: by 10.223.164.221 with SMTP id h29csp1486395wrb; Wed, 25 Oct 2017 00:57:58 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QxdkJXlOIz2sWsM4XgAD46aHfdoixlIhZno6yTs/FH3Nohz8FJ6qwaAMzNEWHcjA5uuE21 X-Received: by 10.99.166.18 with SMTP id t18mr1239158pge.403.1508918278597; Wed, 25 Oct 2017 00:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508918278; cv=none; d=google.com; s=arc-20160816; b=z07D5EgtdT9pN6jMV3zuDdXqJuxaGrVJCeLxzQVbjk43Wp+K7p6dTeXdcgOP/Lucr4 hbvyGXs4sKYXNPIXSrYWp0s4HokGdiaD4m3dWvFYoYewJiGobvo6HoDjy/ymJRWrsN4X 9OTuZsPahj7aSUl4x6usNOGkDJqKIwo8U1B1R1AmOdGwL8ia1qHsbcpwq88DDlnpptDT cYJA1woyNqvhVE7jpxe7MVrrs+6TEFCoHpOJ9+29KibDEL/BI8Nhj7HPbifmAzt+ChIj QklJtRTEoYv9f7dL+hAMGObGx+F5BkffpdzPn5dNxuT4muU7eVsPMS+pyQ6MJRqqqdTB XZbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=RZu2dLZ6Trz6hyi4tJCzyQ4M1EaJ07eT4ipIdoMWqsg=; b=QW+sHVNETUuUDDgPG3/n1BExpWrFmiD7xw1v5qizCoPkduuWDoFSsj+Go2JJ08Bcmg R4k6o/DKHcvzgA8jbpXRaiteVkFoo5yVfRj32IUZWHbhQD8R/J84Pkg5QOoIorDGuzo9 ZzsYCxxzJ7OUqusCXnn/eaBDqoXYDBLWxkDMBsYUcHGpo28A+NJFy2hFnMEE5QAGCzgw QhEEjNnc3nrDmF8RHHslgs35M/jdnP6QpvNfiGH0OCWdZlbSSaNgEsTmRsHTVim6IRDZ 6XI6URl9X/LAN1fuJFjsKZsD19DJdVKXVU6DTL5CCDDkV8Pvl0NaJS5iQraeHsTL7fDD PxqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XNTZyeDu; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w189si1460467pgd.176.2017.10.25.00.57.43; Wed, 25 Oct 2017 00:57:58 -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; dkim=pass header.i=@chromium.org header.s=google header.b=XNTZyeDu; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932184AbdJYH5X (ORCPT + 99 others); Wed, 25 Oct 2017 03:57:23 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:52930 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751696AbdJYH5W (ORCPT ); Wed, 25 Oct 2017 03:57:22 -0400 Received: by mail-wr0-f193.google.com with SMTP id k62so22999673wrc.9 for ; Wed, 25 Oct 2017 00:57:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=RZu2dLZ6Trz6hyi4tJCzyQ4M1EaJ07eT4ipIdoMWqsg=; b=XNTZyeDuthv9fwdLbP65z9KpsIIKNcuxk5W01OeVoN8m/ziU+UlbQ4yn2FD3sB1jBF QOwlAi16lh+GwPPiSWEossCTpjBanH5XkPfziFzCpWZXbUxCUVUoKMSzorDij5n5xbof eJquOmgCCZniGcIYnrKSP2/BEuFSzyyUeJnME= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=RZu2dLZ6Trz6hyi4tJCzyQ4M1EaJ07eT4ipIdoMWqsg=; b=RmzVG9Jh81rtXM6aNlMrXol/x2dkXfKT/UrEF0QackZImq+EkwQXpP+VDgVbzGNCoC r+hUEORzEysUyvq7Vh2PtjYS86NFNVBs1SZ5fuXMAwQL4uqr1QdZsUfOkO35THsM/7OW P6a06nfmKIU2FuStwf6wgTCrEAEzBEgI/q3deqQbyOs2y1eEbxHu8ixMVajmS0d3WOcz SEjXKUYhpX1oKDKgTqSHsB6WTyNTtkA8uK+DRAzxTfLoHtTxCBd7MkCnas1a6NyUn+k3 BWDyXLi3ctTzq0ZqdcZ/fBZfCv8jk9l90COUnClLAiFE5sD9Mwa7DEhBDqae99NqRHh0 VQkA== X-Gm-Message-State: AMCzsaUbj7HFE6LeKHAiqcxFSU5X0OcNJDLJaYLrzhe+kG8Vfulhe+qn pKiqVu+q+lxAzy5luI1gjJjl8Q== X-Received: by 10.223.196.221 with SMTP id o29mr1218820wrf.210.1508918240895; Wed, 25 Oct 2017 00:57:20 -0700 (PDT) Received: from localhost ([62.168.35.107]) by smtp.gmail.com with ESMTPSA id o7sm2567540wrf.31.2017.10.25.00.57.20 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 25 Oct 2017 00:57:20 -0700 (PDT) Date: Wed, 25 Oct 2017 03:57:19 -0400 From: Sean Paul To: Nickey Yang Cc: mark.yao@rock-chips.com, robh+dt@kernel.org, heiko@sntech.de, mark.rutland@arm.com, airlied@linux.ie, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, seanpaul@chromium.org, briannorris@chromium.org, hl@rock-chips.com, zyw@rock-chips.comg, xbl@rock-chips.com, Kristian Kristensen , Archit Taneja Subject: Re: [PATCH v3 3/6] drm/rockchip/dsi: correct Feedback divider setting Message-ID: <20171025075719.4tt7lomec5x7guon@art_vandelay> References: <1508903463-7254-1-git-send-email-nickey.yang@rock-chips.com> <1508903463-7254-3-git-send-email-nickey.yang@rock-chips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1508903463-7254-3-git-send-email-nickey.yang@rock-chips.com> User-Agent: NeoMutt/20170306-97-7656f1-dirty (1.8.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 25, 2017 at 11:51:00AM +0800, Nickey Yang wrote: > This patch correct Feedback divider setting: > 1、Set Feedback divider [8:5] when HIGH_PROGRAM_EN > 2、Due to the use of a "by 2 pre-scaler," the range of the > feedback multiplication Feedback divider is limited to even > division numbers, and Feedback divider must be greater than > 12, less than 1000. > 3、Make the previously configured Feedback divider(LSB) > factors effective > > Signed-off-by: Nickey Yang > --- You don't list the changes between this version and the previous ones, so I looked at the feedback from the last time. Archit asked a question about moving to dw-mipi-dsi, and Kristian asked you to split the patch for each line item in the above list. I know you split out the register definitions, but an explanation about why you didn't split the rest would be helpful. In future, list the changes between patches and Cc people who have given you review on your previous versions (I've cc'd Archit and Kristian). Sean > drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 93 ++++++++++++++++++++++------------ > 1 file changed, 62 insertions(+), 31 deletions(-) > > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c > index 09e7bfe..589b420 100644 > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c > @@ -239,7 +239,7 @@ > #define LOW_PROGRAM_EN 0 > #define HIGH_PROGRAM_EN BIT(7) > #define LOOP_DIV_LOW_SEL(val) (((val) - 1) & 0x1f) > -#define LOOP_DIV_HIGH_SEL(val) ((((val) - 1) >> 5) & 0x1f) > +#define LOOP_DIV_HIGH_SEL(val) ((((val) - 1) >> 5) & 0xf) > #define PLL_LOOP_DIV_EN BIT(5) > #define PLL_INPUT_DIV_EN BIT(4) > > @@ -531,6 +531,14 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) > dw_mipi_dsi_phy_write(dsi, PLL_LOOP_DIVIDER_RATIO, > LOOP_DIV_LOW_SEL(dsi->feedback_div) | > LOW_PROGRAM_EN); > + /* > + * we need set PLL_INPUT_AND_LOOP_DIVIDER_RATIOS_CONTROL immediately > + * to make the configrued LSB effective according to IP simulation > + * and lab test results. > + * Only in this way can we get correct mipi phy pll frequency. > + */ > + dw_mipi_dsi_phy_write(dsi, PLL_INPUT_AND_LOOP_DIVIDER_RATIOS_CONTROL, > + PLL_LOOP_DIV_EN | PLL_INPUT_DIV_EN); > dw_mipi_dsi_phy_write(dsi, PLL_LOOP_DIVIDER_RATIO, > LOOP_DIV_HIGH_SEL(dsi->feedback_div) | > HIGH_PROGRAM_EN); > @@ -604,11 +612,16 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) > static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi, > struct drm_display_mode *mode) > { > - unsigned int i, pre; > - unsigned long mpclk, pllref, tmp; > - unsigned int m = 1, n = 1, target_mbps = 1000; > + unsigned long mpclk, tmp; > + unsigned int target_mbps = 1000; > unsigned int max_mbps = dppa_map[ARRAY_SIZE(dppa_map) - 1].max_mbps; > int bpp; > + unsigned long best_freq = 0; > + unsigned long fvco_min, fvco_max, fin, fout; > + unsigned int min_prediv, max_prediv; > + unsigned int _prediv, uninitialized_var(best_prediv); > + unsigned long _fbdiv, uninitialized_var(best_fbdiv); > + unsigned long min_delta = ULONG_MAX; > > bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); > if (bpp < 0) { > @@ -629,35 +642,53 @@ static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi, > "DPHY clock frequency is out of range\n"); > } > > - pllref = DIV_ROUND_UP(clk_get_rate(dsi->pllref_clk), USEC_PER_SEC); > - tmp = pllref; > - > - /* > - * The limits on the PLL divisor are: > - * > - * 5MHz <= (pllref / n) <= 40MHz > - * > - * we walk over these values in descreasing order so that if we hit > - * an exact match for target_mbps it is more likely that "m" will be > - * even. > - * > - * TODO: ensure that "m" is even after this loop. > - */ > - for (i = pllref / 5; i > (pllref / 40); i--) { > - pre = pllref / i; > - if ((tmp > (target_mbps % pre)) && (target_mbps / pre < 512)) { > - tmp = target_mbps % pre; > - n = i; > - m = target_mbps / pre; > + fin = clk_get_rate(dsi->pllref_clk); > + fout = target_mbps * USEC_PER_SEC; > + > + /* constraint: 5Mhz <= Fref / N <= 40MHz */ > + min_prediv = DIV_ROUND_UP(fin, 40 * USEC_PER_SEC); > + max_prediv = fin / (5 * USEC_PER_SEC); > + > + /* constraint: 80MHz <= Fvco <= 1500Mhz */ > + fvco_min = 80 * USEC_PER_SEC; > + fvco_max = 1500 * USEC_PER_SEC; > + > + for (_prediv = min_prediv; _prediv <= max_prediv; _prediv++) { > + u64 tmp; > + u32 delta; > + /* Fvco = Fref * M / N */ > + tmp = (u64)fout * _prediv; > + do_div(tmp, fin); > + _fbdiv = tmp; > + /* > + * Due to the use of a "by 2 pre-scaler," the range of the > + * feedback multiplication value M is limited to even division > + * numbers, and m must be greater than 12, less than 1000. > + */ > + if (_fbdiv <= 12 || _fbdiv >= 1000) > + continue; > + > + _fbdiv += _fbdiv % 2; > + > + tmp = (u64)_fbdiv * fin; > + do_div(tmp, _prediv); > + if (tmp < fvco_min || tmp > fvco_max) > + continue; > + > + delta = abs(fout - tmp); > + if (delta < min_delta) { > + best_prediv = _prediv; > + best_fbdiv = _fbdiv; > + min_delta = delta; > + best_freq = tmp; > } > - if (tmp == 0) > - break; > } > - > - dsi->lane_mbps = pllref / n * m; > - dsi->input_div = n; > - dsi->feedback_div = m; > - > + if (best_freq) { > + dsi->lane_mbps = DIV_ROUND_UP(best_freq, USEC_PER_SEC); > + dsi->input_div = best_prediv; > + dsi->feedback_div = best_fbdiv; > + } else > + DRM_DEV_ERROR(dsi->dev, "Can not find best_freq for DPHY\n"); > return 0; > } > > -- > 1.9.1 > -- Sean Paul, Software Engineer, Google / Chromium OS From 1582200040001158569@xxx Wed Oct 25 03:52:21 +0000 2017 X-GM-THRID: 1582200040001158569 X-Gmail-Labels: Inbox,Category Forums