Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1703210pxv; Fri, 25 Jun 2021 21:14:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvOShCC4V/PSh4pkdfQ9aQBkTQ6nii5KK6EB4TFy2SPoeR3rUgCjRs2nIjp3qsxXHVdzfy X-Received: by 2002:a05:6402:2210:: with SMTP id cq16mr19355988edb.261.1624680891926; Fri, 25 Jun 2021 21:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624680891; cv=none; d=google.com; s=arc-20160816; b=JHX2uR3VD3dOGYHIPxmNX4VH9wNRphbekVyZ1k9G6wkVTM6e/I9rpDNIcdEOF2n9jZ UoPAcXRPfajYI3RsM8nE/eL/gkOQglwq0d+J1wunDSASuXPCNHviSyJsdugJHvFDJo8V JAK68JLe5OUX+9blSN+0oXQVSNnHkgDCnn6s8dYJHzJE4VyomoQgt/cazabCnpxn+DgU OrsGbrYwT/3WQ/d//Yh1yYSvLrqFM2Gog6/m/Dh0DFQdRWBKJ559ZqB3oPhk+8YC+lM9 7dtnqBixseSCT9tkEGNcLZmcLWBlq0kD0Fb32XBNSFoyKqZBumlMPmbGGx5hgaM5PJxL WYGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=7XmQvQvm0aPu5N9PjvLgCyZvcSKg+RE2nU9tcAt0ep0=; b=zJWbye8NGnLibbNAEOJGc/J8zdwzI75dQNgnrVY15M8ZMqrQTvgNDrU9MNtB2rv64N +LxmfQsSFfEQZR6QDXJ8+GqIpnfhoGvoJ1J0bbj/2skh2A/BSCwTX9/v6jCEjS1WRM2H 6lzpA+S6aVNo0Y8usqNWZnHgc2MoXrwxGfuG2gb4Dmwu7b9JaIkS37dmSd9uKNVLdFed K9PdEqSqYnsxWwiwIEizbp+uxfb4R020CXDn1JyGvbT7W/OrT28AA10kvgUTgI9HFWfX RHuLxTxizqWvVYPLYSE0AlIgxodCV2ZLahXAvS0UtU8EP2jR1SJI5yLVy3SZwGfEgsA6 E1+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f24si7746398edr.606.2021.06.25.21.14.29; Fri, 25 Jun 2021 21:14:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbhFZENg (ORCPT + 99 others); Sat, 26 Jun 2021 00:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbhFZENf (ORCPT ); Sat, 26 Jun 2021 00:13:35 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 00CC2C061574 for ; Fri, 25 Jun 2021 21:11:13 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id 3F9D29200BF; Sat, 26 Jun 2021 06:11:13 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 3C9289200BC; Sat, 26 Jun 2021 06:11:13 +0200 (CEST) Date: Sat, 26 Jun 2021 06:11:13 +0200 (CEST) From: "Maciej W. Rozycki" To: Greg Kroah-Hartman , Jiri Slaby , Thomas Bogendoerfer cc: linux-serial@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 2/2] MIPS: Malta: Do not byte-swap accesses to the CBUS UART In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Correct big-endian accesses to the CBUS UART, a Malta on-board discrete TI16C550C part wired directly to the system controller's device bus, and do not use byte swapping with the 32-bit accesses to the device. The CBUS is used for devices such as the boot flash memory needed early on in system bootstrap even before PCI has been initialised. Therefore it uses the system controller's device bus, which follows the endianness set with the CPU, which means no byte-swapping is ever required for data accesses to CBUS, unlike with PCI. The CBUS UART uses the UPIO_MEM32 access method, that is the `readl' and `writel' MMIO accessors, which on the MIPS platform imply byte-swapping with PCI systems. Consequently the wrong byte lane is accessed with the big-endian configuration and the UART is not correctly accessed. As it happens the UPIO_MEM32BE access method makes use of the `ioread32' and `iowrite32' MMIO accessors, which still use `readl' and `writel' respectively, however they byte-swap data passed, effectively cancelling swapping done with the accessors themselves and making it suitable for the CBUS UART. Make the CBUS UART switch between UPIO_MEM32 and UPIO_MEM32BE then, based on the endianness selected. With this change in place the device is correctly recognised with big-endian Malta at boot, along with the Super I/O devices behind PCI: Serial: 8250/16550 driver, 5 ports, IRQ sharing enabled printk: console [ttyS0] disabled serial8250.0: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A printk: console [ttyS0] enabled printk: bootconsole [uart8250] disabled serial8250.0: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A serial8250.0: ttyS2 at MMIO 0x1f000900 (irq = 20, base_baud = 230400) is a 16550A Signed-off-by: Maciej W. Rozycki Fixes: e7c4782f92fc ("[MIPS] Put an end to 's long and annyoing existence") Cc: stable@vger.kernel.org # v2.6.23+ --- Changes from v1: - Remove console message duplicates from the commit description. --- arch/mips/mti-malta/malta-platform.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) linux-mips-malta-cbus-uart-be.diff Index: linux-macro-ide-tty/arch/mips/mti-malta/malta-platform.c =================================================================== --- linux-macro-ide-tty.orig/arch/mips/mti-malta/malta-platform.c +++ linux-macro-ide-tty/arch/mips/mti-malta/malta-platform.c @@ -48,7 +48,8 @@ static struct plat_serial8250_port uart8 .mapbase = 0x1f000900, /* The CBUS UART */ .irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_MB2, .uartclk = 3686400, /* Twice the usual clk! */ - .iotype = UPIO_MEM32, + .iotype = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) ? + UPIO_MEM32BE : UPIO_MEM32, .flags = CBUS_UART_FLAGS, .regshift = 3, },