[ORLinux] Linux device access
Stefan Kristiansson
stefan.kristiansson at saunalahti.fi
Mon Jul 4 15:07:14 CEST 2011
On 4.7.2011 7:22, Jonas Bonn wrote:
> On Sun, 2011-07-03 at 23:39 +0300, Stefan Kristiansson wrote:
>> Is there any particular reason for not using the wishbone wrappers instead of having the ifdefs in
>> the driver code?
>> I guess it's a matter of taste and I'm fine with having them in the drivers code, but I kind of liked the
>> wishbone wrappers approach better.
>>
>
> The problem, as I see it, is that the hardware isn't necessarily
> wishbone-only. I could be wrong (in particular for the ethmac case),
> but I believe there are #ifdefs in the RTL that allow you to put the
> device on an Avalon bus. Using wishbone-specific accessors in the
> driver wouldn't really be right for people using the driver on other
> buses...
>
Those ifdefs are just for some internal workaround for people creating an avalon<->wishbone wrapper.
The external interface of the core is still wishbone.
> If we do a wrapper, we still end up with:
>
> #ifdef CONFIG_WISHBONE_BUS
> wb_ioread32(...)
> #else
> ioread32(...)
> #endif
>
> ...so if we need to do an #ifdef anyway in order to specify the bus,
> then we might as well just do it for endianess.
>
> There is one other solution and that's to embed information about the
> device endianess into the __iomem cookie returned by ioremap.
> Unfortunately, doing that changes the semantics of ioread32 and also
> makes it less of a lightweight instruction than it is today.
>
> There's still an argument for putting some kind of wrapper back into
> io.h, but at this point in time, I'm not quite sure how to do it.
> Suggestions welcome.
>
I don't have any concrete suggestions at the moment,
so I'd say having the ifdefs in the drivers is good enough for the time being.
Stefan
More information about the Linux
mailing list