Skip to content

Commit

Permalink
Revert "MFC: r340495"
Browse files Browse the repository at this point in the history
This reverts commit c722f5f.
  • Loading branch information
fichtner committed Jul 2, 2019
1 parent 939e7ef commit dfe3385
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions sys/dev/mmc/mmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -828,14 +828,9 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_ivars *ivar)
const uint8_t *ext_csd;
uint32_t clock;
uint8_t value;
enum mmc_bus_timing timing;
enum mmc_bus_width bus_width;

dev = sc->dev;
timing = mmcbr_get_timing(dev);
bus_width = ivar->bus_width;
if (mmcbr_get_mode(dev) != mode_mmc || ivar->csd.spec_vers < 4 ||
timing == bus_timing_normal || bus_width == bus_width_1)
if (mmcbr_get_mode(dev) != mode_mmc || ivar->csd.spec_vers < 4)
return (MMC_ERR_NONE);

value = 0;
Expand All @@ -846,8 +841,8 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_ivars *ivar)
if (clock <= MMC_TYPE_HS_26_MAX)
value = ext_csd[EXT_CSD_PWR_CL_26_195];
else if (clock <= MMC_TYPE_HS_52_MAX) {
if (timing >= bus_timing_mmc_ddr52 &&
bus_width >= bus_width_4)
if (mmcbr_get_timing(dev) >= bus_timing_mmc_ddr52 &&
ivar->bus_width >= bus_width_4)
value = ext_csd[EXT_CSD_PWR_CL_52_195_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_52_195];
Expand All @@ -866,13 +861,13 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_ivars *ivar)
if (clock <= MMC_TYPE_HS_26_MAX)
value = ext_csd[EXT_CSD_PWR_CL_26_360];
else if (clock <= MMC_TYPE_HS_52_MAX) {
if (timing == bus_timing_mmc_ddr52 &&
bus_width >= bus_width_4)
if (mmcbr_get_timing(dev) == bus_timing_mmc_ddr52 &&
ivar->bus_width >= bus_width_4)
value = ext_csd[EXT_CSD_PWR_CL_52_360_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_52_360];
} else if (clock <= MMC_TYPE_HS200_HS400ES_MAX) {
if (bus_width == bus_width_8)
if (ivar->bus_width == bus_width_8)
value = ext_csd[EXT_CSD_PWR_CL_200_360_DDR];
else
value = ext_csd[EXT_CSD_PWR_CL_200_360];
Expand All @@ -884,7 +879,7 @@ mmc_set_power_class(struct mmc_softc *sc, struct mmc_ivars *ivar)
return (MMC_ERR_INVALID);
}

if (bus_width == bus_width_8)
if (ivar->bus_width == bus_width_8)
value = (value & EXT_CSD_POWER_CLASS_8BIT_MASK) >>
EXT_CSD_POWER_CLASS_8BIT_SHIFT;
else
Expand Down Expand Up @@ -2170,7 +2165,7 @@ mmc_calculate_clock(struct mmc_softc *sc)
for (i = 0; i < sc->child_count; i++) {
ivar = device_get_ivars(sc->child_list[i]);
if ((ivar->timings & ~(1 << bus_timing_normal)) == 0)
goto clock;
continue;

rca = ivar->rca;
if (mmc_select_card(sc, rca) != MMC_ERR_NONE) {
Expand Down Expand Up @@ -2236,7 +2231,6 @@ mmc_calculate_clock(struct mmc_softc *sc)
}
}

clock:
/* Set clock (must be done before initial tuning). */
mmcbr_set_clock(dev, max_dtr);
mmcbr_update_ios(dev);
Expand Down

0 comments on commit dfe3385

Please sign in to comment.