source: rtems/c/src/lib/libbsp/powerpc/shared/bootloader/pci.c @ c47f29d

4.104.114.84.95
Last change on this file since c47f29d was c47f29d, checked in by Greg Menke <gregory.menke@…>, on 12/06/04 at 18:21:25

PR 729/bsps

  • bootloader/pci.c: Removed the r->size=0 and r->base=0 assignement which makes too-large regions conflict with onboard hardware, replacing it with sfree which deletes the memory region from the setup code, leaving it disabled.
  • Property mode set to 100644
File size: 41.4 KB
Line 
1/*
2 *  pci.c -- Crude pci handling for early boot.
3 *
4 *  Copyright (C) 1998, 1999 Gabriel Paubert, paubert@iram.es
5 *
6 *  Modified to compile in RTEMS development environment
7 *  by Eric Valette
8 *
9 *  Copyright (C) 1999 Eric Valette. valette@crf.canon.fr
10 *
11 *  The license and distribution terms for this file may be
12 *  found in found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 * $Id$
16 */
17
18#include <sys/types.h>
19#include <rtems/bspIo.h>
20#include <libcpu/spr.h>
21#include "bootldr.h"
22#include "pci.h"
23#include <libcpu/io.h>
24#include <libcpu/page.h>
25#include <bsp/consoleIo.h>
26#include <string.h>
27
28#include <string.h>
29
30typedef unsigned int u32;
31
32
33
34/*
35#define DEBUG
36#define PCI_DEBUG
37*/
38
39/* Used to reorganize PCI space on stupid machines which spread resources
40 * across a wide address space. This is bad when P2P bridges are present
41 * or when it limits the mappings that a resource hog like a PCI<->VME
42 * bridge can use.
43 */
44
45typedef struct _pci_resource {
46      struct _pci_resource *next;
47      struct pci_dev *dev;
48      u_long base;    /* will be 64 bits on 64 bits machines */
49      u_long size;
50      u_char type;      /* 1 is I/O else low order 4 bits of the memory type */
51      u_char reg;       /* Register # in conf space header */
52      u_short cmd;    /* Original cmd byte */
53} pci_resource;
54
55typedef struct _pci_area {
56      struct _pci_area *next;
57      u_long start;
58      u_long end;
59      struct pci_bus *bus;
60      u_int flags;
61} pci_area;
62
63typedef struct _pci_area_head {
64      pci_area *head;
65      u_long mask;
66      int high; /* To allocate from top */
67} pci_area_head;
68
69#define PCI_AREA_PREFETCHABLE 0
70#define PCI_AREA_MEMORY 1
71#define PCI_AREA_IO 2
72
73struct _pci_private {
74      volatile u_int * config_addr;
75      volatile u_char * config_data;
76      struct pci_dev **last_dev_p;
77      struct pci_bus pci_root;
78      pci_resource *resources;
79      pci_area_head io, mem;
80
81} pci_private = {
82   config_addr: NULL,
83   config_data: (volatile u_char *) 0x80800000,
84   last_dev_p: NULL,
85   resources: NULL,
86   io: {NULL, 0xfff, 0},
87   mem: {NULL, 0xfffff, 0}
88};
89
90#define pci ((struct _pci_private *)(bd->pci_private))
91#define pci_root pci->pci_root
92
93#if !defined(DEBUG)
94#undef PCI_DEBUG
95/*
96  #else
97  #define PCI_DEBUG
98*/
99#endif
100
101#if defined(PCI_DEBUG)
102static void
103print_pci_resources(const char *s) {
104   pci_resource *p;
105   printk("%s", s);
106   for (p=pci->resources; p; p=p->next) {
107/*
108      printk("  %p:%p %06x %08lx %08lx %d\n",
109             p, p->next,
110             (p->dev->devfn<<8)+(p->dev->bus->number<<16)
111             +0x10+p->reg*4,
112             p->base,
113             p->size,
114             p->type);
115*/
116
117      printk("  %p:%p %d:%02x (%04x:%04x) %08lx %08lx %d\n",
118             p, p->next,
119             p->dev->bus->number, PCI_SLOT(p->dev->devfn),
120             p->dev->vendor, p->dev->device,
121             p->base,
122             p->size,
123             p->type);
124
125   }
126}
127
128static void
129print_pci_area(pci_area *p) {
130   for (; p; p=p->next) {
131      printk("    %p:%p %p %08lx %08lx\n",
132             p, p->next, p->bus, p->start, p->end);
133   }
134}
135
136static void
137print_pci_areas(const char *s) {
138   printk("%s  PCI I/O areas:\n",s);
139   print_pci_area(pci->io.head);
140   printk("  PCI memory areas:\n");
141   print_pci_area(pci->mem.head);
142}
143#else
144#define print_pci_areas(x)
145#define print_pci_resources(x)
146#endif
147
148/* Maybe there are some devices who use a size different
149 * from the alignment. For now we assume both are the same.
150 * The blacklist might be used for other weird things in the future too,
151 * since weird non PCI complying devices seem to proliferate these days.
152 */
153
154struct blacklist_entry {
155      u_short vendor, device;
156      u_char reg;
157      u_long actual_size;
158};
159
160#define BLACKLIST(vid, did, breg, actual_size) \
161        {PCI_VENDOR_ID_##vid, PCI_DEVICE_ID_##vid##_##did, breg, actual_size}
162
163static struct blacklist_entry blacklist[] = {
164   BLACKLIST(S3, TRIO, 0, 0x04000000),
165   {0xffff, 0, 0, 0}
166};
167
168/* This function filters resources and then inserts them into a list of
169 * configurable pci resources.
170 */
171
172#define AREA(r) \
173(((r->type&PCI_BASE_ADDRESS_SPACE)==PCI_BASE_ADDRESS_SPACE_IO) ? PCI_AREA_IO :\
174          ((r->type&PCI_BASE_ADDRESS_MEM_PREFETCH) ? PCI_AREA_PREFETCHABLE :\
175           PCI_AREA_MEMORY))
176
177static int insert_before(pci_resource *e, pci_resource *t) {
178   if (e->dev->bus->number != t->dev->bus->number)
179      return e->dev->bus->number > t->dev->bus->number;
180   if (AREA(e) != AREA(t)) return AREA(e)<AREA(t);
181   return (e->size > t->size);
182}
183
184static void insert_resource(pci_resource *r) {
185   struct blacklist_entry *b;
186   pci_resource *p;
187   if (!r) return;
188
189   /* First fixup in case we have a blacklist entry. Note that this
190    * may temporarily leave a resource in an inconsistent state: with
191    * (base & (size-1)) !=0. This is harmless.
192    */
193   for (b=blacklist; b->vendor!=0xffff; b++) {
194      if ((r->dev->vendor==b->vendor) &&
195          (r->dev->device==b->device) &&
196          (r->reg==b->reg)) {
197         r->size=b->actual_size;
198         break;
199      }
200   }
201
202   /* Motorola NT firmware does not configure pci devices which are not
203    * required for booting, others do. For now:
204    * - allocated devices in the ISA range (64kB I/O, 16Mb memory)
205    *   but non zero base registers are left as is.
206    * - all other registers, whether already allocated or not, are
207    *   reallocated unless they require an inordinate amount of
208    *   resources (>256 Mb for memory >64kB for I/O). These
209    *   devices with too large mapping requirements are simply ignored
210    *   and their bases are set to 0. This should disable the
211    *   corresponding decoders according to the PCI specification.
212    *   Many devices are buggy in this respect, however, but the
213    *   limits have hopefully been set high enough to avoid problems.
214    */
215
216   /*
217   ** This is little ugly below.  It seems that at least on the MCP750,
218   ** the PBC has some default IO space mappings that the bsp #defines
219   ** that read/write to PCI I/O space assume, particuarly the i8259
220   ** manipulation code.  So, if we allow the small IO spaces on PCI bus
221   ** 0 and 1 to be remapped, the registers can shift out from under the
222   ** #defines.  This is particuarly awful, but short of redefining the
223   ** PCI I/O primitives to be functions with base addresses read from
224   ** the hardware, we are stuck with the kludge below.  Note that
225   ** everything is remapped on the CPCI backplane and any downstream
226   ** hardware, its just the builtin stuff we're tiptoeing around.
227   **
228   ** Gregm, 7/16/2003
229   **
230   ** Gregm, changed 11/2003 so IO devices only on bus 0 zero are not
231   ** remapped.  This covers the builtin pc-like io devices- but
232   ** properly maps IO devices on higher busses.
233   */
234   if( r->dev->bus->number == 0 )
235   {
236   if ((r->type==PCI_BASE_ADDRESS_SPACE_IO)
237       ? (r->base && r->base <0x10000)
238       : (r->base && r->base <0x1000000)) {
239
240#ifdef PCI_DEBUG
241         printk("freeing region;  %p:%p %d:%02x (%04x:%04x) %08lx %08lx %d\n",
242                r, r->next,
243                r->dev->bus->number, PCI_SLOT(r->dev->devfn),
244                r->dev->vendor, r->dev->device,
245                r->base,
246                r->size,
247                r->type);
248#endif
249      sfree(r);
250      return;
251   }
252   }
253
254
255   /* 2004/11/30, PR 729 fix is removing the r->size=0 and r->base=0
256    * assignement which makes too-large regions conflict with onboard
257    * hardware, replacing it with sfree which deletes the memory region
258    * from the setup code, leaving it disabled. */
259   if ((r->type==PCI_BASE_ADDRESS_SPACE_IO)
260       ? (r->size > 0x10000)
261       : (r->size > 0x18000000)) {
262      sfree(r);
263      return;
264   }
265
266   /* Now insert into the list sorting by
267    * 1) decreasing bus number
268    * 2) space: prefetchable memory, non-prefetchable and finally I/O
269    * 3) decreasing size
270    */
271   if (!pci->resources || insert_before(r, pci->resources)) {
272      r->next = pci->resources;
273      pci->resources=r;
274   } else {
275      for (p=pci->resources; p->next; p=p->next) {
276         if (insert_before(r, p->next)) break;
277      }
278      r->next=p->next;
279      p->next=r;
280   }
281}
282
283/* This version only works for bus 0. I don't have any P2P bridges to test
284 * a more sophisticated version which has therefore not been implemented.
285 * Prefetchable memory is not yet handled correctly either.
286 * And several levels of PCI bridges much less even since there must be
287 * allocated together to be able to setup correctly the top bridge.
288 */
289
290static u_long find_range(u_char bus, u_char type,
291                         pci_resource **first,
292                         pci_resource **past, u_int *flags) {
293   pci_resource *p;
294   u_long total=0;
295   u_int fl=0;
296
297   for (p=pci->resources; p; p=p->next)
298   {
299      if ((p->dev->bus->number == bus) &&
300          AREA(p)==type) break;
301   }
302
303   *first = p;
304
305   for (; p; p=p->next)
306   {
307      if ((p->dev->bus->number != bus) ||
308          AREA(p)!=type || p->size == 0) break;
309      total = total+p->size;
310      fl |= 1<<p->type;
311   }
312
313   *past = p;
314   /* This will be used later to tell whether there are any 32 bit
315    * devices in an area which could be mapped higher than 4Gb
316    * on 64 bits architectures
317    */
318   *flags = fl;
319   return total;
320}
321
322static inline void init_free_area(pci_area_head *h, u_long start,
323                                  u_long end, u_int mask, int high) {
324   pci_area *p;
325   p = salloc(sizeof(pci_area));
326   if (!p) return;
327   h->head = p;
328   p->next = NULL;
329   p->start = (start+mask)&~mask;
330   p->end = (end-mask)|mask;
331   p->bus = NULL;
332   h->mask = mask;
333   h->high = high;
334}
335
336static void insert_area(pci_area_head *h, pci_area *p) {
337   pci_area *q = h->head;
338   if (!p) return;
339   if (q && (q->start< p->start)) {
340      for(;q->next && q->next->start<p->start; q = q->next);
341      if ((q->end >= p->start) ||
342          (q->next && p->end>=q->next->start)) {
343         sfree(p);
344         printk("Overlapping pci areas!\n");
345         return;
346      }
347      p->next = q->next;
348      q->next = p;
349   } else { /* Insert at head */
350      if (q && (p->end >= q->start)) {
351         sfree(p);
352         printk("Overlapping pci areas!\n");
353         return;
354      }
355      p->next = q;
356      h->head = p;
357   }
358}
359
360static
361void remove_area(pci_area_head *h, pci_area *p)
362{
363   pci_area *q = h->head;
364
365   if (!p || !q) return;
366   if (q==p)
367   {
368      h->head = q->next;
369      return;
370   }
371   for(;q && q->next!=p; q=q->next);
372   if (q) q->next=p->next;
373}
374
375static pci_area * alloc_area(pci_area_head *h, struct pci_bus *bus,
376                             u_long required, u_long mask, u_int flags) {
377   pci_area *p;
378   pci_area *from, *split, *new;
379
380   required = (required+h->mask) & ~h->mask;
381   for (p=h->head, from=NULL; p; p=p->next)
382   {
383      u_long l1 = ((p->start+required+mask)&~mask)-1;
384      u_long l2 = ((p->start+mask)&~mask)+required-1;
385      /* Allocated areas point to the bus to which they pertain */
386      if (p->bus) continue;
387      if ((p->end)>=l1 || (p->end)>=l2) from=p;
388      if (from && !h->high) break;
389   }
390   if (!from) return NULL;
391
392   split = salloc(sizeof(pci_area));
393   new = salloc(sizeof(pci_area));
394   /* If allocation of new succeeds then allocation of split has
395    * also been successful (given the current mm algorithms) !
396    */
397   if (!new) {
398      sfree(split);
399      return NULL;
400   }
401   new->bus = bus;
402   new->flags = flags;
403   /* Now allocate pci_space taking alignment into account ! */
404   if (h->high)
405   {
406      u_long l1 = ((from->end+1)&~mask)-required;
407      u_long l2 = (from->end+1-required)&~mask;
408      new->start = (l1>l2) ? l1 : l2;
409      split->end = from->end;
410      from->end = new->start-1;
411      split->start = new->start+required;
412      new->end = new->start+required-1;
413   }
414   else
415   {
416      u_long l1 = ((from->start+mask)&~mask)+required-1;
417      u_long l2 = ((from->start+required+mask)&~mask)-1;
418      new->end = (l1<l2) ? l1 : l2;
419      split->start = from->start;
420      from->start = new->end+1;
421      new->start = new->end+1-required;
422      split->end = new->start-1;
423   }
424
425   if (from->end+1 == from->start) remove_area(h, from);
426   if (split->end+1 != split->start)
427   {
428      split->bus = NULL;
429      insert_area(h, split);
430   }
431   else
432   {
433      sfree(split);
434   }
435   insert_area(h, new);
436   print_pci_areas("alloc_area called:\n");
437   return new;
438}
439
440static inline
441void alloc_space(pci_area *p, pci_resource *r)
442{
443   if (p->start & (r->size-1)) {
444      r->base = p->end+1-r->size;
445      p->end -= r->size;
446   } else {
447      r->base = p->start;
448      p->start += r->size;
449   }
450}
451
452static void reconfigure_bus_space(u_char bus, u_char type, pci_area_head *h)
453{
454   pci_resource *first, *past, *r;
455   pci_area *area, tmp;
456   u_int flags;
457   u_int required = find_range(bus, type, &first, &past, &flags);
458
459   if (required==0) return;
460
461   area = alloc_area(h, first->dev->bus, required, first->size-1, flags);
462
463   if (!area) return;
464
465   tmp = *area;
466   for (r=first; r!=past; r=r->next)
467   {
468      alloc_space(&tmp, r);
469   }
470}
471
472#define BUS0_IO_START           0x10000
473#define BUS0_IO_END             0x1ffff
474#define BUS0_MEM_START          0x1000000
475#define BUS0_MEM_END            0x3f00000
476
477#define BUSREST_IO_START        0x20000
478#define BUSREST_IO_END          0x7ffff
479#define BUSREST_MEM_START       0x4000000
480#define BUSREST_MEM_END        0x10000000
481
482static void reconfigure_pci(void) {
483   pci_resource *r;
484   struct pci_dev *dev;
485
486   /* FIXME: for now memory is relocated from low, it's better
487    * to start from higher addresses.
488    */
489   /*
490   init_free_area(&pci->io, 0x10000, 0x7fffff, 0xfff, 0);
491   init_free_area(&pci->mem, 0x1000000, 0x3cffffff, 0xfffff, 0);
492   */
493
494   init_free_area(&pci->io, BUS0_IO_START, BUS0_IO_END, 0xfff, 0);
495   init_free_area(&pci->mem, BUS0_MEM_START, BUS0_MEM_END, 0xfffff, 0);
496
497   /* First reconfigure the I/O space, this will be more
498    * complex when there is more than 1 bus. And 64 bits
499    * devices are another kind of problems.
500    */
501   reconfigure_bus_space(0, PCI_AREA_IO, &pci->io);
502   reconfigure_bus_space(0, PCI_AREA_MEMORY, &pci->mem);
503   reconfigure_bus_space(0, PCI_AREA_PREFETCHABLE, &pci->mem);
504
505   /* Now we have to touch the configuration space of all
506    * the devices to remap them better than they are right now.
507    * This is done in 3 steps:
508    * 1) first disable I/O and memory response of all devices
509    * 2) modify the base registers
510    * 3) restore the original PCI_COMMAND register.
511    */
512   for (r=pci->resources; r; r= r->next) {
513      if (!r->dev->sysdata) {
514         r->dev->sysdata=r;
515         pci_read_config_word(r->dev, PCI_COMMAND, &r->cmd);
516         pci_write_config_word(r->dev, PCI_COMMAND,
517                               r->cmd & ~(PCI_COMMAND_IO|
518                                          PCI_COMMAND_MEMORY));
519      }
520   }
521
522   for (r=pci->resources; r; r= r->next) {
523      pci_write_config_dword(r->dev,
524                             PCI_BASE_ADDRESS_0+(r->reg<<2),
525                             r->base);
526      if ((r->type&
527           (PCI_BASE_ADDRESS_SPACE|
528            PCI_BASE_ADDRESS_MEM_TYPE_MASK)) ==
529          (PCI_BASE_ADDRESS_SPACE_MEMORY|
530           PCI_BASE_ADDRESS_MEM_TYPE_64)) {
531         pci_write_config_dword(r->dev,
532                                PCI_BASE_ADDRESS_1+(r->reg<<2),
533                                0);
534      }
535   }
536   for (dev=bd->pci_devices; dev; dev= dev->next) {
537      if (dev->sysdata) {
538         pci_write_config_word(dev, PCI_COMMAND,
539                               ((pci_resource *)dev->sysdata)
540                               ->cmd);
541         dev->sysdata=NULL;
542      }
543   }
544}
545
546static int
547indirect_pci_read_config_byte(unsigned char bus, unsigned char dev_fn,
548                              unsigned char offset, unsigned char *val) {
549   out_be32(pci->config_addr,
550            0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24));
551   *val=in_8(pci->config_data + (offset&3));
552   return PCIBIOS_SUCCESSFUL;
553}
554
555static int
556indirect_pci_read_config_word(unsigned char bus, unsigned char dev_fn,
557                              unsigned char offset, unsigned short *val) {
558   *val = 0xffff;
559   if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER;
560   out_be32(pci->config_addr,
561            0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24));
562   *val=in_le16((volatile u_short *)(pci->config_data + (offset&3)));
563   return PCIBIOS_SUCCESSFUL;
564}
565
566static int
567indirect_pci_read_config_dword(unsigned char bus, unsigned char dev_fn,
568                               unsigned char offset, unsigned int *val) {
569   *val = 0xffffffff;
570   if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER;
571   out_be32(pci->config_addr,
572            0x80|(bus<<8)|(dev_fn<<16)|(offset<<24));
573   *val=in_le32((volatile u_int *)pci->config_data);
574   return PCIBIOS_SUCCESSFUL;
575}
576
577static int
578indirect_pci_write_config_byte(unsigned char bus, unsigned char dev_fn,
579                               unsigned char offset, unsigned char val) {
580   out_be32(pci->config_addr,
581            0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24));
582   out_8(pci->config_data + (offset&3), val);
583   return PCIBIOS_SUCCESSFUL;
584}
585
586static int
587indirect_pci_write_config_word(unsigned char bus, unsigned char dev_fn,
588                               unsigned char offset, unsigned short val) {
589   if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER;
590   out_be32(pci->config_addr,
591            0x80|(bus<<8)|(dev_fn<<16)|((offset&~3)<<24));
592   out_le16((volatile u_short *)(pci->config_data + (offset&3)), val);
593   return PCIBIOS_SUCCESSFUL;
594}
595
596static int
597indirect_pci_write_config_dword(unsigned char bus, unsigned char dev_fn,
598                                unsigned char offset, unsigned int val) {
599   if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER;
600   out_be32(pci->config_addr,
601            0x80|(bus<<8)|(dev_fn<<16)|(offset<<24));
602   out_le32((volatile u_int *)pci->config_data, val);
603   return PCIBIOS_SUCCESSFUL;
604}
605
606static const struct pci_config_access_functions indirect_functions = {
607   indirect_pci_read_config_byte,
608   indirect_pci_read_config_word,
609   indirect_pci_read_config_dword,
610   indirect_pci_write_config_byte,
611   indirect_pci_write_config_word,
612   indirect_pci_write_config_dword
613};
614
615static int
616direct_pci_read_config_byte(unsigned char bus, unsigned char dev_fn,
617                            unsigned char offset, unsigned char *val) {
618   if (bus != 0 || (1<<PCI_SLOT(dev_fn) & 0xff8007fe)) {
619      *val=0xff;
620      return PCIBIOS_DEVICE_NOT_FOUND;
621   }
622   *val=in_8(pci->config_data + ((1<<PCI_SLOT(dev_fn))&~1)
623             + (PCI_FUNC(dev_fn)<<8) + offset);
624   return PCIBIOS_SUCCESSFUL;
625}
626
627static int
628direct_pci_read_config_word(unsigned char bus, unsigned char dev_fn,
629                            unsigned char offset, unsigned short *val) {
630   *val = 0xffff;
631   if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER;
632   if (bus != 0 || (1<<PCI_SLOT(dev_fn) & 0xff8007fe)) {
633      return PCIBIOS_DEVICE_NOT_FOUND;
634   }
635   *val=in_le16((volatile u_short *)
636                (pci->config_data + ((1<<PCI_SLOT(dev_fn))&~1)
637                 + (PCI_FUNC(dev_fn)<<8) + offset));
638   return PCIBIOS_SUCCESSFUL;
639}
640
641static int
642direct_pci_read_config_dword(unsigned char bus, unsigned char dev_fn,
643                             unsigned char offset, unsigned int *val) {
644   *val = 0xffffffff;
645   if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER;
646   if (bus != 0 || (1<<PCI_SLOT(dev_fn) & 0xff8007fe)) {
647      return PCIBIOS_DEVICE_NOT_FOUND;
648   }
649   *val=in_le32((volatile u_int *)
650                (pci->config_data + ((1<<PCI_SLOT(dev_fn))&~1)
651                 + (PCI_FUNC(dev_fn)<<8) + offset));
652   return PCIBIOS_SUCCESSFUL;
653}
654
655static int
656direct_pci_write_config_byte(unsigned char bus, unsigned char dev_fn,
657                             unsigned char offset, unsigned char val) {
658   if (bus != 0 || (1<<PCI_SLOT(dev_fn) & 0xff8007fe)) {
659      return PCIBIOS_DEVICE_NOT_FOUND;
660   }
661   out_8(pci->config_data + ((1<<PCI_SLOT(dev_fn))&~1)
662         + (PCI_FUNC(dev_fn)<<8) + offset,
663         val);
664   return PCIBIOS_SUCCESSFUL;
665}
666
667static int
668direct_pci_write_config_word(unsigned char bus, unsigned char dev_fn,
669                             unsigned char offset, unsigned short val) {
670   if (offset&1) return PCIBIOS_BAD_REGISTER_NUMBER;
671   if (bus != 0 || (1<<PCI_SLOT(dev_fn) & 0xff8007fe)) {
672      return PCIBIOS_DEVICE_NOT_FOUND;
673   }
674   out_le16((volatile u_short *)
675            (pci->config_data + ((1<<PCI_SLOT(dev_fn))&~1)
676             + (PCI_FUNC(dev_fn)<<8) + offset),
677            val);
678   return PCIBIOS_SUCCESSFUL;
679}
680
681static int
682direct_pci_write_config_dword(unsigned char bus, unsigned char dev_fn,
683                              unsigned char offset, unsigned int val) {
684   if (offset&3) return PCIBIOS_BAD_REGISTER_NUMBER;
685   if (bus != 0 || (1<<PCI_SLOT(dev_fn) & 0xff8007fe)) {
686      return PCIBIOS_DEVICE_NOT_FOUND;
687   }
688   out_le32((volatile u_int *)
689            (pci->config_data + ((1<<PCI_SLOT(dev_fn))&~1)
690             + (PCI_FUNC(dev_fn)<<8) + offset),
691            val);
692   return PCIBIOS_SUCCESSFUL;
693}
694
695static const struct pci_config_access_functions direct_functions = {
696   direct_pci_read_config_byte,
697   direct_pci_read_config_word,
698   direct_pci_read_config_dword,
699   direct_pci_write_config_byte,
700   direct_pci_write_config_word,
701   direct_pci_write_config_dword
702};
703
704void pci_read_bases(struct pci_dev *dev, unsigned int howmany)
705{
706   unsigned int reg, nextreg;
707
708#define REG (PCI_BASE_ADDRESS_0 + (reg<<2))
709
710   u_short cmd;
711   u32 l, ml;
712   pci_read_config_word(dev, PCI_COMMAND, &cmd);
713
714   for(reg=0; reg<howmany; reg=nextreg)
715   {
716      pci_resource *r;
717
718      nextreg=reg+1;
719      pci_read_config_dword(dev, REG, &l);
720#if 0
721      if (l == 0xffffffff /*AJF || !l*/) continue;
722#endif
723      /* Note that disabling the memory response of a host bridge
724       * would lose data if a DMA transfer were in progress. In a
725       * bootloader we don't care however. Also we can't print any
726       * message for a while since we might just disable the console.
727       */
728      pci_write_config_word(dev, PCI_COMMAND, cmd &
729                            ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY));
730      pci_write_config_dword(dev, REG, ~0);
731      pci_read_config_dword(dev, REG, &ml);
732      pci_write_config_dword(dev, REG, l);
733
734      /* Reenable the device now that we've played with
735       * base registers.
736       */
737      pci_write_config_word(dev, PCI_COMMAND, cmd);
738
739      /* seems to be an unused entry skip it */
740      if ( ml == 0 || ml == 0xffffffff ) continue;
741
742      if ((l &
743           (PCI_BASE_ADDRESS_SPACE|PCI_BASE_ADDRESS_MEM_TYPE_MASK))
744          == (PCI_BASE_ADDRESS_MEM_TYPE_64
745              |PCI_BASE_ADDRESS_SPACE_MEMORY)) {
746         nextreg=reg+2;
747      }
748      dev->base_address[reg] = l;
749      r = salloc(sizeof(pci_resource));
750      if (!r) {
751         printk("Error allocating pci_resource struct.\n");
752         continue;
753      }
754      r->dev = dev;
755      r->reg = reg;
756      if ((l&PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
757         r->type = l&~PCI_BASE_ADDRESS_IO_MASK;
758         r->base = l&PCI_BASE_ADDRESS_IO_MASK;
759         /* r->size = ~(ml&PCI_BASE_ADDRESS_IO_MASK)+1; */
760      } else {
761         r->type = l&~PCI_BASE_ADDRESS_MEM_MASK;
762         r->base = l&PCI_BASE_ADDRESS_MEM_MASK;
763         /* r->size = ~(ml&PCI_BASE_ADDRESS_MEM_MASK)+1; */
764      }
765
766      /* find the first bit set to one after the base
767         address type bits to find length of region */
768      {
769         unsigned int c= 16 , val= 0;
770         while( !(val= ml & c) ) c <<= 1;
771         r->size = val;
772      }
773
774#ifdef PCI_DEBUG
775      printk("   readbase bus %d, (%04x:%04x), base %08x, size %08x, type %d\n",
776             r->dev->bus->number,
777             r->dev->vendor,
778             r->dev->device,
779             r->base,
780             r->size,
781             r->type );
782#endif
783
784      /* Check for the blacklisted entries */
785      insert_resource(r);
786   }
787}
788
789u_int pci_scan_bus(struct pci_bus *bus)
790{
791   unsigned int devfn, l, max, class;
792   unsigned char irq, hdr_type, is_multi = 0;
793   struct pci_dev *dev, **bus_last;
794   struct pci_bus *child;
795
796#if 0
797   printk("scanning pci bus %d\n", bus->number );
798#endif
799
800   bus_last = &bus->devices;
801   max = bus->secondary;
802   for (devfn = 0; devfn < 0xff; ++devfn) {
803      if (PCI_FUNC(devfn) && !is_multi) {
804         /* not a multi-function device */
805         continue;
806      }
807      if (pcibios_read_config_byte(bus->number, devfn, PCI_HEADER_TYPE, &hdr_type))
808         continue;
809      if (!PCI_FUNC(devfn))
810         is_multi = hdr_type & 0x80;
811
812      if (pcibios_read_config_dword(bus->number, devfn, PCI_VENDOR_ID, &l) ||
813          /* some broken boards return 0 if a slot is empty: */
814          l == 0xffffffff || l == 0x00000000 || l == 0x0000ffff || l == 0xffff0000) {
815         is_multi = 0;
816         continue;
817      }
818
819      dev = salloc(sizeof(*dev));
820      dev->bus = bus;
821      dev->devfn  = devfn;
822      dev->vendor = l & 0xffff;
823      dev->device = (l >> 16) & 0xffff;
824
825      pcibios_read_config_dword(bus->number, devfn,
826                                PCI_CLASS_REVISION, &class);
827      class >>= 8;                                  /* upper 3 bytes */
828      dev->class = class;
829      class >>= 8;
830      dev->hdr_type = hdr_type;
831
832      switch (hdr_type & 0x7f) {                    /* header type */
833         case PCI_HEADER_TYPE_NORMAL:               /* standard header */
834            if (class == PCI_CLASS_BRIDGE_PCI)
835               goto bad;
836            /*
837             * If the card generates interrupts, read IRQ number
838             * (some architectures change it during pcibios_fixup())
839             */
840            pcibios_read_config_byte(bus->number, dev->devfn, PCI_INTERRUPT_PIN, &irq);
841            if (irq)
842               pcibios_read_config_byte(bus->number, dev->devfn, PCI_INTERRUPT_LINE, &irq);
843            dev->irq = irq;
844            /*
845             * read base address registers, again pcibios_fixup() can
846             * tweak these
847             */
848            pci_read_bases(dev, 6);
849            pcibios_read_config_dword(bus->number, devfn, PCI_ROM_ADDRESS, &l);
850            dev->rom_address = (l == 0xffffffff) ? 0 : l;
851            break;
852         case PCI_HEADER_TYPE_BRIDGE:               /* bridge header */
853            if (class != PCI_CLASS_BRIDGE_PCI)
854               goto bad;
855            pci_read_bases(dev, 2);
856            pcibios_read_config_dword(bus->number, devfn, PCI_ROM_ADDRESS1, &l);
857            dev->rom_address = (l == 0xffffffff) ? 0 : l;
858            break;
859         case PCI_HEADER_TYPE_CARDBUS:              /* CardBus bridge header */
860            if (class != PCI_CLASS_BRIDGE_CARDBUS)
861               goto bad;
862            pci_read_bases(dev, 1);
863            break;
864
865         default:                                   /* unknown header */
866        bad:
867            printk("PCI device with unknown header type %d ignored.\n",
868                   hdr_type&0x7f);
869            continue;
870      }
871
872      /*
873       * Put it into the global PCI device chain. It's used to
874       * find devices once everything is set up.
875       */
876      *pci->last_dev_p = dev;
877      pci->last_dev_p = &dev->next;
878
879      /*
880       * Now insert it into the list of devices held
881       * by the parent bus.
882       */
883      *bus_last = dev;
884      bus_last = &dev->sibling;
885
886   }
887
888   /*
889    * After performing arch-dependent fixup of the bus, look behind
890    * all PCI-to-PCI bridges on this bus.
891    */
892   for(dev=bus->devices; dev; dev=dev->sibling)
893      /*
894       * If it's a bridge, scan the bus behind it.
895       */
896      if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
897         unsigned int buses;
898         unsigned int devfn = dev->devfn;
899         unsigned short cr;
900
901         /*
902          * Insert it into the tree of buses.
903          */
904         child = salloc(sizeof(*child));
905         child->next = bus->children;
906         bus->children = child;
907         child->self = dev;
908         child->parent = bus;
909
910         /*
911          * Set up the primary, secondary and subordinate
912          * bus numbers.
913          */
914         child->number = child->secondary = ++max;
915         child->primary = bus->secondary;
916         child->subordinate = 0xff;
917         /*
918          * Clear all status bits and turn off memory,
919          * I/O and master enables.
920          */
921         pcibios_read_config_word(bus->number, devfn, PCI_COMMAND, &cr);
922         pcibios_write_config_word(bus->number, devfn, PCI_COMMAND, 0x0000);
923         pcibios_write_config_word(bus->number, devfn, PCI_STATUS, 0xffff);
924         /*
925          * Read the existing primary/secondary/subordinate bus
926          * number configuration to determine if the PCI bridge
927          * has already been configured by the system.  If so,
928          * do not modify the configuration, merely note it.
929          */
930         pcibios_read_config_dword(bus->number, devfn, PCI_PRIMARY_BUS, &buses);
931         if ((buses & 0xFFFFFF) != 0)
932         {
933            unsigned int cmax;
934
935            child->primary = buses & 0xFF;
936            child->secondary = (buses >> 8) & 0xFF;
937            child->subordinate = (buses >> 16) & 0xFF;
938            child->number = child->secondary;
939            cmax = pci_scan_bus(child);
940            if (cmax > max) max = cmax;
941         }
942         else
943         {
944            /*
945             * Configure the bus numbers for this bridge:
946             */
947            buses &= 0xff000000;
948            buses |=
949               (((unsigned int)(child->primary)     <<  0) |
950                ((unsigned int)(child->secondary)   <<  8) |
951                ((unsigned int)(child->subordinate) << 16));
952            pcibios_write_config_dword(bus->number, devfn, PCI_PRIMARY_BUS, buses);
953            /*
954             * Now we can scan all subordinate buses:
955             */
956            max = pci_scan_bus(child);
957            /*
958             * Set the subordinate bus number to its real
959             * value:
960             */
961            child->subordinate = max;
962            buses = (buses & 0xff00ffff)
963               | ((unsigned int)(child->subordinate) << 16);
964            pcibios_write_config_dword(bus->number, devfn, PCI_PRIMARY_BUS, buses);
965         }
966         pcibios_write_config_word(bus->number, devfn, PCI_COMMAND, cr );
967      }
968
969   /*
970    * We've scanned the bus and so we know all about what's on
971    * the other side of any bridges that may be on this bus plus
972    * any devices.
973    *
974    * Return how far we've got finding sub-buses.
975    */
976   return max;
977}
978
979#if 0
980
981void
982pci_fixup(void)
983{
984   struct pci_dev *p;
985   struct pci_bus *bus;
986
987   for (bus = &pci_root; bus; bus=bus->next)
988   {
989      for (p=bus->devices; p; p=p->sibling)
990      {
991      }
992   }
993}
994
995static void print_pci_info()
996{
997   pci_resource *r;
998   struct pci_bus *pb = &pci_root;
999
1000   printk("\n");
1001   printk("PCI busses:\n");
1002
1003   for(pb= &pci_root; pb; pb=pb->children )
1004   {
1005      printk("   number %d, primary %d, secondary %d, subordinate %d\n",
1006             pb->number,
1007             pb->primary,
1008             pb->secondary,
1009             pb->subordinate );
1010      printk("   bridge; vendor %04x, device %04x\n",
1011             pb->self->vendor,
1012             pb->self->device );
1013
1014      {
1015         struct pci_dev *pd;
1016
1017         for(pd= pb->devices; pd; pd=pd->sibling )
1018         {
1019            printk("       vendor %04x, device %04x, irq %d\n",
1020                   pd->vendor,
1021                   pd->device,
1022                   pd->irq );
1023
1024         }
1025         printk("\n");
1026      }
1027
1028   }
1029   printk("\n");
1030
1031   printk("PCI resources:\n");
1032   for (r=pci->resources; r; r= r->next)
1033   {
1034      printk("   bus %d, vendor %04x, device %04x, base %08x, size %08x, type %d\n",
1035             r->dev->bus->number,
1036             r->dev->vendor,
1037             r->dev->device,
1038             r->base,
1039             r->size,
1040             r->type );
1041   }
1042   printk("\n");
1043
1044   return;
1045}
1046
1047#endif
1048
1049static struct _addr_start
1050{
1051      uint32_t   start_pcimem;
1052      uint32_t   start_pciio;
1053      uint32_t   start_prefetch;
1054} astart;
1055
1056static pci_resource *enum_device_resources( struct pci_dev *pdev, int i )
1057{
1058   pci_resource *r;
1059
1060   for(r= pci->resources; r; r= r->next )
1061   {
1062      if( r->dev == pdev )
1063      {
1064         if( i-- == 0 ) break;
1065      }
1066   }
1067   return r;
1068}
1069
1070static void recursive_bus_reconfigure( struct pci_bus *pbus )
1071{
1072   struct pci_dev       *pdev;
1073   struct pci_bus       *childbus;
1074   int  isroot = 0;
1075
1076   if( !pbus )
1077   {
1078      /* start with the root bus */
1079      astart.start_pcimem   = BUSREST_MEM_START;
1080      astart.start_pciio    = BUSREST_IO_START;
1081      astart.start_prefetch = ((BUSREST_MEM_END >> 16) << 16);
1082
1083      pbus = &pci_root;
1084      isroot = -1;
1085   }
1086
1087#define WRITE_BRIDGE_IO
1088#define WRITE_BRIDGE_MEM
1089#define WRITE_BRIDGE_PF
1090#define WRITE_BRIDGE_ENABLE
1091
1092/*
1093** Run thru the p2p bridges on this bus and recurse into subordinate busses
1094*/
1095   for( childbus= pbus->children; childbus; childbus= childbus->next )
1096   {
1097      pdev= childbus->self;
1098
1099      pcibios_write_config_byte(pdev->bus->number, pdev->devfn, PCI_LATENCY_TIMER,     0x80 );
1100      pcibios_write_config_byte(pdev->bus->number, pdev->devfn, PCI_SEC_LATENCY_TIMER, 0x80 );
1101
1102      {
1103         struct _addr_start   addrhold;
1104         uint8_t              base8, limit8;
1105         uint16_t             base16, limit16, ubase16, ulimit16;
1106
1107         /* save the base address values */
1108         memcpy( &addrhold, &astart, sizeof(struct _addr_start));
1109
1110         recursive_bus_reconfigure( childbus );
1111
1112#ifdef PCI_DEBUG
1113         printk("pci: configuring bus %d bridge (%04x:%04x), bus %d : (%d-%d)\n",
1114                pdev->bus->number,
1115                pdev->vendor,
1116                pdev->device,
1117                childbus->primary,
1118                childbus->secondary,
1119                childbus->subordinate );
1120#endif
1121
1122         /*
1123          * use the current values & the saved ones to figure out
1124          * the address spaces for the bridge
1125          */
1126
1127         if( addrhold.start_pciio == astart.start_pciio )
1128         {
1129            base8 = limit8 = 0xff;
1130            ubase16 = ulimit16 = 0xffff;
1131         }
1132         else
1133         {
1134            base8    = (uint8_t) ((addrhold.start_pciio >> 8) & 0xf0);
1135            ubase16  = (uint16_t)(addrhold.start_pciio >> 16);
1136            limit8   = (uint8_t) ((astart.start_pciio >> 8 ) & 0xf0);
1137            ulimit16 = (uint16_t)(astart.start_pciio >> 16);
1138            astart.start_pciio += 0x1000;
1139         }
1140
1141#ifdef PCI_DEBUG
1142         printk("pci:     io base %08x limit %08x\n", (base8<<8)+(ubase16<<16), (limit8<<8)+(ulimit16<<16));
1143#endif
1144#ifdef WRITE_BRIDGE_IO
1145         pcibios_write_config_word(pdev->bus->number, pdev->devfn, PCI_IO_BASE_UPPER16, ubase16 );
1146         pcibios_write_config_byte(pdev->bus->number, pdev->devfn, PCI_IO_BASE, base8 );
1147
1148         pcibios_write_config_word(pdev->bus->number, pdev->devfn, PCI_IO_LIMIT_UPPER16, ulimit16 );
1149         pcibios_write_config_byte(pdev->bus->number, pdev->devfn, PCI_IO_LIMIT, limit8 );
1150#endif
1151
1152         if( addrhold.start_pcimem == astart.start_pcimem )
1153         {
1154            limit16 = 0;
1155            base16 = 0xffff;
1156         }
1157         else
1158         {
1159            limit16= (uint16_t)((astart.start_pcimem >> 16) & 0xfff0);
1160            base16 = (uint16_t)((addrhold.start_pcimem >> 16) & 0xfff0);
1161            astart.start_pcimem += 0x100000;
1162         }
1163#ifdef PCI_DEBUG
1164         printk("pci:      memory %04x, limit %04x\n", base16, limit16);
1165#endif
1166#ifdef WRITE_BRIDGE_MEM
1167         pcibios_write_config_word(pdev->bus->number, pdev->devfn, PCI_MEMORY_BASE, base16 );
1168         pcibios_write_config_word(pdev->bus->number, pdev->devfn, PCI_MEMORY_LIMIT, limit16 );
1169#endif
1170
1171
1172         if( astart.start_prefetch == addrhold.start_prefetch )
1173         {
1174            limit16 = 0;
1175            base16 = 0xffff;
1176         }
1177         else
1178         {
1179            limit16= (uint16_t)((addrhold.start_prefetch >> 16) & 0xfff0);
1180            base16 = (uint16_t)((astart.start_prefetch >> 16) & 0xfff0);
1181            astart.start_prefetch -= 0x100000;
1182         }
1183#ifdef PCI_DEBUG
1184         printk("pci:   pf memory %04x, limit %04x\n", base16, limit16);
1185#endif
1186#ifdef WRITE_BRIDGE_PF
1187         pcibios_write_config_dword(pdev->bus->number, pdev->devfn, PCI_PREF_BASE_UPPER32, 0);
1188         pcibios_write_config_word(pdev->bus->number, pdev->devfn, PCI_PREF_MEMORY_BASE, base16 );
1189         pcibios_write_config_dword(pdev->bus->number, pdev->devfn, PCI_PREF_LIMIT_UPPER32, 0);
1190         pcibios_write_config_word(pdev->bus->number, pdev->devfn, PCI_PREF_MEMORY_LIMIT, limit16 );
1191#endif
1192
1193#ifdef WRITE_BRIDGE_ENABLE
1194         pcibios_write_config_word(pdev->bus->number,
1195                                   pdev->devfn,
1196                                   PCI_BRIDGE_CONTROL,
1197                                   (unsigned16)( 0 ));
1198
1199         pcibios_write_config_word(pdev->bus->number,
1200                                   pdev->devfn,
1201                                   PCI_COMMAND,
1202                                   (unsigned16)( PCI_COMMAND_IO |
1203                                                 PCI_COMMAND_MEMORY |
1204                                                 PCI_COMMAND_MASTER ));
1205#endif
1206      }
1207   }
1208
1209   if( !isroot )
1210   {
1211#ifdef PCI_DEBUG
1212      printk("pci: Configuring devices on bus %d\n", pbus->number);
1213#endif
1214      /*
1215      ** Run thru this bus and set up addresses for all the non-bridge devices
1216      */
1217      for( pdev = pbus->devices; pdev; pdev= pdev->sibling )
1218      {
1219         if( (pdev->class >> 8) != PCI_CLASS_BRIDGE_PCI )
1220         {
1221            pci_resource *r;
1222            int i = 0;
1223            unsigned alloc;
1224
1225            /* enumerate all the resources defined by this device & reserve space
1226            ** for each of their defined regions.
1227            */
1228
1229#ifdef PCI_DEBUG
1230            printk("pci: configuring; vendor %04x, device %04x\n", pdev->vendor, pdev->device );
1231#endif
1232
1233            while( (r= enum_device_resources( pdev, i++ )) )
1234            {
1235               /*
1236               ** Force all memory spaces to be non-prefetchable because
1237               ** on the pci bus, byte-wise reads against prefetchable
1238               ** memory are applied as 32 bit reads, which is a pain
1239               ** when you're trying to talk to hardware.  This is a
1240               ** little sub-optimal because the algorithm doesn't sort
1241               ** the address regions to pack them in, OTOH, perhaps its
1242               ** not so bad because the inefficient packing will help
1243               ** avoid buffer overflow/underflow problems.
1244               */
1245#if 0
1246               if( (r->type & PCI_BASE_ADDRESS_MEM_PREFETCH) )
1247               {
1248                  /* prefetchable space */
1249
1250                  /* shift base pointer down to an integer multiple of the size of the desired region */
1251                  astart.start_prefetch -= (alloc= ((r->size / PAGE_SIZE) + 1) * PAGE_SIZE);
1252                  /* shift base pointer down to an integer multiple of the size of the desired region */
1253                  astart.start_prefetch = (astart.start_prefetch / r->size) * r->size;
1254
1255                  r->base = astart.start_prefetch;
1256#ifdef PCI_DEBUG
1257                  printk("pci:       pf %08X, size %08X, alloc %08X\n", r->base, r->size, alloc );
1258#endif
1259               }
1260#endif
1261               if( r->type & PCI_BASE_ADDRESS_SPACE_IO )
1262               {
1263                  /* io space */
1264
1265                  /* shift base pointer up to an integer multiple of the size of the desired region */
1266                  if( astart.start_pciio % r->size )
1267                     astart.start_pciio = (((astart.start_pciio / r->size) + 1) * r->size);
1268
1269                  r->base = astart.start_pciio;
1270                  astart.start_pciio += (alloc= ((r->size / PAGE_SIZE) + 1) * PAGE_SIZE);
1271#ifdef PCI_DEBUG
1272                  printk("pci:      io  %08X, size %08X, alloc %08X\n", r->base, r->size, alloc );
1273#endif
1274               }
1275               else
1276               {
1277                  /* memory space */
1278
1279                  /* shift base pointer up to an integer multiple of the size of the desired region */
1280                  if( astart.start_pcimem % r->size )
1281                     astart.start_pcimem = (((astart.start_pcimem / r->size) + 1) * r->size);
1282
1283                  r->base = astart.start_pcimem;
1284                  astart.start_pcimem += (alloc= ((r->size / PAGE_SIZE) + 1) * PAGE_SIZE);
1285#ifdef PCI_DEBUG
1286                  printk("pci:      mem %08X, size %08X, alloc %08X\n", r->base, r->size, alloc );
1287#endif
1288               }
1289            }
1290
1291         }
1292      }
1293   }
1294
1295}
1296
1297void pci_init(void)
1298{
1299   PPC_DEVICE *hostbridge;
1300
1301   if (pci->last_dev_p) {
1302      printk("Two or more calls to pci_init!\n");
1303      return;
1304   }
1305   pci->last_dev_p = &(bd->pci_devices);
1306   hostbridge=residual_find_device(PROCESSORDEVICE, NULL,
1307                                   BridgeController,
1308                                   PCIBridge, -1, 0);
1309   if (hostbridge) {
1310      if (hostbridge->DeviceId.Interface==PCIBridgeIndirect) {
1311         bd->pci_functions=&indirect_functions;
1312         /* Should be extracted from residual data,
1313          * indeed MPC106 in CHRP mode is different,
1314          * but we should not use residual data in
1315          * this case anyway.
1316          */
1317         pci->config_addr = ((volatile u_int *)
1318                             (ptr_mem_map->io_base+0xcf8));
1319         pci->config_data = ptr_mem_map->io_base+0xcfc;
1320      } else if(hostbridge->DeviceId.Interface==PCIBridgeDirect) {
1321         bd->pci_functions=&direct_functions;
1322         pci->config_data=(u_char *) 0x80800000;
1323      } else {
1324      }
1325   } else {
1326      /* Let us try by experimentation at our own risk! */
1327      u_int id0;
1328      bd->pci_functions = &direct_functions;
1329      /* On all direct bridges I know the host bridge itself
1330       * appears as device 0 function 0.
1331       */
1332      pcibios_read_config_dword(0, 0, PCI_VENDOR_ID, &id0);
1333      if (id0==~0U) {
1334         bd->pci_functions = &indirect_functions;
1335         pci->config_addr = ((volatile u_int *)
1336                             (ptr_mem_map->io_base+0xcf8));
1337         pci->config_data = ptr_mem_map->io_base+0xcfc;
1338      }
1339      /* Here we should check that the host bridge is actually
1340       * present, but if it not, we are in such a desperate
1341       * situation, that we probably can't even tell it.
1342       */
1343   }
1344   /* Now build a small database of all found PCI devices */
1345   printk("\nPCI: Probing PCI hardware\n");
1346   pci_root.subordinate=pci_scan_bus(&pci_root);
1347
1348   print_pci_resources("Installed PCI resources:\n");
1349
1350   recursive_bus_reconfigure(NULL);
1351
1352   reconfigure_pci();
1353
1354   print_pci_resources("Allocated PCI resources:\n");
1355
1356#if 0
1357   print_pci_info();
1358#endif
1359}
1360
1361/* eof */
Note: See TracBrowser for help on using the repository browser.