* [PATCH v5 0/2] mmc: add new sdhci reset sequence for brcm 74165b0 @ 2023-12-19 16:22 Kamal Dasu 2023-12-19 16:22 ` [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Kamal Dasu 2023-12-19 16:22 ` [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu 0 siblings, 2 replies; 6+ messages in thread From: Kamal Dasu @ 2023-12-19 16:22 UTC (permalink / raw) To: ulf.hansson, linux-kernel, alcooperx, linux-arm-kernel, adrian.hunter, linux-mmc, robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree Cc: f.fainelli, bcm-kernel-feedback-list, Kamal Dasu [-- Attachment #1: Type: text/plain, Size: 1102 bytes --] v5 changes - got rid of 'Reported by:' and 'Closes:' tags for all patches v4 changes: - Fix for v3 changes that introduced dt schema errors - Fix for v3 changes that introduced sdhci-brcmstb build warnings - Added proper PATCH format and cleanup commit messages as per review comments. Added proper 'Reported-by' and 'Closes' tags - Added comments for 32-bit register access as per review comments - Replaced wait loop polling with readb_poll_timeout() helper as per review comments for the sdhci-brcmstb driver changes v3 changes: - Removed extra emun arrayfor possible compatible strings - shdci-brcmstb checkpatch warning fixes v2 changes: - Fixed devicetree bindings for shdci-brcmstb and removed 74165 compatible string as per review comments Kamal Dasu (2): dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 mmc: add new sdhci reset sequence for brcm 74165b0 .../bindings/mmc/brcm,sdhci-brcmstb.yaml | 4 +- drivers/mmc/host/sdhci-brcmstb.c | 67 +++++++++++++++++-- 2 files changed, 63 insertions(+), 8 deletions(-) -- 2.17.1 [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 4203 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 2023-12-19 16:22 [PATCH v5 0/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu @ 2023-12-19 16:22 ` Kamal Dasu 2023-12-20 7:36 ` Krzysztof Kozlowski 2023-12-19 16:22 ` [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu 1 sibling, 1 reply; 6+ messages in thread From: Kamal Dasu @ 2023-12-19 16:22 UTC (permalink / raw) To: ulf.hansson, linux-kernel, alcooperx, linux-arm-kernel, adrian.hunter, linux-mmc, robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree Cc: f.fainelli, bcm-kernel-feedback-list, Kamal Dasu [-- Attachment #1: Type: text/plain, Size: 985 bytes --] From: Kamal Dasu <kdasu@broadcom.com> With newer sdio controller core used for 74165b0 we need to update the compatibility with "brcm,bcm74165b0-sdhci". Signed-off-by: Kamal Dasu <kdasu@broadcom.com> --- 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 -- 2.17.1 [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 4203 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 2023-12-19 16:22 ` [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Kamal Dasu @ 2023-12-20 7:36 ` Krzysztof Kozlowski 0 siblings, 0 replies; 6+ messages in thread From: Krzysztof Kozlowski @ 2023-12-20 7:36 UTC (permalink / raw) To: Kamal Dasu, ulf.hansson, linux-kernel, alcooperx, linux-arm-kernel, adrian.hunter, linux-mmc, robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree Cc: f.fainelli, bcm-kernel-feedback-list, Kamal Dasu On 19/12/2023 17:22, Kamal Dasu wrote: > From: Kamal Dasu <kdasu@broadcom.com> > > With newer sdio controller core used for 74165b0 we need to update > the compatibility with "brcm,bcm74165b0-sdhci". > > Signed-off-by: Kamal Dasu <kdasu@broadcom.com> > --- Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- This is an automated instruction, just in case, because many review tags are being ignored. If you know the process, you can skip it (please do not feel offended by me posting it here - no bad intentions intended). If you do not know the process, here is a short explanation: Please add Acked-by/Reviewed-by/Tested-by tags when posting new versions, under or above your Signed-off-by tag. Tag is "received", when provided in a message replied to you on the mailing list. Tools like b4 can help here. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for tags received on the version they apply. https://elixir.bootlin.com/linux/v6.5-rc3/source/Documentation/process/submitting-patches.rst#L577 Best regards, Krzysztof ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 2023-12-19 16:22 [PATCH v5 0/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu 2023-12-19 16:22 ` [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Kamal Dasu @ 2023-12-19 16:22 ` Kamal Dasu 2023-12-19 21:55 ` Florian Fainelli 1 sibling, 1 reply; 6+ messages in thread From: Kamal Dasu @ 2023-12-19 16:22 UTC (permalink / raw) To: ulf.hansson, linux-kernel, alcooperx, linux-arm-kernel, adrian.hunter, linux-mmc, robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree Cc: f.fainelli, bcm-kernel-feedback-list, Kamal Dasu [-- Attachment #1: Type: text/plain, Size: 4375 bytes --] From: Kamal Dasu <kdasu@broadcom.com> 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 <kdasu@broadcom.com> --- 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 <linux/io.h> +#include <linux/iopoll.h> #include <linux/mmc/host.h> #include <linux/module.h> #include <linux/of.h> @@ -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 }, {}, }; -- 2.17.1 [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 4203 bytes --] ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 2023-12-19 16:22 ` [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu @ 2023-12-19 21:55 ` Florian Fainelli 2023-12-20 2:07 ` Kamal Dasu 0 siblings, 1 reply; 6+ messages in thread From: Florian Fainelli @ 2023-12-19 21:55 UTC (permalink / raw) To: Kamal Dasu, ulf.hansson, linux-kernel, alcooperx, linux-arm-kernel, adrian.hunter, linux-mmc, robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree Cc: f.fainelli, bcm-kernel-feedback-list, Kamal Dasu [-- Attachment #1: Type: text/plain, Size: 1369 bytes --] Hi Kamal, On 12/19/2023 5:22 PM, Kamal Dasu wrote: > From: Kamal Dasu <kdasu@broadcom.com> > > 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 <kdasu@broadcom.com> > --- [snip] > +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); Does this need to be readb_poll_timeout_atomic() since this function can be used in both atomic and non-atomic context AFAIR? -- Florian [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 4221 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 2023-12-19 21:55 ` Florian Fainelli @ 2023-12-20 2:07 ` Kamal Dasu 0 siblings, 0 replies; 6+ messages in thread From: Kamal Dasu @ 2023-12-20 2:07 UTC (permalink / raw) To: Florian Fainelli Cc: ulf.hansson, linux-kernel, alcooperx, linux-arm-kernel, adrian.hunter, linux-mmc, robh+dt, krzysztof.kozlowski+dt, conor+dt, devicetree, f.fainelli, bcm-kernel-feedback-list, Kamal Dasu [-- Attachment #1: Type: text/plain, Size: 1644 bytes --] > On Dec 19, 2023, at 4:55 PM, Florian Fainelli <florian.fainelli@broadcom.com> wrote: > > Hi Kamal, > >> On 12/19/2023 5:22 PM, Kamal Dasu wrote: >> From: Kamal Dasu <kdasu@broadcom.com> >> 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 <kdasu@broadcom.com> >> --- > > [snip] > >> +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); > > Does this need to be readb_poll_timeout_atomic() since this function can be used in both atomic and non-atomic context AFAIR? Yes it does. Will send a v6 > -- > Florian Kamal [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/pkcs7-signature, Size: 4203 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-12-20 7:36 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-12-19 16:22 [PATCH v5 0/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu 2023-12-19 16:22 ` [PATCH v5 1/2] dt-bindings: mmc: brcm,sdhci-brcmstb: Add support for 74165b0 Kamal Dasu 2023-12-20 7:36 ` Krzysztof Kozlowski 2023-12-19 16:22 ` [PATCH v5 2/2] mmc: add new sdhci reset sequence for brcm 74165b0 Kamal Dasu 2023-12-19 21:55 ` Florian Fainelli 2023-12-20 2:07 ` Kamal Dasu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox