Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp404463ybm; Wed, 22 May 2019 05:19:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoqQXSetDN3/9JyIO2H+Esvtq5pZ1OO3g6BSg+lgEdBO4CnXttj0Du1fT3bogj5yI24K2P X-Received: by 2002:a62:1bcc:: with SMTP id b195mr41966577pfb.75.1558527588479; Wed, 22 May 2019 05:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558527588; cv=none; d=google.com; s=arc-20160816; b=SuTuGsDROMigXvfIKuDinhO4mNt/XYO60s6Eprk5AENuVX214jIc84D7yp+DwkI7yW MTGzqCW/GiawE3LsXu2ZWgM0cgRnVXbzl5n3phbB9Yar1eRe+VC9FXX67/F83TcWQmdL zULvZGLet9W5BnC1M0g9xJNukQ941+QPRDRgM+8XxI5Y0SiGvdjKnZMOMmmjwIlQ86AP 5ra9m23+uq8pFDgZkZiN9AERIa9ZAbDqCe1BGgzpALHImm0FH2JjU+jicpvcj0lt2kam aogRkrAoEXk8GZ5ZqguvNLavKBu3tfO2W8Wtm18RnLVbmDl6Fjam+Get0pGc4vHWqTRy I6hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :dkim-signature; bh=ULpgX9HYncfSaEjyyyTwrdNHRBTq+jrPPxiAH/Bi1aw=; b=tGwxSM8Eh6YiVh8RQX/oQbd8uWh946SX1FPr27fAI/NO37VRvSDNLqXbkEDeLca0kH dgTVE76V8fdsUXjfheS5Om/DA5uSCoL4e4Z2e30Ow459VmkHmowrmYkAjK6eFAtlZwTY lS981Aak/VL45VEL54F+PwNo9uH/G+TZtPX7hVS3AmN74gO9IghZ/0KHfK7A79zYRKyA CnYWHEx0OSuwKpBjU6CHIcOsghaDa2Kxl2wYzFKjdRF4R1AKfU91A04VlcacD3hXW1BF J9Jf7ZXvc5pZjculeZYpnAnuoDk71wY3wGc5aSR4DDjoRXWfdO0gt2mSYAdJ9ICFbYTP OnFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=aSA1itul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cn12si26770489plb.349.2019.05.22.05.19.32; Wed, 22 May 2019 05:19:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=aSA1itul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbfEVMRO (ORCPT + 99 others); Wed, 22 May 2019 08:17:14 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:45745 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728680AbfEVMRO (ORCPT ); Wed, 22 May 2019 08:17:14 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 458BTM0ZB4z9v2JC; Wed, 22 May 2019 14:17:11 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=aSA1itul; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id 2tBcVXNsQ-sn; Wed, 22 May 2019 14:17:11 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 458BTL6PbWz9v2JB; Wed, 22 May 2019 14:17:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1558527430; bh=ULpgX9HYncfSaEjyyyTwrdNHRBTq+jrPPxiAH/Bi1aw=; h=From:Subject:To:Cc:Date:From; b=aSA1itulWnmknDSRHJhSq1WT91YKt9nFX1g2vucCgzWDHHhNM0nDTcVysFxUvQZic 1v9U+CpLqpd8blZoTTPh8TgLi0ZrXGB2y7lrwuGlEn9MQBjybBAVdsixui/i5AXygf 0bmPvZ5IMK1zkqvNUvDbvhChGB8o7760K93FkHZU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 2F6C18B840; Wed, 22 May 2019 14:17:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id a6HB5Dsaeycs; Wed, 22 May 2019 14:17:12 +0200 (CEST) Received: from po16846vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 0A5E98B83E; Wed, 22 May 2019 14:17:12 +0200 (CEST) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id E04AD68430; Wed, 22 May 2019 12:17:11 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] tty: serial: cpm_uart - fix init when SMC is relocated To: Greg Kroah-Hartman , Jiri Slaby Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-serial@vger.kernel.org Date: Wed, 22 May 2019 12:17:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SMC relocation can also be activated earlier by the bootloader, so the driver's behaviour cannot rely on selected kernel config. When the SMC is relocated, CPM_CR_INIT_TRX cannot be used. But the only thing CPM_CR_INIT_TRX does is to clear the rstate and tstate registers, so this can be done manually, even when SMC is not relocated. Signed-off-by: Christophe Leroy Fixes: 9ab921201444 ("cpm_uart: fix non-console port startup bug") --- drivers/tty/serial/cpm_uart/cpm_uart_core.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index b929c7ae3a27..7bab9a3eda92 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c @@ -407,7 +407,16 @@ static int cpm_uart_startup(struct uart_port *port) clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_RX); } cpm_uart_initbd(pinfo); - cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX); + if (IS_SMC(pinfo)) { + out_be32(&pinfo->smcup->smc_rstate, 0); + out_be32(&pinfo->smcup->smc_tstate, 0); + out_be16(&pinfo->smcup->smc_rbptr, + in_be16(&pinfo->smcup->smc_rbase)); + out_be16(&pinfo->smcup->smc_tbptr, + in_be16(&pinfo->smcup->smc_tbase)); + } else { + cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX); + } } /* Install interrupt handler. */ retval = request_irq(port->irq, cpm_uart_int, 0, "cpm_uart", port); @@ -861,16 +870,14 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo) (u8 __iomem *)pinfo->tx_bd_base - DPRAM_BASE); /* - * In case SMC1 is being relocated... + * In case SMC is being relocated... */ -#if defined (CONFIG_I2C_SPI_SMC1_UCODE_PATCH) out_be16(&up->smc_rbptr, in_be16(&pinfo->smcup->smc_rbase)); out_be16(&up->smc_tbptr, in_be16(&pinfo->smcup->smc_tbase)); out_be32(&up->smc_rstate, 0); out_be32(&up->smc_tstate, 0); out_be16(&up->smc_brkcr, 1); /* number of break chars */ out_be16(&up->smc_brkec, 0); -#endif /* Set up the uart parameters in the * parameter ram. @@ -884,8 +891,6 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo) out_be16(&up->smc_brkec, 0); out_be16(&up->smc_brkcr, 1); - cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX); - /* Set UART mode, 8 bit, no parity, one stop. * Enable receive and transmit. */ -- 2.13.3