fusee: fix regression in card detection

This commit is contained in:
Kate J. Temkin 2018-05-06 22:32:52 -06:00
parent 5065a04451
commit f5ed029cdb

View file

@ -828,12 +828,6 @@ static int sdmmc_hardware_init(struct mmc *mmc)
// Ensure we're using Single-operation DMA (SDMA) mode for DMA. // Ensure we're using Single-operation DMA (SDMA) mode for DMA.
regs->host_control &= ~MMC_DMA_SELECT_MASK; regs->host_control &= ~MMC_DMA_SELECT_MASK;
// ... and verify that the card is there.
if (!sdmmc_card_present(mmc)) {
mmc_print(mmc, "ERROR: no card detected!");
return ENODEV;
}
return 0; return 0;
} }
@ -2134,7 +2128,6 @@ static int sdmmc_initialize_defaults(struct mmc *mmc)
mmc->name = "eMMC"; mmc->name = "eMMC";
mmc->max_bus_width = MMC_BUS_WIDTH_8BIT; mmc->max_bus_width = MMC_BUS_WIDTH_8BIT;
mmc->operating_voltage = MMC_VOLTAGE_1V8; mmc->operating_voltage = MMC_VOLTAGE_1V8;
mmc->card_detect_gpio = GPIO_MICROSD_CARD_DETECT;
// Set up function pointers for each of our per-instance functions. // Set up function pointers for each of our per-instance functions.
mmc->set_up_clock_and_io = sdmmc4_set_up_clock_and_io; mmc->set_up_clock_and_io = sdmmc4_set_up_clock_and_io;
@ -2153,6 +2146,7 @@ static int sdmmc_initialize_defaults(struct mmc *mmc)
mmc->card_type = MMC_CARD_SD; mmc->card_type = MMC_CARD_SD;
mmc->max_bus_width = MMC_BUS_WIDTH_4BIT; mmc->max_bus_width = MMC_BUS_WIDTH_4BIT;
mmc->operating_voltage = MMC_VOLTAGE_3V3; mmc->operating_voltage = MMC_VOLTAGE_3V3;
mmc->card_detect_gpio = GPIO_MICROSD_CARD_DETECT;
// For the microSD card slot, assume we have an SD-type card. // For the microSD card slot, assume we have an SD-type card.
// Negotiation has a chance to change this, later. // Negotiation has a chance to change this, later.
@ -2219,6 +2213,12 @@ int sdmmc_init(struct mmc *mmc, enum sdmmc_controller controller)
return rc; return rc;
} }
// ... and verify that the card is there.
if (!mmc->card_present(mmc)) {
mmc_print(mmc, "ERROR: no card detected!");
return ENODEV;
}
// Handle the initialization that's specific to the card type. // Handle the initialization that's specific to the card type.
rc = mmc->card_init(mmc); rc = mmc->card_init(mmc);
if (rc) { if (rc) {