Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8810575imu; Tue, 4 Dec 2018 14:45:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/XeIEGz9UWmkp1xuR89HucA2jPpzCK/8HFgpadIFVOzS15ijdHqtC5EVMKSmN1BJErrN2hu X-Received: by 2002:a62:e201:: with SMTP id a1mr21474966pfi.75.1543963532045; Tue, 04 Dec 2018 14:45:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543963532; cv=none; d=google.com; s=arc-20160816; b=WlcN57lSX7JyLbXDuBr3jQeoNV8D7h6IsOblIvWkPLJ4hD1DWkESfk2Hokgo/fHGYq RXY2QJ/Hyxvz/O1emsxetYolA5WRH5KzT1lFLZyLhIG5WdS8X9ExENPDCFe25QBntl49 8WxqMNLQtbPcotMe/gN0iE13TXCVR29m2e5PMtukinseuHOuJjm+3gXt0WhWg84udid4 NM4XzmClI5GhL1G+DQ1VrLxtDYNNra7Z9Z8Li/NYpRi82Y5TjOR3VpHPwg2HubpvGgaW V0KIH7Vw+/UYllwlcm9u5I1ekugl/vf5mSNX63YMV3qMGE/NB/Nz64cN0tCFQPjxYDZS 9Wpw== 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=jcsSgVishubggGNytYKHnyWfllvca0P0GPDK9c5rNNg=; b=P4V939OGqsy1ZfSPkMx8Xx4TXW4N8TayjBOHRRfHDzQVk4eNYVoIuBp+910QmtQqMA IEl+rYpNhkSdU9cM5lgqnqy8Lpk6GZBYEfmPFa2vAJt+r8OO3zs+vV+zNoiW2ReZETVj GTSjpF4t6lMPyPvICGs9BUZ92AcPwFcXKuaRfaP7DW9epbyBRNgDD2Uw2YRdGN91Ijaz doN9ljdJ3lht3VGVt4ZSZJyN3x8n0zALabpOBITCCF5+SY/Pzl+4QNotpp/CnmEN3n/S QeAen7U+5oAu8fDlQGKqjjCP8xJVwzBmZTIePcldpOomgzfOA8rZMWP9ATj2ubSvFMw6 EyeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=A8bICMI+; 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 g9si19503000plb.54.2018.12.04.14.45.16; Tue, 04 Dec 2018 14:45:32 -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=@chromium.org header.s=google header.b=A8bICMI+; 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 S1726788AbeLDWn5 (ORCPT + 99 others); Tue, 4 Dec 2018 17:43:57 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39291 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbeLDWnR (ORCPT ); Tue, 4 Dec 2018 17:43:17 -0500 Received: by mail-pg1-f195.google.com with SMTP id w6so8030287pgl.6 for ; Tue, 04 Dec 2018 14:43:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jcsSgVishubggGNytYKHnyWfllvca0P0GPDK9c5rNNg=; b=A8bICMI+a90oeM8ADbb4djwlv6/Na/7hSIdAqG5jUf8U2eYCIOg2/Ygz5CFFuRyMl6 7uVQNxbNWVYX0CBqLVZ+tH9sluO8UCsQCRjKdbwvqOgmgzb6f3d49924gE7BUjKG5f5n xgmoKPdDlNnmNUKjAIy6Ecp2v5L/oggaCbRtw= 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=jcsSgVishubggGNytYKHnyWfllvca0P0GPDK9c5rNNg=; b=fx7Y9VMvNvsYfHF1zInDZetbD6tzHRKJbr0gSVODIk3jV0oaJRNBWjJXRW2SPSf0kq 4rohE+2wc0naOGOrT9biuGUkMTIH7PqfLi0WgtNn+60Kgx0KVq7hwjdsc7YRglOSaCOP Hvgi87m+wPIVC813VABn3fgk3piijgnui6CjJvQvSfO0cmMOdOJpGazRLTfC7/YX21qY 6PAdfqGh0fVJZgwRufAaasKcq1mNLwkjwuvynjHjBJJvn4UZTq7y+lJkO2CoGh+Cq25R vcqoGd4vz0Ys+o2PbyijQfEznDvyJ2SKCn/ubuU2jGKcTHySGiR1cT8JsJ1xm6gPP6yt EE5A== X-Gm-Message-State: AA+aEWaDGgRoSeyO0UNab59BDSEzEo5mWN/AHCGGvaW1pWUAIXQY5Fu1 ratxU8VD0tEF7bBeIMCw3pDmHg== X-Received: by 2002:a62:7c47:: with SMTP id x68mr22197205pfc.209.1543963396303; Tue, 04 Dec 2018 14:43:16 -0800 (PST) Received: from mka.mtv.corp.google.com ([2620:15c:202:1:b6af:f85:ed6c:ac6a]) by smtp.gmail.com with ESMTPSA id y184sm21961917pgd.71.2018.12.04.14.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 14:43:15 -0800 (PST) From: Matthias Kaehlcke To: Rob Clark , David Airlie , Rob Herring , Mark Rutland , Andy Gross , David Brown Cc: Archit Taneja , Sean Paul , Rajesh Yadav , Douglas Anderson , Stephen Boyd , Jeykumar Sankaran , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Matthias Kaehlcke Subject: [PATCH v4 3/8] drm/msm/dsi: 28nm PHY: Get ref clock from the DT Date: Tue, 4 Dec 2018 14:42:29 -0800 Message-Id: <20181204224234.62619-4-mka@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog In-Reply-To: <20181204224234.62619-1-mka@chromium.org> References: <20181204224234.62619-1-mka@chromium.org> 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 Get the ref clock of the PHY from the device tree instead of hardcoding its name and rate. Signed-off-by: Matthias Kaehlcke --- Changes in v4: - always use parent rate in dsi_pll_28nm_clk_set_rate() and dsi_pll_28nm_clk_recalc_rate() - pass name of VCO ref clock to pll_28nm_register() instead of storing it in a struct field - updated commit message Changes in v3: - use default name and rate if the ref clock is not specified in the DT - store vco_ref_clk_name instead of vco_ref_clk - dsi_pll_28nm_clk_set_rate: changed data type of ref_clk_rate to unsigned long - fixed check for EPROBE_DEFER - renamed VCO_REF_CLK_RATE to VCO_REF_CLK_DEFAULT_RATE Changes in v2: - patch added to the series --- drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c | 36 +++++++++++++++------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c index 26e3a01a99c2b..7777340b03e8d 100644 --- a/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c +++ b/drivers/gpu/drm/msm/dsi/pll/dsi_pll_28nm.c @@ -40,7 +40,6 @@ #define NUM_PROVIDED_CLKS 2 -#define VCO_REF_CLK_RATE 19200000 #define VCO_MIN_RATE 350000000 #define VCO_MAX_RATE 750000000 @@ -166,17 +165,17 @@ static int dsi_pll_28nm_clk_set_rate(struct clk_hw *hw, unsigned long rate, pll_write(base + REG_DSI_28nm_PHY_PLL_LPFC1_CFG, 0x70); pll_write(base + REG_DSI_28nm_PHY_PLL_LPFC2_CFG, 0x15); - rem = rate % VCO_REF_CLK_RATE; + rem = rate % parent_rate; if (rem) { refclk_cfg = DSI_28nm_PHY_PLL_REFCLK_CFG_DBLR; frac_n_mode = 1; - div_fbx1000 = rate / (VCO_REF_CLK_RATE / 500); - gen_vco_clk = div_fbx1000 * (VCO_REF_CLK_RATE / 500); + div_fbx1000 = rate / (parent_rate / 500); + gen_vco_clk = div_fbx1000 * (parent_rate / 500); } else { refclk_cfg = 0x0; frac_n_mode = 0; - div_fbx1000 = rate / (VCO_REF_CLK_RATE / 1000); - gen_vco_clk = div_fbx1000 * (VCO_REF_CLK_RATE / 1000); + div_fbx1000 = rate / (parent_rate / 1000); + gen_vco_clk = div_fbx1000 * (parent_rate / 1000); } DBG("refclk_cfg = %d", refclk_cfg); @@ -265,7 +264,7 @@ static unsigned long dsi_pll_28nm_clk_recalc_rate(struct clk_hw *hw, void __iomem *base = pll_28nm->mmio; u32 sdm0, doubler, sdm_byp_div; u32 sdm_dc_off, sdm_freq_seed, sdm2, sdm3; - u32 ref_clk = VCO_REF_CLK_RATE; + u32 ref_clk = parent_rate; unsigned long vco_rate; VERB("parent_rate=%lu", parent_rate); @@ -273,7 +272,7 @@ static unsigned long dsi_pll_28nm_clk_recalc_rate(struct clk_hw *hw, /* Check to see if the ref clk doubler is enabled */ doubler = pll_read(base + REG_DSI_28nm_PHY_PLL_REFCLK_CFG) & DSI_28nm_PHY_PLL_REFCLK_CFG_DBLR; - ref_clk += (doubler * VCO_REF_CLK_RATE); + ref_clk += (doubler * ref_clk); /* see if it is integer mode or sdm mode */ sdm0 = pll_read(base + REG_DSI_28nm_PHY_PLL_SDM_CFG0); @@ -514,11 +513,12 @@ static void dsi_pll_28nm_destroy(struct msm_dsi_pll *pll) pll_28nm->clk_data.clk_num = 0; } -static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm) +static int pll_28nm_register(struct dsi_pll_28nm *pll_28nm, + const char *ref_clk_name) { char clk_name[32], parent1[32], parent2[32], vco_name[32]; struct clk_init_data vco_init = { - .parent_names = (const char *[]){ "xo" }, + .parent_names = &ref_clk_name, .num_parents = 1, .name = vco_name, .flags = CLK_IGNORE_UNUSED, @@ -593,6 +593,8 @@ struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev, { struct dsi_pll_28nm *pll_28nm; struct msm_dsi_pll *pll; + struct clk *vco_ref_clk; + const char *vco_ref_clk_name; int ret; if (!pdev) @@ -605,6 +607,18 @@ struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev, pll_28nm->pdev = pdev; pll_28nm->id = id; + vco_ref_clk = devm_clk_get(&pdev->dev, "ref"); + if (!IS_ERR(vco_ref_clk)) { + vco_ref_clk_name = __clk_get_name(vco_ref_clk); + } else { + ret = PTR_ERR(vco_ref_clk); + if (ret == -EPROBE_DEFER) + ERR_PTR(ret); + + dev_warn(&pdev->dev, "'ref' clock is not specified, using default name\n"); + vco_ref_clk_name = "xo"; + } + pll_28nm->mmio = msm_ioremap(pdev, "dsi_pll", "DSI_PLL"); if (IS_ERR_OR_NULL(pll_28nm->mmio)) { dev_err(&pdev->dev, "%s: failed to map pll base\n", __func__); @@ -637,7 +651,7 @@ struct msm_dsi_pll *msm_dsi_pll_28nm_init(struct platform_device *pdev, return ERR_PTR(-EINVAL); } - ret = pll_28nm_register(pll_28nm); + ret = pll_28nm_register(pll_28nm, vco_ref_clk_name); if (ret) { dev_err(&pdev->dev, "failed to register PLL: %d\n", ret); return ERR_PTR(ret); -- 2.20.0.rc1.387.gf8505762e3-goog