Lines Matching +full:read +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()
124 device_printf(sc->ipmi_dev, in kcs_error()
139 /* Read error status */ in kcs_error()
142 device_printf(sc->ipmi_dev, "KCS error: %02x\n", in kcs_error()
145 /* Write READ into Data_in */ in kcs_error()
162 device_printf(sc->ipmi_dev, "KCS: Error retry exhausted\n"); in kcs_error()
193 DELAY(1000000); in kcs_start_write()
260 * Read one byte of the reply message.
270 /* Read State */ in kcs_read_byte()
278 /* Read Data_out */ in kcs_read_byte()
281 /* Write READ into Data_in */ in kcs_read_byte()
294 /* Read Dummy */ 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()
378 /* Read the reply. First, read the NetFn/LUN. */ 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()
391 /* Next we read the command. */ 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()
404 /* Next we read the completion code. */ 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()
408 "KCS: Failed to read completion code\n"); 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()
417 /* Finally, read the reply from the BMC. */ in kcs_polled_request()
422 device_printf(sc->ipmi_dev, in kcs_polled_request()
423 "KCS: Read failed on byte %d\n", i + 1); 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()
435 "KCS: Read short %02x byte %d\n", data, i + 1); 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()
449 "KCS: Read short: %zd buffer, %d actual\n", 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()
560 * any unused bytes will return 0x00 when read. We make use of the C/D bit
562 * we write the command, that bit should be set, so we should get a non-zero
563 * value back when we read CTL_STS if the offset we are testing is the CTL_STS
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()
580 DELAY(100); 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()
619 DELAY(100); in ipmi_kcs_probe_align()
626 DELAY(100); in ipmi_kcs_probe_align()
630 /* Read error status. */ in ipmi_kcs_probe_align()
633 /* Write dummy READ to DATA_IN. */ in ipmi_kcs_probe_align()
639 DELAY(100); 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()