3 * SNI64 specific PCI support for SNI IO.
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
9 * Copyright (c) 1997, 1998, 2000-2003 Silicon Graphics, Inc. All rights reserved.
11 #include <linux/init.h>
12 #include <linux/types.h>
13 #include <linux/config.h>
14 #include <linux/pci.h>
15 #include <asm/sn/types.h>
16 #include <asm/sn/sgi.h>
17 #include <asm/sn/io.h>
18 #include <asm/sn/driver.h>
19 #include <asm/sn/iograph.h>
20 #include <asm/param.h>
21 #include <asm/sn/pio.h>
22 #include <asm/sn/xtalk/xwidget.h>
23 #include <asm/sn/sn_private.h>
24 #include <asm/sn/addrs.h>
25 #include <asm/sn/invent.h>
26 #include <asm/sn/hcl.h>
27 #include <asm/sn/hcl_util.h>
28 #include <asm/sn/pci/pciio.h>
29 #include <asm/sn/pci/pcibr.h>
30 #include <asm/sn/pci/pcibr_private.h>
31 #include <asm/sn/pci/bridge.h>
34 #define DBG(x...) printk(x)
43 extern vertex_hdl_t pci_bus_to_vertex(unsigned char);
44 extern vertex_hdl_t devfn_to_vertex(unsigned char bus, unsigned char devfn);
47 * snia64_read_config_byte - Read a byte from the config area of the device.
49 static int snia64_read_config_byte (struct pci_dev *dev,
50 int where, unsigned char *val)
52 unsigned long res = 0;
54 vertex_hdl_t device_vertex;
56 if ( (dev == (struct pci_dev *)0) || (val == (unsigned char *)0) ) {
57 return PCIBIOS_DEVICE_NOT_FOUND;
59 device_vertex = devfn_to_vertex(dev->bus->number, dev->devfn);
61 DBG("%s : nonexistent device: bus= 0x%x slot= 0x%x func= 0x%x\n",
62 __FUNCTION__, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
65 res = pciio_config_get(device_vertex, (unsigned) where, size);
66 *val = (unsigned char) res;
67 return PCIBIOS_SUCCESSFUL;
71 * snia64_read_config_word - Read 2 bytes from the config area of the device.
73 static int snia64_read_config_word (struct pci_dev *dev,
74 int where, unsigned short *val)
76 unsigned long res = 0;
77 unsigned size = 2; /* 2 bytes */
78 vertex_hdl_t device_vertex;
80 if ( (dev == (struct pci_dev *)0) || (val == (unsigned short *)0) ) {
81 return PCIBIOS_DEVICE_NOT_FOUND;
83 device_vertex = devfn_to_vertex(dev->bus->number, dev->devfn);
85 DBG("%s : nonexistent device: bus= 0x%x slot= 0x%x func= 0x%x\n",
86 __FUNCTION__, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
89 res = pciio_config_get(device_vertex, (unsigned) where, size);
90 *val = (unsigned short) res;
91 return PCIBIOS_SUCCESSFUL;
95 * snia64_read_config_dword - Read 4 bytes from the config area of the device.
97 static int snia64_read_config_dword (struct pci_dev *dev,
98 int where, unsigned int *val)
100 unsigned long res = 0;
101 unsigned size = 4; /* 4 bytes */
102 vertex_hdl_t device_vertex;
105 return PCIBIOS_BAD_REGISTER_NUMBER;
107 if ( (dev == (struct pci_dev *)0) || (val == (unsigned int *)0) ) {
108 return PCIBIOS_DEVICE_NOT_FOUND;
111 device_vertex = devfn_to_vertex(dev->bus->number, dev->devfn);
112 if (!device_vertex) {
113 DBG("%s : nonexistent device: bus= 0x%x slot= 0x%x func= 0x%x\n",
114 __FUNCTION__, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
117 res = pciio_config_get(device_vertex, (unsigned) where, size);
118 *val = (unsigned int) res;
119 return PCIBIOS_SUCCESSFUL;
123 * snia64_write_config_byte - Writes 1 byte to the config area of the device.
125 static int snia64_write_config_byte (struct pci_dev *dev,
126 int where, unsigned char val)
128 vertex_hdl_t device_vertex;
130 if ( dev == (struct pci_dev *)0 ) {
131 return PCIBIOS_DEVICE_NOT_FOUND;
134 device_vertex = devfn_to_vertex(dev->bus->number, dev->devfn);
135 if (!device_vertex) {
136 DBG("%s : nonexistent device: bus= 0x%x slot= 0x%x func= 0x%x\n",
137 __FUNCTION__, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
140 pciio_config_set( device_vertex, (unsigned)where, 1, (uint64_t) val);
142 return PCIBIOS_SUCCESSFUL;
146 * snia64_write_config_word - Writes 2 bytes to the config area of the device.
148 static int snia64_write_config_word (struct pci_dev *dev,
149 int where, unsigned short val)
151 vertex_hdl_t device_vertex = NULL;
154 return PCIBIOS_BAD_REGISTER_NUMBER;
156 if ( dev == (struct pci_dev *)0 ) {
157 return PCIBIOS_DEVICE_NOT_FOUND;
160 device_vertex = devfn_to_vertex(dev->bus->number, dev->devfn);
161 if (!device_vertex) {
162 DBG("%s : nonexistent device: bus= 0x%x slot= 0x%x func= 0x%x\n",
163 __FUNCTION__, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
166 pciio_config_set( device_vertex, (unsigned)where, 2, (uint64_t) val);
168 return PCIBIOS_SUCCESSFUL;
172 * snia64_write_config_dword - Writes 4 bytes to the config area of the device.
174 static int snia64_write_config_dword (struct pci_dev *dev,
175 int where, unsigned int val)
177 vertex_hdl_t device_vertex;
180 return PCIBIOS_BAD_REGISTER_NUMBER;
182 if ( dev == (struct pci_dev *)0 ) {
183 return PCIBIOS_DEVICE_NOT_FOUND;
186 device_vertex = devfn_to_vertex(dev->bus->number, dev->devfn);
187 if (!device_vertex) {
188 DBG("%s : nonexistent device: bus= 0x%x slot= 0x%x func= 0x%x\n",
189 __FUNCTION__, dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
192 pciio_config_set( device_vertex, (unsigned)where, 4, (uint64_t) val);
194 return PCIBIOS_SUCCESSFUL;
197 static struct pci_ops snia64_pci_ops = {
198 snia64_read_config_byte,
199 snia64_read_config_word,
200 snia64_read_config_dword,
201 snia64_write_config_byte,
202 snia64_write_config_word,
203 snia64_write_config_dword
207 * snia64_pci_find_bios - SNIA64 pci_find_bios() platform specific code.
210 sn_pci_find_bios(void)
212 extern struct pci_ops *pci_root_ops;
214 * Go initialize our IO Infrastructure ..
216 extern void sgi_master_io_infr_init(void);
218 sgi_master_io_infr_init();
220 /* sn_io_infrastructure_init(); */
221 pci_root_ops = &snia64_pci_ops;
224 void sn_pci_find_bios(void) {}
225 struct list_head pci_root_buses;
226 struct list_head pci_root_buses;
227 struct list_head pci_devices;
229 #endif /* CONFIG_PCI */