From patchwork Tue Sep 5 11:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achal Verma X-Patchwork-Id: 13374439 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69D17C83F3E for ; Tue, 5 Sep 2023 11:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6zSuBvu02litW1YwByM4ewmMQhxvL7LvwffubqRxtKU=; b=DX/mBcrEcVbosA HxUDKS6SFW2/9n1GrCD0lJC4RiBbqDeULeywTIq4FCqRL1fo80dlzslyIfLorXR6UVCnBuqJVaoM3 SfHkvAGlCFkMvV7c1b/ARriht7kAuPL7kUUHX6Eo8oNA43GdchPD3FZQHpuQB7oobmCRDSmiwSVcK gh4tIdxd728c+74j+iNQMUjKyBKnxsX2VLWekYw5hAp79vLfjvDEpyddnYBMih6tep5p7HNSguE8y JFBzL2svMUqWjE61YfM4xMRCb3Q4XedV1fDg34LXcfI2VPr0tm3WlsTfWQu5sJFi505WcP0vZFxbj ihMFDG8ZQE1V1xuLofrg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdUXr-005wBT-08; Tue, 05 Sep 2023 11:48:35 +0000 Received: from fllv0015.ext.ti.com ([198.47.19.141]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdUXo-005w9a-17 for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 11:48:33 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 385BmJWf067524; Tue, 5 Sep 2023 06:48:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1693914499; bh=wv46gSUbnd5T5QXTH0Mwp9tu+So1/AjM94GeHUDcTjM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Kd8/VPT9fcuFT5JgaYi2xQgt5cpbiC78w1cUY3q48XLNBf3d7o/OPRtIeuBcb4C/R K9FNJiD+JwqimTQQdC1jyoYYTxmQv61m6kNNZovef5KppsyqFyu5AP1ywqCVt51gOd VWDJW6WIqPz7wkmBG0MRmy0NI8qvvngwAYXqYOVo= Received: from DLEE109.ent.ti.com (dlee109.ent.ti.com [157.170.170.41]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 385BmJ66054136 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Sep 2023 06:48:19 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) 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.2507.23; Tue, 5 Sep 2023 06:48:19 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 5 Sep 2023 06:48:19 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 385BmI3E075471; Tue, 5 Sep 2023 06:48:19 -0500 From: Achal Verma To: Vignesh Raghavendra , Lorenzo Pieralisi , Krzysztof Wilczy_ski , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley CC: , , , , , Achal Verma Subject: [RFC PATCH 1/2] dt-bindings: PCI: ti,j721e-pci-*: Add "ti,syscon-pcie-refclk-out" property Date: Tue, 5 Sep 2023 17:18:15 +0530 Message-ID: <20230905114816.2993628-2-a-verma1@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230905114816.2993628-1-a-verma1@ti.com> References: <20230905114816.2993628-1-a-verma1@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_044832_463811_4E5806E7 X-CRM114-Status: GOOD ( 10.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Added "ti,syscon-pcie-refclk-out" property to specify the ACSPCIE clock buffer register offset in SYSCON, which would be used to enable serdes reference clock output. Signed-off-by: Achal Verma --- .../bindings/pci/ti,j721e-pci-host.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml b/Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml index a2c5eaea57f5..27bdc52282c4 100644 --- a/Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml +++ b/Documentation/devicetree/bindings/pci/ti,j721e-pci-host.yaml @@ -44,6 +44,18 @@ properties: - description: pcie_ctrl register offset within SYSCON description: Specifier for configuring PCIe mode and link speed. + ti,syscon-pcie-refclk-out: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: Phandle to the SYSCON entry + - description: lock2_kick0 register offset within SYSCON + - description: lock2_kick1 register offset within SYSCON + - description: acspcie_ctrl register offset within SYSCON + - description: pcie_refclk_clksel register offset within SYSCON + - description: clock source index to source ref clock + description: Specifier for enabling ACSPCIe clock buffer for reference clock output. + power-domains: maxItems: 1 @@ -99,6 +111,7 @@ required: - reg - reg-names - ti,syscon-pcie-ctrl + - ti,syscon-pcie-refclk-out - max-link-speed - num-lanes - power-domains @@ -153,3 +166,43 @@ examples: dma-ranges = <0x02000000 0x0 0x0 0x0 0x0 0x10000 0x0>; }; }; + + - + #include + #include + #include + #include + + bus { + #address-cells = <2>; + #size-cells = <2>; + + pcie1_rc: pcie@2910000 { + compatible = "ti,j784s4-pcie-host"; + reg = <0x00 0x02910000 0x00 0x1000>, + <0x00 0x02917000 0x00 0x400>, + <0x00 0x0d800000 0x00 0x00800000>, + <0x00 0x18000000 0x00 0x00001000>; + reg-names = "intd_cfg", "user_cfg", "reg", "cfg"; + interrupt-names = "link_state"; + interrupts = ; + device_type = "pci"; + ti,syscon-pcie-ctrl = <&scm_conf 0x4074>; + ti,syscon-pcie-refclk-out = <&scm_conf 0x9008 0x900c 0x18090 0x8074 0x1>; + max-link-speed = <3>; + num-lanes = <4>; + power-domains = <&k3_pds 333 TI_SCI_PD_EXCLUSIVE>; + clocks = <&k3_clks 333 0>; + clock-names = "fck"; + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x0 0xff>; + vendor-id = <0x104c>; + device-id = <0xb013>; + msi-map = <0x0 &gic_its 0x10000 0x10000>; + dma-coherent; + ranges = <0x01000000 0x0 0x18001000 0x00 0x18001000 0x0 0x0010000>, + <0x02000000 0x0 0x18011000 0x00 0x18011000 0x0 0x7fef000>; + dma-ranges = <0x02000000 0x0 0x0 0x0 0x0 0x10000 0x0>; + }; + }; From patchwork Tue Sep 5 11:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Achal Verma X-Patchwork-Id: 13374441 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5134DCA0FF3 for ; Tue, 5 Sep 2023 11:49:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wUWqOhryTxDqZw1RtTEfiPVmfqNNPwBNwsobRpvjR58=; b=OvNn7KbAIfNxoq G6M2iGsrXZHqReSgD8DqxhYpz9G/NexSi80iqemiHx7JxfOFDpKhoRkYtTVgLIibIncW+pg0cQj9v Z80p5m+qNXWfNPQH8NGcT5Ke2zgvSOdzGVN1QWKofgy3Dxyc3nl5mnRazqd1pCXaI8TFrBEm2Btzw 7yc3/EhnEdPF6muiyGJgbfQdq3XsUE0R+0Q1uXIwRBD0c5rcljfLgbC00lpXjoBzBc6cZ9hxShVfL dES44UuYwhqlaXauv/BKfFWF3ROU7QCLfXkXlkMxCA6y/hRWABTfH7nI39fMn5mN8/JLItfdUKvie zHOj9yOtVKUahRL5Q0+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qdUXp-005wAi-1Y; Tue, 05 Sep 2023 11:48:33 +0000 Received: from lelv0143.ext.ti.com ([198.47.23.248]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qdUXm-005w9E-0D for linux-arm-kernel@lists.infradead.org; Tue, 05 Sep 2023 11:48:31 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 385BmMkh103769; Tue, 5 Sep 2023 06:48:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1693914502; bh=/iPn0yREcHMFWliXICPndWnFxV56aW4OXQpn08OE5mY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=DXB+AQ9akhiFeX9N1vc5Jl4qDySFY6M0rguw7ZRGEGgenpYHdwC5lj16fZxp9UiZ7 huSvmPmwCVU6rSIlJwIPPCCsbn4daZ9f2C5pMgddxzYSr5kYLljjjEyvCUZfLf0LiL XVIRKmEs7D5g12taU7/8Hv7wMXS2+FaRU4T2x64s= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 385BmMQE054158 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 5 Sep 2023 06:48:22 -0500 Received: from DLEE108.ent.ti.com (157.170.170.38) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 5 Sep 2023 06:48:20 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 5 Sep 2023 06:48:21 -0500 Received: from localhost (ileaxei01-snat2.itg.ti.com [10.180.69.6]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 385BmKNJ046722; Tue, 5 Sep 2023 06:48:20 -0500 From: Achal Verma To: Vignesh Raghavendra , Lorenzo Pieralisi , Krzysztof Wilczy_ski , Rob Herring , Bjorn Helgaas , Krzysztof Kozlowski , Conor Dooley CC: , , , , , Achal Verma Subject: [RFC PATCH 2/2] pci: j721e: Enable reference clock output from serdes Date: Tue, 5 Sep 2023 17:18:16 +0530 Message-ID: <20230905114816.2993628-3-a-verma1@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230905114816.2993628-1-a-verma1@ti.com> References: <20230905114816.2993628-1-a-verma1@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230905_044830_182585_4AB36BB1 X-CRM114-Status: GOOD ( 17.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org PCIe1 in J7AHP EVM has EP side connector reference clock connection from serdes named SOC_SERDES0_REFCLK(PCIE_REFCLK_OUT) unlike PCIe0 which has reference clock connection from on-board serdes. To enable this reference clock out, ACSPCIE clock buffer pads have to be enabled. This change enables ACSPCIE clock buffer pads and select clock source for reference clock output. Signed-off-by: Achal Verma --- .../pci/controller/cadence/pci-j721e-host.c | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/drivers/pci/controller/cadence/pci-j721e-host.c b/drivers/pci/controller/cadence/pci-j721e-host.c index af47aa090159..106472920f68 100644 --- a/drivers/pci/controller/cadence/pci-j721e-host.c +++ b/drivers/pci/controller/cadence/pci-j721e-host.c @@ -10,10 +10,21 @@ #include #include #include +#include +#include #include "pcie-cadence.h" #include "pci-j721e.h" +#define CTRL_MMR_LOCK2_MASK 0xFFFFFFFF +#define CTRL_MMR_LOCK2_KICK0_UNLOCK_VAL 0x68EF3490 +#define CTRL_MMR_LOCK2_KICK1_UNLOCK_VAL 0xD172BC5A +#define CTRL_MMR_LOCK_KICK_LOCK_VAL 0xFFFFFFFF +#define CTRL_MMR_ACSPCIE_PAD_MASK 0xFFFFFFFF +#define CTRL_MMR_ACSPCIE_PAD_EN 0x01000000 +#define PCIE_REFCLK_CLKSEL_OUT_EN BIT(8) +#define PCIE_REFCLK_CLKSEL_MASK GENMASK(1, 0) + static int cdns_ti_pcie_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value) { @@ -79,6 +90,84 @@ static const struct of_device_id of_j721e_pcie_host_match[] = { }; MODULE_DEVICE_TABLE(of, of_j721e_pcie_host_match); +static int j721e_enable_acspcie(struct j721e_pcie *pcie) +{ + struct device *dev = pcie->cdns_pcie->dev; + struct device_node *node = dev->of_node; + struct of_phandle_args args; + unsigned int lock2_kick0_offset, lock2_kick1_offset; + unsigned int acspcie_pad_offset, refclk_clksel_offset; + unsigned int refclk_clksel_source; + struct regmap *syscon; + u32 val = 0, mask = 0; + int ret; + + /* + * If property ti,syscon-pcie-refclk-out exists, believe PCIe connector + * requires PCIe ref clock from Serdes, so enable ACSPCIE pads and mux + * to source out PCIe ref clock else ref clock has to be supplied from + * on-board clock generator. + */ + syscon = syscon_regmap_lookup_by_phandle(node, "ti,syscon-pcie-refclk-out"); + if (IS_ERR(syscon)) + return 0; + + ret = of_parse_phandle_with_fixed_args(node, "ti,syscon-pcie-refclk-out", 5, + 0, &args); + if (ret) { + dev_err(dev, "Failed to read ti,syscon-pcie-refclk-out property\n"); + return ret; + } + + lock2_kick0_offset = args.args[0]; + lock2_kick1_offset = args.args[1]; + acspcie_pad_offset = args.args[2]; + refclk_clksel_offset = args.args[3]; + refclk_clksel_source = args.args[4]; + + /* Un-lock Partition 2 : 8000h to 9FFFh */ + mask = CTRL_MMR_LOCK2_MASK; + val = CTRL_MMR_LOCK2_KICK0_UNLOCK_VAL; + ret = regmap_update_bits(syscon, lock2_kick0_offset, mask, val); + if (ret) + goto err; + + val = CTRL_MMR_LOCK2_KICK1_UNLOCK_VAL; + ret = regmap_update_bits(syscon, lock2_kick1_offset, mask, val); + if (ret) + goto err; + + /* Enable ACSPCIe PADS */ + mask = CTRL_MMR_ACSPCIE_PAD_MASK; + val = CTRL_MMR_ACSPCIE_PAD_EN; + ret = regmap_update_bits(syscon, acspcie_pad_offset, mask, val); + if (ret) + goto err; + + /* PCIE_REFCLKx_CLKSEL : EN + ref_clk_source */ + mask = PCIE_REFCLK_CLKSEL_OUT_EN | PCIE_REFCLK_CLKSEL_MASK; + val = PCIE_REFCLK_CLKSEL_OUT_EN | refclk_clksel_source; + ret = regmap_update_bits(syscon, refclk_clksel_offset, mask, val); + if (ret) + goto err; + + /* Re-lock Partition 2 : 8000h to 9FFFh */ + mask = CTRL_MMR_LOCK_KICK_LOCK_VAL; + val = CTRL_MMR_LOCK_KICK_LOCK_VAL; + ret = regmap_update_bits(syscon, lock2_kick0_offset, mask, val); + if (ret) + goto err; + + ret = regmap_update_bits(syscon, lock2_kick1_offset, mask, val); + if (ret) + goto err; + + return 0; +err: + dev_err(dev, "Failed to enable ref clock out\n"); + return ret; +} + static int j721e_pcie_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -121,6 +210,13 @@ static int j721e_pcie_probe(struct platform_device *pdev) if (ret) return ret; + /* + * Enable ACSPCIe clock buffer to source out reference clock for EP + */ + ret = j721e_enable_acspcie(pcie); + if (ret < 0) + return ret; + pcie->perst_gpiod = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW); if (IS_ERR(pcie->perst_gpiod)) { ret = PTR_ERR(pcie->perst_gpiod);