Lines Matching +full:cmd +full:- +full:timeout +full:- +full:ms

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2017-2018 Panasas
60 static int imcsmb_readb(device_t dev, u_char slave, char cmd, char *byte);
61 static int imcsmb_readw(device_t dev, u_char slave, char cmd, short *word);
62 static int imcsmb_writeb(device_t dev, u_char slave, char cmd, char byte);
63 static int imcsmb_writew(device_t dev, u_char slave, char cmd, short word);
66 static int imcsmb_transfer(device_t dev, u_char slave, char cmd, void *data,
87 sc->dev = dev;
88 sc->imcsmb_pci = device_get_parent(dev);
89 sc->regs = device_get_ivars(dev);
92 sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY);
93 if (sc->smbus == NULL) {
157 rc = imcsmb_pci_request_bus(sc->imcsmb_pci);
161 imcsmb_pci_release_bus(sc->imcsmb_pci);
183 * @param[in] cmd
191 imcsmb_readb(device_t dev, u_char slave, char cmd, char *byte)
194 return (imcsmb_transfer(dev, slave, cmd, byte, FALSE, FALSE));
207 * @param[in] cmd
215 imcsmb_readw(device_t dev, u_char slave, char cmd, short *word)
218 return (imcsmb_transfer(dev, slave, cmd, word, TRUE, FALSE));
231 * @param[in] cmd
239 imcsmb_writeb(device_t dev, u_char slave, char cmd, char byte)
242 return (imcsmb_transfer(dev, slave, cmd, &byte, FALSE, TRUE));
255 * @param[in] cmd
263 imcsmb_writew(device_t dev, u_char slave, char cmd, short word)
266 return (imcsmb_transfer(dev, slave, cmd, &word, TRUE, TRUE));
280 * @param[in] cmd
295 imcsmb_transfer(device_t dev, u_char slave, char cmd, void *data, int word_op,
319 orig_cntl_val = pci_read_config(sc->imcsmb_pci,
320 sc->regs->smb_cntl, 4);
363 /* [26:24] The three non-DTI, non-R/W bits of the slave address. */
369 cmd_val |= (uint32_t) ((uint8_t) cmd << 16);
382 * the temperature sensors are I2C. Thus, byte-swap the
398 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cntl, cntl_val, 4);
400 /* Poll on the BUSY bit in the status register until clear, or timeout.
401 * We just cleared the auto-poll bit, so we need to make sure the device
402 * is idle before issuing a command. We can safely timeout after 35 ms,
405 for (i = 4; i != 0; i--) {
406 stat_val = pci_read_config(sc->imcsmb_pci, sc->regs->smb_stat,
415 device_printf(sc->dev,
416 "transfer: timeout waiting for device to settle\n");
422 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cmd, cmd_val, 4);
424 /* Wait for WRITE_DATA_DONE/READ_DATA_VALID to be set, or timeout and
425 * fail. We wait up to 35ms.
427 for (i = 35000; i != 0; i -= 10)
430 stat_val = pci_read_config(sc->imcsmb_pci, sc->regs->smb_stat,
452 device_printf(dev, "transfer timeout\n");
456 /* It is generally the case that this bit indicates non-ACK, but it
461 /* While it is not documented, empirically, SPD page-change
475 * above, byte-swap.
492 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cntl, orig_cntl_val, 4);