sbus.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/iommu.h>
  12. #include <asm/scatterlist.h>
  13. /* We scan which devices are on the SBus using the PROM node device
  14. * tree. SBus devices are described in two different ways. You can
  15. * either get an absolute address at which to access the device, or
  16. * you can get a SBus 'slot' number and an offset within that slot.
  17. */
  18. /* The base address at which to calculate device OBIO addresses. */
  19. #define SUN_SBUS_BVADDR 0x00000000
  20. #define SBUS_OFF_MASK 0x0fffffff
  21. /* These routines are used to calculate device address from slot
  22. * numbers + offsets, and vice versa.
  23. */
  24. static __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
  25. {
  26. return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
  27. }
  28. static __inline__ int sbus_dev_slot(unsigned long dev_addr)
  29. {
  30. return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
  31. }
  32. struct sbus_bus;
  33. /* Linux SBUS device tables */
  34. struct sbus_dev {
  35. struct sbus_bus *bus; /* Our toplevel parent SBUS */
  36. struct sbus_dev *next; /* Chain of siblings */
  37. struct sbus_dev *child; /* Chain of children */
  38. struct sbus_dev *parent;/* Parent device if not toplevel*/
  39. int prom_node; /* OBP node of this device */
  40. char prom_name[64]; /* OBP device name property */
  41. int slot; /* SBUS slot number */
  42. struct resource resource[PROMREG_MAX];
  43. struct linux_prom_registers reg_addrs[PROMREG_MAX];
  44. int num_registers, ranges_applied;
  45. struct linux_prom_ranges device_ranges[PROMREG_MAX];
  46. int num_device_ranges;
  47. unsigned int irqs[4];
  48. int num_irqs;
  49. };
  50. /* This struct describes the SBus(s) found on this machine. */
  51. struct sbus_bus {
  52. void *iommu; /* Opaque IOMMU cookie */
  53. struct sbus_dev *devices; /* Tree of SBUS devices */
  54. struct sbus_bus *next; /* Next SBUS in system */
  55. int prom_node; /* OBP node of SBUS */
  56. char prom_name[64]; /* Usually "sbus" or "sbi" */
  57. int clock_freq;
  58. struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
  59. int num_sbus_ranges;
  60. int portid;
  61. void *starfire_cookie;
  62. };
  63. extern struct sbus_bus *sbus_root;
  64. /* Device probing routines could find these handy */
  65. #define for_each_sbus(bus) \
  66. for((bus) = sbus_root; (bus); (bus)=(bus)->next)
  67. #define for_each_sbusdev(device, bus) \
  68. for((device) = (bus)->devices; (device); (device)=(device)->next)
  69. #define for_all_sbusdev(device, bus) \
  70. for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
  71. for ((device) = (bus)->devices; (device); (device) = (device)->next)
  72. /* Driver DVMA interfaces. */
  73. #define sbus_can_dma_64bit(sdev) (1)
  74. #define sbus_can_burst64(sdev) (1)
  75. extern void sbus_set_sbus64(struct sbus_dev *, int);
  76. /* These yield IOMMU mappings in consistent mode. */
  77. extern void *sbus_alloc_consistent(struct sbus_dev *, size_t, dma_addr_t *dma_addrp);
  78. extern void sbus_free_consistent(struct sbus_dev *, size_t, void *, dma_addr_t);
  79. #define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
  80. #define SBUS_DMA_TODEVICE DMA_TO_DEVICE
  81. #define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
  82. #define SBUS_DMA_NONE DMA_NONE
  83. /* All the rest use streaming mode mappings. */
  84. extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
  85. extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
  86. extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
  87. extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
  88. /* Finally, allow explicit synchronization of streamable mappings. */
  89. extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
  90. #define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
  91. extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
  92. extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
  93. #define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
  94. extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
  95. #endif /* !(_SPARC64_SBUS_H) */