[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20200306124901.8D4668030700@mail.baikalelectronics.ru>
Date: Fri, 6 Mar 2020 15:46:57 +0300
From: <Sergey.Semin@...kalelectronics.ru>
To: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
CC: Serge Semin <Sergey.Semin@...kalelectronics.ru>,
Serge Semin <fancer.lancer@...il.com>,
Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>,
Paul Burton <paulburton@...nel.org>,
Ralf Baechle <ralf@...ux-mips.org>,
<linux-mips@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH 14/22] mips: early_printk_8250: Use offset-sized IO-mem accessors
From: Serge Semin <Sergey.Semin@...kalelectronics.ru>
Some platforms may prohibit to access the IO-memory with instructions
of certain memory widths. For instance Bailal-T1 has devices placed
behind memory OCP port (which also the reason of DMA accesses being
incoherent) and can't be accessed through CCA uncacheable memory with
other than 4-bytes aligned (LW/SW) instructions. Ignoring this rule
will cause the APB EHB error with 0xFFs returned on read operations.
In order to fix the issue for this platform and for others, which may
have similar problems, lets recode serial_in()/serial_out() to call
a certain memory accessors in accordance with the UART registers shift
setting.
Signed-off-by: Serge Semin <Sergey.Semin@...kalelectronics.ru>
Signed-off-by: Alexey Malahov <Alexey.Malahov@...kalelectronics.ru>
Cc: Thomas Bogendoerfer <tsbogend@...ha.franken.de>
Cc: Paul Burton <paulburton@...nel.org>
Cc: Ralf Baechle <ralf@...ux-mips.org>
---
arch/mips/kernel/early_printk_8250.c | 34 ++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/arch/mips/kernel/early_printk_8250.c b/arch/mips/kernel/early_printk_8250.c
index 567c6ec0cfae..e2c2405cff62 100644
--- a/arch/mips/kernel/early_printk_8250.c
+++ b/arch/mips/kernel/early_printk_8250.c
@@ -23,12 +23,42 @@ void setup_8250_early_printk_port(unsigned long base, unsigned int reg_shift,
static inline u8 serial_in(int offset)
{
- return readb(serial8250_base + (offset << serial8250_reg_shift));
+ u8 ret = 0xFF;
+
+ offset <<= serial8250_reg_shift;
+ switch (serial8250_reg_shift) {
+ case 0:
+ ret = readb(serial8250_base + offset);
+ break;
+ case 1:
+ ret = readw(serial8250_base + offset);
+ break;
+ case 2:
+ ret = readl(serial8250_base + offset);
+ break;
+ default:
+ break;
+ }
+
+ return ret;
}
static inline void serial_out(int offset, char value)
{
- writeb(value, serial8250_base + (offset << serial8250_reg_shift));
+ offset <<= serial8250_reg_shift;
+ switch (serial8250_reg_shift) {
+ case 0:
+ writeb(value, serial8250_base + offset);
+ break;
+ case 1:
+ writew(value, serial8250_base + offset);
+ break;
+ case 2:
+ writel(value, serial8250_base + offset);
+ break;
+ default:
+ break;
+ }
}
void prom_putchar(char c)
--
2.25.1
Powered by blists - more mailing lists