From patchwork Tue Apr 6 09:26:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greentime Hu X-Patchwork-Id: 12184663 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,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 8AB6CC433ED for ; Tue, 6 Apr 2021 09:27:07 +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 3D72F613C4 for ; Tue, 6 Apr 2021 09:27:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3D72F613C4 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=P192ppIXF/qA09gHcCFl2NwcNbS+LBDQehKJLO5dYx8=; b=MqG+W+Tvo+SRwNDCu8xRLZIkt 0GCmG0ioN0TRjsdh7fFH6gNfJsqLBj/unZDpeUMVJQrANuBsxlhZKwc4ym7/69NI5o2O/Sa1x0Opt Y1T66fLSschjAdeFkojTsrJ1aFDnDFXYtNN/3crOBsSa3Xzuhz7zap0P0o87VabHSgx6O8AL+aB1l JDfJAHb1HxRHM5gBgRZIiQVKV9G+N+DMp4qzc1uaDaoGQpWI5LmrACL2dNK6hnp0WxRlActY0y5lN YZ1i0Ttw+1dMIxRRUmSmd//4N4Zk48MchDUlIJqTLN56OjEMbF/TIFi8VvtximUDi6QdJco/qNU/z 3fR1hqIIA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lThz4-0020on-Mm; Tue, 06 Apr 2021 09:26:54 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lThz0-0020nm-Qi for linux-riscv@lists.infradead.org; Tue, 06 Apr 2021 09:26:52 +0000 Received: by mail-pl1-x631.google.com with SMTP id d8so7143550plh.11 for ; Tue, 06 Apr 2021 02:26:50 -0700 (PDT) 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=N3Ofv7Rek7cgGq9uaGjBnpEgWWaqpn6QcKrofIPEUwg=; b=HdpsD23ddU5o3+4Q3um01ArRXSBgFQCSf9fvg0Onusd7OTlW31mKWwVVtn9hRdNbl7 NEL9XGb2EkF9EOtE4b3xKHdHa14BxAMMsBSHQLWu+kzl76nN+46LooziNw0id3gYtSgg 3h+BFA7ULzSJJSZbS35OUhL5tfdzSKlyJcg1UJN8sW6TtnXtsqfKPeoTXGotlIgxbhon TCllR7Y0G6lrpPbffWItio84nYZ7tzm5HZcOgYzvTyRr3lhmMV2AHjCz/tK8jxyI0if2 Ad7Nxiv9JBJvzh5D9XPCXCMs2vKpJI2V1WMUU2loiSOYonbSQS2NbSlPAZUsHRK/B1Nd bMpQ== 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=N3Ofv7Rek7cgGq9uaGjBnpEgWWaqpn6QcKrofIPEUwg=; b=PZPH0UCYyMWjreII+BlqBVdcvVXIMfhMlD0UfucUsyLKIlMV90+oWT6kgMCDkuBxti AxCWC7y7nMK/1pfj1lOQw7DfaDapr2K/jiqT4LrDGs8ksl3Dqm3aW+/oRy7hSMrnKiWE j+rsLMybIbIrGu+KPUan0HzxGHv9iB9dYdy3aEe2EiosVBZQDLMwCilJknHVcg4iJM3D +JCApTniELfuuT4y4WdlCu7QhzO6NmtkPF9qfVywrvgC2TcAl2BWQ1yDsaMW3pJ5nzvN 2loKhxT4lgh7lDNM2uSZhcSUj8D6Sg2ROdl7VeOdpFyWoGX2+mT7k/Fb2F5UdY5aMspU PucA== X-Gm-Message-State: AOAM533nVTwToIAkSsdWGtP9JT3rCUhox7qz8/yRF8wdBZFFLxvKf2jo gHBenL1vpidSQKpKA9qHOY37vQ== X-Google-Smtp-Source: ABdhPJzMuJPf8f4/IXZ9RS34Yy4BurTWBeHq615uq0YF1SvUR0UA0RpYGBc1YO+y3qX187XTl+JQlg== X-Received: by 2002:a17:90a:7b85:: with SMTP id z5mr1861348pjc.39.1617701209420; Tue, 06 Apr 2021 02:26:49 -0700 (PDT) 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 w7sm13685589pff.208.2021.04.06.02.26.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 02:26:48 -0700 (PDT) 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, 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, helgaas@kernel.org Subject: [PATCH v5 2/6] clk: sifive: Use reset-simple in prci driver for PCIe driver Date: Tue, 6 Apr 2021 17:26:30 +0800 Message-Id: <20210406092634.50465-3-greentime.hu@sifive.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210406092634.50465-1-greentime.hu@sifive.com> References: <20210406092634.50465-1-greentime.hu@sifive.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210406_102650_964703_605BF449 X-CRM114-Status: GOOD ( 13.85 ) 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 Acked-by: Stephen Boyd --- drivers/clk/sifive/Kconfig | 2 ++ drivers/clk/sifive/sifive-prci.c | 13 +++++++++++++ drivers/clk/sifive/sifive-prci.h | 4 ++++ drivers/reset/Kconfig | 1 + 4 files changed, 20 insertions(+) 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 8fdba5da2902..0704fddba6b9 100644 --- a/drivers/clk/sifive/sifive-prci.c +++ b/drivers/clk/sifive/sifive-prci.c @@ -583,6 +583,19 @@ 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); 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..d0f5d0afc240 100644 --- a/drivers/reset/Kconfig +++ b/drivers/reset/Kconfig @@ -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