1 |
1275 |
phoenix |
/*
|
2 |
|
|
* This file is subject to the terms and conditions of the GNU General
|
3 |
|
|
* Public License. See the file "COPYING" in the main directory of
|
4 |
|
|
* this archive for more details.
|
5 |
|
|
*
|
6 |
|
|
* Copyright (C) 1997, 2001-2003 Silicon Graphics, Inc. All rights reserved.
|
7 |
|
|
*
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
#ifndef _ASM_SN_PCI_PCIBA_H
|
11 |
|
|
#define _ASM_SN_PCI_PCIBA_H
|
12 |
|
|
|
13 |
|
|
#include <linux/ioctl.h>
|
14 |
|
|
#include <linux/types.h>
|
15 |
|
|
#include <linux/pci.h>
|
16 |
|
|
|
17 |
|
|
#define PCI_CFG_VENDOR_ID PCI_VENDOR_ID
|
18 |
|
|
#define PCI_CFG_COMMAND PCI_COMMAND
|
19 |
|
|
#define PCI_CFG_REV_ID PCI_REVISION_ID
|
20 |
|
|
#define PCI_CFG_HEADER_TYPE PCI_HEADER_TYPE
|
21 |
|
|
#define PCI_CFG_BASE_ADDR(n) PCI_BASE_ADDRESS_##n
|
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* /hw/.../pci/[slot]/config accepts ioctls to read
|
25 |
|
|
* and write specific registers as follows:
|
26 |
|
|
*
|
27 |
|
|
* "t" is the native type (char, short, uint32, uint64)
|
28 |
|
|
* to read from CFG space; results will be arranged in
|
29 |
|
|
* byte significance (ie. first byte from PCI is lowest
|
30 |
|
|
* or last byte in result).
|
31 |
|
|
*
|
32 |
|
|
* "r" is the byte offset in PCI CFG space of the first
|
33 |
|
|
* byte of the register (it's least significant byte,
|
34 |
|
|
* in the little-endian PCI numbering). This can actually
|
35 |
|
|
* be as much as 16 bits wide, and is intended to match
|
36 |
|
|
* the layout of a "Type 1 Configuration Space" address:
|
37 |
|
|
* the register number in the low eight bits, then three
|
38 |
|
|
* bits for the function number and five bits for the
|
39 |
|
|
* slot number.
|
40 |
|
|
*/
|
41 |
|
|
#define PCIIOCCFGRD(t,r) _IOR(0,(r),t)
|
42 |
|
|
#define PCIIOCCFGWR(t,r) _IOW(0,(r),t)
|
43 |
|
|
|
44 |
|
|
/* Some common config register access commands.
|
45 |
|
|
* Use these as examples of how to construct
|
46 |
|
|
* values for other registers you want to access.
|
47 |
|
|
*/
|
48 |
|
|
|
49 |
|
|
/* PCIIOCGETID: arg is ptr to 32-bit int,
|
50 |
|
|
* returns the 32-bit ID value with VENDOR
|
51 |
|
|
* in the bottom 16 bits and DEVICE in the top.
|
52 |
|
|
*/
|
53 |
|
|
#define PCIIOCGETID PCIIOCCFGRD(uint32_t,PCI_CFG_VENDOR_ID)
|
54 |
|
|
|
55 |
|
|
/* PCIIOCSETCMD: arg is ptr to a 16-bit short,
|
56 |
|
|
* which will be written to the CMD register.
|
57 |
|
|
*/
|
58 |
|
|
#define PCIIOCSETCMD PCIIOCCFGWR(uint16_t,PCI_CFG_COMMAND)
|
59 |
|
|
|
60 |
|
|
/* PCIIOCGETREV: arg is ptr to an 8-bit char,
|
61 |
|
|
* which will get the 8-bit revision number.
|
62 |
|
|
*/
|
63 |
|
|
#define PCIIOCGETREV PCIIOCCFGRD(uint8_t,PCI_CFG_REV_ID)
|
64 |
|
|
|
65 |
|
|
/* PCIIOCGETHTYPE: arg is ptr to an 8-bit char,
|
66 |
|
|
* which will get the 8-bit header type.
|
67 |
|
|
*/
|
68 |
|
|
#define PCIIOCGETHTYPE PCIIOCCFGRD(uint8_t,PCI_CFG_HEADER_TYPE)
|
69 |
|
|
|
70 |
|
|
/* PCIIOCGETBASE(n): arg is ptr to a 32-bit int,
|
71 |
|
|
* which will get the value of the BASE<n> register.
|
72 |
|
|
*/
|
73 |
|
|
|
74 |
|
|
/* FIXME chadt: this doesn't tell me whether or not this will work
|
75 |
|
|
with non-constant 'n.' */
|
76 |
|
|
#define PCIIOCGETBASE(n) PCIIOCCFGRD(uint32_t,PCI_CFG_BASE_ADDR(n))
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
/* /hw/.../pci/[slot]/dma accepts ioctls to allocate
|
80 |
|
|
* and free physical memory for use in user-triggered
|
81 |
|
|
* DMA operations.
|
82 |
|
|
*/
|
83 |
|
|
#define PCIIOCDMAALLOC _IOWR(0,1,uint64_t)
|
84 |
|
|
#define PCIIOCDMAFREE _IOW(0,1,uint64_t)
|
85 |
|
|
|
86 |
|
|
/* pio cache-mode ioctl defines. current only uncached accelerated */
|
87 |
|
|
#define PCIBA_CACHE_MODE_SET 1
|
88 |
|
|
#define PCIBA_CACHE_MODE_CLEAR 2
|
89 |
|
|
#ifdef PIOMAP_UNC_ACC
|
90 |
|
|
#define PCIBA_UNCACHED_ACCEL PIOMAP_UNC_ACC
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
/* The parameter for PCIIOCDMAALLOC needs to contain
|
94 |
|
|
* both the size of the request and the flag values
|
95 |
|
|
* to be used in setting up the DMA.
|
96 |
|
|
*
|
97 |
|
|
|
98 |
|
|
FIXME chadt: gonna have to revisit this: what flags would an IRIXer like to
|
99 |
|
|
have available?
|
100 |
|
|
|
101 |
|
|
* Any flags normally useful in pciio_dmamap
|
102 |
|
|
* or pciio_dmatrans function calls can6 be used here. */
|
103 |
|
|
#define PCIIOCDMAALLOC_REQUEST_PACK(flags,size) \
|
104 |
|
|
((((uint64_t)(flags))<<32)| \
|
105 |
|
|
(((uint64_t)(size))&0xFFFFFFFF))
|
106 |
|
|
|
107 |
|
|
|
108 |
|
|
#ifdef __KERNEL__
|
109 |
|
|
extern int pciba_init(void);
|
110 |
|
|
#endif
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
#endif /* _ASM_SN_PCI_PCIBA_H */
|