On Fri, Apr 08, 2016 at 03:29:05PM +0300, Artturi Alm wrote:
> On Fri, Apr 08, 2016 at 01:44:11PM +0200, Patrick Wildt wrote:
> > Hi,
> >
> > with the feedback received on the fdt bus, the fdt stuff will now be
> > replacing the mainbus. [..snip..]
> >
> > Patrick
> >
> > [..snip..]
>
> Hi,
>
> have you planned ahead which route you are going to take with regards to
> how drivers will be written in the future? i see two options, do it all
> in some kind of mainbus(per soc?) and feed driver _attach() args(i'd prefer),
> or infest all of the drivers with fdt node lookups and linux/fbsd-like
> code/logic.
>
> i think it's a design question that all of you should agree upon as early as
> possible to avoid cruft. as a result of my own incompetence i have rewritten
> each and every armv7 driver xxx_match() a few times. ;D
>
> -Artturi
>
The idea is that all drivers attach to mainbus. The driver checks its
mainbus_attach_args in the match function, if the given node is
compatible to the driver, by doing something simple like:
if (fdt_node_compatible(ma->ma_node, "samsung,exynos4210-ehci"))
return (1);
When it attaches, it's given a node, a bus space and bus dma tag. This
is all it needs to do its job. I hope that soon we can have some
FDT-based API to attach interrupts:
arm_intr_establish_fdt(ma->ma_node, IPL_NET, handler, sc,
sc->sc_dev.dv_xname);
Similarly, we should have something for Clocks and GPIOs. Those are all
exposed in the device tree which we can make plenty use of.
There are a few drivers that need special handling. EHCI and AHCI need
an attachment driver, as ehci* at mainbus? can only be handled by one
driver. So you need something like.
imxehci* at mainbus?
ehci* at imxehci?
That's a bit of an overhead and steals about 16 lines in
imxehci.c/imxahci.c.
You don't anymore need an imx0, exynos0 or sunxi0 bus. Those can all be
replaced by the mainbus.
Patrick