| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * CompactPCI Hot Plug Driver PCI functions | 
|  | 3 | * | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 4 | * Copyright (C) 2002,2005 by SOMA Networks, Inc. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * | 
|  | 6 | * All rights reserved. | 
|  | 7 | * | 
|  | 8 | * This program is free software; you can redistribute it and/or modify | 
|  | 9 | * it under the terms of the GNU General Public License as published by | 
|  | 10 | * the Free Software Foundation; either version 2 of the License, or (at | 
|  | 11 | * your option) any later version. | 
|  | 12 | * | 
|  | 13 | * This program is distributed in the hope that it will be useful, but | 
|  | 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 15 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | 
|  | 16 | * NON INFRINGEMENT.  See the GNU General Public License for more | 
|  | 17 | * details. | 
|  | 18 | * | 
|  | 19 | * You should have received a copy of the GNU General Public License | 
|  | 20 | * along with this program; if not, write to the Free Software | 
|  | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
|  | 22 | * | 
|  | 23 | * Send feedback to <scottm@somanetworks.com> | 
|  | 24 | */ | 
|  | 25 |  | 
|  | 26 | #include <linux/config.h> | 
|  | 27 | #include <linux/module.h> | 
|  | 28 | #include <linux/kernel.h> | 
|  | 29 | #include <linux/pci.h> | 
|  | 30 | #include <linux/proc_fs.h> | 
|  | 31 | #include "../pci.h" | 
|  | 32 | #include "pci_hotplug.h" | 
|  | 33 | #include "cpci_hotplug.h" | 
|  | 34 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #define MY_NAME	"cpci_hotplug" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 |  | 
|  | 37 | extern int cpci_debug; | 
|  | 38 |  | 
|  | 39 | #define dbg(format, arg...)					\ | 
|  | 40 | do {							\ | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 41 | if (cpci_debug)					\ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | printk (KERN_DEBUG "%s: " format "\n",	\ | 
|  | 43 | MY_NAME , ## arg); 		\ | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 44 | } while (0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg) | 
|  | 46 | #define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) | 
|  | 47 | #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) | 
|  | 48 |  | 
|  | 49 | #define ROUND_UP(x, a)		(((x) + (a) - 1) & ~((a) - 1)) | 
|  | 50 |  | 
|  | 51 |  | 
|  | 52 | u8 cpci_get_attention_status(struct slot* slot) | 
|  | 53 | { | 
|  | 54 | int hs_cap; | 
|  | 55 | u16 hs_csr; | 
|  | 56 |  | 
|  | 57 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 58 | slot->devfn, | 
|  | 59 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 60 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 |  | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 63 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | slot->devfn, | 
|  | 65 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 66 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 68 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | return hs_csr & 0x0008 ? 1 : 0; | 
|  | 70 | } | 
|  | 71 |  | 
|  | 72 | int cpci_set_attention_status(struct slot* slot, int status) | 
|  | 73 | { | 
|  | 74 | int hs_cap; | 
|  | 75 | u16 hs_csr; | 
|  | 76 |  | 
|  | 77 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 78 | slot->devfn, | 
|  | 79 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 80 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 82 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | slot->devfn, | 
|  | 84 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 85 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 87 | if (status) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | hs_csr |= HS_CSR_LOO; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 89 | else | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | hs_csr &= ~HS_CSR_LOO; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 91 | if (pci_bus_write_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | slot->devfn, | 
|  | 93 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 94 | hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | return 1; | 
|  | 97 | } | 
|  | 98 |  | 
|  | 99 | u16 cpci_get_hs_csr(struct slot* slot) | 
|  | 100 | { | 
|  | 101 | int hs_cap; | 
|  | 102 | u16 hs_csr; | 
|  | 103 |  | 
|  | 104 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 105 | slot->devfn, | 
|  | 106 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 107 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | return 0xFFFF; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 109 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | slot->devfn, | 
|  | 111 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 112 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | return 0xFFFF; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | return hs_csr; | 
|  | 115 | } | 
|  | 116 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | int cpci_check_and_clear_ins(struct slot* slot) | 
|  | 118 | { | 
|  | 119 | int hs_cap; | 
|  | 120 | u16 hs_csr; | 
|  | 121 | int ins = 0; | 
|  | 122 |  | 
|  | 123 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 124 | slot->devfn, | 
|  | 125 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 126 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 128 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | slot->devfn, | 
|  | 130 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 131 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 133 | if (hs_csr & HS_CSR_INS) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | /* Clear INS (by setting it) */ | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 135 | if (pci_bus_write_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | slot->devfn, | 
|  | 137 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 138 | hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | ins = 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 140 | else | 
|  | 141 | ins = 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | } | 
|  | 143 | return ins; | 
|  | 144 | } | 
|  | 145 |  | 
|  | 146 | int cpci_check_ext(struct slot* slot) | 
|  | 147 | { | 
|  | 148 | int hs_cap; | 
|  | 149 | u16 hs_csr; | 
|  | 150 | int ext = 0; | 
|  | 151 |  | 
|  | 152 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 153 | slot->devfn, | 
|  | 154 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 155 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 157 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | slot->devfn, | 
|  | 159 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 160 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | return 0; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 162 | if (hs_csr & HS_CSR_EXT) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | ext = 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | return ext; | 
|  | 165 | } | 
|  | 166 |  | 
|  | 167 | int cpci_clear_ext(struct slot* slot) | 
|  | 168 | { | 
|  | 169 | int hs_cap; | 
|  | 170 | u16 hs_csr; | 
|  | 171 |  | 
|  | 172 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 173 | slot->devfn, | 
|  | 174 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 175 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | return -ENODEV; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 177 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | slot->devfn, | 
|  | 179 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 180 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | return -ENODEV; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 182 | if (hs_csr & HS_CSR_EXT) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | /* Clear EXT (by setting it) */ | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 184 | if (pci_bus_write_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | slot->devfn, | 
|  | 186 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 187 | hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | return -ENODEV; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | } | 
|  | 190 | return 0; | 
|  | 191 | } | 
|  | 192 |  | 
|  | 193 | int cpci_led_on(struct slot* slot) | 
|  | 194 | { | 
|  | 195 | int hs_cap; | 
|  | 196 | u16 hs_csr; | 
|  | 197 |  | 
|  | 198 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 199 | slot->devfn, | 
|  | 200 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 201 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | return -ENODEV; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 203 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | slot->devfn, | 
|  | 205 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 206 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | return -ENODEV; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 208 | if ((hs_csr & HS_CSR_LOO) != HS_CSR_LOO) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | hs_csr |= HS_CSR_LOO; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 210 | if (pci_bus_write_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | slot->devfn, | 
|  | 212 | hs_cap + 2, | 
|  | 213 | hs_csr)) { | 
|  | 214 | err("Could not set LOO for slot %s", | 
|  | 215 | slot->hotplug_slot->name); | 
|  | 216 | return -ENODEV; | 
|  | 217 | } | 
|  | 218 | } | 
|  | 219 | return 0; | 
|  | 220 | } | 
|  | 221 |  | 
|  | 222 | int cpci_led_off(struct slot* slot) | 
|  | 223 | { | 
|  | 224 | int hs_cap; | 
|  | 225 | u16 hs_csr; | 
|  | 226 |  | 
|  | 227 | hs_cap = pci_bus_find_capability(slot->bus, | 
|  | 228 | slot->devfn, | 
|  | 229 | PCI_CAP_ID_CHSWP); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 230 | if (!hs_cap) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | return -ENODEV; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 232 | if (pci_bus_read_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | slot->devfn, | 
|  | 234 | hs_cap + 2, | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 235 | &hs_csr)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | return -ENODEV; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 237 | if (hs_csr & HS_CSR_LOO) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | hs_csr &= ~HS_CSR_LOO; | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 239 | if (pci_bus_write_config_word(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | slot->devfn, | 
|  | 241 | hs_cap + 2, | 
|  | 242 | hs_csr)) { | 
|  | 243 | err("Could not clear LOO for slot %s", | 
|  | 244 | slot->hotplug_slot->name); | 
|  | 245 | return -ENODEV; | 
|  | 246 | } | 
|  | 247 | } | 
|  | 248 | return 0; | 
|  | 249 | } | 
|  | 250 |  | 
|  | 251 |  | 
|  | 252 | /* | 
|  | 253 | * Device configuration functions | 
|  | 254 | */ | 
|  | 255 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | int cpci_configure_slot(struct slot* slot) | 
|  | 257 | { | 
| Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 258 | unsigned char busnr; | 
|  | 259 | struct pci_bus *child; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 |  | 
|  | 261 | dbg("%s - enter", __FUNCTION__); | 
|  | 262 |  | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 263 | if (slot->dev == NULL) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | dbg("pci_dev null, finding %02x:%02x:%x", | 
|  | 265 | slot->bus->number, PCI_SLOT(slot->devfn), PCI_FUNC(slot->devfn)); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 266 | slot->dev = pci_get_slot(slot->bus, slot->devfn); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } | 
|  | 268 |  | 
|  | 269 | /* Still NULL? Well then scan for it! */ | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 270 | if (slot->dev == NULL) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | int n; | 
|  | 272 | dbg("pci_dev still null"); | 
|  | 273 |  | 
|  | 274 | /* | 
|  | 275 | * This will generate pci_dev structures for all functions, but | 
|  | 276 | * we will only call this case when lookup fails. | 
|  | 277 | */ | 
|  | 278 | n = pci_scan_slot(slot->bus, slot->devfn); | 
|  | 279 | dbg("%s: pci_scan_slot returned %d", __FUNCTION__, n); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 280 | if (n > 0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | pci_bus_add_devices(slot->bus); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 282 | slot->dev = pci_get_slot(slot->bus, slot->devfn); | 
|  | 283 | if (slot->dev == NULL) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | err("Could not find PCI device for slot %02x", slot->number); | 
| Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 285 | return 1; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } | 
|  | 287 | } | 
|  | 288 |  | 
| Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 289 | if (slot->dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { | 
|  | 290 | pci_read_config_byte(slot->dev, PCI_SECONDARY_BUS, &busnr); | 
|  | 291 | child = pci_add_new_bus(slot->dev->bus, slot->dev, busnr); | 
|  | 292 | pci_do_scan_bus(child); | 
|  | 293 | pci_bus_size_bridges(child); | 
|  | 294 | } | 
|  | 295 |  | 
|  | 296 | pci_bus_assign_resources(slot->dev->bus); | 
|  | 297 |  | 
| Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 298 | dbg("%s - exit", __FUNCTION__); | 
|  | 299 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | } | 
|  | 301 |  | 
|  | 302 | int cpci_unconfigure_slot(struct slot* slot) | 
|  | 303 | { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | int i; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | struct pci_dev *dev; | 
|  | 306 |  | 
|  | 307 | dbg("%s - enter", __FUNCTION__); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 308 | if (!slot->dev) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | err("No device for slot %02x\n", slot->number); | 
|  | 310 | return -ENODEV; | 
|  | 311 | } | 
|  | 312 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | for (i = 0; i < 8; i++) { | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 314 | dev = pci_get_slot(slot->bus, | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | PCI_DEVFN(PCI_SLOT(slot->devfn), i)); | 
| Scott Murray | bcc488a | 2005-05-27 16:48:52 -0400 | [diff] [blame] | 316 | if (dev) { | 
| Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 317 | pci_remove_bus_device(dev); | 
|  | 318 | slot->dev = NULL; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | } | 
|  | 320 | } | 
| Scott Murray | 43b7d7c | 2005-05-09 17:31:50 -0400 | [diff] [blame] | 321 | dbg("%s - exit", __FUNCTION__); | 
|  | 322 | return 0; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |