From patchwork Fri Nov 20 20:38:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 1404114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=ZQVzmYJz; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Cd7gx5WGTz9sVK for ; Sat, 21 Nov 2020 07:39:25 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731609AbgKTUiu (ORCPT ); Fri, 20 Nov 2020 15:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731585AbgKTUiu (ORCPT ); Fri, 20 Nov 2020 15:38:50 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE6FDC0613CF for ; Fri, 20 Nov 2020 12:38:49 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id w4so8275605pgg.13 for ; Fri, 20 Nov 2020 12:38:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mbSdN3eggVr4Z4kNEOK/lmtmEvAGNP/ePDTi+gor+9g=; b=ZQVzmYJzMNvAjDjQR89LuXJTbHANBNdoSzu62O6G1lAYXSDWC3g71pXH1FFCabJVLr GGR+I/LN6X0NabNctqqRm3NrOUJH9+LYW7ULtD/SsKyRpEKAnfzQJ9bc498u5te0/5Xx n7ycTKveqSXk2ENAQKsZQ69iYxFfjDtr73Z0Y= 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=mbSdN3eggVr4Z4kNEOK/lmtmEvAGNP/ePDTi+gor+9g=; b=WQBWf2gmgmpQ+xaz6u5C91BXAiihlNSc43VcNbyg2cEBCqOsHqCTIvFgsOT47ftVeu ORzNCl6Jz5ilfw1rGdOunyCqikL4hIxHpVilFsqyXnuGIt11r6et8RSen1Zag4QIjW5t bqWhYFBsjNYFZLZiX4mxbZGf885UHhN8NVhIaS3QLZP9U4lZ7LAluF3YPbyjDKegDAv6 92twXQt63CbQvp30vp+dNVAMYAj12MkvKJC57ByauqOQG3NMAsh6i1Pk3V/hOjlgfJWQ 6rmKXnbEzBBxOznTsjWrtzZLSodCclgXT08XbJgH+oXetyfgq0J28AdpUljlYD5XkvUw qQAw== X-Gm-Message-State: AOAM530ZG5AUxRN/dUkNB3HW9+03qxs+PgAlwuwl4l4O3jgMfWPJPiAj n9NWoikpiryD1aPrZWmIrb6pS0ptEF8y+Q== X-Google-Smtp-Source: ABdhPJxYYDT/hBQ9ouf40YSxJ2eozRDy/6CMRz+JfnrrmWLaY8J8LAhthcgYzokcFvbMrC4cfYtAwg== X-Received: by 2002:a17:90a:6b0d:: with SMTP id v13mr12396525pjj.206.1605904729471; Fri, 20 Nov 2020 12:38:49 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id gx24sm4838688pjb.38.2020.11.20.12.38.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:38:48 -0800 (PST) From: Jim Quinlan To: Philipp Zabel , Hans de Goede , Jens Axboe , bcm-kernel-feedback-list@broadcom.com, james.quinlan@broadcom.com Cc: Jim Quinlan , Florian Fainelli , linux-ide@vger.kernel.org (open list:LIBATA SUBSYSTEM (Serial and Parallel ATA drivers)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 1/2] ata: ahci_brcm: Fix use of BCM7216 reset controller Date: Fri, 20 Nov 2020 15:38:38 -0500 Message-Id: <20201120203840.35139-2-james.quinlan@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201120203840.35139-1-james.quinlan@broadcom.com> References: <20201120203840.35139-1-james.quinlan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Jim Quinlan This driver may use one of two resets controllers. Keep them in separate variables to keep things simple. The reset controller "rescal" is shared between the AHCI driver and the PCIe driver for the BrcmSTB 7216 chip. Use devm_reset_control_get_optional_shared() to handle this sharing. Fixes: 272ecd60a636 ("ata: ahci_brcm: BCM7216 reset is self de-asserting") Fixes: c345ec6a50e9 ("ata: ahci_brcm: Support BCM7216 reset controller name") Signed-off-by: Jim Quinlan --- drivers/ata/ahci_brcm.c | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c index 49f7acbfcf01..bad455fb6ab8 100644 --- a/drivers/ata/ahci_brcm.c +++ b/drivers/ata/ahci_brcm.c @@ -86,7 +86,8 @@ struct brcm_ahci_priv { u32 port_mask; u32 quirks; enum brcm_ahci_version version; - struct reset_control *rcdev; + struct reset_control *rcdev_rescal; + struct reset_control *rcdev_ahci; }; static inline u32 brcm_sata_readreg(void __iomem *addr) @@ -352,8 +353,8 @@ static int brcm_ahci_suspend(struct device *dev) else ret = 0; - if (priv->version != BRCM_SATA_BCM7216) - reset_control_assert(priv->rcdev); + reset_control_assert(priv->rcdev_ahci); + reset_control_rearm(priv->rcdev_rescal); return ret; } @@ -365,10 +366,10 @@ static int __maybe_unused brcm_ahci_resume(struct device *dev) struct brcm_ahci_priv *priv = hpriv->plat_data; int ret = 0; - if (priv->version == BRCM_SATA_BCM7216) - ret = reset_control_reset(priv->rcdev); - else - ret = reset_control_deassert(priv->rcdev); + ret = reset_control_deassert(priv->rcdev_ahci); + if (ret) + return ret; + ret = reset_control_reset(priv->rcdev_rescal); if (ret) return ret; @@ -428,7 +429,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; @@ -450,15 +450,15 @@ 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 */ - if (priv->version == BRCM_SATA_BCM7216) - reset_name = "rescal"; - else - reset_name = "ahci"; - - priv->rcdev = devm_reset_control_get_optional(&pdev->dev, reset_name); - if (IS_ERR(priv->rcdev)) - return PTR_ERR(priv->rcdev); + if (priv->version == BRCM_SATA_BCM7216) { + priv->rcdev_rescal = devm_reset_control_get_optional_shared( + &pdev->dev, "rescal"); + if (IS_ERR(priv->rcdev_rescal)) + return PTR_ERR(priv->rcdev_rescal); + } + priv->rcdev_ahci = devm_reset_control_get_optional(&pdev->dev, "ahci"); + if (IS_ERR(priv->rcdev_ahci)) + return PTR_ERR(priv->rcdev_ahci); hpriv = ahci_platform_get_resources(pdev, 0); if (IS_ERR(hpriv)) @@ -479,10 +479,10 @@ static int brcm_ahci_probe(struct platform_device *pdev) break; } - if (priv->version == BRCM_SATA_BCM7216) - ret = reset_control_reset(priv->rcdev); - else - ret = reset_control_deassert(priv->rcdev); + ret = reset_control_reset(priv->rcdev_rescal); + if (ret) + return ret; + ret = reset_control_deassert(priv->rcdev_ahci); if (ret) return ret; @@ -527,8 +527,8 @@ static int brcm_ahci_probe(struct platform_device *pdev) out_disable_clks: ahci_platform_disable_clks(hpriv); out_reset: - if (priv->version != BRCM_SATA_BCM7216) - reset_control_assert(priv->rcdev); + reset_control_assert(priv->rcdev_ahci); + reset_control_rearm(priv->rcdev_rescal); return ret; }