Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic add suspend/resume support
details: https://anonhg.NetBSD.org/src/rev/62bd173602a0
branches: trunk
changeset: 757209:62bd173602a0
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Thu Aug 19 14:58:22 2010 +0000
description:
add suspend/resume support
diffstat:
sys/dev/ic/w83l518d.c | 25 +++++++++++++++++++++++--
sys/dev/ic/w83l518d_sdmmc.c | 38 ++++++++++++++++++++++++++++++++++----
sys/dev/ic/w83l518d_sdmmc.h | 4 +++-
sys/dev/ic/w83l518dvar.h | 6 +++++-
4 files changed, 65 insertions(+), 8 deletions(-)
diffs (166 lines):
diff -r 687935151b9b -r 62bd173602a0 sys/dev/ic/w83l518d.c
--- a/sys/dev/ic/w83l518d.c Thu Aug 19 11:08:33 2010 +0000
+++ b/sys/dev/ic/w83l518d.c Thu Aug 19 14:58:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518d.c,v 1.1 2009/09/30 20:44:50 jmcneill Exp $ */
+/* $NetBSD: w83l518d.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */
/*
* Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v 1.1 2009/09/30 20:44:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w83l518d.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -137,3 +137,24 @@
return 0;
}
+
+/*
+ * pmf
+ */
+bool
+wb_suspend(struct wb_softc *wb)
+{
+ if (wb->wb_type == WB_DEVNO_SD)
+ return wb_sdmmc_suspend(wb);
+
+ return false;
+}
+
+bool
+wb_resume(struct wb_softc *wb)
+{
+ if (wb->wb_type == WB_DEVNO_SD)
+ return wb_sdmmc_resume(wb);
+
+ return false;
+}
diff -r 687935151b9b -r 62bd173602a0 sys/dev/ic/w83l518d_sdmmc.c
--- a/sys/dev/ic/w83l518d_sdmmc.c Thu Aug 19 11:08:33 2010 +0000
+++ b/sys/dev/ic/w83l518d_sdmmc.c Thu Aug 19 14:58:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518d_sdmmc.c,v 1.1 2009/09/30 20:44:50 jmcneill Exp $ */
+/* $NetBSD: w83l518d_sdmmc.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */
/*
* Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: w83l518d_sdmmc.c,v 1.1 2009/09/30 20:44:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w83l518d_sdmmc.c,v 1.2 2010/08/19 14:58:22 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -126,12 +126,12 @@
/* put the device in a known state */
wb_idx_write(wb, WB_INDEX_SETUP, WB_SETUP_SOFT_RST);
while (--i > 0 && wb_idx_read(wb, WB_INDEX_SETUP) & WB_SETUP_SOFT_RST)
- delay(10);
+ delay(100);
if (i == 0) {
aprint_error_dev(wb->wb_dev, "timeout resetting device\n");
return false;
}
- wb_idx_write(wb, WB_INDEX_CLK, WB_CLK_375K);
+ wb_idx_write(wb, WB_INDEX_CLK, wb->wb_sdmmc_clk);
wb_idx_write(wb, WB_INDEX_FIFOEN, 0);
wb_idx_write(wb, WB_INDEX_DMA, 0);
wb_idx_write(wb, WB_INDEX_PBSMSB, 0);
@@ -172,6 +172,7 @@
callout_setfunc(&wb->wb_sdmmc_callout, wb_sdmmc_discover, wb);
wb->wb_sdmmc_width = 1;
+ wb->wb_sdmmc_clk = WB_CLK_375K;
if (wb_sdmmc_enable(wb) == false)
return;
@@ -287,6 +288,8 @@
else
clk = WB_CLK_375K;
+ wb->wb_sdmmc_clk = clk;
+
if (wb_idx_read(wb, WB_INDEX_CLK) != clk)
wb_idx_write(wb, WB_INDEX_CLK, clk);
@@ -574,3 +577,30 @@
return 1;
}
+
+/*
+ * pmf
+ */
+bool
+wb_sdmmc_suspend(struct wb_softc *wb)
+{
+ return wb_sdmmc_disable(wb);
+}
+
+bool
+wb_sdmmc_resume(struct wb_softc *wb)
+{
+ uint8_t val;
+
+ val = wb_read(wb, WB_SD_CSR);
+ val &= ~WB_CSR_POWER_N;
+ wb_write(wb, WB_SD_CSR, val);
+
+ if (wb_sdmmc_enable(wb) == false)
+ return false;
+
+ if (wb_idx_read(wb, WB_INDEX_CLK) != wb->wb_sdmmc_clk)
+ wb_idx_write(wb, WB_INDEX_CLK, wb->wb_sdmmc_clk);
+
+ return true;
+}
diff -r 687935151b9b -r 62bd173602a0 sys/dev/ic/w83l518d_sdmmc.h
--- a/sys/dev/ic/w83l518d_sdmmc.h Thu Aug 19 11:08:33 2010 +0000
+++ b/sys/dev/ic/w83l518d_sdmmc.h Thu Aug 19 14:58:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518d_sdmmc.h,v 1.1 2009/09/30 20:44:50 jmcneill Exp $ */
+/* $NetBSD: w83l518d_sdmmc.h,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */
/*
* Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,5 +31,7 @@
void wb_sdmmc_attach(struct wb_softc *);
int wb_sdmmc_detach(struct wb_softc *, int);
int wb_sdmmc_intr(struct wb_softc *);
+bool wb_sdmmc_suspend(struct wb_softc *);
+bool wb_sdmmc_resume(struct wb_softc *);
#endif
diff -r 687935151b9b -r 62bd173602a0 sys/dev/ic/w83l518dvar.h
--- a/sys/dev/ic/w83l518dvar.h Thu Aug 19 11:08:33 2010 +0000
+++ b/sys/dev/ic/w83l518dvar.h Thu Aug 19 14:58:22 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w83l518dvar.h,v 1.1 2009/09/30 20:44:50 jmcneill Exp $ */
+/* $NetBSD: w83l518dvar.h,v 1.2 2010/08/19 14:58:22 jmcneill Exp $ */
/*
* Copyright (c) 2009 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -41,6 +41,7 @@
/* private */
device_t wb_sdmmc_dev;
int wb_sdmmc_width;
+ uint8_t wb_sdmmc_clk;
uint8_t wb_sdmmc_intsts;
callout_t wb_sdmmc_callout;
};
@@ -56,4 +57,7 @@
void wb_led(struct wb_softc *, bool);
+bool wb_suspend(struct wb_softc *);
+bool wb_resume(struct wb_softc *);
+
#endif
Home |
Main Index |
Thread Index |
Old Index