linux/arch/cris/arch-v32/drivers/pci/bios.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2#include <linux/pci.h>
   3#include <linux/kernel.h>
   4#include <hwregs/intr_vect.h>
   5
   6void pcibios_set_master(struct pci_dev *dev)
   7{
   8        u8 lat;
   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);
  12}
  13
  14resource_size_t
  15pcibios_align_resource(void *data, const struct resource *res,
  16                       resource_size_t size, resource_size_t align)
  17{
  18        resource_size_t start = res->start;
  19
  20        if ((res->flags & IORESOURCE_IO) && (start & 0x300))
  21                start = (start + 0x3ff) & ~0x3ff;
  22
  23        return start;
  24}
  25
  26int pcibios_enable_resources(struct pci_dev *dev, int mask)
  27{
  28        u16 cmd, old_cmd;
  29        int idx;
  30        struct resource *r;
  31
  32        pci_read_config_word(dev, PCI_COMMAND, &cmd);
  33        old_cmd = cmd;
  34        for(idx=0; idx<6; idx++) {
  35                /* Only set up the requested stuff */
  36                if (!(mask & (1<<idx)))
  37                        continue;
  38
  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));
  42                        return -EINVAL;
  43                }
  44                if (r->flags & IORESOURCE_IO)
  45                        cmd |= PCI_COMMAND_IO;
  46                if (r->flags & IORESOURCE_MEM)
  47                        cmd |= PCI_COMMAND_MEMORY;
  48        }
  49        if (dev->resource[PCI_ROM_RESOURCE].start)
  50                cmd |= PCI_COMMAND_MEMORY;
  51        if (cmd != old_cmd) {
  52                printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
  53                pci_write_config_word(dev, PCI_COMMAND, cmd);
  54        }
  55        return 0;
  56}
  57
  58int pcibios_enable_irq(struct pci_dev *dev)
  59{
  60        dev->irq = EXT_INTR_VECT;
  61        return 0;
  62}
  63
  64int pcibios_enable_device(struct pci_dev *dev, int mask)
  65{
  66        int err;
  67
  68        if ((err = pcibios_enable_resources(dev, mask)) < 0)
  69                return err;
  70
  71        if (!dev->msi_enabled)
  72                pcibios_enable_irq(dev);
  73        return 0;
  74}
  75