~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/skiboot/platforms/ibm-fsp/apollo-pci.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2013-2015 IBM Corp.
 
2
 *
 
3
 * Licensed under the Apache License, Version 2.0 (the "License");
 
4
 * you may not use this file except in compliance with the License.
 
5
 * You may obtain a copy of the License at
 
6
 *
 
7
 *      http://www.apache.org/licenses/LICENSE-2.0
 
8
 *
 
9
 * Unless required by applicable law or agreed to in writing, software
 
10
 * distributed under the License is distributed on an "AS IS" BASIS,
 
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
12
 * implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
#include <skiboot.h>
 
18
#include <device.h>
 
19
#include <fsp.h>
 
20
#include <p7ioc.h>
 
21
#include <pci-cfg.h>
 
22
#include <pci.h>
 
23
#include <pci-slot.h>
 
24
 
 
25
#include "ibm-fsp.h"
 
26
#include "lxvpd.h"
 
27
 
 
28
/* Debugging option */
 
29
#define APOLLO_PCI_DBG(fmt, a...)       \
 
30
        prlog(PR_DEBUG, "APOLLO-PCI: " fmt, ##a)
 
31
#define APOLLO_PCI_INFO(fmt, a...)      \
 
32
        prlog(PR_INFO, "APOLLO-PCI: " fmt, ##a)
 
33
#define APOLLO_PCI_ERR(fmt, a...)       \
 
34
        prlog(PR_ERR, "APOLLO-PCI: " fmt, ##a)
 
35
 
 
36
void apollo_pci_setup_phb(struct phb *phb, unsigned int index)
 
37
{
 
38
        struct dt_node *ioc_node;
 
39
 
 
40
        /* Grab the device-tree node of the IOC */
 
41
        ioc_node = phb->dt_node->parent;
 
42
        if (!ioc_node) {
 
43
                APOLLO_PCI_DBG("No IOC devnode for PHB%04x\n",
 
44
                               phb->opal_id);
 
45
                return;
 
46
        }
 
47
 
 
48
        /*
 
49
         * Process the pcie slot entries from the lx vpd lid
 
50
         *
 
51
         * FIXME: We currently assume chip 1 always, this will have to be
 
52
         * fixed once we understand the right way to get the BRxy/BRxy "x"
 
53
         * "x" value. It's not working well. I found 2 different root ports
 
54
         * on Firebird-L has been assigned to same slot label.
 
55
         */
 
56
        lxvpd_process_slot_entries(phb, ioc_node, 1,
 
57
                                   index, sizeof(struct lxvpd_pci_slot));
 
58
}
 
59
 
 
60
void apollo_pci_get_slot_info(struct phb *phb, struct pci_device *pd)
 
61
{
 
62
        struct pci_slot *slot;
 
63
        struct lxvpd_pci_slot *s = NULL;
 
64
 
 
65
        if (pd->dev_type != PCIE_TYPE_ROOT_PORT     &&
 
66
            pd->dev_type != PCIE_TYPE_SWITCH_UPPORT &&
 
67
            pd->dev_type != PCIE_TYPE_SWITCH_DNPORT &&
 
68
            pd->dev_type != PCIE_TYPE_PCIE_TO_PCIX)
 
69
                return;
 
70
 
 
71
        /* Create PCIe slot */
 
72
        slot = pcie_slot_create(phb, pd);
 
73
        if (!slot)
 
74
                return;
 
75
 
 
76
        /* Root complex inherits methods from PHB slot */
 
77
        if (!pd->parent && phb->slot)
 
78
                memcpy(&slot->ops, &phb->slot->ops, sizeof(struct pci_slot_ops));
 
79
 
 
80
        /* Patch PCIe slot */
 
81
        s = lxvpd_get_slot(slot);
 
82
        if (s) {
 
83
                lxvpd_extract_info(slot, s);
 
84
                slot->ops.add_properties = lxvpd_add_slot_properties;
 
85
        }
 
86
}