mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Alexander Shiyan <shc_work@mail.ru>
To: barebox@lists.infradead.org
Subject: [PATCH 13/13] serial: clps711x: Migrate to using SYSCON driver
Date: Mon, 11 Mar 2013 13:26:43 +0400	[thread overview]
Message-ID: <1362994003-22653-13-git-send-email-shc_work@mail.ru> (raw)
In-Reply-To: <1362994003-22653-1-git-send-email-shc_work@mail.ru>


Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 arch/arm/mach-clps711x/devices.c |    4 ----
 drivers/serial/serial_clps711x.c |   31 +++++++++++++++++++------------
 2 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-clps711x/devices.c b/arch/arm/mach-clps711x/devices.c
index b36013f..9eeff5c 100644
--- a/arch/arm/mach-clps711x/devices.c
+++ b/arch/arm/mach-clps711x/devices.c
@@ -52,15 +52,11 @@ void clps711x_setup_memcfg(int bank, u32 val)
 
 static struct resource uart0_resources[] = {
 	DEFINE_RES_MEM(UBRLCR1, SZ_4),
-	DEFINE_RES_MEM(SYSCON1, SZ_4),
-	DEFINE_RES_MEM(SYSFLG1, SZ_4),
 	DEFINE_RES_MEM(UARTDR1, SZ_4),
 };
 
 static struct resource uart1_resources[] = {
 	DEFINE_RES_MEM(UBRLCR2, SZ_4),
-	DEFINE_RES_MEM(SYSCON2, SZ_4),
-	DEFINE_RES_MEM(SYSFLG2, SZ_4),
 	DEFINE_RES_MEM(UARTDR2, SZ_4),
 };
 
diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
index 21d0b55..cb250be 100644
--- a/drivers/serial/serial_clps711x.c
+++ b/drivers/serial/serial_clps711x.c
@@ -15,18 +15,21 @@
 #include <io.h>
 #include <linux/clk.h>
 #include <linux/err.h>
+#include <mfd/syscon.h>
 
 #include <mach/clps711x.h>
 
 struct clps711x_uart {
 	void __iomem		*UBRLCR;
-	void __iomem		*SYSCON;
-	void __iomem		*SYSFLG;
 	void __iomem		*UARTDR;
+	void __iomem		*syscon;
 	struct clk		*uart_clk;
 	struct console_device	cdev;
 };
 
+#define SYSCON(x)	((x)->syscon + 0x00)
+#define SYSFLG(x)	((x)->syscon + 0x40)
+
 static int clps711x_setbaudrate(struct console_device *cdev, int baudrate)
 {
 	struct clps711x_uart *s = cdev->dev->priv;
@@ -48,7 +51,7 @@ static void clps711x_init_port(struct console_device *cdev)
 	u32 tmp;
 
 	/* Disable the UART */
-	writel(readl(s->SYSCON) & ~SYSCON_UARTEN, s->SYSCON);
+	writel(readl(SYSCON(s)) & ~SYSCON_UARTEN, SYSCON(s));
 
 	/* Setup Line Control Register */
 	tmp = readl(s->UBRLCR) & UBRLCR_BAUD_MASK;
@@ -59,7 +62,7 @@ static void clps711x_init_port(struct console_device *cdev)
 	clps711x_setbaudrate(cdev, CONFIG_BAUDRATE);
 
 	/* Enable the UART */
-	writel(readl(s->SYSCON) | SYSCON_UARTEN, s->SYSCON);
+	writel(readl(SYSCON(s)) | SYSCON_UARTEN, SYSCON(s));
 }
 
 static void clps711x_putc(struct console_device *cdev, char c)
@@ -67,7 +70,7 @@ static void clps711x_putc(struct console_device *cdev, char c)
 	struct clps711x_uart *s = cdev->dev->priv;
 
 	/* Wait until there is space in the FIFO */
-	while (readl(s->SYSFLG) & SYSFLG_UTXFF)
+	while (readl(SYSFLG(s)) & SYSFLG_UTXFF)
 		barrier();
 
 	/* Send the character */
@@ -80,7 +83,7 @@ static int clps711x_getc(struct console_device *cdev)
 	u16 data;
 
 	/* Wait until there is data in the FIFO */
-	while (readl(s->SYSFLG) & SYSFLG_URXFE)
+	while (readl(SYSFLG(s)) & SYSFLG_URXFE)
 		barrier();
 
 	data = readw(s->UARTDR);
@@ -96,31 +99,35 @@ static int clps711x_tstc(struct console_device *cdev)
 {
 	struct clps711x_uart *s = cdev->dev->priv;
 
-	return !(readl(s->SYSFLG) & SYSFLG_URXFE);
+	return !(readl(SYSFLG(s)) & SYSFLG_URXFE);
 }
 
 static void clps711x_flush(struct console_device *cdev)
 {
 	struct clps711x_uart *s = cdev->dev->priv;
 
-	while (readl(s->SYSFLG) & SYSFLG_UBUSY)
+	while (readl(SYSFLG(s)) & SYSFLG_UBUSY)
 		barrier();
 }
 
 static int clps711x_probe(struct device_d *dev)
 {
 	struct clps711x_uart *s;
+	char syscon_dev[18];
 
-	BUG_ON(dev->num_resources != 4);
+	BUG_ON(dev->num_resources != 2);
+	BUG_ON((dev->id != 0) && (dev->id != 1));
 
 	s = xzalloc(sizeof(struct clps711x_uart));
 	s->uart_clk = clk_get(dev, NULL);
 	BUG_ON(IS_ERR(s->uart_clk));
 
 	s->UBRLCR = dev_get_mem_region(dev, 0);
-	s->SYSCON = dev_get_mem_region(dev, 1);
-	s->SYSFLG = dev_get_mem_region(dev, 2);
-	s->UARTDR = dev_get_mem_region(dev, 3);
+	s->UARTDR = dev_get_mem_region(dev, 1);
+
+	sprintf(syscon_dev, "clps711x-syscon%i", dev->id + 1);
+	s->syscon = syscon_base_lookup_by_pdevname(syscon_dev);
+	BUG_ON(IS_ERR(s->syscon));
 
 	dev->priv	= s;
 	s->cdev.dev	= dev;
-- 
1.7.3.4


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

  parent reply	other threads:[~2013-03-11  9:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11  9:26 [PATCH 01/13] ARM: clep7212: Migrate to config-board Alexander Shiyan
2013-03-11  9:26 ` [PATCH 02/13] ARM: clps711x: Fix setup bus wait state scaling factor for 13Mhz mode Alexander Shiyan
2013-03-11  9:26 ` [PATCH 03/13] ARM: clps711x: Replace numeric PLL option with boolean for raise CPU frequency Alexander Shiyan
2013-03-11  9:26 ` [PATCH 04/13] ARM: clps711x: Add clocksource driver Alexander Shiyan
2013-03-11 11:01   ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-11 11:10     ` Sascha Hauer
2013-03-11 16:22       ` Re[2]: " Alexander Shiyan
2013-03-11 18:00         ` Sascha Hauer
2013-03-11 18:17           ` Re[2]: " Alexander Shiyan
2013-03-11  9:26 ` [PATCH 05/13] ARM: clps711x: Using COMMON_CLK Alexander Shiyan
2013-03-11 11:00   ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-11 11:26     ` Re[2]: " Alexander Shiyan
2013-03-11 11:58       ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-11  9:26 ` [PATCH 06/13] Add Generic GPIO driver Alexander Shiyan
2013-03-11  9:26 ` [PATCH 07/13] ARM: clps711x: Add " Alexander Shiyan
2013-03-11  9:26 ` [PATCH 08/13] Add helpers to define resources Alexander Shiyan
2013-03-11  9:26 ` [PATCH 09/13] ARM: clps711x: Migrate to using DEFINE_RES_MEM macro Alexander Shiyan
2013-03-11  9:26 ` [PATCH 10/13] ARM: clps711x: Limit chipselect setup up to CS5 Alexander Shiyan
2013-03-11  9:26 ` [PATCH 11/13] Add system controller register driver (SYSCON) Alexander Shiyan
2013-03-11  9:26 ` [PATCH 12/13] ARM: clps711x: Export system-wide registers through SYSCON driver Alexander Shiyan
2013-03-11  9:26 ` Alexander Shiyan [this message]
2013-03-11 21:18 ` [PATCH 01/13] ARM: clep7212: Migrate to config-board 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=1362994003-22653-13-git-send-email-shc_work@mail.ru \
    --to=shc_work@mail.ru \
    --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