3 #include <ddekit/ddekit.h>
5 #include <ddekit/types.h>
7 /** \defgroup DDEKit_pci */
9 /** Our version of PCI_ANY_ID */
10 #define DDEKIT_PCI_ANY_ID (~0)
12 /** Copy of L4IO_PCIDEV_RES */
13 #define DDEKIT_PCIDEV_RES 12
15 struct ddekit_pci_dev
;
17 /** PCI resource descriptor. Copied from generic_io.
21 typedef struct ddekit_pci_resource
{
27 void ddekit_pci_init(void);
29 int ddekit_pci_get_device(int nr
, int *bus
, int *slot
, int *func
);
31 int ddekit_pci_read(int bus
, int slot
, int func
, int pos
, int len
,
32 ddekit_uint32_t
*val
);
33 int ddekit_pci_write(int bus
, int slot
, int func
, int pos
, int len
,
36 /** Read byte from PCI config space.
42 * \param func function #
43 * \param pos offset in config space
44 * \retval val read value
48 int ddekit_pci_readb(int bus
, int slot
, int func
, int pos
,
51 /** Read word from PCI config space.
57 * \param func function #
58 * \param pos offset in config space
59 * \retval val read value
63 int ddekit_pci_readw(int bus
, int slot
, int func
, int pos
,
64 ddekit_uint16_t
*val
);
66 /** Read dword from PCI config space.
72 * \param func function #
73 * \param pos offset in config space
74 * \retval val read value
78 int ddekit_pci_readl(int bus
, int slot
, int func
, int pos
,
79 ddekit_uint32_t
*val
);
81 /** Write byte to PCI config space.
87 * \param func function #
88 * \param pos offset in config space
89 * \retval val value to write
93 int ddekit_pci_writeb(int bus
, int slot
, int func
, int pos
,
96 /** Write word to PCI config space.
102 * \param func function #
103 * \param pos offset in config space
104 * \retval val value to write
108 int ddekit_pci_writew(int bus
, int slot
, int func
, int pos
,
109 ddekit_uint16_t val
);
111 /** Write word to PCI config space.
113 * \ingroup DDEKit_pci
117 * \param func function #
118 * \param pos offset in config space
119 * \retval val value to write
123 int ddekit_pci_writel(int bus
, int slot
, int func
, int pos
,
124 ddekit_uint32_t val
);
126 /** Find a PCI device.
128 * \ingroup DDEKit_pci
130 * \param bus pointer to bus number or \ref DDEKIT_PCI_ANY_ID
131 * \param slot pointer to slot number (devfn >> DEVFN_SLOTSHIFT) or \ref DDEKIT_PCI_ANY_ID
132 * \param func pointer to func number (devfc & DEVFN_FUNCMASK) or \ref DDEKIT_PCI_ANY_ID
133 * \param start search device list only behind this device (excluding it!), NULL
134 * searches whole device list
136 * \retval bus bus number
137 * \retval slot slot number
138 * \retval func function number
140 * \return device a valid PCI device
141 * \return NULL if no device found
143 struct ddekit_pci_dev
* ddekit_pci_find_device(int *bus
, int *slot
, int
144 *func
, struct ddekit_pci_dev
*start
);
146 /** Enable PCI device
147 * \ingroup DDEKit_pci
149 int ddekit_pci_enable_device(struct ddekit_pci_dev
*dev
);
151 /** Disable PCI device
152 * \ingroup DDEKit_pci
154 int ddekit_pci_disable_device(struct ddekit_pci_dev
*dev
);
156 /** Enable bus-mastering for device.
157 * \ingroup DDEKit_pci
159 void ddekit_pci_set_master(struct ddekit_pci_dev
*dev
);
161 /** Get device vendor ID.
162 * \ingroup DDEKit_pci
164 unsigned short ddekit_pci_get_vendor(struct ddekit_pci_dev
*dev
);
167 * \ingroup DDEKit_pci
169 unsigned short ddekit_pci_get_device_id(struct ddekit_pci_dev
*dev
);
171 /** Get device subvendor ID.
172 * \ingroup DDEKit_pci
174 unsigned short ddekit_pci_get_sub_vendor(struct ddekit_pci_dev
*dev
);
176 /** Get subdevice ID.
177 * \ingroup DDEKit_pci
179 unsigned short ddekit_pci_get_sub_device(struct ddekit_pci_dev
*dev
);
181 /** Get device class ID.
182 * \ingroup DDEKit_pci
184 unsigned ddekit_pci_get_dev_class(struct ddekit_pci_dev
*dev
);
186 /** Get device's IRQ number.
187 * \ingroup DDEKit_pci
189 unsigned long ddekit_pci_get_irq(struct ddekit_pci_dev
*dev
);
192 * \ingroup DDEKit_pci
194 char *ddekit_pci_get_name(struct ddekit_pci_dev
*dev
);
196 /** Get device's slot name.
197 * \ingroup DDEKit_pci
199 char *ddekit_pci_get_slot_name(struct ddekit_pci_dev
*dev
);
201 /** Get one of the device's resources.
202 * \ingroup DDEKit_pci
204 ddekit_pci_res_t
*ddekit_pci_get_resource(struct ddekit_pci_dev
*dev
,
207 int ddekit_pci_irq_enable(int bus
, int slot
, int func
, int pin
, int