2 * Copyright (c) 2014 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * Intel 4th generation mobile cpus integrated I2C device, smbus driver.
37 * See ig4_reg.h for datasheet reference and notes.
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/kernel.h>
43 #include <sys/module.h>
44 #include <sys/errno.h>
46 #include <sys/mutex.h>
47 #include <sys/syslog.h>
49 #include <sys/sysctl.h>
53 #include <bus/pci/pcivar.h>
54 #include <bus/pci/pcireg.h>
55 #include <bus/smbus/smbconf.h>
62 #define TRANS_NORMAL 1
66 static void ig4iic_intr(void *cookie);
67 static void ig4iic_dump(ig4iic_softc_t *sc);
70 SYSCTL_INT(_debug, OID_AUTO, ig4_dump, CTLTYPE_INT | CTLFLAG_RW,
74 * Low-level inline support functions
78 reg_write(ig4iic_softc_t *sc, uint32_t reg, uint32_t value)
80 bus_space_write_4(sc->regs_t, sc->regs_h, reg, value);
81 bus_space_barrier(sc->regs_t, sc->regs_h, reg, 4,
82 BUS_SPACE_BARRIER_WRITE);
87 reg_read(ig4iic_softc_t *sc, uint32_t reg)
91 bus_space_barrier(sc->regs_t, sc->regs_h, reg, 4,
92 BUS_SPACE_BARRIER_READ);
93 value = bus_space_read_4(sc->regs_t, sc->regs_h, reg);
98 * Enable or disable the controller and wait for the controller to acknowledge
103 set_controller(ig4iic_softc_t *sc, uint32_t ctl)
109 reg_write(sc, IG4_REG_I2C_EN, ctl);
110 error = SMB_ETIMEOUT;
112 for (retry = 100; retry > 0; --retry) {
113 v = reg_read(sc, IG4_REG_ENABLE_STATUS);
114 if (((v ^ ctl) & IG4_I2C_ENABLE) == 0) {
118 tsleep(sc, 0, "i2cslv", 1);
124 * Wait up to 25ms for the requested status using a 25uS polling loop.
128 wait_status(ig4iic_softc_t *sc, uint32_t status)
136 error = SMB_ETIMEOUT;
137 count = sys_cputimer->count();
138 limit = sys_cputimer->freq / 40;
140 while (sys_cputimer->count() - count <= limit) {
142 * Check requested status
144 v = reg_read(sc, IG4_REG_I2C_STA);
151 * Shim RX_NOTEMPTY of the data was read by the
154 if (status & IG4_STATUS_RX_NOTEMPTY) {
155 if (sc->rpos != sc->rnext) {
162 * Shim TX_EMPTY by resetting the retry timer if we
163 * see a change in the transmit fifo level.
165 if (status & IG4_STATUS_TX_EMPTY) {
166 v = reg_read(sc, IG4_REG_TXFLR) & IG4_FIFOLVL_MASK;
169 count = sys_cputimer->count();
174 * The interrupt will wake us up if we are waiting for
175 * read data, otherwise poll.
177 if (status & IG4_STATUS_RX_NOTEMPTY) {
178 lksleep(sc, &sc->lk, 0, "i2cwait", (hz + 99) / 100);
187 * Read I2C data. The data might have already been read by
188 * the interrupt code, otherwise it is sitting in the data
193 data_read(ig4iic_softc_t *sc)
197 if (sc->rpos == sc->rnext) {
198 c = (uint8_t)reg_read(sc, IG4_REG_DATA_CMD);
200 c = sc->rbuf[sc->rpos & IG4_RBUFMASK];
207 * Set the slave address. The controller must be disabled when
208 * changing the address.
210 * This operation does not issue anything to the I2C bus but sets
211 * the target address for when the controller later issues a START.
215 set_slave_addr(ig4iic_softc_t *sc, uint8_t slave, int trans_op)
221 use_10bit = sc->use_10bit;
222 if (trans_op & SMB_TRANS_7BIT)
224 if (trans_op & SMB_TRANS_10BIT)
227 if (sc->slave_valid && sc->last_slave == slave &&
228 sc->use_10bit == use_10bit) {
231 sc->use_10bit = use_10bit;
234 * Wait for TXFIFO to drain before disabling the controller.
236 * If a write message has not been completed it's really a
237 * programming error, but for now in that case issue an extra
240 * If a read message has not been completed it's also a programming
241 * error, for now just ignore it.
243 wait_status(sc, IG4_STATUS_TX_NOTFULL);
244 if (sc->write_started) {
245 reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_STOP);
246 sc->write_started = 0;
248 if (sc->read_started)
249 sc->read_started = 0;
250 wait_status(sc, IG4_STATUS_TX_EMPTY);
252 set_controller(sc, 0);
253 ctl = reg_read(sc, IG4_REG_CTL);
254 ctl &= ~IG4_CTL_10BIT;
255 ctl |= IG4_CTL_RESTARTEN;
259 tar |= IG4_TAR_10BIT;
260 ctl |= IG4_CTL_10BIT;
262 reg_write(sc, IG4_REG_CTL, ctl);
263 reg_write(sc, IG4_REG_TAR_ADD, tar);
264 set_controller(sc, IG4_I2C_ENABLE);
266 sc->last_slave = slave;
270 * Issue START with byte command, possible count, and a variable length
271 * read or write buffer, then possible turn-around read. The read also
272 * has a possible count received.
276 * Quick: START+ADDR+RD/WR STOP
278 * Normal: START+ADDR+WR CMD DATA..DATA STOP
281 * RESTART+ADDR RDATA..RDATA STOP
282 * (can also be used for I2C transactions)
284 * Process Call: START+ADDR+WR CMD DATAL DATAH
285 * RESTART+ADDR+RD RDATAL RDATAH STOP
287 * Block: START+ADDR+RD CMD
288 * RESTART+ADDR+RD RCOUNT DATA... STOP
291 * RESTART+ADDR+WR WCOUNT DATA... STOP
293 * For I2C - basically, no *COUNT fields, possibly no *CMD field. If the
294 * sender needs to issue a 2-byte command it will incorporate it
295 * into the write buffer and also set NOCMD.
297 * Generally speaking, the START+ADDR / RESTART+ADDR is handled automatically
298 * by the controller at the beginning of a command sequence or on a data
299 * direction turn-around, and we only need to tell it when to issue the STOP.
302 smb_transaction(ig4iic_softc_t *sc, char cmd, int op,
303 char *wbuf, int wcount, char *rbuf, int rcount, int *actualp)
310 * Debugging - dump registers
313 unit = device_get_unit(sc->dev);
314 if (ig4_dump & (1 << unit)) {
315 ig4_dump &= ~(1 << unit);
321 * Issue START or RESTART with next data byte, clear any previous
322 * abort condition that may have been holding the txfifo in reset.
324 last = IG4_DATA_RESTART;
325 reg_read(sc, IG4_REG_CLR_TX_ABORT);
330 * Issue command if not told otherwise (smbus).
332 if ((op & SMB_TRANS_NOCMD) == 0) {
333 error = wait_status(sc, IG4_STATUS_TX_NOTFULL);
337 if (wcount == 0 && rcount == 0 && (op & SMB_TRANS_NOSTOP) == 0)
338 last |= IG4_DATA_STOP;
339 reg_write(sc, IG4_REG_DATA_CMD, last);
344 * Clean out any previously received data.
346 if (sc->rpos != sc->rnext &&
347 (op & SMB_TRANS_NOREPORT) == 0) {
348 device_printf(sc->dev,
349 "discarding %d bytes of spurious data\n",
350 sc->rnext - sc->rpos);
356 * If writing and not told otherwise, issue the write count (smbus).
358 if (wcount && (op & SMB_TRANS_NOCNT) == 0) {
359 error = wait_status(sc, IG4_STATUS_TX_NOTFULL);
363 reg_write(sc, IG4_REG_DATA_CMD, last);
371 error = wait_status(sc, IG4_STATUS_TX_NOTFULL);
374 last |= (u_char)*wbuf;
375 if (wcount == 1 && rcount == 0 && (op & SMB_TRANS_NOSTOP) == 0)
376 last |= IG4_DATA_STOP;
377 reg_write(sc, IG4_REG_DATA_CMD, last);
384 * Issue reads to xmit FIFO (strange, I know) to tell the controller
385 * to clock in data. At the moment just issue one read ahead to
386 * pipeline the incoming data.
388 * NOTE: In the case of NOCMD and wcount == 0 we still issue a
389 * RESTART here, even if the data direction has not changed
390 * from the previous CHAINing call. This we force the RESTART.
391 * (A new START is issued automatically by the controller in
392 * the other nominal cases such as a data direction change or
393 * a previous STOP was issued).
395 * If this will be the last byte read we must also issue the STOP
396 * at the end of the read.
399 last = IG4_DATA_RESTART | IG4_DATA_COMMAND_RD;
401 (op & (SMB_TRANS_NOSTOP | SMB_TRANS_NOCNT)) ==
403 last |= IG4_DATA_STOP;
405 reg_write(sc, IG4_REG_DATA_CMD, last);
406 last = IG4_DATA_COMMAND_RD;
410 * Bulk read (i2c) and count field handling (smbus)
414 * Maintain a pipeline by queueing the allowance for the next
415 * read before waiting for the current read.
418 if (op & SMB_TRANS_NOCNT)
419 last = (rcount == 2) ? IG4_DATA_STOP : 0;
422 reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_COMMAND_RD |
425 error = wait_status(sc, IG4_STATUS_RX_NOTEMPTY);
427 if ((op & SMB_TRANS_NOREPORT) == 0) {
428 device_printf(sc->dev,
429 "rx timeout addr 0x%02x\n",
434 last = data_read(sc);
436 if (op & SMB_TRANS_NOCNT) {
437 *rbuf = (u_char)last;
444 * Handle count field (smbus), which is not part of
445 * the rcount'ed buffer. The first read data in a
446 * bulk transfer is the count.
448 * XXX if rcount is loaded as 0 how do I generate a
449 * STOP now without issuing another RD or WR?
451 if (rcount > (u_char)last)
452 rcount = (u_char)last;
453 op |= SMB_TRANS_NOCNT;
458 /* XXX wait for xmit buffer to become empty */
459 last = reg_read(sc, IG4_REG_TX_ABRT_SOURCE);
465 * SMBUS API FUNCTIONS
467 * Called from ig4iic_pci_attach/detach()
470 ig4iic_attach(ig4iic_softc_t *sc)
475 lockmgr(&sc->lk, LK_EXCLUSIVE);
477 v = reg_read(sc, IG4_REG_COMP_TYPE);
478 kprintf("type %08x", v);
479 v = reg_read(sc, IG4_REG_COMP_PARAM1);
480 kprintf(" params %08x", v);
481 v = reg_read(sc, IG4_REG_GENERAL);
482 kprintf(" general %08x", v);
483 if ((v & IG4_GENERAL_SWMODE) == 0) {
484 v |= IG4_GENERAL_SWMODE;
485 reg_write(sc, IG4_REG_GENERAL, v);
486 v = reg_read(sc, IG4_REG_GENERAL);
487 kprintf(" (updated %08x)", v);
490 v = reg_read(sc, IG4_REG_SW_LTR_VALUE);
491 kprintf(" swltr %08x", v);
492 v = reg_read(sc, IG4_REG_AUTO_LTR_VALUE);
493 kprintf(" autoltr %08x", v);
495 v = reg_read(sc, IG4_REG_COMP_VER);
496 kprintf(" version %08x\n", v);
497 if (v != IG4_COMP_VER) {
502 v = reg_read(sc, IG4_REG_SS_SCL_HCNT);
503 kprintf("SS_SCL_HCNT=%08x", v);
504 v = reg_read(sc, IG4_REG_SS_SCL_LCNT);
505 kprintf(" LCNT=%08x", v);
506 v = reg_read(sc, IG4_REG_FS_SCL_HCNT);
507 kprintf(" FS_SCL_HCNT=%08x", v);
508 v = reg_read(sc, IG4_REG_FS_SCL_LCNT);
509 kprintf(" LCNT=%08x\n", v);
510 v = reg_read(sc, IG4_REG_SDA_HOLD);
511 kprintf("HOLD %08x\n", v);
513 v = reg_read(sc, IG4_REG_SS_SCL_HCNT);
514 reg_write(sc, IG4_REG_FS_SCL_HCNT, v);
515 v = reg_read(sc, IG4_REG_SS_SCL_LCNT);
516 reg_write(sc, IG4_REG_FS_SCL_LCNT, v);
519 * Program based on a 25000 Hz clock. This is a bit of a
520 * hack (obviously). The defaults are 400 and 470 for standard
521 * and 60 and 130 for fast. The defaults for standard fail
522 * utterly (presumably cause an abort) because the clock time
523 * is ~18.8ms by default. This brings it down to ~4ms (for now).
525 reg_write(sc, IG4_REG_SS_SCL_HCNT, 100);
526 reg_write(sc, IG4_REG_SS_SCL_LCNT, 125);
527 reg_write(sc, IG4_REG_FS_SCL_HCNT, 100);
528 reg_write(sc, IG4_REG_FS_SCL_LCNT, 125);
531 * Use a threshold of 1 so we get interrupted on each character,
532 * allowing us to use lksleep() in our poll code. Not perfect
533 * but this is better than using DELAY() for receiving data.
535 reg_write(sc, IG4_REG_RX_TL, 1);
537 reg_write(sc, IG4_REG_CTL,
539 IG4_CTL_SLAVE_DISABLE |
543 sc->smb = device_add_child(sc->dev, "smbus", -1);
544 if (sc->smb == NULL) {
545 device_printf(sc->dev, "smbus driver not found\n");
552 * Don't do this, it blows up the PCI config
554 reg_write(sc, IG4_REG_RESETS, IG4_RESETS_ASSERT);
555 reg_write(sc, IG4_REG_RESETS, IG4_RESETS_DEASSERT);
559 * Interrupt on STOP detect or receive character ready
561 reg_write(sc, IG4_REG_INTR_MASK, IG4_INTR_STOP_DET |
563 if (set_controller(sc, 0))
564 device_printf(sc->dev, "controller error during attach-1\n");
565 if (set_controller(sc, IG4_I2C_ENABLE))
566 device_printf(sc->dev, "controller error during attach-2\n");
567 error = bus_setup_intr(sc->dev, sc->intr_res, 0,
568 ig4iic_intr, sc, &sc->intr_handle, NULL);
570 device_printf(sc->dev,
571 "Unable to setup irq: error %d\n", error);
575 /* Attach us to the smbus */
576 lockmgr(&sc->lk, LK_RELEASE);
577 error = bus_generic_attach(sc->dev);
578 lockmgr(&sc->lk, LK_EXCLUSIVE);
580 device_printf(sc->dev,
581 "failed to attach child: error %d\n", error);
584 sc->generic_attached = 1;
587 lockmgr(&sc->lk, LK_RELEASE);
592 ig4iic_detach(ig4iic_softc_t *sc)
596 lockmgr(&sc->lk, LK_EXCLUSIVE);
598 reg_write(sc, IG4_REG_INTR_MASK, 0);
599 reg_read(sc, IG4_REG_CLR_INTR);
600 set_controller(sc, 0);
602 if (sc->generic_attached) {
603 error = bus_generic_detach(sc->dev);
606 sc->generic_attached = 0;
609 device_delete_child(sc->dev, sc->smb);
612 if (sc->intr_handle) {
613 bus_teardown_intr(sc->dev, sc->intr_res, sc->intr_handle);
614 sc->intr_handle = NULL;
619 lockmgr(&sc->lk, LK_RELEASE);
624 ig4iic_smb_callback(device_t dev, int index, void *data)
626 ig4iic_softc_t *sc = device_get_softc(dev);
629 lockmgr(&sc->lk, LK_EXCLUSIVE);
632 case SMB_REQUEST_BUS:
635 case SMB_RELEASE_BUS:
643 lockmgr(&sc->lk, LK_RELEASE);
649 * Quick command. i.e. START + cmd + R/W + STOP and no data. It is
650 * unclear to me how I could implement this with the intel i2c controller
651 * because the controler sends STARTs and STOPs automatically with data.
654 ig4iic_smb_quick(device_t dev, u_char slave, int how)
656 ig4iic_softc_t *sc = device_get_softc(dev);
659 lockmgr(&sc->lk, LK_EXCLUSIVE);
663 error = SMB_ENOTSUPP;
666 error = SMB_ENOTSUPP;
669 error = SMB_ENOTSUPP;
672 lockmgr(&sc->lk, LK_RELEASE);
678 * Incremental send byte without stop (?). It is unclear why the slave
679 * address is specified if this presumably is used in combination with
680 * ig4iic_smb_quick().
682 * (Also, how would this work anyway? Issue the last byte with writeb()?)
685 ig4iic_smb_sendb(device_t dev, u_char slave, char byte)
687 ig4iic_softc_t *sc = device_get_softc(dev);
691 lockmgr(&sc->lk, LK_EXCLUSIVE);
693 set_slave_addr(sc, slave, 0);
695 if (wait_status(sc, IG4_STATUS_TX_NOTFULL) == 0) {
696 reg_write(sc, IG4_REG_DATA_CMD, cmd);
699 error = SMB_ETIMEOUT;
702 lockmgr(&sc->lk, LK_RELEASE);
707 * Incremental receive byte without stop (?). It is unclear why the slave
708 * address is specified if this presumably is used in combination with
709 * ig4iic_smb_quick().
712 ig4iic_smb_recvb(device_t dev, u_char slave, char *byte)
714 ig4iic_softc_t *sc = device_get_softc(dev);
717 lockmgr(&sc->lk, LK_EXCLUSIVE);
719 set_slave_addr(sc, slave, 0);
720 reg_write(sc, IG4_REG_DATA_CMD, IG4_DATA_COMMAND_RD);
721 if (wait_status(sc, IG4_STATUS_RX_NOTEMPTY) == 0) {
722 *byte = data_read(sc);
726 error = SMB_ETIMEOUT;
729 lockmgr(&sc->lk, LK_RELEASE);
734 * Write command and single byte in transaction.
737 ig4iic_smb_writeb(device_t dev, u_char slave, char cmd, char byte)
739 ig4iic_softc_t *sc = device_get_softc(dev);
742 lockmgr(&sc->lk, LK_EXCLUSIVE);
744 set_slave_addr(sc, slave, 0);
745 error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT,
746 &byte, 1, NULL, 0, NULL);
748 lockmgr(&sc->lk, LK_RELEASE);
753 * Write command and single word in transaction.
756 ig4iic_smb_writew(device_t dev, u_char slave, char cmd, short word)
758 ig4iic_softc_t *sc = device_get_softc(dev);
762 lockmgr(&sc->lk, LK_EXCLUSIVE);
764 set_slave_addr(sc, slave, 0);
765 buf[0] = word & 0xFF;
767 error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT,
768 buf, 2, NULL, 0, NULL);
770 lockmgr(&sc->lk, LK_RELEASE);
775 * write command and read single byte in transaction.
778 ig4iic_smb_readb(device_t dev, u_char slave, char cmd, char *byte)
780 ig4iic_softc_t *sc = device_get_softc(dev);
783 lockmgr(&sc->lk, LK_EXCLUSIVE);
785 set_slave_addr(sc, slave, 0);
786 error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT,
787 NULL, 0, byte, 1, NULL);
789 lockmgr(&sc->lk, LK_RELEASE);
794 * write command and read word in transaction.
797 ig4iic_smb_readw(device_t dev, u_char slave, char cmd, short *word)
799 ig4iic_softc_t *sc = device_get_softc(dev);
803 lockmgr(&sc->lk, LK_EXCLUSIVE);
805 set_slave_addr(sc, slave, 0);
806 if ((error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT,
807 NULL, 0, buf, 2, NULL)) == 0) {
808 *word = (u_char)buf[0] | ((u_char)buf[1] << 8);
811 lockmgr(&sc->lk, LK_RELEASE);
816 * write command and word and read word in transaction
819 ig4iic_smb_pcall(device_t dev, u_char slave, char cmd,
820 short sdata, short *rdata)
822 ig4iic_softc_t *sc = device_get_softc(dev);
827 lockmgr(&sc->lk, LK_EXCLUSIVE);
829 set_slave_addr(sc, slave, 0);
830 wbuf[0] = sdata & 0xFF;
831 wbuf[1] = sdata >> 8;
832 if ((error = smb_transaction(sc, cmd, SMB_TRANS_NOCNT,
833 wbuf, 2, rbuf, 2, NULL)) == 0) {
834 *rdata = (u_char)rbuf[0] | ((u_char)rbuf[1] << 8);
837 lockmgr(&sc->lk, LK_RELEASE);
842 ig4iic_smb_bwrite(device_t dev, u_char slave, char cmd,
843 u_char wcount, char *buf)
845 ig4iic_softc_t *sc = device_get_softc(dev);
848 lockmgr(&sc->lk, LK_EXCLUSIVE);
850 set_slave_addr(sc, slave, 0);
851 error = smb_transaction(sc, cmd, 0,
852 buf, wcount, NULL, 0, NULL);
854 lockmgr(&sc->lk, LK_RELEASE);
859 ig4iic_smb_bread(device_t dev, u_char slave, char cmd,
860 u_char *countp_char, char *buf)
862 ig4iic_softc_t *sc = device_get_softc(dev);
863 int rcount = *countp_char;
866 lockmgr(&sc->lk, LK_EXCLUSIVE);
868 set_slave_addr(sc, slave, 0);
869 error = smb_transaction(sc, cmd, 0,
870 NULL, 0, buf, rcount, &rcount);
871 *countp_char = rcount;
873 lockmgr(&sc->lk, LK_RELEASE);
878 ig4iic_smb_trans(device_t dev, int slave, char cmd, int op,
879 char *wbuf, int wcount, char *rbuf, int rcount,
882 ig4iic_softc_t *sc = device_get_softc(dev);
885 lockmgr(&sc->lk, LK_EXCLUSIVE);
887 set_slave_addr(sc, slave, op);
888 error = smb_transaction(sc, cmd, op,
889 wbuf, wcount, rbuf, rcount, actualp);
891 lockmgr(&sc->lk, LK_RELEASE);
896 * Interrupt Operation
900 ig4iic_intr(void *cookie)
902 ig4iic_softc_t *sc = cookie;
905 lockmgr(&sc->lk, LK_EXCLUSIVE);
906 /* reg_write(sc, IG4_REG_INTR_MASK, IG4_INTR_STOP_DET);*/
907 status = reg_read(sc, IG4_REG_I2C_STA);
908 if (status & IG4_STATUS_RX_NOTEMPTY) {
909 sc->rbuf[sc->rnext & IG4_RBUFMASK] =
910 (uint8_t)reg_read(sc, IG4_REG_DATA_CMD);
913 reg_read(sc, IG4_REG_CLR_INTR);
915 lockmgr(&sc->lk, LK_RELEASE);
918 #define REGDUMP(sc, reg) \
919 device_printf(sc->dev, " %-23s %08x\n", #reg, reg_read(sc, reg))
923 ig4iic_dump(ig4iic_softc_t *sc)
925 device_printf(sc->dev, "ig4iic register dump:\n");
926 REGDUMP(sc, IG4_REG_CTL);
927 REGDUMP(sc, IG4_REG_TAR_ADD);
928 REGDUMP(sc, IG4_REG_SS_SCL_HCNT);
929 REGDUMP(sc, IG4_REG_SS_SCL_LCNT);
930 REGDUMP(sc, IG4_REG_FS_SCL_HCNT);
931 REGDUMP(sc, IG4_REG_FS_SCL_LCNT);
932 REGDUMP(sc, IG4_REG_INTR_STAT);
933 REGDUMP(sc, IG4_REG_INTR_MASK);
934 REGDUMP(sc, IG4_REG_RAW_INTR_STAT);
935 REGDUMP(sc, IG4_REG_RX_TL);
936 REGDUMP(sc, IG4_REG_TX_TL);
937 REGDUMP(sc, IG4_REG_I2C_EN);
938 REGDUMP(sc, IG4_REG_I2C_STA);
939 REGDUMP(sc, IG4_REG_TXFLR);
940 REGDUMP(sc, IG4_REG_RXFLR);
941 REGDUMP(sc, IG4_REG_SDA_HOLD);
942 REGDUMP(sc, IG4_REG_TX_ABRT_SOURCE);
943 REGDUMP(sc, IG4_REG_SLV_DATA_NACK);
944 REGDUMP(sc, IG4_REG_DMA_CTRL);
945 REGDUMP(sc, IG4_REG_DMA_TDLR);
946 REGDUMP(sc, IG4_REG_DMA_RDLR);
947 REGDUMP(sc, IG4_REG_SDA_SETUP);
948 REGDUMP(sc, IG4_REG_ENABLE_STATUS);
949 REGDUMP(sc, IG4_REG_COMP_PARAM1);
950 REGDUMP(sc, IG4_REG_COMP_VER);
951 REGDUMP(sc, IG4_REG_COMP_TYPE);
952 REGDUMP(sc, IG4_REG_CLK_PARMS);
953 REGDUMP(sc, IG4_REG_RESETS);
954 REGDUMP(sc, IG4_REG_GENERAL);
955 REGDUMP(sc, IG4_REG_SW_LTR_VALUE);
956 REGDUMP(sc, IG4_REG_AUTO_LTR_VALUE);
960 DRIVER_MODULE(smbus, ig4iic, smbus_driver, smbus_devclass, NULL, NULL);