prom_parse.c 883 B

1234567891011121314151617181920212223242526272829303132333435
  1. #undef DEBUG
  2. #include <linux/kernel.h>
  3. #include <linux/string.h>
  4. #include <linux/ioport.h>
  5. #include <linux/etherdevice.h>
  6. #include <linux/of_address.h>
  7. #include <asm/prom.h>
  8. void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
  9. unsigned long *busno, unsigned long *phys, unsigned long *size)
  10. {
  11. const u32 *dma_window;
  12. u32 cells;
  13. const unsigned char *prop;
  14. dma_window = dma_window_prop;
  15. /* busno is always one cell */
  16. *busno = *(dma_window++);
  17. prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
  18. if (!prop)
  19. prop = of_get_property(dn, "#address-cells", NULL);
  20. cells = prop ? *(u32 *)prop : of_n_addr_cells(dn);
  21. *phys = of_read_number(dma_window, cells);
  22. dma_window += cells;
  23. prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
  24. cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
  25. *size = of_read_number(dma_window, cells);
  26. }