sbus.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* $Id: sbus.h,v 1.22 2000/02/18 13:50:50 davem Exp $
  2. * sbus.h: Defines for the Sun SBus.
  3. *
  4. * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #ifndef _SPARC_SBUS_H
  7. #define _SPARC_SBUS_H
  8. #include <linux/dma-mapping.h>
  9. #include <linux/ioport.h>
  10. #include <asm/oplib.h>
  11. /* #include <asm/iommu.h> */ /* Unused since we use opaque iommu (|io-unit) */
  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 0xf8000000
  20. #define SBUS_OFF_MASK 0x01ffffff
  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)<<25)+(offset));
  27. }
  28. static inline int sbus_dev_slot(unsigned long dev_addr)
  29. {
  30. return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
  31. }
  32. struct sbus_bus;
  33. /* Linux SBUS device tables */
  34. struct sbus_dev {
  35. struct sbus_bus *bus; /* Back ptr to sbus */
  36. struct sbus_dev *next; /* next device on this SBus or null */
  37. struct sbus_dev *child; /* For ledma and espdma on sun4m */
  38. struct sbus_dev *parent; /* Parent device if not toplevel */
  39. int prom_node; /* PROM device tree node for this device */
  40. char prom_name[64]; /* PROM device name */
  41. int slot;
  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; /* Link to devices on this SBus */
  54. struct sbus_bus *next; /* next SBus, if more than one SBus */
  55. int prom_node; /* PROM device tree node for this 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 devid;
  61. int board;
  62. };
  63. extern struct sbus_bus *sbus_root;
  64. static inline int
  65. sbus_is_slave(struct sbus_dev *dev)
  66. {
  67. /* XXX Have to write this for sun4c's */
  68. return 0;
  69. }
  70. /* Device probing routines could find these handy */
  71. #define for_each_sbus(bus) \
  72. for((bus) = sbus_root; (bus); (bus)=(bus)->next)
  73. #define for_each_sbusdev(device, bus) \
  74. for((device) = (bus)->devices; (device); (device)=(device)->next)
  75. #define for_all_sbusdev(device, bus) \
  76. for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
  77. for ((device) = (bus)->devices; (device); (device) = (device)->next)
  78. /* Driver DVMA interfaces. */
  79. #define sbus_can_dma_64bit(sdev) (0) /* actually, sparc_cpu_model==sun4d */
  80. #define sbus_can_burst64(sdev) (0) /* actually, sparc_cpu_model==sun4d */
  81. extern void sbus_set_sbus64(struct sbus_dev *, int);
  82. /* These yield IOMMU mappings in consistent mode. */
  83. extern void *sbus_alloc_consistent(struct sbus_dev *, long, u32 *dma_addrp);
  84. extern void sbus_free_consistent(struct sbus_dev *, long, void *, u32);
  85. void prom_adjust_ranges(struct linux_prom_ranges *, int,
  86. struct linux_prom_ranges *, int);
  87. #define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
  88. #define SBUS_DMA_TODEVICE DMA_TO_DEVICE
  89. #define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
  90. #define SBUS_DMA_NONE DMA_NONE
  91. /* All the rest use streaming mode mappings. */
  92. extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
  93. extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
  94. extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
  95. extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
  96. /* Finally, allow explicit synchronization of streamable mappings. */
  97. extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
  98. #define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
  99. extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
  100. extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
  101. #define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
  102. extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
  103. /* Eric Brower (ebrower@usa.net)
  104. * Translate SBus interrupt levels to ino values--
  105. * this is used when converting sbus "interrupts" OBP
  106. * node values to "intr" node values, and is platform
  107. * dependent. If only we could call OBP with
  108. * "sbus-intr>cpu (sbint -- ino)" from kernel...
  109. * See .../drivers/sbus/sbus.c for details.
  110. */
  111. BTFIXUPDEF_CALL(unsigned int, sbint_to_irq, struct sbus_dev *sdev, unsigned int)
  112. #define sbint_to_irq(sdev, sbint) BTFIXUP_CALL(sbint_to_irq)(sdev, sbint)
  113. #endif /* !(_SPARC_SBUS_H) */