How do I alloc multiple memory regions specified in a device tree?

Lee D embaudarm at gmail.com
Sun Dec 17 23:04:40 UTC 2017


On Sun, Dec 17, 2017 at 3:19 PM, Ian Lepore <ian at freebsd.org> wrote:
> On Sun, 2017-12-17 at 15:00 -0500, Lee D wrote:
>> Hi everyone.
>>
>> I have a device driver that must access registers in multiple memory
>> ranges.  How do I pull those values out of the device tree?
>>
>> bus_alloc_resource_any() works, but only for the first memory range.
>> The second time I call it, it crashes the kernel.
>>
>
> The 'rid' argument is the zero-based index of the register range you
> want to allocate.  Just increment rid from 0 through the number of
> offset/length tuples in the fdt regs property.
>
> You can allocate all the ranges at once with bus_alloc_resources().
> For an example, see the a10fb_spec array in arm/allwinner/a10_fb.c
>
> -- Ian
>

Thank you, I see it was staring me in the face the whole time.
Setting rid to the tuple index did the trick.

Also thanks for the info on bus_alloc_resources().

Lee


More information about the freebsd-hackers mailing list