Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/altera Use standard DT bindings for card detect
details: https://anonhg.NetBSD.org/src/rev/2d3199d50d90
branches: trunk
changeset: 999199:2d3199d50d90
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri May 24 10:37:39 2019 +0000
description:
Use standard DT bindings for card detect
diffstat:
sys/arch/arm/altera/cycv_dwcmmc.c | 38 +++++++++++++++++++++++++++++++++++---
1 files changed, 35 insertions(+), 3 deletions(-)
diffs (74 lines):
diff -r d75e2c876cf5 -r 2d3199d50d90 sys/arch/arm/altera/cycv_dwcmmc.c
--- a/sys/arch/arm/altera/cycv_dwcmmc.c Fri May 24 10:08:46 2019 +0000
+++ b/sys/arch/arm/altera/cycv_dwcmmc.c Fri May 24 10:37:39 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cycv_dwcmmc.c,v 1.2 2019/05/20 20:14:08 aymeric Exp $ */
+/* $NetBSD: cycv_dwcmmc.c,v 1.3 2019/05/24 10:37:39 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cycv_dwcmmc.c,v 1.2 2019/05/20 20:14:08 aymeric Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cycv_dwcmmc.c,v 1.3 2019/05/24 10:37:39 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -47,8 +47,15 @@
static int cycv_dwcmmc_match(device_t, cfdata_t, void *);
static void cycv_dwcmmc_attach(device_t, device_t, void *);
+static int cycv_dwcmmc_card_detect(struct dwc_mmc_softc *);
+
struct cycv_dwcmmc_softc {
struct dwc_mmc_softc sc;
+ int sc_phandle;
+ bool sc_non_removable;
+ bool sc_broken_cd;
+ struct fdtbus_gpio_pin *sc_gpio_cd;
+ bool sc_gpio_cd_inverted;
struct clk *sc_clk_biu;
struct clk *sc_clk_ciu;
};
@@ -128,9 +135,16 @@
sc->sc_fifo_reg = FIFO_REG;
sc->sc_flags = DWC_MMC_F_USE_HOLD_REG | DWC_MMC_F_DMA;
- sc->sc_card_detect = NULL;
+ sc->sc_card_detect = cycv_dwcmmc_card_detect;
sc->sc_write_protect = NULL;
+ esc->sc_phandle = phandle;
+ esc->sc_gpio_cd = fdtbus_gpio_acquire(phandle, "cd-gpios", GPIO_PIN_INPUT);
+ esc->sc_gpio_cd_inverted = of_hasprop(phandle, "cd-inverted") ? 0 : 1;
+
+ esc->sc_non_removable = of_hasprop(phandle, "non-removable");
+ esc->sc_broken_cd = of_hasprop(phandle, "broken-cd");
+
aprint_naive("\n");
aprint_normal(": MHS (%u Hz)\n", sc->sc_clock_freq);
@@ -151,3 +165,21 @@
}
aprint_normal_dev(self, "interrupting on %s\n", intrstr);
}
+
+static int
+cycv_dwcmmc_card_detect(struct dwc_mmc_softc *sc)
+{
+ struct cycv_dwcmmc_softc *esc = device_private(sc->sc_dev);
+ int val;
+
+ if (esc->sc_non_removable || esc->sc_broken_cd) {
+ return 1;
+ } else if (esc->sc_gpio_cd != NULL) {
+ val = fdtbus_gpio_read(esc->sc_gpio_cd);
+ if (esc->sc_gpio_cd_inverted)
+ val = !val;
+ return val;
+ } else {
+ return 1;
+ }
+}
Home |
Main Index |
Thread Index |
Old Index