add suspend/resume support
This commit is contained in:
parent
77b2a8365a
commit
0465f35ecf
|
@ -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>
|
||||
|
@ -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 @@ wb_intr(void *opaque)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
@ -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 @@ wb_sdmmc_enable(struct wb_softc *wb)
|
|||
/* 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 @@ wb_sdmmc_attach(struct wb_softc *wb)
|
|||
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 @@ wb_sdmmc_bus_clock(sdmmc_chipset_handle_t sch, int freq)
|
|||
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 @@ wb_sdmmc_intr(struct wb_softc *wb)
|
|||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
@ -41,6 +41,7 @@ struct wb_softc {
|
|||
/* 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_idx_write(struct wb_softc *, uint8_t, uint8_t);
|
|||
|
||||
void wb_led(struct wb_softc *, bool);
|
||||
|
||||
bool wb_suspend(struct wb_softc *);
|
||||
bool wb_resume(struct wb_softc *);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue