7 #include <linux/kernel.h>
18 #define is_enable_cmd(value) ((value)&(PCI_COMMAND_MEMORY|PCI_COMMAND_IO))
19 #define is_master_cmd(value) ((value)&PCI_COMMAND_MASTER)
27 if (!pci_is_enabled(dev))
45 dev_data = pci_get_drvdata(dev);
74 DRV_NAME
": %s: enable memory-write-invalidate\n",
79 DRV_NAME
": %s: cannot enable "
80 "memory-write-invalidate (%d)\n",
82 value &= ~PCI_COMMAND_INVALIDATE;
86 return pci_write_config_word(dev, offset, value);
89 static int rom_write(
struct pci_dev *dev,
int offset,
u32 value,
void *data)
106 pci_read_config_dword(dev, offset, &tmpval);
107 if (tmpval != bar->
val && value == bar->
val) {
109 pci_write_config_dword(dev, offset, bar->
val);
123 static int bar_write(
struct pci_dev *dev,
int offset,
u32 value,
void *data)
140 pci_read_config_dword(dev, offset, &tmpval);
141 if (tmpval != bar->
val && value == bar->
val) {
143 pci_write_config_dword(dev, offset, bar->
val);
151 static int bar_read(
struct pci_dev *dev,
int offset,
u32 * value,
void *data)
166 static inline void read_dev_bar(
struct pci_dev *dev,
181 bar_info->
val = res[pos - 1].
start >> 32;
189 bar_info->
len_val = resource_size(&res[pos]);
192 static void *bar_init(
struct pci_dev *dev,
int offset)
199 read_dev_bar(dev, bar, offset, ~0);
205 static void *rom_init(
struct pci_dev *dev,
int offset)
218 static void bar_reset(
struct pci_dev *dev,
int offset,
void *data)
225 static void bar_release(
struct pci_dev *dev,
int offset,
void *data)
230 static int xen_pcibk_read_vendor(
struct pci_dev *dev,
int offset,
231 u16 *value,
void *data)
238 static int xen_pcibk_read_device(
struct pci_dev *dev,
int offset,
239 u16 *value,
void *data)
246 static int interrupt_read(
struct pci_dev *dev,
int offset,
u8 * value,
249 *value = (
u8) dev->
irq;
254 static int bist_write(
struct pci_dev *dev,
int offset,
u8 value,
void *data)
259 err = pci_read_config_byte(dev, offset, &cur_value);
265 err = pci_write_config_byte(dev, offset, value);
275 .u.w.read = xen_pcibk_read_vendor,
280 .u.w.read = xen_pcibk_read_device,
285 .u.w.read = command_read,
286 .u.w.write = command_write,
291 .u.b.read = interrupt_read,
314 .u.b.write = bist_write,
319 #define CFG_FIELD_BAR(reg_offset) \
321 .offset = reg_offset, \
324 .reset = bar_reset, \
325 .release = bar_release, \
326 .u.dw.read = bar_read, \
327 .u.dw.write = bar_write, \
330 #define CFG_FIELD_ROM(reg_offset) \
332 .offset = reg_offset, \
335 .reset = bar_reset, \
336 .release = bar_release, \
337 .u.dw.read = bar_read, \
338 .u.dw.write = rom_write, \
363 err = xen_pcibk_config_add_fields(dev, header_common);
369 err = xen_pcibk_config_add_fields(dev, header_0);
373 err = xen_pcibk_config_add_fields(dev, header_1);