On Thu, Apr 07, 2016 at 06:00:25PM +0200, Mark Kettenis wrote: > > Date: Thu, 7 Apr 2016 16:54:19 +0200 > > From: Patrick Wildt <patr...@blueri.se> > > > > Hi, > > > > after a bit of talking with jsg@ we have found a way forward on how to > > integrate FDT into ARM. > > > > An aspect of this is having an MI FDT bus residing in sys/dev/ofw/, > > where the fdt subroutines currently already are. Then we'll convert > > the vexpress platform to use FDT and continue with Exynos later on. > > > > As a first step I would rename fdt.c to fdt_subr.c. The actual fdt bus > > will then be committed to fdt.c. Also, create sys/dev/ofw/files.fdt to > > later on declare the new fdt bus in there. > > > > As we'll soon declare fdt at mainbus, I think we should also move the > > include of files.fdt to be after mainbus on socppc. Even if it won't > > be used on socppc. > > > > ok? > > I have no objections to rename fdt.c fdt_subr.c. However, I do object > against having an "fdt" bus, at least for socppc. The fdt code should
I don't propose an fdt bus for socppc. > just be the enumeration mechanism for "mainbus". And I think armv7 > should be the same. That sounds more like implementing the fdtbus functionality, but just call it mainbus. The current situation is that we have a mainbus0 on arm that attaches anything that wants to be attached. It's not really the mainbus you expect it to be. What is does is attach cpu0 at mainbus0 and depending on the SoC an obio0 at mainbus0, pxaip0 at mainbus0, or imx0 at mainbus0, exynos0 at mainbus0 and so on. These are the actual busses that create their own bus space and bus dma tag and pass it to the controller driver instance. mainbus0 does (not yet) do anything in that regard. This also means all drivers are ... imxuart0 at imx0, not at mainbus0. Looks like: mainbus0 at root cpu0 at mainbus0 cortex0 at mainbus0 ampintc0 at mainbus0 imx0 at mainbus0 imxuart0 at imx0 imxiic0 at imx0 ehci0 at imx0 Goal was: mainbus0 at root cpu0 at mainbus0 ampintc0 at fdt0 imxuart0 at fdt0 So the idea was to replace imx0, exynos0, vexpress0, etc. on ARMv7 with an fdt0 that does all that what e. g. imx0 used to do, just with FDT only. Attaching controllers from FDT is not just going through the tree and attaching all nodes that are there. You have to take care of interrupt- controller hierarchy and clocks. Those need to be attached first. This adds a bit of complexity and should probably not be duplicated for a new arch (arm64 for instance). Which is why we thought it would be nice to have that in sys/dev/ofw/. I could though completely replace mainbus.c with the fdtbus, call it mainbus, implement it for armv7 only, and fall back to the old version for the legacy platforms armish, zaurus and non-fdt armv7. Is that the way to go? > > It should be relatively easy to add an ma_node member to the arm > struct mainbus_attach_args and use the fdt to attach the right drivers > if it is present and fall back on mainbussearch() if the fdt > information is not available yet (or if a particular platform has not > been converted yet). You just have to make mainbussearch() set > ma_node to -1 (or some other magic value) and check for that in the > existing "platform" drivers, > > I think that implies that we don't need sys/dev/ofw/files.fdt either. > > Cheers, > > Mark > > > diff --git sys/arch/armv7/conf/files.armv7 sys/arch/armv7/conf/files.armv7 > > index c5d022c..fc0a14f 100644 > > --- sys/arch/armv7/conf/files.armv7 > > +++ sys/arch/armv7/conf/files.armv7 > > @@ -10,7 +10,8 @@ major {rd = 18} > > > > define fdt {} > > file arch/armv7/fdt/fdt_machdep.c fdt needs-flag > > -file dev/ofw/fdt.c > > + > > +include "dev/ofw/files.fdt" > > > > file arch/arm/arm/conf.c > > > > diff --git sys/arch/socppc/conf/files.socppc > > sys/arch/socppc/conf/files.socppc > > index 4aa9526..3d02ddb 100644 > > --- sys/arch/socppc/conf/files.socppc > > +++ sys/arch/socppc/conf/files.socppc > > @@ -14,10 +14,8 @@ file arch/socppc/socppc/disksubr.c > > disk > > file arch/socppc/socppc/machdep.c > > file arch/socppc/socppc/mem.c > > file dev/cninit.c > > -file dev/ofw/fdt.c > > file arch/socppc/socppc/n1200_dts.S > > > > - > > define mainbus {} > > device mainbus > > attach mainbus at root > > @@ -27,6 +25,8 @@ device cpu > > attach cpu at mainbus > > file arch/socppc/socppc/cpu.c > > > > +include "dev/ofw/files.fdt" > > + > > # MPC8349E on-board devices > > device obio {[addr = 0], [ivec = -1], [phy = -1]} > > attach obio at mainbus > > diff --git sys/dev/ofw/fdt.c sys/dev/ofw/fdt_subr.c > > similarity index 100% > > rename from sys/dev/ofw/fdt.c > > rename to sys/dev/ofw/fdt_subr.c > > diff --git sys/dev/ofw/files.fdt sys/dev/ofw/files.fdt > > new file mode 100644 > > index 0000000..0ff8192 > > --- /dev/null > > +++ sys/dev/ofw/files.fdt > > @@ -0,0 +1,3 @@ > > +# $OpenBSD$ > > + > > +file dev/ofw/fdt_subr.c > > > > >