From patchwork Fri May 29 15:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinh Nguyen X-Patchwork-Id: 11579169 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 DE6F5139A for ; Fri, 29 May 2020 15:58:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD4F92077D for ; Fri, 29 May 2020 15:58:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590767899; bh=DKe6k1X2sNZ70atW9Z+9GVwAyAKVYlyY5QzaAyE/cxg=; h=From:To:Cc:Subject:Date:List-ID:From; b=AOI9EVctLPnj/49bKni83tQsNOaCYlTrBD0CKEjgoT6pjqQUpL0lDOKRW2XVcveO8 Bgho8wwPbFKEcV/u2YieHwKzxeYbI4g16J+X2y4A9gNZSYuJtSFHhl19huxgfbNsE1 T8Jyz+dXNOLmOwSAE2j6tdMBxbSZ79VP0H0UfiQA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbgE2P6O (ORCPT ); Fri, 29 May 2020 11:58:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:36536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbgE2P6O (ORCPT ); Fri, 29 May 2020 11:58:14 -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 734DA2072D; Fri, 29 May 2020 15:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590767893; bh=DKe6k1X2sNZ70atW9Z+9GVwAyAKVYlyY5QzaAyE/cxg=; h=From:To:Cc:Subject:Date:From; b=h1fFz0g0JdXyYAUhlce+XjTpPSxI1Y3mpe62hzgpHexkdlnrBjJqZoWVco0nmaT1r t/ndMGO4dkMXBU37MvqKq+dfiijYoQ9Vn9vA+IjuHKu8JzQ9pHcnzZ8zKOqit6a59g gDZTmzi+bY9aNJF8iNAbUwsBxvWyGmcwr9P/OeSU= From: Dinh Nguyen To: linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, robh+dt@kernel.org, Sergey.Semin@baikalelectronics.ru, fancer.lancer@gmail.com, andriy.shevchenko@linux.intel.com, lars.povlsen@microchip.com, liang.j.jin@ericsson.com Subject: [PATCHv4 1/2] spi: dw: add reset control Date: Fri, 29 May 2020 10:58:05 -0500 Message-Id: <20200529155806.16758-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 --- v4: no change 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 0894b4c09496..a1b87d4606ba 100644 --- a/drivers/spi/spi-dw-mmio.c +++ b/drivers/spi/spi-dw-mmio.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "spi-dw.h" @@ -29,6 +30,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 @@ -224,6 +226,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); @@ -257,6 +267,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; } @@ -268,6 +280,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 Fri May 29 15:58:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinh Nguyen X-Patchwork-Id: 11579167 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 D1E74139A for ; Fri, 29 May 2020 15:58:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B8E8B2072D for ; Fri, 29 May 2020 15:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590767898; bh=zL5cZTZL9Q9NYyBA9lT7dprVoQEUmueen5FwUFKr71A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OoE7daSHy23rdb6VMNj72Au5LD+TBbx15J3lkGWgTFtmvVF0xSeOZsTt552xAnNmu Z21fPboqnLWyPCdh3Afsg1rebSFtxSTs+pgeLIbUAhI/eeeruvvD8N+9Dk2tP8mZ0q EZTj+ecDY7ksx4gM9Ql7juXfkJA7t/iqAVe/WzNQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbgE2P6P (ORCPT ); Fri, 29 May 2020 11:58:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:36584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726845AbgE2P6P (ORCPT ); Fri, 29 May 2020 11:58:15 -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 AF8E1208B8; Fri, 29 May 2020 15:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590767894; bh=zL5cZTZL9Q9NYyBA9lT7dprVoQEUmueen5FwUFKr71A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CMiV2+SxCCGbgl65XqB38WA3kKS1Bk6V3pQDJ9ZVs9H5VI9Z2pWzAuHF2cFqMwoHt Je4vYsI3doBvrNkWOw1FAxlzrIZN8qXBrkCgTZS+jpv6SBLhxkgW8NG55CjUUXmMY2 +2yQwFVDA+koPTa89gsX0B4sZ7SYsvpMNcivVRYE= From: Dinh Nguyen To: linux-kernel@vger.kernel.org Cc: dinguyen@kernel.org, devicetree@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, robh+dt@kernel.org, Sergey.Semin@baikalelectronics.ru, fancer.lancer@gmail.com, andriy.shevchenko@linux.intel.com, lars.povlsen@microchip.com, liang.j.jin@ericsson.com Subject: [PATCHv4 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Date: Fri, 29 May 2020 10:58:06 -0500 Message-Id: <20200529155806.16758-2-dinguyen@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200529155806.16758-1-dinguyen@kernel.org> References: <20200529155806.16758-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 --- v4: rebased to linux-next 20200529 v3: no change 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 020e3168ee41..0f21407a7ea3 100644 --- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt @@ -25,6 +25,9 @@ Optional properties: device. Supported values are 2 or 4 (the default). - dmas : Phandle + identifiers of Tx and Rx DMA channels. - dma-names : Contains the names of the DMA channels. Must be "tx" and "rx". +- 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. @@ -40,5 +43,7 @@ Example: num-cs = <2>; cs-gpios = <&gpio0 13 0>, <&gpio0 14 0>; + resets = <&rst SPIM0_RST>; + reset-names = "spi"; };