From: Xiang W <wxjstz@126.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 3/4] lib: utils/serial: add domains_init for 8250
Date: Thu, 6 Jun 2024 17:17:15 +0800 [thread overview]
Message-ID: <20240606091723.896477-4-wxjstz@126.com> (raw)
In-Reply-To: <20240606091723.896477-1-wxjstz@126.com>
8250 needs to add memregion to root_domain. Move this part of
operation to sbi_console_device.domains_init
Signed-off-by: Xiang W <wxjstz@126.com>
---
include/sbi_utils/serial/uart8250.h | 1 +
lib/utils/serial/uart8250.c | 28 +++++++++++++++++++---------
2 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/include/sbi_utils/serial/uart8250.h b/include/sbi_utils/serial/uart8250.h
index be9483a..0949b96 100644
--- a/include/sbi_utils/serial/uart8250.h
+++ b/include/sbi_utils/serial/uart8250.h
@@ -18,6 +18,7 @@ struct uart8250_device {
u32 baudrate;
u32 reg_shift;
u32 reg_width;
+ u32 reg_offset;
};
void uart8250_putc(struct uart8250_device *dev, char ch);
diff --git a/lib/utils/serial/uart8250.c b/lib/utils/serial/uart8250.c
index db35ec3..754548f 100644
--- a/lib/utils/serial/uart8250.c
+++ b/lib/utils/serial/uart8250.c
@@ -92,10 +92,21 @@ static int uart8250_console_getc(void)
return uart8250_getc(&console_dev);
}
+static int uart8250_domains_init(void)
+{
+ unsigned long base = (unsigned long)console_dev.base
+ - console_dev.reg_offset;
+
+ return sbi_domain_root_add_memrange(base, PAGE_SIZE, PAGE_SIZE,
+ (SBI_DOMAIN_MEMREGION_MMIO |
+ SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW));
+}
+
static struct sbi_console_device uart8250_console = {
.name = "uart8250",
.console_putc = uart8250_console_putc,
- .console_getc = uart8250_console_getc
+ .console_getc = uart8250_console_getc,
+ .domains_init = uart8250_domains_init
};
int uart8250_init(struct uart8250_device * dev, unsigned long base, u32 in_freq,
@@ -103,11 +114,12 @@ int uart8250_init(struct uart8250_device * dev, unsigned long base, u32 in_freq,
{
u16 bdiv = 0;
- dev->base = (volatile char *)base + reg_offset;
- dev->reg_shift = reg_shift;
- dev->reg_width = reg_width;
- dev->in_freq = in_freq;
- dev->baudrate = baudrate;
+ dev->base = (volatile char *)base + reg_offset;
+ dev->reg_offset = reg_offset;
+ dev->reg_shift = reg_shift;
+ dev->reg_width = reg_width;
+ dev->in_freq = in_freq;
+ dev->baudrate = baudrate;
if (baudrate)
bdiv = (in_freq + 8 * baudrate) / (16 * baudrate);
@@ -147,7 +159,5 @@ int uart8250_console_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg
sbi_console_set_device(&uart8250_console);
- return sbi_domain_root_add_memrange(base, PAGE_SIZE, PAGE_SIZE,
- (SBI_DOMAIN_MEMREGION_MMIO |
- SBI_DOMAIN_MEMREGION_SHARED_SURW_MRW));
+ return 0;
}
--
2.43.0
next prev parent reply other threads:[~2024-06-06 9:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-06 9:17 [PATCH 0/4] Initialize the console as early as possible Xiang W
2024-06-06 9:17 ` [PATCH 1/4] include: sbi_utils: fixup fdt_get_address Xiang W
2024-06-06 9:17 ` [PATCH 2/4] lib: sbi: Add domains_init to sbi_console_device Xiang W
2024-06-06 9:17 ` Xiang W [this message]
2024-06-06 9:17 ` [PATCH 4/4] lib: sbi: Initialize the console as early as possible Xiang W
2024-06-21 12:07 ` [PATCH 0/4] " Anup Patel
2024-06-21 14:02 ` Andrew Jones
2024-06-21 14:55 ` Xiang W
2024-06-21 14:52 ` Xiang W
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240606091723.896477-4-wxjstz@126.com \
--to=wxjstz@126.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.