Date: Sun, 25 Feb 2018 10:23:07 -0700 From: Ian Lepore <ian@freebsd.org> To: Lee D <embaudarm@gmail.com>, freebsd-hackers@freebsd.org Subject: Re: Help, please, with getting a custom I2C real time clock module to load Message-ID: <1519579387.91697.252.camel@freebsd.org> In-Reply-To: <CANC_bnOe1-%2BBQocKfNraJuq4UjbYe=ita=0qsy65EVMdhGQDLQ@mail.gmail.com> References: <CANC_bnOe1-%2BBQocKfNraJuq4UjbYe=ita=0qsy65EVMdhGQDLQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 2018-02-25 at 09:48 -0500, Lee D wrote: > Hi Everyone, > > I have written a new I2C driver (for the Xilinx Zynq) and a new real > time clock chip driver (for the ST M41T82) to use with hardware on my > custom board. This is for 11.0.1. > > The I2C driver works fine, but I can't seem to get my RTC driver to > load. The m41t82_probe() function is never even called. > > Both are loaded with kldload at the moment. > > I think the problem is something in DRIVER_MODULE macro that is > preventing the kernel from even trying to let it probe. One clue is > that if I change "iicbus" to "simplebus" in the DRIVER_MODULE macro > of the RTC, it will then at least call m41t82_probe(). > > It's like the kernel thinks that I have no iicbus driver and thus > won't even try to load the RTC module. > > I have turned on "device iic" and "device iicbus" in my kernel config > file. > > No messages are given when I try to load the m41t82 module. It just > silently loads and does nothing. > > Here is a code snippet from my I2C driver: > ------------------------------------------ > > static driver_t i2c_driver = { > "i2c", > i2c_methods, > sizeof(struct i2c_softc), > }; > static devclass_t i2c_devclass; > > DRIVER_MODULE(iicbus, i2c, iicbus_driver, iicbus_devclass, 0, 0); > DRIVER_MODULE(i2c, simplebus, i2c_driver, i2c_devclass, 0, 0); > Right here is where the disconnect is happening. It's the ofw_iicbus driver that needs to declared in the first DRIVER_MODULE() instead of iicbus, because ofw_iicbus is the one that knows to look in the fdt data for slave devices and add them as children of the bus. But, the extern declarations needed to do that didn't exist until I added them last week in r329526. What i2c drivers have been doing in the past, and the way to work around it in the 11.x code you're dealing with, is to leverage one of the DRIVER_MODULE() declarations that already exists in ofw_iicbus, by naming your driver "iichb" instead of "i2c". Like this: static driver_t i2c_driver = { "iichb", i2c_methods, sizeof(struct i2c_softc), }; Or you could import r329526 into the kernel source you're using and rebuild the kernel. I do intend to MFC that change to 11-stable (in fact, I should probably do that today). When you've got these new drivers working, please consider putting them up for review at https://reviews.freebsd.org and we'll get them committed to freebsd. -- Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1519579387.91697.252.camel>