2007-07-10 16:33:01 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
2008-12-01 08:16:08 +00:00
|
|
|
* Copyright (C) 2006, 07 MIPS Technologies, Inc.
|
2007-07-10 16:33:01 +00:00
|
|
|
* written by Ralf Baechle (ralf@linux-mips.org)
|
2008-12-01 08:16:08 +00:00
|
|
|
* written by Ralf Baechle <ralf@linux-mips.org>
|
2007-07-10 16:33:01 +00:00
|
|
|
*
|
2008-11-25 08:33:20 +00:00
|
|
|
* Copyright (C) 2008 Wind River Systems, Inc.
|
|
|
|
* updated by Tiejun Chen <tiejun.chen@windriver.com>
|
|
|
|
*
|
|
|
|
* 1. Probe driver for the Malta's UART ports:
|
2007-07-10 16:33:01 +00:00
|
|
|
*
|
|
|
|
* o 2 ports in the SMC SuperIO
|
|
|
|
* o 1 port in the CBUS UART, a discrete 16550 which normally is only used
|
|
|
|
* for bringups.
|
|
|
|
*
|
|
|
|
* We don't use 8250_platform.c on Malta as it would result in the CBUS
|
|
|
|
* UART becoming ttyS0.
|
2008-11-25 08:33:20 +00:00
|
|
|
*
|
|
|
|
* 2. Register RTC-CMOS platform device on Malta.
|
2007-07-10 16:33:01 +00:00
|
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/serial_8250.h>
|
2010-10-07 13:08:54 +00:00
|
|
|
#include <linux/irq.h>
|
2008-11-25 08:33:20 +00:00
|
|
|
#include <linux/platform_device.h>
|
2012-11-13 09:41:50 +00:00
|
|
|
#include <asm/mips-boards/maltaint.h>
|
2007-07-10 16:33:01 +00:00
|
|
|
|
|
|
|
#define SMC_PORT(base, int) \
|
|
|
|
{ \
|
|
|
|
.iobase = base, \
|
|
|
|
.irq = int, \
|
|
|
|
.uartclk = 1843200, \
|
|
|
|
.iotype = UPIO_PORT, \
|
2021-06-10 18:38:48 +00:00
|
|
|
.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | \
|
|
|
|
UPF_MAGIC_MULTIPLIER, \
|
2007-07-10 16:33:01 +00:00
|
|
|
.regshift = 0, \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CBUS_UART_FLAGS (UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP)
|
|
|
|
|
|
|
|
static struct plat_serial8250_port uart8250_data[] = {
|
|
|
|
SMC_PORT(0x3F8, 4),
|
|
|
|
SMC_PORT(0x2F8, 3),
|
2013-10-14 08:49:25 +00:00
|
|
|
#ifndef CONFIG_MIPS_CMP
|
2007-07-10 16:33:01 +00:00
|
|
|
{
|
|
|
|
.mapbase = 0x1f000900, /* The CBUS UART */
|
2012-11-13 09:41:50 +00:00
|
|
|
.irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_MB2,
|
2007-07-10 16:33:01 +00:00
|
|
|
.uartclk = 3686400, /* Twice the usual clk! */
|
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: e7c4782f92fc ("[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-06-26 04:11:13 +00:00
|
|
|
.iotype = IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) ?
|
|
|
|
UPIO_MEM32BE : UPIO_MEM32,
|
2007-07-10 16:33:01 +00:00
|
|
|
.flags = CBUS_UART_FLAGS,
|
|
|
|
.regshift = 3,
|
|
|
|
},
|
2013-10-14 08:49:25 +00:00
|
|
|
#endif
|
2007-07-10 16:33:01 +00:00
|
|
|
{ },
|
|
|
|
};
|
|
|
|
|
2008-11-25 08:33:20 +00:00
|
|
|
static struct platform_device malta_uart8250_device = {
|
2007-07-10 16:33:01 +00:00
|
|
|
.name = "serial8250",
|
2008-12-01 08:16:08 +00:00
|
|
|
.id = PLAT8250_DEV_PLATFORM,
|
2007-07-10 16:33:01 +00:00
|
|
|
.dev = {
|
|
|
|
.platform_data = uart8250_data,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2008-11-25 08:33:20 +00:00
|
|
|
static struct platform_device *malta_devices[] __initdata = {
|
|
|
|
&malta_uart8250_device,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init malta_add_devices(void)
|
2007-07-10 16:33:01 +00:00
|
|
|
{
|
2016-09-14 15:31:01 +00:00
|
|
|
return platform_add_devices(malta_devices, ARRAY_SIZE(malta_devices));
|
2008-11-25 08:33:20 +00:00
|
|
|
}
|
2007-07-10 16:33:01 +00:00
|
|
|
|
2008-11-25 08:33:20 +00:00
|
|
|
device_initcall(malta_add_devices);
|