Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/mmc/host/dwmmc.c
Show First 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | if ((len = OF_getproplen(node, "clock-frequency")) > 0) { | ||||
OF_getencprop(node, "clock-frequency", dts_value, len); | OF_getencprop(node, "clock-frequency", dts_value, len); | ||||
bus_hz = dts_value[0]; | bus_hz = dts_value[0]; | ||||
} | } | ||||
#ifdef EXT_RESOURCES | #ifdef EXT_RESOURCES | ||||
/* IP block reset is optional */ | /* IP block reset is optional */ | ||||
error = hwreset_get_by_ofw_name(sc->dev, 0, "reset", &sc->hwreset); | error = hwreset_get_by_ofw_name(sc->dev, 0, "reset", &sc->hwreset); | ||||
if (error != 0 && error != ENOENT) | if (error != 0 && | ||||
error != ENOENT && | |||||
error != ENODEV) { | |||||
device_printf(sc->dev, "Cannot get reset\n"); | device_printf(sc->dev, "Cannot get reset\n"); | ||||
goto fail; | |||||
} | |||||
/* vmmc regulator is optional */ | /* vmmc regulator is optional */ | ||||
error = regulator_get_by_ofw_property(sc->dev, 0, "vmmc-supply", | error = regulator_get_by_ofw_property(sc->dev, 0, "vmmc-supply", | ||||
&sc->vmmc); | &sc->vmmc); | ||||
if (error != 0 && error != ENOENT) | if (error != 0 && | ||||
error != ENOENT && | |||||
error != ENODEV) { | |||||
device_printf(sc->dev, "Cannot get regulator 'vmmc-supply'\n"); | device_printf(sc->dev, "Cannot get regulator 'vmmc-supply'\n"); | ||||
goto fail; | |||||
} | |||||
/* vqmmc regulator is optional */ | /* vqmmc regulator is optional */ | ||||
error = regulator_get_by_ofw_property(sc->dev, 0, "vqmmc-supply", | error = regulator_get_by_ofw_property(sc->dev, 0, "vqmmc-supply", | ||||
&sc->vqmmc); | &sc->vqmmc); | ||||
if (error != 0 && error != ENOENT) | if (error != 0 && | ||||
error != ENOENT && | |||||
error != ENODEV) { | |||||
device_printf(sc->dev, "Cannot get regulator 'vqmmc-supply'\n"); | device_printf(sc->dev, "Cannot get regulator 'vqmmc-supply'\n"); | ||||
goto fail; | |||||
} | |||||
/* Assert reset first */ | /* Assert reset first */ | ||||
if (sc->hwreset != NULL) { | if (sc->hwreset != NULL) { | ||||
error = hwreset_assert(sc->hwreset); | error = hwreset_assert(sc->hwreset); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(sc->dev, "Cannot assert reset\n"); | device_printf(sc->dev, "Cannot assert reset\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
} | } | ||||
/* BIU (Bus Interface Unit clock) is optional */ | /* BIU (Bus Interface Unit clock) is optional */ | ||||
error = clk_get_by_ofw_name(sc->dev, 0, "biu", &sc->biu); | error = clk_get_by_ofw_name(sc->dev, 0, "biu", &sc->biu); | ||||
if (error != 0 && error != ENOENT) | if (error != 0 && | ||||
error != ENOENT && | |||||
error != ENODEV) { | |||||
device_printf(sc->dev, "Cannot get 'biu' clock\n"); | device_printf(sc->dev, "Cannot get 'biu' clock\n"); | ||||
goto fail; | |||||
} | |||||
if (sc->biu) { | if (sc->biu) { | ||||
error = clk_enable(sc->biu); | error = clk_enable(sc->biu); | ||||
if (error != 0) { | if (error != 0) { | ||||
device_printf(sc->dev, "cannot enable biu clock\n"); | device_printf(sc->dev, "cannot enable biu clock\n"); | ||||
goto fail; | goto fail; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* CIU (Controller Interface Unit clock) is mandatory | * CIU (Controller Interface Unit clock) is mandatory | ||||
* if no clock-frequency property is given | * if no clock-frequency property is given | ||||
*/ | */ | ||||
error = clk_get_by_ofw_name(sc->dev, 0, "ciu", &sc->ciu); | error = clk_get_by_ofw_name(sc->dev, 0, "ciu", &sc->ciu); | ||||
if (error != 0 && error != ENOENT) | if (error != 0 && | ||||
error != ENOENT && | |||||
error != ENODEV) { | |||||
device_printf(sc->dev, "Cannot get 'ciu' clock\n"); | device_printf(sc->dev, "Cannot get 'ciu' clock\n"); | ||||
goto fail; | |||||
} | |||||
if (sc->ciu) { | if (sc->ciu) { | ||||
if (bus_hz != 0) { | if (bus_hz != 0) { | ||||
error = clk_set_freq(sc->ciu, bus_hz, 0); | error = clk_set_freq(sc->ciu, bus_hz, 0); | ||||
if (error != 0) | if (error != 0) | ||||
device_printf(sc->dev, | device_printf(sc->dev, | ||||
"cannot set ciu clock to %u\n", bus_hz); | "cannot set ciu clock to %u\n", bus_hz); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 709 Lines • Show Last 20 Lines |