* added 0.99 linux version
[mascara-docs.git] / i386 / linux / linux-2.3.21 / include / asm-sparc64 / sbus.h
blobf3169c8ceb9ca96ebd97fb09ba5b942df01c839d
1 /* $Id: sbus.h,v 1.10 1998/12/16 04:33:58 davem Exp $
2 * sbus.h: Defines for the Sun SBus.
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
7 /* XXX This needs to be mostly redone for sun5 SYSIO. */
9 #ifndef _SPARC64_SBUS_H
10 #define _SPARC64_SBUS_H
12 #include <asm/oplib.h>
13 #include <asm/iommu.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.
21 /* The base address at which to calculate device OBIO addresses. */
22 #define SUN_SBUS_BVADDR 0x00000000
23 #define SBUS_OFF_MASK 0x0fffffff
25 /* These routines are used to calculate device address from slot
26 * numbers + offsets, and vice versa.
29 extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
31 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
34 extern __inline__ int sbus_dev_slot(unsigned long dev_addr)
36 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
39 extern __inline__ unsigned long sbus_dev_offset(unsigned long dev_addr)
41 return (unsigned long) (((dev_addr)-SUN_SBUS_BVADDR)&SBUS_OFF_MASK);
44 struct linux_sbus;
46 /* Linux SBUS device tables */
47 struct linux_sbus_device {
48 struct linux_sbus_device *next; /* next device on this SBus or null */
49 struct linux_sbus_device *child; /* For ledma and espdma on sun4m */
50 struct linux_sbus *my_bus; /* Back ptr to sbus */
51 int prom_node; /* PROM device tree node for this device */
52 char prom_name[32]; /* PROM device name */
54 struct linux_prom_registers reg_addrs[PROMREG_MAX];
55 int num_registers, ranges_applied;
57 unsigned int irqs[4];
58 int num_irqs;
60 unsigned long sbus_addr; /* Absolute base address for device. */
61 unsigned long sbus_vaddrs[PROMVADDR_MAX];
62 unsigned long num_vaddrs;
63 unsigned long offset; /* Offset given by PROM */
64 int slot;
67 /* This struct describes the SBus(s) found on this machine. */
68 struct linux_sbus {
69 struct linux_sbus *next; /* next SBus, if more than one SBus */
70 struct linux_sbus_device *devices; /* Link to devices on this SBus */
71 struct iommu_struct *iommu; /* IOMMU for this sbus if applicable */
72 int prom_node; /* PROM device tree node for this SBus */
73 char prom_name[64]; /* Usually "sbus" or "sbi" */
74 int clock_freq;
75 struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
76 int num_sbus_ranges;
77 int upaid;
78 void *starfire_cookie;
81 extern struct linux_sbus *SBus_chain;
83 /* Device probing routines could find these handy */
84 #define for_each_sbus(bus) \
85 for((bus) = SBus_chain; (bus); (bus)=(bus)->next)
87 #define for_each_sbusdev(device, bus) \
88 for((device) = (bus)->devices; (device); (device)=(device)->next)
90 #define for_all_sbusdev(device, bus) \
91 for((bus) = SBus_chain, ((device) = (bus) ? (bus)->devices : 0); (bus); (device)=((device)->next ? (device)->next : ((bus) = (bus)->next, (bus) ? (bus)->devices : 0)))
93 extern void mmu_set_sbus64(struct linux_sbus_device *, int);
95 /* If you did not get the buffer from mmu_get_*() or sparc_alloc_dvma()
96 * then you must use this to get the 32-bit SBUS dvma address.
97 * And in this case it is your responsibility to make sure the buffer
98 * is GFP_DMA, ie. that it is not greater than MAX_DMA_ADDRESS.
100 extern unsigned long phys_base;
101 #define sbus_dvma_addr(__addr) ((__u32)(__pa(__addr) - phys_base))
103 /* Apply promlib probed SBUS ranges to registers. */
104 extern void prom_apply_sbus_ranges(struct linux_sbus *sbus,
105 struct linux_prom_registers *sbusregs, int nregs,
106 struct linux_sbus_device *sdev);
108 #endif /* !(_SPARC64_SBUS_H) */