diff options
Diffstat (limited to 'drivers/tty/serial/8250/8250_pci.c')
-rw-r--r-- | drivers/tty/serial/8250/8250_pci.c | 414 |
1 files changed, 296 insertions, 118 deletions
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 892eb32cdef4..08da4d3e2162 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c | |||
@@ -21,12 +21,14 @@ | |||
21 | #include <linux/serial_core.h> | 21 | #include <linux/serial_core.h> |
22 | #include <linux/8250_pci.h> | 22 | #include <linux/8250_pci.h> |
23 | #include <linux/bitops.h> | 23 | #include <linux/bitops.h> |
24 | #include <linux/rational.h> | ||
24 | 25 | ||
25 | #include <asm/byteorder.h> | 26 | #include <asm/byteorder.h> |
26 | #include <asm/io.h> | 27 | #include <asm/io.h> |
27 | 28 | ||
28 | #include <linux/dmaengine.h> | 29 | #include <linux/dmaengine.h> |
29 | #include <linux/platform_data/dma-dw.h> | 30 | #include <linux/platform_data/dma-dw.h> |
31 | #include <linux/platform_data/dma-hsu.h> | ||
30 | 32 | ||
31 | #include "8250.h" | 33 | #include "8250.h" |
32 | 34 | ||
@@ -1392,45 +1394,22 @@ byt_set_termios(struct uart_port *p, struct ktermios *termios, | |||
1392 | struct ktermios *old) | 1394 | struct ktermios *old) |
1393 | { | 1395 | { |
1394 | unsigned int baud = tty_termios_baud_rate(termios); | 1396 | unsigned int baud = tty_termios_baud_rate(termios); |
1395 | unsigned int m, n; | 1397 | unsigned long fref = 100000000, fuart = baud * 16; |
1398 | unsigned long w = BIT(15) - 1; | ||
1399 | unsigned long m, n; | ||
1396 | u32 reg; | 1400 | u32 reg; |
1397 | 1401 | ||
1402 | /* Get Fuart closer to Fref */ | ||
1403 | fuart *= rounddown_pow_of_two(fref / fuart); | ||
1404 | |||
1398 | /* | 1405 | /* |
1399 | * For baud rates 0.5M, 1M, 1.5M, 2M, 2.5M, 3M, 3.5M and 4M the | 1406 | * For baud rates 0.5M, 1M, 1.5M, 2M, 2.5M, 3M, 3.5M and 4M the |
1400 | * dividers must be adjusted. | 1407 | * dividers must be adjusted. |
1401 | * | 1408 | * |
1402 | * uartclk = (m / n) * 100 MHz, where m <= n | 1409 | * uartclk = (m / n) * 100 MHz, where m <= n |
1403 | */ | 1410 | */ |
1404 | switch (baud) { | 1411 | rational_best_approximation(fuart, fref, w, w, &m, &n); |
1405 | case 500000: | 1412 | p->uartclk = fuart; |
1406 | case 1000000: | ||
1407 | case 2000000: | ||
1408 | case 4000000: | ||
1409 | m = 64; | ||
1410 | n = 100; | ||
1411 | p->uartclk = 64000000; | ||
1412 | break; | ||
1413 | case 3500000: | ||
1414 | m = 56; | ||
1415 | n = 100; | ||
1416 | p->uartclk = 56000000; | ||
1417 | break; | ||
1418 | case 1500000: | ||
1419 | case 3000000: | ||
1420 | m = 48; | ||
1421 | n = 100; | ||
1422 | p->uartclk = 48000000; | ||
1423 | break; | ||
1424 | case 2500000: | ||
1425 | m = 40; | ||
1426 | n = 100; | ||
1427 | p->uartclk = 40000000; | ||
1428 | break; | ||
1429 | default: | ||
1430 | m = 2304; | ||
1431 | n = 3125; | ||
1432 | p->uartclk = 73728000; | ||
1433 | } | ||
1434 | 1413 | ||
1435 | /* Reset the clock */ | 1414 | /* Reset the clock */ |
1436 | reg = (m << BYT_PRV_CLK_M_VAL_SHIFT) | (n << BYT_PRV_CLK_N_VAL_SHIFT); | 1415 | reg = (m << BYT_PRV_CLK_M_VAL_SHIFT) | (n << BYT_PRV_CLK_N_VAL_SHIFT); |
@@ -1525,6 +1504,167 @@ byt_serial_setup(struct serial_private *priv, | |||
1525 | return ret; | 1504 | return ret; |
1526 | } | 1505 | } |
1527 | 1506 | ||
1507 | #define INTEL_MID_UART_PS 0x30 | ||
1508 | #define INTEL_MID_UART_MUL 0x34 | ||
1509 | #define INTEL_MID_UART_DIV 0x38 | ||
1510 | |||
1511 | static void intel_mid_set_termios(struct uart_port *p, | ||
1512 | struct ktermios *termios, | ||
1513 | struct ktermios *old, | ||
1514 | unsigned long fref) | ||
1515 | { | ||
1516 | unsigned int baud = tty_termios_baud_rate(termios); | ||
1517 | unsigned short ps = 16; | ||
1518 | unsigned long fuart = baud * ps; | ||
1519 | unsigned long w = BIT(24) - 1; | ||
1520 | unsigned long mul, div; | ||
1521 | |||
1522 | if (fref < fuart) { | ||
1523 | /* Find prescaler value that satisfies Fuart < Fref */ | ||
1524 | if (fref > baud) | ||
1525 | ps = fref / baud; /* baud rate too high */ | ||
1526 | else | ||
1527 | ps = 1; /* PLL case */ | ||
1528 | fuart = baud * ps; | ||
1529 | } else { | ||
1530 | /* Get Fuart closer to Fref */ | ||
1531 | fuart *= rounddown_pow_of_two(fref / fuart); | ||
1532 | } | ||
1533 | |||
1534 | rational_best_approximation(fuart, fref, w, w, &mul, &div); | ||
1535 | p->uartclk = fuart * 16 / ps; /* core uses ps = 16 always */ | ||
1536 | |||
1537 | writel(ps, p->membase + INTEL_MID_UART_PS); /* set PS */ | ||
1538 | writel(mul, p->membase + INTEL_MID_UART_MUL); /* set MUL */ | ||
1539 | writel(div, p->membase + INTEL_MID_UART_DIV); | ||
1540 | |||
1541 | serial8250_do_set_termios(p, termios, old); | ||
1542 | } | ||
1543 | |||
1544 | static void intel_mid_set_termios_38_4M(struct uart_port *p, | ||
1545 | struct ktermios *termios, | ||
1546 | struct ktermios *old) | ||
1547 | { | ||
1548 | intel_mid_set_termios(p, termios, old, 38400000); | ||
1549 | } | ||
1550 | |||
1551 | static void intel_mid_set_termios_50M(struct uart_port *p, | ||
1552 | struct ktermios *termios, | ||
1553 | struct ktermios *old) | ||
1554 | { | ||
1555 | /* | ||
1556 | * The uart clk is 50Mhz, and the baud rate come from: | ||
1557 | * baud = 50M * MUL / (DIV * PS * DLAB) | ||
1558 | */ | ||
1559 | intel_mid_set_termios(p, termios, old, 50000000); | ||
1560 | } | ||
1561 | |||
1562 | static bool intel_mid_dma_filter(struct dma_chan *chan, void *param) | ||
1563 | { | ||
1564 | struct hsu_dma_slave *s = param; | ||
1565 | |||
1566 | if (s->dma_dev != chan->device->dev || s->chan_id != chan->chan_id) | ||
1567 | return false; | ||
1568 | |||
1569 | chan->private = s; | ||
1570 | return true; | ||
1571 | } | ||
1572 | |||
1573 | static int intel_mid_serial_setup(struct serial_private *priv, | ||
1574 | const struct pciserial_board *board, | ||
1575 | struct uart_8250_port *port, int idx, | ||
1576 | int index, struct pci_dev *dma_dev) | ||
1577 | { | ||
1578 | struct device *dev = port->port.dev; | ||
1579 | struct uart_8250_dma *dma; | ||
1580 | struct hsu_dma_slave *tx_param, *rx_param; | ||
1581 | |||
1582 | dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); | ||
1583 | if (!dma) | ||
1584 | return -ENOMEM; | ||
1585 | |||
1586 | tx_param = devm_kzalloc(dev, sizeof(*tx_param), GFP_KERNEL); | ||
1587 | if (!tx_param) | ||
1588 | return -ENOMEM; | ||
1589 | |||
1590 | rx_param = devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL); | ||
1591 | if (!rx_param) | ||
1592 | return -ENOMEM; | ||
1593 | |||
1594 | rx_param->chan_id = index * 2 + 1; | ||
1595 | tx_param->chan_id = index * 2; | ||
1596 | |||
1597 | dma->rxconf.src_maxburst = 64; | ||
1598 | dma->txconf.dst_maxburst = 64; | ||
1599 | |||
1600 | rx_param->dma_dev = &dma_dev->dev; | ||
1601 | tx_param->dma_dev = &dma_dev->dev; | ||
1602 | |||
1603 | dma->fn = intel_mid_dma_filter; | ||
1604 | dma->rx_param = rx_param; | ||
1605 | dma->tx_param = tx_param; | ||
1606 | |||
1607 | port->port.type = PORT_16750; | ||
1608 | port->port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE; | ||
1609 | port->dma = dma; | ||
1610 | |||
1611 | return pci_default_setup(priv, board, port, idx); | ||
1612 | } | ||
1613 | |||
1614 | #define PCI_DEVICE_ID_INTEL_PNW_UART1 0x081b | ||
1615 | #define PCI_DEVICE_ID_INTEL_PNW_UART2 0x081c | ||
1616 | #define PCI_DEVICE_ID_INTEL_PNW_UART3 0x081d | ||
1617 | |||
1618 | static int pnw_serial_setup(struct serial_private *priv, | ||
1619 | const struct pciserial_board *board, | ||
1620 | struct uart_8250_port *port, int idx) | ||
1621 | { | ||
1622 | struct pci_dev *pdev = priv->dev; | ||
1623 | struct pci_dev *dma_dev; | ||
1624 | int index; | ||
1625 | |||
1626 | switch (pdev->device) { | ||
1627 | case PCI_DEVICE_ID_INTEL_PNW_UART1: | ||
1628 | index = 0; | ||
1629 | break; | ||
1630 | case PCI_DEVICE_ID_INTEL_PNW_UART2: | ||
1631 | index = 1; | ||
1632 | break; | ||
1633 | case PCI_DEVICE_ID_INTEL_PNW_UART3: | ||
1634 | index = 2; | ||
1635 | break; | ||
1636 | default: | ||
1637 | return -EINVAL; | ||
1638 | } | ||
1639 | |||
1640 | dma_dev = pci_get_slot(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 3)); | ||
1641 | |||
1642 | port->port.set_termios = intel_mid_set_termios_50M; | ||
1643 | |||
1644 | return intel_mid_serial_setup(priv, board, port, idx, index, dma_dev); | ||
1645 | } | ||
1646 | |||
1647 | #define PCI_DEVICE_ID_INTEL_TNG_UART 0x1191 | ||
1648 | |||
1649 | static int tng_serial_setup(struct serial_private *priv, | ||
1650 | const struct pciserial_board *board, | ||
1651 | struct uart_8250_port *port, int idx) | ||
1652 | { | ||
1653 | struct pci_dev *pdev = priv->dev; | ||
1654 | struct pci_dev *dma_dev; | ||
1655 | int index = PCI_FUNC(pdev->devfn); | ||
1656 | |||
1657 | /* Currently no support for HSU port0 */ | ||
1658 | if (index-- == 0) | ||
1659 | return -ENODEV; | ||
1660 | |||
1661 | dma_dev = pci_get_slot(pdev->bus, PCI_DEVFN(5, 0)); | ||
1662 | |||
1663 | port->port.set_termios = intel_mid_set_termios_38_4M; | ||
1664 | |||
1665 | return intel_mid_serial_setup(priv, board, port, idx, index, dma_dev); | ||
1666 | } | ||
1667 | |||
1528 | static int | 1668 | static int |
1529 | pci_omegapci_setup(struct serial_private *priv, | 1669 | pci_omegapci_setup(struct serial_private *priv, |
1530 | const struct pciserial_board *board, | 1670 | const struct pciserial_board *board, |
@@ -1550,95 +1690,71 @@ static int pci_fintek_setup(struct serial_private *priv, | |||
1550 | struct uart_8250_port *port, int idx) | 1690 | struct uart_8250_port *port, int idx) |
1551 | { | 1691 | { |
1552 | struct pci_dev *pdev = priv->dev; | 1692 | struct pci_dev *pdev = priv->dev; |
1553 | unsigned long base; | ||
1554 | unsigned long iobase; | ||
1555 | unsigned long ciobase = 0; | ||
1556 | u8 config_base; | 1693 | u8 config_base; |
1694 | u16 iobase; | ||
1695 | |||
1696 | config_base = 0x40 + 0x08 * idx; | ||
1697 | |||
1698 | /* Get the io address from configuration space */ | ||
1699 | pci_read_config_word(pdev, config_base + 4, &iobase); | ||
1700 | |||
1701 | dev_dbg(&pdev->dev, "%s: idx=%d iobase=0x%x", __func__, idx, iobase); | ||
1702 | |||
1703 | port->port.iotype = UPIO_PORT; | ||
1704 | port->port.iobase = iobase; | ||
1705 | |||
1706 | return 0; | ||
1707 | } | ||
1708 | |||
1709 | static int pci_fintek_init(struct pci_dev *dev) | ||
1710 | { | ||
1711 | unsigned long iobase; | ||
1712 | u32 max_port, i; | ||
1557 | u32 bar_data[3]; | 1713 | u32 bar_data[3]; |
1714 | u8 config_base; | ||
1558 | 1715 | ||
1559 | /* | 1716 | switch (dev->device) { |
1560 | * Find each UARTs offset in PCI configuraion space | 1717 | case 0x1104: /* 4 ports */ |
1561 | */ | 1718 | case 0x1108: /* 8 ports */ |
1562 | switch (idx) { | 1719 | max_port = dev->device & 0xff; |
1563 | case 0: | ||
1564 | config_base = 0x40; | ||
1565 | break; | 1720 | break; |
1566 | case 1: | 1721 | case 0x1112: /* 12 ports */ |
1567 | config_base = 0x48; | 1722 | max_port = 12; |
1568 | break; | ||
1569 | case 2: | ||
1570 | config_base = 0x50; | ||
1571 | break; | ||
1572 | case 3: | ||
1573 | config_base = 0x58; | ||
1574 | break; | ||
1575 | case 4: | ||
1576 | config_base = 0x60; | ||
1577 | break; | ||
1578 | case 5: | ||
1579 | config_base = 0x68; | ||
1580 | break; | ||
1581 | case 6: | ||
1582 | config_base = 0x70; | ||
1583 | break; | ||
1584 | case 7: | ||
1585 | config_base = 0x78; | ||
1586 | break; | ||
1587 | case 8: | ||
1588 | config_base = 0x80; | ||
1589 | break; | ||
1590 | case 9: | ||
1591 | config_base = 0x88; | ||
1592 | break; | ||
1593 | case 10: | ||
1594 | config_base = 0x90; | ||
1595 | break; | ||
1596 | case 11: | ||
1597 | config_base = 0x98; | ||
1598 | break; | 1723 | break; |
1599 | default: | 1724 | default: |
1600 | /* Unknown number of ports, get out of here */ | ||
1601 | return -EINVAL; | 1725 | return -EINVAL; |
1602 | } | 1726 | } |
1603 | 1727 | ||
1604 | if (idx < 4) { | ||
1605 | base = pci_resource_start(priv->dev, 3); | ||
1606 | ciobase = (int)(base + (0x8 * idx)); | ||
1607 | } | ||
1608 | |||
1609 | /* Get the io address dispatch from the BIOS */ | 1728 | /* Get the io address dispatch from the BIOS */ |
1610 | pci_read_config_dword(pdev, 0x24, &bar_data[0]); | 1729 | pci_read_config_dword(dev, 0x24, &bar_data[0]); |
1611 | pci_read_config_dword(pdev, 0x20, &bar_data[1]); | 1730 | pci_read_config_dword(dev, 0x20, &bar_data[1]); |
1612 | pci_read_config_dword(pdev, 0x1c, &bar_data[2]); | 1731 | pci_read_config_dword(dev, 0x1c, &bar_data[2]); |
1613 | |||
1614 | /* Calculate Real IO Port */ | ||
1615 | iobase = (bar_data[idx/4] & 0xffffffe0) + (idx % 4) * 8; | ||
1616 | 1732 | ||
1617 | dev_dbg(&pdev->dev, "%s: idx=%d iobase=0x%lx ciobase=0x%lx config_base=0x%2x\n", | 1733 | for (i = 0; i < max_port; ++i) { |
1618 | __func__, idx, iobase, ciobase, config_base); | 1734 | /* UART0 configuration offset start from 0x40 */ |
1735 | config_base = 0x40 + 0x08 * i; | ||
1619 | 1736 | ||
1620 | /* Enable UART I/O port */ | 1737 | /* Calculate Real IO Port */ |
1621 | pci_write_config_byte(pdev, config_base + 0x00, 0x01); | 1738 | iobase = (bar_data[i / 4] & 0xffffffe0) + (i % 4) * 8; |
1622 | 1739 | ||
1623 | /* Select 128-byte FIFO and 8x FIFO threshold */ | 1740 | /* Enable UART I/O port */ |
1624 | pci_write_config_byte(pdev, config_base + 0x01, 0x33); | 1741 | pci_write_config_byte(dev, config_base + 0x00, 0x01); |
1625 | 1742 | ||
1626 | /* LSB UART */ | 1743 | /* Select 128-byte FIFO and 8x FIFO threshold */ |
1627 | pci_write_config_byte(pdev, config_base + 0x04, (u8)(iobase & 0xff)); | 1744 | pci_write_config_byte(dev, config_base + 0x01, 0x33); |
1628 | 1745 | ||
1629 | /* MSB UART */ | 1746 | /* LSB UART */ |
1630 | pci_write_config_byte(pdev, config_base + 0x05, (u8)((iobase & 0xff00) >> 8)); | 1747 | pci_write_config_byte(dev, config_base + 0x04, |
1748 | (u8)(iobase & 0xff)); | ||
1631 | 1749 | ||
1632 | /* irq number, this usually fails, but the spec says to do it anyway. */ | 1750 | /* MSB UART */ |
1633 | pci_write_config_byte(pdev, config_base + 0x06, pdev->irq); | 1751 | pci_write_config_byte(dev, config_base + 0x05, |
1752 | (u8)((iobase & 0xff00) >> 8)); | ||
1634 | 1753 | ||
1635 | port->port.iotype = UPIO_PORT; | 1754 | pci_write_config_byte(dev, config_base + 0x06, dev->irq); |
1636 | port->port.iobase = iobase; | 1755 | } |
1637 | port->port.mapbase = 0; | ||
1638 | port->port.membase = NULL; | ||
1639 | port->port.regshift = 0; | ||
1640 | 1756 | ||
1641 | return 0; | 1757 | return max_port; |
1642 | } | 1758 | } |
1643 | 1759 | ||
1644 | static int skip_tx_en_setup(struct serial_private *priv, | 1760 | static int skip_tx_en_setup(struct serial_private *priv, |
@@ -1989,6 +2105,34 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { | |||
1989 | }, | 2105 | }, |
1990 | { | 2106 | { |
1991 | .vendor = PCI_VENDOR_ID_INTEL, | 2107 | .vendor = PCI_VENDOR_ID_INTEL, |
2108 | .device = PCI_DEVICE_ID_INTEL_PNW_UART1, | ||
2109 | .subvendor = PCI_ANY_ID, | ||
2110 | .subdevice = PCI_ANY_ID, | ||
2111 | .setup = pnw_serial_setup, | ||
2112 | }, | ||
2113 | { | ||
2114 | .vendor = PCI_VENDOR_ID_INTEL, | ||
2115 | .device = PCI_DEVICE_ID_INTEL_PNW_UART2, | ||
2116 | .subvendor = PCI_ANY_ID, | ||
2117 | .subdevice = PCI_ANY_ID, | ||
2118 | .setup = pnw_serial_setup, | ||
2119 | }, | ||
2120 | { | ||
2121 | .vendor = PCI_VENDOR_ID_INTEL, | ||
2122 | .device = PCI_DEVICE_ID_INTEL_PNW_UART3, | ||
2123 | .subvendor = PCI_ANY_ID, | ||
2124 | .subdevice = PCI_ANY_ID, | ||
2125 | .setup = pnw_serial_setup, | ||
2126 | }, | ||
2127 | { | ||
2128 | .vendor = PCI_VENDOR_ID_INTEL, | ||
2129 | .device = PCI_DEVICE_ID_INTEL_TNG_UART, | ||
2130 | .subvendor = PCI_ANY_ID, | ||
2131 | .subdevice = PCI_ANY_ID, | ||
2132 | .setup = tng_serial_setup, | ||
2133 | }, | ||
2134 | { | ||
2135 | .vendor = PCI_VENDOR_ID_INTEL, | ||
1992 | .device = PCI_DEVICE_ID_INTEL_BSW_UART1, | 2136 | .device = PCI_DEVICE_ID_INTEL_BSW_UART1, |
1993 | .subvendor = PCI_ANY_ID, | 2137 | .subvendor = PCI_ANY_ID, |
1994 | .subdevice = PCI_ANY_ID, | 2138 | .subdevice = PCI_ANY_ID, |
@@ -2653,6 +2797,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { | |||
2653 | .subvendor = PCI_ANY_ID, | 2797 | .subvendor = PCI_ANY_ID, |
2654 | .subdevice = PCI_ANY_ID, | 2798 | .subdevice = PCI_ANY_ID, |
2655 | .setup = pci_fintek_setup, | 2799 | .setup = pci_fintek_setup, |
2800 | .init = pci_fintek_init, | ||
2656 | }, | 2801 | }, |
2657 | { | 2802 | { |
2658 | .vendor = 0x1c29, | 2803 | .vendor = 0x1c29, |
@@ -2660,6 +2805,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { | |||
2660 | .subvendor = PCI_ANY_ID, | 2805 | .subvendor = PCI_ANY_ID, |
2661 | .subdevice = PCI_ANY_ID, | 2806 | .subdevice = PCI_ANY_ID, |
2662 | .setup = pci_fintek_setup, | 2807 | .setup = pci_fintek_setup, |
2808 | .init = pci_fintek_init, | ||
2663 | }, | 2809 | }, |
2664 | { | 2810 | { |
2665 | .vendor = 0x1c29, | 2811 | .vendor = 0x1c29, |
@@ -2667,6 +2813,7 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { | |||
2667 | .subvendor = PCI_ANY_ID, | 2813 | .subvendor = PCI_ANY_ID, |
2668 | .subdevice = PCI_ANY_ID, | 2814 | .subdevice = PCI_ANY_ID, |
2669 | .setup = pci_fintek_setup, | 2815 | .setup = pci_fintek_setup, |
2816 | .init = pci_fintek_init, | ||
2670 | }, | 2817 | }, |
2671 | 2818 | ||
2672 | /* | 2819 | /* |
@@ -2864,6 +3011,8 @@ enum pci_board_num_t { | |||
2864 | pbn_ADDIDATA_PCIe_8_3906250, | 3011 | pbn_ADDIDATA_PCIe_8_3906250, |
2865 | pbn_ce4100_1_115200, | 3012 | pbn_ce4100_1_115200, |
2866 | pbn_byt, | 3013 | pbn_byt, |
3014 | pbn_pnw, | ||
3015 | pbn_tng, | ||
2867 | pbn_qrk, | 3016 | pbn_qrk, |
2868 | pbn_omegapci, | 3017 | pbn_omegapci, |
2869 | pbn_NETMOS9900_2s_115200, | 3018 | pbn_NETMOS9900_2s_115200, |
@@ -3630,6 +3779,16 @@ static struct pciserial_board pci_boards[] = { | |||
3630 | .uart_offset = 0x80, | 3779 | .uart_offset = 0x80, |
3631 | .reg_shift = 2, | 3780 | .reg_shift = 2, |
3632 | }, | 3781 | }, |
3782 | [pbn_pnw] = { | ||
3783 | .flags = FL_BASE0, | ||
3784 | .num_ports = 1, | ||
3785 | .base_baud = 115200, | ||
3786 | }, | ||
3787 | [pbn_tng] = { | ||
3788 | .flags = FL_BASE0, | ||
3789 | .num_ports = 1, | ||
3790 | .base_baud = 1843200, | ||
3791 | }, | ||
3633 | [pbn_qrk] = { | 3792 | [pbn_qrk] = { |
3634 | .flags = FL_BASE0, | 3793 | .flags = FL_BASE0, |
3635 | .num_ports = 1, | 3794 | .num_ports = 1, |
@@ -4006,41 +4165,41 @@ static void pciserial_remove_one(struct pci_dev *dev) | |||
4006 | pci_disable_device(dev); | 4165 | pci_disable_device(dev); |
4007 | } | 4166 | } |
4008 | 4167 | ||
4009 | #ifdef CONFIG_PM | 4168 | #ifdef CONFIG_PM_SLEEP |
4010 | static int pciserial_suspend_one(struct pci_dev *dev, pm_message_t state) | 4169 | static int pciserial_suspend_one(struct device *dev) |
4011 | { | 4170 | { |
4012 | struct serial_private *priv = pci_get_drvdata(dev); | 4171 | struct pci_dev *pdev = to_pci_dev(dev); |
4172 | struct serial_private *priv = pci_get_drvdata(pdev); | ||
4013 | 4173 | ||
4014 | if (priv) | 4174 | if (priv) |
4015 | pciserial_suspend_ports(priv); | 4175 | pciserial_suspend_ports(priv); |
4016 | 4176 | ||
4017 | pci_save_state(dev); | ||
4018 | pci_set_power_state(dev, pci_choose_state(dev, state)); | ||
4019 | return 0; | 4177 | return 0; |
4020 | } | 4178 | } |
4021 | 4179 | ||
4022 | static int pciserial_resume_one(struct pci_dev *dev) | 4180 | static int pciserial_resume_one(struct device *dev) |
4023 | { | 4181 | { |
4182 | struct pci_dev *pdev = to_pci_dev(dev); | ||
4183 | struct serial_private *priv = pci_get_drvdata(pdev); | ||
4024 | int err; | 4184 | int err; |
4025 | struct serial_private *priv = pci_get_drvdata(dev); | ||
4026 | |||
4027 | pci_set_power_state(dev, PCI_D0); | ||
4028 | pci_restore_state(dev); | ||
4029 | 4185 | ||
4030 | if (priv) { | 4186 | if (priv) { |
4031 | /* | 4187 | /* |
4032 | * The device may have been disabled. Re-enable it. | 4188 | * The device may have been disabled. Re-enable it. |
4033 | */ | 4189 | */ |
4034 | err = pci_enable_device(dev); | 4190 | err = pci_enable_device(pdev); |
4035 | /* FIXME: We cannot simply error out here */ | 4191 | /* FIXME: We cannot simply error out here */ |
4036 | if (err) | 4192 | if (err) |
4037 | dev_err(&dev->dev, "Unable to re-enable ports, trying to continue.\n"); | 4193 | dev_err(dev, "Unable to re-enable ports, trying to continue.\n"); |
4038 | pciserial_resume_ports(priv); | 4194 | pciserial_resume_ports(priv); |
4039 | } | 4195 | } |
4040 | return 0; | 4196 | return 0; |
4041 | } | 4197 | } |
4042 | #endif | 4198 | #endif |
4043 | 4199 | ||
4200 | static SIMPLE_DEV_PM_OPS(pciserial_pm_ops, pciserial_suspend_one, | ||
4201 | pciserial_resume_one); | ||
4202 | |||
4044 | static struct pci_device_id serial_pci_tbl[] = { | 4203 | static struct pci_device_id serial_pci_tbl[] = { |
4045 | /* Advantech use PCI_DEVICE_ID_ADVANTECH_PCI3620 (0x3620) as 'PCI_SUBVENDOR_ID' */ | 4204 | /* Advantech use PCI_DEVICE_ID_ADVANTECH_PCI3620 (0x3620) as 'PCI_SUBVENDOR_ID' */ |
4046 | { PCI_VENDOR_ID_ADVANTECH, PCI_DEVICE_ID_ADVANTECH_PCI3620, | 4205 | { PCI_VENDOR_ID_ADVANTECH, PCI_DEVICE_ID_ADVANTECH_PCI3620, |
@@ -5363,6 +5522,26 @@ static struct pci_device_id serial_pci_tbl[] = { | |||
5363 | pbn_byt }, | 5522 | pbn_byt }, |
5364 | 5523 | ||
5365 | /* | 5524 | /* |
5525 | * Intel Penwell | ||
5526 | */ | ||
5527 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PNW_UART1, | ||
5528 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
5529 | pbn_pnw}, | ||
5530 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PNW_UART2, | ||
5531 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
5532 | pbn_pnw}, | ||
5533 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PNW_UART3, | ||
5534 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
5535 | pbn_pnw}, | ||
5536 | |||
5537 | /* | ||
5538 | * Intel Tangier | ||
5539 | */ | ||
5540 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TNG_UART, | ||
5541 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, | ||
5542 | pbn_tng}, | ||
5543 | |||
5544 | /* | ||
5366 | * Intel Quark x1000 | 5545 | * Intel Quark x1000 |
5367 | */ | 5546 | */ |
5368 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_UART, | 5547 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_QRK_UART, |
@@ -5510,10 +5689,9 @@ static struct pci_driver serial_pci_driver = { | |||
5510 | .name = "serial", | 5689 | .name = "serial", |
5511 | .probe = pciserial_init_one, | 5690 | .probe = pciserial_init_one, |
5512 | .remove = pciserial_remove_one, | 5691 | .remove = pciserial_remove_one, |
5513 | #ifdef CONFIG_PM | 5692 | .driver = { |
5514 | .suspend = pciserial_suspend_one, | 5693 | .pm = &pciserial_pm_ops, |
5515 | .resume = pciserial_resume_one, | 5694 | }, |
5516 | #endif | ||
5517 | .id_table = serial_pci_tbl, | 5695 | .id_table = serial_pci_tbl, |
5518 | .err_handler = &serial8250_err_handler, | 5696 | .err_handler = &serial8250_err_handler, |
5519 | }; | 5697 | }; |