Lines Matching +full:wait +full:- +full:delay

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
49 #define POLLING_DELAY_MIN 4 /* Waits are 2-3 usecs on typical systems */
64 while (ticks - start < MAX_TIMEOUT && (status & mask) != value) { in kcs_wait()
66 * The wait delay is increased exponentially to avoid putting in kcs_wait()
69 DELAY(delay_usec); in kcs_wait()
109 /* Wait for IBF = 0 */ in kcs_error()
115 /* Wait for IBF = 0 */ in kcs_error()
124 device_printf(sc->ipmi_dev, in kcs_error()
131 /* Wait for IBF = 0 */ in kcs_error()
136 /* Wait for OBF = 1 */ in kcs_error()
142 device_printf(sc->ipmi_dev, "KCS error: %02x\n", in kcs_error()
148 /* Wait for IBF = 0 */ in kcs_error()
154 /* Wait for OBF = 1 */ in kcs_error()
162 device_printf(sc->ipmi_dev, "KCS: Error retry exhausted\n"); in kcs_error()
175 /* Wait for IBF = 0 */ in kcs_start_write()
186 /* Wait for IBF = 0 */ in kcs_start_write()
193 DELAY(1000000); in kcs_start_write()
218 /* Wait for IBF = 0 */ in kcs_write_byte()
242 /* Wait for IBF = 0 */ in kcs_write_last_byte()
267 /* Wait for IBF = 0 */ in kcs_read_byte()
273 /* Wait for OBF = 1 */ in kcs_read_byte()
289 /* Wait for OBF = 1*/ in kcs_read_byte()
317 device_printf(sc->ipmi_dev, "KCS: Failed to start write\n"); in kcs_polled_request()
321 device_printf(sc->ipmi_dev, "KCS: WRITE_START... ok\n"); in kcs_polled_request()
324 if (!kcs_write_byte(sc, req->ir_addr)) { in kcs_polled_request()
325 device_printf(sc->ipmi_dev, "KCS: Failed to write address\n"); in kcs_polled_request()
329 device_printf(sc->ipmi_dev, "KCS: Wrote address: %02x\n", req->ir_addr); in kcs_polled_request()
332 if (req->ir_requestlen == 0) { in kcs_polled_request()
333 if (!kcs_write_last_byte(sc, req->ir_command)) { in kcs_polled_request()
334 device_printf(sc->ipmi_dev, in kcs_polled_request()
339 device_printf(sc->ipmi_dev, "KCS: Wrote command: %02x\n", in kcs_polled_request()
340 req->ir_command); in kcs_polled_request()
343 if (!kcs_write_byte(sc, req->ir_command)) { in kcs_polled_request()
344 device_printf(sc->ipmi_dev, in kcs_polled_request()
349 device_printf(sc->ipmi_dev, "KCS: Wrote command: %02x\n", in kcs_polled_request()
350 req->ir_command); in kcs_polled_request()
353 cp = req->ir_request; in kcs_polled_request()
354 for (i = 0; i < req->ir_requestlen - 1; i++) { in kcs_polled_request()
356 device_printf(sc->ipmi_dev, in kcs_polled_request()
362 device_printf(sc->ipmi_dev, "KCS: Wrote data: %02x\n", in kcs_polled_request()
363 cp[-1]); in kcs_polled_request()
368 device_printf(sc->ipmi_dev, in kcs_polled_request()
373 device_printf(sc->ipmi_dev, "KCS: Wrote last data: %02x\n", in kcs_polled_request()
380 device_printf(sc->ipmi_dev, "KCS: Failed to read address\n"); in kcs_polled_request()
384 device_printf(sc->ipmi_dev, "KCS: Read address: %02x\n", data); in kcs_polled_request()
386 if (data != IPMI_REPLY_ADDR(req->ir_addr)) { in kcs_polled_request()
387 device_printf(sc->ipmi_dev, "KCS: Reply address mismatch\n"); in kcs_polled_request()
393 device_printf(sc->ipmi_dev, "KCS: Failed to read command\n"); in kcs_polled_request()
397 device_printf(sc->ipmi_dev, "KCS: Read command: %02x\n", data); in kcs_polled_request()
399 if (data != req->ir_command) { in kcs_polled_request()
400 device_printf(sc->ipmi_dev, "KCS: Command mismatch\n"); in kcs_polled_request()
405 if (kcs_read_byte(sc, &req->ir_compcode) != 1) { in kcs_polled_request()
407 device_printf(sc->ipmi_dev, in kcs_polled_request()
413 device_printf(sc->ipmi_dev, "KCS: Read completion code: %02x\n", in kcs_polled_request()
414 req->ir_compcode); in kcs_polled_request()
422 device_printf(sc->ipmi_dev, in kcs_polled_request()
428 if (i < req->ir_replybuflen) { in kcs_polled_request()
429 req->ir_reply[i] = data; in kcs_polled_request()
431 device_printf(sc->ipmi_dev, "KCS: Read data %02x\n", in kcs_polled_request()
434 device_printf(sc->ipmi_dev, in kcs_polled_request()
441 req->ir_replylen = i; in kcs_polled_request()
443 device_printf(sc->ipmi_dev, "KCS: READ finished (%d bytes)\n", i); in kcs_polled_request()
444 if (req->ir_replybuflen < i) in kcs_polled_request()
446 if (req->ir_replybuflen < i && req->ir_replybuflen != 0) in kcs_polled_request()
448 device_printf(sc->ipmi_dev, in kcs_polled_request()
450 req->ir_replybuflen, i); in kcs_polled_request()
472 req->ir_error = 0; in kcs_loop()
474 req->ir_error = EIO; in kcs_loop()
486 return (kproc_create(kcs_loop, sc, &sc->ipmi_kthread, 0, 0, "%s: kcs", in kcs_startup()
487 device_get_nameunit(sc->ipmi_dev))); in kcs_startup()
497 error = msleep(req, &sc->ipmi_requests_lock, 0, "ipmireq", 0); in kcs_driver_request_queue()
499 error = req->ir_error; in kcs_driver_request_queue()
513 req->ir_error = 0; in kcs_driver_request_poll()
515 req->ir_error = EIO; in kcs_driver_request_poll()
516 return (req->ir_error); in kcs_driver_request_poll()
536 sc->ipmi_startup = kcs_startup; in ipmi_kcs_attach()
537 sc->ipmi_enqueue_request = ipmi_polled_enqueue_request; in ipmi_kcs_attach()
538 sc->ipmi_driver_request = kcs_driver_request; in ipmi_kcs_attach()
539 sc->ipmi_driver_requests_polled = 1; in ipmi_kcs_attach()
544 device_printf(sc->ipmi_dev, "couldn't find it\n"); in ipmi_kcs_attach()
549 device_printf(sc->ipmi_dev, "KCS: initial state: %02x\n", status); in ipmi_kcs_attach()
562 * we write the command, that bit should be set, so we should get a non-zero
571 sc->ipmi_io_spacing = 1; in ipmi_kcs_probe_align()
574 device_printf(sc->ipmi_dev, "Trying KCS align %d... ", sc->ipmi_io_spacing); in ipmi_kcs_probe_align()
577 /* Wait for IBF = 0 */ in ipmi_kcs_probe_align()
580 DELAY(100); in ipmi_kcs_probe_align()
586 /* Wait for IBF = 0 */ in ipmi_kcs_probe_align()
589 DELAY(100); in ipmi_kcs_probe_align()
598 sc->ipmi_io_spacing <<= 1; in ipmi_kcs_probe_align()
599 if (sc->ipmi_io_spacing > 4) in ipmi_kcs_probe_align()
616 /* Wait for IBF = 0 */ in ipmi_kcs_probe_align()
619 DELAY(100); in ipmi_kcs_probe_align()
624 /* Wait for IBF = 1 */ in ipmi_kcs_probe_align()
626 DELAY(100); in ipmi_kcs_probe_align()
636 /* Wait for IBF = 0 */ in ipmi_kcs_probe_align()
639 DELAY(100); in ipmi_kcs_probe_align()
645 /* Wait for IBF = 1 */ in ipmi_kcs_probe_align()
647 DELAY(100); in ipmi_kcs_probe_align()
655 device_printf(sc->ipmi_dev, "KCS probe: end state %x\n", in ipmi_kcs_probe_align()