From patchwork Wed May 27 20:41:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinh Nguyen X-Patchwork-Id: 11573941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5232F60D for ; Wed, 27 May 2020 20:41:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31BDC20835 for ; Wed, 27 May 2020 20:41:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590612107; bh=Ug71YAZsoGA3BQn8dQLhYeUE2MzjpBSD/D+UvGQWqNQ=; h=From:To:Cc:Subject:Date:List-ID:From; b=Q9Bn0+WsR5PXrIG7PXnHt+X7j2qVIBIm27GELh9p27kUeHW8/gjXdVYCtdWko/2I9 AisaeeT1+whyaVJJh9HMr/JqvW14QnZFPadk2Za/0vcrHSlRQY0bwPQrsx3ExICyvT zQYmsb/wTt8BeCjySP0aqwcORpKZb+vl8dS0PnRI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728019AbgE0Ulk (ORCPT ); Wed, 27 May 2020 16:41:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:53222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgE0Ulj (ORCPT ); Wed, 27 May 2020 16:41:39 -0400 Received: from localhost.localdomain (cpe-70-114-128-244.austin.res.rr.com [70.114.128.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33865207BC; Wed, 27 May 2020 20:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590612099; bh=Ug71YAZsoGA3BQn8dQLhYeUE2MzjpBSD/D+UvGQWqNQ=; h=From:To:Cc:Subject:Date:From; b=s8U14Lq+ZQ49gdWC4LMdi4yECEVGzlh/JFFPH9QDfhmMdEFvFV47p0RalFhdNJeRB nZvNfyTns3VXFaL34+u46RbJQQaNU//Wy7BRyHA4G31W4BLhsWAIBo3Su9qBFF475F 6pEAvy3lnwL/apVhodsx9Gj1FHf18jN3IaaOCTSI= From: Dinh Nguyen To: linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, devicetree@vger.kernel.org, broonie@kernel.org, robh+dt@kernel.org, linux-spi@vger.kernel.org, Sergey.Semin@baikalelectronics.ru, fancer.lancer@gmail.com, andriy.shevchenko@linux.intel.com, lars.povlsen@microchip.com, Liang Jin J Subject: [PATCHv3 1/2] spi: dw: add reset control Date: Wed, 27 May 2020 15:41:09 -0500 Message-Id: <20200527204110.25676-1-dinguyen@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Add mechanism to get the reset control and deassert it in order to bring the IP out of reset. Signed-off-by: Liang Jin J Signed-off-by: Dinh Nguyen --- v3: allow for other failures remove tab for rstc reset_control v2: use _get_optional_exclusive put IP back into reset if there was an error in probe function --- drivers/spi/spi-dw-mmio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c index 384a3ab6dc2d..1e921c40d79b 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "spi-dw.h" @@ -30,6 +31,7 @@ struct dw_spi_mmio { struct clk *clk; struct clk *pclk; void *priv; + struct reset_control *rstc; }; #define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL 0x24 @@ -175,6 +177,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) if (ret) goto out_clk; + /* find an optional reset controller */ + dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi"); + if (IS_ERR(dwsmmio->rstc)) { + ret = PTR_ERR(dwsmmio->rstc); + goto out_clk; + } + reset_control_deassert(dwsmmio->rstc); + dws->bus_num = pdev->id; dws->max_freq = clk_get_rate(dwsmmio->clk); @@ -208,6 +218,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev) clk_disable_unprepare(dwsmmio->pclk); out_clk: clk_disable_unprepare(dwsmmio->clk); + reset_control_assert(dwsmmio->rstc); + return ret; } @@ -219,6 +231,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); clk_disable_unprepare(dwsmmio->pclk); clk_disable_unprepare(dwsmmio->clk); + reset_control_assert(dwsmmio->rstc); return 0; } From patchwork Wed May 27 20:41:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinh Nguyen X-Patchwork-Id: 11573939 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5B84739 for ; Wed, 27 May 2020 20:41:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EC7A20835 for ; Wed, 27 May 2020 20:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590612105; bh=Z9bdFnz1pD08lYT+ADDGs4FNE+dhk4zct/gTLKdD2e8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=newltaHEK9b5nZAsLs8CQdyzpzPCEq0GJ6MQoOgfko5ERDab6081/j+xT0d66m4Wl OdNCW52RADTpcI/SJp2YA5aRhKr02PsLoseXhqDkvbGXH2feHE3TQtRaVogr2LcWG3 3Mt99WrWNhql8KgEXu3d6Ok+pn9OGRs4LcKpvh/0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728450AbgE0Ull (ORCPT ); Wed, 27 May 2020 16:41:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:53236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgE0Ulk (ORCPT ); Wed, 27 May 2020 16:41:40 -0400 Received: from localhost.localdomain (cpe-70-114-128-244.austin.res.rr.com [70.114.128.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6EF8320890; Wed, 27 May 2020 20:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590612100; bh=Z9bdFnz1pD08lYT+ADDGs4FNE+dhk4zct/gTLKdD2e8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fuhnHJmKxeu0i6qDYipGidYG7AVEnw30cR01JBCvq+EoG6Vzhu5pgEtZ0Mhio8sxt FNvoSRHbLYTnnYIQqwLduLb715dkLIB4TLojSPly/5FYibjgwqhP3Hiz1v7e4r0iMi dqwgeMbVTnzexcJ+5bOUjuONkPZ/BWhlsKrZ5ltQ= From: Dinh Nguyen To: linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, devicetree@vger.kernel.org, broonie@kernel.org, robh+dt@kernel.org, linux-spi@vger.kernel.org, Sergey.Semin@baikalelectronics.ru, fancer.lancer@gmail.com, andriy.shevchenko@linux.intel.com, lars.povlsen@microchip.com Subject: [PATCHv3 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Date: Wed, 27 May 2020 15:41:10 -0500 Message-Id: <20200527204110.25676-2-dinguyen@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200527204110.25676-1-dinguyen@kernel.org> References: <20200527204110.25676-1-dinguyen@kernel.org> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org Add optional reset property. Signed-off-by: Dinh Nguyen --- v2: actually document the "resets" and "reset-names" optional properties --- Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt index 3ed08ee9feba..c679778612f3 100644 --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt @@ -22,6 +22,9 @@ Optional properties: - num-cs : The number of chipselects. If omitted, this will default to 4. - reg-io-width : The I/O register width (in bytes) implemented by this device. Supported values are 2 or 4 (the default). +- resets : contains an entry for each entry in reset-names. + See ../reset/reset.txt for details. +- reset-names : must contain "spi" Child nodes as per the generic SPI binding. @@ -37,5 +40,7 @@ Example: num-cs = <2>; cs-gpios = <&gpio0 13 0>, <&gpio0 14 0>; + resets = <&rst SPIM0_RST>; + reset-names = "spi"; };