prom_parse.c 909 B

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