Rev 1627 | Rev 1631 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1627 | serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | |||
7 | |||
8 | |||
9 | |||
1628 | serge | 10 | #define PCIBIOS_SUCCESSFUL 0x00 |
11 | |||
1627 | serge | 12 | |
13 | .name = "PCI IO", |
||
14 | .start = 0, |
||
15 | .end = IO_SPACE_LIMIT, |
||
16 | .flags = IORESOURCE_IO, |
||
17 | }; |
||
18 | |||
19 | |||
20 | .name = "PCI mem", |
||
21 | .start = 0, |
||
22 | .end = -1, |
||
23 | .flags = IORESOURCE_MEM, |
||
24 | }; |
||
25 | |||
26 | |||
1628 | serge | 27 | |
1627 | serge | 28 | |
1628 | serge | 29 | u8 pos, int cap, int *ttl) |
30 | { |
||
1627 | serge | 31 | u8 id; |
1628 | serge | 32 | |
33 | |||
34 | pci_bus_read_config_byte(bus, devfn, pos, &pos); |
||
35 | if (pos < 0x40) |
||
36 | break; |
||
37 | pos &= ~3; |
||
38 | pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, |
||
39 | &id); |
||
40 | if (id == 0xff) |
||
41 | break; |
||
42 | if (id == cap) |
||
43 | return pos; |
||
44 | pos += PCI_CAP_LIST_NEXT; |
||
45 | } |
||
46 | return 0; |
||
47 | } |
||
1627 | serge | 48 | |
49 | |||
1628 | serge | 50 | u8 pos, int cap) |
51 | { |
||
52 | int ttl = PCI_FIND_CAP_TTL; |
||
53 | |||
54 | |||
55 | } |
||
56 | static int __pci_bus_find_cap_start(struct pci_bus *bus, |
||
57 | unsigned int devfn, u8 hdr_type) |
||
58 | { |
||
59 | u16 status; |
||
60 | |||
61 | |||
62 | if (!(status & PCI_STATUS_CAP_LIST)) |
||
63 | return 0; |
||
64 | |||
65 | |||
66 | case PCI_HEADER_TYPE_NORMAL: |
||
67 | case PCI_HEADER_TYPE_BRIDGE: |
||
68 | return PCI_CAPABILITY_LIST; |
||
69 | case PCI_HEADER_TYPE_CARDBUS: |
||
70 | return PCI_CB_CAPABILITY_LIST; |
||
71 | default: |
||
72 | return 0; |
||
73 | } |
||
74 | |||
75 | |||
76 | } |
||
77 | |||
78 | |||
79 | |||
80 | * pci_find_capability - query for devices' capabilities |
||
81 | * @dev: PCI device to query |
||
82 | * @cap: capability code |
||
83 | * |
||
84 | * Tell if a device supports a given PCI capability. |
||
85 | * Returns the address of the requested capability structure within the |
||
86 | * device's PCI configuration space or 0 in case the device does not |
||
87 | * support it. Possible values for @cap: |
||
88 | * |
||
89 | * %PCI_CAP_ID_PM Power Management |
||
90 | * %PCI_CAP_ID_AGP Accelerated Graphics Port |
||
91 | * %PCI_CAP_ID_VPD Vital Product Data |
||
92 | * %PCI_CAP_ID_SLOTID Slot Identification |
||
93 | * %PCI_CAP_ID_MSI Message Signalled Interrupts |
||
94 | * %PCI_CAP_ID_CHSWP CompactPCI HotSwap |
||
95 | * %PCI_CAP_ID_PCIX PCI-X |
||
96 | * %PCI_CAP_ID_EXP PCI Express |
||
97 | */ |
||
98 | int pci_find_capability(struct pci_dev *dev, int cap) |
||
99 | { |
||
100 | int pos; |
||
101 | |||
102 | |||
103 | if (pos) |
||
104 | pos = __pci_find_next_cap(dev->bus, dev->devfn, pos, cap); |
||
105 | |||
106 | |||
107 | } |
||
108 | |||
109 | |||
110 | |||
1627 | serge | 111 | { |
112 | struct pci_bus *b; |
||
113 | |||
114 | |||
115 | if (b) { |
||
116 | INIT_LIST_HEAD(&b->node); |
||
117 | INIT_LIST_HEAD(&b->children); |
||
118 | INIT_LIST_HEAD(&b->devices); |
||
119 | INIT_LIST_HEAD(&b->slots); |
||
120 | INIT_LIST_HEAD(&b->resources); |
||
121 | } |
||
122 | return b; |
||
123 | } |
||
124 | |||
125 | |||
126 | { |
||
127 | int error; |
||
128 | struct pci_bus *b, *b2; |
||
129 | |||
130 | |||
131 | if (!b) |
||
132 | return NULL; |
||
133 | |||
134 | |||
135 | b->ops = ops; |
||
136 | |||
137 | |||
138 | if (b2) { |
||
139 | /* If we already got to this bus through a different bridge, ignore it */ |
||
140 | dbgprintf("bus already known\n"); |
||
141 | goto err_out; |
||
142 | } |
||
143 | |||
144 | |||
145 | list_add_tail(&b->node, &pci_root_buses); |
||
146 | // up_write(&pci_bus_sem); |
||
147 | |||
148 | |||
149 | b->resource[0] = &ioport_resource; |
||
150 | b->resource[1] = &iomem_resource; |
||
151 | |||
152 | |||
153 | |||
154 | |||
155 | kfree(b); |
||
156 | return NULL; |
||
157 | } |
||
158 | |||
159 | |||
160 | |||
161 | |||
162 | |||
163 | |||
164 | { |
||
165 | struct pci_bus* child; |
||
166 | struct list_head *tmp; |
||
167 | |||
168 | |||
169 | return bus; |
||
170 | |||
171 | |||
172 | child = pci_do_find_bus(pci_bus_b(tmp), busnr); |
||
173 | if(child) |
||
174 | return child; |
||
175 | } |
||
176 | return NULL; |
||
177 | } |
||
178 | |||
179 | |||
180 | |||
181 | * pci_find_bus - locate PCI bus from a given domain and bus number |
||
182 | * @domain: number of PCI domain to search |
||
183 | * @busnr: number of desired PCI bus |
||
184 | * |
||
185 | * Given a PCI bus number and domain number, the desired PCI bus is located |
||
186 | * in the global list of PCI buses. If the bus is found, a pointer to its |
||
187 | * data structure is returned. If no bus is found, %NULL is returned. |
||
188 | */ |
||
189 | struct pci_bus * pci_find_bus(int domain, int busnr) |
||
190 | { |
||
191 | struct pci_bus *bus = NULL; |
||
192 | struct pci_bus *tmp_bus; |
||
193 | |||
194 | |||
195 | if (pci_domain_nr(bus) != domain) |
||
196 | continue; |
||
197 | tmp_bus = pci_do_find_bus(bus, busnr); |
||
198 | if (tmp_bus) |
||
199 | return tmp_bus; |
||
200 | } |
||
201 | return NULL; |
||
202 | } |
||
203 | |||
204 | |||
205 | * pci_find_next_bus - begin or continue searching for a PCI bus |
||
206 | * @from: Previous PCI bus found, or %NULL for new search. |
||
207 | * |
||
208 | * Iterates through the list of known PCI busses. A new search is |
||
209 | * initiated by passing %NULL as the @from argument. Otherwise if |
||
210 | * @from is not %NULL, searches continue from next device on the |
||
211 | * global list. |
||
212 | */ |
||
213 | struct pci_bus * |
||
214 | pci_find_next_bus(const struct pci_bus *from) |
||
215 | { |
||
216 | struct list_head *n; |
||
217 | struct pci_bus *b = NULL; |
||
218 | |||
219 | |||
220 | // down_read(&pci_bus_sem); |
||
221 | n = from ? from->node.next : pci_root_buses.next; |
||
222 | if (n != &pci_root_buses) |
||
223 | b = pci_bus_b(n); |
||
224 | // up_read(&pci_bus_sem); |
||
225 | return b; |
||
226 | } |
||
227 | |||
228 | |||
229 | |||
1628 | serge | 230 | * pci_get_slot - locate PCI device for a given PCI slot |
231 | * @bus: PCI bus on which desired PCI device resides |
||
232 | * @devfn: encodes number of PCI slot in which the desired PCI |
||
233 | * device resides and the logical device number within that slot |
||
234 | * in case of multi-function devices. |
||
235 | * |
||
236 | * Given a PCI bus and slot/function number, the desired PCI device |
||
237 | * is located in the list of PCI devices. |
||
238 | * If the device is found, its reference count is increased and this |
||
239 | * function returns a pointer to its data structure. The caller must |
||
240 | * decrement the reference count by calling pci_dev_put(). |
||
241 | * If no device is found, %NULL is returned. |
||
242 | */ |
||
243 | struct pci_dev * pci_get_slot(struct pci_bus *bus, unsigned int devfn) |
||
244 | { |
||
245 | struct list_head *tmp; |
||
246 | struct pci_dev *dev; |
||
247 | |||
248 | |||
249 | // down_read(&pci_bus_sem); |
||
250 | |||
251 | |||
252 | dev = pci_dev_b(tmp); |
||
253 | if (dev->devfn == devfn) |
||
254 | goto out; |
||
255 | } |
||
256 | |||
257 | |||
258 | out: |
||
259 | // pci_dev_get(dev); |
||
260 | // up_read(&pci_bus_sem); |
||
261 | return dev; |
||
262 | } |
||
263 | |||
264 | |||
265 | |||
266 | |||
267 | |||
268 | * pci_find_ext_capability - Find an extended capability |
||
269 | * @dev: PCI device to query |
||
270 | * @cap: capability code |
||
271 | * |
||
272 | * Returns the address of the requested extended capability structure |
||
273 | * within the device's PCI configuration space or 0 if the device does |
||
274 | * not support it. Possible values for @cap: |
||
275 | * |
||
276 | * %PCI_EXT_CAP_ID_ERR Advanced Error Reporting |
||
277 | * %PCI_EXT_CAP_ID_VC Virtual Channel |
||
278 | * %PCI_EXT_CAP_ID_DSN Device Serial Number |
||
279 | * %PCI_EXT_CAP_ID_PWR Power Budgeting |
||
280 | */ |
||
281 | int pci_find_ext_capability(struct pci_dev *dev, int cap) |
||
282 | { |
||
283 | u32 header; |
||
284 | int ttl; |
||
285 | int pos = PCI_CFG_SPACE_SIZE; |
||
286 | |||
287 | |||
288 | ttl = (PCI_CFG_SPACE_EXP_SIZE - PCI_CFG_SPACE_SIZE) / 8; |
||
289 | |||
290 | |||
291 | return 0; |
||
292 | |||
293 | |||
294 | return 0; |
||
295 | |||
296 | |||
297 | * If we have no capabilities, this is indicated by cap ID, |
||
298 | * cap version and next pointer all being 0. |
||
299 | */ |
||
300 | if (header == 0) |
||
301 | return 0; |
||
302 | |||
303 | |||
304 | if (PCI_EXT_CAP_ID(header) == cap) |
||
305 | return pos; |
||
306 | |||
307 | |||
308 | if (pos < PCI_CFG_SPACE_SIZE) |
||
309 | break; |
||
310 | |||
311 | |||
312 | break; |
||
313 | } |
||
314 | |||
315 | |||
316 | }>=>> |
||
317 |