summaryrefslogtreecommitdiffstats
path: root/sys/dev/mmc/mmc.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2008-09-28 23:24:52 +0000
committerimp <imp@FreeBSD.org>2008-09-28 23:24:52 +0000
commit24e5e160a7d45aa5e6118a1e55027b84d9473783 (patch)
tree8aae94b487e7bd9a3ab866063e98b17b50a41f23 /sys/dev/mmc/mmc.c
parent83045cd47beead80622500100f12d67745f65b94 (diff)
downloadFreeBSD-src-24e5e160a7d45aa5e6118a1e55027b84d9473783.zip
FreeBSD-src-24e5e160a7d45aa5e6118a1e55027b84d9473783.tar.gz
Implement power down, and power down the bus on detach.
Submitted by: mav@
Diffstat (limited to 'sys/dev/mmc/mmc.c')
-rw-r--r--sys/dev/mmc/mmc.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c
index cc0db3f..439b9e0 100644
--- a/sys/dev/mmc/mmc.c
+++ b/sys/dev/mmc/mmc.c
@@ -106,6 +106,7 @@ static int mmc_detach(device_t dev);
#define MMC_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
static void mmc_delayed_attach(void *);
+static void mmc_power_down(struct mmc_softc *sc);
static int mmc_wait_for_cmd(struct mmc_softc *sc, struct mmc_command *cmd,
int retries);
static int mmc_wait_for_command(struct mmc_softc *sc, uint32_t opcode,
@@ -161,6 +162,7 @@ mmc_detach(device_t dev)
free(ivar, M_DEVBUF);
}
free(kids, M_TEMP);
+ mmc_power_down(sc);
MMC_LOCK_DESTROY(sc);
@@ -454,7 +456,19 @@ mmc_power_up(struct mmc_softc *sc)
mmc_ms_delay(2);
}
-// I wonder if the following is endian safe.
+static void
+mmc_power_down(struct mmc_softc *sc)
+{
+ device_t dev = sc->dev;
+
+ mmcbr_set_bus_mode(dev, opendrain);
+ mmcbr_set_chip_select(dev, cs_dontcare);
+ mmcbr_set_bus_width(dev, bus_width_1);
+ mmcbr_set_power_mode(dev, power_off);
+ mmcbr_set_clock(dev, 0);
+ mmcbr_update_ios(dev);
+}
+
static uint32_t
mmc_get_bits(uint32_t *bits, int start, int size)
{
OpenPOWER on IntegriCloud