prom_parse.c 910 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0
  2. #undef DEBUG
  3. #include <linux/kernel.h>
  4. #include <linux/string.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 __be32 *dma_window,
  10. unsigned long *busno, unsigned long *phys,
  11. unsigned long *size)
  12. {
  13. u32 cells;
  14. const __be32 *prop;
  15. /* busno is always one cell */
  16. *busno = of_read_number(dma_window, 1);
  17. 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 ? of_read_number(prop, 1) : 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 ? of_read_number(prop, 1) : of_n_size_cells(dn);
  26. *size = of_read_number(dma_window, cells);
  27. }