From: Rob Herring <robh@kernel.org>
To: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
Cc: linux-serial@vger.kernel.org, devicetree@vger.kernel.org,
jslaby@suse.com, git-dev@xilinx.com, gregkh@linuxfoundation.org
Subject: Re: [PATCH 2/2] tty: pl011: Add support for xilinx uart
Date: Tue, 25 Aug 2020 16:17:13 -0600 [thread overview]
Message-ID: <20200825221713.GB1429623@bogus> (raw)
In-Reply-To: <1597855439-746-2-git-send-email-shubhrajyoti.datta@xilinx.com>
On Wed, Aug 19, 2020 at 10:13:59PM +0530, Shubhrajyoti Datta wrote:
> Xilinx uart is similar to sbsa but it has configurable
> parity and hardware flow. Add a compatible for the same.
>
> Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xilinx.com>
> ---
> drivers/tty/serial/amba-pl011.c | 77 ++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 76 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> index 8efd7c2..41dbcee 100644
> --- a/drivers/tty/serial/amba-pl011.c
> +++ b/drivers/tty/serial/amba-pl011.c
> @@ -2073,6 +2073,55 @@ sbsa_uart_set_termios(struct uart_port *port, struct ktermios *termios,
> spin_unlock_irqrestore(&port->lock, flags);
> }
>
> +static void
> +xlnx_sbsa_uart_set_termios(struct uart_port *port, struct ktermios *termios,
> + struct ktermios *old)
> +{
> + struct uart_amba_port *uap =
> + container_of(port, struct uart_amba_port, port);
> + unsigned long flags;
> + unsigned int lcr_h, old_cr;
> +
> + tty_termios_encode_baud_rate(termios, uap->fixed_baud, uap->fixed_baud);
> + /* The SBSA UART only supports 8n1 without hardware flow control. */
> + termios->c_cflag &= ~(CMSPAR | CRTSCTS);
> + switch (termios->c_cflag & CSIZE) {
> + case CS5:
> + lcr_h = UART01x_LCRH_WLEN_5;
> + break;
> + case CS6:
> + lcr_h = UART01x_LCRH_WLEN_6;
> + break;
> + case CS7:
> + lcr_h = UART01x_LCRH_WLEN_7;
> + break;
> + default:
> + lcr_h = UART01x_LCRH_WLEN_8;
> + break;
> + }
> + if (termios->c_cflag & CSTOPB)
> + lcr_h |= UART01x_LCRH_STP2;
> + if (termios->c_cflag & PARENB) {
> + lcr_h |= UART01x_LCRH_PEN;
> + if (!(termios->c_cflag & PARODD))
> + lcr_h |= UART01x_LCRH_EPS;
> + if (termios->c_cflag & CMSPAR)
> + lcr_h |= UART011_LCRH_SPS;
> + }
> + if (uap->fifosize > 1)
> + lcr_h |= UART01x_LCRH_FEN;
I'm guessing at least some of the above code is just copy-n-paste from
the pl011 version? Can't you reuse the existing version?
> + spin_lock_irqsave(&port->lock, flags);
> + uart_update_timeout(port, CS8, uap->fixed_baud);
> + pl011_setup_status_masks(port, termios);
> + /* first, disable everything */
> + old_cr = pl011_read(uap, REG_CR);
> + pl011_write(0, uap, REG_CR);
> + pl011_write_lcr_h(uap, lcr_h);
> + pl011_write(old_cr, uap, REG_CR);
> + spin_unlock_irqrestore(&port->lock, flags);
> +}
> +
> static const char *pl011_type(struct uart_port *port)
> {
> struct uart_amba_port *uap =
> @@ -2179,6 +2228,28 @@ static const struct uart_ops sbsa_uart_pops = {
> #endif
> };
>
> +static const struct uart_ops xlnx_sbsa_uart_pops = {
> + .tx_empty = pl011_tx_empty,
> + .set_mctrl = sbsa_uart_set_mctrl,
> + .get_mctrl = sbsa_uart_get_mctrl,
> + .stop_tx = pl011_stop_tx,
> + .start_tx = pl011_start_tx,
> + .stop_rx = pl011_stop_rx,
> + .startup = sbsa_uart_startup,
> + .shutdown = sbsa_uart_shutdown,
> + .set_termios = xlnx_sbsa_uart_set_termios,
> + .type = pl011_type,
> + .release_port = pl011_release_port,
> + .request_port = pl011_request_port,
> + .config_port = pl011_config_port,
> + .verify_port = pl011_verify_port,
> +#ifdef CONFIG_CONSOLE_POLL
> + .poll_init = pl011_hwinit,
> + .poll_get_char = pl011_get_poll_char,
> + .poll_put_char = pl011_put_poll_char,
> +#endif
> +};
> +
> static struct uart_amba_port *amba_ports[UART_NR];
>
> #ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
> @@ -2754,7 +2825,10 @@ static int sbsa_uart_probe(struct platform_device *pdev)
> uap->reg_offset = uap->vendor->reg_offset;
> uap->fifosize = 32;
> uap->port.iotype = uap->vendor->access_32b ? UPIO_MEM32 : UPIO_MEM;
> - uap->port.ops = &sbsa_uart_pops;
> + if (of_device_is_compatible(pdev->dev.of_node, "arm,xlnx-sbsa-uart"))
> + uap->port.ops = &xlnx_sbsa_uart_pops;
> + else
> + uap->port.ops = &sbsa_uart_pops;
> uap->fixed_baud = baudrate;
>
> snprintf(uap->type, sizeof(uap->type), "SBSA");
> @@ -2781,6 +2855,7 @@ static int sbsa_uart_remove(struct platform_device *pdev)
>
> static const struct of_device_id sbsa_uart_of_match[] = {
> { .compatible = "arm,sbsa-uart", },
> + { .compatible = "arm,xlnx-sbsa-uart", },
> {},
> };
> MODULE_DEVICE_TABLE(of, sbsa_uart_of_match);
> --
> 2.7.4
>
next prev parent reply other threads:[~2020-08-25 22:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 16:43 [PATCH 1/2] bindings: serial: Add xilinx compatible Shubhrajyoti Datta
2020-08-19 16:43 ` [PATCH 2/2] tty: pl011: Add support for xilinx uart Shubhrajyoti Datta
2020-08-25 22:17 ` Rob Herring [this message]
2020-08-25 22:12 ` [PATCH 1/2] bindings: serial: Add xilinx compatible Rob Herring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200825221713.GB1429623@bogus \
--to=robh@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=git-dev@xilinx.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-serial@vger.kernel.org \
--cc=shubhrajyoti.datta@xilinx.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).