All of lore.kernel.org
 help / color / mirror / Atom feed
* how to best ioremap() the ranges part of a "simple-bus" device?
@ 2018-07-31 14:24 rpjday at crashcourse.ca
  2018-08-01  7:59 ` Martin Kaiser
  0 siblings, 1 reply; 3+ messages in thread
From: rpjday at crashcourse.ca @ 2018-07-31 14:24 UTC (permalink / raw)
  To: kernelnewbies


   another (i suspect) fairly simple question, i've just never had the occasion
to mess around in this part of the code.

   if i have a device tree source file containing the snippet:

         slave0: slave0-fubar at 90000000 {
                 compatible = "simple-bus";
                 ranges = <0x0 0x90000000 0x10000000>;
                 #address-cells = <1>;
                 #size-cells = <1>;
         };

         slave1: slave1-fubar at a0000000 {
                 compatible = "simple-bus";
                 ranges = <0x0 0xa0000000 0x10000000>;
                 #address-cells = <1>;
                 #size-cells = <1>;
         };

those two ranges actually represent physical addresses within
an FPGA and, when certain events occur, i want some driver code to
read/write some registers in slave0's address space, so obviously
i'll need to access that device tree entry and effectively ioremap()
slave0's physical address to a usable virtual address.

   is there a canonical way to do this? short of manually extracting
the appropriate device tree node and reading that property and calling
ioremap()? is there a wrapper for that sort of operation, which i
imagine must be fairly common?

   oh, and a pointer to a good example in the current kernel source
would, of course, be useful.

rday

^ permalink raw reply	[flat|nested] 3+ messages in thread

* how to best ioremap() the ranges part of a "simple-bus" device?
  2018-07-31 14:24 how to best ioremap() the ranges part of a "simple-bus" device? rpjday at crashcourse.ca
@ 2018-08-01  7:59 ` Martin Kaiser
  2018-08-01  8:34   ` Martin Kaiser
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Kaiser @ 2018-08-01  7:59 UTC (permalink / raw)
  To: kernelnewbies

Thus wrote rpjday at crashcourse.ca (rpjday at crashcourse.ca):


> i'll need to access that device tree entry and effectively ioremap()
> slave0's physical address to a usable virtual address.

>   is there a canonical way to do this? short of manually extracting
> the appropriate device tree node and reading that property and calling
> ioremap()? is there a wrapper for that sort of operation, which i
> imagine must be fairly common?

I guess that of_iomap() does what you need here.

>   oh, and a pointer to a good example in the current kernel source
> would, of course, be useful.

cm_init() in arch/arm/mach-integrator/core.c searches a dt node and does
maps its address space. If you search for of_iomap() in the sources,
you'll find plenty of other examples.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* how to best ioremap() the ranges part of a "simple-bus" device?
  2018-08-01  7:59 ` Martin Kaiser
@ 2018-08-01  8:34   ` Martin Kaiser
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Kaiser @ 2018-08-01  8:34 UTC (permalink / raw)
  To: kernelnewbies

Thus wrote Martin Kaiser (lists at kaiser.cx):

> Thus wrote rpjday at crashcourse.ca (rpjday at crashcourse.ca):


> > i'll need to access that device tree entry and effectively ioremap()
> > slave0's physical address to a usable virtual address.

> >   is there a canonical way to do this? short of manually extracting
> > the appropriate device tree node and reading that property and calling
> > ioremap()? is there a wrapper for that sort of operation, which i
> > imagine must be fairly common?

> I guess that of_iomap() does what you need here.

Oh, I missed your point. You were asking specifically about ranges,
of_remap() searches for a reg property.

I'm not aware of any generic function to parse ranges. All I found was
of_pci_range_to_resource() which is specific to PCI...

You could search the dt files for "ranges =", find the corresponding
drivers and see how they parse the info.

Sorry for the noise,
Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-01  8:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 14:24 how to best ioremap() the ranges part of a "simple-bus" device? rpjday at crashcourse.ca
2018-08-01  7:59 ` Martin Kaiser
2018-08-01  8:34   ` Martin Kaiser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.