1 /* $Id: sbus.h,v 1.9 1996/02/15 09:13:03 davem Exp $ 2 * sbus.h: Defines for the Sun SBus. 3 * 4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 5 */ 6
7 #ifndef_SPARC_SBUS_H 8 #define_SPARC_SBUS_H 9
10 #include <asm/oplib.h>
11 #include <asm/iommu.h>
12
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
19 /* The base address at which to calculate device OBIO addresses. */ 20 #defineSUN_SBUS_BVADDR 0xf8000000
21 #defineSBUS_OFF_MASK 0x01ffffff
22
23 /* These routines are used to calculate device address from slot 24 * numbers + offsets, and vice versa. 25 */ 26
27 externinlineunsignedlong sbus_devaddr(intslotnum, unsignedlongoffset)
/* */ 28 { 29 return (unsignedlong) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
30 } 31
32 externinlineint sbus_dev_slot(unsignedlongdev_addr)
/* */ 33 { 34 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
35 } 36
37 externinlineunsignedlong sbus_dev_offset(unsignedlongdev_addr)
/* */ 38 { 39 return (unsignedlong) (((dev_addr)-SUN_SBUS_BVADDR)&SBUS_OFF_MASK);
40 } 41
42 structlinux_sbus;
43
44 /* Linux SBUS device tables */ 45 structlinux_sbus_device{ 46 structlinux_sbus_device *next; /* next device on this SBus or null */ 47 structlinux_sbus_device *child; /* For ledma and espdma on sun4m */ 48 structlinux_sbus *my_bus; /* Back ptr to sbus */ 49 intprom_node; /* PROM device tree node for this device */ 50 charprom_name[64]; /* PROM device name */ 51 char linux_name[64]; /* Name used internally by Linux */ 52
53 structlinux_prom_registersreg_addrs[PROMREG_MAX];
54 intnum_registers;
55
56 structlinux_prom_irqsirqs[PROMINTR_MAX];
57 intnum_irqs;
58
59 unsignedlong sbus_addr; /* Absolute base address for device. */ 60 unsignedlong sbus_vaddrs[PROMVADDR_MAX];
61 unsignedlong num_vaddrs;
62 unsignedlongoffset; /* Offset given by PROM */ 63 intslot;
64 };
65
66 /* This struct describes the SBus(s) found on this machine. */ 67 structlinux_sbus{ 68 structlinux_sbus *next; /* next SBus, if more than one SBus */ 69 structlinux_sbus_device *devices; /* Link to devices on this SBus */ 70 structiommu_struct *iommu; /* IOMMU for this sbus if applicable */ 71 intprom_node; /* PROM device tree node for this SBus */ 72 charprom_name[64]; /* Usually "sbus" */ 73 int clock_freq;
74 };
75
76 externstructlinux_sbus *SBus_chain;
77
78 externinlineint 79 sbus_is_slave(structlinux_sbus_device *dev)
/* */ 80 { 81 /* Have to write this for sun4c's */ 82 return 0;
83 } 84
85 /* Device probing routines could find these handy */ 86 #definefor_each_sbus(bus) \
87 for((bus) = SBus_chain; (bus); (bus)=(bus)->next)
88
89 #definefor_each_sbusdev(device, bus) \
90 for((device) = (bus)->devices; (device); (device)=(device)->next)
91
92 #endif/* !(_SPARC_SBUS_H) */