]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/asm-sparc/sbus.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[mirror_ubuntu-artful-kernel.git] / include / asm-sparc / sbus.h
CommitLineData
1da177e4
LT
1/* $Id: sbus.h,v 1.22 2000/02/18 13:50:50 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 <linux/dma-mapping.h>
11#include <linux/ioport.h>
12
13#include <asm/oplib.h>
576c352e
DM
14#include <asm/prom.h>
15#include <asm/of_device.h>
1da177e4
LT
16#include <asm/scatterlist.h>
17
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.
22 */
23
24/* The base address at which to calculate device OBIO addresses. */
25#define SUN_SBUS_BVADDR 0xf8000000
26#define SBUS_OFF_MASK 0x01ffffff
27
28/* These routines are used to calculate device address from slot
29 * numbers + offsets, and vice versa.
30 */
31
3115624e 32static inline unsigned long sbus_devaddr(int slotnum, unsigned long offset)
1da177e4
LT
33{
34 return (unsigned long) (SUN_SBUS_BVADDR+((slotnum)<<25)+(offset));
35}
36
3115624e 37static inline int sbus_dev_slot(unsigned long dev_addr)
1da177e4
LT
38{
39 return (int) (((dev_addr)-SUN_SBUS_BVADDR)>>25);
40}
41
42struct sbus_bus;
43
44/* Linux SBUS device tables */
45struct sbus_dev {
576c352e
DM
46 struct of_device ofdev;
47 struct sbus_bus *bus;
48 struct sbus_dev *next;
49 struct sbus_dev *child;
50 struct sbus_dev *parent;
51 int prom_node;
52 char prom_name[64];
1da177e4
LT
53 int slot;
54
55 struct resource resource[PROMREG_MAX];
56
57 struct linux_prom_registers reg_addrs[PROMREG_MAX];
576c352e 58 int num_registers;
1da177e4
LT
59
60 struct linux_prom_ranges device_ranges[PROMREG_MAX];
61 int num_device_ranges;
62
63 unsigned int irqs[4];
64 int num_irqs;
65};
576c352e 66#define to_sbus_device(d) container_of(d, struct sbus_dev, ofdev.dev)
1da177e4
LT
67
68/* This struct describes the SBus(s) found on this machine. */
69struct sbus_bus {
576c352e 70 struct of_device ofdev;
1da177e4
LT
71 void *iommu; /* Opaque IOMMU cookie */
72 struct sbus_dev *devices; /* Link to devices on this SBus */
73 struct sbus_bus *next; /* next SBus, if more than one SBus */
74 int prom_node; /* PROM device tree node for this SBus */
75 char prom_name[64]; /* Usually "sbus" or "sbi" */
76 int clock_freq;
77
78 struct linux_prom_ranges sbus_ranges[PROMREG_MAX];
79 int num_sbus_ranges;
80
81 int devid;
82 int board;
83};
576c352e 84#define to_sbus(d) container_of(d, struct sbus_bus, ofdev.dev)
1da177e4
LT
85
86extern struct sbus_bus *sbus_root;
87
3115624e 88static inline int
1da177e4
LT
89sbus_is_slave(struct sbus_dev *dev)
90{
91 /* XXX Have to write this for sun4c's */
92 return 0;
93}
94
95/* Device probing routines could find these handy */
96#define for_each_sbus(bus) \
97 for((bus) = sbus_root; (bus); (bus)=(bus)->next)
98
99#define for_each_sbusdev(device, bus) \
100 for((device) = (bus)->devices; (device); (device)=(device)->next)
101
102#define for_all_sbusdev(device, bus) \
103 for ((bus) = sbus_root; (bus); (bus) = (bus)->next) \
104 for ((device) = (bus)->devices; (device); (device) = (device)->next)
105
106/* Driver DVMA interfaces. */
107#define sbus_can_dma_64bit(sdev) (0) /* actually, sparc_cpu_model==sun4d */
108#define sbus_can_burst64(sdev) (0) /* actually, sparc_cpu_model==sun4d */
109extern void sbus_set_sbus64(struct sbus_dev *, int);
8fae097d 110extern void sbus_fill_device_irq(struct sbus_dev *);
1da177e4
LT
111
112/* These yield IOMMU mappings in consistent mode. */
113extern void *sbus_alloc_consistent(struct sbus_dev *, long, u32 *dma_addrp);
114extern void sbus_free_consistent(struct sbus_dev *, long, void *, u32);
115void prom_adjust_ranges(struct linux_prom_ranges *, int,
116 struct linux_prom_ranges *, int);
117
118#define SBUS_DMA_BIDIRECTIONAL DMA_BIDIRECTIONAL
119#define SBUS_DMA_TODEVICE DMA_TO_DEVICE
120#define SBUS_DMA_FROMDEVICE DMA_FROM_DEVICE
121#define SBUS_DMA_NONE DMA_NONE
122
123/* All the rest use streaming mode mappings. */
124extern dma_addr_t sbus_map_single(struct sbus_dev *, void *, size_t, int);
125extern void sbus_unmap_single(struct sbus_dev *, dma_addr_t, size_t, int);
126extern int sbus_map_sg(struct sbus_dev *, struct scatterlist *, int, int);
127extern void sbus_unmap_sg(struct sbus_dev *, struct scatterlist *, int, int);
128
129/* Finally, allow explicit synchronization of streamable mappings. */
130extern void sbus_dma_sync_single_for_cpu(struct sbus_dev *, dma_addr_t, size_t, int);
131#define sbus_dma_sync_single sbus_dma_sync_single_for_cpu
132extern void sbus_dma_sync_single_for_device(struct sbus_dev *, dma_addr_t, size_t, int);
133extern void sbus_dma_sync_sg_for_cpu(struct sbus_dev *, struct scatterlist *, int, int);
134#define sbus_dma_sync_sg sbus_dma_sync_sg_for_cpu
135extern void sbus_dma_sync_sg_for_device(struct sbus_dev *, struct scatterlist *, int, int);
136
137/* Eric Brower (ebrower@usa.net)
138 * Translate SBus interrupt levels to ino values--
139 * this is used when converting sbus "interrupts" OBP
140 * node values to "intr" node values, and is platform
141 * dependent. If only we could call OBP with
142 * "sbus-intr>cpu (sbint -- ino)" from kernel...
143 * See .../drivers/sbus/sbus.c for details.
144 */
145BTFIXUPDEF_CALL(unsigned int, sbint_to_irq, struct sbus_dev *sdev, unsigned int)
146#define sbint_to_irq(sdev, sbint) BTFIXUP_CALL(sbint_to_irq)(sdev, sbint)
147
576c352e
DM
148extern void sbus_arch_bus_ranges_init(struct device_node *, struct sbus_bus *);
149extern void sbus_setup_iommu(struct sbus_bus *, struct device_node *);
150extern void sbus_setup_arch_props(struct sbus_bus *, struct device_node *);
151extern int sbus_arch_preinit(void);
152extern void sbus_arch_postinit(void);
153
1da177e4 154#endif /* !(_SPARC_SBUS_H) */