1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
#include "local.h"
#include <linux/delay.h>
#include <linux/pci.h>
#include <linux/list.h>
#include <linux/init.h>
/* will include $(CONTRIB)/drivers/pci/pci.h */
#include "pci.h"
DECLARE_INITVAR(dde26_pci);
/** PCI device descriptor */
typedef struct l4dde_pci_dev {
struct list_head next; /**< chain info */
struct ddekit_pci_dev *ddekit_dev; /**< corresponding DDEKit descriptor */
struct pci_dev *linux_dev; /**< Linux descriptor */
} l4dde_pci_dev_t;
/*******************************************************************************************
** PCI data **
*******************************************************************************************/
/** List of Linux-DDEKit PCIDev mappings */
static LIST_HEAD(pcidev_mappings);
/** PCI bus */
static struct pci_bus *pci_bus = NULL;
static int l4dde26_pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val);
static int l4dde26_pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val);
/** PCI operations for our virtual PCI bus */
static struct pci_ops dde_pcibus_ops = {
.read = l4dde26_pci_read,
.write = l4dde26_pci_write,
};
/*******************************************************************************************
** Read/write PCI config space. This is simply mapped to the DDEKit functions. **
*******************************************************************************************/
static int l4dde26_pci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
{
return ddekit_pci_read(bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), where, size, val);
}
static int l4dde26_pci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
{
return ddekit_pci_write(bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn), where, size, val);
}
int pci_irq_enable(struct pci_dev *dev)
{
int irq = dev->irq;
int pin = 0;
int ret;
DEBUG_MSG("dev %p", dev);
if (!dev)
return -EINVAL;
pin = (int)dev->pin;
DEBUG_MSG("irq %d, pin %d", dev->irq, dev->pin);
if (!pin) {
dev_warn(&dev->dev,
"No interrupt pin configured for device %s\n",
pci_name(dev));
return 0;
}
pin--;
ret = ddekit_pci_irq_enable(dev->bus->number, PCI_SLOT(dev->devfn),
PCI_FUNC(dev->devfn), pin, &irq);
if (ret) {
dev_warn(&dev->dev, "Interrupt enable failed for device %s (%d)\n",
pci_name(dev), ret);
return -1;
}
dev_info(&dev->dev, "PCI INT %c -> GSI %d -> IRQ %d\n",
'A' + pin, irq, dev->irq);
dev->irq = irq;
return 0;
}
int __pci_enable_device(struct pci_dev *dev)
{
WARN_UNIMPL;
return 0;
}
/**
* pci_enable_device - Initialize device before it's used by a driver.
*
* Initialize device before it's used by a driver. Ask low-level code
* to enable I/O and memory. Wake up the device if it was suspended.
* Beware, this function can fail.
*
* \param dev PCI device to be initialized
*
*/
int
pci_enable_device(struct pci_dev *dev)
{
CHECK_INITVAR(dde26_pci);
// WARN_UNIMPL;
return pci_irq_enable(dev);
}
/**
* pci_disable_device - Disable PCI device after use
*
* Signal to the system that the PCI device is not in use by the system
* anymore. This only involves disabling PCI bus-mastering, if active.
*
* \param dev PCI device to be disabled
*/
void pci_disable_device(struct pci_dev *dev)
{
CHECK_INITVAR(dde26_pci);
WARN_UNIMPL;
}
void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
{
//WARN_UNIMPL;
}
void pci_set_master(struct pci_dev *dev)
{
CHECK_INITVAR(dde26_pci);
WARN_UNIMPL;
}
int pci_create_sysfs_dev_files(struct pci_dev *pdev)
{
return 0;
}
unsigned int pcibios_assign_all_busses(void)
{
return 1;
}
void
pcibios_align_resource(void *data, struct resource *res,
resource_size_t size, resource_size_t align)
{
WARN_UNIMPL;
}
int pcibios_enable_device(struct pci_dev *dev, int mask)
{
#if 0
int err;
if ((err = pcibios_enable_resources(dev, mask)) < 0)
return err;
return pcibios_enable_irq(dev);
#endif
return 0;
}
/*******************************************************************************************
** Initialization function **
*******************************************************************************************/
/** Initialize DDELinux PCI subsystem.
*/
void __init l4dde26_init_pci(void)
{
ddekit_pci_init();
pci_bus = pci_create_bus(NULL, 0, &dde_pcibus_ops, NULL);
Assert(pci_bus);
pci_do_scan_bus(pci_bus);
INITIALIZE_INITVAR(dde26_pci);
}
arch_initcall(l4dde26_init_pci);
|