Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 Dec 2017 18:03:58 -0500
From:      Lee D <embaudarm@gmail.com>
To:        Ian Lepore <ian@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How do I alloc multiple memory regions specified in a device tree?
Message-ID:  <CANC_bnPez8c8txrnAWV2ONR1_E=AnaLYQq6_VjpRysczRfcUgw@mail.gmail.com>
In-Reply-To: <1513541989.95072.36.camel@freebsd.org>
References:  <CANC_bnMjPzSKM0q1__or=cTrvoxnM_LXo-avFYgbUZVeZPT9wg@mail.gmail.com> <1513541989.95072.36.camel@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Dec 17, 2017 at 3:19 PM, Ian Lepore <ian@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANC_bnPez8c8txrnAWV2ONR1_E=AnaLYQq6_VjpRysczRfcUgw>