sbusvar.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* $OpenBSD: sbusvar.h,v 1.13 2008/06/26 05:42:18 ray Exp $ */
  2. /* $NetBSD: sbusvar.h,v 1.11 2000/11/01 06:18:45 eeh Exp $ */
  3. /*-
  4. * Copyright (c) 1998 The NetBSD Foundation, Inc.
  5. * All rights reserved.
  6. *
  7. * This code is derived from software contributed to The NetBSD Foundation
  8. * by Paul Kranenburg.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  21. * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  23. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29. * POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef _SBUS_VAR_H
  32. #define _SBUS_VAR_H
  33. struct sbus_softc;
  34. /*
  35. * S-bus variables.
  36. */
  37. /* Device register space description */
  38. struct sbus_reg {
  39. u_int32_t sbr_slot;
  40. u_int32_t sbr_offset;
  41. u_int32_t sbr_size;
  42. };
  43. /* Interrupt information */
  44. struct sbus_intr {
  45. u_int32_t sbi_pri; /* priority (IPL) */
  46. u_int32_t sbi_vec; /* vector (always 0?) */
  47. };
  48. /* Address translation across busses */
  49. struct sbus_range {
  50. u_int32_t cspace; /* Client space */
  51. u_int32_t coffset; /* Client offset */
  52. u_int32_t pspace; /* Parent space */
  53. u_int32_t poffset; /* Parent offset */
  54. u_int32_t size; /* Size in bytes of this range */
  55. };
  56. /*
  57. * SBus driver attach arguments.
  58. */
  59. struct sbus_attach_args {
  60. int sa_placeholder; /* for obio attach args sharing */
  61. bus_space_tag_t sa_bustag;
  62. bus_dma_tag_t sa_dmatag;
  63. char *sa_name; /* PROM node name */
  64. int sa_node; /* PROM handle */
  65. struct sbus_reg *sa_reg; /* SBus register space for device */
  66. int sa_nreg; /* Number of SBus register spaces */
  67. #define sa_slot sa_reg[0].sbr_slot
  68. #define sa_offset sa_reg[0].sbr_offset
  69. #define sa_size sa_reg[0].sbr_size
  70. struct sbus_intr *sa_intr; /* SBus interrupts for device */
  71. int sa_nintr; /* Number of interrupts */
  72. #define sa_pri sa_intr[0].sbi_pri
  73. u_int32_t *sa_promvaddrs;/* PROM-supplied virtual addresses -- 32-bit */
  74. int sa_npromvaddrs; /* Number of PROM VAs */
  75. #define sa_promvaddr sa_promvaddrs[0]
  76. int sa_frequency; /* SBus clockrate */
  77. };
  78. int sbus_print(void *, const char *);
  79. int sbus_setup_attach_args(
  80. struct sbus_softc *,
  81. bus_space_tag_t,
  82. bus_dma_tag_t,
  83. int, /*node*/
  84. struct sbus_attach_args *);
  85. void sbus_destroy_attach_args(struct sbus_attach_args *);
  86. #define sbus_bus_map(t, slot, offset, sz, flags, unused, hp) \
  87. bus_space_map(t, BUS_ADDR(slot, offset), sz, flags, hp)
  88. #if notyet
  89. /* variables per SBus */
  90. struct sbus_softc {
  91. struct device sc_dev; /* base device */
  92. bus_space_tag_t sc_bustag;
  93. bus_dma_tag_t sc_dmatag;
  94. int sc_clockfreq; /* clock frequency (in Hz) */
  95. struct sbus_range *sc_range;
  96. int sc_nrange;
  97. int sc_burst; /* burst transfer sizes supported */
  98. /* machdep stuff follows here */
  99. int *sc_intr2ipl; /* Interrupt level translation */
  100. int *sc_intr_compat; /* `intr' property to sbus compat */
  101. };
  102. #endif
  103. /*
  104. * PROM-reported DMA burst sizes for the SBus
  105. */
  106. #define SBUS_BURST_1 0x1
  107. #define SBUS_BURST_2 0x2
  108. #define SBUS_BURST_4 0x4
  109. #define SBUS_BURST_8 0x8
  110. #define SBUS_BURST_16 0x10
  111. #define SBUS_BURST_32 0x20
  112. #define SBUS_BURST_64 0x40
  113. /* We use #defined(SUN4*) here while the ports are in flux */
  114. #if defined(__sparc__) && !defined(__sparc64__)
  115. #include <sparc/dev/sbusvar.h>
  116. #define INTLEV(x) (x)
  117. #elif defined(__sparc64__)
  118. #include <sparc64/dev/sbusvar.h>
  119. #include <sparc64/dev/iommureg.h>
  120. #endif
  121. #endif /* _SBUS_VAR_H */