diff mbox series

[Qemu,devel,v4,2/3] msf2: Add EMAC block to SmartFusion2 SoC

Message ID 1586529926-11441-3-git-send-email-sundeep.lkml@gmail.com
State New
Headers show
Series Add SmartFusion2 EMAC block | expand

Commit Message

sundeep subbaraya April 10, 2020, 2:45 p.m. UTC
From: Subbaraya Sundeep <sundeep.lkml@gmail.com>

With SmartFusion2 Ethernet MAC model in
place this patch adds the same to SoC.

Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
---
 hw/arm/msf2-soc.c         | 21 ++++++++++++++++++++-
 include/hw/arm/msf2-soc.h |  3 +++
 2 files changed, 23 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé April 12, 2020, 5:58 p.m. UTC | #1
On 4/10/20 4:45 PM, sundeep.lkml@gmail.com wrote:
> From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> 
> With SmartFusion2 Ethernet MAC model in
> place this patch adds the same to SoC.
> 
> Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> ---
>  hw/arm/msf2-soc.c         | 21 ++++++++++++++++++++-
>  include/hw/arm/msf2-soc.h |  3 +++
>  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> index 588d643..2f2db6d 100644
> --- a/hw/arm/msf2-soc.c
> +++ b/hw/arm/msf2-soc.c
> @@ -35,6 +35,7 @@

Maybe you also want:

- * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
+ * Copyright (c) 2017-2020 Subbaraya Sundeep <sundeep.lkml@gmail.com>

>  
>  #define MSF2_TIMER_BASE       0x40004000
>  #define MSF2_SYSREG_BASE      0x40038000
> +#define MSF2_EMAC_BASE        0x40041000
>  
>  #define ENVM_BASE_ADDRESS     0x60000000
>  
> @@ -55,6 +56,7 @@ static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };
>  static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
>  static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
>  static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
> +static const int emac_irq[MSF2_NUM_EMACS] = { 12 };

Correct.

>  
>  static void do_sys_reset(void *opaque, int n, int level)
>  {
> @@ -81,6 +83,13 @@ static void m2sxxx_soc_initfn(Object *obj)
>          sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]),
>                            TYPE_MSS_SPI);
>      }
> +
> +    sysbus_init_child_obj(obj, "eth", &s->emac, sizeof(s->emac),

"eth" -> "tsemac" (or "emac")?

> +                          TYPE_MSS_EMAC);
> +    if (nd_table[0].used) {
> +        qemu_check_nic_model(&nd_table[0], TYPE_MSS_EMAC);
> +        qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
> +    }
>  }
>  
>  static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
> @@ -192,6 +201,17 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
>          g_free(bus_name);
>      }
>  
> +    dev = DEVICE(&s->emac);

Can you pass the DMA memory via a link property please?

       object_property_set_link(OBJECT(&s->emac),
                                OBJECT(get_system_memory()),
                                "ahb-bus", &error_abort);

> +    object_property_set_bool(OBJECT(&s->emac), true, "realized", &err);
> +    if (err != NULL) {
> +        error_propagate(errp, err);
> +        return;
> +    }
> +    busdev = SYS_BUS_DEVICE(dev);
> +    sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE);
> +    sysbus_connect_irq(busdev, 0,
> +                           qdev_get_gpio_in(armv7m, emac_irq[0]));

Indentation is off.

> +
>      /* Below devices are not modelled yet. */
>      create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
>      create_unimplemented_device("dma", 0x40003000, 0x1000);
> @@ -202,7 +222,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
>      create_unimplemented_device("can", 0x40015000, 0x1000);
>      create_unimplemented_device("rtc", 0x40017000, 0x1000);
>      create_unimplemented_device("apb_config", 0x40020000, 0x10000);
> -    create_unimplemented_device("emac", 0x40041000, 0x1000);
>      create_unimplemented_device("usb", 0x40043000, 0x1000);
>  }
>  
> diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
> index 3cfe5c7..296ed03 100644
> --- a/include/hw/arm/msf2-soc.h
> +++ b/include/hw/arm/msf2-soc.h
> @@ -29,12 +29,14 @@
>  #include "hw/timer/mss-timer.h"
>  #include "hw/misc/msf2-sysreg.h"
>  #include "hw/ssi/mss-spi.h"
> +#include "hw/net/msf2-emac.h"
>  
>  #define TYPE_MSF2_SOC     "msf2-soc"
>  #define MSF2_SOC(obj)     OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC)
>  
>  #define MSF2_NUM_SPIS         2
>  #define MSF2_NUM_UARTS        2
> +#define MSF2_NUM_EMACS        1
>  
>  /*
>   * System timer consists of two programmable 32-bit
> @@ -62,6 +64,7 @@ typedef struct MSF2State {
>      MSF2SysregState sysreg;
>      MSSTimerState timer;
>      MSSSpiState spi[MSF2_NUM_SPIS];
> +    MSF2EmacState emac;

You used 'emac_irq[MSF2_NUM_EMACS]', either use emac[MSF2_NUM_EMACS]
here or drop MSF2_NUM_EMACS?

>  } MSF2State;
>  
>  #endif
>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
sundeep subbaraya April 14, 2020, 1:13 p.m. UTC | #2
Hi Philippe,

On Sun, Apr 12, 2020 at 11:28 PM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> On 4/10/20 4:45 PM, sundeep.lkml@gmail.com wrote:
> > From: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> >
> > With SmartFusion2 Ethernet MAC model in
> > place this patch adds the same to SoC.
> >
> > Signed-off-by: Subbaraya Sundeep <sundeep.lkml@gmail.com>
> > ---
> >  hw/arm/msf2-soc.c         | 21 ++++++++++++++++++++-
> >  include/hw/arm/msf2-soc.h |  3 +++
> >  2 files changed, 23 insertions(+), 1 deletion(-)
> >
> > diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
> > index 588d643..2f2db6d 100644
> > --- a/hw/arm/msf2-soc.c
> > +++ b/hw/arm/msf2-soc.c
> > @@ -35,6 +35,7 @@
>
> Maybe you also want:
>
> - * Copyright (c) 2017 Subbaraya Sundeep <sundeep.lkml@gmail.com>
> + * Copyright (c) 2017-2020 Subbaraya Sundeep <sundeep.lkml@gmail.com>
>
Ok.
> >
> >  #define MSF2_TIMER_BASE       0x40004000
> >  #define MSF2_SYSREG_BASE      0x40038000
> > +#define MSF2_EMAC_BASE        0x40041000
> >
> >  #define ENVM_BASE_ADDRESS     0x60000000
> >
> > @@ -55,6 +56,7 @@ static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };
> >  static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
> >  static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
> >  static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
> > +static const int emac_irq[MSF2_NUM_EMACS] = { 12 };
>
> Correct.
>
> >
> >  static void do_sys_reset(void *opaque, int n, int level)
> >  {
> > @@ -81,6 +83,13 @@ static void m2sxxx_soc_initfn(Object *obj)
> >          sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]),
> >                            TYPE_MSS_SPI);
> >      }
> > +
> > +    sysbus_init_child_obj(obj, "eth", &s->emac, sizeof(s->emac),
>
> "eth" -> "tsemac" (or "emac")?
>
Will change to emac.
> > +                          TYPE_MSS_EMAC);
> > +    if (nd_table[0].used) {
> > +        qemu_check_nic_model(&nd_table[0], TYPE_MSS_EMAC);
> > +        qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
> > +    }
> >  }
> >
> >  static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
> > @@ -192,6 +201,17 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
> >          g_free(bus_name);
> >      }
> >
> > +    dev = DEVICE(&s->emac);
>
> Can you pass the DMA memory via a link property please?
>
>        object_property_set_link(OBJECT(&s->emac),
>                                 OBJECT(get_system_memory()),
>                                 "ahb-bus", &error_abort);
>
Okay.
> > +    object_property_set_bool(OBJECT(&s->emac), true, "realized", &err);
> > +    if (err != NULL) {
> > +        error_propagate(errp, err);
> > +        return;
> > +    }
> > +    busdev = SYS_BUS_DEVICE(dev);
> > +    sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE);
> > +    sysbus_connect_irq(busdev, 0,
> > +                           qdev_get_gpio_in(armv7m, emac_irq[0]));
>
> Indentation is off.
>
Will fix
> > +
> >      /* Below devices are not modelled yet. */
> >      create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
> >      create_unimplemented_device("dma", 0x40003000, 0x1000);
> > @@ -202,7 +222,6 @@ static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
> >      create_unimplemented_device("can", 0x40015000, 0x1000);
> >      create_unimplemented_device("rtc", 0x40017000, 0x1000);
> >      create_unimplemented_device("apb_config", 0x40020000, 0x10000);
> > -    create_unimplemented_device("emac", 0x40041000, 0x1000);
> >      create_unimplemented_device("usb", 0x40043000, 0x1000);
> >  }
> >
> > diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
> > index 3cfe5c7..296ed03 100644
> > --- a/include/hw/arm/msf2-soc.h
> > +++ b/include/hw/arm/msf2-soc.h
> > @@ -29,12 +29,14 @@
> >  #include "hw/timer/mss-timer.h"
> >  #include "hw/misc/msf2-sysreg.h"
> >  #include "hw/ssi/mss-spi.h"
> > +#include "hw/net/msf2-emac.h"
> >
> >  #define TYPE_MSF2_SOC     "msf2-soc"
> >  #define MSF2_SOC(obj)     OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC)
> >
> >  #define MSF2_NUM_SPIS         2
> >  #define MSF2_NUM_UARTS        2
> > +#define MSF2_NUM_EMACS        1
> >
> >  /*
> >   * System timer consists of two programmable 32-bit
> > @@ -62,6 +64,7 @@ typedef struct MSF2State {
> >      MSF2SysregState sysreg;
> >      MSSTimerState timer;
> >      MSSSpiState spi[MSF2_NUM_SPIS];
> > +    MSF2EmacState emac;
>
> You used 'emac_irq[MSF2_NUM_EMACS]', either use emac[MSF2_NUM_EMACS]
> here or drop MSF2_NUM_EMACS?
>
Will drop MSF2_NUM_EMACS.

> >  } MSF2State;
> >
> >  #endif
> >
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Thank you,
Sundeep
diff mbox series

Patch

diff --git a/hw/arm/msf2-soc.c b/hw/arm/msf2-soc.c
index 588d643..2f2db6d 100644
--- a/hw/arm/msf2-soc.c
+++ b/hw/arm/msf2-soc.c
@@ -35,6 +35,7 @@ 
 
 #define MSF2_TIMER_BASE       0x40004000
 #define MSF2_SYSREG_BASE      0x40038000
+#define MSF2_EMAC_BASE        0x40041000
 
 #define ENVM_BASE_ADDRESS     0x60000000
 
@@ -55,6 +56,7 @@  static const uint32_t uart_addr[MSF2_NUM_UARTS] = { 0x40000000 , 0x40010000 };
 static const int spi_irq[MSF2_NUM_SPIS] = { 2, 3 };
 static const int uart_irq[MSF2_NUM_UARTS] = { 10, 11 };
 static const int timer_irq[MSF2_NUM_TIMERS] = { 14, 15 };
+static const int emac_irq[MSF2_NUM_EMACS] = { 12 };
 
 static void do_sys_reset(void *opaque, int n, int level)
 {
@@ -81,6 +83,13 @@  static void m2sxxx_soc_initfn(Object *obj)
         sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]),
                           TYPE_MSS_SPI);
     }
+
+    sysbus_init_child_obj(obj, "eth", &s->emac, sizeof(s->emac),
+                          TYPE_MSS_EMAC);
+    if (nd_table[0].used) {
+        qemu_check_nic_model(&nd_table[0], TYPE_MSS_EMAC);
+        qdev_set_nic_properties(DEVICE(&s->emac), &nd_table[0]);
+    }
 }
 
 static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
@@ -192,6 +201,17 @@  static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
         g_free(bus_name);
     }
 
+    dev = DEVICE(&s->emac);
+    object_property_set_bool(OBJECT(&s->emac), true, "realized", &err);
+    if (err != NULL) {
+        error_propagate(errp, err);
+        return;
+    }
+    busdev = SYS_BUS_DEVICE(dev);
+    sysbus_mmio_map(busdev, 0, MSF2_EMAC_BASE);
+    sysbus_connect_irq(busdev, 0,
+                           qdev_get_gpio_in(armv7m, emac_irq[0]));
+
     /* Below devices are not modelled yet. */
     create_unimplemented_device("i2c_0", 0x40002000, 0x1000);
     create_unimplemented_device("dma", 0x40003000, 0x1000);
@@ -202,7 +222,6 @@  static void m2sxxx_soc_realize(DeviceState *dev_soc, Error **errp)
     create_unimplemented_device("can", 0x40015000, 0x1000);
     create_unimplemented_device("rtc", 0x40017000, 0x1000);
     create_unimplemented_device("apb_config", 0x40020000, 0x10000);
-    create_unimplemented_device("emac", 0x40041000, 0x1000);
     create_unimplemented_device("usb", 0x40043000, 0x1000);
 }
 
diff --git a/include/hw/arm/msf2-soc.h b/include/hw/arm/msf2-soc.h
index 3cfe5c7..296ed03 100644
--- a/include/hw/arm/msf2-soc.h
+++ b/include/hw/arm/msf2-soc.h
@@ -29,12 +29,14 @@ 
 #include "hw/timer/mss-timer.h"
 #include "hw/misc/msf2-sysreg.h"
 #include "hw/ssi/mss-spi.h"
+#include "hw/net/msf2-emac.h"
 
 #define TYPE_MSF2_SOC     "msf2-soc"
 #define MSF2_SOC(obj)     OBJECT_CHECK(MSF2State, (obj), TYPE_MSF2_SOC)
 
 #define MSF2_NUM_SPIS         2
 #define MSF2_NUM_UARTS        2
+#define MSF2_NUM_EMACS        1
 
 /*
  * System timer consists of two programmable 32-bit
@@ -62,6 +64,7 @@  typedef struct MSF2State {
     MSF2SysregState sysreg;
     MSSTimerState timer;
     MSSSpiState spi[MSF2_NUM_SPIS];
+    MSF2EmacState emac;
 } MSF2State;
 
 #endif