sbus.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* $Id: sbus.h,v 1.14 2000/02/18 13:50:55 davem Exp $
  2. * sbus.h: Defines for the Sun SBus.
  3. *
  4. * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
  5. */
  6. #ifndef _SPARC64_SBUS_H
  7. #define _SPARC64_SBUS_H
  8. #include <linux/dma-mapping.h>
  9. #include <linux/ioport.h>
  10. #include <asm/oplib.h>
  11. #include <asm/prom.h>
  12. #include <asm/of_device.h>
  13. #include <asm/iommu.h>
  14. #include <asm/scatterlist.h>
  15. /* We scan which devices are on the SBus using the PROM node device
  16. * tree. SBus devices are described in two different ways. You can
  17. * either get an absolute address at which to access the device, or
  18. * you can get a SBus 'slot' number and an offset within that slot.
  19. */
  20. /* The base address at which to calculate device OBIO addresses. */
  21. #define SUN_SBUS_BVADDR 0x00000000
  22. #define SBUS_OFF_MASK 0x0fffffff
  23. /* These routines are used to calculate device address from slot
  24. * numbers + offsets, and vice versa.
  25. */
  26. static __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
  27. {
  28. return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
  29. }
  30. static __inline__ int sbus_dev_slot(unsigned long dev_addr)
  31. {
  32. return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
  33. }
  34. struct sbus_bus;
  35. /* Linux SBUS device tables */
  36. struct sbus_dev {
  37. struct of_device ofdev;
  38. struct sbus_bus *bus;
  39. struct sbus_dev *next;
  40. struct sbus_dev *child;
  41. struct sbus_dev *parent;
  42. int prom_node;
  43. char prom_name[64];
  44. int slot;
  45. struct resource resource[PROMREG_MAX];
  46. struct linux_prom_registers reg_addrs[PROMREG_MAX];
  47. int num_registers;
  48. struct linux_prom_ranges device_ranges[PROMREG_MAX];
  49. int num_device_ranges;
  50. unsigned int irqs[4];
  51. int num_irqs;
  52. };
  53. #define to_sbus_device(d) container_of(d, struct sbus_dev, ofdev.dev)
  54. /* This struct describes the SBus(s) found on this machine. */
  55. struct sbus_bus {
  56. struct of_device ofdev;
  57. void *iommu; /* Opaque IOMMU cookie */
  58. struct sbus_dev *devices; /* Tree of SBUS devices */
  59. struct sbus_bus *next; /* Next SBUS in system */
  60. int prom_node; /* OBP node of SBUS */
  61. char prom_name[64]; /* Usually "sbus" or "sbi" */
  62. int clock_freq;
  63. struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
  64. int num_sbus_ranges;
  65. int portid;
  66. };
  67. #define to_sbus(d) container_of(d, struct sbus_bus, ofdev.dev)
  68. extern struct sbus_bus *sbus_root;
  69. /* Device probing routines could find these handy */
  70. #define for_each_sbus(bus) \
  71. for((bus) = sbus_root; (bus); (bus)=(bus)->next)
  72. #define for_each_sbusdev(device, bus) \
  73. for((device) = (bus)->devices; (device); (device)=(device)->next)
  74. #define for_all_sbusdev(device, bus) \
  75. for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
  76. for ((device) = (bus)->devices; (device); (device) = (device)->next)
  77. /* Driver DVMA interfaces. */
  78. #define sbus_can_dma_64bit(sdev) (1)
  79. #define sbus_can_burst64(sdev) (1)
  80. extern void sbus_set_sbus64(struct sbus_dev *, int);
  81. extern void sbus_fill_device_irq(struct sbus_dev *);
  82. /* These yield IOMMU mappings in consistent mode. */
  83. extern void *sbus_alloc_consistent(struct sbus_dev *, size_t, dma_addr_t *dma_addrp);
  84. extern void sbus_free_consistent(struct sbus_dev *, size_t, void *, dma_addr_t);
  85. #define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
  86. #define SBUS_DMA_TODEVICE DMA_TO_DEVICE
  87. #define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
  88. #define SBUS_DMA_NONE DMA_NONE
  89. /* All the rest use streaming mode mappings. */
  90. extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
  91. extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
  92. extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
  93. extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
  94. /* Finally, allow explicit synchronization of streamable mappings. */
  95. extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
  96. #define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
  97. extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
  98. extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
  99. #define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
  100. extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
  101. extern void sbus_arch_bus_ranges_init(struct device_node *, struct sbus_bus *);
  102. extern void sbus_setup_iommu(struct sbus_bus *, struct device_node *);
  103. extern void sbus_setup_arch_props(struct sbus_bus *, struct device_node *);
  104. extern int sbus_arch_preinit(void);
  105. extern void sbus_arch_postinit(void);
  106. #endif /* !(_SPARC64_SBUS_H) */