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

Commit 058b08a2 authored by Talel Shenhar's avatar Talel Shenhar Committed by Matt Wagantall
Browse files

mmc: quirks: add new quirk that allows HPI disable



Certain cards might get broken when HPI feature is used.
This patch allows host to avoid using HPI for such
buggy cards by adding new quirk.

As some of the other features like BKOPs/Cache are
dependent on HPI feature, those features would also
get disabled if HPI is disabled.

Change-Id: I93a8810e4031eafcd44b5152296e065dc3330b63
Signed-off-by: default avatarTalel Shenhar <tatias@codeaurora.org>
parent 822d256a
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -542,13 +542,30 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
			ext_csd[EXT_CSD_PWR_CL_DDR_200_360];
	}

	/* check whether the eMMC card supports HPI */
	if ((ext_csd[EXT_CSD_HPI_FEATURES] & 0x1) &&
		!(card->quirks & MMC_QUIRK_BROKEN_HPI)) {
		card->ext_csd.hpi = 1;
		if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x2)
			card->ext_csd.hpi_cmd = MMC_STOP_TRANSMISSION;
		else
			card->ext_csd.hpi_cmd = MMC_SEND_STATUS;
		/*
		 * Indicate the maximum timeout to close
		 * a command interrupted by HPI
		 */
		card->ext_csd.out_of_int_time =
			ext_csd[EXT_CSD_OUT_OF_INTERRUPT_TIME] * 10;
	}

	if (card->ext_csd.rev >= 5) {
		/* Adjust production date as per JEDEC JESD84-B451 */
		if (card->cid.year < 2010)
			card->cid.year += 16;

		/* check whether the eMMC card supports BKOPS */
		if (ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) {
		if ((ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1) &&
				card->ext_csd.hpi) {
			card->ext_csd.bkops = 1;
			card->ext_csd.bkops_en = ext_csd[EXT_CSD_BKOPS_EN];
			card->ext_csd.raw_bkops_status =
@@ -558,21 +575,6 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
					mmc_hostname(card->host));
		}

		/* check whether the eMMC card supports HPI */
		if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x1) {
			card->ext_csd.hpi = 1;
			if (ext_csd[EXT_CSD_HPI_FEATURES] & 0x2)
				card->ext_csd.hpi_cmd =	MMC_STOP_TRANSMISSION;
			else
				card->ext_csd.hpi_cmd = MMC_SEND_STATUS;
			/*
			 * Indicate the maximum timeout to close
			 * a command interrupted by HPI
			 */
			card->ext_csd.out_of_int_time =
				ext_csd[EXT_CSD_OUT_OF_INTERRUPT_TIME] * 10;
		}

		card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
		card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION];

@@ -1673,8 +1675,9 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
	/*
	 * If cache size is higher than 0, this indicates
	 * the existence of cache and it can be turned on.
	 * If HPI is not supported then cache shouldn't be enabled.
	 */
	if (card->ext_csd.cache_size > 0) {
	if (card->ext_csd.cache_size > 0 && card->ext_csd.hpi_en) {
		err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
				EXT_CSD_CACHE_CTRL, 1,
				card->ext_csd.generic_cmd6_time);
+1 −1
Original line number Diff line number Diff line
@@ -653,7 +653,7 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status)
	unsigned int opcode;
	int err;

	if (!card->ext_csd.hpi) {
	if (!card->ext_csd.hpi_en) {
		pr_warn("%s: Card didn't support HPI command\n",
			mmc_hostname(card->host));
		return -EINVAL;
+2 −0
Original line number Diff line number Diff line
@@ -302,6 +302,8 @@ struct mmc_card {
#define MMC_QUIRK_BROKEN_IRQ_POLLING	(1<<11)	/* Polling SDIO_CCCR_INTx could create a fake interrupt */
						/* byte mode */
#define MMC_QUIRK_INAND_DATA_TIMEOUT  (1<<12)   /* For incorrect data timeout */
#define MMC_QUIRK_BROKEN_HPI (1 << 13)		/* For devices which gets */
						/* broken due to HPI feature */

	unsigned int		erase_size;	/* erase size in sectors */
 	unsigned int		erase_shift;	/* if erase unit is power 2 */