Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/nvidia hook up power, card detect, write protec...
details: https://anonhg.NetBSD.org/src/rev/8981b27b5421
branches: trunk
changeset: 337889:8981b27b5421
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat May 02 17:07:55 2015 +0000
description:
hook up power, card detect, write protect gpios
diffstat:
sys/arch/arm/nvidia/tegra_sdhc.c | 49 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 47 insertions(+), 2 deletions(-)
diffs (95 lines):
diff -r 35feaafb9c16 -r 8981b27b5421 sys/arch/arm/nvidia/tegra_sdhc.c
--- a/sys/arch/arm/nvidia/tegra_sdhc.c Sat May 02 17:06:53 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_sdhc.c Sat May 02 17:07:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_sdhc.c,v 1.2 2015/05/02 14:10:03 jmcneill Exp $ */
+/* $NetBSD: tegra_sdhc.c,v 1.3 2015/05/02 17:07:55 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.2 2015/05/02 14:10:03 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.3 2015/05/02 17:07:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -50,6 +50,9 @@
static int tegra_sdhc_match(device_t, cfdata_t, void *);
static void tegra_sdhc_attach(device_t, device_t, void *);
+static int tegra_sdhc_card_detect(struct sdhc_softc *);
+static int tegra_sdhc_write_protect(struct sdhc_softc *);
+
struct tegra_sdhc_softc {
struct sdhc_softc sc;
@@ -60,6 +63,10 @@
bus_size_t sc_bsz;
struct sdhc_host *sc_host;
void *sc_ih;
+
+ struct tegra_gpio_pin *sc_pin_cd;
+ struct tegra_gpio_pin *sc_pin_power;
+ struct tegra_gpio_pin *sc_pin_wp;
};
CFATTACH_DECL_NEW(tegra_sdhc, sizeof(struct tegra_sdhc_softc),
@@ -77,6 +84,8 @@
struct tegra_sdhc_softc * const sc = device_private(self);
struct tegraio_attach_args * const tio = aux;
const struct tegra_locators * const loc = &tio->tio_loc;
+ prop_dictionary_t prop = device_properties(self);
+ const char *pin;
int error;
sc->sc.sc_dev = self;
@@ -97,6 +106,22 @@
sc->sc_bsz = loc->loc_size;
sc->sc_port = loc->loc_port;
+ if (prop_dictionary_get_cstring_nocopy(prop, "power-gpio", &pin)) {
+ sc->sc_pin_power = tegra_gpio_acquire(pin, GPIO_PIN_OUTPUT);
+ if (sc->sc_pin_power)
+ tegra_gpio_write(sc->sc_pin_power, 1);
+ }
+
+ if (prop_dictionary_get_cstring_nocopy(prop, "cd-gpio", &pin))
+ sc->sc_pin_cd = tegra_gpio_acquire(pin, GPIO_PIN_INPUT);
+ if (prop_dictionary_get_cstring_nocopy(prop, "wp-gpio", &pin))
+ sc->sc_pin_wp = tegra_gpio_acquire(pin, GPIO_PIN_INPUT);
+
+ if (sc->sc_pin_cd)
+ sc->sc.sc_vendor_card_detect = tegra_sdhc_card_detect;
+ if (sc->sc_pin_wp)
+ sc->sc.sc_vendor_write_protect = tegra_sdhc_write_protect;
+
/*
* The controller supports SDR104 speeds (208 MHz). With PLLP (408 Mhz)
* as input and div=2 we can get a reasonable 204 MHz for the SDHC.
@@ -131,3 +156,23 @@
return;
}
}
+
+static int
+tegra_sdhc_card_detect(struct sdhc_softc *ssc)
+{
+ struct tegra_sdhc_softc *sc = device_private(ssc->sc_dev);
+
+ KASSERT(sc->sc_pin_cd != NULL);
+
+ return !tegra_gpio_read(sc->sc_pin_cd);
+}
+
+static int
+tegra_sdhc_write_protect(struct sdhc_softc *ssc)
+{
+ struct tegra_sdhc_softc *sc = device_private(ssc->sc_dev);
+
+ KASSERT(sc->sc_pin_wp != NULL);
+
+ return tegra_gpio_read(sc->sc_pin_wp);
+}
Home |
Main Index |
Thread Index |
Old Index