Lines Matching +full:slave +full:- +full:kernel
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright (c) 2017-2018 Panasas
34 #include <sys/kernel.h>
61 static int imcsmb_readb(device_t dev, u_char slave, char cmd, char *byte);
62 static int imcsmb_readw(device_t dev, u_char slave, char cmd, short *word);
63 static int imcsmb_writeb(device_t dev, u_char slave, char cmd, char byte);
64 static int imcsmb_writew(device_t dev, u_char slave, char cmd, short word);
67 static int imcsmb_transfer(device_t dev, u_char slave, char cmd, void *data,
73 * which any SMBus slave device drivers will connect to.
88 sc->dev = dev; in imcsmb_attach()
89 sc->imcsmb_pci = device_get_parent(dev); in imcsmb_attach()
90 sc->regs = device_get_ivars(dev); in imcsmb_attach()
93 sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY); in imcsmb_attach()
94 if (sc->smbus == NULL) { in imcsmb_attach()
182 rc = imcsmb_pci_request_bus(sc->imcsmb_pci); in imcsmb_callback()
186 imcsmb_pci_release_bus(sc->imcsmb_pci); in imcsmb_callback()
205 * @param[in] slave
216 imcsmb_readb(device_t dev, u_char slave, char cmd, char *byte) in imcsmb_readb() argument
219 return (imcsmb_transfer(dev, slave, cmd, byte, FALSE, FALSE)); in imcsmb_readb()
229 * @param[in] slave
240 imcsmb_readw(device_t dev, u_char slave, char cmd, short *word) in imcsmb_readw() argument
243 return (imcsmb_transfer(dev, slave, cmd, word, TRUE, FALSE)); in imcsmb_readw()
253 * @param[in] slave
264 imcsmb_writeb(device_t dev, u_char slave, char cmd, char byte) in imcsmb_writeb() argument
267 return (imcsmb_transfer(dev, slave, cmd, &byte, FALSE, TRUE)); in imcsmb_writeb()
277 * @param[in] slave
288 imcsmb_writew(device_t dev, u_char slave, char cmd, short word) in imcsmb_writew() argument
291 return (imcsmb_transfer(dev, slave, cmd, &word, TRUE, TRUE)); in imcsmb_writew()
302 * @param[in] slave
320 imcsmb_transfer(device_t dev, u_char slave, char cmd, void *data, int word_op, in imcsmb_transfer() argument
344 orig_cntl_val = pci_read_config(sc->imcsmb_pci, in imcsmb_transfer()
345 sc->regs->smb_cntl, 4); in imcsmb_transfer()
353 * the four high bits of the slave address. in imcsmb_transfer()
356 cntl_val |= ((uint32_t) slave & 0xf0) << 24; in imcsmb_transfer()
388 /* [26:24] The three non-DTI, non-R/W bits of the slave address. */ in imcsmb_transfer()
389 cmd_val |= (uint32_t) ((slave & 0xe) << 23); in imcsmb_transfer()
407 * the temperature sensors are I2C. Thus, byte-swap the in imcsmb_transfer()
423 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cntl, cntl_val, 4); in imcsmb_transfer()
426 * We just cleared the auto-poll bit, so we need to make sure the device in imcsmb_transfer()
430 for (i = 4; i != 0; i--) { in imcsmb_transfer()
431 stat_val = pci_read_config(sc->imcsmb_pci, sc->regs->smb_stat, in imcsmb_transfer()
440 device_printf(sc->dev, in imcsmb_transfer()
447 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cmd, cmd_val, 4); in imcsmb_transfer()
452 for (i = 35000; i != 0; i -= 10) in imcsmb_transfer()
455 stat_val = pci_read_config(sc->imcsmb_pci, sc->regs->smb_stat, in imcsmb_transfer()
481 /* It is generally the case that this bit indicates non-ACK, but it in imcsmb_transfer()
486 /* While it is not documented, empirically, SPD page-change in imcsmb_transfer()
490 if ((slave & 0xf0) != 0x60) { in imcsmb_transfer()
500 * above, byte-swap. in imcsmb_transfer()
517 pci_write_config(sc->imcsmb_pci, sc->regs->smb_cntl, orig_cntl_val, 4); in imcsmb_transfer()