linux/arch/mips/mti-malta
Maciej W. Rozycki 9a936d6c3d MIPS: Malta: Do not byte-swap accesses to the CBUS UART
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

Fixes: e7c4782f92 ("[MIPS] Put an end to <asm/serial.h>'s long and annyoing existence")
Cc: stable@vger.kernel.org # v2.6.23+
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2106260524430.37803@angie.orcam.me.uk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-21 12:52:14 +02:00
..
Makefile MIPS: malta: Use img-ascii-lcd driver for LCD display 2018-11-20 21:05:39 -08:00
malta-amon.c MIPS: APRP: Choose the correct VPE loader by fixing the linking 2014-03-06 21:20:23 +01:00
malta-dt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
malta-dtshim.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
malta-init.c MIPS: init: move externs to header file 2021-01-07 17:12:51 +01:00
malta-int.c MIPS: Replace setup_irq() by request_irq() 2020-03-05 16:47:35 +01:00
malta-memory.c MIPS: Remove empty prom_free_prom_memory functions 2021-01-07 17:11:33 +01:00
malta-platform.c MIPS: Malta: Do not byte-swap accesses to the CBUS UART 2021-07-21 12:52:14 +02:00
malta-setup.c driver core: lift dma_default_coherent into common code 2021-02-13 09:51:45 +01:00
malta-time.c MIPS: Remove KVM_GUEST support 2021-03-10 15:18:40 +01:00
Platform MIPS: Remove KVM_GUEST support 2021-03-10 15:18:40 +01:00