[PATCH linux dev-4.13] serial: 8250: Add Nuvoton NPCM UART

Joel Stanley joel at jms.id.au
Tue Feb 6 16:50:12 AEDT 2018


On Mon, Feb 5, 2018 at 7:39 PM, Tomer Maimon <tmaimon77 at gmail.com> wrote:
> On 2 February 2018 at 06:27, Joel Stanley <joel at jms.id.au> wrote:

>>  /* Uart divisor latch read */
>> @@ -2143,6 +2153,15 @@ int serial8250_do_startup(struct uart_port *port)
>>                                 UART_DA830_PWREMU_MGMT_FREE);
>>         }
>>
>> +       if (port->type == PORT_NPCM) {
>> +               /*
>> +                * Nuvoton calls the scratch register 'UART_TOR' (timeout
>> +                * register). Enable it, and set TIOC (timeout interrupt
>> +                * comparator) to be 0x20 for correct operation.
>> +                */
>> +               serial_port_out(port, UART_NPCM_TOR, UART_NPCM_TOIE | 0x20);
>> +       }
>
> Can we set the TOR register dynamically (adding special IOCTL)?

We would have to have a good reason to do so.

Under what circumstances would a user need to change this dynamically?

>
>> +
>>  #ifdef CONFIG_SERIAL_8250_RSA
>>         /*
>>          * If this is an RSA port, see if we can kick it up to the
>> @@ -2465,6 +2484,15 @@ static unsigned int xr17v35x_get_divisor(struct uart_8250_port *up,
>>         return quot_16 >> 4;
>>  }
>>
>> +/* Nuvoton NPCM UARTs have a custom divisor calculation */
>> +static unsigned int npcm_get_divisor(struct uart_8250_port *up,
>> +               unsigned int baud)
>> +{
>> +       struct uart_port *port = &up->port;
>> +
>> +       return DIV_ROUND_CLOSEST(port->uartclk, 16 * baud + 2) - 2;
>> +}

Did you test this version of the driver on your hardware?

I think I understand why you had the extra code, but does it affect
operation in any of your tests?

>From what I understand the baud rates are often calculated to be "near enough".

Cheers,

Joel


More information about the openbmc mailing list