Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp136696pxf; Wed, 10 Mar 2021 02:28:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0pXZ2/mDvHK64NGZVyO6dHicnAUgos1aWPM1VnXnKZALvkjB5GeaUUkkiRDG8eqa1Lzeq X-Received: by 2002:a17:907:9870:: with SMTP id ko16mr2853200ejc.227.1615372120347; Wed, 10 Mar 2021 02:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615372120; cv=none; d=google.com; s=arc-20160816; b=LnMHmEwI//yp/T1NVzlZxsvbfmt4Am7be5g6GZ0WBmSMWfX7I3Z/Qp6HNvxntD2VmI pHe1DBKT248K6EDYJRU0glWiJoS5F2IkvXtdqdyyq1/Tk+XeXkR8ps8zW1WRKBKWvhA8 QFHybDrCLrLfB/gt4al/LN1Dbfa4rqxbB3/aMxVLhmSjUdcWuzneR+Pt8kfxB3FEgLcZ 0aSXdBpx1+6/ZZawede6NmLx3f1G7Uy0OQQNrpgGUoEnmJV17HHieQqnk1lEkkta5brs GGispX4I0M2hp3VK+WqA9HBtSBqnfkkkVW8EtMHB9yF/9pwRO8Rfm6MM+V1k/YPLxnqv AbAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=i09rXQy/RppMIEWjXFpnoKgIX92U98VUciWg+IgQCcY=; b=u67f3TETEwFStkFa9hS3N87Vachj72hm9dEZymPnrrnozVx0mfB/L1fcy3p0hV20jJ A8v0i3ZsM4nsqxCQzGaQj0M8qZuFiYLD4WtOIMhmnGi7oI6+HtKq9bNlshLzpz0bJa/9 4M4eqjrFueizq+1ehMcVF3RXaHD5U6l0vzZgVXJp8FkAQ3cYiBCX/r9gM8BIoE75GgKv nWU4pqhaAPa2QZxWskNYJ3yOitWc8gS+UqULqHlpDiUXNw4TtFu9oyvbSXyAhzZ8WE// jnGonVHX3zzESVI0CTvYn0zv+r3cQb+Gr3fGic2JOnDFx3Cae0OrJ92uSshsXDBhgn39 GKuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Dow2EYJa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si11017356ejj.133.2021.03.10.02.28.17; Wed, 10 Mar 2021 02:28:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Dow2EYJa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232425AbhCJKZD (ORCPT + 99 others); Wed, 10 Mar 2021 05:25:03 -0500 Received: from fllv0015.ext.ti.com ([198.47.19.141]:52310 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232049AbhCJKYp (ORCPT ); Wed, 10 Mar 2021 05:24:45 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 12AAOVmB127513; Wed, 10 Mar 2021 04:24:31 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1615371871; bh=i09rXQy/RppMIEWjXFpnoKgIX92U98VUciWg+IgQCcY=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=Dow2EYJaRA2Rl8750jd7BObGVy3xIjKkJ6szsmnmPRlHSXguG6kjUkduGa+Vks4jm Mw66qzJjIs/L76LJhnZhKsaZPy4397ICBMeyf2ZUKpHAteyKVqOQIZkYtxRFT/O+WJ 582jgrIkOJtV2Oi3Y3a5fW51Udfd8L7gehMDANG4= Received: from DLEE106.ent.ti.com (dlee106.ent.ti.com [157.170.170.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 12AAOV07013901 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Mar 2021 04:24:31 -0600 Received: from DLEE109.ent.ti.com (157.170.170.41) by DLEE106.ent.ti.com (157.170.170.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 10 Mar 2021 04:24:30 -0600 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE109.ent.ti.com (157.170.170.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Wed, 10 Mar 2021 04:24:30 -0600 Received: from [10.250.234.4] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 12AAOR52115402; Wed, 10 Mar 2021 04:24:28 -0600 Subject: Re: [PATCH v2 9/9] phy: cadence-torrent: Add support to drive refclk out To: Swapnil Kashinath Jakhade , Vinod Koul , Rob Herring , Peter Rosin CC: "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-phy@lists.infradead.org" References: <20210222112314.10772-1-kishon@ti.com> <20210222112314.10772-10-kishon@ti.com> From: Kishon Vijay Abraham I Message-ID: Date: Wed, 10 Mar 2021 15:54:27 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Swapnil, On 09/03/21 7:51 pm, Swapnil Kashinath Jakhade wrote: > Hi Kishon, > >> -----Original Message----- >> From: Kishon Vijay Abraham I >> Sent: Monday, February 22, 2021 4:53 PM >> To: Kishon Vijay Abraham I ; Vinod Koul >> ; Rob Herring ; Peter Rosin >> ; Swapnil Kashinath Jakhade >> Cc: linux-kernel@vger.kernel.org; devicetree@vger.kernel.org; linux- >> phy@lists.infradead.org >> Subject: [PATCH v2 9/9] phy: cadence-torrent: Add support to drive refclk out >> >> EXTERNAL MAIL >> >> >> cmn_refclk_

lines in Torrent SERDES is used for connecting external >> reference clock. cmn_refclk_

can also be configured to output the >> reference clock. Model this derived reference clock as a "clock" so that >> platforms like AM642 EVM can enable it. >> >> This is used by PCIe to use the same refclk both in local SERDES >> and remote device. Add support here to drive refclk out. >> >> Signed-off-by: Kishon Vijay Abraham I >> --- >> drivers/phy/cadence/phy-cadence-torrent.c | 202 +++++++++++++++++++++- >> 1 file changed, 199 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c >> b/drivers/phy/cadence/phy-cadence-torrent.c >> index f310e15d94cb..07eebdd90d4b 100644 >> --- a/drivers/phy/cadence/phy-cadence-torrent.c >> +++ b/drivers/phy/cadence/phy-cadence-torrent.c >> @@ -7,7 +7,9 @@ >> */ >> >> #include >> +#include >> #include >> +#include >> #include >> #include >> #include >> @@ -76,6 +78,8 @@ >> * register offsets from SD0801 PHY register block base (i.e MHDP >> * register base + 0x500000) >> */ >> +#define CMN_CDIAG_REFCLK_OVRD 0x004CU >> +#define CMN_CDIAG_REFCLK_DRV0_CTRL 0x0050U > > Nitpick, this can be added sequentially. > >> #define CMN_SSM_BANDGAP_TMR 0x0021U >> #define CMN_SSM_BIAS_TMR 0x0022U >> #define CMN_PLLSM0_PLLPRE_TMR 0x002AU >> @@ -206,6 +210,8 @@ >> #define RX_DIAG_ACYA 0x01FFU >> >> /* PHY PCS common registers */ >> +#define PHY_PIPE_CMN_CTRL1 0x0000U >> +#define PHY_ISO_CMN_CTRL 0x0008U >> #define PHY_PLL_CFG 0x000EU >> #define PHY_PIPE_USB3_GEN2_PRE_CFG0 0x0020U >> #define PHY_PIPE_USB3_GEN2_POST_CFG0 0x0022U >> @@ -216,6 +222,10 @@ >> #define PHY_PMA_CMN_CTRL2 0x0001U >> #define PHY_PMA_PLL_RAW_CTRL 0x0003U >> >> +static const char * const clk_names[] = { >> + [CDNS_TORRENT_REFCLK_DRIVER] = "refclk-driver", >> +}; >> + >> static const struct reg_field phy_pll_cfg = >> REG_FIELD(PHY_PLL_CFG, 0, 1); >> >> @@ -231,6 +241,36 @@ static const struct reg_field phy_pma_pll_raw_ctrl = >> static const struct reg_field phy_reset_ctrl = >> REG_FIELD(PHY_RESET, 8, 8); >> >> +#define REFCLK_OUT_NUM_CONFIGURATIONS_PCS_CONFIG 2 > > This could be reduced just to REFCLK_OUT_NUM_PCS_CONFIG, but up to you. > Same below. > >> + >> +enum cdns_torrent_refclk_out_pcs { >> + PHY_ISO_CMN_CTRL_8, >> + PHY_PIPE_CMN_CTRL1_0, >> +}; >> + >> +#define REFCLK_OUT_NUM_CONFIGURATIONS_CMN_CONFIG 5 >> + >> +enum cdns_torrent_refclk_out_cmn { >> + CMN_CDIAG_REFCLK_OVRD_4, >> + CMN_CDIAG_REFCLK_DRV0_CTRL_1, >> + CMN_CDIAG_REFCLK_DRV0_CTRL_4, >> + CMN_CDIAG_REFCLK_DRV0_CTRL_5, >> + CMN_CDIAG_REFCLK_DRV0_CTRL_6, >> +}; >> + >> +static const struct reg_field refclk_out_pcs_cfg[] = { >> + [PHY_ISO_CMN_CTRL_8] = REG_FIELD(PHY_ISO_CMN_CTRL, 8, >> 8), >> + [PHY_PIPE_CMN_CTRL1_0] = REG_FIELD(PHY_PIPE_CMN_CTRL1, >> 0, 0), >> +}; >> + >> +static const struct reg_field refclk_out_cmn_cfg[] = { >> + [CMN_CDIAG_REFCLK_OVRD_4] = >> REG_FIELD(CMN_CDIAG_REFCLK_OVRD, 4, 4), >> + [CMN_CDIAG_REFCLK_DRV0_CTRL_1] = >> REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 1, 1), >> + [CMN_CDIAG_REFCLK_DRV0_CTRL_4] = >> REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 4, 4), >> + [CMN_CDIAG_REFCLK_DRV0_CTRL_5] = >> REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 5, 5), >> + [CMN_CDIAG_REFCLK_DRV0_CTRL_6] = >> REG_FIELD(CMN_CDIAG_REFCLK_DRV0_CTRL, 6, 6), >> +}; >> + >> enum cdns_torrent_phy_type { >> TYPE_NONE, >> TYPE_DP, >> @@ -279,6 +319,8 @@ struct cdns_torrent_phy { >> struct regmap_field *phy_pma_cmn_ctrl_2; >> struct regmap_field *phy_pma_pll_raw_ctrl; >> struct regmap_field *phy_reset_ctrl; >> + struct clk *clks[CDNS_TORRENT_REFCLK_DRIVER + 1]; >> + struct clk_onecell_data clk_data; >> }; >> >> enum phy_powerstate { >> @@ -288,6 +330,16 @@ enum phy_powerstate { >> POWERSTATE_A3 = 3, >> }; >> >> +struct cdns_torrent_derived_refclk { >> + struct clk_hw hw; >> + struct regmap_field >> *pcs_fields[REFCLK_OUT_NUM_CONFIGURATIONS_PCS_CONFIG]; >> + struct regmap_field >> *cmn_fields[REFCLK_OUT_NUM_CONFIGURATIONS_CMN_CONFIG]; >> + struct clk_init_data clk_data; >> +}; >> + >> +#define to_cdns_torrent_derived_refclk(_hw) \ >> + container_of(_hw, struct >> cdns_torrent_derived_refclk, hw) >> + >> static int cdns_torrent_phy_init(struct phy *phy); >> static int cdns_torrent_dp_init(struct phy *phy); >> static int cdns_torrent_dp_run(struct cdns_torrent_phy *cdns_phy, >> @@ -1604,6 +1656,111 @@ static int cdns_torrent_dp_run(struct >> cdns_torrent_phy *cdns_phy, u32 num_lanes) >> return ret; >> } >> >> +static int cdns_torrent_derived_refclk_enable(struct clk_hw *hw) >> +{ >> + struct cdns_torrent_derived_refclk *derived_refclk = >> to_cdns_torrent_derived_refclk(hw); >> + >> + regmap_field_write(derived_refclk- >>> cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_6], 0); >> + regmap_field_write(derived_refclk- >>> cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_4], 1); >> + regmap_field_write(derived_refclk- >>> cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_5], 1); >> + regmap_field_write(derived_refclk- >>> cmn_fields[CMN_CDIAG_REFCLK_DRV0_CTRL_1], 0); >> + regmap_field_write(derived_refclk- >>> cmn_fields[CMN_CDIAG_REFCLK_OVRD_4], 1); >> + regmap_field_write(derived_refclk- >>> pcs_fields[PHY_PIPE_CMN_CTRL1_0], 1); >> + regmap_field_write(derived_refclk- >>> pcs_fields[PHY_ISO_CMN_CTRL_8], 1); >> + >> + return 0; >> +} >> + >> +static void cdns_torrent_derived_refclk_disable(struct clk_hw *hw) >> +{ >> + struct cdns_torrent_derived_refclk *derived_refclk = >> to_cdns_torrent_derived_refclk(hw); >> + >> + regmap_field_write(derived_refclk- >>> pcs_fields[PHY_ISO_CMN_CTRL_8], 0); >> +} >> + > > PHY_ISO_CMN_CTRL is a PHY isolation register. Not sure, but is this correct > to control phy_en_refclk to enable/disable refclk output from here? hmm.. I see this is used to drive phy_en_refclk when in ISOLATION mode. Given that we are not selecting to operate in isolation mode, this shouldn't be required. This was present in the sequence given by HW team but maybe it's enabled for some debugging. I've also verified PCIe works without this configuration. I'll repost without this configuration and also check with HW team on why it was added. Thanks Kishon