Lines Matching refs:dev

28 __FBSDID("$FreeBSD: releng/11.0/sys/dev/mc146818/mc146818.c 272894 2014-10-10 14:17:42Z bapt $");
43 #include <dev/mc146818/mc146818reg.h>
44 #include <dev/mc146818/mc146818var.h>
52 mc146818_attach(device_t dev)
56 sc = device_get_softc(dev);
59 device_printf(dev, "%s: mutex not initialized\n", __func__);
80 if (((*sc->sc_mcread)(dev, MC_REGD) & MC_REGD_VRT) == 0) {
82 device_printf(dev, "%s: battery low\n", __func__);
87 (*sc->sc_mcwrite)(dev, MC_REGA, sc->sc_rega);
92 (*sc->sc_mcwrite)(dev, MC_REGB, sc->sc_regb);
95 clock_register(dev, 1000000); /* 1 second resolution */
105 mc146818_gettime(device_t dev, struct timespec *ts)
111 sc = device_get_softc(dev);
121 if (((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP) == 0)
125 device_printf(dev, "%s: timeout\n", __func__);
133 ct.sec = FROMREG((*sc->sc_mcread)(dev, MC_SEC));
134 ct.min = FROMREG((*sc->sc_mcread)(dev, MC_MIN));
135 ct.hour = FROMREG((*sc->sc_mcread)(dev, MC_HOUR));
137 ct.dow = FROMREG((*sc->sc_mcread)(dev, MC_DOW)) - 1;
138 ct.day = FROMREG((*sc->sc_mcread)(dev, MC_DOM));
139 ct.mon = FROMREG((*sc->sc_mcread)(dev, MC_MONTH));
140 year = FROMREG((*sc->sc_mcread)(dev, MC_YEAR));
143 cent = (*sc->sc_getcent)(dev);
156 mc146818_getsecs(device_t dev, int *secp)
161 sc = device_get_softc(dev);
167 if (((*sc->sc_mcread)(dev, MC_REGA) & MC_REGA_UIP) == 0) {
168 sec = FROMREG((*sc->sc_mcread)(dev, MC_SEC));
174 device_printf(dev, "%s: timeout\n", __func__);
191 mc146818_settime(device_t dev, struct timespec *ts)
197 sc = device_get_softc(dev);
207 (*sc->sc_mcwrite)(dev, MC_REGB,
212 (*sc->sc_mcwrite)(dev, MC_SEC, TOREG(ct.sec));
213 (*sc->sc_mcwrite)(dev, MC_MIN, TOREG(ct.min));
214 (*sc->sc_mcwrite)(dev, MC_HOUR, TOREG(ct.hour));
216 (*sc->sc_mcwrite)(dev, MC_DOW, TOREG(ct.dow + 1));
217 (*sc->sc_mcwrite)(dev, MC_DOM, TOREG(ct.day));
218 (*sc->sc_mcwrite)(dev, MC_MONTH, TOREG(ct.mon));
223 (*sc->sc_setcent)(dev, cent);
227 (*sc->sc_mcwrite)(dev, MC_YEAR, TOREG(year));
230 (*sc->sc_mcwrite)(dev, MC_REGB, sc->sc_regb);
242 mc146818_def_read(device_t dev, u_int reg)
246 sc = device_get_softc(dev);
252 mc146818_def_write(device_t dev, u_int reg, u_int val)
256 sc = device_get_softc(dev);
271 mc146818_def_getcent(device_t dev)
275 sc = device_get_softc(dev);
276 return ((*sc->sc_mcread)(dev, MC_CENT));
280 mc146818_def_setcent(device_t dev, u_int cent)
284 sc = device_get_softc(dev);
285 (*sc->sc_mcwrite)(dev, MC_CENT, cent);