2 * sbus.h: Defines for the Sun SBus.
4 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
10 #include <linux/dma-mapping.h>
11 #include <linux/ioport.h>
12 #include <linux/of_device.h>
14 #include <asm/oplib.h>
16 #include <asm/scatterlist.h>
18 /* We scan which devices are on the SBus using the PROM node device
19 * tree. SBus devices are described in two different ways. You can
20 * either get an absolute address at which to access the device, or
21 * you can get a SBus 'slot' number and an offset within that slot.
24 /* The base address at which to calculate device OBIO addresses. */
25 #define SUN_SBUS_BVADDR 0xf8000000
26 #define SBUS_OFF_MASK 0x01ffffff
28 /* These routines are used to calculate device address from slot
29 * numbers + offsets, and vice versa.
32 static inline unsigned long sbus_devaddr(int slotnum
, unsigned long offset
)
34 return (unsigned long) (SUN_SBUS_BVADDR
+((slotnum
)<<25)+(offset
));
37 static inline int sbus_dev_slot(unsigned long dev_addr
)
39 return (int) (((dev_addr
)-SUN_SBUS_BVADDR
)>>25);
44 /* Linux SBUS device tables */
46 struct of_device ofdev
;
48 struct sbus_dev
*next
;
49 struct sbus_dev
*child
;
50 struct sbus_dev
*parent
;
55 struct resource resource
[PROMREG_MAX
];
57 struct linux_prom_registers reg_addrs
[PROMREG_MAX
];
60 struct linux_prom_ranges device_ranges
[PROMREG_MAX
];
61 int num_device_ranges
;
66 #define to_sbus_device(d) container_of(d, struct sbus_dev, ofdev.dev)
68 /* This struct describes the SBus(s) found on this machine. */
70 struct of_device ofdev
;
71 struct sbus_dev
*devices
; /* Link to devices on this SBus */
72 struct sbus_bus
*next
; /* next SBus, if more than one SBus */
73 int prom_node
; /* PROM device tree node for this SBus */
74 char prom_name
[64]; /* Usually "sbus" or "sbi" */
77 struct linux_prom_ranges sbus_ranges
[PROMREG_MAX
];
83 #define to_sbus(d) container_of(d, struct sbus_bus, ofdev.dev)
85 extern struct sbus_bus
*sbus_root
;
88 sbus_is_slave(struct sbus_dev
*dev
)
90 /* XXX Have to write this for sun4c's */
94 /* Device probing routines could find these handy */
95 #define for_each_sbus(bus) \
96 for((bus) = sbus_root; (bus); (bus)=(bus)->next)
98 #define for_each_sbusdev(device, bus) \
99 for((device) = (bus)->devices; (device); (device)=(device)->next)
101 #define for_all_sbusdev(device, bus) \
102 for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
103 for ((device) = (bus)->devices; (device); (device) = (device)->next)
105 /* Driver DVMA interfaces. */
106 #define sbus_can_dma_64bit(sdev) (0) /* actually, sparc_cpu_model==sun4d */
107 #define sbus_can_burst64(sdev) (0) /* actually, sparc_cpu_model==sun4d */
108 extern void sbus_set_sbus64(struct sbus_dev
*, int);
109 extern void sbus_fill_device_irq(struct sbus_dev
*);
111 /* These yield IOMMU mappings in consistent mode. */
112 void prom_adjust_ranges(struct linux_prom_ranges
*, int,
113 struct linux_prom_ranges
*, int);
115 /* Eric Brower (ebrower@usa.net)
116 * Translate SBus interrupt levels to ino values--
117 * this is used when converting sbus "interrupts" OBP
118 * node values to "intr" node values, and is platform
119 * dependent. If only we could call OBP with
120 * "sbus-intr>cpu (sbint -- ino)" from kernel...
121 * See .../drivers/sbus/sbus.c for details.
123 BTFIXUPDEF_CALL(unsigned int, sbint_to_irq
, struct sbus_dev
*sdev
, unsigned int)
124 #define sbint_to_irq(sdev, sbint) BTFIXUP_CALL(sbint_to_irq)(sdev, sbint)
126 extern void sbus_arch_bus_ranges_init(struct device_node
*, struct sbus_bus
*);
127 extern void sbus_setup_iommu(struct sbus_bus
*, struct device_node
*);
128 extern void sbus_setup_arch_props(struct sbus_bus
*, struct device_node
*);
129 extern int sbus_arch_preinit(void);
130 extern void sbus_arch_postinit(void);
132 #endif /* !(_SPARC_SBUS_H) */