Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3357939iob; Mon, 16 May 2022 20:34:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgc+B01vSS3h5oV9pBnuslCOlJJCtAuc5j7RpGEkWtlW48QV4JQJ89T0OsMjjOBvhTKmtX X-Received: by 2002:a17:907:3e90:b0:6f7:f63:78b6 with SMTP id hs16-20020a1709073e9000b006f70f6378b6mr17804147ejc.3.1652758455782; Mon, 16 May 2022 20:34:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652758455; cv=none; d=google.com; s=arc-20160816; b=xZbpBHUuBSGo8A3FPNQSNPPuIgT76MHv40RDS9hOG9mZ017dhs+C27FO56xyOLp+k+ ZdCSA96cEv3/9lhveZ54Say61Ma+7RUynDeftGP1a1pT30iMGsYx/3TizNC9JOa8tLMF xe5RYsow3VDr2d85WDxXNfxySciprE2iIaMlkdo6zgYMqQR0+unvFqFnhP5rhgUV409j GDL6Pmz/OgwQe4D89kQTqa5nPQ1aZPzptQEe7FinFsy0hZA1PMTrknLHq5WBdNydc7QA anybBsd35hITSMU2oRimfP8OZRq2Z/5Gqkip69ywltxtn+cyylp7HL86KiMtUNerCYMH 8GFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2+7aYTpH57cKCXqMSKnW2C+7I/V9PDowO9Hl3uO/TF0=; b=nQ5cI/JV2y63ZpAP1UtUt+ER1AQvvmwX9bToOXI7qaajCPjoXRTjbn47CqFP9/Hyq6 0xhdODpWgLaJBe4J6hv7EKW/bdE7v//xBlgoLZC/ZLnPR8SCR5e8lW6oSmvx8bX8TWVD 01+jBNkfoxSiz5Ipy/xYbjErbjnCkgaXsN7ebMKg4ApA+AQ+nDdC0t8TQD9sxKcokg3m fAv8BMydVUmBlx/MqDrriRJJZFuUfVmMEabC4k49GsgLLS1DqpHImCj3URcUcG3OymiJ nh7emGDnzwVW0Oy2I//rsjeWMa6YTSCpeIA0SFPgMmM6GNdZo0N0GeQ3/9hy4NIDuBKs LBxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lf8I6p9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2-20020a1709067b8200b006f428802b05si1249822ejo.220.2022.05.16.20.33.49; Mon, 16 May 2022 20:34:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lf8I6p9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347168AbiEPTvu (ORCPT + 99 others); Mon, 16 May 2022 15:51:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347020AbiEPTq5 (ORCPT ); Mon, 16 May 2022 15:46:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E02D427F5; Mon, 16 May 2022 12:44:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D46376154E; Mon, 16 May 2022 19:44:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4630C385AA; Mon, 16 May 2022 19:44:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652730258; bh=9o4RUFqur9mew6cE5fqLdZI9D4SDZqn1UsWDbvfWv3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lf8I6p9TZpsFGehl0Pvv2KgHj0FTOisFEx+dhU+9ehu8wkSArAFnwk11Rglms4VTn LyjMyOMBazMBHkE4liny0EmKa/mh//lBW2Kw5Q/cIq/FAj4weogN2r7tsWss3kJz/l tnbLWJ/2rWIuMlUhZ7wxLn/uo3/IiQQzqvOj4gSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, AngeloGioacchino Del Regno Subject: [PATCH 5.4 33/43] serial: 8250_mtk: Fix UART_EFR register address Date: Mon, 16 May 2022 21:36:44 +0200 Message-Id: <20220516193615.695595614@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516193614.714657361@linuxfoundation.org> References: <20220516193614.714657361@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: AngeloGioacchino Del Regno commit bb0b197aadd928f52ce6f01f0ee977f0a08cf1be upstream. On MediaTek SoCs, the UART IP is 16550A compatible, but there are some specific quirks: we are declaring a register shift of 2, but this is only valid for the majority of the registers, as there are some that are out of the standard layout. Specifically, this driver is using definitions from serial_reg.h, where we have a UART_EFR register defined as 2: this results in a 0x8 offset, but there we have the FCR register instead. The right offset for the EFR register on MediaTek UART is at 0x98, so, following the decimal definition convention in serial_reg.h and accounting for the register left shift of two, add and use the correct register address for this IP, defined as decimal 38, so that the final calculation results in (0x26 << 2) = 0x98. Fixes: bdbd0a7f8f03 ("serial: 8250-mtk: modify baudrate setting") Signed-off-by: AngeloGioacchino Del Regno Cc: stable Link: https://lore.kernel.org/r/20220427132328.228297-2-angelogioacchino.delregno@collabora.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_mtk.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c @@ -36,6 +36,7 @@ #define MTK_UART_IER_RTSI 0x40 /* Enable RTS Modem status interrupt */ #define MTK_UART_IER_CTSI 0x80 /* Enable CTS Modem status interrupt */ +#define MTK_UART_EFR 38 /* I/O: Extended Features Register */ #define MTK_UART_EFR_EN 0x10 /* Enable enhancement feature */ #define MTK_UART_EFR_RTS 0x40 /* Enable hardware rx flow control */ #define MTK_UART_EFR_CTS 0x80 /* Enable hardware tx flow control */ @@ -168,7 +169,7 @@ static void mtk8250_dma_enable(struct ua MTK_UART_DMA_EN_RX | MTK_UART_DMA_EN_TX); serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); - serial_out(up, UART_EFR, UART_EFR_ECB); + serial_out(up, MTK_UART_EFR, UART_EFR_ECB); serial_out(up, UART_LCR, lcr); if (dmaengine_slave_config(dma->rxchan, &dma->rxconf) != 0) @@ -231,7 +232,7 @@ static void mtk8250_set_flow_ctrl(struct int lcr = serial_in(up, UART_LCR); serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); - serial_out(up, UART_EFR, UART_EFR_ECB); + serial_out(up, MTK_UART_EFR, UART_EFR_ECB); serial_out(up, UART_LCR, lcr); lcr = serial_in(up, UART_LCR); @@ -240,7 +241,7 @@ static void mtk8250_set_flow_ctrl(struct serial_out(up, MTK_UART_ESCAPE_DAT, MTK_UART_ESCAPE_CHAR); serial_out(up, MTK_UART_ESCAPE_EN, 0x00); serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); - serial_out(up, UART_EFR, serial_in(up, UART_EFR) & + serial_out(up, MTK_UART_EFR, serial_in(up, MTK_UART_EFR) & (~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK))); serial_out(up, UART_LCR, lcr); mtk8250_disable_intrs(up, MTK_UART_IER_XOFFI | @@ -254,8 +255,8 @@ static void mtk8250_set_flow_ctrl(struct serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /*enable hw flow control*/ - serial_out(up, UART_EFR, MTK_UART_EFR_HW_FC | - (serial_in(up, UART_EFR) & + serial_out(up, MTK_UART_EFR, MTK_UART_EFR_HW_FC | + (serial_in(up, MTK_UART_EFR) & (~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK)))); serial_out(up, UART_LCR, lcr); @@ -269,8 +270,8 @@ static void mtk8250_set_flow_ctrl(struct serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); /*enable sw flow control */ - serial_out(up, UART_EFR, MTK_UART_EFR_XON1_XOFF1 | - (serial_in(up, UART_EFR) & + serial_out(up, MTK_UART_EFR, MTK_UART_EFR_XON1_XOFF1 | + (serial_in(up, MTK_UART_EFR) & (~(MTK_UART_EFR_HW_FC | MTK_UART_EFR_SW_FC_MASK)))); serial_out(up, UART_XON1, START_CHAR(port->state->port.tty));