diff options
author | Uwe Stuehler <uwe@cvs.openbsd.org> | 2007-03-18 20:50:24 +0000 |
---|---|---|
committer | Uwe Stuehler <uwe@cvs.openbsd.org> | 2007-03-18 20:50:24 +0000 |
commit | dbae9d9f778079bf5b61ef91c0bb7361e2a5f1e4 (patch) | |
tree | 5a5022855ab04a29786dcdc23b6bb0e1b4a2c44c | |
parent | 2820d116979e135234d1261ada149c763a9c0e8f (diff) |
Add an interface to scoop(4) to control CF and SD card power
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_scoop.c | 57 | ||||
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_scoopreg.h | 8 | ||||
-rw-r--r-- | sys/arch/zaurus/dev/zaurus_scoopvar.h | 3 |
3 files changed, 62 insertions, 6 deletions
diff --git a/sys/arch/zaurus/dev/zaurus_scoop.c b/sys/arch/zaurus/dev/zaurus_scoop.c index 424fdea5efb..2b7c2aab960 100644 --- a/sys/arch/zaurus/dev/zaurus_scoop.c +++ b/sys/arch/zaurus/dev/zaurus_scoop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_scoop.c,v 1.12 2005/11/17 05:26:31 uwe Exp $ */ +/* $OpenBSD: zaurus_scoop.c,v 1.13 2007/03/18 20:50:23 uwe Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> @@ -49,10 +49,15 @@ struct cfdriver scoop_cd = { NULL, "scoop", DV_DULL }; +enum card { + SD_CARD, + CF_CARD /* socket 0 (external) */ +}; + int scoop_gpio_pin_read(struct scoop_softc *sc, int); void scoop_gpio_pin_write(struct scoop_softc *sc, int, int); void scoop_gpio_pin_ctl(struct scoop_softc *sc, int, int); - +void scoop0_set_card_power(enum card, int); int scoopmatch(struct device *parent, void *match, void *aux) @@ -223,6 +228,54 @@ scoop_set_headphone(int on) } /* + * Enable or disable 3.3V power to the SD/MMC card slot. + */ +void +scoop_set_sdmmc_power(int on) +{ + scoop0_set_card_power(SD_CARD, on ? SCP_CPR_SD_3V : SCP_CPR_OFF); +} + +/* + * The Card Power Register of the first SCOOP unit controls the power + * for the first CompactFlash slot and the SD/MMC card slot as well. + */ +void +scoop0_set_card_power(enum card slot, int new_cpr) +{ + struct scoop_softc *sc = scoop_cd.cd_devs[0]; + u_int16_t cpr; + + cpr = bus_space_read_2(sc->sc_iot, sc->sc_ioh, SCOOP_CPR); + if (new_cpr & SCP_CPR_VOLTAGE_MSK) { + if (slot == CF_CARD) + cpr |= SCP_CPR_5V; + else if (slot == SD_CARD) + cpr |= SCP_CPR_SD_3V; + + scoop_gpio_pin_write(sc, SCOOP0_CF_POWER_C3000, 1); + if (!ISSET(cpr, SCP_CPR_5V) && !ISSET(cpr, SCP_CPR_SD_3V)) + delay(5000); + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_CPR, + cpr | new_cpr); + } else { + if (slot == CF_CARD) + cpr &= ~SCP_CPR_5V; + else if (slot == SD_CARD) + cpr &= ~SCP_CPR_SD_3V; + + if (!ISSET(cpr, SCP_CPR_5V) && !ISSET(cpr, SCP_CPR_SD_3V)) { + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_CPR, + SCP_CPR_OFF); + delay(1000); + scoop_gpio_pin_write(sc, SCOOP0_CF_POWER_C3000, 0); + } else + bus_space_write_2(sc->sc_iot, sc->sc_ioh, SCOOP_CPR, + cpr | new_cpr); + } +} + +/* * Turn on pullup resistor while not reading the remote control. */ void diff --git a/sys/arch/zaurus/dev/zaurus_scoopreg.h b/sys/arch/zaurus/dev/zaurus_scoopreg.h index c2aa000147a..b5a87619883 100644 --- a/sys/arch/zaurus/dev/zaurus_scoopreg.h +++ b/sys/arch/zaurus/dev/zaurus_scoopreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_scoopreg.h,v 1.7 2005/07/01 23:51:55 uwe Exp $ */ +/* $OpenBSD: zaurus_scoopreg.h,v 1.8 2007/03/18 20:50:23 uwe Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> @@ -34,8 +34,10 @@ #define SCP_CSR_PWR 0x0080 #define SCOOP_CPR 0x0c /* card power register */ #define SCP_CPR_OFF 0x0000 -#define SCP_CPR_3V 0x0001 -#define SCP_CPR_5V 0x0002 +#define SCP_CPR_3V 0x0001 /* 3V for CF card */ +#define SCP_CPR_5V 0x0002 /* 5V for CF card */ +#define SCP_CPR_SD_3V 0x0004 /* 3.3V for SD/MMC card */ +#define SCP_CPR_VOLTAGE_MSK 0x0007 #define SCP_CPR_PWR 0x0080 #define SCOOP_CCR 0x10 /* card control register */ #define SCP_CCR_RESET 0x0080 diff --git a/sys/arch/zaurus/dev/zaurus_scoopvar.h b/sys/arch/zaurus/dev/zaurus_scoopvar.h index 84411efc87f..2f5d1c78851 100644 --- a/sys/arch/zaurus/dev/zaurus_scoopvar.h +++ b/sys/arch/zaurus/dev/zaurus_scoopvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: zaurus_scoopvar.h,v 1.10 2005/11/17 05:26:31 uwe Exp $ */ +/* $OpenBSD: zaurus_scoopvar.h,v 1.11 2007/03/18 20:50:23 uwe Exp $ */ /* * Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de> @@ -27,6 +27,7 @@ void scoop_charge_battery(int, int); void scoop_discharge_battery(int); void scoop_check_mcr(void); void scoop_set_headphone(int); +void scoop_set_sdmmc_power(int); void scoop_akin_pullup(int); void scoop_suspend(void); void scoop_resume(void); |