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

Commit 02c19e3f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mmc: core: add clock-scaling support to HS400 cards"

parents ab4ad96a 611766c0
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -2824,13 +2824,19 @@ EXPORT_SYMBOL_GPL(mmc_reset_clk_scale_stats);
unsigned long mmc_get_max_frequency(struct mmc_host *host)
{
	unsigned long freq;
	unsigned char timing;

	if (host->ops && host->ops->get_max_frequency) {
		freq = host->ops->get_max_frequency(host);
		goto out;
	}

	switch (host->ios.timing) {
	if (mmc_card_hs400(host->card))
		timing = MMC_TIMING_MMC_HS400;
	else
		timing = host->ios.timing;

	switch (timing) {
	case MMC_TIMING_UHS_SDR50:
		freq = UHS_SDR50_MAX_DTR;
		break;
@@ -2843,6 +2849,9 @@ unsigned long mmc_get_max_frequency(struct mmc_host *host)
	case MMC_TIMING_UHS_DDR50:
		freq = UHS_DDR50_MAX_DTR;
		break;
	case MMC_TIMING_MMC_HS400:
		freq = MMC_HS400_MAX_DTR;
		break;
	default:
		mmc_host_clk_hold(host);
		freq = host->ios.clock;
@@ -2883,6 +2892,9 @@ static unsigned long mmc_get_min_frequency(struct mmc_host *host)
	case MMC_TIMING_MMC_HS200:
		freq = MMC_HIGH_52_MAX_DTR;
		break;
	case MMC_TIMING_MMC_HS400:
		freq = MMC_HIGH_52_MAX_DTR;
		break;
	case MMC_TIMING_UHS_DDR50:
		freq = UHS_DDR50_MAX_DTR / 2;
		break;
+28 −3
Original line number Diff line number Diff line
@@ -1179,6 +1179,26 @@ out:
	return err;
}

int mmc_set_clock_bus_speed(struct mmc_card *card, unsigned long freq)
{
	int err;

	if (freq < MMC_HS400_MAX_DTR) {
		/*
		 * Lower the clock and adjust the timing to be able
		 * to switch to HighSpeed mode
		 */
		mmc_set_timing(card->host, MMC_TIMING_LEGACY);
		mmc_set_clock(card->host, MMC_HIGH_26_MAX_DTR);

		err = mmc_select_hs(card, &card->cached_ext_csd);
	} else {
		err = mmc_select_hs400(card, &card->cached_ext_csd);
	}

	return err;
}

/**
 * mmc_change_bus_speed() - Change MMC card bus frequency at runtime
 * @host: pointer to mmc host structure
@@ -1214,8 +1234,6 @@ static int mmc_change_bus_speed(struct mmc_host *host, unsigned long *freq)
			|| mmc_card_hs400(card)) {
		if (*freq > card->ext_csd.hs_max_dtr)
			*freq = card->ext_csd.hs_max_dtr;
		if (mmc_card_highspeed(card) && (*freq > 52000000))
			*freq = 52000000;
	} else if (*freq > card->csd.max_dtr) {
		*freq = card->csd.max_dtr;
	}
@@ -1223,7 +1241,13 @@ static int mmc_change_bus_speed(struct mmc_host *host, unsigned long *freq)
	if (*freq < host->f_min)
		*freq = host->f_min;

	if (mmc_card_hs400(card)) {
		err = mmc_set_clock_bus_speed(card, *freq);
		if (err)
			goto out;
	} else {
		mmc_set_clock(host, (unsigned int) (*freq));
	}

	if ((mmc_card_hs400(card) || mmc_card_hs200(card))
		&& card->host->ops->execute_tuning) {
@@ -1414,6 +1438,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
		err = mmc_get_ext_csd(card, &ext_csd);
		if (err)
			goto free_card;
		memcpy(&card->cached_ext_csd, ext_csd, sizeof(card->ext_csd));
		err = mmc_read_ext_csd(card, ext_csd);
		if (err)
			goto free_card;
+1 −0
Original line number Diff line number Diff line
@@ -394,6 +394,7 @@ struct mmc_card {
	unsigned int		idle_timeout;
	struct notifier_block        reboot_notify;
	bool issue_long_pon;
	u8 cached_ext_csd;
};

/*