lkml.org 
[lkml]   [2018]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 4/6] x86/boot: Assume MMIO if serial base address supplied via earlyprintk
Date
If user supplied serial base address via kernel command line and value
is higher than IO space limit (64k boundary), assume for now that MMIO
byte access is required.

Later we might expand or modify this if needed.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
arch/x86/boot/early_serial_console.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/x86/boot/early_serial_console.c b/arch/x86/boot/early_serial_console.c
index 8b091919b3b9..8cb7b0e8fe98 100644
--- a/arch/x86/boot/early_serial_console.c
+++ b/arch/x86/boot/early_serial_console.c
@@ -33,6 +33,22 @@ static void io_serial_out(unsigned long addr, int offset, int value)
outb(value, addr + offset);
}

+#define IO_SPACE_LIMIT 0xffff
+
+static void mem8_serial_out(unsigned long addr, int offset, int value)
+{
+ u8 __iomem *vaddr = (u8 __iomem *)addr;
+ /* shift implied by pointer type */
+ writeb(value, vaddr + offset);
+}
+
+static unsigned int mem8_serial_in(unsigned long addr, int offset)
+{
+ u8 __iomem *vaddr = (u8 __iomem *)addr;
+ /* shift implied by pointer type */
+ return readb(vaddr + offset);
+}
+
static void early_serial_configure(unsigned long port, int baud)
{
unsigned char c;
@@ -54,7 +70,11 @@ static void early_serial_configure(unsigned long port, int baud)
static void early_serial_init(unsigned long port, int baud)
{
/* Assign serial I/O accessors */
- if (port) {
+ if (port > IO_SPACE_LIMIT) {
+ /* It is memory mapped - assume 8-bit alignment */
+ serial_in = mem8_serial_in;
+ serial_out = mem8_serial_out;
+ } else if (port) {
/* These will always be IO based ports */
serial_in = io_serial_in;
serial_out = io_serial_out;
--
2.15.1
\
 
 \ /
  Last update: 2018-01-14 23:27    [W:0.071 / U:25.712 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site