diff mbox

[v3,11/14] hw/exynos4210.c: Add LAN support for SMDKC210.

Message ID 1323672206-11891-12-git-send-email-e.voevodin@samsung.com
State New
Headers show

Commit Message

Evgeny Voevodin Dec. 12, 2011, 6:43 a.m. UTC
SMDKC210 uses lan9215 chip, but lan9118 in 16-bit mode seems to
be enough.

Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
---
 hw/exynos4210.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

Comments

Peter Maydell Dec. 13, 2011, 12:01 p.m. UTC | #1
On 12 December 2011 06:43, Evgeny Voevodin <e.voevodin@samsung.com> wrote:
> SMDKC210 uses lan9215 chip, but lan9118 in 16-bit mode seems to
> be enough.
>
> Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com>
> ---
>  hw/exynos4210.c |   18 ++++++++++++++++++
>  1 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/hw/exynos4210.c b/hw/exynos4210.c
> index 055205d..0a93866 100644
> --- a/hw/exynos4210.c
> +++ b/hw/exynos4210.c
> @@ -26,6 +26,8 @@
>  #include "sysemu.h"
>  #include "sysbus.h"
>  #include "arm-misc.h"
> +#include "net.h"
> +#include "devices.h"
>  #include "exec-memory.h"
>  #include "exynos4210.h"
>
> @@ -226,6 +228,8 @@ static void exynos4210_init(ram_addr_t ram_size,
>     SysBusDevice *busdev;
>     ram_addr_t mem_size;
>     int n;
> +    NICInfo *nd;
> +    int done_nic = 0;
>
>     switch (board_type) {
>     case BOARD_EXYNOS4210_NURI:
> @@ -458,6 +462,20 @@ static void exynos4210_init(ram_addr_t ram_size,
>         exynos4210_uart_create(addr, fifo_size, channel, NULL, uart_irq);
>     }
>
> +    /*** LAN adapter: this should be a 9215 but the 9118 is close enough ***/
> +    if (board_type == BOARD_EXYNOS4210_SMDKC210) {
> +        for (n = 0; n < nb_nics; n++) {
> +            nd = &nd_table[n];
> +
> +            if (!done_nic && (!nd->model ||
> +                    strcmp(nd->model, "lan9118") == 0)) {
> +                dev = lan9118_init(nd, 0x05000000,
> +                        qemu_irq_invert(irq_table[exynos4210_get_irq(37, 1)]));
> +                qdev_prop_set_uint32(dev, "mode_16bit", 1);
> +                done_nic = 1;
> +            }
> +        }
> +    }

This whole loop is overkill for the straightforward case of
"we only allow one NIC and this is it". Look at hw/vexpress.c,
but basically you want:

    nd = &nd_table[0];
    if (nd->vlan) {
       initialise lan9118 based on nd;
    }

As noted in previous patch, you can't set qdev properties after
the device has been initialised, only before.

>
>     /*** Load kernel ***/
>
> --
> 1.7.4.1
>
>
diff mbox

Patch

diff --git a/hw/exynos4210.c b/hw/exynos4210.c
index 055205d..0a93866 100644
--- a/hw/exynos4210.c
+++ b/hw/exynos4210.c
@@ -26,6 +26,8 @@ 
 #include "sysemu.h"
 #include "sysbus.h"
 #include "arm-misc.h"
+#include "net.h"
+#include "devices.h"
 #include "exec-memory.h"
 #include "exynos4210.h"
 
@@ -226,6 +228,8 @@  static void exynos4210_init(ram_addr_t ram_size,
     SysBusDevice *busdev;
     ram_addr_t mem_size;
     int n;
+    NICInfo *nd;
+    int done_nic = 0;
 
     switch (board_type) {
     case BOARD_EXYNOS4210_NURI:
@@ -458,6 +462,20 @@  static void exynos4210_init(ram_addr_t ram_size,
         exynos4210_uart_create(addr, fifo_size, channel, NULL, uart_irq);
     }
 
+    /*** LAN adapter: this should be a 9215 but the 9118 is close enough ***/
+    if (board_type == BOARD_EXYNOS4210_SMDKC210) {
+        for (n = 0; n < nb_nics; n++) {
+            nd = &nd_table[n];
+
+            if (!done_nic && (!nd->model ||
+                    strcmp(nd->model, "lan9118") == 0)) {
+                dev = lan9118_init(nd, 0x05000000,
+                        qemu_irq_invert(irq_table[exynos4210_get_irq(37, 1)]));
+                qdev_prop_set_uint32(dev, "mode_16bit", 1);
+                done_nic = 1;
+            }
+        }
+    }
 
     /*** Load kernel ***/