mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 01/11] serial netx: get rid of map_base
Date: Thu, 28 Jul 2011 15:41:54 +0200	[thread overview]
Message-ID: <1311860524-28566-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1311860524-28566-1-git-send-email-s.hauer@pengutronix.de>

While at it, switch to standard readl/writel accessors

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/serial/serial_netx.c |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/serial/serial_netx.c b/drivers/serial/serial_netx.c
index 9d4b29e..fbbc4ef 100644
--- a/drivers/serial/serial_netx.c
+++ b/drivers/serial/serial_netx.c
@@ -26,11 +26,7 @@
 #include <driver.h>
 #include <init.h>
 #include <malloc.h>
-
-#define IO_WRITE(addr, val) (*(volatile unsigned long *)(addr) = (val))
-#define IO_READ(addr) (*(volatile unsigned long *)(addr))
-
-unsigned long addr = 0x100a00;
+#include <asm/io.h>
 
 enum uart_regs {
 	UART_DR              = 0x00,
@@ -76,14 +72,15 @@ enum uart_regs {
 static int netx_serial_init_port(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 	unsigned int divisor;
 
 	/* disable uart */
-	IO_WRITE( dev->map_base + UART_CR, 0);
+	writel(0, base + UART_CR);
 
-	IO_WRITE( dev->map_base + UART_LINE_CR, LINE_CR_8BIT | LINE_CR_FEN);
+	writel(LINE_CR_8BIT | LINE_CR_FEN, base + UART_LINE_CR);
 
-	IO_WRITE( dev->map_base + UART_DRV_ENABLE, DRV_ENABLE_TX | DRV_ENABLE_RTS );
+	writel(DRV_ENABLE_TX | DRV_ENABLE_RTS, base + UART_DRV_ENABLE);
 
 	/* set baud rate */
 	divisor = 115200 * 4096;
@@ -91,12 +88,12 @@ static int netx_serial_init_port(struct console_device *cdev)
 	divisor *= 256;
 	divisor /= 100000;
 
-	IO_WRITE( dev->map_base + UART_BAUDDIV_MSB, (divisor >> 8) & 0xff );
-	IO_WRITE( dev->map_base + UART_BAUDDIV_LSB, divisor & 0xff );
-	IO_WRITE( dev->map_base + UART_BRM_CR, BRM_CR_BAUD_RATE_MODE);
+	writel((divisor >> 8) & 0xff, base + UART_BAUDDIV_MSB);
+	writel(divisor & 0xff, base + UART_BAUDDIV_LSB);
+	writel(BRM_CR_BAUD_RATE_MODE, base + UART_BRM_CR);
 
 	/* Finally, enable the UART */
-	IO_WRITE( dev->map_base + UART_CR, CR_UARTEN);
+	writel(CR_UARTEN, base + UART_CR);
 
 	return 0;
 }
@@ -109,22 +106,24 @@ static int netx_serial_setbaudrate(struct console_device *cdev, int baudrate)
 static void netx_serial_putc(struct console_device *cdev, char c)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
-	while( IO_READ(dev->map_base + UART_FR) & FR_TXFF );
+	while (readl(base + UART_FR) & FR_TXFF );
 
-	IO_WRITE(dev->map_base + UART_DR, c);
+	writel(c, base + UART_DR);
 }
 
 static int netx_serial_getc(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 	int c;
 
-	while( IO_READ(dev->map_base + UART_FR) & FR_RXFE );
+	while (readl(base + UART_FR) & FR_RXFE );
 
-	c = IO_READ(dev->map_base + UART_DR);
+	c = readl(base + UART_DR);
 
-	IO_READ(dev->map_base + UART_SR);
+	readl(base + UART_SR);
 
 	return c;
 }
@@ -132,8 +131,9 @@ static int netx_serial_getc(struct console_device *cdev)
 static int netx_serial_tstc(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
-	return (IO_READ(dev->map_base + UART_FR) & FR_RXFE) ? 0 : 1;
+	return (readl(base + UART_FR) & FR_RXFE) ? 0 : 1;
 }
 
 static int netx_serial_probe(struct device_d *dev)
@@ -142,6 +142,7 @@ static int netx_serial_probe(struct device_d *dev)
 
 	cdev = xmalloc(sizeof(struct console_device));
 	dev->type_data = cdev;
+	dev->priv = dev_request_mem_region(dev, 0);
 	cdev->dev = dev;
 	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
 	cdev->tstc = netx_serial_tstc;
-- 
1.7.5.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2011-07-28 13:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-28 13:41 more switches to resources Sascha Hauer
2011-07-28 13:41 ` Sascha Hauer [this message]
2011-07-28 13:41 ` [PATCH 02/11] serial s3c: get rid of map_base Sascha Hauer
2011-07-28 13:41 ` [PATCH 03/11] serial pl010: " Sascha Hauer
2011-07-28 13:41 ` [PATCH 04/11] serial stm: " Sascha Hauer
2011-07-28 13:41 ` [PATCH 05/11] serial mpc5xxx: " Sascha Hauer
2011-07-28 13:41 ` [PATCH 06/11] smc911x: use dev_* instead of printf Sascha Hauer
2011-07-28 13:42 ` [PATCH 07/11] smc911x: switch to use resources Sascha Hauer
2011-07-28 13:42 ` [PATCH 08/11] smc911x: embed eth_device into priv Sascha Hauer
2011-07-28 13:42 ` [PATCH 09/11] ARM pcm037: Fix wrong sdram base Sascha Hauer
2011-07-28 13:42 ` [PATCH 10/11] smc91111: switch to resources Sascha Hauer
2011-07-28 13:42 ` [PATCH 11/11] fec_mpc5200: " Sascha Hauer

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=1311860524-28566-2-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox