mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] Switch Nios2 devices to ressource usage
@ 2011-07-25 19:50 franck.jullien
  2011-07-25 19:50 ` [PATCH 1/4] nios2/generic.c: use add_generic_device helper franck.jullien
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: franck.jullien @ 2011-07-25 19:50 UTC (permalink / raw)
  To: barebox

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

This series switches nios2 drivers to ressources

Franck Jullien (4):
  nios2/generic.c: use add_generic_device helper
  nios2/altera_tse.c: switch to ressources
  nios2/serial_altera.c: switch to ressources
  nios2/serial_altera_jtag.c: switch to ressources

 arch/nios2/boards/generic/generic.c |   20 ++++----------------
 drivers/net/altera_tse.c            |    4 ++--
 drivers/serial/serial_altera.c      |    8 ++++----
 drivers/serial/serial_altera_jtag.c |    6 +++---
 4 files changed, 13 insertions(+), 25 deletions(-)


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

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

* [PATCH 1/4] nios2/generic.c: use add_generic_device helper
  2011-07-25 19:50 [PATCH] Switch Nios2 devices to ressource usage franck.jullien
@ 2011-07-25 19:50 ` franck.jullien
  2011-07-25 19:50 ` [PATCH 2/4] nios2/altera_tse.c: switch to ressources franck.jullien
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: franck.jullien @ 2011-07-25 19:50 UTC (permalink / raw)
  To: barebox

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

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 arch/nios2/boards/generic/generic.c |   20 ++++----------------
 1 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/arch/nios2/boards/generic/generic.c b/arch/nios2/boards/generic/generic.c
index 089715b..f424be5 100644
--- a/arch/nios2/boards/generic/generic.c
+++ b/arch/nios2/boards/generic/generic.c
@@ -6,20 +6,6 @@
 
 static int phy_address = 1;
 
-static struct device_d mac_dev = {
-	.id            = -1,
-	.name          = "altera_tse",
-	.map_base      = NIOS_SOPC_TSE_BASE,
-	.size          = 0x00000400,
-	.platform_data = &phy_address,
-};
-
-static struct device_d altera_serial_device = {
-	.id       = -1,
-	.name     = "altera_serial",
-	.map_base = NIOS_SOPC_UART_BASE,
-};
-
 /*
 static struct device_d epcs_flash_device = {
 	.id       = -1,
@@ -33,7 +19,8 @@ static int generic_devices_init(void)
 	add_cfi_flash_device(-1, NIOS_SOPC_FLASH_BASE, NIOS_SOPC_FLASH_SIZE, 0);
 	add_mem_device("ram0", NIOS_SOPC_MEMORY_BASE, NIOS_SOPC_MEMORY_SIZE,
 		       IORESOURCE_MEM_WRITEABLE);
-	register_device(&mac_dev);
+	add_generic_device("altera_tse", -1, NULL, NIOS_SOPC_TSE_BASE, 0x400,
+			   IORESOURCE_MEM, &phy_address);
 	/*register_device(&epcs_flash_device);*/
 
 	devfs_add_partition("nor0", 0x00000, 0x40000, PARTITION_FIXED, "self0");
@@ -49,7 +36,8 @@ device_initcall(generic_devices_init);
 
 static int altera_console_init(void)
 {
-	register_device(&altera_serial_device);
+	add_generic_device("altera_serial", -1, NULL, NIOS_SOPC_UART_BASE, 0x20,
+			   IORESOURCE_MEM, NULL);
 
 	return 0;
 }
-- 
1.7.1


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

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

* [PATCH 2/4] nios2/altera_tse.c: switch to ressources
  2011-07-25 19:50 [PATCH] Switch Nios2 devices to ressource usage franck.jullien
  2011-07-25 19:50 ` [PATCH 1/4] nios2/generic.c: use add_generic_device helper franck.jullien
@ 2011-07-25 19:50 ` franck.jullien
  2011-07-26  6:48   ` Sascha Hauer
  2011-07-25 19:50 ` [PATCH 3/4] nios2/serial_altera.c: " franck.jullien
  2011-07-25 19:50 ` [PATCH 4/4] nios2/serial_altera_jtag.c: " franck.jullien
  3 siblings, 1 reply; 9+ messages in thread
From: franck.jullien @ 2011-07-25 19:50 UTC (permalink / raw)
  To: barebox

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

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 drivers/net/altera_tse.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
index ac8cd2d..4298739 100644
--- a/drivers/net/altera_tse.c
+++ b/drivers/net/altera_tse.c
@@ -510,7 +510,7 @@ static int tse_probe(struct device_d *dev)
 	dev->type_data = edev;
 	edev->priv = (struct altera_tse_priv *)(edev + 1);
 
-	edev->iobase = dev->map_base;
+	edev->iobase = (int)dev_request_mem_region(dev, 0);
 
 	priv = edev->priv;
 
@@ -539,7 +539,7 @@ static int tse_probe(struct device_d *dev)
 	memset(rx_desc, 0, (sizeof *rx_desc) * (PKTBUFSRX + 1)); 
 	memset(tx_desc, 0, (sizeof *tx_desc) * 2);
 
-	priv->mac_dev = (struct alt_tse_mac *)dev->map_base;
+	priv->mac_dev = (struct alt_tse_mac *)dev_request_mem_region(dev, 0);
 	priv->sgdma_rx = (struct alt_sgdma_registers *)NIOS_SOPC_SGDMA_RX_BASE;
 	priv->sgdma_tx = (struct alt_sgdma_registers *)NIOS_SOPC_SGDMA_TX_BASE;
 	priv->rx_desc = rx_desc;
-- 
1.7.1


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

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

* [PATCH 3/4] nios2/serial_altera.c: switch to ressources
  2011-07-25 19:50 [PATCH] Switch Nios2 devices to ressource usage franck.jullien
  2011-07-25 19:50 ` [PATCH 1/4] nios2/generic.c: use add_generic_device helper franck.jullien
  2011-07-25 19:50 ` [PATCH 2/4] nios2/altera_tse.c: switch to ressources franck.jullien
@ 2011-07-25 19:50 ` franck.jullien
  2011-07-26  6:52   ` Sascha Hauer
  2011-07-25 19:50 ` [PATCH 4/4] nios2/serial_altera_jtag.c: " franck.jullien
  3 siblings, 1 reply; 9+ messages in thread
From: franck.jullien @ 2011-07-25 19:50 UTC (permalink / raw)
  To: barebox

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

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

diff --git a/drivers/serial/serial_altera.c b/drivers/serial/serial_altera.c
index 54c7178..c0a8356 100644
--- a/drivers/serial/serial_altera.c
+++ b/drivers/serial/serial_altera.c
@@ -29,7 +29,7 @@
 
 static int altera_serial_setbaudrate(struct console_device *cdev, int baudrate)
 {
-	struct nios_uart *uart = (struct nios_uart *)cdev->dev->map_base;
+	struct nios_uart *uart = (struct nios_uart *)dev_request_mem_region(cdev->dev, 0);
 	uint16_t div;
 
 	div = (CPU_FREQ / baudrate) - 1;
@@ -40,7 +40,7 @@ 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 nios_uart *uart = (struct nios_uart *)dev_request_mem_region(cdev->dev, 0);
 
 	while ((readw(&uart->status) & NIOS_UART_TRDY) == 0);
 
@@ -49,14 +49,14 @@ 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 nios_uart *uart = (struct nios_uart *)dev_request_mem_region(cdev->dev, 0);
 
 	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 nios_uart *uart = (struct nios_uart *)dev_request_mem_region(cdev->dev, 0);
 
 	while (altera_serial_tstc(cdev) == 0);
 
-- 
1.7.1


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

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

* [PATCH 4/4] nios2/serial_altera_jtag.c: switch to ressources
  2011-07-25 19:50 [PATCH] Switch Nios2 devices to ressource usage franck.jullien
                   ` (2 preceding siblings ...)
  2011-07-25 19:50 ` [PATCH 3/4] nios2/serial_altera.c: " franck.jullien
@ 2011-07-25 19:50 ` franck.jullien
  2011-07-26  6:53   ` Sascha Hauer
  3 siblings, 1 reply; 9+ messages in thread
From: franck.jullien @ 2011-07-25 19:50 UTC (permalink / raw)
  To: barebox

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

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

diff --git a/drivers/serial/serial_altera_jtag.c b/drivers/serial/serial_altera_jtag.c
index 322f9e9..7d42382 100644
--- a/drivers/serial/serial_altera_jtag.c
+++ b/drivers/serial/serial_altera_jtag.c
@@ -37,7 +37,7 @@ static int altera_serial_jtag_setbaudrate(struct console_device *cdev, int baudr
 
 static void altera_serial_jtag_putc(struct console_device *cdev, char c)
 {
-	struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;
+	struct nios_jtag *jtag = (struct nios_jtag *)dev_request_mem_region(cdev->dev, 0);
 	uint32_t st;
 
 	while (1) {
@@ -51,14 +51,14 @@ static void altera_serial_jtag_putc(struct console_device *cdev, char c)
 
 static int altera_serial_jtag_tstc(struct console_device *cdev)
 {
-	struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;
+	struct nios_jtag *jtag = (struct nios_jtag *)dev_request_mem_region(cdev->dev, 0);
 
 	return readl(&jtag->control) & NIOS_JTAG_RRDY;
 }
 
 static int altera_serial_jtag_getc(struct console_device *cdev)
 {
-	struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;
+	struct nios_jtag *jtag = (struct nios_jtag *)dev_request_mem_region(cdev->dev, 0);
 	uint32_t val;
 
 	while (1) {
-- 
1.7.1


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

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

* Re: [PATCH 2/4] nios2/altera_tse.c: switch to ressources
  2011-07-25 19:50 ` [PATCH 2/4] nios2/altera_tse.c: switch to ressources franck.jullien
@ 2011-07-26  6:48   ` Sascha Hauer
  2011-07-26 11:41     ` Franck JULLIEN
  0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2011-07-26  6:48 UTC (permalink / raw)
  To: franck.jullien; +Cc: barebox

Hi Franck,

On Mon, Jul 25, 2011 at 09:50:18PM +0200, franck.jullien@gmail.com wrote:
> From: Franck Jullien <franck.jullien@gmail.com>
> 
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
>  drivers/net/altera_tse.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
> index ac8cd2d..4298739 100644
> --- a/drivers/net/altera_tse.c
> +++ b/drivers/net/altera_tse.c
> @@ -510,7 +510,7 @@ static int tse_probe(struct device_d *dev)
>  	dev->type_data = edev;
>  	edev->priv = (struct altera_tse_priv *)(edev + 1);
>  
> -	edev->iobase = dev->map_base;
> +	edev->iobase = (int)dev_request_mem_region(dev, 0);

Damned. I wasn't aware that struct eth_device has an int iobase.
Can you please move your iobase to edev->priv (as a void __iomem *)?

Then we can remove this otherwise unused field from eth_device.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 3/4] nios2/serial_altera.c: switch to ressources
  2011-07-25 19:50 ` [PATCH 3/4] nios2/serial_altera.c: " franck.jullien
@ 2011-07-26  6:52   ` Sascha Hauer
  0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-07-26  6:52 UTC (permalink / raw)
  To: franck.jullien; +Cc: barebox

On Mon, Jul 25, 2011 at 09:50:19PM +0200, franck.jullien@gmail.com wrote:
> From: Franck Jullien <franck.jullien@gmail.com>
> 
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
>  drivers/serial/serial_altera.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/serial/serial_altera.c b/drivers/serial/serial_altera.c
> index 54c7178..c0a8356 100644
> --- a/drivers/serial/serial_altera.c
> +++ b/drivers/serial/serial_altera.c
> @@ -29,7 +29,7 @@
>  
>  static int altera_serial_setbaudrate(struct console_device *cdev, int baudrate)
>  {
> -	struct nios_uart *uart = (struct nios_uart *)cdev->dev->map_base;
> +	struct nios_uart *uart = (struct nios_uart *)dev_request_mem_region(cdev->dev, 0);

Hm, dev_request_mem_region is not really a request function, so this
will work. Anyway, once we turn it into a real request function this
would break. Please use cdev->dev->priv instead.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 4/4] nios2/serial_altera_jtag.c: switch to ressources
  2011-07-25 19:50 ` [PATCH 4/4] nios2/serial_altera_jtag.c: " franck.jullien
@ 2011-07-26  6:53   ` Sascha Hauer
  0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2011-07-26  6:53 UTC (permalink / raw)
  To: franck.jullien; +Cc: barebox

On Mon, Jul 25, 2011 at 09:50:20PM +0200, franck.jullien@gmail.com wrote:
> From: Franck Jullien <franck.jullien@gmail.com>
> 
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
>  drivers/serial/serial_altera_jtag.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/serial/serial_altera_jtag.c b/drivers/serial/serial_altera_jtag.c
> index 322f9e9..7d42382 100644
> --- a/drivers/serial/serial_altera_jtag.c
> +++ b/drivers/serial/serial_altera_jtag.c
> @@ -37,7 +37,7 @@ static int altera_serial_jtag_setbaudrate(struct console_device *cdev, int baudr
>  
>  static void altera_serial_jtag_putc(struct console_device *cdev, char c)
>  {
> -	struct nios_jtag *jtag = (struct nios_jtag *)cdev->dev->map_base;
> +	struct nios_jtag *jtag = (struct nios_jtag *)dev_request_mem_region(cdev->dev, 0);

Same here.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 2/4] nios2/altera_tse.c: switch to ressources
  2011-07-26  6:48   ` Sascha Hauer
@ 2011-07-26 11:41     ` Franck JULLIEN
  0 siblings, 0 replies; 9+ messages in thread
From: Franck JULLIEN @ 2011-07-26 11:41 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hi Sascha,

2011/7/26 Sascha Hauer <s.hauer@pengutronix.de>:
> Hi Franck,
>
> On Mon, Jul 25, 2011 at 09:50:18PM +0200, franck.jullien@gmail.com wrote:
>> From: Franck Jullien <franck.jullien@gmail.com>
>>
>> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
>> ---
>>  drivers/net/altera_tse.c |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c
>> index ac8cd2d..4298739 100644
>> --- a/drivers/net/altera_tse.c
>> +++ b/drivers/net/altera_tse.c
>> @@ -510,7 +510,7 @@ static int tse_probe(struct device_d *dev)
>>       dev->type_data = edev;
>>       edev->priv = (struct altera_tse_priv *)(edev + 1);
>>
>> -     edev->iobase = dev->map_base;
>> +     edev->iobase = (int)dev_request_mem_region(dev, 0);
>
> Damned. I wasn't aware that struct eth_device has an int iobase.
> Can you please move your iobase to edev->priv (as a void __iomem *)?
>

No problem. I'll also use resources for sgdma_tx and sgdma_rx. I'll resend the
patch tonight.


> Then we can remove this otherwise unused field from eth_device.
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>

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

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

end of thread, other threads:[~2011-07-26 11:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 19:50 [PATCH] Switch Nios2 devices to ressource usage franck.jullien
2011-07-25 19:50 ` [PATCH 1/4] nios2/generic.c: use add_generic_device helper franck.jullien
2011-07-25 19:50 ` [PATCH 2/4] nios2/altera_tse.c: switch to ressources franck.jullien
2011-07-26  6:48   ` Sascha Hauer
2011-07-26 11:41     ` Franck JULLIEN
2011-07-25 19:50 ` [PATCH 3/4] nios2/serial_altera.c: " franck.jullien
2011-07-26  6:52   ` Sascha Hauer
2011-07-25 19:50 ` [PATCH 4/4] nios2/serial_altera_jtag.c: " franck.jullien
2011-07-26  6:53   ` Sascha Hauer

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