Lines Matching +full:smbus +full:- +full:timeout +full:- +full:disable

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2017-2018 Panasas
49 #include <dev/smbus/smbconf.h>
58 /* SMBus methods */
71 * parent imcsmb_pci's registers that we will use. Create the smbus(4) device,
72 * which any SMBus slave device drivers will connect to.
87 sc->dev = dev; in imcsmb_attach()
88 sc->imcsmb_pci = device_get_parent(dev); in imcsmb_attach()
89 sc->regs = device_get_ivars(dev); in imcsmb_attach()
91 /* Create the smbus child */ in imcsmb_attach()
92 sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY); in imcsmb_attach()
93 if (sc->smbus == NULL) { in imcsmb_attach()
95 device_printf(dev, "Child smbus not added\n"); in imcsmb_attach()
100 /* Attach the smbus child. */ in imcsmb_attach()
121 device_set_desc(dev, "iMC SMBus controller"); in imcsmb_probe()
127 * function to quiesce / restart firmware tasks which might use the SMBus.
138 * Tell's the rest of the SMBus subsystem to allow or disallow waiting;
157 rc = imcsmb_pci_request_bus(sc->imcsmb_pci); in imcsmb_callback()
161 imcsmb_pci_release_bus(sc->imcsmb_pci); in imcsmb_callback()
181 * The SMBus address of the target device.
184 * The SMBus command for the target device; this is the offset for SPDs,
205 * The SMBus address of the target device.
208 * The SMBus command for the target device; this is the offset for SPDs,
229 * The SMBus address of the target device.
232 * The SMBus command for the target device; this is the offset for SPDs,
253 * The SMBus address of the target device.
256 * The SMBus command for the target device; this is the offset for SPDs,
271 * SMBus controller.
278 * The SMBus address of the target device.
281 * The SMBus command for the target device; this is the offset for SPDs,
319 orig_cntl_val = pci_read_config(sc->imcsmb_pci, in imcsmb_transfer()
320 sc->regs->smb_cntl, 4); in imcsmb_transfer()
363 /* [26:24] The three non-DTI, non-R/W bits of the slave address. */ in imcsmb_transfer()
375 * endianness for word operations on I2C vs SMBus! in imcsmb_transfer()
382 * the temperature sensors are I2C. Thus, byte-swap the in imcsmb_transfer()
395 /* Write the updated value to the control register first, to disable in imcsmb_transfer()
398 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cntl, cntl_val, 4); in imcsmb_transfer()
400 /* Poll on the BUSY bit in the status register until clear, or timeout. in imcsmb_transfer()
401 * We just cleared the auto-poll bit, so we need to make sure the device in imcsmb_transfer()
402 * is idle before issuing a command. We can safely timeout after 35 ms, in imcsmb_transfer()
403 * as this is the maximum time the SMBus spec allows for a transaction. in imcsmb_transfer()
405 for (i = 4; i != 0; i--) { in imcsmb_transfer()
406 stat_val = pci_read_config(sc->imcsmb_pci, sc->regs->smb_stat, in imcsmb_transfer()
415 device_printf(sc->dev, in imcsmb_transfer()
416 "transfer: timeout waiting for device to settle\n"); in imcsmb_transfer()
420 * starts the SMBus command. in imcsmb_transfer()
422 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cmd, cmd_val, 4); in imcsmb_transfer()
424 /* Wait for WRITE_DATA_DONE/READ_DATA_VALID to be set, or timeout and in imcsmb_transfer()
427 for (i = 35000; i != 0; i -= 10) in imcsmb_transfer()
430 stat_val = pci_read_config(sc->imcsmb_pci, sc->regs->smb_stat, in imcsmb_transfer()
452 device_printf(dev, "transfer timeout\n"); in imcsmb_transfer()
456 /* It is generally the case that this bit indicates non-ACK, but it in imcsmb_transfer()
461 /* While it is not documented, empirically, SPD page-change in imcsmb_transfer()
475 * above, byte-swap. in imcsmb_transfer()
492 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cntl, orig_cntl_val, 4); in imcsmb_transfer()
503 /* smbus methods */
520 MODULE_DEPEND(imcsmb, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER);
523 DRIVER_MODULE(smbus, imcsmb, smbus_driver, 0, 0);