|
27 | 27 |
|
28 | 28 | #include <linux/dmaengine.h> |
29 | 29 | #include <linux/platform_data/dma-dw.h> |
| 30 | +#include <linux/platform_data/dma-hsu.h> |
30 | 31 |
|
31 | 32 | #include "8250.h" |
32 | 33 |
|
@@ -1525,6 +1526,148 @@ byt_serial_setup(struct serial_private *priv, |
1525 | 1526 | return ret; |
1526 | 1527 | } |
1527 | 1528 |
|
| 1529 | +#define INTEL_MID_UART_PS 0x30 |
| 1530 | +#define INTEL_MID_UART_MUL 0x34 |
| 1531 | + |
| 1532 | +static void intel_mid_set_termios_50M(struct uart_port *p, |
| 1533 | + struct ktermios *termios, |
| 1534 | + struct ktermios *old) |
| 1535 | +{ |
| 1536 | + unsigned int baud = tty_termios_baud_rate(termios); |
| 1537 | + u32 ps, mul; |
| 1538 | + |
| 1539 | + /* |
| 1540 | + * The uart clk is 50Mhz, and the baud rate come from: |
| 1541 | + * baud = 50M * MUL / (DIV * PS * DLAB) |
| 1542 | + * |
| 1543 | + * For those basic low baud rate we can get the direct |
| 1544 | + * scalar from 2746800, like 115200 = 2746800/24. For those |
| 1545 | + * higher baud rate, we handle them case by case, mainly by |
| 1546 | + * adjusting the MUL/PS registers, and DIV register is kept |
| 1547 | + * as default value 0x3d09 to make things simple. |
| 1548 | + */ |
| 1549 | + |
| 1550 | + ps = 0x10; |
| 1551 | + |
| 1552 | + switch (baud) { |
| 1553 | + case 500000: |
| 1554 | + case 1000000: |
| 1555 | + case 1500000: |
| 1556 | + case 3000000: |
| 1557 | + mul = 0x3a98; |
| 1558 | + p->uartclk = 48000000; |
| 1559 | + break; |
| 1560 | + case 2000000: |
| 1561 | + case 4000000: |
| 1562 | + mul = 0x2710; |
| 1563 | + ps = 0x08; |
| 1564 | + p->uartclk = 64000000; |
| 1565 | + break; |
| 1566 | + case 2500000: |
| 1567 | + mul = 0x30d4; |
| 1568 | + p->uartclk = 40000000; |
| 1569 | + break; |
| 1570 | + case 3500000: |
| 1571 | + mul = 0x3345; |
| 1572 | + ps = 0x0c; |
| 1573 | + p->uartclk = 56000000; |
| 1574 | + break; |
| 1575 | + default: |
| 1576 | + mul = 0x2400; |
| 1577 | + p->uartclk = 29491200; |
| 1578 | + } |
| 1579 | + |
| 1580 | + writel(ps, p->membase + INTEL_MID_UART_PS); /* set PS */ |
| 1581 | + writel(mul, p->membase + INTEL_MID_UART_MUL); /* set MUL */ |
| 1582 | + |
| 1583 | + serial8250_do_set_termios(p, termios, old); |
| 1584 | +} |
| 1585 | + |
| 1586 | +static bool intel_mid_dma_filter(struct dma_chan *chan, void *param) |
| 1587 | +{ |
| 1588 | + struct hsu_dma_slave *s = param; |
| 1589 | + |
| 1590 | + if (s->dma_dev != chan->device->dev || s->chan_id != chan->chan_id) |
| 1591 | + return false; |
| 1592 | + |
| 1593 | + chan->private = s; |
| 1594 | + return true; |
| 1595 | +} |
| 1596 | + |
| 1597 | +static int intel_mid_serial_setup(struct serial_private *priv, |
| 1598 | + const struct pciserial_board *board, |
| 1599 | + struct uart_8250_port *port, int idx, |
| 1600 | + int index, struct pci_dev *dma_dev) |
| 1601 | +{ |
| 1602 | + struct device *dev = port->port.dev; |
| 1603 | + struct uart_8250_dma *dma; |
| 1604 | + struct hsu_dma_slave *tx_param, *rx_param; |
| 1605 | + |
| 1606 | + dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); |
| 1607 | + if (!dma) |
| 1608 | + return -ENOMEM; |
| 1609 | + |
| 1610 | + tx_param = devm_kzalloc(dev, sizeof(*tx_param), GFP_KERNEL); |
| 1611 | + if (!tx_param) |
| 1612 | + return -ENOMEM; |
| 1613 | + |
| 1614 | + rx_param = devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL); |
| 1615 | + if (!rx_param) |
| 1616 | + return -ENOMEM; |
| 1617 | + |
| 1618 | + rx_param->chan_id = index * 2 + 1; |
| 1619 | + tx_param->chan_id = index * 2; |
| 1620 | + |
| 1621 | + dma->rxconf.src_maxburst = 64; |
| 1622 | + dma->txconf.dst_maxburst = 64; |
| 1623 | + |
| 1624 | + rx_param->dma_dev = &dma_dev->dev; |
| 1625 | + tx_param->dma_dev = &dma_dev->dev; |
| 1626 | + |
| 1627 | + dma->fn = intel_mid_dma_filter; |
| 1628 | + dma->rx_param = rx_param; |
| 1629 | + dma->tx_param = tx_param; |
| 1630 | + |
| 1631 | + port->port.type = PORT_16750; |
| 1632 | + port->port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE; |
| 1633 | + port->dma = dma; |
| 1634 | + |
| 1635 | + return pci_default_setup(priv, board, port, idx); |
| 1636 | +} |
| 1637 | + |
| 1638 | +#define PCI_DEVICE_ID_INTEL_PNW_UART1 0x081b |
| 1639 | +#define PCI_DEVICE_ID_INTEL_PNW_UART2 0x081c |
| 1640 | +#define PCI_DEVICE_ID_INTEL_PNW_UART3 0x081d |
| 1641 | + |
| 1642 | +static int pnw_serial_setup(struct serial_private *priv, |
| 1643 | + const struct pciserial_board *board, |
| 1644 | + struct uart_8250_port *port, int idx) |
| 1645 | +{ |
| 1646 | + struct pci_dev *pdev = priv->dev; |
| 1647 | + struct pci_dev *dma_dev; |
| 1648 | + int index; |
| 1649 | + |
| 1650 | + switch (pdev->device) { |
| 1651 | + case PCI_DEVICE_ID_INTEL_PNW_UART1: |
| 1652 | + index = 0; |
| 1653 | + break; |
| 1654 | + case PCI_DEVICE_ID_INTEL_PNW_UART2: |
| 1655 | + index = 1; |
| 1656 | + break; |
| 1657 | + case PCI_DEVICE_ID_INTEL_PNW_UART3: |
| 1658 | + index = 2; |
| 1659 | + break; |
| 1660 | + default: |
| 1661 | + return -EINVAL; |
| 1662 | + } |
| 1663 | + |
| 1664 | + dma_dev = pci_get_slot(pdev->bus, PCI_DEVFN(PCI_SLOT(pdev->devfn), 3)); |
| 1665 | + |
| 1666 | + port->port.set_termios = intel_mid_set_termios_50M; |
| 1667 | + |
| 1668 | + return intel_mid_serial_setup(priv, board, port, idx, index, dma_dev); |
| 1669 | +} |
| 1670 | + |
1528 | 1671 | static int |
1529 | 1672 | pci_omegapci_setup(struct serial_private *priv, |
1530 | 1673 | const struct pciserial_board *board, |
@@ -1987,6 +2130,27 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { |
1987 | 2130 | .subdevice = PCI_ANY_ID, |
1988 | 2131 | .setup = byt_serial_setup, |
1989 | 2132 | }, |
| 2133 | + { |
| 2134 | + .vendor = PCI_VENDOR_ID_INTEL, |
| 2135 | + .device = PCI_DEVICE_ID_INTEL_PNW_UART1, |
| 2136 | + .subvendor = PCI_ANY_ID, |
| 2137 | + .subdevice = PCI_ANY_ID, |
| 2138 | + .setup = pnw_serial_setup, |
| 2139 | + }, |
| 2140 | + { |
| 2141 | + .vendor = PCI_VENDOR_ID_INTEL, |
| 2142 | + .device = PCI_DEVICE_ID_INTEL_PNW_UART2, |
| 2143 | + .subvendor = PCI_ANY_ID, |
| 2144 | + .subdevice = PCI_ANY_ID, |
| 2145 | + .setup = pnw_serial_setup, |
| 2146 | + }, |
| 2147 | + { |
| 2148 | + .vendor = PCI_VENDOR_ID_INTEL, |
| 2149 | + .device = PCI_DEVICE_ID_INTEL_PNW_UART3, |
| 2150 | + .subvendor = PCI_ANY_ID, |
| 2151 | + .subdevice = PCI_ANY_ID, |
| 2152 | + .setup = pnw_serial_setup, |
| 2153 | + }, |
1990 | 2154 | { |
1991 | 2155 | .vendor = PCI_VENDOR_ID_INTEL, |
1992 | 2156 | .device = PCI_DEVICE_ID_INTEL_QRK_UART, |
@@ -2878,6 +3042,7 @@ enum pci_board_num_t { |
2878 | 3042 | pbn_ADDIDATA_PCIe_8_3906250, |
2879 | 3043 | pbn_ce4100_1_115200, |
2880 | 3044 | pbn_byt, |
| 3045 | + pbn_pnw, |
2881 | 3046 | pbn_qrk, |
2882 | 3047 | pbn_omegapci, |
2883 | 3048 | pbn_NETMOS9900_2s_115200, |
@@ -3644,6 +3809,11 @@ static struct pciserial_board pci_boards[] = { |
3644 | 3809 | .uart_offset = 0x80, |
3645 | 3810 | .reg_shift = 2, |
3646 | 3811 | }, |
| 3812 | + [pbn_pnw] = { |
| 3813 | + .flags = FL_BASE0, |
| 3814 | + .num_ports = 1, |
| 3815 | + .base_baud = 115200, |
| 3816 | + }, |
3647 | 3817 | [pbn_qrk] = { |
3648 | 3818 | .flags = FL_BASE0, |
3649 | 3819 | .num_ports = 1, |
@@ -5376,6 +5546,19 @@ static struct pci_device_id serial_pci_tbl[] = { |
5376 | 5546 | PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000, |
5377 | 5547 | pbn_byt }, |
5378 | 5548 |
|
| 5549 | + /* |
| 5550 | + * Intel Penwell |
| 5551 | + */ |
| 5552 | + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PNW_UART1, |
| 5553 | + PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 5554 | + pbn_pnw}, |
| 5555 | + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PNW_UART2, |
| 5556 | + PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 5557 | + pbn_pnw}, |
| 5558 | + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PNW_UART3, |
| 5559 | + PCI_ANY_ID, PCI_ANY_ID, 0, 0, |
| 5560 | + pbn_pnw}, |
| 5561 | + |
5379 | 5562 | /* |
5380 | 5563 | * Intel Quark x1000 |
5381 | 5564 | */ |
|
0 commit comments