From patchwork Tue Mar 2 10:59:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12113765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 670B6C433DB for ; Wed, 3 Mar 2021 16:10:06 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0BB3264EE6 for ; Wed, 3 Mar 2021 16:10:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BB3264EE6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BPQEAJ8P80suMP4JkvuI/0J/6iLt/Wn3+i0bUvSJt6U=; b=o5WC3Jc20kB/d+LKijyO7JRV0 9ZCj8KOiXqVty+Pgq6L75UwkK6RtcIhR8hJHqW6AoOnjasPQEYCDUtS+lPlswF2xdT94n3RuzkUsz 8gFChMV02m2jLO5niemFCdFbLR64jqxZHoR6nlPV+vUOZ0+WX8yywAMnZLLH+3IOJUs/ObczP10ue bj+6oQqjQLl1vnQwzAZjMJM+VdQEaLjANfItOkecz53dqgczG9+e5YOz+cfSwVuoYLfRlRzbLlw5s YSrmMi0InLwX6Sy8XhXjBBWxcsmt7DzUWaPF/c+De2GsVP44ApueSlgeqP+44aO21eBn/zwnyBHZg 0bxzyatBA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHU4M-005Xh3-P0; Wed, 03 Mar 2021 16:09:51 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHSor-005Djj-MB for linux-riscv@desiato.infradead.org; Wed, 03 Mar 2021 14:49:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=PfSnh6VZnYLNCYZWrxu4Dq5GHP0C0hePVJDMZuOnMco=; b=SV87KuiRLamhW0Uqbk1oFB7Yq1 /jHHyskqQBjf8csjwL46IgM9dVmD6HUluJzL/wagvGLIOo2flTexIK36Cv7dgl9ESGcI7ar68QlVq VHaav08Sx/oluINVqpaMTvvQeQmwPjRAJNAhGM1QTnSPrn8K+CQ6bE5oi6sjKzsOeFNsh8iGmHuKR Dzv+ui5phXYrhlH69lSpW6nBlQoDkJSgRF/BuA+bzoY52IXLklcaOJUkQHds1Wg5h2+ZWdOehr17n DhGVQ+mjeFH7foDIKxv4zbA2bdWTKRyYQrwwNGNQHS9g8/dJrPooCYF+9oBgBVP1puJwoOdLYhF7D rh2I3zBw==; Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH2lX-00GygP-87 for linux-riscv@lists.infradead.org; Tue, 02 Mar 2021 11:00:36 +0000 Received: by mail-pl1-x634.google.com with SMTP id s16so11807751plr.9 for ; Tue, 02 Mar 2021 03:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PfSnh6VZnYLNCYZWrxu4Dq5GHP0C0hePVJDMZuOnMco=; b=MVUDJWAqtXNs/jB1M4kP6cNQ2qZTGiTKCV/vO3tQYtFB5rorElbpE0zv+EXxTmOu7y jeMQaNukBc5JAeD7m5UoFc70BfFVdHzX00ZpNimV8uUnZtUmgO8E4j0sKTOaIjEe3949 rYoAjYKikKndXxx2AKTG1PguHb2LDESOUPQ24mzFp8i1zP0+LUJYdYJqqtc1/OsMl04Z e3Ggs/QCSxKQJOqIYJXncoVOdptm1QdhDbCQNrC5RZK4eVzqPbEqWD2CABVxyFWPetKv IQA4GvtULmcQo1y2j6AMLQv93ouhZPJF9Fz53heFmIflD6oZ6ap2ZQaNWTv5d6w5AWSb 7Hjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PfSnh6VZnYLNCYZWrxu4Dq5GHP0C0hePVJDMZuOnMco=; b=FhY72zl0zPHivB7AGq8UNAbr73JODzxDdFkMyzgZo4tUfdxqHmlIXcntIjqxXfxFRx AS6KHIEF8pto5o/QmqZee2sIq1/oiDXrcBKIEued9jdkmq/9N/iTVtJ6QyUSi4zzKdob BLwWrahPQFxEXLimipOP/267D+/Hh3qATzGY4NgHEkQXA79FOEsmPiEJDolMx/8QlE1L TnZnwkp6Sd/HagDc3PM4N1BhJ6hUa6UZKW9a4if/zhDfO3Zz7V5yCQXUycAlGCy6mqcK SxxMxU+XJ6RNHT1PbE5O+YosTHMULUU9pGPZ2BVfqhQhRodXWJgLxjw2mvbCxOJqYutI vkqA== X-Gm-Message-State: AOAM531pMoYWAmvDTTUq01WyVKNcQAjgjwBqXxwshM0Xqut1xo3a5FNJ RdNgH0QlMwMofXcM8ggClhUKHw== X-Google-Smtp-Source: ABdhPJxxOBD2qaCz1iOhr3Se5EKi1PgefKoHh7gmrsm0GCbJQCFbhHnOgqCrOb11uWpxfAadrSptIw== X-Received: by 2002:a17:90a:bd92:: with SMTP id z18mr3805618pjr.114.1614682771848; Tue, 02 Mar 2021 02:59:31 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id t26sm19500451pfq.208.2021.03.02.02.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:59:31 -0800 (PST) From: Greentime Hu To: greentime.hu@sifive.com, paul.walmsley@sifive.com, hes@sifive.com, erik.danie@sifive.com, zong.li@sifive.com, bhelgaas@google.com, robh+dt@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.pieralisi@arm.com, p.zabel@pengutronix.de, alex.dewar90@gmail.com, khilman@baylibre.com, hayashi.kunihiko@socionext.com, vidyas@nvidia.com, jh80.chung@samsung.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 1/6] clk: sifive: Add pcie_aux clock in prci driver for PCIe driver Date: Tue, 2 Mar 2021 18:59:12 +0800 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_110036_582218_DB723983 X-CRM114-Status: GOOD ( 15.75 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We add pcie_aux clock in this patch so that pcie driver can use clk_prepare_enable() and clk_disable_unprepare() to enable and disable pcie_aux clock. Signed-off-by: Greentime Hu --- drivers/clk/sifive/fu740-prci.c | 11 +++++ drivers/clk/sifive/fu740-prci.h | 2 +- drivers/clk/sifive/sifive-prci.c | 41 +++++++++++++++++++ drivers/clk/sifive/sifive-prci.h | 9 ++++ include/dt-bindings/clock/sifive-fu740-prci.h | 1 + 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/drivers/clk/sifive/fu740-prci.c b/drivers/clk/sifive/fu740-prci.c index 764d1097aa51..53f6e00a03b9 100644 --- a/drivers/clk/sifive/fu740-prci.c +++ b/drivers/clk/sifive/fu740-prci.c @@ -72,6 +72,12 @@ static const struct clk_ops sifive_fu740_prci_hfpclkplldiv_clk_ops = { .recalc_rate = sifive_prci_hfpclkplldiv_recalc_rate, }; +static const struct clk_ops sifive_fu740_prci_pcie_aux_clk_ops = { + .enable = sifive_prci_pcie_aux_clock_enable, + .disable = sifive_prci_pcie_aux_clock_disable, + .is_enabled = sifive_prci_pcie_aux_clock_is_enabled, +}; + /* List of clock controls provided by the PRCI */ struct __prci_clock __prci_init_clocks_fu740[] = { [PRCI_CLK_COREPLL] = { @@ -120,4 +126,9 @@ struct __prci_clock __prci_init_clocks_fu740[] = { .parent_name = "hfpclkpll", .ops = &sifive_fu740_prci_hfpclkplldiv_clk_ops, }, + [PRCI_CLK_PCIE_AUX] = { + .name = "pcie_aux", + .parent_name = "hfclk", + .ops = &sifive_fu740_prci_pcie_aux_clk_ops, + }, }; diff --git a/drivers/clk/sifive/fu740-prci.h b/drivers/clk/sifive/fu740-prci.h index 13ef971f7764..511a0bf7ba2b 100644 --- a/drivers/clk/sifive/fu740-prci.h +++ b/drivers/clk/sifive/fu740-prci.h @@ -9,7 +9,7 @@ #include "sifive-prci.h" -#define NUM_CLOCK_FU740 8 +#define NUM_CLOCK_FU740 9 extern struct __prci_clock __prci_init_clocks_fu740[NUM_CLOCK_FU740]; diff --git a/drivers/clk/sifive/sifive-prci.c b/drivers/clk/sifive/sifive-prci.c index c78b042750e2..baf7313dac92 100644 --- a/drivers/clk/sifive/sifive-prci.c +++ b/drivers/clk/sifive/sifive-prci.c @@ -448,6 +448,47 @@ void sifive_prci_hfpclkpllsel_use_hfpclkpll(struct __prci_data *pd) r = __prci_readl(pd, PRCI_HFPCLKPLLSEL_OFFSET); /* barrier */ } +/* PCIE AUX clock APIs for enable, disable. */ +int sifive_prci_pcie_aux_clock_is_enabled(struct clk_hw *hw) +{ + struct __prci_clock *pc = clk_hw_to_prci_clock(hw); + struct __prci_data *pd = pc->pd; + u32 r; + + r = __prci_readl(pd, PRCI_PCIE_AUX_OFFSET); + + if (r & PRCI_PCIE_AUX_EN_MASK) + return 1; + else + return 0; +} + +int sifive_prci_pcie_aux_clock_enable(struct clk_hw *hw) +{ + struct __prci_clock *pc = clk_hw_to_prci_clock(hw); + struct __prci_data *pd = pc->pd; + u32 r; + + if (sifive_prci_pcie_aux_clock_is_enabled(hw)) + return 0; + + __prci_writel(1, PRCI_PCIE_AUX_OFFSET, pd); + r = __prci_readl(pd, PRCI_PCIE_AUX_OFFSET); /* barrier */ + + return 0; +} + +void sifive_prci_pcie_aux_clock_disable(struct clk_hw *hw) +{ + struct __prci_clock *pc = clk_hw_to_prci_clock(hw); + struct __prci_data *pd = pc->pd; + u32 r; + + __prci_writel(0, PRCI_PCIE_AUX_OFFSET, pd); + r = __prci_readl(pd, PRCI_PCIE_AUX_OFFSET); /* barrier */ + +} + /** * __prci_register_clocks() - register clock controls in the PRCI * @dev: Linux struct device diff --git a/drivers/clk/sifive/sifive-prci.h b/drivers/clk/sifive/sifive-prci.h index dbdbd1722688..022c67cf053c 100644 --- a/drivers/clk/sifive/sifive-prci.h +++ b/drivers/clk/sifive/sifive-prci.h @@ -67,6 +67,11 @@ #define PRCI_DDRPLLCFG1_CKE_SHIFT 31 #define PRCI_DDRPLLCFG1_CKE_MASK (0x1 << PRCI_DDRPLLCFG1_CKE_SHIFT) +/* PCIEAUX */ +#define PRCI_PCIE_AUX_OFFSET 0x14 +#define PRCI_PCIE_AUX_EN_SHIFT 0 +#define PRCI_PCIE_AUX_EN_MASK (0x1 << PRCI_PCIE_AUX_EN_SHIFT) + /* GEMGXLPLLCFG0 */ #define PRCI_GEMGXLPLLCFG0_OFFSET 0x1c #define PRCI_GEMGXLPLLCFG0_DIVR_SHIFT 0 @@ -296,4 +301,8 @@ unsigned long sifive_prci_tlclksel_recalc_rate(struct clk_hw *hw, unsigned long sifive_prci_hfpclkplldiv_recalc_rate(struct clk_hw *hw, unsigned long parent_rate); +int sifive_prci_pcie_aux_clock_is_enabled(struct clk_hw *hw); +int sifive_prci_pcie_aux_clock_enable(struct clk_hw *hw); +void sifive_prci_pcie_aux_clock_disable(struct clk_hw *hw); + #endif /* __SIFIVE_CLK_SIFIVE_PRCI_H */ diff --git a/include/dt-bindings/clock/sifive-fu740-prci.h b/include/dt-bindings/clock/sifive-fu740-prci.h index cd7706ea5677..7899b7fee7db 100644 --- a/include/dt-bindings/clock/sifive-fu740-prci.h +++ b/include/dt-bindings/clock/sifive-fu740-prci.h @@ -19,5 +19,6 @@ #define PRCI_CLK_CLTXPLL 5 #define PRCI_CLK_TLCLK 6 #define PRCI_CLK_PCLK 7 +#define PRCI_CLK_PCIE_AUX 8 #endif /* __DT_BINDINGS_CLOCK_SIFIVE_FU740_PRCI_H */ From patchwork Tue Mar 2 10:59:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12113933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB64EC433E0 for ; Wed, 3 Mar 2021 17:19:20 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53C7864ED9 for ; Wed, 3 Mar 2021 17:19:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53C7864ED9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=X0uXcZc2Pnkm72a2H3q87NZ91g94b1R23RuqeoGRCEE=; b=DotUZTGMhP08TW8bKVc3Qqaxs DNrjjdmmB+MGz/27d34K+9JWctPvBjrQv4Qj/yT5U7wBrwmTA/oN/ePzceYSihFPv+FD1HJd0V9Sh YtY012tTXDRLIQXOP+V2foxueR/2v53zP15GL34kFtBdScf8ObvflKRHq4D6PitsOf7OD0EbrOYIg iTGFOsivNHRRp9j+o9lI76FNC/BhAX2esuXqXTZJ1OmPH1ZPfJsUmRhfRaelWKKHBN+vinEf/I+Lb yymI7kZkPKuWlrpvD3NS/7GivF6XHWl+Cu4L1Y41AeoLdA1EJHWsIp6QMTX+LZ9AA9JImzvYm+o/7 6FMxLRa0w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHV9P-005lsi-6J; Wed, 03 Mar 2021 17:19:07 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHStr-005F7R-C2 for linux-riscv@desiato.infradead.org; Wed, 03 Mar 2021 14:54:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=u6t/37IyVxin5Ht2dpG96JWylVJHChqoPdK9b3/r2Tk=; b=J2Bx0Q5qUdRGZwEJVzxj79ZnPc agMK90LtUstWl7Ej5cUTMY0IL6G9RUN2pK8xtrYSXyAfbFFjBUx/PTShxyl40663CA4t3U/Snpygo U1crhTcovl1FfVxZWCBz/sEbEGi9g/jFRSIsfr725SSPwGpYv0SoNOjsHNz+riGSgSUC/FnQw2C/U y0BgDFq4ugSfCWL8gap1FL1PeCh+9YaIzikl8aPAsx2LGK5ttaMxeU9gIOVE95IvTtPtZ80Wxyf2h gKYx8UlIEJ0S6OAkg2Q+lm+rzXjAE6fMX6S9WhKOZfw7npD8zxBnLWcF+V3EpxAAa9qXhgpYOZ4qZ EOEHNoLQ==; Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH2lb-00Gygs-EO for linux-riscv@lists.infradead.org; Tue, 02 Mar 2021 11:00:40 +0000 Received: by mail-pf1-x429.google.com with SMTP id d12so11040591pfo.7 for ; Tue, 02 Mar 2021 03:00:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=u6t/37IyVxin5Ht2dpG96JWylVJHChqoPdK9b3/r2Tk=; b=dmHcDAYFKLLqTOsvf5p41tbZfMnkTkQbBAs8K9RFyRZ1BWqaviEUrW6MltF8u402OJ qr9t7qF/MVuoxGJnduTffQKjYx8nbsFN6oaHDJuWZ3NOHX6NAkVsw3o4tKkX87+vLtVe 0TEQdBi7us9IB1SCjzNKuV1/CKNUv7q+xMwcqYYK4w9kr/Czggj89AE2v0Tve2wtnKZp GlwZ9G6kBho4Ct0PUXMYzQ1JyYOBFLDAst2+fEIzQNwU+wpsadnfNYKVi0WQ8zjd5I1S Kktrg+quS/UItfCItat+2Z65rMVvVrbVC11DhVqfjoaiWMYoPDZS1aXBjsTi4R2ymFjX RnSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u6t/37IyVxin5Ht2dpG96JWylVJHChqoPdK9b3/r2Tk=; b=Zh3MmdPI0kLTaONkgdUJWhIegyvkFkvTgOmxA7QMgm8M/354aLsSKK5sb4oQJ+iNQB KO2/MRvcNkz+OJQnJk0qrzMc1PyQI8PdsgMWRBXtBTM8hmJJAOxSkIzXPjEnldI34DS7 fA695e5GbjalMyuGr+kJZC8Ji9zhFK4GEKBtsvxjSjMLHxOvlCTdRtyz5N7cyYK4GVVi xkj58VLf5ymuEXnkve+9jtjQS1j6m4HkNNRk9MHI8RWA0ZYsty3/TWHBSXMyy/u3w4Au +G605M0yaF0QHYcQu3EzxFxmdrgR8SF2k9mlsKGlvpkq4ZkUphFJqhqHlfHziC6Vy2R8 BVGw== X-Gm-Message-State: AOAM533PsXMQ/3E8/UWL5bbR0JHcL0ujUwW4e9sC4NC+TbKXERhoRb5X LeC28GW+R/V1cEUf3LXE3uqcNw== X-Google-Smtp-Source: ABdhPJylvXar14N05xZmEcvHjUe6bk4TRJdURaXGBevBG2TJaWqrMkEom3Rr1QxWW0n0TwD/tl5mKA== X-Received: by 2002:a63:d451:: with SMTP id i17mr2445904pgj.391.1614682775713; Tue, 02 Mar 2021 02:59:35 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id t26sm19500451pfq.208.2021.03.02.02.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:59:35 -0800 (PST) From: Greentime Hu To: greentime.hu@sifive.com, paul.walmsley@sifive.com, hes@sifive.com, erik.danie@sifive.com, zong.li@sifive.com, bhelgaas@google.com, robh+dt@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.pieralisi@arm.com, p.zabel@pengutronix.de, alex.dewar90@gmail.com, khilman@baylibre.com, hayashi.kunihiko@socionext.com, vidyas@nvidia.com, jh80.chung@samsung.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 2/6] clk: sifive: Use reset-simple in prci driver for PCIe driver Date: Tue, 2 Mar 2021 18:59:13 +0800 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_110040_866740_280F6AF5 X-CRM114-Status: GOOD ( 13.60 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org We use reset-simple in this patch so that pcie driver can use devm_reset_control_get() to get this reset data structure and use reset_control_deassert() to deassert pcie_power_up_rst_n. Signed-off-by: Greentime Hu Reviewed-by: Philipp Zabel --- drivers/clk/sifive/Kconfig | 2 ++ drivers/clk/sifive/sifive-prci.c | 14 ++++++++++++++ drivers/clk/sifive/sifive-prci.h | 4 ++++ drivers/reset/Kconfig | 3 ++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/drivers/clk/sifive/Kconfig b/drivers/clk/sifive/Kconfig index 1c14eb20c066..9132c3c4aa86 100644 --- a/drivers/clk/sifive/Kconfig +++ b/drivers/clk/sifive/Kconfig @@ -10,6 +10,8 @@ if CLK_SIFIVE config CLK_SIFIVE_PRCI bool "PRCI driver for SiFive SoCs" + select RESET_CONTROLLER + select RESET_SIMPLE select CLK_ANALOGBITS_WRPLL_CLN28HPC help Supports the Power Reset Clock interface (PRCI) IP block found in diff --git a/drivers/clk/sifive/sifive-prci.c b/drivers/clk/sifive/sifive-prci.c index baf7313dac92..925affc6de55 100644 --- a/drivers/clk/sifive/sifive-prci.c +++ b/drivers/clk/sifive/sifive-prci.c @@ -583,7 +583,21 @@ static int sifive_prci_probe(struct platform_device *pdev) if (IS_ERR(pd->va)) return PTR_ERR(pd->va); + pd->reset.rcdev.owner = THIS_MODULE; + pd->reset.rcdev.nr_resets = PRCI_RST_NR; + pd->reset.rcdev.ops = &reset_simple_ops; + pd->reset.rcdev.of_node = pdev->dev.of_node; + pd->reset.active_low = true; + pd->reset.membase = pd->va + PRCI_DEVICESRESETREG_OFFSET; + spin_lock_init(&pd->reset.lock); + + r = devm_reset_controller_register(&pdev->dev, &pd->reset.rcdev); + if (r) { + dev_err(dev, "could not register reset controller: %d\n", r); + return r; + } r = __prci_register_clocks(dev, pd, desc); + if (r) { dev_err(dev, "could not register clocks: %d\n", r); return r; diff --git a/drivers/clk/sifive/sifive-prci.h b/drivers/clk/sifive/sifive-prci.h index 022c67cf053c..91658a88af4e 100644 --- a/drivers/clk/sifive/sifive-prci.h +++ b/drivers/clk/sifive/sifive-prci.h @@ -11,6 +11,7 @@ #include #include +#include #include /* @@ -121,6 +122,8 @@ #define PRCI_DEVICESRESETREG_CHIPLINK_RST_N_MASK \ (0x1 << PRCI_DEVICESRESETREG_CHIPLINK_RST_N_SHIFT) +#define PRCI_RST_NR 7 + /* CLKMUXSTATUSREG */ #define PRCI_CLKMUXSTATUSREG_OFFSET 0x2c #define PRCI_CLKMUXSTATUSREG_TLCLKSEL_STATUS_SHIFT 1 @@ -221,6 +224,7 @@ */ struct __prci_data { void __iomem *va; + struct reset_simple_data reset; struct clk_hw_onecell_data hw_clks; }; diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index 71ab75a46491..f094df93d911 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -173,7 +173,7 @@ config RESET_SCMI config RESET_SIMPLE bool "Simple Reset Controller Driver" if COMPILE_TEST - default ARCH_AGILEX || ARCH_ASPEED || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || ARCH_STRATIX10 || ARCH_SUNXI || ARCH_ZX || ARC + default ARCH_AGILEX || ARCH_ASPEED || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || ARCH_STRATIX10 || ARCH_SUNXI || ARCH_ZX || ARC || RISCV help This enables a simple reset controller driver for reset lines that that can be asserted and deasserted by toggling bits in a contiguous, @@ -187,6 +187,7 @@ config RESET_SIMPLE - RCC reset controller in STM32 MCUs - Allwinner SoCs - ZTE's zx2967 family + - SiFive FU740 SoCs config RESET_STM32MP157 bool "STM32MP157 Reset Driver" if COMPILE_TEST From patchwork Tue Mar 2 10:59:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12113719 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B207C433E0 for ; Wed, 3 Mar 2021 15:34:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7219C64ECF for ; Wed, 3 Mar 2021 15:34:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7219C64ECF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gcvd0jK68SvYDVEMIb0sJW7C1c07tDLNHHDZnBh1aP0=; b=E7yPLIt+ngEY+kD5tmcuWFo8L Dwg/7g/MWUklp54UCHtAuBZmEckzB7GnMwcJ1yV3SEG07nyDOoYdZhExdAiDR6tHNWrOcs1kUDcwp wu3QCA3d/5Rqk3cHIUeOnIbn9BTvhvgV/UOKoRhnA1CbjXEESdQdQHveGZbl9UftEycJCGKG34KZJ EENC3OCuNCFdpj/5oO1mcthCpj1h98x3b9XPZvILMtTtxHPK9ZufdabBRTnr2CpQbMhNsDFDhrpsn g1JltCWHbEpQ2DHEshvTlOumwbjab3/Qqyo560on2aSr/l9Rhzqqi2s0XiISiX2KYKOivIBevddtF iW/Wv1VGg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHTWJ-005PHf-TJ; Wed, 03 Mar 2021 15:34:40 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHSTl-0058BQ-9q for linux-riscv@desiato.infradead.org; Wed, 03 Mar 2021 14:27:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=/USle6rtqTPO64EisM9sX8IiqldHS5gOFIC7i3hO5BU=; b=aF6p1uXnOb3X6TWAdYtzNEsfSn ttA2Cm+GVt1qM1dDyI42a21zgvCvJTMUPYDBwo1b9DLzuDiDu+1NQoVliKRRkWHffuRetI8+EJ+dl dGlt6JBpYKuqXapy9eHm72NXuTsrbCl1Nz6CewytDMncqJmvB3Z3ezFoYSrGgrvAkOWESSFjxFBdP cP/XMNEvCIMnIXW7u0eerbKisVtaRR3W204My6h+NzubWHWg8MjWxaZ+n/458C48YaJZ8tHREoVMb WIEh/XGCUDA1T2rWaJPIi+bRyzzoMOQJQpKRoe4NkyVSqz3l1tAZ/COcpgtwVIl2n6OvIL4zQaoZ3 gAutgpJQ==; Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH2lg-00Gyhr-VX for linux-riscv@lists.infradead.org; Tue, 02 Mar 2021 11:00:46 +0000 Received: by mail-pl1-x632.google.com with SMTP id k22so11817442pll.6 for ; Tue, 02 Mar 2021 03:00:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=/USle6rtqTPO64EisM9sX8IiqldHS5gOFIC7i3hO5BU=; b=LRtiAF9kbHh5VuCDJBNTBZRw0JqzCn2GorHa0OaGv3KuZF0ituHBFJPADTShwCpl9d 6yigVY58onm1SZPyKwdir7rH63l99cfavgctu8xlWQoInrPFd1Fy8f2Creu4aJ4EDifF Ch4ZhnW9Ob1S+QS7KViyOQI1HKr+DJwKQ7kj0R2x7rtNHrEkndwu55//0+kP5FR/JKy6 iNqOLo9t8C8yCSj7wQulxbUQJN71aYe8XHD0dSvE6s+Kl+u5n1oNj7sn8DAqcsRQtLmD CJR0zapJ3GDCfSbmHPExNCc1/czX5L1vXOXS46gDkagjf+JVz7VvMe0BIrbvP1CMpXgV XpqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/USle6rtqTPO64EisM9sX8IiqldHS5gOFIC7i3hO5BU=; b=XH/kVc9BNUiAGLGVOGggN+QFMyKRLbyuBZ2ddv9vQo89O1RXXvMWoFZEag10jFRSZ3 Qhyjt2SVbrEvYbNlwOh+XRf15fVmvyBYoZknf5jmqyLExXIDoWXDC97IOzGdandpr+YH ap/wvVei6x7AcMLDjNrzYH5799ijTvtybKg/4YIJoRRlbKMAilESBzZ0nFNjWAFyl8Cm B9r3H9Nh5CQImNHfR+/sRbFc43MwUKKsEGetyrnX727Htqlrvdb3kon485zCB1mAv+x4 z4EtJ/cuIB66fZYEIbIEmvJybFEFb8/nnqXTlL3Fdr3jRwYBegmthLq0iZ/79eFh2uVD 4fdA== X-Gm-Message-State: AOAM531ChlaYMyoJb2hCC5irvXglcO25UnpaTjlQcKnkYktOFYluCP0D kYV/DBHTr1l8dx8NmL6wFFWMjw== X-Google-Smtp-Source: ABdhPJzq5rLhprXNE/gziWlHFB0NKMzepHExLCYtN0zDKq662/9ZKusst83fZ3/drY3VyKZUYTvTjA== X-Received: by 2002:a17:902:d893:b029:e3:f3ce:cc6a with SMTP id b19-20020a170902d893b02900e3f3cecc6amr3293615plz.28.1614682779630; Tue, 02 Mar 2021 02:59:39 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id t26sm19500451pfq.208.2021.03.02.02.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:59:39 -0800 (PST) From: Greentime Hu To: greentime.hu@sifive.com, paul.walmsley@sifive.com, hes@sifive.com, erik.danie@sifive.com, zong.li@sifive.com, bhelgaas@google.com, robh+dt@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.pieralisi@arm.com, p.zabel@pengutronix.de, alex.dewar90@gmail.com, khilman@baylibre.com, hayashi.kunihiko@socionext.com, vidyas@nvidia.com, jh80.chung@samsung.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 3/6] MAINTAINERS: Add maintainers for SiFive FU740 PCIe driver Date: Tue, 2 Mar 2021 18:59:14 +0800 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_110046_005891_9C13FAD8 X-CRM114-Status: UNSURE ( 7.20 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Here add maintainer information for SiFive FU740 PCIe driver. Signed-off-by: Greentime Hu --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index bfc1b86e3e73..4da888be6e80 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13592,6 +13592,14 @@ S: Maintained F: Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt F: drivers/pci/controller/dwc/*imx6* +PCI DRIVER FOR FU740 +M: Paul Walmsley +M: Greentime Hu +L: linux-pci@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/pci/sifive,fu740-pcie.yaml +F: drivers/pci/controller/dwc/pcie-fu740.c + PCI DRIVER FOR INTEL VOLUME MANAGEMENT DEVICE (VMD) M: Jonathan Derrick L: linux-pci@vger.kernel.org From patchwork Tue Mar 2 10:59:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12113815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6336C433DB for ; Wed, 3 Mar 2021 16:22:49 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 421C564EEA for ; Wed, 3 Mar 2021 16:22:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 421C564EEA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YN2PDFjLGvTcyh8GH8HvOmZY8OvKLWIXjats43YjhGQ=; b=JwIk0ibl7z7K76GUTrLJL8m3+ o73wpYnNkjtMqt20zRvGoOJ1CNFJ/aJzrei29FPoKDKLPqmv1/ZPpiEsNKSPS1mSUMRRtrS0N+3er es2eDOw24JRSwJl7ZT3/a10z4uyDfZGdKhw9ZdUivkWFGDZpeoODW8uDPFcnp3Pcts7/Oc3KD6Yo2 OG0KUkNVC9U3YdtdsLAxLmNrpoSTazvbWBa3BfP+Dd6LWU41ZzaMHmapF9ZVEDIw8orUUddZzrcHk mer8+DUihkmT6SJhfxmxaN5s1VAnT/2wLQzBQWIoXGtuQA7TZdGBQHHKiZnQe0h2o7ROn4xbbRZNw AIn317Xpg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHUGX-005aBD-Ny; Wed, 03 Mar 2021 16:22:25 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHS8v-0053PG-D8 for linux-riscv@desiato.infradead.org; Wed, 03 Mar 2021 14:06:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=Z/dfY5xm4k/Ul+cKsSCbJO/Eur+ApLPQXMui9RQwcuI=; b=q1D45G/uEMubz91qSkol4FTUjx CPAU0DvoZFWnDHfFolqfunPPFVMSZ/WeX8TN7n4gsjd4IazqYoMNA8tjP3ebPDcBwvv5LZC1enX/G qx8n5bIeoGxIjedoDVvFXiriNcAA0huMSEJOQEsbvxb/cEK1kc+cgpun4hkol65Bjkeb7tmku6dZt G+au3xalCjzxfWMKwK79Mrce8F27+OF07oqsvCio35L5t2bxH2lX4GoNhfWk5GV5wIPq5CWtRVH89 xnsDsI1zHfmlyA9CXTQwwnlh4a0sb726KrWrtnZ+3pIcLAzAge3D+AWaESey/yNmytAMT30hqq+i1 tmCNvAnA==; Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH2lj-00Gyi7-Sw for linux-riscv@lists.infradead.org; Tue, 02 Mar 2021 11:00:48 +0000 Received: by mail-pl1-x629.google.com with SMTP id g20so11830316plo.2 for ; Tue, 02 Mar 2021 03:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Z/dfY5xm4k/Ul+cKsSCbJO/Eur+ApLPQXMui9RQwcuI=; b=GZ9t4ppqMF94bhg6elVg2uI0iomTwMiSRcHzvkR9zSMm+wTZsLhmeyirh4naLkS6vT 9Ra7yLccS11NjADG/wAJAPuLyUPdkNSJc/9PzsDHO1rN6ex4G6PpakY2bnUu93OoXbdr g37yzmr9uGwpfEWGlfe6EMNL6UgUZQzmqUnNJ6E0Lzmksr0ZL2Udu8qnq4F2XwWnEXJ1 lpHmclksU91BQ/OFtMqGqZlktpq/+XzFxA2h4v2Z1lh9EeRkH4WwewGrRIUN5uzso7sO plDypcr0SIJNWCzk/hjdQ3MGCwzE4RRHK35CCPst+2GBg35XylaqHX2cWNNMoVXTsJjz 2vKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Z/dfY5xm4k/Ul+cKsSCbJO/Eur+ApLPQXMui9RQwcuI=; b=Gu0kDCzf/Rs/RvOl6rWliq9V8jYKolVOEBDU3iokZIBiRtPYKH+M/1+XwhpgrMxHy/ W5pAzqKS7rTqiG9asvwESVfijf/a9ArNehg85JB8ozwaHroHYhLN85CdZEIEO1/+LcDI yd4hVMHWXqfDTiI37IPZHQzmWMjc7jx7tnSZKNaWvBJrbH5aiIdqX01aqPPejW0UX9+I 7Sqz0VAOsOiFR9rfAzjFARVewaSsP1b3xvIiMd5nQMueDwYOyxePxjcSjSOjl0dOtoZN nZ+9bVRi5JbQnuGs4650xuxdxGQtHcPFvR+xe/iSjXk5C9v4Kup//j/EOvmj47Fq4S8V 4MTw== X-Gm-Message-State: AOAM532ObISRyjvcQlbs8fIxWQu5GuEAcps5mYuIcexSSStIm/AvAR0h V6005gJli4+X5Ju+huOprcIz9A== X-Google-Smtp-Source: ABdhPJwuKmQiaA5v9dnOg9LHFYrm5ScBlxWQ0x/TG427VEY8lO0BNwTeKjkzgLULJAucs458UBppKQ== X-Received: by 2002:a17:903:1cd:b029:e5:b98e:a29 with SMTP id e13-20020a17090301cdb02900e5b98e0a29mr1293206plh.22.1614682783498; Tue, 02 Mar 2021 02:59:43 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id t26sm19500451pfq.208.2021.03.02.02.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:59:43 -0800 (PST) From: Greentime Hu To: greentime.hu@sifive.com, paul.walmsley@sifive.com, hes@sifive.com, erik.danie@sifive.com, zong.li@sifive.com, bhelgaas@google.com, robh+dt@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.pieralisi@arm.com, p.zabel@pengutronix.de, alex.dewar90@gmail.com, khilman@baylibre.com, hayashi.kunihiko@socionext.com, vidyas@nvidia.com, jh80.chung@samsung.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 4/6] dt-bindings: PCI: Add SiFive FU740 PCIe host controller Date: Tue, 2 Mar 2021 18:59:15 +0800 Message-Id: <4e63c5515f9755d0cf4cd65ab70048554d917d89.1614681831.git.greentime.hu@sifive.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_110048_927229_158956BA X-CRM114-Status: GOOD ( 10.83 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add PCIe host controller DT bindings of SiFive FU740. Signed-off-by: Greentime Hu --- .../bindings/pci/sifive,fu740-pcie.yaml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/sifive,fu740-pcie.yaml diff --git a/Documentation/devicetree/bindings/pci/sifive,fu740-pcie.yaml b/Documentation/devicetree/bindings/pci/sifive,fu740-pcie.yaml new file mode 100644 index 000000000000..879ab4f80456 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/sifive,fu740-pcie.yaml @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/sifive,fu740-pcie.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SiFive fu740 PCIe host controller + +description: | + SiFive fu740 PCIe host controller is based on the Synopsys DesignWare + PCI core. It shares common features with the PCIe DesignWare core and + inherits common properties defined in + Documentation/devicetree/bindings/pci/designware-pcie.txt. + +maintainers: + - Paul Walmsley + - Greentime Hu + +allOf: + - $ref: /schemas/pci/pci-bus.yaml# + +properties: + compatible: + const: sifive,fu740-pcie + + reg: + maxItems: 4 + + reg-names: + items: + - const: dbi + - const: config + - const: mgmt + + device_type: + const: pci + + dma-coherent: + description: Indicates that the PCIe IP block can ensure the coherency + + bus-range: + description: Range of bus numbers associated with this controller. + + num-lanes: true + + msi-parent: true + + interrupt-names: + items: + - const: msi + - const: inta + - const: intb + - const: intc + - const: intd + + resets: + description: A phandle to the PCIe power up reset line + + pwren-gpios: + description: Should specify the GPIO for controlling the PCI bus device power on + + perstn-gpios: + description: Should specify the GPIO for controlling the PCI bus device reset + +required: + - compatible + - reg + - reg-names + - device_type + - dma-coherent + - bus-range + - ranges + - num-lanes + - interrupts + - interrupt-names + - interrupt-parent + - interrupt-map-mask + - interrupt-map + - clock-names + - clocks + - resets + - pwren-gpios + - perstn-gpios + +additionalProperties: false + +examples: + - | + pcie@e00000000 { + #address-cells = <3>; + #interrupt-cells = <1>; + #size-cells = <2>; + compatible = "sifive,fu740-pcie"; + reg = <0xe 0x00000000 0x1 0x0 + 0xd 0xf0000000 0x0 0x10000000 + 0x0 0x100d0000 0x0 0x1000>; + reg-names = "dbi", "config", "mgmt"; + device_type = "pci"; + dma-coherent; + bus-range = <0x0 0xff>; + ranges = <0x81000000 0x0 0x60080000 0x0 0x60080000 0x0 0x10000 /* I/O */ + 0x82000000 0x0 0x60090000 0x0 0x60090000 0x0 0xff70000 /* mem */ + 0x82000000 0x0 0x70000000 0x0 0x70000000 0x0 0x1000000 /* mem */ + 0xc3000000 0x20 0x00000000 0x20 0x00000000 0x20 0x00000000>; /* mem prefetchable */ + num-lanes = <0x8>; + interrupts = <56 57 58 59 60 61 62 63 64>; + interrupt-names = "msi", "inta", "intb", "intc", "intd"; + interrupt-parent = <&plic0>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &plic0 57>, + <0x0 0x0 0x0 0x2 &plic0 58>, + <0x0 0x0 0x0 0x3 &plic0 59>, + <0x0 0x0 0x0 0x4 &plic0 60>; + clock-names = "pcie_aux"; + clocks = <&prci PRCI_CLK_PCIE_AUX>; + resets = <&prci 4>; + pwren-gpios = <&gpio 5 0>; + perstn-gpios = <&gpio 8 0>; + }; From patchwork Tue Mar 2 10:59:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12114067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9906C433DB for ; Wed, 3 Mar 2021 18:37:27 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4164364ED4 for ; Wed, 3 Mar 2021 18:37:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4164364ED4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=G9rUuUUO3RxoDbS9cf4iLpZyOqLHH91uN+A+C0fC7u0=; b=jFdMFyu1a1ZB2fRcbga++pm8F FnvVr/bMe4LkdRHxV2pB9gULmDNIMOXaGE819SBuMTOh7BSAA3dq9nzIo4zxv5prHzO/cjki+DHzS Sfoq1sDEEG+PKWEes2fzK29Hhi1CV4+mgFh9qYfGPt9G0mves9f5ZrOIf5TcH6Mo9WqAWhF2/a17q M2oOYcu9g3GvPt+fHZLD58G0RjsIi6oSi/yo6eNblmvz98FgjMz2g7a7a38dqTXDiZbeSo9Oc+hCv 75p7/keNfo4QL+e2p/kB8UuubEU8aRZDdbIW/Jiz1J0dCr4A0BE569nOEd0ZoDOjG9ZPd8jqhUdxg QCL0VG3wg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHWMy-0062tO-K0; Wed, 03 Mar 2021 18:37:12 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHT10-005HBT-Qk for linux-riscv@desiato.infradead.org; Wed, 03 Mar 2021 15:02:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=G721zZTwXfYMtU5FKmiux3Od7hwLZ+OelKtBGyhozqk=; b=H88qz9Ybo0yoKIHkD5UuhzhZVs JIZoel73dymobL2DxwAMxsVxFYcnlr4ZI7W4waX6oLehPYa8TuixxJbPlHWQBlffBgy/2Q3JBcMbk YO+wboZDmN8nJpGmyGqE+cIbf6ZR/kUVn1b0+2kyfXG92DhWWt0ndYZ6JdkYfyv8UXqO6M4rRCny5 1KQAOFvEbamKkzFV5XGa7sJDLli9PvZtQvz0YkRtXP1ybxuCaFZxPB9xTwuPP75SMR3MULB29lq4S 2BVJgWOkH3MWdpKt0nFaU7/hx5pQna2y3JX75u6YNw0vmfJvtnlhHWh2LGnTD7L0DjSKZP1cmoJY7 CFVMh09A==; Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH2lm-00Gyin-U5 for linux-riscv@lists.infradead.org; Tue, 02 Mar 2021 11:00:52 +0000 Received: by mail-pj1-x1034.google.com with SMTP id c19so1690935pjq.3 for ; Tue, 02 Mar 2021 03:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=G721zZTwXfYMtU5FKmiux3Od7hwLZ+OelKtBGyhozqk=; b=grw+olZL2twC8Xldd7dQSXPQfG7nWEMJj8nv87WJS01VE/TWfVFNB7phJ0/1ixVMbS 9mWP5IRsVDKjJ1Iqw5MD95sNUY5I6+QnbCKgpR9fWmGEljLcCfFUX6f5bsXGnlssvg4L 6Fe0alWFn121cdEOGTZc9D+V5+G2hU0QEgTgriNZwd9IX8t8MT5LzaWi9babqLwpAApT kcPpfdWOrm86mFHWol40KOvqDvyzLApfPPMr9xexnyT7t6Rje5gyJPk6Y3KZHR94RjiB 77nNi2j8NK5y2c5/QWRCA6IaV8B8lwFAUMZKcBtk4FTnKLGlzKmVhUbLR55pbloOTUQo eMCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G721zZTwXfYMtU5FKmiux3Od7hwLZ+OelKtBGyhozqk=; b=fe6RjdqpiO5TRqxB58H1z2KYiZjHIV5/BAUkE/gmn9KnoYydbvjW4Ce5s1MfH4hA6o YeYcX8vFh3tCjHQQtX5Wx0gkXw71CjaUuDRxRQNf++rozxGnUu6I5SZK91pW23raNLq0 AFykTMaIeOuFOw2YO5AG4iPdiF8qsgt5bZkrjpGEdljYVI3qJHTihIoQ7EChlgl1SfVE Ix47/dm6DIowwmtVJSNrfLjDuzd6Az3GXFXjrmHEfrjJpD8AEs2DpSGgRN19UgxjQ1VQ +sMLMLmPLfBAdk1p+h0TpEdzZ/yZt75tO6XCFGmDN5gyVVqguUHcQGZrGGDXSapItm4K fDXQ== X-Gm-Message-State: AOAM532MwcXplrALRnjiAk1LDSt/dhOBvrXTbzU+RMJtJN5QbKdoGDOT 91KbwnSQ/CwZauYn1N+wBAH8tg== X-Google-Smtp-Source: ABdhPJzQis8oY/O/HsDLYmmbmxWLv7ai03+FTORunnD359++ALLJ2+RnWQAUsXuOc3FNu0HXCHI00A== X-Received: by 2002:a17:902:b711:b029:e3:71f1:e08e with SMTP id d17-20020a170902b711b02900e371f1e08emr3262092pls.18.1614682787466; Tue, 02 Mar 2021 02:59:47 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id t26sm19500451pfq.208.2021.03.02.02.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:59:47 -0800 (PST) From: Greentime Hu To: greentime.hu@sifive.com, paul.walmsley@sifive.com, hes@sifive.com, erik.danie@sifive.com, zong.li@sifive.com, bhelgaas@google.com, robh+dt@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.pieralisi@arm.com, p.zabel@pengutronix.de, alex.dewar90@gmail.com, khilman@baylibre.com, hayashi.kunihiko@socionext.com, vidyas@nvidia.com, jh80.chung@samsung.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 5/6] PCI: designware: Add SiFive FU740 PCIe host controller driver Date: Tue, 2 Mar 2021 18:59:16 +0800 Message-Id: <34c2c3985443b23a75ce89c605c4b833bbafd134.1614681831.git.greentime.hu@sifive.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_110052_444192_DC77A87E X-CRM114-Status: GOOD ( 24.25 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Paul Walmsley Add driver for the SiFive FU740 PCIe host controller. This controller is based on the DesignWare PCIe core. Co-developed-by: Henry Styles Signed-off-by: Henry Styles Co-developed-by: Erik Danie Signed-off-by: Erik Danie Co-developed-by: Greentime Hu Signed-off-by: Greentime Hu Signed-off-by: Paul Walmsley --- drivers/pci/controller/dwc/Kconfig | 9 + drivers/pci/controller/dwc/Makefile | 1 + drivers/pci/controller/dwc/pcie-fu740.c | 455 ++++++++++++++++++++++++ 3 files changed, 465 insertions(+) create mode 100644 drivers/pci/controller/dwc/pcie-fu740.c diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig index 22c5529e9a65..0a37d21ed64e 100644 --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -318,4 +318,13 @@ config PCIE_AL required only for DT-based platforms. ACPI platforms with the Annapurna Labs PCIe controller don't need to enable this. +config PCIE_FU740 + bool "SiFive FU740 PCIe host controller" + depends on PCI_MSI_IRQ_DOMAIN + depends on SOC_SIFIVE || COMPILE_TEST + select PCIE_DW_HOST + help + Say Y here if you want PCIe controller support for the SiFive + FU740. + endmenu diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile index a751553fa0db..625f6aaeb5b8 100644 --- a/drivers/pci/controller/dwc/Makefile +++ b/drivers/pci/controller/dwc/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o +obj-$(CONFIG_PCIE_FU740) += pcie-fu740.o obj-$(CONFIG_PCI_IMX6) += pci-imx6.o obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone.o diff --git a/drivers/pci/controller/dwc/pcie-fu740.c b/drivers/pci/controller/dwc/pcie-fu740.c new file mode 100644 index 000000000000..6916eea40ea5 --- /dev/null +++ b/drivers/pci/controller/dwc/pcie-fu740.c @@ -0,0 +1,455 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * FU740 DesignWare PCIe Controller integration + * Copyright (C) 2019-2021 SiFive, Inc. + * Paul Walmsley + * Greentime Hu + * + * Based in part on the i.MX6 PCIe host controller shim which is: + * + * Copyright (C) 2013 Kosagi + * https://www.kosagi.com + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcie-designware.h" + +#define to_fu740_pcie(x) dev_get_drvdata((x)->dev) + +struct fu740_pcie { + struct dw_pcie *pci; + void __iomem *mgmt_base; + int perstn_gpio; + int pwren_gpio; + struct clk *pcie_aux; + struct reset_control *rst; +}; + +#define SIFIVE_DEVICESRESETREG 0x28 + +#define PCIEX8MGMT_PERST_N 0x0 +#define PCIEX8MGMT_APP_LTSSM_ENABLE 0x10 +#define PCIEX8MGMT_APP_HOLD_PHY_RST 0x18 +#define PCIEX8MGMT_DEVICE_TYPE 0x708 +#define PCIEX8MGMT_PHY0_CR_PARA_ADDR 0x860 +#define PCIEX8MGMT_PHY0_CR_PARA_RD_EN 0x870 +#define PCIEX8MGMT_PHY0_CR_PARA_RD_DATA 0x878 +#define PCIEX8MGMT_PHY0_CR_PARA_SEL 0x880 +#define PCIEX8MGMT_PHY0_CR_PARA_WR_DATA 0x888 +#define PCIEX8MGMT_PHY0_CR_PARA_WR_EN 0x890 +#define PCIEX8MGMT_PHY0_CR_PARA_ACK 0x898 +#define PCIEX8MGMT_PHY1_CR_PARA_ADDR 0x8a0 +#define PCIEX8MGMT_PHY1_CR_PARA_RD_EN 0x8b0 +#define PCIEX8MGMT_PHY1_CR_PARA_RD_DATA 0x8b8 +#define PCIEX8MGMT_PHY1_CR_PARA_SEL 0x8c0 +#define PCIEX8MGMT_PHY1_CR_PARA_WR_DATA 0x8c8 +#define PCIEX8MGMT_PHY1_CR_PARA_WR_EN 0x8d0 +#define PCIEX8MGMT_PHY1_CR_PARA_ACK 0x8d8 + +/* PCIe Port Logic registers (memory-mapped) */ +#define PL_OFFSET 0x700 +#define PCIE_PL_GEN2_CTRL_OFF (PL_OFFSET + 0x10c) +#define PCIE_PL_DIRECTED_SPEED_CHANGE_OFF 0x20000 + +#define PCIE_PHY_MAX_RETRY_CNT 1000 + +static void fu740_pcie_assert_perstn(struct fu740_pcie *afp) +{ + /* PERST_N GPIO */ + if (gpio_is_valid(afp->perstn_gpio)) + gpio_direction_output(afp->perstn_gpio, 0); + + /* Controller PERST_N */ + __raw_writel(0x0, afp->mgmt_base + PCIEX8MGMT_PERST_N); +} + +static void fu740_pcie_deassert_perstn(struct fu740_pcie *afp) +{ + /* Controller PERST_N */ + __raw_writel(0x1, afp->mgmt_base + PCIEX8MGMT_PERST_N); + /* PERST_N GPIO */ + if (gpio_is_valid(afp->perstn_gpio)) + gpio_direction_output(afp->perstn_gpio, 1); +} + +static void fu740_pcie_power_on(struct fu740_pcie *afp) +{ + if (gpio_is_valid(afp->pwren_gpio)) { + gpio_direction_output(afp->pwren_gpio, 1); + mdelay(100); + } +} + +static void fu740_pcie_drive_perstn(struct fu740_pcie *afp) +{ + fu740_pcie_assert_perstn(afp); + fu740_pcie_power_on(afp); + fu740_pcie_deassert_perstn(afp); +} + +static void fu740_phyregreadwrite(const uint8_t phy, const uint8_t write, + const uint16_t addr, + const uint16_t wrdata, uint16_t *rddata, + struct fu740_pcie *afp) +{ + unsigned char ack = 0; + unsigned int cnt = 0; + struct device *dev = afp->pci->dev; + + /* setup */ + __raw_writel(addr, + afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_ADDR : + PCIEX8MGMT_PHY0_CR_PARA_ADDR)); + if (write) + __raw_writel(wrdata, + afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_WR_DATA : + PCIEX8MGMT_PHY0_CR_PARA_WR_DATA)); + if (write) + __raw_writel(1, + afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_WR_EN : + PCIEX8MGMT_PHY0_CR_PARA_WR_EN)); + else + __raw_writel(1, + afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_RD_EN : + PCIEX8MGMT_PHY0_CR_PARA_RD_EN)); + + /* wait for wait_idle */ + do { + if (__raw_readl + (afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_ACK : + PCIEX8MGMT_PHY0_CR_PARA_ACK))) { + ack = 1; + if (!write) + __raw_readl(afp->mgmt_base + + (phy ? + PCIEX8MGMT_PHY1_CR_PARA_RD_DATA : + PCIEX8MGMT_PHY0_CR_PARA_RD_DATA)); + } + } while (!ack); + + /* clear */ + if (write) + __raw_writel(0, + afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_WR_EN : + PCIEX8MGMT_PHY0_CR_PARA_WR_EN)); + else + __raw_writel(0, + afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_RD_EN : + PCIEX8MGMT_PHY0_CR_PARA_RD_EN)); + + /* wait for ~wait_idle */ + while (__raw_readl + (afp->mgmt_base + + (phy ? PCIEX8MGMT_PHY1_CR_PARA_ACK : + PCIEX8MGMT_PHY0_CR_PARA_ACK))) { + cpu_relax(); + cnt++; + if (cnt > PCIE_PHY_MAX_RETRY_CNT) { + dev_err(dev, "PCIE phy doesn't enter idle state.\n"); + break; + } + } +} + +static void fu740_pcie_init_phy(struct fu740_pcie *afp) +{ + int lane; + + /* enable phy cr_para_sel interfaces */ + __raw_writel(0x1, afp->mgmt_base + PCIEX8MGMT_PHY0_CR_PARA_SEL); + __raw_writel(0x1, afp->mgmt_base + PCIEX8MGMT_PHY1_CR_PARA_SEL); + + /* wait 10 cr_para cycles */ + msleep(1); + + /* set PHY AC termination mode */ + for (lane = 0; lane < 4; lane++) { + fu740_phyregreadwrite(0, 1, + 0x1008 + (0x100 * lane), + 0x0e21, NULL, afp); + fu740_phyregreadwrite(1, 1, + 0x1008 + (0x100 * lane), + 0x0e21, NULL, afp); + } + +} + +static void fu740_pcie_ltssm_enable(struct device *dev) +{ + struct fu740_pcie *afp = dev_get_drvdata(dev); + + /* Enable LTSSM */ + __raw_writel(0x1, afp->mgmt_base + PCIEX8MGMT_APP_LTSSM_ENABLE); +} + +static int fu740_pcie_start_link(struct dw_pcie *pci) +{ + struct device *dev = pci->dev; + u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); + u32 tmp; + int ret; + + /* + * Force Gen1 operation when starting the link. In case the link is + * started in Gen2 mode, there is a possibility the devices on the + * bus will not be detected at all. This happens with PCIe switches. + */ + dw_pcie_dbi_ro_wr_en(pci); + tmp = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP); + tmp &= ~PCI_EXP_LNKCAP_SLS; + tmp |= PCI_EXP_LNKCAP_SLS_2_5GB; + dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, tmp); + dw_pcie_dbi_ro_wr_dis(pci); + + /* Start LTSSM. */ + fu740_pcie_ltssm_enable(dev); + + ret = dw_pcie_wait_for_link(pci); + if (ret) + goto err_reset_phy; + + /* Now set it to operate in Gen3 */ + dw_pcie_dbi_ro_wr_en(pci); + tmp = dw_pcie_readl_dbi(pci, offset + PCI_EXP_LNKCAP); + tmp &= ~PCI_EXP_LNKCAP_SLS; + tmp |= PCI_EXP_LNKCAP_SLS_8_0GB; + dw_pcie_writel_dbi(pci, offset + PCI_EXP_LNKCAP, tmp); + /* Enable DIRECTED SPEED CHANGE bit of GEN2_CTRL_OFF register */ + tmp = dw_pcie_readl_dbi(pci, PCIE_PL_GEN2_CTRL_OFF); + tmp |= PCIE_PL_DIRECTED_SPEED_CHANGE_OFF; + dw_pcie_writel_dbi(pci, PCIE_PL_GEN2_CTRL_OFF, tmp); + dw_pcie_dbi_ro_wr_dis(pci); + + ret = dw_pcie_wait_for_link(pci); + if (ret) + goto err_reset_phy; + + /* + * Reenable DIRECTED SPEED CHANGE. + * + * You need to set this bit after each speed change, but after + * reaching G1, setting it once doesn't seem to work (it reaches G3 + * equalization states and then times out, falls back to G1). But + * If after that, you set it again, it then reaches G3 perfectly + * fine. + */ + dw_pcie_dbi_ro_wr_en(pci); + tmp = dw_pcie_readl_dbi(pci, PCIE_PL_GEN2_CTRL_OFF); + tmp |= PCIE_PL_DIRECTED_SPEED_CHANGE_OFF; + dw_pcie_writel_dbi(pci, PCIE_PL_GEN2_CTRL_OFF, tmp); + dw_pcie_dbi_ro_wr_dis(pci); + + ret = dw_pcie_wait_for_link(pci); + if (ret) + goto err_reset_phy; + + tmp = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA); + dev_info(dev, "Link up, Gen%i\n", tmp & PCI_EXP_LNKSTA_CLS); + return 0; + + err_reset_phy: + dev_err(dev, "Failed to bring link up!\n" + "PHY DEBUG_R0=0x%08x DEBUG_R1=0x%08x\n", + dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG0), + dw_pcie_readl_dbi(pci, PCIE_PORT_DEBUG1)); + return ret; +} + +static int fu740_pcie_host_init(struct pcie_port *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct fu740_pcie *afp = to_fu740_pcie(pci); + struct device *dev = pci->dev; + int ret = 0; + + /* power on reset */ + fu740_pcie_drive_perstn(afp); + + /* enable pcieauxclk */ + ret = clk_prepare_enable(afp->pcie_aux); + if (ret) + dev_err(dev, "unable to enable pcie_aux clock\n"); + + /* + * assert hold_phy_rst (hold the controller LTSSM in reset after + * power_up_rst_n + * for register programming with cr_para) + */ + __raw_writel(0x1, afp->mgmt_base + PCIEX8MGMT_APP_HOLD_PHY_RST); + + /* deassert power_up_rst_n */ + ret = reset_control_deassert(afp->rst); + if (ret) + dev_err(dev, "unable to deassert pcie_power_up_rst_n\n"); + + fu740_pcie_init_phy(afp); + + /* disable pcieauxclk */ + clk_disable_unprepare(afp->pcie_aux); + /* clear hold_phy_rst */ + __raw_writel(0x0, afp->mgmt_base + PCIEX8MGMT_APP_HOLD_PHY_RST); + /* enable pcieauxclk */ + ret = clk_prepare_enable(afp->pcie_aux); + /* set RC mode */ + __raw_writel(0x4, afp->mgmt_base + PCIEX8MGMT_DEVICE_TYPE); + + return 0; +} + +static const struct dw_pcie_host_ops fu740_pcie_host_ops = { + .host_init = fu740_pcie_host_init, +}; + +static const struct dw_pcie_ops dw_pcie_ops = { + .start_link = fu740_pcie_start_link, +}; + +static const struct dev_pm_ops fu740_pcie_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(fu740_pcie_suspend_noirq, + fu740_pcie_resume_noirq) +}; + +static int fu740_pcie_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct dw_pcie *pci; + struct fu740_pcie *afp; + struct resource *mgmt_res; + struct device_node *node = dev->of_node; + int ret; + u16 val; + + afp = devm_kzalloc(dev, sizeof(*afp), GFP_KERNEL); + if (!afp) + return -ENOMEM; + + pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL); + if (!pci) + return -ENOMEM; + + pci->dev = dev; + pci->ops = &dw_pcie_ops; + pci->pp.ops = &fu740_pcie_host_ops; + + afp->pci = pci; + + mgmt_res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mgmt"); + if (!mgmt_res) { + dev_warn(dev, "missing required mgmt address range"); + return -ENOENT; + } + afp->mgmt_base = devm_ioremap_resource(dev, mgmt_res); + if (IS_ERR(afp->mgmt_base)) + return PTR_ERR(afp->mgmt_base); + + /* Fetch GPIOs */ + afp->perstn_gpio = of_get_named_gpio(node, "perstn-gpios", 0); + if (gpio_is_valid(afp->perstn_gpio)) { + ret = devm_gpio_request_one(dev, afp->perstn_gpio, + GPIOF_OUT_INIT_LOW, "perstn-gpios"); + if (ret) { + dev_err(dev, "unable to get perstn gpio\n"); + return ret; + } + } else if (afp->perstn_gpio == -EPROBE_DEFER) { + dev_err(dev, "perst-gpios EPROBE_DEFER\n"); + return afp->perstn_gpio; + } + + afp->pwren_gpio = of_get_named_gpio(node, "pwren-gpios", 0); + if (gpio_is_valid(afp->pwren_gpio)) { + ret = devm_gpio_request_one(dev, afp->pwren_gpio, + GPIOF_OUT_INIT_LOW, "pwren-gpios"); + if (ret) { + dev_err(dev, "unable to get pwren gpio\n"); + return ret; + } + } else if (afp->pwren_gpio == -EPROBE_DEFER) { + dev_err(dev, "pwren-gpios EPROBE_DEFER\n"); + return afp->pwren_gpio; + } + + /* Fetch clocks */ + afp->pcie_aux = devm_clk_get(dev, "pcie_aux"); + if (IS_ERR(afp->pcie_aux)) + return dev_err_probe(dev, PTR_ERR(afp->pcie_aux), + "pcie_aux clock source missing or invalid\n"); + + /* Fetch reset */ + afp->rst = devm_reset_control_get(dev, NULL); + if (IS_ERR(afp->rst)) + return dev_err_probe(dev, PTR_ERR(afp->rst), "unable to get reset\n"); + + platform_set_drvdata(pdev, afp); + + ret = dw_pcie_host_init(&pci->pp); + if (ret < 0) + return ret; + + if (pci_msi_enabled()) { + u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_MSI); + + val = dw_pcie_readw_dbi(pci, offset + PCI_MSI_FLAGS); + val |= PCI_MSI_FLAGS_ENABLE; + dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS, val); + } + + return 0; +} + +static void fu740_pcie_shutdown(struct platform_device *pdev) +{ + struct fu740_pcie *afp = platform_get_drvdata(pdev); + + /* bring down link, so bootloader gets clean state in case of reboot */ + fu740_pcie_assert_perstn(afp); +} + +static const struct of_device_id fu740_pcie_of_match[] = { + {.compatible = "sifive,fu740-pcie"}, + {}, +}; + +static struct platform_driver fu740_pcie_driver = { + .driver = { + .name = "fu740-pcie", + .of_match_table = fu740_pcie_of_match, + .suppress_bind_attrs = true, + .pm = &fu740_pcie_pm_ops, + }, + .probe = fu740_pcie_probe, + .shutdown = fu740_pcie_shutdown, +}; + +static int __init fu740_pcie_init(void) +{ + return platform_driver_register(&fu740_pcie_driver); +} + +device_initcall(fu740_pcie_init); From patchwork Tue Mar 2 10:59:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12113631 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5296EC433DB for ; Wed, 3 Mar 2021 14:25:34 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42DE564EDF for ; Wed, 3 Mar 2021 14:25:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42DE564EDF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; 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:To:From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+WGUM7i0SqyG9RVG33wumywbzeouAbCAmBxIMQSnyD8=; b=RNoQ5ZdaSL7CMnY7ahSgMtxHo F2IT8FS1hiJqmn3yYFXx6BlJvPBfmCAmHdScYASoubQ5guIYdYIrW7fX7pC4pQe+lGwAEur1W66Pa ahN0fgSPyKXRUFf3cTMuHYuxiDRA932JQg8d35toGMGYzB9Hxa74YlWyxLNBxxk6neT9cNdUh76+P xsKHk63TKahTbmdWCkwgpzWqeWuhjfbTJYkHoXn01vYJAHSYJROCIeht9fRO5nTRcYxFN7d1jvomi 0u57O/3MZCmtR/8JewdaWuwrBJNy0nQlluTbdvnxay2TBrtJDGra5vSFIhjz/VO1aDG98f3xcuheI fdeMhmnZA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHSQp-0057Kt-Ez; Wed, 03 Mar 2021 14:24:55 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHS86-005326-Eb for linux-riscv@desiato.infradead.org; Wed, 03 Mar 2021 14:05:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=Po2WnbeRcNxbdVRWP+uTe3ZxilZPtJNj+wNjess1Fqs=; b=spV0cQ1v07EPq2LbiMgjPp4uBM e1y704AoCTomDjHh9K2+6jymMgrzlThI1eCWyp9gph5XHJrZaFgn0hvMAFeb1KwLVRk5NXujH4ucd uWK8Inh/y5Ari091c3+jPcqGnb5do5IpsjLor6tNcnb0MZKkhWCFPWs2BsOdmLKDgsFDyL+C71zVD /EsKyuVMUoejETFZmqlFth99eQE1GBy76DrI+0ofnwqw+DKXDWO/BKwkZO+z5RTJ67Sh8AppqqOEB 8h/KcGq6ltiZhwoJPEGl76Ws63GMsrpkTqvbqlinjME+2/y9RzCrB12XOaHbEHAdU1ER6F22l2MbA 8CAmRQpA==; Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lH2lp-00Gyj1-VM for linux-riscv@lists.infradead.org; Tue, 02 Mar 2021 11:00:55 +0000 Received: by mail-pj1-x1033.google.com with SMTP id d13-20020a17090abf8db02900c0590648b1so1083052pjs.1 for ; Tue, 02 Mar 2021 03:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Po2WnbeRcNxbdVRWP+uTe3ZxilZPtJNj+wNjess1Fqs=; b=a5MyBXo6eov2ekIk8ZTfKHDNNdEoI4pKVri0SYc2F9SqYWibdQAXMjW3/w7FU/p/kg c51InQz0krRao9T5zPLw59TMVGitBuCGxloOW2a6N2HxyYz+5D+BaKS6EexoelT6VG/F cLhmS6GHKPR/R9pUBTpK+ZzLQq4r3k3u5M2k/oK8DNOa2g9pRU5In7tUGmZrN5oax8Gp xtafybVddL4BjJoA01DR/QEKBy55T32hKD1PoSLSqD/4iLIQMuoV5gKApwWVSxk36oMa 7VrN6Rzarf0ceik8mxDudoNJSOkGYM6IgV9gBF765dqYhMGp5Cogl4ysmSY9NRz8K7qk G77g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Po2WnbeRcNxbdVRWP+uTe3ZxilZPtJNj+wNjess1Fqs=; b=TQzTrXT1Ouq15DhTkctsdgQNm1yFPEF2QO4a1lgOjChJpgj9rhHpT8bjNud2DGbq3N WoiLZE/xhSiYDVHafaSmm8P7HzcStjf4+QbNgY8qcj8Uwp3ydM38k6Ow8IAxLrd8ONqO eZ/34uiyElR6cBgE5/5PegH7BfB6S8Tp3yc47RWnV/T/HJ11W1qtwjyhLtZs+S9WjDcc Mh+b/cpRgbxt4vO3x4zjxKCZLZvZwUL4TNmKChK2pFjFsxhpygEPh4dIyEI4yEe0S0gN TJlpfenPlzNolXNipNplCEVjVn6xb47CfMCLiBMJSY1WRHKtV+rUujJOErf6ABM8TtEC FgKA== X-Gm-Message-State: AOAM533HYqy9so/09INS2md2wuBorrSqoX1sUXXMzmnJ6jz+Ji37JFnG MfHJpZD/3fROA4iLcYtyXYeD/A== X-Google-Smtp-Source: ABdhPJxJIJ3Tse6OxPoZISwk+LpR8TLSC6nbCdGBioVdI/phJeX6zkYJhK340UzKOl5FITpYzpeIZw== X-Received: by 2002:a17:90a:9905:: with SMTP id b5mr3711228pjp.195.1614682791332; Tue, 02 Mar 2021 02:59:51 -0800 (PST) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id t26sm19500451pfq.208.2021.03.02.02.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Mar 2021 02:59:50 -0800 (PST) From: Greentime Hu To: greentime.hu@sifive.com, paul.walmsley@sifive.com, hes@sifive.com, erik.danie@sifive.com, zong.li@sifive.com, bhelgaas@google.com, robh+dt@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, mturquette@baylibre.com, sboyd@kernel.org, lorenzo.pieralisi@arm.com, p.zabel@pengutronix.de, alex.dewar90@gmail.com, khilman@baylibre.com, hayashi.kunihiko@socionext.com, vidyas@nvidia.com, jh80.chung@samsung.com, linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [RFC PATCH 6/6] riscv: dts: Add PCIe support for the SiFive FU740-C000 SoC Date: Tue, 2 Mar 2021 18:59:17 +0800 Message-Id: X-Mailer: git-send-email 2.30.0 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_110054_967882_523243DA X-CRM114-Status: UNSURE ( 7.70 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Signed-off-by: Greentime Hu --- arch/riscv/boot/dts/sifive/fu740-c000.dtsi | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/arch/riscv/boot/dts/sifive/fu740-c000.dtsi b/arch/riscv/boot/dts/sifive/fu740-c000.dtsi index d1bb22b11920..d0839739b425 100644 --- a/arch/riscv/boot/dts/sifive/fu740-c000.dtsi +++ b/arch/riscv/boot/dts/sifive/fu740-c000.dtsi @@ -158,6 +158,7 @@ prci: clock-controller@10000000 { reg = <0x0 0x10000000 0x0 0x1000>; clocks = <&hfclk>, <&rtcclk>; #clock-cells = <1>; + #reset-cells = <1>; }; uart0: serial@10010000 { compatible = "sifive,fu740-c000-uart", "sifive,uart0"; @@ -288,5 +289,38 @@ gpio: gpio@10060000 { clocks = <&prci PRCI_CLK_PCLK>; status = "disabled"; }; + pcie@e00000000 { + #address-cells = <3>; + #interrupt-cells = <1>; + #num-lanes = <8>; + #size-cells = <2>; + compatible = "sifive,fu740-pcie"; + reg = <0xe 0x00000000 0x1 0x0 + 0xd 0xf0000000 0x0 0x10000000 + 0x0 0x100d0000 0x0 0x1000>; + reg-names = "dbi", "config", "mgmt"; + device_type = "pci"; + dma-coherent; + bus-range = <0x0 0xff>; + ranges = <0x81000000 0x0 0x60080000 0x0 0x60080000 0x0 0x10000 /* I/O */ + 0x82000000 0x0 0x60090000 0x0 0x60090000 0x0 0xff70000 /* mem */ + 0x82000000 0x0 0x70000000 0x0 0x70000000 0x0 0x1000000 /* mem */ + 0xc3000000 0x20 0x00000000 0x20 0x00000000 0x20 0x00000000>; /* mem prefetchable */ + num-lanes = <0x8>; + interrupts = <56 57 58 59 60 61 62 63 64>; + interrupt-names = "msi", "inta", "intb", "intc", "intd"; + interrupt-parent = <&plic0>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &plic0 57>, + <0x0 0x0 0x0 0x2 &plic0 58>, + <0x0 0x0 0x0 0x3 &plic0 59>, + <0x0 0x0 0x0 0x4 &plic0 60>; + clock-names = "pcie_aux"; + clocks = <&prci PRCI_CLK_PCIE_AUX>; + pwren-gpios = <&gpio 5 0>; + perstn-gpios = <&gpio 8 0>; + resets = <&prci 4>; + status = "okay"; + }; }; };