···165165}166166167167/*168168+ * Test if the card supports high-speed mode and, if so, switch to it.169169+ */170170+static int sdio_enable_hs(struct mmc_card *card)171171+{172172+ int ret;173173+ u8 speed;174174+175175+ if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED))176176+ return 0;177177+178178+ if (!card->cccr.high_speed)179179+ return 0;180180+181181+ ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_SPEED, 0, &speed);182182+ if (ret)183183+ return ret;184184+185185+ speed |= SDIO_SPEED_EHS;186186+187187+ ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_SPEED, speed, NULL);188188+ if (ret)189189+ return ret;190190+191191+ mmc_card_set_highspeed(card);192192+ mmc_set_timing(card->host, MMC_TIMING_SD_HS);193193+194194+ return 0;195195+}196196+197197+/*168198 * Host is being removed. Free up the current card.169199 */170200static void mmc_sdio_remove(struct mmc_host *host)···363333 goto remove;364334365335 /*366366- * No support for high-speed yet, so just set367367- * the card's maximum speed.336336+ * Switch to high-speed (if supported).368337 */369369- mmc_set_clock(host, card->cis.max_dtr);338338+ err = sdio_enable_hs(card);339339+ if (err)340340+ goto remove;341341+342342+ /*343343+ * Change to the card's maximum speed.344344+ */345345+ if (mmc_card_highspeed(card)) {346346+ /*347347+ * The SDIO specification doesn't mention how348348+ * the CIS transfer speed register relates to349349+ * high-speed, but it seems that 50 MHz is350350+ * mandatory.351351+ */352352+ mmc_set_clock(host, 50000000);353353+ } else {354354+ mmc_set_clock(host, card->cis.max_dtr);355355+ }370356371357 /*372358 * Switch to wider bus (if supported).