Lines Matching +full:top +full:- +full:ctrl

1 /*-
30 * Driver for Maxim DS1307 I2C real-time clock/calendar.
103 sc->sc_ctrl = 0; in ds1307_ctrl_read()
104 error = ds1307_read1(sc->sc_dev, DS1307_CONTROL, &sc->sc_ctrl); in ds1307_ctrl_read()
106 device_printf(sc->sc_dev, "%s: cannot read from RTC: %d\n", in ds1307_ctrl_read()
118 uint8_t ctrl; in ds1307_ctrl_write() local
120 ctrl = sc->sc_ctrl & DS1307_CTRL_MASK; in ds1307_ctrl_write()
121 error = ds1307_write1(sc->sc_dev, DS1307_CONTROL, ctrl); in ds1307_ctrl_write()
123 device_printf(sc->sc_dev, "%s: cannot write to RTC: %d\n", in ds1307_ctrl_write()
139 if (sc->chiptype == TYPE_MICROCHIP_MCP7941X) in ds1307_sqwe_sysctl()
143 sqwe = newv = (sc->sc_ctrl & sqwe_bit) ? 1 : 0; in ds1307_sqwe_sysctl()
145 if (error != 0 || req->newptr == NULL) in ds1307_sqwe_sysctl()
148 sc->sc_ctrl &= ~sqwe_bit; in ds1307_sqwe_sysctl()
150 sc->sc_ctrl |= sqwe_bit; in ds1307_sqwe_sysctl()
170 tmp = (sc->sc_ctrl & DS1307_CTRL_RS_MASK); in ds1307_sqw_freq_sysctl()
172 tmp = nitems(ds1307_sqw_freq) - 1; in ds1307_sqw_freq_sysctl()
175 if (error != 0 || req->newptr == NULL) in ds1307_sqw_freq_sysctl()
182 sc->sc_ctrl &= ~DS1307_CTRL_RS_MASK; in ds1307_sqw_freq_sysctl()
183 sc->sc_ctrl |= newf; in ds1307_sqw_freq_sysctl()
202 sqwe = newv = (sc->sc_ctrl & DS1307_CTRL_OUT) ? 1 : 0; in ds1307_sqw_out_sysctl()
204 if (error != 0 || req->newptr == NULL) in ds1307_sqw_out_sysctl()
207 sc->sc_ctrl &= ~DS1307_CTRL_OUT; in ds1307_sqw_out_sysctl()
209 sc->sc_ctrl |= DS1307_CTRL_OUT; in ds1307_sqw_out_sysctl()
228 if (compat->ocd_str != NULL) { in ds1307_probe()
229 switch(compat->ocd_data) { in ds1307_probe()
240 device_set_desc(dev, "Epson RX-8035"); in ds1307_probe()
243 device_set_desc(dev, "Unknown DS1307-like device"); in ds1307_probe()
263 sc->sc_dev = dev; in ds1307_attach()
264 sc->enum_hook.ich_func = ds1307_start; in ds1307_attach()
265 sc->enum_hook.ich_arg = dev; in ds1307_attach()
268 sc->chiptype = compat->ocd_data; in ds1307_attach()
270 if (sc->chiptype == TYPE_MAXIM1307) in ds1307_attach()
271 sc->chiptype = TYPE_DS1307; in ds1307_attach()
273 sc->chiptype = TYPE_DS1307; in ds1307_attach()
280 if (config_intrhook_establish(&sc->enum_hook) != 0) in ds1307_attach()
301 dev = sc->sc_dev; in is_epson_time_valid()
304 * The RX-8035 single register read is non-standard in is_epson_time_valid()
305 * Refer to section 8.9.5 of the RX-8035 application manual: in is_epson_time_valid()
307 * Basically, register to read goes into the top 4 bits. in is_epson_time_valid()
327 device_printf(dev, "Power-on reset detected (ctrl2=%#02x)\n", in is_epson_time_valid()
343 dev = sc->sc_dev; in mark_epson_time_valid()
372 if (sc->chiptype == TYPE_EPSON_RX8035) in is_dev_time_valid()
375 dev = sc->sc_dev; in is_dev_time_valid()
384 switch (sc->chiptype) { in is_dev_time_valid()
410 config_intrhook_disestablish(&sc->enum_hook); in ds1307_start()
418 * square wave output cannot be changed or inhibited on the RX-8035, in ds1307_start()
421 if (sc->chiptype == TYPE_EPSON_RX8035) in ds1307_start()
430 ds1307_sqwe_sysctl, "IU", "DS1307 square-wave enable"); in ds1307_start()
434 "DS1307 square-wave output frequency"); in ds1307_start()
437 ds1307_sqw_out_sysctl, "IU", "DS1307 square-wave output state"); in ds1307_start()
442 * clock_settime() method to be called just after top-of-second; in ds1307_start()
443 * resetting the time resets top-of-second in the hardware. in ds1307_start()
458 error = iicdev_readfrom(sc->sc_dev, DS1307_SECS, data, sizeof(data), in ds1307_gettime()
476 if (sc->chiptype == TYPE_EPSON_RX8035) in ds1307_gettime()
482 sc->sc_use_ampm = true; in ds1307_gettime()
496 clock_dbgprint_bcd(sc->sc_dev, CLOCK_DBG_READ, &bct); in ds1307_gettime()
497 return (clock_bcd_to_ts(&bct, ts, sc->sc_use_ampm)); in ds1307_gettime()
512 * We request a timespec with no resolution-adjustment. That also in ds1307_settime()
515 ts->tv_sec -= utc_offset(); in ds1307_settime()
516 clock_ts_to_bcd(ts, &bct, sc->sc_use_ampm); in ds1307_settime()
517 clock_dbgprint_bcd(sc->sc_dev, CLOCK_DBG_WRITE, &bct); in ds1307_settime()
523 if (sc->sc_use_ampm) { in ds1307_settime()
524 pmflags = (sc->chiptype != TYPE_EPSON_RX8035) ? in ds1307_settime()
529 } else if (sc->chiptype == TYPE_EPSON_RX8035) in ds1307_settime()
541 if (sc->chiptype == TYPE_MICROCHIP_MCP7941X) { in ds1307_settime()
550 error = iicdev_writeto(sc->sc_dev, DS1307_SECS, data, sizeof(data), in ds1307_settime()
556 if (sc->chiptype == TYPE_EPSON_RX8035) in ds1307_settime()