1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/kernel.h>
4 #include <hwregs/intr_vect.h>
6 void pcibios_set_master(struct pci_dev
*dev
)
9 pci_read_config_byte(dev
, PCI_LATENCY_TIMER
, &lat
);
10 printk(KERN_DEBUG
"PCI: Setting latency timer of device %s to %d\n", pci_name(dev
), lat
);
11 pci_write_config_byte(dev
, PCI_LATENCY_TIMER
, lat
);
15 pcibios_align_resource(void *data
, const struct resource
*res
,
16 resource_size_t size
, resource_size_t align
)
18 resource_size_t start
= res
->start
;
20 if ((res
->flags
& IORESOURCE_IO
) && (start
& 0x300))
21 start
= (start
+ 0x3ff) & ~0x3ff;
26 int pcibios_enable_resources(struct pci_dev
*dev
, int mask
)
32 pci_read_config_word(dev
, PCI_COMMAND
, &cmd
);
34 for(idx
=0; idx
<6; idx
++) {
35 /* Only set up the requested stuff */
36 if (!(mask
& (1<<idx
)))
39 r
= &dev
->resource
[idx
];
40 if (!r
->start
&& r
->end
) {
41 printk(KERN_ERR
"PCI: Device %s not available because of resource collisions\n", pci_name(dev
));
44 if (r
->flags
& IORESOURCE_IO
)
45 cmd
|= PCI_COMMAND_IO
;
46 if (r
->flags
& IORESOURCE_MEM
)
47 cmd
|= PCI_COMMAND_MEMORY
;
49 if (dev
->resource
[PCI_ROM_RESOURCE
].start
)
50 cmd
|= PCI_COMMAND_MEMORY
;
52 printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev
), old_cmd
, cmd
);
53 pci_write_config_word(dev
, PCI_COMMAND
, cmd
);
58 int pcibios_enable_irq(struct pci_dev
*dev
)
60 dev
->irq
= EXT_INTR_VECT
;
64 int pcibios_enable_device(struct pci_dev
*dev
, int mask
)
68 if ((err
= pcibios_enable_resources(dev
, mask
)) < 0)
71 if (!dev
->msi_enabled
)
72 pcibios_enable_irq(dev
);