From patchwork Tue Jan 7 18:30:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 206052 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 16E4AC282DD for ; Tue, 7 Jan 2020 18:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E53EE206F0 for ; Tue, 7 Jan 2020 18:31:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VpgMidaY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728606AbgAGSbI (ORCPT ); Tue, 7 Jan 2020 13:31:08 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51827 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbgAGSbI (ORCPT ); Tue, 7 Jan 2020 13:31:08 -0500 Received: by mail-wm1-f66.google.com with SMTP id d73so601467wmd.1; Tue, 07 Jan 2020 10:31:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0GZ/2btd9WbdeIHkXR9dqHVEEQVXHUGyMIYqGnC+II0=; b=VpgMidaYw8KNPWqbVfr/rT1197l8lSncVLRnCyqu0HB25M7EWRDP2y2wQk4B9l9hUN fHQBgGk4S4f7zSNc4G1qyqnwSy64wT8RKxmfI9qh6lAgEcpSEHq8MeTKevHr4/i3Mlw3 fhqZfrKIwH5LjhD8svpQ6jcbbf08CFPGpCOPLqoIAxDp/T2FmaKZ3rx9I3+pa4RiHyHy tLNlVBtSycqe6/o1NkN/nX9T86WmiyoAYVjIX8znpBpXuYue8diWzrE7gzONKZU6Mqh4 VnfMd2SesgPeSoJZswi/Q1X5JSoikQ5hTQqzm42I6k4igv6z6geNqHovx/sasbPJiZvK B3tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0GZ/2btd9WbdeIHkXR9dqHVEEQVXHUGyMIYqGnC+II0=; b=JppY2tl/JGC08FDMNeLyOh1hPaOEDddXbwFblUeHyIdnHyS+XwT0PPaTMh0smg8bAO rr15CmQafJ18a1xY9ks05pC8sUva3zFXuMGnIsDQJsV8GJtjPPF4B/avG2Ky2eVBdKk8 KCQV9EzrdiUFFX9tDwVj/QpMJf7xBNH3/gsiaxHmO5UvsAzoTyP5HNDrkmVaUqdwLn4u Fzg8Y+0cDl3VXNrusSGrMqp6vKtT7FWGh0DeDuukSm4xI0MF9EzveVTxoDFrVyUsdnMz LBHlfZva4eimOHxhEayMDpXfIQrY/KdOQYd0aKfaDBEli597pRVn3oNfsc26Mp4aYmqs p4Tw== X-Gm-Message-State: APjAAAX8GLDLSwSFM6Jpko+e2+eKCipduxPkoTOaZ6C5YIU3hsSBsPMO F2cuMhrL0qMalNfIKAFCT7FWSE0y X-Google-Smtp-Source: APXvYqzoRxm80vAgRUmtbZLOf/MZFA5ymUw5SZagpuUO7roaHGmZ71GirKkDje3/A2iDVa0Gbf9YMQ== X-Received: by 2002:a1c:5f41:: with SMTP id t62mr439532wmb.42.1578421865537; Tue, 07 Jan 2020 10:31:05 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id r6sm842764wrq.92.2020.01.07.10.31.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 10:31:04 -0800 (PST) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, Florian Fainelli , Jens Axboe , Rob Herring , Mark Rutland , Hans de Goede , Philipp Zabel , Tejun Heo , Jaedon Shin , linux-ide@vger.kernel.org (open list:LIBATA SUBSYSTEM (Serial and Parallel ATA drivers)), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v3 1/3] ata: ahci_brcm: Correct reset control API usage Date: Tue, 7 Jan 2020 10:30:20 -0800 Message-Id: <20200107183022.26224-2-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200107183022.26224-1-f.fainelli@gmail.com> References: <20200107183022.26224-1-f.fainelli@gmail.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Philipp provided suggestions on using the devm_reset_control_get_optional_*() API such that checks against a NULL or error reset control resource could be eliminated. In the process, make sure that we also grab the BCM7216 reset control line using the shared semantics, since the "rescal" reset fits that model. Suggested-by: Philipp Zabel Signed-off-by: Florian Fainelli --- drivers/ata/ahci_brcm.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c index 13ceca687104..718516fe6997 100644 --- a/drivers/ata/ahci_brcm.c +++ b/drivers/ata/ahci_brcm.c @@ -349,11 +349,10 @@ static int brcm_ahci_suspend(struct device *dev) brcm_sata_phys_disable(priv); ret = ahci_platform_suspend(dev); + if (ret) + return ret; - if (!IS_ERR_OR_NULL(priv->rcdev)) - reset_control_assert(priv->rcdev); - - return ret; + return reset_control_assert(priv->rcdev); } static int brcm_ahci_resume(struct device *dev) @@ -363,8 +362,7 @@ static int brcm_ahci_resume(struct device *dev) struct brcm_ahci_priv *priv = hpriv->plat_data; int ret = 0; - if (!IS_ERR_OR_NULL(priv->rcdev)) - ret = reset_control_deassert(priv->rcdev); + ret = reset_control_deassert(priv->rcdev); if (ret) return ret; @@ -425,7 +423,6 @@ static int brcm_ahci_probe(struct platform_device *pdev) { const struct of_device_id *of_id; struct device *dev = &pdev->dev; - const char *reset_name = NULL; struct brcm_ahci_priv *priv; struct ahci_host_priv *hpriv; struct resource *res; @@ -447,15 +444,21 @@ static int brcm_ahci_probe(struct platform_device *pdev) if (IS_ERR(priv->top_ctrl)) return PTR_ERR(priv->top_ctrl); - /* Reset is optional depending on platform and named differently */ + /* Reset is optional depending on platform and named differently + * and of different kind (shared vs. exclusive) + */ if (priv->version == BRCM_SATA_BCM7216) - reset_name = "rescal"; + priv->rcdev = devm_reset_control_get_optional_shared(dev, + "rescal"); else - reset_name = "ahci"; + priv->rcdev = devm_reset_control_get_optional_exclusive(dev, + "ahci"); + if (IS_ERR(priv->rcdev)) + return PTR_ERR(priv->rcdev); - priv->rcdev = devm_reset_control_get(&pdev->dev, reset_name); - if (!IS_ERR_OR_NULL(priv->rcdev)) - reset_control_deassert(priv->rcdev); + ret = reset_control_deassert(priv->rcdev); + if (ret) + return ret; hpriv = ahci_platform_get_resources(pdev, 0); if (IS_ERR(hpriv)) { @@ -519,8 +522,7 @@ static int brcm_ahci_probe(struct platform_device *pdev) out_disable_clks: ahci_platform_disable_clks(hpriv); out_reset: - if (!IS_ERR_OR_NULL(priv->rcdev)) - reset_control_assert(priv->rcdev); + reset_control_assert(priv->rcdev); return ret; } From patchwork Tue Jan 7 18:30:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 206051 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 6FFA8C33C9E for ; Tue, 7 Jan 2020 18:31:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 493A42072A for ; Tue, 7 Jan 2020 18:31:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yafxffao" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728651AbgAGSbO (ORCPT ); Tue, 7 Jan 2020 13:31:14 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:32820 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbgAGSbO (ORCPT ); Tue, 7 Jan 2020 13:31:14 -0500 Received: by mail-wm1-f66.google.com with SMTP id d139so14782951wmd.0; Tue, 07 Jan 2020 10:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0F4Kd5Ywhqg4TZ9Cg5D+47SboN/4h4Ft84pZMAsNlKo=; b=YafxffaoqkeQGIPgQKSLZv7Ponlme3Bk0WVdm20udVQUIgs0xAsxF0mmMa7fZd4G5K Uhb0TxGXUnj4YS5k5vnpcqgKb9J3R5CIDOG4pS6bxXNa8guBkL7GqiluFnnuOI4epULH VU5cW5Cnk0UL8VtrLN3KQaQQU3um2nv3/K/ZfwbvUnIMGSg7Hb8MMyc4lFU9ekUO/wUE 2o3lkceF2HTYw3oBjPZjqDjeXpd9BRPrZhTCf6Sm3oox7oCLbI9Kcx+ROSjdGHQLtNSi EHH8UYd4qf+w1JYsZabXeRDAa4AsDjSF+syE3hs/pR0XOT5LXhWFJ9rHHcDqrLS/cswu GcRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0F4Kd5Ywhqg4TZ9Cg5D+47SboN/4h4Ft84pZMAsNlKo=; b=F4OM55/02TCqr1CWQ8h2n03IpiULDmxLJZEZDfuykWFHwUnPPcLNpFBtlO5T4PPiBE snBEis+PF/YYtWiZ/0FWWo5Pn4CDTCiMUOhC5p22WlJB2uhZLa1c7MCV7P8UjIZtMymO Hjx4k0AWTiexwBH08jQRPMfOMf8OsknlgVz3Bkvl+g39GCaGu2ESj96I8y85oHkJoWqQ QDvOiXzVuLfD8iEi0IqV9XlF9FVt/MCOYJDAq22VGvFCNKRnLNqGx46roTtNWHC/iKpZ 1mX0FOXXrb9mHSjdLf4eE1hM8Da+tGd4BnVp+eyvIVu4JTZDnfePBcZhw/SUuJb9a9Lq ZFKA== X-Gm-Message-State: APjAAAWcx+YIlSLxLwN65/rM+R1fgGXvTf/8HBORjKFmMNU/xZm0t0fr TP8vazfxU0rNI+h1N8IHvRerMBgU X-Google-Smtp-Source: APXvYqxGPnpDm3ovMwAlFLSA5Y2lqNnDLtsjmBX4mk+5yIqPHrHdUCu55+wEtDsvnBpPB5ovF5GVXw== X-Received: by 2002:a1c:f001:: with SMTP id a1mr382380wmb.76.1578421871534; Tue, 07 Jan 2020 10:31:11 -0800 (PST) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id r6sm842764wrq.92.2020.01.07.10.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 10:31:10 -0800 (PST) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, Florian Fainelli , Jens Axboe , Rob Herring , Mark Rutland , Hans de Goede , Philipp Zabel , Tejun Heo , Jaedon Shin , linux-ide@vger.kernel.org (open list:LIBATA SUBSYSTEM (Serial and Parallel ATA drivers)), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v3 3/3] ata: ahci_brcm: BCM7216 reset is self de-asserting Date: Tue, 7 Jan 2020 10:30:22 -0800 Message-Id: <20200107183022.26224-4-f.fainelli@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200107183022.26224-1-f.fainelli@gmail.com> References: <20200107183022.26224-1-f.fainelli@gmail.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The BCM7216 reset controller line is self-deasserting, unlike other platforms, so make use of reset_control_reset() instead of reset_control_deassert(). Signed-off-by: Florian Fainelli --- drivers/ata/ahci_brcm.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c index c229fea39a47..62c948e56beb 100644 --- a/drivers/ata/ahci_brcm.c +++ b/drivers/ata/ahci_brcm.c @@ -352,7 +352,10 @@ static int brcm_ahci_suspend(struct device *dev) if (ret) return ret; - return reset_control_assert(priv->rcdev); + if (priv->version != BRCM_SATA_BCM7216) + ret = reset_control_assert(priv->rcdev); + + return ret; } static int brcm_ahci_resume(struct device *dev) @@ -362,7 +365,10 @@ static int brcm_ahci_resume(struct device *dev) struct brcm_ahci_priv *priv = hpriv->plat_data; int ret = 0; - ret = reset_control_deassert(priv->rcdev); + if (priv->version == BRCM_SATA_BCM7216) + ret = reset_control_reset(priv->rcdev); + else + ret = reset_control_deassert(priv->rcdev); if (ret) return ret; @@ -475,7 +481,10 @@ static int brcm_ahci_probe(struct platform_device *pdev) break; } - ret = reset_control_deassert(priv->rcdev); + if (priv->version == BRCM_SATA_BCM7216) + ret = reset_control_reset(priv->rcdev); + else + ret = reset_control_deassert(priv->rcdev); if (ret) return ret; @@ -520,7 +529,8 @@ static int brcm_ahci_probe(struct platform_device *pdev) out_disable_clks: ahci_platform_disable_clks(hpriv); out_reset: - reset_control_assert(priv->rcdev); + if (priv->version != BRCM_SATA_BCM7216) + reset_control_assert(priv->rcdev); return ret; }