1 /* $Id: sbus.h,v 1.22 2000/02/18 13:50:50 davem Exp $
2 * sbus.h: Defines for the Sun SBus.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
10 #include <linux/ioport.h>
12 #include <asm/oplib.h>
13 /* #include <asm/iommu.h> */ /* Unused since we use opaque iommu (|io-unit) */
14 #include <asm/scatterlist.h>
16 /* We scan which devices are on the SBus using the PROM node device
17 * tree. SBus devices are described in two different ways. You can
18 * either get an absolute address at which to access the device, or
19 * you can get a SBus 'slot' number and an offset within that slot.
22 /* The base address at which to calculate device OBIO addresses. */
23 #define SUN_SBUS_BVADDR 0xf8000000
24 #define SBUS_OFF_MASK 0x01ffffff
26 /* These routines are used to calculate device address from slot
27 * numbers + offsets, and vice versa.
30 extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
32 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
35 extern __inline__ int sbus_dev_slot(unsigned long dev_addr)
37 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
42 /* Linux SBUS device tables */
44 struct sbus_bus *bus; /* Back ptr to sbus */
45 struct sbus_dev *next; /* next device on this SBus or null */
46 struct sbus_dev *child; /* For ledma and espdma on sun4m */
47 struct sbus_dev *parent; /* Parent device if not toplevel */
48 int prom_node; /* PROM device tree node for this device */
49 char prom_name[64]; /* PROM device name */
52 struct resource resource[PROMREG_MAX];
54 struct linux_prom_registers reg_addrs[PROMREG_MAX];
55 int num_registers, ranges_applied;
57 struct linux_prom_ranges device_ranges[PROMREG_MAX];
58 int num_device_ranges;
64 /* This struct describes the SBus(s) found on this machine. */
66 void *iommu; /* Opaque IOMMU cookie */
67 struct sbus_dev *devices; /* Link to devices on this SBus */
68 struct sbus_bus *next; /* next SBus, if more than one SBus */
69 int prom_node; /* PROM device tree node for this SBus */
70 char prom_name[64]; /* Usually "sbus" or "sbi" */
73 struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
80 extern struct sbus_bus *sbus_root;
83 sbus_is_slave(struct sbus_dev *dev)
85 /* XXX Have to write this for sun4c's */
89 /* Device probing routines could find these handy */
90 #define for_each_sbus(bus) \
91 for((bus) = sbus_root; (bus); (bus)=(bus)->next)
93 #define for_each_sbusdev(device, bus) \
94 for((device) = (bus)->devices; (device); (device)=(device)->next)
96 #define for_all_sbusdev(device, bus) \
97 for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
98 for ((device) = (bus)->devices; (device); (device) = (device)->next)
100 /* Driver DVMA interfaces. */
101 #define sbus_can_dma_64bit(sdev) (0) /* actually, sparc_cpu_model==sun4d */
102 #define sbus_can_burst64(sdev) (0) /* actually, sparc_cpu_model==sun4d */
103 extern void sbus_set_sbus64(struct sbus_dev *, int);
105 /* These yield IOMMU mappings in consistent mode. */
106 extern void *sbus_alloc_consistent(struct sbus_dev *, long, u32 *dma_addrp);
107 extern void sbus_free_consistent(struct sbus_dev *, long, void *, u32);
109 #define SBUS_DMA_BIDIRECTIONAL 0
110 #define SBUS_DMA_TODEVICE 1
111 #define SBUS_DMA_FROMDEVICE 2
112 #define SBUS_DMA_NONE 3
114 /* All the rest use streaming mode mappings. */
115 extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
116 extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
117 extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
118 extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
120 /* Finally, allow explicit synchronization of streamable mappings. */
121 extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
122 #define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
123 extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
124 extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
125 #define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
126 extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
128 /* Eric Brower (ebrower@usa.net)
129 * Translate SBus interrupt levels to ino values--
130 * this is used when converting sbus "interrupts" OBP
131 * node values to "intr" node values, and is platform
132 * dependent. If only we could call OBP with
133 * "sbus-intr>cpu (sbint -- ino)" from kernel...
134 * See .../drivers/sbus/sbus.c for details.
136 BTFIXUPDEF_CALL(unsigned int, sbint_to_irq, struct sbus_dev *sdev, unsigned int)
137 #define sbint_to_irq(sdev, sbint) BTFIXUP_CALL(sbint_to_irq)(sdev, sbint)
139 #endif /* !(_SPARC_SBUS_H) */