From patchwork Fri Dec 8 20:21:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 13485827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF912C4167B for ; Fri, 8 Dec 2023 20:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=JQDDWa2m/MoT98fQ48F/gV8mnjt69kENdY4C08zphtU=; b=DOI Kj7bl09u/ZUO23OYQNnPrC56fpWDoB89q4P4tEzlxObvZJUb24cKWtg//8zB1Xb0Bbfp9DKdKjjX9 ICdmv0jZe10z2gcG+fQSNZ7fViPt+sVPz57CEfr4Gabh9Y9M2mO1u99carljUqzoKm2acv3xg3uB1 BJbswD50/BXgglUlwZH6iZ9yClqvp24c9t4OrEAZs1pn90k9MT+GMJnx8ZqdeHznba5QiLJFPmni3 1itJZ/LJFsf13fc5w/BDe+j+Ny7rE8di0x6vq/cetT2l3UsY8m4yXiKS7/arAI7K3ZWIvJOAPUbRL jtv+MOkyOayYLAChtlicUsedxkNHvxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBhLd-00GTNS-0G; Fri, 08 Dec 2023 20:21:21 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBhLZ-00GTMN-0d for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 20:21:19 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-6ce72730548so2035285b3a.1 for ; Fri, 08 Dec 2023 12:21:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1702066875; x=1702671675; darn=lists.infradead.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LNbwTK0waZMiIQOwV3dQd1T4NZvzpyjmbKeOhRW4Kuk=; b=ao6WBOa3I0CtqCU2xaazuGVFJrhOnrDhoVFOja+/sGDfGZbOPy657UzU4X+fQ+BdDY pszehpbHUQ+PjeWrowOdVAClVrAnh70YEnYTep2nTzerXYNAMjuuHjucgQtStVlUKipD CHxWiBvlAKASnBs+nEu1IYwBafLCVJywpnhQw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702066875; x=1702671675; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LNbwTK0waZMiIQOwV3dQd1T4NZvzpyjmbKeOhRW4Kuk=; b=E3HDxckJcOG02QxqyaS2EXJR7QhXaRLwsSXRqSMR4a3uPQcF66byKg6SLBkPaTszex I9IY/ruMtsccsoJypnY4k20/16YRZfCiV23l4sHRmRIJNygzDs/CHMLMJ9w32NuNQUoC ad8fNCboAx/cT8K90FHR/VprJNHgVAcblscRpunUFLgWCDz89bszDirWHRFuRhy9WPa0 bTa+Z6jxzsm1+HiBInIUHtgNwWg/5Lv3Q+T3gQpGxXv3dH0KkKVD1zV+eOwhcymYRBSo wcqSDNkQKkmQv+Jb6IRH7CKH4IesMY4OhQ0FhkKNm9FHXM5GH1zhZ8LZMCgX7vJjqwTa rMyQ== X-Gm-Message-State: AOJu0Yzk7SM0f8e/OuySbWM4H2WLrcXbb41ybvE8f+2sd/UNoajcAjW5 AXcranGO3sQE6kXKcF8LII6ejZ9erKHO4oZ+k3P5jQ== X-Google-Smtp-Source: AGHT+IGHqGzG7ztvompPiNKslZQCOkPgmaPjXQbqgVhEkAfyD8kbvTZmdFsxyJwNAeVrjJDa/FlK/g== X-Received: by 2002:a05:6a00:170a:b0:6cd:faa6:fc4b with SMTP id h10-20020a056a00170a00b006cdfaa6fc4bmr785154pfc.33.1702066875293; Fri, 08 Dec 2023 12:21:15 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id v29-20020a63481d000000b005c19c586cb7sm1952127pga.33.2023.12.08.12.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 12:21:14 -0800 (PST) From: Kamal Dasu To: ulf.hansson@linaro.org, linux-kernel@vger.kernel.org, alcooperx@gmail.com, linux-arm-kernel@lists.infradead.org, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, devicetree@vger.kernel.org Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, Kamal Dasu Subject: [PATCH 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Date: Fri, 8 Dec 2023 15:21:07 -0500 Message-Id: <20231208202108.7468-1-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231208_122117_634137_E68FF8AF X-CRM114-Status: UNSURE ( 9.51 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Kamal Dasu With newer sdio controller core used for 74165b0 we need to update the compatibility with "brcm,bcm74165b0-sdhci". Signed-off-by: Kamal Dasu --- .../devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml index c028039bc477..cec9ff063794 100644 --- a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +++ b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml @@ -13,6 +13,11 @@ maintainers: properties: compatible: oneOf: + - items: + - enum: + - brcm,bcm74165b0-sdhci + - const: brcm,bcm74165-sdhci + - const: brcm,sdhci-brcmstb - items: - enum: - brcm,bcm7216-sdhci From patchwork Fri Dec 8 20:21:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 13485828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5FB86C4167B for ; Fri, 8 Dec 2023 20:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe :List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ofWI8ZMOgWIMpkV1AtB4+fouMZEiVPXaNp/nZ0usIJU=; b=CHw699sawQ0Il7culBYXXj63WM FwDoRj1nxf/x0oOMacUuFCa7u++bzcySwskUGh2nFbclSlr2UuR6o5TxarfOzFrIEo2q9wuJ+eWEY 0C9wZDE68cGMEzSKE70n3tELJMXgA/3r0mS4LY8ICL3FDfRx25ZaI9xk3CqzIV2Us2S6RoNGl3hWV 2TrwSGR9lyC1oWmZ0zjfl+G8ccqMFzzRT7BqWGzkjzHLH00+cX/z4UwQ7IhFOXhlkpCMgAX+mCUZT 1uzZjUiETn93eVLRBlw6iOi1ZtnVq3jCrzN6CHMjCSBix+g1onlvENL5YiIZsJdwhQeJDGD5d0gKM YWZI52SA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBhLr-00GTQp-2B; Fri, 08 Dec 2023 20:21:35 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBhLo-00GTPx-29 for linux-arm-kernel@lists.infradead.org; Fri, 08 Dec 2023 20:21:34 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1d06d4d685aso19145015ad.3 for ; Fri, 08 Dec 2023 12:21:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1702066891; x=1702671691; darn=lists.infradead.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=Bo5MDELTZjiL51ABS0IghRdZvN3wolTzUS7aYmcTM9Q=; b=caCrAGzHn5mpqW6KWrsjk7qC1e7lOOz6iNzFz00yWnJ7a6ktTGnjOD85siJ83pVh56 8Qw36CS+n/5BbSD4RdjH/P0HnshBeAH7Hvkxf6gE1YUBCPwQoxOADwqZZF628fsh7Zou h7bD95gmtn4H6ba9lSVpFBNNtMDp5bS4Bnv7I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702066891; x=1702671691; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bo5MDELTZjiL51ABS0IghRdZvN3wolTzUS7aYmcTM9Q=; b=WSCYKRnwoMzrpTk37sgXTW+w0GG69ZIRyC5H09Yet4g+cs7orDWDUQFunByrFbpyoU IbUfnkib+tG0KJoagilszAIT8H3Fq8u2kCWnKOGbJoXfyUI86+CYAhTWChzv9totSarX GQeZVLnxE8pJJFSKlT3vUnSrO9NZIeGAwGHmNqDEcDF7wSUQx3EKHk7dfrhQya25W97V jBM/DC1B8et/SU0uKbbUco67uKHcwHREdyyGOQmbLDLLYNbySFt+DPge6ktZmGRVe0Kk LVEwziOqacXr7i0ErqRpaCL+P4mZGNO7OjkZP4tDxwI6Uev4gZf83ZZjSmwOoA5WATV6 GSiw== X-Gm-Message-State: AOJu0YyYhDyaxS8MH5j8CZXcCLitInlWp66LwqBHE9Dxd02k5WgSeuWH NwB4HlgJ1b6Z3P33W1bWt1lscw== X-Google-Smtp-Source: AGHT+IH+nTOgLpRgnuZLYs5BQXNJBtNy9L5TktNY5AwoGQViw82oVKYXe5ga1sI8TztgRgy15ZE8Pw== X-Received: by 2002:a17:902:c20d:b0:1d0:3eac:e66 with SMTP id 13-20020a170902c20d00b001d03eac0e66mr574433pll.29.1702066891085; Fri, 08 Dec 2023 12:21:31 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id v29-20020a63481d000000b005c19c586cb7sm1952127pga.33.2023.12.08.12.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 12:21:30 -0800 (PST) From: Kamal Dasu To: ulf.hansson@linaro.org, linux-kernel@vger.kernel.org, alcooperx@gmail.com, linux-arm-kernel@lists.infradead.org, adrian.hunter@intel.com, linux-mmc@vger.kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, devicetree@vger.kernel.org Cc: f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, Kamal Dasu Subject: [PATCH 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Date: Fri, 8 Dec 2023 15:21:08 -0500 Message-Id: <20231208202108.7468-2-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231208202108.7468-1-kamal.dasu@broadcom.com> References: <20231208202108.7468-1-kamal.dasu@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231208_122132_708305_DCA3E5C6 X-CRM114-Status: GOOD ( 17.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Kamal Dasu 74165b0 shall use a new sdio controller core version which requires a different reset sequence. For core reset we use sdhci_reset. For CMD and/or DATA reset added a new function to also enable SDCHI clocks SDHCI_CLOCK_CARD_EN SDHCI_CLOCK_INT_EN along with the SDHCI_RESET_CMD and/or SDHCI_RESET_DATA fields. Signed-off-by: Kamal Dasu --- drivers/mmc/host/sdhci-brcmstb.c | 69 +++++++++++++++++++++++++++++--- 1 file changed, 64 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index c23251bb95f3..3fac471b5b5d 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -44,8 +44,13 @@ struct brcmstb_match_priv { static inline void enable_clock_gating(struct sdhci_host *host) { + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); u32 reg; + if (!(priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK)) + return; + reg = sdhci_readl(host, SDHCI_VENDOR); reg |= SDHCI_VENDOR_GATE_SDCLK_EN; sdhci_writel(host, reg, SDHCI_VENDOR); @@ -53,14 +58,54 @@ static inline void enable_clock_gating(struct sdhci_host *host) static void brcmstb_reset(struct sdhci_host *host, u8 mask) { - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - struct sdhci_brcmstb_priv *priv = sdhci_pltfm_priv(pltfm_host); - sdhci_and_cqhci_reset(host, mask); /* Reset will clear this, so re-enable it */ - if (priv->flags & BRCMSTB_PRIV_FLAGS_GATE_CLOCK) - enable_clock_gating(host); + enable_clock_gating(host); +} + +static void brcmstb_sdhci_reset_cmd_data(struct sdhci_host *host, u8 mask) +{ + ktime_t timeout; + u32 reg; + u32 new_mask = (mask & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) << 24; + + new_mask |= SDHCI_CLOCK_CARD_EN | SDHCI_CLOCK_INT_EN; + reg = sdhci_readl(host, SDHCI_CLOCK_CONTROL); + sdhci_writel(host, reg | new_mask, SDHCI_CLOCK_CONTROL); + + /* Wait max 10 ms */ + timeout = ktime_add_ms(ktime_get(), 10); + + /* hw clears the bit when it's done */ + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + if (!(sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask)) + break; + if (timedout) { + pr_err("%s: Reset 0x%x never completed.\n", + mmc_hostname(host->mmc), (int)mask); + sdhci_err_stats_inc(host, CTRL_TIMEOUT); + sdhci_dumpregs(host); + return; + } + udelay(10); + } +} + +static void brcmstb_reset_74165b0(struct sdhci_host *host, u8 mask) +{ + /* take care of RESET_ALL as usual */ + if (mask & SDHCI_RESET_ALL) + sdhci_and_cqhci_reset(host, SDHCI_RESET_ALL); + + /* cmd and/or data treated differently on this core */ + if (mask & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) + brcmstb_sdhci_reset_cmd_data(host, mask); + + /* Reset will clear this, so re-enable it */ + enable_clock_gating(host); } static void sdhci_brcmstb_hs400es(struct mmc_host *mmc, struct mmc_ios *ios) @@ -162,6 +207,13 @@ static struct sdhci_ops sdhci_brcmstb_ops_7216 = { .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, }; +static const struct sdhci_ops sdhci_brcmstb_ops_74165b0 = { + .set_clock = sdhci_brcmstb_set_clock, + .set_bus_width = sdhci_set_bus_width, + .reset = brcmstb_reset_74165b0, + .set_uhs_signaling = sdhci_brcmstb_set_uhs_signaling, +}; + static struct brcmstb_match_priv match_priv_7425 = { .flags = BRCMSTB_MATCH_FLAGS_NO_64BIT | BRCMSTB_MATCH_FLAGS_BROKEN_TIMEOUT, @@ -179,10 +231,17 @@ static const struct brcmstb_match_priv match_priv_7216 = { .ops = &sdhci_brcmstb_ops_7216, }; +static const struct brcmstb_match_priv match_priv_74165b0 = { + .flags = BRCMSTB_MATCH_FLAGS_HAS_CLOCK_GATE, + .hs400es = sdhci_brcmstb_hs400es, + .ops = &sdhci_brcmstb_ops_74165b0, +}; + static const struct of_device_id __maybe_unused sdhci_brcm_of_match[] = { { .compatible = "brcm,bcm7425-sdhci", .data = &match_priv_7425 }, { .compatible = "brcm,bcm7445-sdhci", .data = &match_priv_7445 }, { .compatible = "brcm,bcm7216-sdhci", .data = &match_priv_7216 }, + { .compatible = "brcm,bcm74165b0-sdhci", .data = &match_priv_74165b0 }, {}, };