Subversion Repositories Kolibri OS

Rev

Rev 1633 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1628 serge 1
 
2
#include 
3
#include 
4
#include 
5
#include 
6
7
 
8
#include "acpi_bus.h"
9
10
 
11
 
12
13
 
14
 
15
    struct list_head node;
16
    ACPI_HANDLE handle;
17
};
18
19
 
20
    {"PNP0A03", 0},
21
    {"", 0},
22
};
23
24
 
1633 serge 25
1628 serge 26
 
27
 
28
 * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge
29
 * @handle - the ACPI CA node in question.
30
 *
31
 * Note: we could make this API take a struct acpi_device * instead, but
32
 * for now, it's more convenient to operate on an acpi_handle.
33
 */
34
int acpi_is_root_bridge(ACPI_HANDLE handle)
35
{
36
    int ret;
37
    struct acpi_device *device;
38
39
 
40
    if (ret)
41
        return 0;
42
43
 
44
    if (ret)
45
        return 0;
46
    else
47
        return 1;
48
}
49
50
 
51
 
52
{
53
    struct acpi_pci_root *root;
54
55
 
56
        if (root->device->handle == handle)
57
            return root;
58
    }
59
    return NULL;
60
}
61
62
 
63
 
64
 * acpi_get_pci_dev - convert ACPI CA handle to struct pci_dev
65
 * @handle: the handle in question
66
 *
67
 * Given an ACPI CA handle, the desired PCI device is located in the
68
 * list of PCI devices.
69
 *
70
 * If the device is found, its reference count is increased and this
71
 * function returns a pointer to its data structure.  The caller must
72
 * decrement the reference count by calling pci_dev_put().
73
 * If no device is found, %NULL is returned.
74
 */
75
struct pci_dev *acpi_get_pci_dev(ACPI_HANDLE handle)
76
{
77
    int dev, fn;
78
    unsigned long long adr;
79
    ACPI_STATUS status;
80
    ACPI_HANDLE phandle;
81
    struct pci_bus *pbus;
82
    struct pci_dev *pdev = NULL;
83
    struct acpi_handle_node *node, *tmp;
84
    struct acpi_pci_root *root;
85
    LIST_HEAD(device_list);
86
87
 
88
     * Walk up the ACPI CA namespace until we reach a PCI root bridge.
89
     */
90
    phandle = handle;
91
    while (!acpi_is_root_bridge(phandle)) {
92
        node = kzalloc(sizeof(struct acpi_handle_node), GFP_KERNEL);
93
        if (!node)
94
            goto out;
95
96
 
97
        node->handle = phandle;
98
        list_add(&node->node, &device_list);
99
100
 
101
        if (ACPI_FAILURE(status))
102
            goto out;
103
    }
104
105
 
106
    if (!root)
107
        goto out;
108
109
 
110
111
 
112
     * Now, walk back down the PCI device tree until we return to our
113
     * original handle. Assumes that everything between the PCI root
114
     * bridge and the device we're looking for must be a P2P bridge.
115
     */
116
    list_for_each_entry(node, &device_list, node) {
117
        ACPI_HANDLE hnd = node->handle;
118
        status = acpi_evaluate_integer(hnd, "_ADR", NULL, &adr);
119
        if (ACPI_FAILURE(status))
120
            goto out;
121
        dev = (adr >> 16) & 0xffff;
122
        fn  = adr & 0xffff;
123
124
 
125
        if (!pdev || hnd == handle)
126
            break;
127
128
 
129
//        pci_dev_put(pdev);
130
131
 
132
         * This function may be called for a non-PCI device that has a
133
         * PCI parent (eg. a disk under a PCI SATA controller).  In that
134
         * case pdev->subordinate will be NULL for the parent.
135
         */
136
        if (!pbus) {
137
            dbgprintf("Not a PCI-to-PCI bridge\n");
138
            pdev = NULL;
139
            break;
140
        }
141
    }
142
out:
143
    list_for_each_entry_safe(node, tmp, &device_list, node)
144
        kfree(node);
145
146
 
147
}
148
149
 
1633 serge 150
 
151
{
152
    struct pci_dev *dev;
153
154
 
155
    {
156
        if(dev->pin)
1867 serge 157
        {
158
            dbgprintf("PCI_%x_%x bus:%d devfn: %x pin %d bios irq: %d acpi irq: %d\n",
159
                       dev->vendor, dev->device, dev->busnr, dev->devfn,
160
                       dev->pin, dev->irq, acpi_get_irq(dev));
161
        };
162
    };
1633 serge 163
}
164
165
 
166
{
167
    struct acpi_pci_root *root;
168
169
 
170
    {
171
        struct pci_bus *pbus, *tbus;
172
        struct pci_dev *dev;
173
174
 
175
176
 
177
        {
178
            if(dev->pin)
1867 serge 179
                dbgprintf("PCI_%x_%x bus:%d devfn: %x pin %d bios irq: %d acpi irq: %d\n",
180
                          dev->vendor, dev->device, dev->busnr, dev->devfn,
181
                          dev->pin, dev->irq, acpi_get_irq(dev));
182
        };
1633 serge 183
184
 
185
        {
186
            print_bus_irqs(tbus);
187
        };
188
    }
189
};
190