source: rtems/bsps/powerpc/mvme3100/pci/detect_host_bridge.c @ 65f868c

5
Last change on this file since 65f868c was 5a4e3dc0, checked in by Sebastian Huber <sebastian.huber@…>, on 04/23/18 at 10:50:58

bsps: Move PCI drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/* PCI Initialization */
2
3/*
4 * Authorship
5 * ----------
6 * This software ('mvme3100' RTEMS BSP) was created by
7 *
8 *     Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
9 *         Stanford Linear Accelerator Center, Stanford University.
10 *
11 * Acknowledgement of sponsorship
12 * ------------------------------
13 * The 'mvme3100' BSP was produced by
14 *     the Stanford Linear Accelerator Center, Stanford University,
15 *         under Contract DE-AC03-76SFO0515 with the Department of Energy.
16 *
17 * Government disclaimer of liability
18 * ----------------------------------
19 * Neither the United States nor the United States Department of Energy,
20 * nor any of their employees, makes any warranty, express or implied, or
21 * assumes any legal liability or responsibility for the accuracy,
22 * completeness, or usefulness of any data, apparatus, product, or process
23 * disclosed, or represents that its use would not infringe privately owned
24 * rights.
25 *
26 * Stanford disclaimer of liability
27 * --------------------------------
28 * Stanford University makes no representations or warranties, express or
29 * implied, nor assumes any liability for the use of this software.
30 *
31 * Stanford disclaimer of copyright
32 * --------------------------------
33 * Stanford University, owner of the copyright, hereby disclaims its
34 * copyright and all other rights in this software.  Hence, anyone may
35 * freely use it for any purpose without restriction.
36 *
37 * Maintenance of notices
38 * ----------------------
39 * In the interest of clarity regarding the origin and status of this
40 * SLAC software, this and all the preceding Stanford University notices
41 * are to remain affixed to any copy or derivative of this software made
42 * or distributed by the recipient and are to be affixed to any copy of
43 * software made or distributed by the recipient that contains a copy or
44 * derivative of this software.
45 *
46 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
47 */
48
49#include <bsp.h>
50#include <bsp/pci.h>
51#include <bsp/irq.h>
52#include <bsp/openpic.h>
53#include <inttypes.h>
54
55/* Motload configures PCI interrupts to start at 16 and up but
56 * we'd rather have them starting at 0.
57 * Use this callback to fix them up.
58 */
59static int
60fixup_irq_line(int bus, int slot, int fun, void *uarg)
61{
62unsigned char line;
63        pci_read_config_byte( bus, slot, fun, PCI_INTERRUPT_LINE, &line);
64        if ( line >= BSP_EXT_IRQ_NUMBER ) {
65                pci_write_config_byte( bus, slot, fun, PCI_INTERRUPT_LINE, line - BSP_EXT_IRQ_NUMBER );
66        }
67
68        return 0;
69}
70
71void BSP_motload_pci_fixup(void)
72{
73  BSP_pciScan(0, fixup_irq_line, 0);
74}
75
76void detect_host_bridge(void)
77{
78  OpenPIC = (volatile struct OpenPIC *) (BSP_8540_CCSR_BASE + BSP_OPEN_PIC_BASE_OFFSET);
79}
80
81static int
82dump_dev_cb(
83   int bus,
84   int dev,
85   int fun,
86   void *uarg
87)
88{
89  uint16_t vi,di;
90  uint16_t cd,st;
91  uint32_t b1,b2;
92  uint8_t  il,ip;
93
94        pci_read_config_word (bus, dev, fun, PCI_VENDOR_ID,      &vi);
95        pci_read_config_word (bus, dev, fun, PCI_DEVICE_ID,      &di);
96        pci_read_config_word (bus, dev, fun, PCI_COMMAND,        &cd);
97        pci_read_config_word (bus, dev, fun, PCI_STATUS,         &st);
98        pci_read_config_dword(bus, dev, fun, PCI_BASE_ADDRESS_0, &b1);
99        pci_read_config_dword(bus, dev, fun, PCI_BASE_ADDRESS_1, &b2);
100        pci_read_config_byte (bus, dev, fun, PCI_INTERRUPT_LINE, &il);
101        pci_read_config_byte (bus, dev, fun, PCI_INTERRUPT_PIN,  &ip);
102
103    printk("%3d:0x%02x:%d    0x%04x-0x%04x:  0x%04x 0x%04x 0x%08" PRIx32 " 0x%08" PRIx32 "       %d -> %3d (=0x%02x)\n",
104                bus, dev, fun, vi, di, cd, st, b1, b2, ip, il, il);
105        return 0;
106}
107
108void
109BSP_pciConfigDump_early(void)
110{
111        printk("BUS:SLOT:FUN  VENDOR-DEV_ID: COMMAND STATUS BASE_ADDR0 BASE_ADDR1 IRQ_PIN -> IRQ_LINE\n");
112        BSP_pciScan(0, dump_dev_cb, 0);
113}
Note: See TracBrowser for help on using the repository browser.