Index: sys/dev/iicbus/iicoc.c =================================================================== --- sys/dev/iicbus/iicoc.c +++ sys/dev/iicbus/iicoc.c @@ -147,8 +147,9 @@ return ((value & OC_CONTROL_EN) == 0); } -int -iicoc_iicbus_start(device_t dev, u_char slave, int timeout) +/* Perform either a start or repeated start. */ +static int +iicoc_iicbus_start_common(device_t dev, u_char slave, int timeout, bool repeat) { int error = IIC_EBUSERR; struct iicoc_softc *sc; @@ -158,7 +159,7 @@ sc->i2cdev_addr = (slave >> 1); /* Verify the bus is idle */ - if (iicoc_wait_on_status(dev, OC_STATUS_BUSY) < 0) + if (!repeat && iicoc_wait_on_status(dev, OC_STATUS_BUSY) < 0) goto i2c_stx_error; /* Write Slave Address */ @@ -186,6 +187,18 @@ return (error); } +int +iicoc_iicbus_start(device_t dev, u_char slave, int timeout) +{ + return (iicoc_iicbus_start_common(dev, slave, timeout, false)); +} + +int +iicoc_iicbus_repeated_start(device_t dev, u_char slave, int timeout) +{ + return (iicoc_iicbus_start_common(dev, slave, timeout, true)); +} + int iicoc_iicbus_stop(device_t dev) { @@ -268,10 +281,3 @@ mtx_unlock(&sc->sc_mtx); return (error); } - -int -iicoc_iicbus_repeated_start(device_t dev, u_char slave, int timeout) -{ - - return 0; -} Index: sys/dev/iicbus/iicoc_fdt.c =================================================================== --- sys/dev/iicbus/iicoc_fdt.c +++ sys/dev/iicbus/iicoc_fdt.c @@ -55,6 +55,9 @@ static struct ofw_compat_data compat_data[] = { { "opencores,i2c-ocores", 1 }, + { "sifive,fu740-c000-i2c", 1 }, + { "sifive,fu540-c000-i2c", 1 }, + { "sifive,i2c0", 1 }, { NULL, 0 } }; @@ -182,6 +185,7 @@ sizeof(struct iicoc_softc), }; +SIMPLEBUS_PNP_INFO(compat_data); DRIVER_MODULE(iicoc, simplebus, iicoc_driver, iicoc_devclass, 0, 0); DRIVER_MODULE(ofw_iicbus, iicoc, ofw_iicbus_driver, ofw_iicbus_devclass, 0, 0); MODULE_DEPEND(iicoc, iicbus, 1, 1, 1); Index: sys/modules/i2c/controllers/Makefile =================================================================== --- sys/modules/i2c/controllers/Makefile +++ sys/modules/i2c/controllers/Makefile @@ -5,5 +5,8 @@ .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" SUBDIR += imcsmb .endif +.if ${MACHINE_CPUARCH} == "riscv" +SUBDIR += iicoc +.endif .include Index: sys/modules/i2c/controllers/iicoc/Makefile =================================================================== --- /dev/null +++ sys/modules/i2c/controllers/iicoc/Makefile @@ -0,0 +1,7 @@ +.PATH: ${SRCTOP}/sys/dev/iicbus + +KMOD = iicoc +SRCS = device_if.h bus_if.h iicbus_if.h \ + iicoc.c iicoc_fdt.c iicoc_pci.c + +.include