Changeset View
Changeset View
Standalone View
Standalone View
sys/arm/allwinner/aw_mmc.c
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | |||||
static void aw_mmc_helper_cd_handler(device_t, bool); | static void aw_mmc_helper_cd_handler(device_t, bool); | ||||
static void aw_mmc_print_error(uint32_t); | static void aw_mmc_print_error(uint32_t); | ||||
static int aw_mmc_update_ios(device_t, device_t); | static int aw_mmc_update_ios(device_t, device_t); | ||||
static int aw_mmc_request(device_t, device_t, struct mmc_request *); | static int aw_mmc_request(device_t, device_t, struct mmc_request *); | ||||
static int aw_mmc_get_ro(device_t, device_t); | static int aw_mmc_get_ro(device_t, device_t); | ||||
static int aw_mmc_acquire_host(device_t, device_t); | static int aw_mmc_acquire_host(device_t, device_t); | ||||
static int aw_mmc_release_host(device_t, device_t); | static int aw_mmc_release_host(device_t, device_t); | ||||
static int aw_mmc_switch_vccq(device_t, device_t); | |||||
#ifdef MMCCAM | #ifdef MMCCAM | ||||
static void aw_mmc_cam_action(struct cam_sim *, union ccb *); | static void aw_mmc_cam_action(struct cam_sim *, union ccb *); | ||||
static void aw_mmc_cam_poll(struct cam_sim *); | static void aw_mmc_cam_poll(struct cam_sim *); | ||||
static int aw_mmc_cam_settran_settings(struct aw_mmc_softc *, union ccb *); | static int aw_mmc_cam_settran_settings(struct aw_mmc_softc *, union ccb *); | ||||
static int aw_mmc_cam_request(struct aw_mmc_softc *, union ccb *); | static int aw_mmc_cam_request(struct aw_mmc_softc *, union ccb *); | ||||
static void aw_mmc_cam_handle_mmcio(struct cam_sim *, union ccb *); | static void aw_mmc_cam_handle_mmcio(struct cam_sim *, union ccb *); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static int | static int | ||||
aw_mmc_cam_settran_settings(struct aw_mmc_softc *sc, union ccb *ccb) | aw_mmc_cam_settran_settings(struct aw_mmc_softc *sc, union ccb *ccb) | ||||
{ | { | ||||
struct mmc_ios *ios; | struct mmc_ios *ios; | ||||
struct mmc_ios *new_ios; | struct mmc_ios *new_ios; | ||||
struct ccb_trans_settings_mmc *cts; | struct ccb_trans_settings_mmc *cts; | ||||
int res; | |||||
ios = &sc->aw_host.ios; | ios = &sc->aw_host.ios; | ||||
cts = &ccb->cts.proto_specific.mmc; | cts = &ccb->cts.proto_specific.mmc; | ||||
new_ios = &cts->ios; | new_ios = &cts->ios; | ||||
/* Update only requested fields */ | /* Update only requested fields */ | ||||
if (cts->ios_valid & MMC_CLK) { | if (cts->ios_valid & MMC_CLK) { | ||||
Show All 26 Lines | if (cts->ios_valid & MMC_BT) { | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->aw_dev, "Timing => %d\n", ios->timing); | device_printf(sc->aw_dev, "Timing => %d\n", ios->timing); | ||||
} | } | ||||
if (cts->ios_valid & MMC_BM) { | if (cts->ios_valid & MMC_BM) { | ||||
ios->bus_mode = new_ios->bus_mode; | ios->bus_mode = new_ios->bus_mode; | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->aw_dev, "Bus mode => %d\n", ios->bus_mode); | device_printf(sc->aw_dev, "Bus mode => %d\n", ios->bus_mode); | ||||
} | } | ||||
if (cts->ios_valid & MMC_VCCQ) { | |||||
ios->vccq = new_ios->vccq; | |||||
if (bootverbose) | |||||
device_printf(sc->aw_dev, "VCCQ => %d\n", ios->vccq); | |||||
res = aw_mmc_switch_vccq(sc->aw_dev, NULL); | |||||
if (bootverbose) | |||||
device_printf(sc->aw_dev, "VCCQ switch result: %d\n", res); | |||||
} | |||||
return (aw_mmc_update_ios(sc->aw_dev, NULL)); | return (aw_mmc_update_ios(sc->aw_dev, NULL)); | ||||
} | } | ||||
static int | static int | ||||
aw_mmc_cam_request(struct aw_mmc_softc *sc, union ccb *ccb) | aw_mmc_cam_request(struct aw_mmc_softc *sc, union ccb *ccb) | ||||
{ | { | ||||
struct ccb_mmcio *mmcio; | struct ccb_mmcio *mmcio; | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | #endif | ||||
if (aw_mmc_setup_dma(sc) != 0) { | if (aw_mmc_setup_dma(sc) != 0) { | ||||
device_printf(sc->aw_dev, "Couldn't setup DMA!\n"); | device_printf(sc->aw_dev, "Couldn't setup DMA!\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
/* Set some defaults for freq and supported mode */ | /* Set some defaults for freq and supported mode */ | ||||
sc->aw_host.f_min = 400000; | sc->aw_host.f_min = 400000; | ||||
sc->aw_host.f_max = 52000000; | sc->aw_host.f_max = 52000000; | ||||
sc->aw_host.ios.vccq = vccq_330; | |||||
sc->aw_host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; | sc->aw_host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340; | ||||
sc->aw_host.caps |= MMC_CAP_HSPEED | MMC_CAP_SIGNALING_330; | sc->aw_host.caps |= MMC_CAP_HSPEED | MMC_CAP_SIGNALING_330; | ||||
mmc_fdt_parse(dev, 0, &sc->mmc_helper, &sc->aw_host); | mmc_fdt_parse(dev, 0, &sc->mmc_helper, &sc->aw_host); | ||||
mmc_fdt_gpio_setup(dev, 0, &sc->mmc_helper, aw_mmc_helper_cd_handler); | mmc_fdt_gpio_setup(dev, 0, &sc->mmc_helper, aw_mmc_helper_cd_handler); | ||||
#ifdef MMCCAM | #ifdef MMCCAM | ||||
sc->ccb = NULL; | sc->ccb = NULL; | ||||
if ((sc->devq = cam_simq_alloc(1)) == NULL) { | if ((sc->devq = cam_simq_alloc(1)) == NULL) { | ||||
▲ Show 20 Lines • Show All 887 Lines • ▼ Show 20 Lines | aw_mmc_update_ios(device_t bus, device_t child) | ||||
} | } | ||||
switch (ios->power_mode) { | switch (ios->power_mode) { | ||||
case power_on: | case power_on: | ||||
break; | break; | ||||
case power_off: | case power_off: | ||||
if (bootverbose) | if (bootverbose) | ||||
device_printf(sc->aw_dev, "Powering down sd/mmc\n"); | device_printf(sc->aw_dev, "Powering down sd/mmc\n"); | ||||
if (sc->mmc_helper.vmmc_supply) | if (sc->mmc_helper.vmmc_supply) | ||||
regulator_disable(sc->mmc_helper.vmmc_supply); | regulator_disable(sc->mmc_helper.vmmc_supply); | ||||
if (sc->mmc_helper.vqmmc_supply) | if (sc->mmc_helper.vqmmc_supply) | ||||
regulator_disable(sc->mmc_helper.vqmmc_supply); | regulator_disable(sc->mmc_helper.vqmmc_supply); | ||||
aw_mmc_reset(sc); | aw_mmc_reset(sc); | ||||
break; | break; | ||||
case power_up: | case power_up: | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |