mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: franck.jullien@gmail.com
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] nios2/serial_altera: Switch to resources
Date: Tue, 26 Jul 2011 22:07:56 +0200	[thread overview]
Message-ID: <1311710877-13004-4-git-send-email-franck.jullien@gmail.com> (raw)
In-Reply-To: <1311710877-13004-1-git-send-email-franck.jullien@gmail.com>

From: Franck Jullien <franck.jullien@gmail.com>

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 drivers/serial/serial_altera.c |   31 ++++++++++++++++++++++++++-----
 1 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/serial_altera.c b/drivers/serial/serial_altera.c
index 54c7178..1148564 100644
--- a/drivers/serial/serial_altera.c
+++ b/drivers/serial/serial_altera.c
@@ -27,9 +27,17 @@
 #include <asm/io.h>
 #include <asm/nios2-io.h>
 
+struct altera_serial_priv {
+	struct console_device cdev;
+	void __iomem *regs;
+};
+
 static int altera_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
-	struct nios_uart *uart = (struct nios_uart *)cdev->dev->map_base;
+	struct altera_serial_priv *priv = container_of(cdev,
+		struct altera_serial_priv, cdev);
+
+	struct nios_uart *uart = priv->regs;
 	uint16_t div;
 
 	div = (CPU_FREQ / baudrate) - 1;
@@ -40,7 +48,10 @@ static int altera_serial_setbaudrate(struct console_device *cdev, int baudrate)
 
 static void altera_serial_putc(struct console_device *cdev, char c)
 {
-	struct nios_uart *uart = (struct nios_uart *)cdev->dev->map_base;
+	struct altera_serial_priv *priv = container_of(cdev,
+		struct altera_serial_priv, cdev);
+
+	struct nios_uart *uart = priv->regs;
 
 	while ((readw(&uart->status) & NIOS_UART_TRDY) == 0);
 
@@ -49,14 +60,20 @@ static void altera_serial_putc(struct console_device *cdev, char c)
 
 static int altera_serial_tstc(struct console_device *cdev)
 {
-	struct nios_uart *uart = (struct nios_uart *)cdev->dev->map_base;
+	struct altera_serial_priv *priv = container_of(cdev,
+		struct altera_serial_priv, cdev);
+
+	struct nios_uart *uart = priv->regs;
 
 	return readw(&uart->status) & NIOS_UART_RRDY;
 }
 
 static int altera_serial_getc(struct console_device *cdev)
 {
-	struct nios_uart *uart = (struct nios_uart *)cdev->dev->map_base;
+	struct altera_serial_priv *priv = container_of(cdev,
+		struct altera_serial_priv, cdev);
+
+	struct nios_uart *uart = priv->regs;
 
 	while (altera_serial_tstc(cdev) == 0);
 
@@ -66,8 +83,12 @@ static int altera_serial_getc(struct console_device *cdev)
 static int altera_serial_probe(struct device_d *dev)
 {
 	struct console_device *cdev;
+	struct altera_serial_priv *priv;
+
+	priv = xmalloc(sizeof(*priv));
+	cdev = &priv->cdev;
 
-	cdev = xmalloc(sizeof(struct console_device));
+	priv->regs = dev_request_mem_region(dev, 0);
 	dev->type_data = cdev;
 	cdev->dev = dev;
 	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
-- 
1.7.6


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

  parent reply	other threads:[~2011-07-26 20:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-26 20:07 [PATCH v2] Switch nios2 devices " franck.jullien
2011-07-26 20:07 ` [PATCH 1/4] nios2/generic.c: Add resources for altera TSE franck.jullien
2011-07-26 20:07 ` [PATCH 2/4] nios2/altera_tse: Switch to resources franck.jullien
2011-07-26 20:07 ` franck.jullien [this message]
2011-07-26 20:07 ` [PATCH 4/4] nios2/altera_serial_jtag: " franck.jullien
2011-07-27  8:56 ` [PATCH v2] Switch nios2 devices " 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=1311710877-13004-4-git-send-email-franck.jullien@gmail.com \
    --to=franck.jullien@gmail.com \
    --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