On Fri, Apr 17, 2009 at 11:21 PM, Eddie Dawydiuk <ed...@embeddedarm.com> wrote: > Hello, > > In the past I've worked with ARM architectures where I could setup virtual / > physical address mappings so I don't have to ioremap then pass around > pointers. Does PowerPC have an equivalent abstraction? If not whats the > recommended approach? > > That is, is there a better approach to the following... > > volatile static unsigned char *my_reg = NULL; > > static inline void read_func() { > > if (!my_reg) > my_reg = (unsigned char *) > ioremap(REG_PHYS_BASE, REG_SIZE); > //do something with the reg > } > > > static inline void write_func() { > > if (!my_reg) > my_reg = (unsigned char *) > ioremap(REG_PHYS_BASE, REG_SIZE); > //do something with the reg > } > > -- > Best Regards, > ________________________________________________________________ > Eddie Dawydiuk, Technologic Systems | voice: (480) 837-5200 > 16525 East Laser Drive | fax: (480) 837-5300 > Fountain Hills, AZ 85268 | web: www.embeddedARM.com > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev >
In general you set devices up a dts file. You can reach its contents using openfirmware functions (of_*). In general you use an of_* function to look up your periperhal in the device tree. Once you have its node you would able to do e.g. of_iomap (which uses ioremap with the right offsets behind its back) to map the device. So you don't hard code physical addresses anymore in the code. Regards, Roderick Colenbrander _______________________________________________ Linuxppc-dev mailing list Linuxppc-dev@ozlabs.org https://ozlabs.org/mailman/listinfo/linuxppc-dev