public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v4 3/5] dm: ns16550: Don't map_physmem for I/O ports
Date: Thu, 26 May 2016 00:01:37 +0200	[thread overview]
Message-ID: <1464213697-7262-1-git-send-email-daniel.schwierzeck@gmail.com> (raw)
In-Reply-To: <1463467408-13245-4-git-send-email-paul.burton@imgtec.com>

From: Paul Burton <paul.burton@imgtec.com>

If the UART is to be accessed using I/O port accessors (inb & outb) then
using map_physmem doesn't make sense, since it operates in a different
memory space. Remove the call to map_physmem when
CONFIG_SYS_NS16550_PORT_MAPPED is defined, allowing I/O port addresses
to not be mangled by the incorrect mapping.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
---

Updated patch due to discussion in:
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/261776/focus=262627

Changes in v4: 
- Only do map_physmem() once in ns16550_serial_ofdata_to_platdata().
Changes in v3: None
Changes in v2:
- New patch, part of a simplified approach tackling only a single Malta UART.


 drivers/serial/ns16550.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 28da9dd..b6eac1c 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -100,7 +100,8 @@ static void ns16550_writeb(NS16550_t port, int offset, int value)
 	unsigned char *addr;
 
 	offset *= 1 << plat->reg_shift;
-	addr = map_physmem(plat->base, 0, MAP_NOCACHE) + offset;
+	addr = (unsigned char *)plat->base + offset;
+
 	/*
 	 * As far as we know it doesn't make sense to support selection of
 	 * these options at run-time, so use the existing CONFIG options.
@@ -114,7 +115,7 @@ static int ns16550_readb(NS16550_t port, int offset)
 	unsigned char *addr;
 
 	offset *= 1 << plat->reg_shift;
-	addr = map_physmem(plat->base, 0, MAP_NOCACHE) + offset;
+	addr = (unsigned char *)plat->base + offset;
 
 	return serial_in_shift(addr + plat->reg_offset, plat->reg_shift);
 }
@@ -400,7 +401,12 @@ int ns16550_serial_ofdata_to_platdata(struct udevice *dev)
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
 
+#ifdef CONFIG_SYS_NS16550_PORT_MAPPED
 	plat->base = addr;
+#else
+	plat->base = map_physmem(addr, 0, MAP_NOCACHE);
+#endif
+
 	plat->reg_offset = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
 				     "reg-offset", 0);
 	plat->reg_shift = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-- 
2.7.4

  reply	other threads:[~2016-05-25 22:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17  6:43 [U-Boot] [PATCH v3 0/5] Malta UART using device model & device tree Paul Burton
2016-05-17  6:43 ` [U-Boot] [PATCH v3 1/5] fdt: Support for ISA busses Paul Burton
2016-05-25 22:07   ` Daniel Schwierzeck
2016-05-17  6:43 ` [U-Boot] [PATCH v3 2/5] fdt: Document the rest of struct of_bus Paul Burton
2016-05-25 22:08   ` Daniel Schwierzeck
2016-05-17  6:43 ` [U-Boot] [PATCH v3 3/5] dm: ns16550: Don't map_physmem for I/O ports Paul Burton
2016-05-25 22:01   ` Daniel Schwierzeck [this message]
2016-05-25 22:09     ` [U-Boot] [PATCH v4 " Daniel Schwierzeck
2016-05-17  6:43 ` [U-Boot] [PATCH v3 4/5] malta: Tidy up UART address selection Paul Burton
2016-05-25 22:09   ` Daniel Schwierzeck
2016-05-17  6:43 ` [U-Boot] [PATCH v3 5/5] malta: Use device model & tree for UART Paul Burton
2016-05-25 22:10   ` Daniel Schwierzeck

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=1464213697-7262-1-git-send-email-daniel.schwierzeck@gmail.com \
    --to=daniel.schwierzeck@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox