Module Name: src Committed By: jmcneill Date: Thu Aug 19 14:58:22 UTC 2010
Modified Files: src/sys/dev/ic: w83l518d.c w83l518d_sdmmc.c w83l518d_sdmmc.h w83l518dvar.h Log Message: add suspend/resume support To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/ic/w83l518d.c \ src/sys/dev/ic/w83l518d_sdmmc.c src/sys/dev/ic/w83l518d_sdmmc.h \ src/sys/dev/ic/w83l518dvar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ic/w83l518d.c diff -u src/sys/dev/ic/w83l518d.c:1.1 src/sys/dev/ic/w83l518d.c:1.2 --- src/sys/dev/ic/w83l518d.c:1.1 Wed Sep 30 20:44:50 2009 +++ src/sys/dev/ic/w83l518d.c Thu Aug 19 14:58:22 2010 @@ -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 <jmcne...@invisible.ca> @@ -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; +} Index: src/sys/dev/ic/w83l518d_sdmmc.c diff -u src/sys/dev/ic/w83l518d_sdmmc.c:1.1 src/sys/dev/ic/w83l518d_sdmmc.c:1.2 --- src/sys/dev/ic/w83l518d_sdmmc.c:1.1 Wed Sep 30 20:44:50 2009 +++ src/sys/dev/ic/w83l518d_sdmmc.c Thu Aug 19 14:58:22 2010 @@ -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 <jmcne...@invisible.ca> @@ -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; +} Index: src/sys/dev/ic/w83l518d_sdmmc.h diff -u src/sys/dev/ic/w83l518d_sdmmc.h:1.1 src/sys/dev/ic/w83l518d_sdmmc.h:1.2 --- src/sys/dev/ic/w83l518d_sdmmc.h:1.1 Wed Sep 30 20:44:50 2009 +++ src/sys/dev/ic/w83l518d_sdmmc.h Thu Aug 19 14:58:22 2010 @@ -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 <jmcne...@invisible.ca> @@ -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 Index: src/sys/dev/ic/w83l518dvar.h diff -u src/sys/dev/ic/w83l518dvar.h:1.1 src/sys/dev/ic/w83l518dvar.h:1.2 --- src/sys/dev/ic/w83l518dvar.h:1.1 Wed Sep 30 20:44:50 2009 +++ src/sys/dev/ic/w83l518dvar.h Thu Aug 19 14:58:22 2010 @@ -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 <jmcne...@invisible.ca> @@ -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