Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/allwinner implement card detect
details: https://anonhg.NetBSD.org/src/rev/bc5b3beb995d
branches: trunk
changeset: 327044:bc5b3beb995d
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Feb 26 02:01:02 2014 +0000
description:
implement card detect
diffstat:
sys/arch/arm/allwinner/awin_mmc.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diffs (54 lines):
diff -r b9357f18913a -r bc5b3beb995d sys/arch/arm/allwinner/awin_mmc.c
--- a/sys/arch/arm/allwinner/awin_mmc.c Wed Feb 26 01:57:48 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_mmc.c Wed Feb 26 02:01:02 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_mmc.c,v 1.2 2014/02/26 00:39:30 jmcneill Exp $ */
+/* $NetBSD: awin_mmc.c,v 1.3 2014/02/26 02:01:02 jmcneill Exp $ */
/*-
* Copyright (c) 2014 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awin_mmc.c,v 1.2 2014/02/26 00:39:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awin_mmc.c,v 1.3 2014/02/26 02:01:02 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -84,6 +84,7 @@
int sc_mmc_number;
int sc_mmc_width;
+ int sc_mmc_present;
device_t sc_sdmmc_dev;
unsigned int sc_pll5_freq;
@@ -214,6 +215,9 @@
SMC_CAPS_SD_HIGHSPEED|
SMC_CAPS_MMC_HIGHSPEED|
SMC_CAPS_AUTO_STOP;
+ if (sc->sc_has_gpio_detect) {
+ saa.saa_caps |= SMC_CAPS_POLL_CARD_DET;
+ }
sc->sc_sdmmc_dev = config_found(self, &saa, NULL);
}
@@ -261,7 +265,16 @@
if (sc->sc_has_gpio_detect == false) {
return 1; /* no card detect pin, assume present */
} else {
- return awin_gpio_pindata_read(&sc->sc_gpio_detect);
+ int v = 0, i;
+ for (i = 0; i < 5; i++) {
+ v += awin_gpio_pindata_read(&sc->sc_gpio_detect);
+ delay(1000);
+ }
+ if (v == 5)
+ sc->sc_mmc_present = 0;
+ else if (v == 0)
+ sc->sc_mmc_present = 1;
+ return sc->sc_mmc_present;
}
}
Home |
Main Index |
Thread Index |
Old Index