Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 329da4eb authored by Sarthak Garg's avatar Sarthak Garg
Browse files

mmc: cmdq_hci: Notify sdhci for enhanced strobe



Provide cmdq_host ops of enhanced strobe to notify
sdhci on enabling/disabling cmdq. This is needed
because of following:
Before running CMDQ transfers in HS400 Enhanced Strobe mode,
SW should write 3 to
HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
Default reset value of this register is 2.

Change-Id: I36ead91ca8c9aeed967f120f8bdc3d2180af7746
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
[xiaonian@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: default avatarXiaonian Wang <xiaonian@codeaurora.org>
Signed-off-by: default avatarSarthak Garg <sartgarg@codeaurora.org>
parent 0949e032
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -375,6 +375,9 @@ static int cqhci_enable(struct mmc_host *mmc, struct mmc_card *card)

	__cqhci_enable(cq_host);

	if (cq_host->ops->enhanced_strobe_mask)
		cq_host->ops->enhanced_strobe_mask(mmc, true);

	cq_host->enabled = true;

#ifdef DEBUG
@@ -430,6 +433,9 @@ static void cqhci_disable(struct mmc_host *mmc)

	__cqhci_disable(cq_host);

	if (cq_host->ops->enhanced_strobe_mask)
		cq_host->ops->enhanced_strobe_mask(mmc, false);

	dmam_free_coherent(mmc_dev(mmc), cq_host->data_size,
			   cq_host->trans_desc_base,
			   cq_host->trans_desc_dma_base);
+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -339,6 +339,7 @@ struct cqhci_host_ops {
	u32 (*read_l)(struct cqhci_host *host, int reg);
	void (*enable)(struct mmc_host *mmc);
	void (*disable)(struct mmc_host *mmc, bool recovery);
	void (*enhanced_strobe_mask)(struct mmc_host *mmc, bool set);
};

static inline void cqhci_writel(struct cqhci_host *host, u32 val, int reg)
+36 −35
Original line number Diff line number Diff line
@@ -2553,10 +2553,46 @@ void sdhci_msm_cqe_sdhci_dumpregs(struct mmc_host *mmc)
	sdhci_dumpregs(host);
}

/*
 * sdhci_msm_enhanced_strobe_mask :-
 * Before running CMDQ transfers in HS400 Enhanced Strobe mode,
 * SW should write 3 to
 * HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
 * The default reset value of this register is 2.
 */
static void sdhci_msm_enhanced_strobe_mask(struct mmc_host *mmc, bool set)
{
	struct sdhci_host *host = mmc_priv(mmc);
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct sdhci_msm_host *msm_host = pltfm_host->priv;
	const struct sdhci_msm_offset *msm_host_offset =
					msm_host->offset;

	if (!msm_host->enhanced_strobe ||
			!mmc_card_strobe(msm_host->mmc->card)) {
		pr_debug("%s: host/card does not support hs400 enhanced strobe\n",
				mmc_hostname(host->mmc));
		return;
	}

	if (set) {
		writel_relaxed((readl_relaxed(host->ioaddr +
			msm_host_offset->CORE_VENDOR_SPEC3)
			| CORE_CMDEN_HS400_INPUT_MASK_CNT),
			host->ioaddr + msm_host_offset->CORE_VENDOR_SPEC3);
	} else {
		writel_relaxed((readl_relaxed(host->ioaddr +
			msm_host_offset->CORE_VENDOR_SPEC3)
			& ~CORE_CMDEN_HS400_INPUT_MASK_CNT),
			host->ioaddr + msm_host_offset->CORE_VENDOR_SPEC3);
	}
}

static const struct cqhci_host_ops sdhci_msm_cqhci_ops = {
	.enable		= sdhci_msm_cqe_enable,
	.disable	= sdhci_msm_cqe_disable,
	.dumpregs		= sdhci_msm_cqe_sdhci_dumpregs,
	.enhanced_strobe_mask = sdhci_msm_enhanced_strobe_mask,
};

#ifdef CONFIG_MMC_CQHCI
@@ -4360,40 +4396,6 @@ static void sdhci_msm_reset(struct sdhci_host *host, u8 mask)
		cqhci_suspend(host->mmc);
}

/*
 * sdhci_msm_enhanced_strobe_mask :-
 * Before running CMDQ transfers in HS400 Enhanced Strobe mode,
 * SW should write 3 to
 * HC_VENDOR_SPECIFIC_FUNC3.CMDEN_HS400_INPUT_MASK_CNT register.
 * The default reset value of this register is 2.
 */
static void sdhci_msm_enhanced_strobe_mask(struct sdhci_host *host, bool set)
{
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
	struct sdhci_msm_host *msm_host = pltfm_host->priv;
	const struct sdhci_msm_offset *msm_host_offset =
					msm_host->offset;

	if (!msm_host->enhanced_strobe ||
			!mmc_card_strobe(msm_host->mmc->card)) {
		pr_debug("%s: host/card does not support hs400 enhanced strobe\n",
				mmc_hostname(host->mmc));
		return;
	}

	if (set) {
		writel_relaxed((readl_relaxed(host->ioaddr +
			msm_host_offset->CORE_VENDOR_SPEC3)
			| CORE_CMDEN_HS400_INPUT_MASK_CNT),
			host->ioaddr + msm_host_offset->CORE_VENDOR_SPEC3);
	} else {
		writel_relaxed((readl_relaxed(host->ioaddr +
			msm_host_offset->CORE_VENDOR_SPEC3)
			& ~CORE_CMDEN_HS400_INPUT_MASK_CNT),
			host->ioaddr + msm_host_offset->CORE_VENDOR_SPEC3);
	}
}

static void sdhci_msm_clear_set_dumpregs(struct sdhci_host *host, bool set)
{
	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -5059,7 +5061,6 @@ static struct sdhci_ops sdhci_msm_ops = {
	.set_bus_width = sdhci_set_bus_width,
	.reset = sdhci_msm_reset,
	.clear_set_dumpregs = sdhci_msm_clear_set_dumpregs,
	.enhanced_strobe_mask = sdhci_msm_enhanced_strobe_mask,
	.reset_workaround = sdhci_msm_reset_workaround,
	.init = sdhci_msm_init,
	.pre_req = sdhci_msm_pre_req,
+0 −1
Original line number Diff line number Diff line
@@ -733,7 +733,6 @@ struct sdhci_ops {
					bool enable, u32 type);
	int     (*enable_controller_clock)(struct sdhci_host *host);
	void	(*clear_set_dumpregs)(struct sdhci_host *host, bool set);
	void	(*enhanced_strobe_mask)(struct sdhci_host *host, bool set);
	void    (*dump_vendor_regs)(struct sdhci_host *host);
	void	(*voltage_switch)(struct sdhci_host *host);
	int	(*select_drive_strength)(struct sdhci_host *host,