From owner-freebsd-current@freebsd.org Mon Dec 10 17:00:47 2018 Return-Path: Delivered-To: freebsd-current@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 F1403132C920 for ; Mon, 10 Dec 2018 17:00:46 +0000 (UTC) (envelope-from Scoobi_doo@yahoo.com) Received: from sonic310-21.consmr.mail.gq1.yahoo.com (sonic310-21.consmr.mail.gq1.yahoo.com [98.137.69.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 212E98312E for ; Mon, 10 Dec 2018 17:00:46 +0000 (UTC) (envelope-from Scoobi_doo@yahoo.com) X-YMail-OSG: 9Z3qJYoVM1k8gyJFMSEYhKcOUuGJ.L59oUie.Gqr9RFYc2fSBfRpxejc9yHsfdS sWjRO4tOH389f5gQfDLYskvxIAJC7MKg6yNb.IZkQpTOdM9iFzbb_U5UHc45ooHTtHbc8a4d9Ndk K7yrNisnGe4jcVmmlSw.f8p13aF.hX4GAS2f63UFjiWBF8E87Y_DVdB2pmsE6qe3xBooD2ZM_Cjo W09ixcPcXzIc81mHU_tsqT18fT.QCC_AzmKZOzoJ9kgyeAK_8j2aQwqEHfcrjtyP13ahOnIff1Bq MwiCT93rYZAP.jhoUCftKho6YpcemOzj03UbAOLZIYScZKBmyQ4p6wcHQ2XxLS8f0qCRxThJhTaT EFSkS9hY1i_dXKO_iGErP3YhY7Ozcf.mE22TM91PEjVbd.PwK5TU_.qwvqo_jLMEIeTSoZXznsyw qR4iNlPSB9vJjyxR3mlpkiZU3wWdB8voOANVQfE6RlLUTQIUUQsgVvHShh7XE6a.wEIGwpq0BD6m oFqimAj6EwS5bbskTjKt9nj_pA7HKysQj7Q7bHhcHrQo5tiy1tsbidd.260XmzP_SfLWXoxkD3Fz Fxt4UlzPd.1pu8Tt8Stpa25zCdUxKRzROHKTAx578J2f7I3wf25XhXJ95yNAEr8xYwJwWyhfgWv7 xa5MFNipsv1j4bqqW1DfjSxIVotyax4KaGBnINdfcivDGYvQ2vNQ719k6RN3oLAW1VhVBrGVIR29 QAZMPUtjQ418jvI6Y8Ftok3lAh11V7T79UvPtKzeI_WHjuABJ9gpZilcNFPNRFA.pu3t.hYj9p5y Sp8fqvU.gBrDDqoj.5rzYAkipc3GWZ6N4.isbByoLq0m1WJznB753zLp9OCtG7K4tuTJMBDnEgVf 8O14RT94LKEt0YsnTsCQMdLYJDYL.j3sHhLxdqLqD1EghsB45tkMatH898afQ3k2QZcLBPQiFTHX 9qjbN8mWwgBYRQCohjzQBoKZVJyoN4uwm_UZJs9.W2IG_PbuuldX1.uNC96nL7RxxmH3N.HwjQ1r .OIENpPjbJLB1c.cUGoyq1RKy2fM0KGSm6FxwjctLQ7P2.VD66Qkxtrk0NjlSHceUOM6RFWBbzsS 71HA- Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.gq1.yahoo.com with HTTP; Mon, 10 Dec 2018 17:00:44 +0000 Received: from 172.58.7.39 (EHLO [192.168.43.50]) ([172.58.7.39]) by smtp420.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 76f063b7b0548c327f7d821f94144d7c; Mon, 10 Dec 2018 17:00:43 +0000 (UTC) To: FreeBSD CURRENT From: Anthony Jenkins Subject: Composite PCI devices in FreeBSD (mfd in Linux) Cc: Gleb Popov <6yearold@gmail.com> Message-ID: Date: Mon, 10 Dec 2018 12:00:40 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Rspamd-Queue-Id: 212E98312E X-Spamd-Result: default: False [-3.02 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[yahoo.com]; NEURAL_HAM_MEDIUM(-0.59)[-0.588,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; FREEMAIL_FROM(0.00)[yahoo.com]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.32)[ip: (0.47), ipnet: 98.137.64.0/21(0.68), asn: 36647(0.54), country: US(-0.09)]; NEURAL_HAM_LONG(-0.94)[-0.936,0]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yahoo.com:+]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; RCVD_IN_DNSWL_NONE(0.00)[147.69.137.98.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.81)[-0.807,0]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/21, country:US]; FREEMAIL_CC(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Dec 2018 17:00:47 -0000 Hi all, I'm trying to port an Intel PCI I2C controller from Linux to FreeBSD.  Linux represents this device as an MFD (multi-function device), meaning it has these "sub-devices" that can be handed off to other drivers to actually attach devices to the system.  The Linux "super" PCI device is the intel-lpss-pci.c, and the "sub" device is i2c-designware-platdrv.c, which represents the DesignWare driver's "platform" attachment to the Linux system.  FreeBSD also has a DesignWare I2C controller driver, ig4(4), but it only has PCI and ACPI bus attachment implementations. I have a port of the Linux intel-lpss driver to FreeBSD, but now I'm trying to figure out the best way to give FreeBSD's ig4(4) driver access to my lpss(4) device.  I'm thinking I could add an ig4_lpss.c describing the "attachment" of an ig4(4) to an lpss(4).  Its probe() method would scan the "lpss" devclass for devices, and its attach() method would attach itself as a child to the lpss device and "grab" the portion of PCI memory and the IRQ that the lpss PCI device got. Is this the "FreeBSD Way (TM)" of handling this type of device?  If not, can you recommend an existing FreeBSD driver I can model my code after? If my approach is acceptable, how do I fully describe the ig4(4) device's attachment to the system?  Is simply making it a child of lpss(4) sufficient?  It's "kind of" a PCI device (it is controlled via access to a PCI memory region and an IRQ), but it's a sub-device of an actual PCI device (lpss(4)) attached to PCI. How would my ig4_lpss attachment get information from the lpss(4) driver about what it probed? Thanks, Anthony Jenkins References:  - intel-lpss.c - https://github.com/torvalds/linux/blob/master/drivers/mfd/intel-lpss.c  - intel-lpss-pci.c - https://github.com/torvalds/linux/blob/master/drivers/mfd/intel-lpss-pci.c  - i2c-designware-platdrv.c - https://github.com/torvalds/linux/blob/master/drivers/i2c/busses/i2c-designware-platdrv.c  - "mfd: introduce a driver for LPSS devices on SPT" - https://lwn.net/Articles/645819/  - FreeBSD port - https://github.com/ScoobiFreeBSD/freebsd-intel-lpss