Commit 0d963ebf authored by Jan Kiszka's avatar Jan Kiszka

serial: exar: Factor out platform hooks

This prepares the addition of IOT2040 platform support by preparing the
needed setup and rs485_config hooks.
Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4076cf08
...@@ -63,6 +63,11 @@ ...@@ -63,6 +63,11 @@
struct exar8250; struct exar8250;
struct exar8250_platform {
int (*rs485_config)(struct uart_port *, struct serial_rs485 *);
int (*register_gpio)(struct pci_dev *, struct uart_8250_port *);
};
/** /**
* struct exar8250_board - board information * struct exar8250_board - board information
* @num_ports: number of serial ports * @num_ports: number of serial ports
...@@ -189,7 +194,7 @@ static void setup_gpio(u8 __iomem *p) ...@@ -189,7 +194,7 @@ static void setup_gpio(u8 __iomem *p)
} }
static void * static void *
xr17v35x_register_gpio(struct pci_dev *pcidev) __xr17v35x_register_gpio(struct pci_dev *pcidev)
{ {
struct platform_device *pdev; struct platform_device *pdev;
...@@ -208,17 +213,36 @@ xr17v35x_register_gpio(struct pci_dev *pcidev) ...@@ -208,17 +213,36 @@ xr17v35x_register_gpio(struct pci_dev *pcidev)
return pdev; return pdev;
} }
static int xr17v35x_register_gpio(struct pci_dev *pcidev,
struct uart_8250_port *port)
{
if (pcidev->vendor == PCI_VENDOR_ID_EXAR)
port->port.private_data =
__xr17v35x_register_gpio(pcidev);
return 0;
}
static const struct exar8250_platform exar8250_default_platform = {
.register_gpio = xr17v35x_register_gpio,
};
static int static int
pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev, pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
struct uart_8250_port *port, int idx) struct uart_8250_port *port, int idx)
{ {
const struct exar8250_board *board = priv->board; const struct exar8250_board *board = priv->board;
const struct exar8250_platform *platform;
unsigned int offset = idx * 0x400; unsigned int offset = idx * 0x400;
unsigned int baud = 7812500; unsigned int baud = 7812500;
u8 __iomem *p; u8 __iomem *p;
int ret; int ret;
platform = &exar8250_default_platform;
port->port.uartclk = baud * 16; port->port.uartclk = baud * 16;
port->port.rs485_config = platform->rs485_config;
/* /*
* Setup the uart clock for the devices on expansion slot to * Setup the uart clock for the devices on expansion slot to
* half the clock speed of the main chip (which is 125MHz) * half the clock speed of the main chip (which is 125MHz)
...@@ -241,12 +265,10 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev, ...@@ -241,12 +265,10 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
/* Setup Multipurpose Input/Output pins. */ /* Setup Multipurpose Input/Output pins. */
setup_gpio(p); setup_gpio(p);
if (pcidev->vendor == PCI_VENDOR_ID_EXAR) ret = platform->register_gpio(pcidev, port);
port->port.private_data =
xr17v35x_register_gpio(pcidev);
} }
return 0; return ret;
} }
static void pci_xr17v35x_exit(struct pci_dev *pcidev) static void pci_xr17v35x_exit(struct pci_dev *pcidev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment