From owner-freebsd-hackers@freebsd.org Sun Feb 25 17:57:19 2018 Return-Path: Delivered-To: freebsd-hackers@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 7ACF7F0655B for ; Sun, 25 Feb 2018 17:57:19 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from pmta2.delivery6.ore.mailhop.org (pmta2.delivery6.ore.mailhop.org [54.200.129.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 039396971D for ; Sun, 25 Feb 2018 17:57:18 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 38329ce8-1a55-11e8-b951-f99fef315fd9 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound2.ore.mailhop.org (Halon) with ESMTPSA id 38329ce8-1a55-11e8-b951-f99fef315fd9; Sun, 25 Feb 2018 17:56:35 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w1PHvA62072887; Sun, 25 Feb 2018 10:57:10 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1519581430.91697.258.camel@freebsd.org> Subject: Re: Help, please, with getting a custom I2C real time clock module to load From: Ian Lepore To: gljennjohn@gmail.com, Lee D Cc: freebsd-hackers@freebsd.org Date: Sun, 25 Feb 2018 10:57:10 -0700 In-Reply-To: <20180225184220.748e9d59@ernst.home> References: <20180225184220.748e9d59@ernst.home> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Feb 2018 17:57:19 -0000 On Sun, 2018-02-25 at 18:42 +0100, Gary Jennejohn wrote: > On Sun, 25 Feb 2018 09:48:58 -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); > > > This should give you a clue: > > grep DRIVER_MODULE /sys/dev/iicbus/iic.c > DRIVER_MODULE(iic, iicbus, iic_driver, iic_devclass, 0, 0); > Nope, not applicable.  Lee's problem was due to not getting ofw_iicbus connected to his new host controller driver so that the children of iicbus would get enumerated.  iic.c is not an i2c host controller whose child is an iicbus, it is itself a child of iicbus. The real problem is that until last week it was impossible for an FDT- based host controller driver to have the proper DRIVER_MODULE() statement because some extern declarations were missing, and the way existing drivers had been working around that was to set their name to "iichb". -- Ian > grep DRIVER_MODULE /sys/dev/iicbus/rtc8583.c > DRIVER_MODULE(rtc8583, iicbus, rtc8583_driver, rtc8583_devclass, NULL, NULL); > > [snip] >