1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2001 Russell King, All Rights Reserved.
7 #include <linux/errno.h>
8 #include <linux/ioport.h>
10 #include <linux/types.h>
13 #include "8250_pcilib.h"
15 int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port,
16 u8 bar, unsigned int offset, int regshift)
18 if (bar >= PCI_STD_NUM_BARS)
21 if (pci_resource_flags(dev, bar) & IORESOURCE_MEM) {
22 if (!pcim_iomap(dev, bar, 0) && !pcim_iomap_table(dev))
25 port->port.iotype = UPIO_MEM;
26 port->port.iobase = 0;
27 port->port.mapbase = pci_resource_start(dev, bar) + offset;
28 port->port.membase = pcim_iomap_table(dev)[bar] + offset;
29 port->port.regshift = regshift;
31 port->port.iotype = UPIO_PORT;
32 port->port.iobase = pci_resource_start(dev, bar) + offset;
33 port->port.mapbase = 0;
34 port->port.membase = NULL;
35 port->port.regshift = 0;
39 EXPORT_SYMBOL_NS_GPL(serial8250_pci_setup_port, SERIAL_8250_PCI);
40 MODULE_LICENSE("GPL");