mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* more switches to resources
@ 2011-07-28 13:41 Sascha Hauer
  2011-07-28 13:41 ` [PATCH 01/11] serial netx: get rid of map_base Sascha Hauer
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

Sascha Hauer (11):
      serial netx: get rid of map_base
      serial s3c: get rid of map_base
      serial pl010: get rid of map_base
      serial stm: get rid of map_base
      serial mpc5xxx: get rid of map_base
      smc911x: use dev_* instead of printf
      smc911x: switch to use resources
      smc911x: embed eth_device into priv
      ARM pcm037: Fix wrong sdram base
      smc91111: switch to resources
      fec_mpc5200: switch to resources

 arch/arm/boards/pcm037/pcm037.c |    2 +-
 drivers/net/cs8900.c            |    2 +-
 drivers/net/fec_mpc5200.c       |    2 +-
 drivers/net/smc91111.c          |    2 +-
 drivers/net/smc911x.c           |   42 ++++++++---------
 drivers/serial/serial_mpc5xxx.c |   11 +++--
 drivers/serial/serial_netx.c    |   37 ++++++++-------
 drivers/serial/serial_pl010.c   |   11 +++--
 drivers/serial/serial_s3c24x0.c |   31 ++++++++-----
 drivers/serial/stm-serial.c     |   94 ++++++++++++++++++++-------------------
 10 files changed, 122 insertions(+), 112 deletions(-)

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 01/11] serial netx: get rid of map_base
  2011-07-28 13:41 more switches to resources Sascha Hauer
@ 2011-07-28 13:41 ` Sascha Hauer
  2011-07-28 13:41 ` [PATCH 02/11] serial s3c: " Sascha Hauer
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 02/11] serial s3c: get rid of map_base
  2011-07-28 13:41 more switches to resources Sascha Hauer
  2011-07-28 13:41 ` [PATCH 01/11] serial netx: get rid of map_base Sascha Hauer
@ 2011-07-28 13:41 ` Sascha Hauer
  2011-07-28 13:41 ` [PATCH 03/11] serial pl010: " Sascha Hauer
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

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

diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c
index 0a17967..21bca12 100644
--- a/drivers/serial/serial_s3c24x0.c
+++ b/drivers/serial/serial_s3c24x0.c
@@ -44,11 +44,12 @@
 static int s3c24x0_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 	unsigned val;
 
 	/* value is calculated so : PCLK / (16 * baudrate) -1 */
 	val = s3c24xx_get_pclk() / (16 * baudrate) - 1;
-	writew(val, dev->map_base + UBRDIV);
+	writew(val, base + UBRDIV);
 
 	return 0;
 }
@@ -56,21 +57,22 @@ static int s3c24x0_serial_setbaudrate(struct console_device *cdev, int baudrate)
 static int s3c24x0_serial_init_port(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
 	/* FIFO enable, Tx/Rx FIFO clear */
-	writeb(0x07, dev->map_base + UFCON);
-	writeb(0x00, dev->map_base + UMCON);
+	writeb(0x07, base + UFCON);
+	writeb(0x00, base + UMCON);
 
 	/* Normal,No parity,1 stop,8 bit */
-	writeb(0x03, dev->map_base + ULCON);
+	writeb(0x03, base + ULCON);
 	/*
 	 * tx=level,rx=edge,disable timeout int.,enable rx error int.,
 	 * normal,interrupt or polling
 	 */
-	writew(0x0245, dev->map_base + UCON);
+	writew(0x0245, base + UCON);
 
 #ifdef CONFIG_DRIVER_SERIAL_S3C24X0_AUTOSYNC
-	writeb(0x01, dev->map_base + UMCON); /* RTS up */
+	writeb(0x01, base + UMCON); /* RTS up */
 #endif
 
 	return 0;
@@ -79,20 +81,22 @@ static int s3c24x0_serial_init_port(struct console_device *cdev)
 static void s3c24x0_serial_putc(struct console_device *cdev, char c)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
 	/* Wait for Tx FIFO not full */
-	while (!(readb(dev->map_base + UTRSTAT) & 0x2))
+	while (!(readb(base + UTRSTAT) & 0x2))
 		;
 
-	writeb(c, dev->map_base + UTXH);
+	writeb(c, base + UTXH);
 }
 
 static int s3c24x0_serial_tstc(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
 	/* If receive fifo is empty, return false */
-	if (readb(dev->map_base + UTRSTAT) & 0x1)
+	if (readb(base + UTRSTAT) & 0x1)
 		return 1;
 
 	return 0;
@@ -101,19 +105,21 @@ static int s3c24x0_serial_tstc(struct console_device *cdev)
 static int s3c24x0_serial_getc(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
 	/* wait for a character */
-	while (!(readb(dev->map_base + UTRSTAT) & 0x1))
+	while (!(readb(base + UTRSTAT) & 0x1))
 		;
 
-	return readb(dev->map_base + URXH);
+	return readb(base + URXH);
 }
 
 static void s3c24x0_serial_flush(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
+	void __iomem *base = dev->priv;
 
-	while (!(readb(dev->map_base + UTRSTAT) & 0x4))
+	while (!(readb(base + UTRSTAT) & 0x4))
 		;
 }
 
@@ -123,6 +129,7 @@ static int s3c24x0_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 = s3c24x0_serial_tstc;
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 03/11] serial pl010: get rid of map_base
  2011-07-28 13:41 more switches to resources Sascha Hauer
  2011-07-28 13:41 ` [PATCH 01/11] serial netx: get rid of map_base Sascha Hauer
  2011-07-28 13:41 ` [PATCH 02/11] serial s3c: " Sascha Hauer
@ 2011-07-28 13:41 ` Sascha Hauer
  2011-07-28 13:41 ` [PATCH 04/11] serial stm: " Sascha Hauer
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/serial/serial_pl010.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/serial_pl010.c b/drivers/serial/serial_pl010.c
index 7923ebb..9f7b7d3 100644
--- a/drivers/serial/serial_pl010.c
+++ b/drivers/serial/serial_pl010.c
@@ -37,7 +37,7 @@
 
 static int pl010_setbaudrate(struct console_device *cdev, int baudrate)
 {
-	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	struct pl010_struct *pl010 = cdev->dev->priv;
 	unsigned int divisor;
 
 	switch (baudrate) {
@@ -76,7 +76,7 @@ static int pl010_setbaudrate(struct console_device *cdev, int baudrate)
 
 static int pl010_init_port(struct console_device *cdev)
 {
-	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	struct pl010_struct *pl010 = cdev->dev->priv;
 
 	/*
 	 * First, disable everything.
@@ -99,7 +99,7 @@ static int pl010_init_port(struct console_device *cdev)
 
 static void pl010_putc(struct console_device *cdev, char c)
 {
-	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	struct pl010_struct *pl010 = cdev->dev->priv;
 
 	/* Wait until there is space in the FIFO */
 	while (readl(&pl010->flag) & UART_PL010_FR_TXFF)
@@ -111,7 +111,7 @@ static void pl010_putc(struct console_device *cdev, char c)
 
 static int pl010_getc(struct console_device *cdev)
 {
-	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	struct pl010_struct *pl010 = cdev->dev->priv;
 	unsigned int data;
 
 	/* Wait until there is data in the FIFO */
@@ -132,7 +132,7 @@ static int pl010_getc(struct console_device *cdev)
 
 static int pl010_tstc(struct console_device *cdev)
 {
-	struct pl010_struct *pl010 = (struct pl010_struct *)cdev->dev->map_base;
+	struct pl010_struct *pl010 = cdev->dev->priv;
 
 	return !(readl(&pl010->flag) & UART_PL010_FR_RXFE);
 }
@@ -143,6 +143,7 @@ static int pl010_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 = pl010_tstc;
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 04/11] serial stm: get rid of map_base
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (2 preceding siblings ...)
  2011-07-28 13:41 ` [PATCH 03/11] serial pl010: " Sascha Hauer
@ 2011-07-28 13:41 ` Sascha Hauer
  2011-07-28 13:41 ` [PATCH 05/11] serial mpc5xxx: " Sascha Hauer
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

While at it, dynamically allocate private driver struct.
There might be only a single instance of this driver,
but don't be a bad example for others.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/serial/stm-serial.c |   94 ++++++++++++++++++++++---------------------
 1 files changed, 48 insertions(+), 46 deletions(-)

diff --git a/drivers/serial/stm-serial.c b/drivers/serial/stm-serial.c
index a225e30..4264345 100644
--- a/drivers/serial/stm-serial.c
+++ b/drivers/serial/stm-serial.c
@@ -52,123 +52,125 @@
 # define RXE (1 << 9)
 #define UARTDBGIMSC 0x38
 
-struct stm_serial_local {
+struct stm_priv {
 	struct console_device cdev;
 	int baudrate;
 	struct notifier_block notify;
+	void __iomem *base;
 };
 
 static void stm_serial_putc(struct console_device *cdev, char c)
 {
-	struct device_d *dev = cdev->dev;
+	struct stm_priv *priv = container_of(cdev, struct stm_priv, cdev);
 
 	/* Wait for room in TX FIFO */
-	while (readl(dev->map_base + UARTDBGFR) & TXFF)
+	while (readl(priv->base + UARTDBGFR) & TXFF)
 		;
 
-	writel(c, dev->map_base + UARTDBGDR);
+	writel(c, priv->base + UARTDBGDR);
 }
 
 static int stm_serial_tstc(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct stm_priv *priv = container_of(cdev, struct stm_priv, cdev);
 
 	/* Check if RX FIFO is not empty */
-	return !(readl(dev->map_base + UARTDBGFR) & RXFE);
+	return !(readl(priv->base + UARTDBGFR) & RXFE);
 }
 
 static int stm_serial_getc(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct stm_priv *priv = container_of(cdev, struct stm_priv, cdev);
 
 	/* Wait while TX FIFO is empty */
-	while (readl(dev->map_base + UARTDBGFR) & RXFE)
+	while (readl(priv->base + UARTDBGFR) & RXFE)
 		;
 
-	return readl(dev->map_base + UARTDBGDR) & 0xff;
+	return readl(priv->base + UARTDBGDR) & 0xff;
 }
 
 static void stm_serial_flush(struct console_device *cdev)
 {
-	struct device_d *dev = cdev->dev;
+	struct stm_priv *priv = container_of(cdev, struct stm_priv, cdev);
 
 	/* Wait for TX FIFO empty */
-	while (readl(dev->map_base + UARTDBGFR) & TXFF)
+	while (readl(priv->base + UARTDBGFR) & TXFF)
 		;
 }
 
 static int stm_serial_setbaudrate(struct console_device *cdev, int new_baudrate)
 {
-	struct device_d *dev = cdev->dev;
-	struct stm_serial_local *local = container_of(cdev, struct stm_serial_local, cdev);
+	struct stm_priv *priv = container_of(cdev, struct stm_priv, cdev);
 	uint32_t cr, lcr_h, quot;
 
 	/* Disable everything */
-	cr = readl(dev->map_base + UARTDBGCR);
-	writel(0, dev->map_base + UARTDBGCR);
+	cr = readl(priv->base + UARTDBGCR);
+	writel(0, priv->base + UARTDBGCR);
 
 	/* Calculate and set baudrate */
 	quot = (imx_get_xclk() * 4) / new_baudrate;
-	writel(quot & 0x3f, dev->map_base + UARTDBGFBRD);
-	writel(quot >> 6, dev->map_base + UARTDBGIBRD);
+	writel(quot & 0x3f, priv->base + UARTDBGFBRD);
+	writel(quot >> 6, priv->base + UARTDBGIBRD);
 
 	/* Set 8n1 mode, enable FIFOs */
 	lcr_h = WLEN8 | FEN;
-	writel(lcr_h, dev->map_base + UARTDBGLCR_H);
+	writel(lcr_h, priv->base + UARTDBGLCR_H);
 
 	/* Re-enable debug UART */
-	writel(cr, dev->map_base + UARTDBGCR);
+	writel(cr, priv->base + UARTDBGCR);
 
-	local->baudrate = new_baudrate;
+	priv->baudrate = new_baudrate;
 
 	return 0;
 }
 
 static int stm_clocksource_clock_change(struct notifier_block *nb, unsigned long event, void *data)
 {
-	struct stm_serial_local *local = container_of(nb, struct stm_serial_local, notify);
+	struct stm_priv *priv = container_of(nb, struct stm_priv, notify);
 
-	return stm_serial_setbaudrate(&local->cdev, local->baudrate);
+	return stm_serial_setbaudrate(&priv->cdev, priv->baudrate);
 }
 
-static int stm_serial_init_port(struct console_device *cdev)
+static int stm_serial_init_port(struct stm_priv *priv)
 {
-	struct device_d *dev = cdev->dev;
-
 	/* Disable UART */
-	writel(0, dev->map_base + UARTDBGCR);
+	writel(0, priv->base + UARTDBGCR);
 
 	/* Mask interrupts */
-	writel(0, dev->map_base + UARTDBGIMSC);
+	writel(0, priv->base + UARTDBGIMSC);
 
 	return 0;
 }
 
-static struct stm_serial_local stm_device = {
-	.cdev = {
-		.f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR,
-		.tstc = stm_serial_tstc,
-		.putc = stm_serial_putc,
-		.getc = stm_serial_getc,
-		.flush = stm_serial_flush,
-		.setbrg = stm_serial_setbaudrate,
-	},
-};
-
 static int stm_serial_probe(struct device_d *dev)
 {
-	stm_device.cdev.dev = dev;
-	dev->type_data = &stm_device.cdev;
+	struct stm_priv *priv;
+	struct console_device *cdev;
+
+	priv = xzalloc(sizeof *priv);
+
+	cdev = &priv->cdev;
+
+	cdev->f_caps = CONSOLE_STDIN | CONSOLE_STDOUT | CONSOLE_STDERR;
+	cdev->tstc = stm_serial_tstc;
+	cdev->putc = stm_serial_putc;
+	cdev->getc = stm_serial_getc;
+	cdev->flush = stm_serial_flush;
+	cdev->setbrg = stm_serial_setbaudrate;
+	cdev->dev = dev;
+
+	dev->type_data = cdev;
+	priv->base = dev_request_mem_region(dev, 0);
 
-	stm_serial_init_port(&stm_device.cdev);
-	stm_serial_setbaudrate(&stm_device.cdev, CONFIG_BAUDRATE);
+	stm_serial_init_port(priv);
+	stm_serial_setbaudrate(cdev, CONFIG_BAUDRATE);
 
 	/* Enable UART */
-	writel(TXE | RXE | UARTEN, dev->map_base + UARTDBGCR);
+	writel(TXE | RXE | UARTEN, priv->base + UARTDBGCR);
 
-	console_register(&stm_device.cdev);
-	stm_device.notify.notifier_call = stm_clocksource_clock_change;
-	clock_register_client(&stm_device.notify);
+	console_register(cdev);
+	priv->notify.notifier_call = stm_clocksource_clock_change;
+	clock_register_client(&priv->notify);
 
 	return 0;
 }
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 05/11] serial mpc5xxx: get rid of map_base
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (3 preceding siblings ...)
  2011-07-28 13:41 ` [PATCH 04/11] serial stm: " Sascha Hauer
@ 2011-07-28 13:41 ` Sascha Hauer
  2011-07-28 13:41 ` [PATCH 06/11] smc911x: use dev_* instead of printf Sascha Hauer
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/serial/serial_mpc5xxx.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/serial_mpc5xxx.c b/drivers/serial/serial_mpc5xxx.c
index 2509708..fb580cf 100644
--- a/drivers/serial/serial_mpc5xxx.c
+++ b/drivers/serial/serial_mpc5xxx.c
@@ -64,7 +64,7 @@ static int __mpc5xxx_serial_setbaudrate(struct mpc5xxx_psc *psc, int baudrate)
 static int mpc5xxx_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
 	struct device_d *dev = cdev->dev;
-	struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
+	struct mpc5xxx_psc *psc = dev->priv;
 
 	__mpc5xxx_serial_setbaudrate(psc, baudrate);
 
@@ -108,7 +108,7 @@ static int __mpc5xxx_serial_init(struct mpc5xxx_psc *psc)
 static int mpc5xxx_serial_init(struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
-	struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
+	struct mpc5xxx_psc *psc = dev->priv;
 
 	__mpc5xxx_serial_init(psc);
 
@@ -118,7 +118,7 @@ static int mpc5xxx_serial_init(struct console_device *cdev)
 static void mpc5xxx_serial_putc (struct console_device *cdev, const char c)
 {
 	struct device_d *dev = cdev->dev;
-	struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
+	struct mpc5xxx_psc *psc = dev->priv;
 
 	/* Wait for last character to go. */
 	while (!(psc->psc_status & PSC_SR_TXEMP))
@@ -130,7 +130,7 @@ static void mpc5xxx_serial_putc (struct console_device *cdev, const char c)
 static int mpc5xxx_serial_getc (struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
-	struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
+	struct mpc5xxx_psc *psc = dev->priv;
 
 	/* Wait for a character to arrive. */
 	while (!(psc->psc_status & PSC_SR_RXRDY))
@@ -142,7 +142,7 @@ static int mpc5xxx_serial_getc (struct console_device *cdev)
 static int mpc5xxx_serial_tstc (struct console_device *cdev)
 {
 	struct device_d *dev = cdev->dev;
-	struct mpc5xxx_psc *psc = (struct mpc5xxx_psc *)dev->map_base;
+	struct mpc5xxx_psc *psc = dev->priv;
 
 	return (psc->psc_status & PSC_SR_RXRDY);
 }
@@ -153,6 +153,7 @@ static int mpc5xxx_serial_probe(struct device_d *dev)
 	
 	cdev = xzalloc(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 = mpc5xxx_serial_tstc;
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 06/11] smc911x: use dev_* instead of printf
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (4 preceding siblings ...)
  2011-07-28 13:41 ` [PATCH 05/11] serial mpc5xxx: " Sascha Hauer
@ 2011-07-28 13:41 ` Sascha Hauer
  2011-07-28 13:42 ` [PATCH 07/11] smc911x: switch to use resources Sascha Hauer
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:41 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/cs8900.c  |    2 +-
 drivers/net/smc911x.c |   22 +++++++++-------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/net/cs8900.c b/drivers/net/cs8900.c
index de6d038..d954e39 100644
--- a/drivers/net/cs8900.c
+++ b/drivers/net/cs8900.c
@@ -441,7 +441,7 @@ static int cs8900_probe(struct device_d *dev)
 	debug("cs8900_init()\n");
 
 	priv = (struct cs8900_priv *)xmalloc(sizeof(*priv));
-	priv->regs = (u16 *)dev->map_base;
+	priv->regs = dev_request_mem_region(dev, 0);
 	if (cs8900_check_id(priv)) {
 		free(priv);
 		return -1;
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index dc5477b..9d84be4 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -528,8 +528,8 @@ static void smc911x_reset(struct eth_device *edev)
 			if ((readl(priv->base + PMT_CTRL) & PMT_CTRL_READY))
 				break;
 			if (is_timeout(start, 100 * USECOND)) {
-				printf(DRIVERNAME
-					": timeout waiting for PM restore\n");
+				dev_err(&edev->dev,
+						"timeout waiting for PM restore\n");
 				return;
 			}
 		}
@@ -545,7 +545,7 @@ static void smc911x_reset(struct eth_device *edev)
 		if (!(readl(priv->base + E2P_CMD) & E2P_CMD_EPC_BUSY))
 			break;
 		if (is_timeout(start, 10 * MSECOND)) {
-			printf(DRIVERNAME ": reset timeout\n");
+			dev_err(&edev->dev, "reset timeout\n");
 			return;
 		}
 	}
@@ -610,7 +610,7 @@ static int smc911x_eth_send(struct eth_device *edev, void *packet, int length)
 					TX_FIFO_INF_TSUSED) >> 16)
 			break;
 		if (is_timeout(start, 100 * MSECOND)) {
-			printf("TX timeout\n");
+			dev_err(&edev->dev, "TX timeout\n");
 			return -1;
 		}
 	}
@@ -625,7 +625,7 @@ static int smc911x_eth_send(struct eth_device *edev, void *packet, int length)
 	if(!status)
 		return 0;
 
-	printf(DRIVERNAME ": failed to send packet: %s%s%s%s%s\n",
+	dev_err(&edev->dev, "failed to send packet: %s%s%s%s%s\n",
 		status & TX_STS_LOC ? "TX_STS_LOC " : "",
 		status & TX_STS_LATE_COLL ? "TX_STS_LATE_COLL " : "",
 		status & TX_STS_MANY_COLL ? "TX_STS_MANY_COLL " : "",
@@ -663,8 +663,7 @@ static int smc911x_eth_rx(struct eth_device *edev)
 			*data++ = readl(priv->base + RX_DATA_FIFO);
 
 		if(status & RX_STS_ES)
-			printf(DRIVERNAME
-				": dropped bad packet. Status: 0x%08x\n",
+			dev_err(&edev->dev, "dropped bad packet. Status: 0x%08x\n",
 				status);
 		else
 			net_receive(NetRxPackets[0], pktlen);
@@ -692,12 +691,9 @@ static int smc911x_probe(struct device_d *dev)
 	uint32_t val;
 	int i;
 
-	debug("smc911x_eth_init()\n");
-
 	val = readl(dev->map_base + BYTE_TEST);
 	if(val != 0x87654321) {
-		printf(DRIVERNAME
-			": no smc911x found on 0x%08x (byte_test=0x%08x)\n",
+		dev_err(dev, "no smc911x found on 0x%08x (byte_test=0x%08x)\n",
 			dev->map_base, val);
 		return -ENODEV;
 	}
@@ -707,11 +703,11 @@ static int smc911x_probe(struct device_d *dev)
 		if (chip_ids[i].id == val) break;
 	}
 	if (!chip_ids[i].id) {
-		printf(DRIVERNAME ": Unknown chip ID %04x\n", val);
+		dev_err(dev, "Unknown chip ID %04x\n", val);
 		return -ENODEV;
 	}
 
-	debug(DRIVERNAME ": detected %s controller\n", chip_ids[i].name);
+	dev_info(dev, "detected %s controller\n", chip_ids[i].name);
 
 	edev = xzalloc(sizeof(struct eth_device) +
 			sizeof(struct smc911x_priv));
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 07/11] smc911x: switch to use resources
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (5 preceding siblings ...)
  2011-07-28 13:41 ` [PATCH 06/11] smc911x: use dev_* instead of printf Sascha Hauer
@ 2011-07-28 13:42 ` Sascha Hauer
  2011-07-28 13:42 ` [PATCH 08/11] smc911x: embed eth_device into priv Sascha Hauer
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:42 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/smc911x.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 9d84be4..615fd61 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -369,7 +369,7 @@
 
 struct smc911x_priv {
 	struct mii_device miidev;
-	unsigned long base;
+	void __iomem *base;
 };
 
 struct chip_id {
@@ -690,15 +690,18 @@ static int smc911x_probe(struct device_d *dev)
 	struct smc911x_priv *priv;
 	uint32_t val;
 	int i;
+	void *base;
 
-	val = readl(dev->map_base + BYTE_TEST);
+	base = dev_request_mem_region(dev, 0);
+
+	val = readl(base + BYTE_TEST);
 	if(val != 0x87654321) {
-		dev_err(dev, "no smc911x found on 0x%08x (byte_test=0x%08x)\n",
-			dev->map_base, val);
+		dev_err(dev, "no smc911x found on 0x%p (byte_test=0x%08x)\n",
+			base, val);
 		return -ENODEV;
 	}
 
-	val = readl(dev->map_base + ID_REV) >> 16;
+	val = readl(base + ID_REV) >> 16;
 	for(i = 0; chip_ids[i].id != 0; i++) {
 		if (chip_ids[i].id == val) break;
 	}
@@ -729,7 +732,7 @@ static int smc911x_probe(struct device_d *dev)
 	priv->miidev.address = 1;
 	priv->miidev.flags = 0;
 	priv->miidev.edev = edev;
-	priv->base = dev->map_base;
+	priv->base = base;
 
 	smc911x_reset(edev);
 	smc911x_phy_reset(edev);
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 08/11] smc911x: embed eth_device into priv
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (6 preceding siblings ...)
  2011-07-28 13:42 ` [PATCH 07/11] smc911x: switch to use resources Sascha Hauer
@ 2011-07-28 13:42 ` Sascha Hauer
  2011-07-28 13:42 ` [PATCH 09/11] ARM pcm037: Fix wrong sdram base Sascha Hauer
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:42 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/smc911x.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 615fd61..8c6f9fc 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -368,6 +368,7 @@
 #define CHIP_9221	0x9221
 
 struct smc911x_priv {
+	struct eth_device edev;
 	struct mii_device miidev;
 	void __iomem *base;
 };
@@ -712,12 +713,10 @@ static int smc911x_probe(struct device_d *dev)
 
 	dev_info(dev, "detected %s controller\n", chip_ids[i].name);
 
-	edev = xzalloc(sizeof(struct eth_device) +
-			sizeof(struct smc911x_priv));
+	priv = xzalloc(sizeof(*priv));
+	edev = &priv->edev;
 	dev->type_data = edev;
-	edev->priv = (struct smc911x_priv *)(edev + 1);
-
-	priv = edev->priv;
+	edev->priv = priv;
 
 	edev->init = smc911x_init_dev;
 	edev->open = smc911x_eth_open;
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 09/11] ARM pcm037: Fix wrong sdram base
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (7 preceding siblings ...)
  2011-07-28 13:42 ` [PATCH 08/11] smc911x: embed eth_device into priv Sascha Hauer
@ 2011-07-28 13:42 ` 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
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:42 UTC (permalink / raw)
  To: barebox

got broken while switching the boards to sdram registration
helper.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/pcm037/pcm037.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/boards/pcm037/pcm037.c b/arch/arm/boards/pcm037/pcm037.c
index 6e20d1d..f011d48 100644
--- a/arch/arm/boards/pcm037/pcm037.c
+++ b/arch/arm/boards/pcm037/pcm037.c
@@ -240,7 +240,7 @@ static int imx31_devices_init(void)
 	imx31_add_nand(&nand_info);
 	register_device(&network_dev);
 
-	sdram_dev = add_mem_device("ram0", IMX_SDRAM_CS1, SDRAM0 * 1024 * 1024,
+	sdram_dev = add_mem_device("ram0", IMX_SDRAM_CS0, SDRAM0 * 1024 * 1024,
 				   IORESOURCE_MEM_WRITEABLE);
 	armlinux_add_dram(sdram_dev);
 #ifndef CONFIG_PCM037_SDRAM_BANK1_NONE
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 10/11] smc91111: switch to resources
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (8 preceding siblings ...)
  2011-07-28 13:42 ` [PATCH 09/11] ARM pcm037: Fix wrong sdram base Sascha Hauer
@ 2011-07-28 13:42 ` Sascha Hauer
  2011-07-28 13:42 ` [PATCH 11/11] fec_mpc5200: " Sascha Hauer
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:42 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/smc91111.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index 535e69a..1c1ffea 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1317,7 +1317,7 @@ static int smc91c111_probe(struct device_d *dev)
 	priv->miidev.address = 0;
 	priv->miidev.flags = 0;
 	priv->miidev.edev = edev;
-	priv->base = IOMEM(dev->map_base);
+	priv->base = dev_request_mem_region(dev, 0);
 
 	smc91c111_reset(edev);
 
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 11/11] fec_mpc5200: switch to resources
  2011-07-28 13:41 more switches to resources Sascha Hauer
                   ` (9 preceding siblings ...)
  2011-07-28 13:42 ` [PATCH 10/11] smc91111: switch to resources Sascha Hauer
@ 2011-07-28 13:42 ` Sascha Hauer
  10 siblings, 0 replies; 12+ messages in thread
From: Sascha Hauer @ 2011-07-28 13:42 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/fec_mpc5200.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/fec_mpc5200.c b/drivers/net/fec_mpc5200.c
index 7528316..4ebd906 100644
--- a/drivers/net/fec_mpc5200.c
+++ b/drivers/net/fec_mpc5200.c
@@ -673,7 +673,7 @@ int mpc5xxx_fec_probe(struct device_d *dev)
 	edev->get_ethaddr = mpc5xxx_fec_get_ethaddr,
 	edev->set_ethaddr = mpc5xxx_fec_set_ethaddr,
 
-	fec->eth = (ethernet_regs *)dev->map_base;
+	fec->eth = dev_request_mem_region(dev, 0);
 	fec->tbdBase = (FEC_TBD *)FEC_BD_BASE;
 	fec->rbdBase = (FEC_RBD *)(FEC_BD_BASE + FEC_TBD_NUM * sizeof(FEC_TBD));
 
-- 
1.7.5.4


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-07-28 13:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 13:41 more switches to resources Sascha Hauer
2011-07-28 13:41 ` [PATCH 01/11] serial netx: get rid of map_base Sascha Hauer
2011-07-28 13:41 ` [PATCH 02/11] serial s3c: " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox