Lines Matching +full:rom +full:- +full:14 +full:h
1 /*-
26 #include <sys/param.h>
27 #include <sys/systm.h>
28 #include <sys/kernel.h>
30 #include <sys/bus.h>
31 #include <sys/errno.h>
32 #include <sys/libkern.h>
33 #include <sys/lock.h>
34 #include <sys/malloc.h>
35 #include <sys/module.h>
36 #include <sys/mutex.h>
37 #include <sys/sbuf.h>
38 #include <sys/sysctl.h>
40 #include <dev/ow/ow.h>
41 #include <dev/ow/owll.h>
42 #include <dev/ow/own.h>
45 * lldev - link level device
46 * ndev - network / transport device (this module)
47 * pdev - presentation device (children of this module)
68 #define OW_LOCK(_sc) mtx_lock(&(_sc)->mtx)
69 #define OW_UNLOCK(_sc) mtx_unlock(&(_sc)->mtx)
70 #define OW_LOCK_DESTROY(_sc) mtx_destroy(&_sc->mtx)
71 #define OW_ASSERT_LOCKED(_sc) mtx_assert(&_sc->mtx, MA_OWNED)
72 #define OW_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->mtx, MA_NOTOWNED)
162 "1-Wire protocol");
175 if (err != 0 || req->newptr == NULL) \
187 "1-Wire timing parameter in microseconds (-1 resets to default)")
251 } while (present == 1 && tries-- > 0); in ow_send_command()
256 if (present == -1) { in ow_send_command()
261 for (i = 0; i < cmd->rom_len; i++) in ow_send_command()
262 ow_send_byte(lldev, &timing_regular, cmd->rom_cmd[i]); in ow_send_command()
263 for (i = 0; i < cmd->rom_read_len; i++) in ow_send_command()
264 ow_read_byte(lldev, &timing_regular, cmd->rom_read + i); in ow_send_command()
265 if (cmd->xpt_len) { in ow_send_command()
267 * Per AN937, the reset pulse and ROM level are always in ow_send_command()
268 * done with the regular timings. Certain ROM commands in ow_send_command()
274 t = (cmd->flags & OW_FLAG_OVERDRIVE) ? in ow_send_command()
276 for (i = 0; i < cmd->xpt_len; i++) in ow_send_command()
277 ow_send_byte(lldev, t, cmd->xpt_cmd[i]); in ow_send_command()
278 if (cmd->flags & OW_FLAG_READ_BIT) { in ow_send_command()
279 memset(cmd->xpt_read, 0, (cmd->xpt_read_len + 7) / 8); in ow_send_command()
280 for (i = 0; i < cmd->xpt_read_len; i++) { in ow_send_command()
282 cmd->xpt_read[i / 8] |= bit << (i % 8); in ow_send_command()
285 for (i = 0; i < cmd->xpt_read_len; i++) in ow_send_command()
286 ow_read_byte(lldev, t, cmd->xpt_read + i); in ow_send_command()
323 di->romid = romid; in ow_add_child()
352 if (di->romid == romid) { in ow_child_by_romid()
363 * CRC generator table -- taken from AN937 DOW CRC LOOKUP FUNCTION Table 2
375 17, 79, 173, 243, 112, 46, 204, 146, 211,141, 111, 49, 178, 236, 14, 80,
410 * All valid ROM IDs have a valid CRC. Check that first. in ow_device_found()
435 prior = -1; in ow_enumerate()
438 last = -2; in ow_enumerate()
442 while (last != -1) { in ow_enumerate()
443 if (sanity-- < 0) { in ow_enumerate()
449 last = -1; in ow_enumerate()
454 * send ROM ID bits one at a time (first the bit, then the in ow_enumerate()
461 * devices on the bus and wind up with a unique ROM. We know in ow_enumerate()
494 case 1: /* 1 then 0 -> 1 for all */ in ow_enumerate()
497 case 2: /* 0 then 1 -> 0 for all */ in ow_enumerate()
507 * the top of the loop for a re-do of this step. in ow_enumerate()
558 sc->dev = ndev; in ow_attach()
559 mtx_init(&sc->mtx, device_get_nameunit(sc->dev), "ow", MTX_DEF); in ow_attach()
587 sbuf_printf(sb, "romid=%8D", &di->romid, ":"); in ow_child_pnpinfo()
600 *result = di->romid & 0xff; in ow_read_ivar()
604 *ptr = &di->romid; in ow_read_ivar()
629 retval += printf(" romid %8D", &di->romid, ":"); in ow_print_child()
641 device_printf(ndev, "romid %8D: no driver\n", &di->romid, ":"); in ow_probe_nomatch()
652 if (sc->owner != NULL) { in ow_acquire_bus()
653 if (sc->owner == pdev) in ow_acquire_bus()
661 while (sc->owner != NULL) in ow_acquire_bus()
662 mtx_sleep(sc, &sc->mtx, 0, "owbuswait", 0); in ow_acquire_bus()
664 sc->owner = pdev; in ow_acquire_bus()
678 if (sc->owner == NULL) in ow_release_bus()
681 if (sc->owner != pdev) in ow_release_bus()
684 device_get_nameunit(sc->owner)); in ow_release_bus()
685 sc->owner = NULL; in ow_release_bus()