From patchwork Tue Jan 2 16:09:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 13509141 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 12D7BC46CD2 for ; Tue, 2 Jan 2024 16:09:48 +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=QALUeJmPmnBHIPR9n7+hu8p3LakIP2VimU50D54P2eQ=; b=Mui/wzDBYgNNx2ZUKMBDZPmUPD 7Dbn7PT+X1jj0dqeAWfXg3e//PgQUL/2vVsHvVuoLIfI+LJ/DfbdLUiXWSudzEP4JoNotWDlJa1y9 YKiTvZiQjpM4Mjc0bYPBn6/B8UKu0Q0CabgnaHqGPVzobwvuwqF2ca+KqAFM4NQpSaUzzDrQZLV2i F5K0DNAzGZpP4UoMgHnlAfV4F9ey6CCK+24GsdaRiekOdZf27D/z/f3N9JyaTcECM7OernH2sT1PK rl4tW11fawUAAwhMRbkcyGZylvHB8pnSmiihbB0sfgRRCjNlp8fZgDeAumKWEZJ/ZuHBg9KCnu3J8 mkqirsZQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rKhKU-008RrQ-14; Tue, 02 Jan 2024 16:09:22 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rKhKQ-008RqD-2E for linux-arm-kernel@lists.infradead.org; Tue, 02 Jan 2024 16:09:20 +0000 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3bbbf5a59b7so4723733b6e.3 for ; Tue, 02 Jan 2024 08:09:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704211757; x=1704816557; 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=Gq/MFgqCSax1B2ieltSynkT1vjwTKJ7dL8O3DborrMg=; b=XuFN0osrEHrBpBuiVwYGxoY43Ky/5Q1L1bykZC9X2EfhPdeaocGq15wperv5vujBF7 IhS8QktrP74jquTvOC/+lcw0Swnla7aiqOD3TrPhRub+RN441AnjzDhq/5uBOqlSFldX xtI7klzewDIFVYYBzEmtsmTh5jznk2AoITQdU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704211757; x=1704816557; 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=Gq/MFgqCSax1B2ieltSynkT1vjwTKJ7dL8O3DborrMg=; b=XXAfpMohqSjYNHp0khMvGlMJCRkOAwVID060PDaxQhstbNfSaGcA+JJQdvGHK7pKVx hRcFVGVRm0T2lmhES7sPFGT9/4E0JZ9TRWJ/OjSIQhM75aZaPnAeSXHECZwYPqIOeqcl BgazfOdUMK5YO+7FyNd1w3/fvi/YWS4J48eq9EF1xoJo+uwmBLSdn1mT0vadBHsmkryX dqabFPvYcUzAAQnkt9wJ8qSufFw3KBnKRKpZozT1zRHZR2ObFzk30gHINHry8N5fvvQr 3rGICPaVp0xDkuNw6hk3DNqOQqKW6ZdTEsV9PYQuB0uwAG3fAkiEWcr3F2aUfBhaNHVp I+9A== X-Gm-Message-State: AOJu0YymbZOoB0N9+jWDvgIbeJNQDI22hA11bxu//dJwe2PYu9Ai+OE0 yhFzr+672at9duAl5Oiw5U04WitGjSBl X-Google-Smtp-Source: AGHT+IFTILOFqzHJ6KnugtbZ9jIFStwPPgIMaApKuuKhCP13N0+c3dtGjgK0Zd3ZytZ4wvoPbdmPag== X-Received: by 2002:a05:6808:6d8:b0:3bb:ce05:d69b with SMTP id m24-20020a05680806d800b003bbce05d69bmr9319111oih.104.1704211757399; Tue, 02 Jan 2024 08:09:17 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id hf8-20020a0562140e8800b0067f6f8c2a66sm10137520qvb.126.2024.01.02.08.09.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 08:09:16 -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 v7 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Date: Tue, 2 Jan 2024 11:09:09 -0500 Message-Id: <20240102160910.15485-2-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240102160910.15485-1-kamal.dasu@broadcom.com> References: <20240102160910.15485-1-kamal.dasu@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240102_080918_731381_7B7691B8 X-CRM114-Status: GOOD ( 12.06 ) 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 Acked-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml index c028039bc477..cbd3d6c6c77f 100644 --- a/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml +++ b/Documentation/devicetree/bindings/mmc/brcm,sdhci-brcmstb.yaml @@ -20,10 +20,8 @@ properties: - const: brcm,sdhci-brcmstb - items: - enum: + - brcm,bcm74165b0-sdhci - brcm,bcm7445-sdhci - - const: brcm,sdhci-brcmstb - - items: - - enum: - brcm,bcm7425-sdhci - const: brcm,sdhci-brcmstb From patchwork Tue Jan 2 16:09:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 13509142 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 40188C47074 for ; Tue, 2 Jan 2024 16:09:51 +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=99VJf2qIELaGVFMmIjCnt2VHINtwjDbpkumSdo4+zo4=; b=p41oTF5t5MB96Jc1yV2C1hjU3c eCElDnfCJ7b1n8+fQEp1j5Gmlgso6TihSRLQVrdj5DQmXUd7sNdXfXDPgE2dfy3yaVlqVlDiKd0z9 qDTqIISa1UREQ4lniojqo5fuIQjb8g+vHMPl8tqzq+x29lskPPtw/5a7ojWx9rBSNSGHt0lO2/NJO jS/haU9DXGlsP6rqVhHzoXA4BgqvUFxMeiCBDPLVrbGRaAM8cadDxi7k8ACrQz9vl8ZLybb6SbeG1 dfNgfsGfOHRgLAAB3PVpq+HhUBgXVjMgJHeMCXwRKuv2LmgfWVC59uMCgz0BES9bckgKbcIbWsCq5 p9vkOBpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rKhKV-008Rre-0A; Tue, 02 Jan 2024 16:09:23 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rKhKR-008Rqd-2m for linux-arm-kernel@lists.infradead.org; Tue, 02 Jan 2024 16:09:21 +0000 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3bbd6e37af4so3445970b6e.1 for ; Tue, 02 Jan 2024 08:09:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704211759; x=1704816559; 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=auyxut6KQcnLEGWAWvVOpikzMRS7U9X11NmalDrR3ZU=; b=M3vxGHNFu+kjEv4BbE8qIt8utMWOELFECTU2iwIk90h91fyz+xUvsq91N+j2I2e23O 7E58j0neZlOkCr7B9IgEvEK77V7dQlsrgkJVACJktESG1Ik9T8DC6nWdavFB9EObuxIi s/FLixUA0CBAtjX6HSrucEmXNUdLc94GJt+dY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704211759; x=1704816559; 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=auyxut6KQcnLEGWAWvVOpikzMRS7U9X11NmalDrR3ZU=; b=l84H1qwfg1PzVZamKOSfwEWrDlIubm0KcRQoqqF4mP3Jlq+7PnEpzk9A+zkTAkTfJE rOwDhYq0rTDczFNr/8llp2xFqNKLv4e3ZMkIqIB2SV+uLPZer2J8dSZbyNWrMgb/M7un WAlxlrBl9EVn0idHV/B+dZSDbEfVCVIHD1n+m5cCt0xakrg86bRx4NgN/oglWx8K27jt gPCgKuXme4WuEjr5SkcljLAUYDIIV91vuV8whr0IZn49G9a+NznM60DX4AGHRHqzX/DA 9qgm099EYfgm18CJgT2ZWQuhoS0RGK4yPzLF7Cuh5mHJGpHjR+Gy69DT1Pae3ByawUbf CUrw== X-Gm-Message-State: AOJu0YzLDtQbTJTWAcIM9lQiv95tb2Ug4wv1jZ+HJx/MicRCtrzd9Yny hMroZarkKB5Vn5YlBpfQbrRceto5OgRA X-Google-Smtp-Source: AGHT+IHpK4las4p6fcezwyDMfYhjIjjihTHc9jKFT7LwTQvxL/ZP3CSOpHxfYAa9el7fUkW4VWhJ/w== X-Received: by 2002:a05:6808:107:b0:3bb:c65c:2c58 with SMTP id b7-20020a056808010700b003bbc65c2c58mr9407756oie.101.1704211759300; Tue, 02 Jan 2024 08:09:19 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id hf8-20020a0562140e8800b0067f6f8c2a66sm10137520qvb.126.2024.01.02.08.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 08:09:18 -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 v7 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Date: Tue, 2 Jan 2024 11:09:10 -0500 Message-Id: <20240102160910.15485-3-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240102160910.15485-1-kamal.dasu@broadcom.com> References: <20240102160910.15485-1-kamal.dasu@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240102_080919_940222_46010349 X-CRM114-Status: GOOD ( 18.10 ) 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 SDHCI 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 Acked-by: Adrian Hunter --- 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..9053526fa212 100644 --- a/drivers/mmc/host/sdhci-brcmstb.c +++ b/drivers/mmc/host/sdhci-brcmstb.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -44,8 +45,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 +59,53 @@ 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) +{ + u32 new_mask = (mask & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) << 24; + int ret; + u32 reg; + + /* + * SDHCI_CLOCK_CONTROL register CARD_EN and CLOCK_INT_EN bits shall + * be set along with SOFTWARE_RESET register RESET_CMD or RESET_DATA + * bits, hence access SDHCI_CLOCK_CONTROL register as 32-bit register + */ + 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); + + reg = sdhci_readb(host, SDHCI_SOFTWARE_RESET); + + ret = read_poll_timeout_atomic(sdhci_readb, reg, !(reg & mask), + 10, 10000, false, + host, SDHCI_SOFTWARE_RESET); + + if (ret) { + 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); + } +} + +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 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 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 }, {}, };