From patchwork Tue Dec 19 16:22:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 13498485 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 7ABDDC41535 for ; Tue, 19 Dec 2023 16:23:34 +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=Gj9ntfMmKt3MoNflwMlZaMW3xGPsYYhSRP3k9oh3ZJU=; b=Ua+2pE5cJSNPntK294fN/filZb DXTalidV/V7x0Aq3iNXp+bYwifZT6TeMb7mXypmnoOfmD5OJDXqGm1XzdUzpipUXe+vTmTEpAyVL/ LQzvx85Xils8+Lp/aoUz+bz/jE10Zcp+jptflk1WZvFFmVM8tHPBxC5yUD7f/czTfXRtjNF8qo2eC f2J7JDcBuIeJB1FWjzgNAytxCyTdlfNYjGWyChXfCOjbLCJHfVdza/XfzjTRK21ndVr0SAe6Ok3FP Ns4wRX4s97gjRsMnfb5NChf2sLUy0IuVAFkBxf/Xks7BZFiZSB39idwIMviKrhprIarvEcA3Dsnid Lt2LTI6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFcs8-00EfjV-1w; Tue, 19 Dec 2023 16:23:08 +0000 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFcs3-00EfhT-2r for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 16:23:05 +0000 Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-4257ba1bc5fso42668661cf.0 for ; Tue, 19 Dec 2023 08:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703002982; x=1703607782; 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=Ms0xn4M+NrrjdmgiPcnIgiraMVgWZaqa1IVOdmYOFHc=; b=KDEiJg0zMEfdFKZjJeCtqjRNYVbsPKdzYZntGXSCvGBeooZYWDmOJV45EZU3oUi91Z 5Nei0YBwJcPDTtdwu/p5sjKooRfwDF73Vfsxtuj5x3yp19mz5cTL3nk9Zmuma8mrQsZ1 ULBl9MH9xRBwlvME6VlFw8Fyq05YGdf+8NMmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703002982; x=1703607782; 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=Ms0xn4M+NrrjdmgiPcnIgiraMVgWZaqa1IVOdmYOFHc=; b=g4SWrRBkA7by1FDIOyZZBKDc5BdRCK3bDt40RMKvMcwjlWv8Jtf5YCfRlH35Z+TTww J+fKioRqMn9DsMQVKY7xSTPHeE4dfGMV/esZE9foZXOQBXzhe6lpbReFy60+cNN/MM5o WHJ8TjeTA3WQV41SDFLHNzogLdvu4aIqmEKgWOy35SyTioD1zie96dIUCxB5xSY37UJu 9Gs/I+qmcUkCqsoYBQJvHiEiLdcheCK2Up5aF3scrMonwc3LNo2Kj3Zdkzxp6mWUVL4T NvCnpPxqjpzplJIAQuHjsyzyvOaLkVKJP4l2v5eNXSxNH0UCoAZ/FJ+1FO9Zg1S77/C1 9ckw== X-Gm-Message-State: AOJu0YwRfV0nv9TLL3KWbtQYTt05A9vEZ+Il6f8coJ49mQtPF8W3Clzr NXG96yOFXpwXHFGgYfLSzvukxA== X-Google-Smtp-Source: AGHT+IENVQz6hoNfv57B1lvvdwokeoZEzpj5wnkKBagbO95gVO1UVIbwhIWwlMpNUbaH95e5W7qtSA== X-Received: by 2002:ac8:594a:0:b0:425:4043:96f6 with SMTP id 10-20020ac8594a000000b00425404396f6mr25470252qtz.131.1703002982131; Tue, 19 Dec 2023 08:23:02 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id o15-20020ac8698f000000b0042388bce404sm10363166qtq.57.2023.12.19.08.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:23:01 -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 v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Date: Tue, 19 Dec 2023 11:22:35 -0500 Message-Id: <20231219162236.36609-2-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231219162236.36609-1-kamal.dasu@broadcom.com> References: <20231219162236.36609-1-kamal.dasu@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_082303_924173_08A0BA29 X-CRM114-Status: GOOD ( 10.50 ) 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 Dec 19 16:22:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Dasu X-Patchwork-Id: 13498486 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 D7389C46CA2 for ; Tue, 19 Dec 2023 16:23:41 +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=0c8GLcwHOnSlSb4/8T6nrcVCojZ+ts4ymp8t/LV/gj0=; b=RsQewQc5wo9x7AJkH8gXbtzvaS LkliMomlIvEoXtQUat6ahmP29TO/cL30f9YCF5ceyNYvzCv01rxIrBQsxli6THUbO36o/1bOtFCkB l/rIRLzFjUnBY2UL+f8eUzQZQTdAaXDpk9646CeO9hF66XQvrd9w96i+RXEOt2lOIoRZSXxc+7R6Z cmYHUfu9tPwVWcMtoasauQyEJoCSjfsfp6aM4bolDTep9Z1n3gWbvlnAlhvhtun/IJeRbY5uSJshM KtP/6GXxGwCVaqFzYRGst7LFuWMDIfFpltoND8u1zcX/zck4z6uDRRJykEQ/Xir1V23fMqeLudsOO zxDQP1jQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFcsF-00Efmv-0m; Tue, 19 Dec 2023 16:23:15 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFcs6-00EfiO-27 for linux-arm-kernel@lists.infradead.org; Tue, 19 Dec 2023 16:23:10 +0000 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3b9e6262fccso3276211b6e.3 for ; Tue, 19 Dec 2023 08:23:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703002985; x=1703607785; 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=Ewh8VWUcOcHhsErCAlCjoMpUIPGQE7MA92/bySPZ5Uw=; b=BxpZrxPtKbZAuSuDeALunx+ahmjkpZlUbUyn6K2yJHgCXPAfz7RRsHn2L0467vYscu ywmBSuS8WxtavHnnZO2rvc5eLy9K5+XayfHH3grDXsWcwPVGPsnjbygftWLdoaW6LkHD SzFc2hPmR460GVIgAnTwoHhoXRjgcX/B7v9qI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703002985; x=1703607785; 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=Ewh8VWUcOcHhsErCAlCjoMpUIPGQE7MA92/bySPZ5Uw=; b=clfPOTpOc7VvXphRg3Ew/aZNkDYDfMAKcRYafIMcQWidoL7TadimgA/t+tcTT/FpzC df9ZVxK2pUHos2+XzuvKdKiAM1TKeZALXsfcFGwjjssUY2jS9/eA9r5E1frlwQz6nPEj VzCWXmvQHXZmx+nWLlDum/We63YIuZXaBQfdcN6HyJj2i9dadzbLk2TZHKOq7Z1aC+9c H8zwb7wWW/KeeQKED8FvV5XWfNJIT8Z4JrmaOqP6rQYlFVpW/VrqwIfVQimx4eSnQAKr tEUk8SptwBOgsU+hn9783YHQFfZHfwhrCmIFtIFCp+fBwSkXYpmo8K26WK4ETrIo2Yds mrNg== X-Gm-Message-State: AOJu0Yy4DkN2s4CcXJ+19oKfd60AJG870Jb0B5i+/aFbb+hLT2ycNyH+ Rcn5q79T/h85rKpUSvRoweuyzA== X-Google-Smtp-Source: AGHT+IEQZ3cByE9AALVT8PBlVU2YFmcnCMtSpN0KVWfSxLTtkh09nO4cE9C5U5BZfhz+FN2po+A7RQ== X-Received: by 2002:a05:6359:6f15:b0:173:24:b27c with SMTP id tk21-20020a0563596f1500b001730024b27cmr360852rwb.32.1703002985239; Tue, 19 Dec 2023 08:23:05 -0800 (PST) Received: from mail.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id o15-20020ac8698f000000b0042388bce404sm10363166qtq.57.2023.12.19.08.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 08:23:04 -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 v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Date: Tue, 19 Dec 2023 11:22:36 -0500 Message-Id: <20231219162236.36609-3-kamal.dasu@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231219162236.36609-1-kamal.dasu@broadcom.com> References: <20231219162236.36609-1-kamal.dasu@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231219_082306_696965_6FE8D0F6 X-CRM114-Status: GOOD ( 18.21 ) 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 --- drivers/mmc/host/sdhci-brcmstb.c | 67 +++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-brcmstb.c b/drivers/mmc/host/sdhci-brcmstb.c index c23251bb95f3..7c5d04be93b3 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,51 @@ 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) +{ + int ret; + u32 reg; + u32 new_mask = (mask & (SDHCI_RESET_CMD | SDHCI_RESET_DATA)) << 24; + + /* + * 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 = readb_poll_timeout(host->ioaddr + SDHCI_SOFTWARE_RESET, + reg, reg & mask, 10, 10000); + + 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 +205,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 +229,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 }, {}, };