From owner-svn-src-all@freebsd.org Thu Jun 20 09:23:04 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1CDC115B3A00; Thu, 20 Jun 2019 09:23:04 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B4FA67253C; Thu, 20 Jun 2019 09:23:03 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8860D9FC1; Thu, 20 Jun 2019 09:23:03 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x5K9N3Zf059010; Thu, 20 Jun 2019 09:23:03 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x5K9N30q059009; Thu, 20 Jun 2019 09:23:03 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201906200923.x5K9N30q059009@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 20 Jun 2019 09:23:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r349227 - stable/11/sys/dev/drm2/i915 X-SVN-Group: stable-11 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/11/sys/dev/drm2/i915 X-SVN-Commit-Revision: 349227 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B4FA67253C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_SHORT(-0.98)[-0.975,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jun 2019 09:23:04 -0000 Author: avg Date: Thu Jun 20 09:23:03 2019 New Revision: 349227 URL: https://svnweb.freebsd.org/changeset/base/349227 Log: drm2/intel_iic: stop using iicbus_set_nostop The desired mode of transmitting messages is implemented by subclassing iicbb driver and overriding its iicbus_transfer method with an almost identical copy that issues the stop condition only at the very end. iicbus_set_nostop is very broken and is set to be removed from the KPI. This is a direct commit as in head the drm drivers have been moved out of the tree. The same change has been committed to FreeBSDDesktop/drm-legacy. Modified: stable/11/sys/dev/drm2/i915/intel_iic.c Modified: stable/11/sys/dev/drm2/i915/intel_iic.c ============================================================================== --- stable/11/sys/dev/drm2/i915/intel_iic.c Thu Jun 20 07:50:38 2019 (r349226) +++ stable/11/sys/dev/drm2/i915/intel_iic.c Thu Jun 20 09:23:03 2019 (r349227) @@ -562,12 +562,11 @@ intel_iicbb_attach(device_t idev) sc->bus = &dev_priv->gmbus[pin]; /* add generic bit-banging code */ - sc->iic_dev = device_add_child(idev, "iicbb", -1); + sc->iic_dev = device_add_child(idev, "iicbb_nostop", -1); if (sc->iic_dev == NULL) return (ENXIO); device_quiet(sc->iic_dev); bus_generic_attach(idev); - iicbus_set_nostop(idev, true); return (0); } @@ -608,8 +607,84 @@ static driver_t intel_iicbb_driver = { static devclass_t intel_iicbb_devclass; DRIVER_MODULE_ORDERED(intel_iicbb, drmn, intel_iicbb_driver, intel_iicbb_devclass, 0, 0, SI_ORDER_FIRST); -DRIVER_MODULE(iicbb, intel_iicbb, iicbb_driver, iicbb_devclass, 0, 0); +/* + * XXX This is a copy of struct iicbb_softc in sys/dev/iicbus/iicbb.c. + * There should really be a shared definition. + */ +struct iicbb_softc { + device_t iicbus; + int udelay; /* signal toggle delay in usec */ +}; + +static int +iicbb_nostop_transfer_impl(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) +{ + int i, error, lenread, lenwrote, addr; + struct iicbb_softc *sc; + device_t bus; + bool started; + + sc = device_get_softc(dev); + bus = sc->iicbus; + started = false; + for (i = 0, error = 0; i < nmsgs && error == 0; i++) { + addr = msgs[i].slave; + if (msgs[i].flags & IIC_M_RD) + addr |= LSB; + else + addr &= ~LSB; + + if ((msgs[i].flags & IIC_M_NOSTART) == 0) { + if (i == 0) + error = iicbus_start(bus, addr, 0); + else + error = iicbus_repeated_start(bus, addr, 0); + if (error != 0) + break; + started = true; + } + + if ((msgs[i].flags & IIC_M_RD) != 0) + error = iicbus_read(bus, msgs[i].buf, msgs[i].len, + &lenread, IIC_LAST_READ, 0); + else + error = iicbus_write(bus, msgs[i].buf, msgs[i].len, + &lenwrote, 0); + } + if (started) + iicbus_stop(bus); + return (error); +} + +static int +iicbb_nostop_transfer(device_t dev, struct iic_msg *msgs, uint32_t nmsgs) +{ + int error; + + error = IICBB_PRE_XFER(device_get_parent(dev)); + if (error) + return (error); + + error = iicbb_nostop_transfer_impl(dev, msgs, nmsgs); + + IICBB_POST_XFER(device_get_parent(dev)); + return (error); +} + +static device_method_t iicbb_nostop_methods[] = { + DEVMETHOD(iicbus_transfer, iicbb_nostop_transfer), + + DEVMETHOD_END +}; + +static devclass_t iicbb_nostop_devclass; + +DEFINE_CLASS_1(iicbb_nostop, iicbb_nostop_driver, iicbb_nostop_methods, + sizeof(struct iicbb_softc), iicbb_driver); +DRIVER_MODULE(iicbb_nostop, intel_iicbb, iicbb_nostop_driver, + iicbb_nostop_devclass, NULL, NULL); + /** * intel_gmbus_setup - instantiate all Intel i2c GMBuses * @dev: DRM device @@ -672,7 +747,7 @@ int intel_setup_gmbus(struct drm_device *dev) /* bbbus */ iic_dev = device_find_child(bus->bbbus_bridge, - "iicbb", -1); + "iicbb_nostop", -1); if (iic_dev == NULL) { DRM_ERROR("bbbus bridge doesn't have iicbb child\n"); goto err;