From: Tony Lindgren <tony@atomide.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>,
Chunyan Zhang <zhang.chunyan@linaro.org>,
Faiz Abbas <faiz_abbas@ti.com>,
Kishon Vijay Abraham I <kishon@ti.com>,
Santosh Shilimkar <ssantosh@kernel.org>,
linux-mmc@vger.kernel.org, linux-omap@vger.kernel.org
Subject: [PATCH 5/5] mmc: sdhci-omap: Check MMCHS_HL_HWINFO register for ADMA
Date: Tue, 21 Sep 2021 14:00:29 +0300 [thread overview]
Message-ID: <20210921110029.21944-6-tony@atomide.com> (raw)
In-Reply-To: <20210921110029.21944-1-tony@atomide.com>
ADMA is only available on controller instances that are connected to the
L3 interconnect and are bus mastering capable.
As the MMCHS_HL_HWINFO is in the module registers before omap registers
and sdhci registers, and the omap registers and sdhci registers can be
at different offsets depending on the SoC, let's read MMCHS_HL_HWINFO
directly.
Let's also switch to using device_property_present() while at it.
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/mmc/host/sdhci-omap.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -692,6 +692,22 @@ static void sdhci_omap_set_power(struct sdhci_host *host, unsigned char mode,
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
}
+/*
+ * MMCHS_HL_HWINFO has the MADMA_EN bit set if the controller instance
+ * is connected to L3 interconnect and is bus master capable. Note that
+ * the MMCHS_HL_HWINFO register is in the module registers before the
+ * omap registers and sdhci registers. The offset can vary for omap
+ * registers depending on the SoC. Do not use sdhci_omap_readl() here.
+ */
+static bool sdhci_omap_has_adma(struct sdhci_omap_host *omap_host, int offset)
+{
+ /* MMCHS_HL_HWINFO register is only available on omap4 and later */
+ if (offset < 0x200)
+ return false;
+
+ return readl(omap_host->base + 4) & 1;
+}
+
static int sdhci_omap_enable_dma(struct sdhci_host *host)
{
u32 reg;
@@ -1209,8 +1225,12 @@ static int sdhci_omap_probe(struct platform_device *pdev)
host->mmc_host_ops.execute_tuning = sdhci_omap_execute_tuning;
host->mmc_host_ops.enable_sdio_irq = sdhci_omap_enable_sdio_irq;
- /* Switch to external DMA only if there is the "dmas" property */
- if (of_find_property(dev->of_node, "dmas", NULL))
+ /*
+ * Switch to external DMA only if there is the "dmas" property and
+ * ADMA is not available on the controller instance.
+ */
+ if (device_property_present(dev, "dmas") &&
+ !sdhci_omap_has_adma(omap_host, offset))
sdhci_switch_external_dma(host, true);
if (device_property_read_bool(dev, "ti,non-removable")) {
--
2.33.0
next prev parent reply other threads:[~2021-09-21 11:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 11:00 [PATCH 0/5] Prepare sdhci-omap to support more SoCs Tony Lindgren
2021-09-21 11:00 ` [PATCH 1/5] mmc: sdhci-omap: Fix NULL pointer exception if regulator is not configured Tony Lindgren
2021-09-21 11:00 ` [PATCH 2/5] mmc: sdhci-omap: Fix context restore Tony Lindgren
2021-09-21 11:00 ` [PATCH 3/5] mmc: sdhci-omap: Restore sysconfig after reset Tony Lindgren
2021-09-21 11:00 ` [PATCH 4/5] mmc: sdhci-omap: Parse legacy ti,non-removable property Tony Lindgren
2021-09-23 18:42 ` Ulf Hansson
2021-09-24 7:04 ` Tony Lindgren
2021-09-21 11:00 ` Tony Lindgren [this message]
2021-09-23 18:50 ` [PATCH 0/5] Prepare sdhci-omap to support more SoCs Ulf Hansson
2021-09-24 7:06 ` Tony Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210921110029.21944-6-tony@atomide.com \
--to=tony@atomide.com \
--cc=adrian.hunter@intel.com \
--cc=faiz_abbas@ti.com \
--cc=kishon@ti.com \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=ssantosh@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=zhang.chunyan@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox