prom_parse.c 874 B

123456789101112131415161718192021222324252627282930313233
  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 __be32 *dma_window,
  9. unsigned long *busno, unsigned long *phys,
  10. unsigned long *size)
  11. {
  12. u32 cells;
  13. const __be32 *prop;
  14. /* busno is always one cell */
  15. *busno = of_read_number(dma_window, 1);
  16. 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 ? of_read_number(prop, 1) : 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 ? of_read_number(prop, 1) : of_n_size_cells(dn);
  25. *size = of_read_number(dma_window, cells);
  26. }