1 |
1276 |
phoenix |
/* $Id: sbus.h,v 1.1.1.1 2004-04-15 03:01:06 phoenix Exp $
|
2 |
|
|
* sbus.h: Defines for the Sun SBus.
|
3 |
|
|
*
|
4 |
|
|
* Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
#ifndef _SPARC64_SBUS_H
|
8 |
|
|
#define _SPARC64_SBUS_H
|
9 |
|
|
|
10 |
|
|
#include <linux/ioport.h>
|
11 |
|
|
|
12 |
|
|
#include <asm/oplib.h>
|
13 |
|
|
#include <asm/iommu.h>
|
14 |
|
|
#include <asm/scatterlist.h>
|
15 |
|
|
|
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.
|
20 |
|
|
*/
|
21 |
|
|
|
22 |
|
|
/* The base address at which to calculate device OBIO addresses. */
|
23 |
|
|
#define SUN_SBUS_BVADDR 0x00000000
|
24 |
|
|
#define SBUS_OFF_MASK 0x0fffffff
|
25 |
|
|
|
26 |
|
|
/* These routines are used to calculate device address from slot
|
27 |
|
|
* numbers + offsets, and vice versa.
|
28 |
|
|
*/
|
29 |
|
|
|
30 |
|
|
extern __inline__ unsigned long sbus_devaddr(int slotnum, unsigned long offset)
|
31 |
|
|
{
|
32 |
|
|
return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<28)+(offset));
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
extern __inline__ int sbus_dev_slot(unsigned long dev_addr)
|
36 |
|
|
{
|
37 |
|
|
return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>28);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
struct sbus_bus;
|
41 |
|
|
|
42 |
|
|
/* Linux SBUS device tables */
|
43 |
|
|
struct sbus_dev {
|
44 |
|
|
struct sbus_bus *bus; /* Our toplevel parent SBUS */
|
45 |
|
|
struct sbus_dev *next; /* Chain of siblings */
|
46 |
|
|
struct sbus_dev *child; /* Chain of children */
|
47 |
|
|
struct sbus_dev *parent;/* Parent device if not toplevel*/
|
48 |
|
|
int prom_node; /* OBP node of this device */
|
49 |
|
|
char prom_name[64]; /* OBP device name property */
|
50 |
|
|
int slot; /* SBUS slot number */
|
51 |
|
|
|
52 |
|
|
struct resource resource[PROMREG_MAX];
|
53 |
|
|
|
54 |
|
|
struct linux_prom_registers reg_addrs[PROMREG_MAX];
|
55 |
|
|
int num_registers, ranges_applied;
|
56 |
|
|
|
57 |
|
|
struct linux_prom_ranges device_ranges[PROMREG_MAX];
|
58 |
|
|
int num_device_ranges;
|
59 |
|
|
|
60 |
|
|
unsigned int irqs[4];
|
61 |
|
|
int num_irqs;
|
62 |
|
|
};
|
63 |
|
|
|
64 |
|
|
/* This struct describes the SBus(s) found on this machine. */
|
65 |
|
|
struct sbus_bus {
|
66 |
|
|
void *iommu; /* Opaque IOMMU cookie */
|
67 |
|
|
struct sbus_dev *devices; /* Tree of SBUS devices */
|
68 |
|
|
struct sbus_bus *next; /* Next SBUS in system */
|
69 |
|
|
int prom_node; /* OBP node of SBUS */
|
70 |
|
|
char prom_name[64]; /* Usually "sbus" or "sbi" */
|
71 |
|
|
int clock_freq;
|
72 |
|
|
|
73 |
|
|
struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
|
74 |
|
|
int num_sbus_ranges;
|
75 |
|
|
|
76 |
|
|
int portid;
|
77 |
|
|
void *starfire_cookie;
|
78 |
|
|
};
|
79 |
|
|
|
80 |
|
|
extern struct sbus_bus *sbus_root;
|
81 |
|
|
|
82 |
|
|
/* Device probing routines could find these handy */
|
83 |
|
|
#define for_each_sbus(bus) \
|
84 |
|
|
for((bus) = sbus_root; (bus); (bus)=(bus)->next)
|
85 |
|
|
|
86 |
|
|
#define for_each_sbusdev(device, bus) \
|
87 |
|
|
for((device) = (bus)->devices; (device); (device)=(device)->next)
|
88 |
|
|
|
89 |
|
|
#define for_all_sbusdev(device, bus) \
|
90 |
|
|
for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
|
91 |
|
|
for ((device) = (bus)->devices; (device); (device) = (device)->next)
|
92 |
|
|
|
93 |
|
|
/* Driver DVMA interfaces. */
|
94 |
|
|
#define sbus_can_dma_64bit(sdev) (1)
|
95 |
|
|
#define sbus_can_burst64(sdev) (1)
|
96 |
|
|
extern void sbus_set_sbus64(struct sbus_dev *, int);
|
97 |
|
|
|
98 |
|
|
/* These yield IOMMU mappings in consistent mode. */
|
99 |
|
|
extern void *sbus_alloc_consistent(struct sbus_dev *, size_t, dma_addr_t *dma_addrp);
|
100 |
|
|
extern void sbus_free_consistent(struct sbus_dev *, size_t, void *, dma_addr_t);
|
101 |
|
|
|
102 |
|
|
#define SBUS_DMA_BIDIRECTIONAL 0
|
103 |
|
|
#define SBUS_DMA_TODEVICE 1
|
104 |
|
|
#define SBUS_DMA_FROMDEVICE 2
|
105 |
|
|
#define SBUS_DMA_NONE 3
|
106 |
|
|
|
107 |
|
|
/* All the rest use streaming mode mappings. */
|
108 |
|
|
extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
|
109 |
|
|
extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
|
110 |
|
|
extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
|
111 |
|
|
extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
|
112 |
|
|
|
113 |
|
|
/* Finally, allow explicit synchronization of streamable mappings. */
|
114 |
|
|
extern void sbus_dma_sync_single(struct sbus_dev *, dma_addr_t, size_t, int);
|
115 |
|
|
extern void sbus_dma_sync_sg(struct sbus_dev *, struct scatterlist *, int, int);
|
116 |
|
|
|
117 |
|
|
#endif /* !(_SPARC64_SBUS_H) */
|