|
77 | 77 |
|
78 | 78 | #define UART_EXAR_RS485_DLY(x) ((x) << 4)
|
79 | 79 |
|
| 80 | +#define UART_EXAR_DLD 0x02 /* Divisor Fractional */ |
| 81 | +#define UART_EXAR_DLD_485_POLARITY 0x80 /* RS-485 Enable Signal Polarity */ |
| 82 | + |
80 | 83 | /*
|
81 | 84 | * IOT2040 MPIO wiring semantics:
|
82 | 85 | *
|
@@ -438,6 +441,44 @@ static int generic_rs485_config(struct uart_port *port, struct ktermios *termios
|
438 | 441 | return 0;
|
439 | 442 | }
|
440 | 443 |
|
| 444 | +static int sealevel_rs485_config(struct uart_port *port, struct ktermios *termios, |
| 445 | + struct serial_rs485 *rs485) |
| 446 | +{ |
| 447 | + u8 __iomem *p = port->membase; |
| 448 | + u8 old_lcr; |
| 449 | + u8 efr; |
| 450 | + u8 dld; |
| 451 | + int ret; |
| 452 | + |
| 453 | + ret = generic_rs485_config(port, termios, rs485); |
| 454 | + if (ret) |
| 455 | + return ret; |
| 456 | + |
| 457 | + if (rs485->flags & SER_RS485_ENABLED) { |
| 458 | + old_lcr = readb(p + UART_LCR); |
| 459 | + |
| 460 | + /* Set EFR[4]=1 to enable enhanced feature registers */ |
| 461 | + efr = readb(p + UART_XR_EFR); |
| 462 | + efr |= UART_EFR_ECB; |
| 463 | + writeb(efr, p + UART_XR_EFR); |
| 464 | + |
| 465 | + /* Set MCR to use DTR as Auto-RS485 Enable signal */ |
| 466 | + writeb(UART_MCR_OUT1, p + UART_MCR); |
| 467 | + |
| 468 | + /* Set LCR[7]=1 to enable access to DLD register */ |
| 469 | + writeb(old_lcr | UART_LCR_DLAB, p + UART_LCR); |
| 470 | + |
| 471 | + /* Set DLD[7]=1 for inverted RS485 Enable logic */ |
| 472 | + dld = readb(p + UART_EXAR_DLD); |
| 473 | + dld |= UART_EXAR_DLD_485_POLARITY; |
| 474 | + writeb(dld, p + UART_EXAR_DLD); |
| 475 | + |
| 476 | + writeb(old_lcr, p + UART_LCR); |
| 477 | + } |
| 478 | + |
| 479 | + return 0; |
| 480 | +} |
| 481 | + |
441 | 482 | static const struct serial_rs485 generic_rs485_supported = {
|
442 | 483 | .flags = SER_RS485_ENABLED,
|
443 | 484 | };
|
@@ -559,6 +600,9 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,
|
559 | 600 | port->port.rs485_config = platform->rs485_config;
|
560 | 601 | port->port.rs485_supported = *(platform->rs485_supported);
|
561 | 602 |
|
| 603 | + if (pcidev->subsystem_vendor == PCI_VENDOR_ID_SEALEVEL) |
| 604 | + port->port.rs485_config = sealevel_rs485_config; |
| 605 | + |
562 | 606 | /*
|
563 | 607 | * Setup the UART clock for the devices on expansion slot to
|
564 | 608 | * half the clock speed of the main chip (which is 125MHz)
|
|
0 commit comments