1 /* $Id: sbus.h,v 1.8 1995/11/25 02:32:38 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
12 /* We scan which devices are on the SBus using the PROM node device 13 * tree. SBus devices are described in two different ways. You can 14 * either get an absolute address at which to access the device, or 15 * you can get a SBus 'slot' number and an offset within that slot. 16 */ 17
18 /* The base address at which to calculate device OBIO addresses. */ 19 #defineSUN_SBUS_BVADDR 0xf8000000
20 #defineSBUS_OFF_MASK 0x01ffffff
21
22 /* These routines are used to calculate device address from slot 23 * numbers + offsets, and vice versa. 24 */ 25
26 externinlineunsignedlong sbus_devaddr(intslotnum, unsignedlongoffset)
/* */ 27 { 28 return (unsignedlong) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
29 } 30
31 externinlineint sbus_dev_slot(unsignedlongdev_addr)
/* */ 32 { 33 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
34 } 35
36 externinlineunsignedlong sbus_dev_offset(unsignedlongdev_addr)
/* */ 37 { 38 return (unsignedlong) (((dev_addr)-SUN_SBUS_BVADDR)&SBUS_OFF_MASK);
39 } 40
41 structlinux_sbus;
42
43 /* Linux SBUS device tables */ 44 structlinux_sbus_device{ 45 structlinux_sbus_device *next; /* next device on this SBus or null */ 46 structlinux_sbus_device *child; /* For ledma and espdma on sun4m */ 47 structlinux_sbus *my_bus; /* Back ptr to sbus */ 48 intprom_node; /* PROM device tree node for this device */ 49 charprom_name[64]; /* PROM device name */ 50 char linux_name[64]; /* Name used internally by Linux */ 51
52 structlinux_prom_registersreg_addrs[PROMREG_MAX];
53 int num_registers;
54
55 structlinux_prom_irqsirqs[PROMINTR_MAX];
56 int num_irqs;
57
58 unsignedlong sbus_addr; /* Absolute base address for device. */ 59 unsignedlong sbus_vaddrs[PROMVADDR_MAX];
60 unsignedlong num_vaddrs;
61 unsignedlongoffset; /* Offset given by PROM */ 62 intslot;
63 };
64
65 /* This struct describes the SBus(s) found on this machine. */ 66 structlinux_sbus{ 67 structlinux_sbus *next; /* next SBus, if more than one SBus */ 68 structlinux_sbus_device *devices; /* Link to devices on this SBus */ 69 intprom_node; /* PROM device tree node for this SBus */ 70 charprom_name[64]; /* Usually "sbus" */ 71 int clock_freq;
72 };
73
74 externstructlinux_sbus *SBus_chain;
75
76 externinlineint 77 sbus_is_slave(structlinux_sbus_device *dev)
/* */ 78 { 79 /* Have to write this for sun4c's */ 80 return 0;
81 } 82
83 /* Device probing routines could find these handy */ 84 #definefor_each_sbus(bus) \
85 for((bus) = SBus_chain; (bus); (bus)=(bus)->next)
86
87 #definefor_each_sbusdev(device, bus) \
88 for((device) = (bus)->devices; (device); (device)=(device)->next)
89
90 #endif/* !(_SPARC_SBUS_H) */