From patchwork Wed Apr 17 14:59:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10905495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D5E717E6 for ; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6621028C0A for ; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63D6B28C0C; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E4F4028C02 for ; Wed, 17 Apr 2019 15:01:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2T-0004XH-7z; Wed, 17 Apr 2019 14:59:53 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2S-0004XB-9W for xen-devel@lists.xenproject.org; Wed, 17 Apr 2019 14:59:52 +0000 X-Inumbo-ID: 731c5e80-6121-11e9-92d7-bc764e045a96 Received: from mail-lj1-x241.google.com (unknown [2a00:1450:4864:20::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 731c5e80-6121-11e9-92d7-bc764e045a96; Wed, 17 Apr 2019 14:59:51 +0000 (UTC) Received: by mail-lj1-x241.google.com with SMTP id f18so22748409lja.10 for ; Wed, 17 Apr 2019 07:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qucunmK9xgz8gtRcruJM1bVATnlVA3EmGKtWXeWisWY=; b=PITMr+MXte6cMjlw6hb1w9mtzR9mkJi7ftkp7ugr9d1iMjYepdqNBFepI08rLrAmlI YRY3d7LYRGyu7pAsJJlHuLCliElhHer4OWXQv+q/bSBKMn7nqaXFbfLyPpzWWzkvHB71 P0uxAFCJitnncto0OyLJTw9gdhJaqtE31CrdkIL7dcDSXfpx4Tyik49ggAMqyfmU8313 XVMuWNClpSC2dvzI4iPepkzsoWiH+zSfSupQN0NMUqDKG22/4ZO3NONY4i57pR8rnew+ 2ZW5tgiR26ZHph1k3p7Iv2U+Glfi43Pj6Xp1rpbNUyp9n9ilY8ZQrguU6LoVxZxZPHf4 +xUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qucunmK9xgz8gtRcruJM1bVATnlVA3EmGKtWXeWisWY=; b=YiGcO5T9UaaklRgj0R3qroVadlTi0AI2WYeW0FYMZsg7dlxEneXvuB/vKj6UD90Xcv mcMG9oMfWBcvKTtXyHcJmxff5eU2J9W+e76xgSAFTalv3dmumtCNYC/c5o7p5IT0B5Do bsx/Id9CV4Mfn7Uj1b6y5e7/TGz93ZXmdprQgossvXQPIpaiycvQ4NttLML7Gf3hKkP7 wPJYwL692pJvsBbY8VG7/9pHu/8TotvUqdqVE0lP8o7Kejz1VdvDwjiRn+Cl2MhH+3PF LV5DvEz6V8k0Gxl5h7QWaTPy+NRi7klkHZ1dbyPo9KWEuqUPrDgFYC45xuh4ExxwXkhW FXYw== X-Gm-Message-State: APjAAAW1NBHuTS8irdIKJusEzqoRM4Qt5Z0orMBF41wvApW3HAFBX0Dn 3qEowD0EmNQG4Q2wM38QfdbDsO+ZzlE= X-Google-Smtp-Source: APXvYqwNntwj/uvFquTpfkS4qeqayKE8ECdISVs4tXNA+tpuIng8JUIkok96MiqlYUmM4/nPVgwarg== X-Received: by 2002:a2e:4ca:: with SMTP id a71mr48109056ljf.39.1555513189759; Wed, 17 Apr 2019 07:59:49 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id u8sm950273lfi.83.2019.04.17.07.59.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Apr 2019 07:59:48 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 17 Apr 2019 17:59:31 +0300 Message-Id: <1555513175-7596-2-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> References: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [PATCH V4 1/5] xen/arm: Clarify usage of earlyprintk for Lager board X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko Current sentence is not entirely correct. Since SCIF0 interface is applicable for Lager board, but is not applicable for all R-Car H2 based boards. For example, Stout board uses SCIFA0 interface. Signed-off-by: Oleksandr Tyshchenko Acked-by: Julien Grall --- docs/misc/arm/early-printk.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index f765f59..b23c54f 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -39,7 +39,7 @@ the name of the machine: - fastmodel: printk on ARM Fastmodel software emulators - hikey960: printk with pl011 with Hikey 960 - juno: printk with pl011 on Juno platform - - lager: printk with SCIF0 on Renesas R-Car H2 processors + - lager: printk with SCIF0 on Renesas Lager board (R-Car H2 processor) - midway: printk with the pl011 on Calxeda Midway processors - mvebu: printk with the MVEBU for Marvell Armada 3700 SoCs - omap5432: printk with UART3 on TI OMAP5432 processors From patchwork Wed Apr 17 14:59:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10905501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3467922 for ; Wed, 17 Apr 2019 15:02:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B54D628BDE for ; Wed, 17 Apr 2019 15:02:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2D8028BF7; Wed, 17 Apr 2019 15:02:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BA80228C0C for ; Wed, 17 Apr 2019 15:02:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2V-0004Xa-HH; Wed, 17 Apr 2019 14:59:55 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2U-0004XP-L3 for xen-devel@lists.xenproject.org; Wed, 17 Apr 2019 14:59:54 +0000 X-Inumbo-ID: 74023403-6121-11e9-92d7-bc764e045a96 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 74023403-6121-11e9-92d7-bc764e045a96; Wed, 17 Apr 2019 14:59:52 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id v13so22772796ljk.4 for ; Wed, 17 Apr 2019 07:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x3xSy6QzALEoh1F0M9A/bhjWDfB8dGoDlovI8FLb5y4=; b=ZRa4iuumA2f5B5mLV2PHtRYcl1W8bWSx9QxQ5PmBEhzWFfQIqKSBPcES3WmIhvgUTx 8uZ0xssBqleLM/fOxldPb5YmRY5QpNbqPFEbas9oQdgjU3bg4oSTreKc34PmsgKa12nH 0SVsnwZbp8/DDgxaMifrf3xRrWVcI3SQB64aa60uBti6MLpfr40cBaUJqSV426qIQwIG Z2NMaLyhFRxhdYqtSODWPCRBSraq95xTON/6lYVGLv9qZ+xwlO/b8eYWJlVk67iGVQX1 Upq7U1zknxrQlBlRuwohHeRNSD9Ha8ysgNHgkoH9oMlT7BThL6GwLPgfQJmKPYlfbenN f1CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x3xSy6QzALEoh1F0M9A/bhjWDfB8dGoDlovI8FLb5y4=; b=E1XkYKgI5OJcUXUQBniklHRS3rVcVsDtlZhGNx77+cdsKT3WJEUS+H+Bml9PX1jS5P O20KFuWChapB5+Ejs0l4B2BqL5atbZ/N6tqXmfyB6Y9P2T55h9LMNqDJ+YQ8Nx0m6gFi L3gSWByiMhuhhMCLnMK030nKdqKjdOU/UCxWh0aaUCq+7mRtlSEGVvMkvA9LCVbuMyCO qYEi4/GMtK8oUeXXNULjA541j6TzDoicwG/SkJhCcq7TpTL/7hT2je6Nm4jcppL+E9g3 52d+l7cnkqY0Hqxe3cKlaKsjwr4xrhtKIrtps/kB0bq5y0p5W507Mfcj1AIx5c+e2Src FxbQ== X-Gm-Message-State: APjAAAWterlYTg75J8SNKYyzqpz0dyNkLfmE7/pvX+m4faMY2J0135im Wa4pS69XgLNoG6fDlnXryobswb7YYoc= X-Google-Smtp-Source: APXvYqy4xN4UVQbOUeYtAVQSWKTWsUgi4slFmsKsvMzpEiS8XYZm1q46jPQnSSV61rK2N6hjm84mZw== X-Received: by 2002:a2e:29da:: with SMTP id p87mr46825907ljp.33.1555513191207; Wed, 17 Apr 2019 07:59:51 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id u8sm950273lfi.83.2019.04.17.07.59.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Apr 2019 07:59:50 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 17 Apr 2019 17:59:32 +0300 Message-Id: <1555513175-7596-3-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> References: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [PATCH V4 2/5] xen/arm: drivers: scif: Extend driver to handle other interfaces X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko Extend driver to be able to handle other SCIF(X) compatible interfaces as well. These interfaces have lot in common, but mostly differ in offsets and bits for some registers. For example, the main difference between SCIF and SCIFA interfaces from "scif-uart" driver's point of view: - Registers offset: serial status, receive/transmit FIFO data registers have different offset - Internal FIFO size: 64 bytes for SCIFA and 16 bytes for SCIF - Overrun bit location: serial status register for SCIFA and dedicated line status register for SCIF Introduce "port_params" array to keep interface specific things. The "data" field in struct dt_device_match is used for recognizing what interface is present on a target board. Please note, nothing has been technically changed for Renesas "Lager" and other supported boards (SCIF). Signed-off-by: Oleksandr Tyshchenko CC: Julien Grall Acked-by: Julien Grall --- Changes in v2: - Name a enum for describing interfaces this driver supports - Use local variable for "params" where appropriate - Use "data" field in struct dt_device_match instead of calling dt_device_is_compatible() - Don't check for "overrun_reg != status_reg" condition during initialization Changes in v3: - This patch is a result of splitting an initial patch "xen/arm: drivers: scif: Add support for SCIFA compatible UARTs" and only reworks a driver - Drop "port_type" variable from scif_uart_init(), pass a pointer directly Changes in v4: - Add ASSERT(match) in scif_uart_init() - Drop "if ( params->overrun_reg != params->status_reg )" check in scif_uart_interrupt() and scif_uart_init_postirq() - Add an explanation to commit message --- xen/drivers/char/scif-uart.c | 114 ++++++++++++++++++++++++++++------------ xen/include/asm-arm/scif-uart.h | 4 -- 2 files changed, 80 insertions(+), 38 deletions(-) diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c index 465fb34..85483ee 100644 --- a/xen/drivers/char/scif-uart.c +++ b/xen/drivers/char/scif-uart.c @@ -40,16 +40,51 @@ static struct scif_uart { char __iomem *regs; struct irqaction irqaction; struct vuart_info vuart; + const struct port_params *params; } scif_com = {0}; +enum port_types +{ + SCIF_PORT, + NR_PORTS, +}; + +struct port_params +{ + unsigned int status_reg; + unsigned int tx_fifo_reg; + unsigned int rx_fifo_reg; + unsigned int overrun_reg; + unsigned int overrun_mask; + unsigned int error_mask; + unsigned int irq_flags; + unsigned int fifo_size; +}; + +static const struct port_params port_params[NR_PORTS] = +{ + [SCIF_PORT] = + { + .status_reg = SCIF_SCFSR, + .tx_fifo_reg = SCIF_SCFTDR, + .rx_fifo_reg = SCIF_SCFRDR, + .overrun_reg = SCIF_SCLSR, + .overrun_mask = SCLSR_ORER, + .error_mask = SCFSR_PER | SCFSR_FER | SCFSR_BRK | SCFSR_ER, + .irq_flags = SCSCR_RIE | SCSCR_TIE | SCSCR_REIE, + .fifo_size = 16, + }, +}; + static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs) { struct serial_port *port = data; struct scif_uart *uart = port->uart; + const struct port_params *params = uart->params; uint16_t status, ctrl; ctrl = scif_readw(uart, SCIF_SCSCR); - status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND; + status = scif_readw(uart, params->status_reg) & ~SCFSR_TEND; /* Ignore next flag if TX Interrupt is disabled */ if ( !(ctrl & SCSCR_TIE) ) status &= ~SCFSR_TDFE; @@ -65,13 +100,13 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs) serial_rx_interrupt(port, regs); /* Error Interrupt */ - if ( status & SCIF_ERRORS ) - scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS); - if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER ) - scif_writew(uart, SCIF_SCLSR, 0); + if ( status & params->error_mask ) + scif_writew(uart, params->status_reg, ~params->error_mask); + if ( scif_readw(uart, params->overrun_reg) & params->overrun_mask ) + scif_writew(uart, params->overrun_reg, ~params->overrun_mask); ctrl = scif_readw(uart, SCIF_SCSCR); - status = scif_readw(uart, SCIF_SCFSR) & ~SCFSR_TEND; + status = scif_readw(uart, params->status_reg) & ~SCFSR_TEND; /* Ignore next flag if TX Interrupt is disabled */ if ( !(ctrl & SCSCR_TIE) ) status &= ~SCFSR_TDFE; @@ -81,12 +116,13 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs) static void __init scif_uart_init_preirq(struct serial_port *port) { struct scif_uart *uart = port->uart; + const struct port_params *params = uart->params; /* * Wait until last bit has been transmitted. This is needed for a smooth * transition when we come from early printk */ - while ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TEND) ); + while ( !(scif_readw(uart, params->status_reg) & SCFSR_TEND) ); /* Disable TX/RX parts and all interrupts */ scif_writew(uart, SCIF_SCSCR, 0); @@ -95,10 +131,10 @@ static void __init scif_uart_init_preirq(struct serial_port *port) scif_writew(uart, SCIF_SCFCR, SCFCR_RFRST | SCFCR_TFRST); /* Clear all errors and flags */ - scif_readw(uart, SCIF_SCFSR); - scif_writew(uart, SCIF_SCFSR, 0); - scif_readw(uart, SCIF_SCLSR); - scif_writew(uart, SCIF_SCLSR, 0); + scif_readw(uart, params->status_reg); + scif_writew(uart, params->status_reg, 0); + scif_readw(uart, params->overrun_reg); + scif_writew(uart, params->overrun_reg, 0); /* Setup trigger level for TX/RX FIFOs */ scif_writew(uart, SCIF_SCFCR, SCFCR_RTRG11 | SCFCR_TTRG11); @@ -111,6 +147,7 @@ static void __init scif_uart_init_preirq(struct serial_port *port) static void __init scif_uart_init_postirq(struct serial_port *port) { struct scif_uart *uart = port->uart; + const struct port_params *params = uart->params; int rc; uart->irqaction.handler = scif_uart_interrupt; @@ -122,14 +159,14 @@ static void __init scif_uart_init_postirq(struct serial_port *port) uart->irq); /* Clear all errors */ - if ( scif_readw(uart, SCIF_SCFSR) & SCIF_ERRORS ) - scif_writew(uart, SCIF_SCFSR, ~SCIF_ERRORS); - if ( scif_readw(uart, SCIF_SCLSR) & SCLSR_ORER ) - scif_writew(uart, SCIF_SCLSR, 0); + if ( scif_readw(uart, params->status_reg) & params->error_mask ) + scif_writew(uart, params->status_reg, ~params->error_mask); + if ( scif_readw(uart, params->overrun_reg) & params->overrun_mask ) + scif_writew(uart, params->overrun_reg, ~params->overrun_mask); /* Enable TX/RX and Error Interrupts */ scif_writew(uart, SCIF_SCSCR, scif_readw(uart, SCIF_SCSCR) | - SCSCR_TIE | SCSCR_RIE | SCSCR_REIE); + params->irq_flags); } static void scif_uart_suspend(struct serial_port *port) @@ -145,43 +182,47 @@ static void scif_uart_resume(struct serial_port *port) static int scif_uart_tx_ready(struct serial_port *port) { struct scif_uart *uart = port->uart; + const struct port_params *params = uart->params; uint16_t cnt; /* Check for empty space in TX FIFO */ - if ( !(scif_readw(uart, SCIF_SCFSR) & SCFSR_TDFE) ) + if ( !(scif_readw(uart, params->status_reg) & SCFSR_TDFE) ) return 0; /* Check number of data bytes stored in TX FIFO */ cnt = scif_readw(uart, SCIF_SCFDR) >> 8; - ASSERT( cnt >= 0 && cnt <= SCIF_FIFO_MAX_SIZE ); + ASSERT( cnt >= 0 && cnt <= params->fifo_size ); - return (SCIF_FIFO_MAX_SIZE - cnt); + return (params->fifo_size - cnt); } static void scif_uart_putc(struct serial_port *port, char c) { struct scif_uart *uart = port->uart; + const struct port_params *params = uart->params; - scif_writeb(uart, SCIF_SCFTDR, c); + scif_writeb(uart, params->tx_fifo_reg, c); /* Clear required TX flags */ - scif_writew(uart, SCIF_SCFSR, scif_readw(uart, SCIF_SCFSR) & - ~(SCFSR_TEND | SCFSR_TDFE)); + scif_writew(uart, params->status_reg, + scif_readw(uart, params->status_reg) & + ~(SCFSR_TEND | SCFSR_TDFE)); } static int scif_uart_getc(struct serial_port *port, char *pc) { struct scif_uart *uart = port->uart; + const struct port_params *params = uart->params; /* Check for available data bytes in RX FIFO */ - if ( !(scif_readw(uart, SCIF_SCFSR) & (SCFSR_RDF | SCFSR_DR)) ) + if ( !(scif_readw(uart, params->status_reg) & (SCFSR_RDF | SCFSR_DR)) ) return 0; - *pc = scif_readb(uart, SCIF_SCFRDR); + *pc = scif_readb(uart, params->rx_fifo_reg); /* dummy read */ - scif_readw(uart, SCIF_SCFSR); + scif_readw(uart, params->status_reg); /* Clear required RX flags */ - scif_writew(uart, SCIF_SCFSR, ~(SCFSR_RDF | SCFSR_DR)); + scif_writew(uart, params->status_reg, ~(SCFSR_RDF | SCFSR_DR)); return 1; } @@ -229,9 +270,16 @@ static struct uart_driver __read_mostly scif_uart_driver = { .vuart_info = scif_vuart_info, }; +static const struct dt_device_match scif_uart_dt_match[] __initconst = +{ + { .compatible = "renesas,scif", .data = (void *)SCIF_PORT }, + { /* sentinel */ }, +}; + static int __init scif_uart_init(struct dt_device_node *dev, const void *data) { + const struct dt_device_match *match; const char *config = data; struct scif_uart *uart; int res; @@ -265,10 +313,14 @@ static int __init scif_uart_init(struct dt_device_node *dev, return -ENOMEM; } + match = dt_match_node(scif_uart_dt_match, dev); + ASSERT( match ); + uart->params = &port_params[(enum port_types)match->data]; + uart->vuart.base_addr = addr; uart->vuart.size = size; - uart->vuart.data_off = SCIF_SCFTDR; - uart->vuart.status_off = SCIF_SCFSR; + uart->vuart.data_off = uart->params->tx_fifo_reg; + uart->vuart.status_off = uart->params->status_reg; uart->vuart.status = SCFSR_TDFE; /* Register with generic serial driver */ @@ -279,12 +331,6 @@ static int __init scif_uart_init(struct dt_device_node *dev, return 0; } -static const struct dt_device_match scif_uart_dt_match[] __initconst = -{ - DT_MATCH_COMPATIBLE("renesas,scif"), - { /* sentinel */ }, -}; - DT_DEVICE_START(scif_uart, "SCIF UART", DEVICE_SERIAL) .dt_match = scif_uart_dt_match, .init = scif_uart_init, diff --git a/xen/include/asm-arm/scif-uart.h b/xen/include/asm-arm/scif-uart.h index 8137850..c343f2f 100644 --- a/xen/include/asm-arm/scif-uart.h +++ b/xen/include/asm-arm/scif-uart.h @@ -21,8 +21,6 @@ #ifndef __ASM_ARM_SCIF_UART_H #define __ASM_ARM_SCIF_UART_H -#define SCIF_FIFO_MAX_SIZE 16 - /* Register offsets */ #define SCIF_SCSMR (0x00) /* Serial mode register */ #define SCIF_SCBRR (0x04) /* Bit rate register */ @@ -57,8 +55,6 @@ #define SCFSR_RDF (1 << 1) /* Receive FIFO Data Full */ #define SCFSR_DR (1 << 0) /* Receive Data Ready */ -#define SCIF_ERRORS (SCFSR_PER | SCFSR_FER | SCFSR_ER | SCFSR_BRK) - /* Line Status Register (SCLSR) */ #define SCLSR_TO (1 << 2) /* Timeout */ #define SCLSR_ORER (1 << 0) /* Overrun Error */ From patchwork Wed Apr 17 14:59:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10905493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EDCD922 for ; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3284E287E2 for ; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30BA028C11; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82196287E2 for ; Wed, 17 Apr 2019 15:01:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2X-0004Y8-QO; Wed, 17 Apr 2019 14:59:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2V-0004Xi-U7 for xen-devel@lists.xenproject.org; Wed, 17 Apr 2019 14:59:55 +0000 X-Inumbo-ID: 74d0db0a-6121-11e9-92d7-bc764e045a96 Received: from mail-lf1-x141.google.com (unknown [2a00:1450:4864:20::141]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 74d0db0a-6121-11e9-92d7-bc764e045a96; Wed, 17 Apr 2019 14:59:54 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id o19so14797340lfl.4 for ; Wed, 17 Apr 2019 07:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GGW6lz0d+TJYKyfVW8KXFaIPKaSqBVU7ZqzfmEp2d8s=; b=Uxtd2kjBFoWpkIrslNTeFf2cR9PkLss+EYPngOFzH3oBE/Fp+JBdmn+WsnAaKGVBkW R92KaYyNbYL/DMl9y+vdiySru/hp/6RI5g1UM2dQkFLHeQq3GUblWH04XQoZ//LNLq65 FNCQAhVgZT6h4Mc+lclvIqCjcllzXV8pBlyItIUm8WRQBD36n6d/ZBWdhJ+5HudbQIM7 Vhj+kuUEI7mTAnMe/yJyVa0TWzyNsrqF/YLk7OFlFdvDHqJCx2q/JgYJdrAcfl0Cqx8Q 6P/6odQhSlQdgFCzYSSXcaGJsc7T1HI5MPcalMoUe3sN7NLVwhveUs9PQDvTmdWgv5Qd WlHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GGW6lz0d+TJYKyfVW8KXFaIPKaSqBVU7ZqzfmEp2d8s=; b=L3X0fHClaxq9UAEEfYvoAnKf2Mg+D8Y+k/780T06UxvEli0hD08tV7g+/vbbGh1X7o pAo8a9SQEB2S/YqxWsbN38eG+P9nR9Q9dw6J8rLx7i79Rry8PnR2KLGbrXv+NpaCGwu5 JPWtnuC0PaGpv9Blub9m6tjPn1dph779pkszweSZV02ZlngC+pXM4pipTblpXVx3JwFo nS3WBUh0lksO3EowEhu+3ljNUR0nvhDGr2u3KYvWfcWn+gWfdmgC25CNd6s2tcA00sgy WAKQGefWDyfb9yEF+/C9gyfIee2Di5OD7odbAOj0EcHk0CCu63D45jL4a0UA99pn4XJ1 3Uyw== X-Gm-Message-State: APjAAAVhEh5oNGoNtkc8oh9Vvi56zPULLiH6Ec/g4YFJ7dohPdGkciWN MxDsbdW2u9ZKKqmgJEMic0g+JxNOLgA= X-Google-Smtp-Source: APXvYqycQ9X6K3e738J9sTvLxwzM8jb2vB/4UNA9l+LIv6zuq0lA6eTlJdNV+7obuljYX+UR9mSHzg== X-Received: by 2002:a19:ed04:: with SMTP id y4mr102162lfy.165.1555513192452; Wed, 17 Apr 2019 07:59:52 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id u8sm950273lfi.83.2019.04.17.07.59.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Apr 2019 07:59:51 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 17 Apr 2019 17:59:33 +0300 Message-Id: <1555513175-7596-4-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> References: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [PATCH V4 3/5] xen/arm: drivers: scif: Add support for SCIFA compatible UARTs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko For the driver to be able to handle SCIFA interface as well, this patch just adds the following: - SCIFA related macros - New element in "port_params" array to keep SCIFA specific things - SCIFA compatible string This patch makes possible to use existing driver for Renesas "Stout" board based on R-Car H2 SoC (SCIFA). Signed-off-by: Oleksandr Tyshchenko CC: Julien Grall Acked-by: Julien Grall --- Changes in v3: - This patch is a result of splitting an initial patch "xen/arm: drivers: scif: Add support for SCIFA compatible UARTs" and only adds SCIFA support Changes in v4: - Remove overrun_bit (SCASSR_ORER) from error_mask --- xen/drivers/char/scif-uart.c | 17 ++++++++++++++++- xen/include/asm-arm/scif-uart.h | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c index 85483ee..fa0b827 100644 --- a/xen/drivers/char/scif-uart.c +++ b/xen/drivers/char/scif-uart.c @@ -1,7 +1,7 @@ /* * xen/drivers/char/scif-uart.c * - * Driver for SCIF (Serial communication interface with FIFO) + * Driver for SCIF(A) (Serial communication interface with FIFO (A)) * compatible UART. * * Oleksandr Tyshchenko @@ -46,6 +46,7 @@ static struct scif_uart { enum port_types { SCIF_PORT, + SCIFA_PORT, NR_PORTS, }; @@ -74,6 +75,19 @@ static const struct port_params port_params[NR_PORTS] = .irq_flags = SCSCR_RIE | SCSCR_TIE | SCSCR_REIE, .fifo_size = 16, }, + + [SCIFA_PORT] = + { + .status_reg = SCIFA_SCASSR, + .tx_fifo_reg = SCIFA_SCAFTDR, + .rx_fifo_reg = SCIFA_SCAFRDR, + .overrun_reg = SCIFA_SCASSR, + .overrun_mask = SCASSR_ORER, + .error_mask = SCASSR_PER | SCASSR_FER | SCASSR_BRK | SCASSR_ER, + .irq_flags = SCASCR_RIE | SCASCR_TIE | SCASCR_DRIE | SCASCR_ERIE | + SCASCR_BRIE, + .fifo_size = 64, + }, }; static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs) @@ -273,6 +287,7 @@ static struct uart_driver __read_mostly scif_uart_driver = { static const struct dt_device_match scif_uart_dt_match[] __initconst = { { .compatible = "renesas,scif", .data = (void *)SCIF_PORT }, + { .compatible = "renesas,scifa", .data = (void *)SCIFA_PORT }, { /* sentinel */ }, }; diff --git a/xen/include/asm-arm/scif-uart.h b/xen/include/asm-arm/scif-uart.h index c343f2f..bce3404 100644 --- a/xen/include/asm-arm/scif-uart.h +++ b/xen/include/asm-arm/scif-uart.h @@ -2,7 +2,7 @@ * xen/include/asm-arm/scif-uart.h * * Common constant definition between early printk and the UART driver - * for the SCIF compatible UART. + * for the SCIF(A) compatible UART. * * Oleksandr Tyshchenko * Copyright (C) 2014, Globallogic. @@ -21,7 +21,7 @@ #ifndef __ASM_ARM_SCIF_UART_H #define __ASM_ARM_SCIF_UART_H -/* Register offsets */ +/* Register offsets (SCIF) */ #define SCIF_SCSMR (0x00) /* Serial mode register */ #define SCIF_SCBRR (0x04) /* Bit rate register */ #define SCIF_SCSCR (0x08) /* Serial control register */ @@ -79,6 +79,42 @@ #define SCFCR_TTRG10 (SCFCR_TTRG1) #define SCFCR_TTRG11 (SCFCR_TTRG1 | SCFCR_TTRG0) +/* Register offsets (SCIFA) */ +#define SCIFA_SCASMR (0x00) /* Serial mode register */ +#define SCIFA_SCABRR (0x04) /* Bit rate register */ +#define SCIFA_SCASCR (0x08) /* Serial control register */ +#define SCIFA_SCATDSR (0x0C) /* Transmit data stop register */ +#define SCIFA_SCAFER (0x10) /* FIFO error count register */ +#define SCIFA_SCASSR (0x14) /* Serial status register */ +#define SCIFA_SCAFCR (0x18) /* FIFO control register */ +#define SCIFA_SCAFDR (0x1C) /* FIFO data count register */ +#define SCIFA_SCAFTDR (0x20) /* Transmit FIFO data register */ +#define SCIFA_SCAFRDR (0x24) /* Receive FIFO data register */ +#define SCIFA_SCAPCR (0x30) /* Serial port control register */ +#define SCIFA_SCAPDR (0x34) /* Serial port data register */ + +/* Serial Control Register (SCASCR) */ +#define SCASCR_ERIE (1 << 10) /* Receive Error Interrupt Enable */ +#define SCASCR_BRIE (1 << 9) /* Break Interrupt Enable */ +#define SCASCR_DRIE (1 << 8) /* Receive Data Ready Interrupt Enable */ +#define SCASCR_TIE (1 << 7) /* Transmit Interrupt Enable */ +#define SCASCR_RIE (1 << 6) /* Receive Interrupt Enable */ +#define SCASCR_TE (1 << 5) /* Transmit Enable */ +#define SCASCR_RE (1 << 4) /* Receive Enable */ +#define SCASCR_CKE0 (1 << 0) /* Clock Enable 0 */ + +/* Serial Status Register (SCASSR) */ +#define SCASSR_ORER (1 << 9) /* Overrun Error */ +#define SCASSR_TSF (1 << 8) /* Transmit Data Stop */ +#define SCASSR_ER (1 << 7) /* Receive Error */ +#define SCASSR_TEND (1 << 6) /* Transmission End */ +#define SCASSR_TDFE (1 << 5) /* Transmit FIFO Data Empty */ +#define SCASSR_BRK (1 << 4) /* Break Detect */ +#define SCASSR_FER (1 << 3) /* Framing Error */ +#define SCASSR_PER (1 << 2) /* Parity Error */ +#define SCASSR_RDF (1 << 1) /* Receive FIFO Data Full */ +#define SCASSR_DR (1 << 0) /* Receive Data Ready */ + #endif /* __ASM_ARM_SCIF_UART_H */ /* From patchwork Wed Apr 17 14:59:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10905497 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1D4718FD for ; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A048287E2 for ; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97F3328B95; Wed, 17 Apr 2019 15:02:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7D6228B56 for ; Wed, 17 Apr 2019 15:01:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2Y-0004YH-3L; Wed, 17 Apr 2019 14:59:58 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2W-0004Xo-6R for xen-devel@lists.xenproject.org; Wed, 17 Apr 2019 14:59:56 +0000 X-Inumbo-ID: 757ea258-6121-11e9-92d7-bc764e045a96 Received: from mail-lf1-x144.google.com (unknown [2a00:1450:4864:20::144]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 757ea258-6121-11e9-92d7-bc764e045a96; Wed, 17 Apr 2019 14:59:55 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id t11so14631597lfl.12 for ; Wed, 17 Apr 2019 07:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sYhlxjtx4Sgld5uQLxETuiOyAQru8QknI0i+nVxVUAo=; b=NMNVl8Q/3vT4P0KaAWs5nA8M4hLLkDTz8yAF/987fGtQ1XVhuDHU0BEjL7Ec8vm5Ba Ii4vglZcqIwsn8gtIwGL+vVNV3ZzxN3HhF50Zh44wLWCCMEDzLfoSZJHpCmtX4JIi2yj GEcP40BoxdNKlQGdec6Ebrwz9S+eWSiP5tw/xtUuPxb+494tqu3/LhkbtiGuAtoAs2eb iM3XAGKVl4xw+KUt90OW+lDkc46IcBbvgrafVgQQFv3SaK99wHJDkPykzxkfAbsJDUOl jYDSUq2J6jsoCyjus8DtiapKDCbST0aj5XS+eLcPcHPY0BqJIN/zKlqYibhzImxMm9cD fVag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sYhlxjtx4Sgld5uQLxETuiOyAQru8QknI0i+nVxVUAo=; b=I1ietDbpb3LQuoM4tqP9t8T89/QMqJddS8v5ors+6Mp9I6VYnfieJGlLFipFUtpkmS sTVi1Q3AvDab5/JscV31f0e6ixbIRWf3s0hUBbzDrPNIL6iq2WPOWCoD8jF4K69qw1ej GY7Ilwjn5ZWnDwQ6N5dA4aHGgoKsOPZc84BHE1yw83sAv2niGVgzTf5qFgeq/3eRm9nk FESt+Kw7cz8FyHNxoHP6QPg2mzL5G4uW2Ov3AN9iHT+3jIBKjdW5Iz5m53L3pYhTXUAf F4wMET7CIzdE+yYxO2Gv6gBNAFgH7J8bZ1/E37fU0oCUvPgQH+0wEnu7ZBpSXngXo883 LgHQ== X-Gm-Message-State: APjAAAUENSsNTEJ/I4L9g5NoMh5c5sKq9qeMTAsEoyGSlny4kLvfBjXD q0alnWXGRZH0/6LIusPkGKIkeIv8sE4= X-Google-Smtp-Source: APXvYqzQP8lrFnWupvy+X6RVblWVVow9Vdo2Y2uLoNC9cqSq9sHDSmMi4/9vqa1BwLow3OJMUxPCiA== X-Received: by 2002:a19:3f09:: with SMTP id m9mr15315708lfa.36.1555513193648; Wed, 17 Apr 2019 07:59:53 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id u8sm950273lfi.83.2019.04.17.07.59.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Apr 2019 07:59:52 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 17 Apr 2019 17:59:34 +0300 Message-Id: <1555513175-7596-5-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> References: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [PATCH V4 4/5] xen/arm: Extend SCIF early prink code to handle other interfaces X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko Extend early prink code to be able to handle other SCIF(X) compatible interfaces as well. These interfaces have lot in common, but mostly differ in offsets and bits for some registers. Introduce "EARLY_PRINTK_VERSION" config option to choose which interface version should be used (to properly apply register offsets). Please note, nothing has been technically changed for Renesas "Lager" and other supported boards (SCIF). The "EARLY_PRINTK_VERSION" option for that board should be empty: CONFIG_EARLY_PRINTK=scif,0xe6e60000 Signed-off-by: Oleksandr Tyshchenko CC: Julien Grall --- Changes in v3: - It was decided not to introduce new debug-scifa.inc for handling SCIFA interface, but to extend existing debug-scif.inc for handling both interfaces. This patch is a result of splitting an initial patch "xen/arm: Add SCIFA UART support for early printk" and only reworks a code Changes in v4: - Update docs/misc/arm/early-printk.txt with the new option --- docs/misc/arm/early-printk.txt | 6 ++++++ xen/arch/arm/Rules.mk | 7 +++++++ xen/arch/arm/arm32/debug-scif.inc | 13 +++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index b23c54f..c054674 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -27,6 +27,12 @@ CONFIG_EARLY_PRINTK=,, If is not given then the code will not try to initialize the UART, so that bootloader or firmware settings can be used for maximum compatibility. + - scif,, + - is a option to choose which interface version should be used + on a target board. + + If is not given then a default interface version (SCIF) + will be used. - For all other uarts there are no additional options. As a convenience it is also possible to select from a list of diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index f264592..3d9a0ed 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -68,6 +68,13 @@ EARLY_PRINTK_INIT_UART := y EARLY_PRINTK_BAUD := $(word 3,$(EARLY_PRINTK_CFG)) endif endif +ifeq ($(EARLY_PRINTK_INC),scif) +ifneq ($(word 3,$(EARLY_PRINTK_CFG)),) +CFLAGS-y += -DEARLY_PRINTK_VERSION_$(word 3,$(EARLY_PRINTK_CFG)) +else +CFLAGS-y += -DEARLY_PRINTK_VERSION_NONE +endif +endif ifneq ($(EARLY_PRINTK_INC),) EARLY_PRINTK := y diff --git a/xen/arch/arm/arm32/debug-scif.inc b/xen/arch/arm/arm32/debug-scif.inc index 143f05d..a8d2eae 100644 --- a/xen/arch/arm/arm32/debug-scif.inc +++ b/xen/arch/arm/arm32/debug-scif.inc @@ -19,6 +19,11 @@ #include +#ifdef EARLY_PRINTK_VERSION_NONE +#define STATUS_REG SCIF_SCFSR +#define TX_FIFO_REG SCIF_SCFTDR +#endif + /* * SCIF UART wait UART to be ready to transmit * rb: register which contains the UART base address @@ -26,7 +31,7 @@ */ .macro early_uart_ready rb rc 1: - ldrh \rc, [\rb, #SCIF_SCFSR] /* <- SCFSR (status register) */ + ldrh \rc, [\rb, #STATUS_REG] /* Read status register */ tst \rc, #SCFSR_TDFE /* Check TDFE bit */ beq 1b /* Wait for the UART to be ready */ .endm @@ -37,10 +42,10 @@ * rt: register which contains the character to transmit */ .macro early_uart_transmit rb rt - strb \rt, [\rb, #SCIF_SCFTDR] /* -> SCFTDR (data register) */ - ldrh \rt, [\rb, #SCIF_SCFSR] /* <- SCFSR (status register) */ + strb \rt, [\rb, #TX_FIFO_REG] /* Write data register */ + ldrh \rt, [\rb, #STATUS_REG] /* Read status register */ and \rt, \rt, #(~(SCFSR_TEND | SCFSR_TDFE)) /* Clear TEND and TDFE bits */ - strh \rt, [\rb, #SCIF_SCFSR] /* -> SCFSR (status register) */ + strh \rt, [\rb, #STATUS_REG] /* Write status register */ .endm /* From patchwork Wed Apr 17 14:59:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Tyshchenko X-Patchwork-Id: 10905491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 764D2922 for ; Wed, 17 Apr 2019 15:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CD4828BFB for ; Wed, 17 Apr 2019 15:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AA5E28C04; Wed, 17 Apr 2019 15:01:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D9CCD28C04 for ; Wed, 17 Apr 2019 15:01:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2Z-0004Z1-Ht; Wed, 17 Apr 2019 14:59:59 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hGm2Y-0004YC-3u for xen-devel@lists.xenproject.org; Wed, 17 Apr 2019 14:59:58 +0000 X-Inumbo-ID: 7637ba27-6121-11e9-92d7-bc764e045a96 Received: from mail-lj1-x242.google.com (unknown [2a00:1450:4864:20::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 7637ba27-6121-11e9-92d7-bc764e045a96; Wed, 17 Apr 2019 14:59:56 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id v22so22735180lje.9 for ; Wed, 17 Apr 2019 07:59:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OmOgL02dvpS19ASKNLZ4vp7Da8zd0cLebcIPv5YiIL4=; b=G4zsPqqHde0INSI4jfI98Kj8vz3Nq+OSbHTop/Z/zEg185wz0knBQH5m8pA2uMZB5K hTKwQSpbk8Thyb7SZyrLlWDLDNXmYhXRKGjJFnHxAQuWa+M8KnRo2lQXfeTdnvmQijmV PF4GQfJJ8+nTQJC+gC101kcuRaoDoHPao2K981grTyp3ROLAbK9hg9Iydywjb7SzXpn8 +OltZIPjSNPzXrd32cXlnLsLmajWR26/OwApy+4Z4kEceEadwhpohQjQcBxQngoV7tZB 9nbTDWPkhVz9i4XCdIaXu/4fBp4s++Zqy+SeMD+pbdh6FbbF9NC4GZNGj8k7l/go0d+G 7Onw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OmOgL02dvpS19ASKNLZ4vp7Da8zd0cLebcIPv5YiIL4=; b=sRUT4ErBOqvTWCBGmWlc0OwzBXCROLBasTdP0UNvBTV8mHgFT8px0cIpAqJb7w1qae W+anYU9wbop/uuxrds265yYwXFqXSfxxhJXLsjpDJmT4gGeRDCx2C7MtDepKS5dJ/kiF gdJ59Zz9/UiCa9XJPq5C3q7WtG2OollEONWacccti1OG/F3ZpQOnPfptBCBwuwubpZX3 qIQuXRC9ji+VTy5V2AQUgd6/G+JkhYVpLaXi0IjL30KF5K+YP97xPvwAHZfJcbJQ21hL d1SId/XRJUob3LMY4fIVkf4qHgnuVIwDJLOYNv7QRxW1pceL+A4zh0VM98rAy6SMIXPu Smgg== X-Gm-Message-State: APjAAAWOIY12+0AfixXPMqC0qFbTxzSjZo9v9rgRTBWPPz65JjMsNf0z j/cd3MBicpcm2VF2QFxWfwFRiIqrV5I= X-Google-Smtp-Source: APXvYqzgizrBpaNQ0r1ua62Y4cgkqbnkOJWBZyclskb4RcKlBnZ9lODpZ21e66PBXUOxWwtQYIvzgQ== X-Received: by 2002:a2e:88c1:: with SMTP id a1mr6942011ljk.78.1555513195016; Wed, 17 Apr 2019 07:59:55 -0700 (PDT) Received: from otyshchenko.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id u8sm950273lfi.83.2019.04.17.07.59.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Apr 2019 07:59:54 -0700 (PDT) From: Oleksandr Tyshchenko To: xen-devel@lists.xenproject.org Date: Wed, 17 Apr 2019 17:59:35 +0300 Message-Id: <1555513175-7596-6-git-send-email-olekstysh@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> References: <1555513175-7596-1-git-send-email-olekstysh@gmail.com> Subject: [Xen-devel] [PATCH V4 5/5] xen/arm: Add early printk support for SCIFA compatible UARTs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Oleksandr Tyshchenko , julien.grall@arm.com, sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Tyshchenko This patch makes possible to use existing early prink code for Renesas "Stout" board based on R-Car H2 SoC (SCIFA). The "EARLY_PRINTK_VERSION" for that board should be 'A': CONFIG_EARLY_PRINTK=scif,0xe6c40000,A Signed-off-by: Oleksandr Tyshchenko CC: Julien Grall --- Changes in v3: - It was decided not to introduce new debug-scifa.inc for handling SCIFA interface, but to extend existing debug-scif.inc for handling both interfaces. This patch is a result of splitting an initial patch "xen/arm: Add SCIFA UART support for early printk" and only adds a support. Changes in v4: - Drop SCIF(A) from comments --- xen/arch/arm/arm32/debug-scif.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/arm32/debug-scif.inc b/xen/arch/arm/arm32/debug-scif.inc index a8d2eae..3f01c90 100644 --- a/xen/arch/arm/arm32/debug-scif.inc +++ b/xen/arch/arm/arm32/debug-scif.inc @@ -1,7 +1,7 @@ /* * xen/arch/arm/arm32/debug-scif.inc * - * SCIF specific debug code + * SCIF(A) specific debug code * * Oleksandr Tyshchenko * Copyright (C) 2014, Globallogic. @@ -22,10 +22,13 @@ #ifdef EARLY_PRINTK_VERSION_NONE #define STATUS_REG SCIF_SCFSR #define TX_FIFO_REG SCIF_SCFTDR +#elif EARLY_PRINTK_VERSION_A +#define STATUS_REG SCIFA_SCASSR +#define TX_FIFO_REG SCIFA_SCAFTDR #endif /* - * SCIF UART wait UART to be ready to transmit + * Wait UART to be ready to transmit * rb: register which contains the UART base address * rc: scratch register */ @@ -37,7 +40,7 @@ .endm /* - * SCIF UART transmit character + * UART transmit character * rb: register which contains the UART base address * rt: register which contains the character to transmit */