Skip to content

Commit 27e20d6

Browse files
committed
mmc: sdhci-tegra: Add support to program MC stream ID
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2144641 commit 03813c8 Author: Prathamesh Shete <pshete@nvidia.com> Date: Tue, 6 Dec 2022 17:59:44 +0100 SMMU clients are supposed to program stream ID from their respective address spaces instead of MC override. Define NVQUIRK_PROGRAM_STREAMID and use it to program SMMU stream ID from the SDMMC client address space. Signed-off-by: Aniruddha TVS Rao <anrao@nvidia.com> Signed-off-by: Prathamesh Shete <pshete@nvidia.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com> Link: https://lore.kernel.org/r/20221206165945.3551774-6-thierry.reding@gmail.com [Ulf: Fixed a checkpatch error] Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Mark Salter <msalter@redhat.com>
1 parent 04d3a06 commit 27e20d6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/mmc/host/sdhci-tegra.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
* Copyright (C) 2010 Google, Inc.
44
*/
55

6+
#include <linux/bitfield.h>
67
#include <linux/clk.h>
78
#include <linux/delay.h>
89
#include <linux/dma-mapping.h>
910
#include <linux/err.h>
1011
#include <linux/gpio/consumer.h>
1112
#include <linux/init.h>
1213
#include <linux/io.h>
14+
#include <linux/iommu.h>
1315
#include <linux/iopoll.h>
1416
#include <linux/ktime.h>
1517
#include <linux/mmc/card.h>
@@ -95,6 +97,8 @@
9597
#define SDHCI_TEGRA_AUTO_CAL_STATUS 0x1ec
9698
#define SDHCI_TEGRA_AUTO_CAL_ACTIVE BIT(31)
9799

100+
#define SDHCI_TEGRA_CIF2AXI_CTRL_0 0x1fc
101+
98102
#define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0)
99103
#define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1)
100104
#define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2)
@@ -122,6 +126,7 @@
122126
#define NVQUIRK_HAS_TMCLK BIT(10)
123127

124128
#define NVQUIRK_HAS_ANDROID_GPT_SECTOR BIT(11)
129+
#define NVQUIRK_PROGRAM_STREAMID BIT(12)
125130

126131
/* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
127132
#define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000
@@ -178,6 +183,7 @@ struct sdhci_tegra {
178183
bool enable_hwcq;
179184
unsigned long curr_clk_rate;
180185
u8 tuned_tap_delay;
186+
u32 stream_id;
181187
};
182188

183189
static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg)
@@ -1565,6 +1571,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra234 = {
15651571
NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
15661572
NVQUIRK_ENABLE_SDR50 |
15671573
NVQUIRK_ENABLE_SDR104 |
1574+
NVQUIRK_PROGRAM_STREAMID |
15681575
NVQUIRK_HAS_TMCLK,
15691576
.min_tap_delay = 95,
15701577
.max_tap_delay = 111,
@@ -1631,6 +1638,19 @@ static int sdhci_tegra_add_host(struct sdhci_host *host)
16311638
return ret;
16321639
}
16331640

1641+
/* Program MC streamID for DMA transfers */
1642+
static void sdhci_tegra_program_stream_id(struct sdhci_host *host)
1643+
{
1644+
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
1645+
struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host);
1646+
1647+
if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID) {
1648+
tegra_sdhci_writel(host, FIELD_PREP(GENMASK(15, 8), tegra_host->stream_id) |
1649+
FIELD_PREP(GENMASK(7, 0), tegra_host->stream_id),
1650+
SDHCI_TEGRA_CIF2AXI_CTRL_0);
1651+
}
1652+
}
1653+
16341654
static int sdhci_tegra_probe(struct platform_device *pdev)
16351655
{
16361656
const struct sdhci_tegra_soc_data *soc_data;
@@ -1691,6 +1711,12 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
16911711

16921712
tegra_sdhci_parse_dt(host);
16931713

1714+
if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID &&
1715+
!tegra_dev_iommu_get_stream_id(&pdev->dev, &tegra_host->stream_id)) {
1716+
dev_warn(mmc_dev(host->mmc), "missing IOMMU stream ID\n");
1717+
tegra_host->stream_id = 0x7f;
1718+
}
1719+
16941720
tegra_host->power_gpio = devm_gpiod_get_optional(&pdev->dev, "power",
16951721
GPIOD_OUT_HIGH);
16961722
if (IS_ERR(tegra_host->power_gpio)) {
@@ -1776,6 +1802,8 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
17761802
if (rc)
17771803
goto err_add_host;
17781804

1805+
sdhci_tegra_program_stream_id(host);
1806+
17791807
return 0;
17801808

17811809
err_add_host:
@@ -1872,6 +1900,8 @@ static int sdhci_tegra_resume(struct device *dev)
18721900
if (ret)
18731901
return ret;
18741902

1903+
sdhci_tegra_program_stream_id(host);
1904+
18751905
ret = sdhci_resume_host(host);
18761906
if (ret)
18771907
goto disable_clk;

0 commit comments

Comments
 (0)