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

4.104.114.84.95
Last change on this file since a77cd066 was e831de8, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:38

2003-09-04 Joel Sherrill <joel@…>

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