[PATCH qemu 36/38] ast2400: add a FTGMAC100 nic

Andrew Jeffery andrew at aj.id.au
Mon Nov 28 13:25:08 AEDT 2016


On Fri, 2016-11-18 at 15:22 +0100, Cédric Le Goater wrote:
> Only the first nic, but the second shouldn't be too complex to add if
> needed.
> 
> Signed-off-by: Cédric Le Goater <clg at kaod.org>

Reviewed-by: Andrew Jeffery <andrew at aj.id.au>

> ---
>  hw/arm/aspeed_soc.c         | 21 +++++++++++++++++++++
>  include/hw/arm/aspeed_soc.h |  2 ++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
> index 06c1f03555b1..f3c41509a4ea 100644
> --- a/hw/arm/aspeed_soc.c
> +++ b/hw/arm/aspeed_soc.c
> @@ -19,6 +19,7 @@
>  #include "hw/char/serial.h"
>  #include "qemu/log.h"
>  #include "hw/i2c/aspeed_i2c.h"
> +#include "net/net.h"
>  
>  #define ASPEED_SOC_UART_5_BASE      0x00184000
>  #define ASPEED_SOC_IOMEM_SIZE       0x00200000
> @@ -33,6 +34,8 @@
>  #define ASPEED_SOC_TIMER_BASE       0x1E782000
>  #define ASPEED_SOC_WDT_BASE         0x1E785000
>  #define ASPEED_SOC_I2C_BASE         0x1E78A000
> +#define ASPEED_SOC_ETH1_BASE        0x1E660000
> +#define ASPEED_SOC_ETH2_BASE        0x1E680000
>  
>  static const int uart_irqs[] = { 9, 32, 33, 34, 10 };
>  static const int timer_irqs[] = { 16, 17, 18, 35, 36, 37, 38, 39, };
> @@ -175,6 +178,10 @@ static void aspeed_soc_init(Object *obj)
>      qdev_set_parent_bus(DEVICE(&s->wdt), sysbus_get_default());
>      object_property_add_const_link(OBJECT(&s->wdt), "scu", OBJECT(&s->scu),
>                                     NULL);
> +
> +    object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100);
> +    object_property_add_child(obj, "ftgmac100", OBJECT(&s->ftgmac100), NULL);
> +    qdev_set_parent_bus(DEVICE(&s->ftgmac100), sysbus_get_default());
>  }
>  
>  static int aspeed_fmc_get_cs(AspeedSoCState *s, Error **errp)
> @@ -344,6 +351,20 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
>          return;
>      }
>      sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, ASPEED_SOC_WDT_BASE);
> +
> +    /* Net */
> +    qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
> +    object_property_set_bool(OBJECT(&s->ftgmac100), true, "aspeed", &err);
> +    object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized",
> +                             &local_err);
> +    error_propagate(&err, local_err);
> +    if (err) {
> +        error_propagate(errp, err);
> +        return;
> +    }
> +    sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, ASPEED_SOC_ETH1_BASE);
> +    sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
> +                       qdev_get_gpio_in(DEVICE(&s->vic), 2));
>  }
>  
>  static void aspeed_soc_class_init(ObjectClass *oc, void *data)
> diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
> index dbec0c159885..1fd0dc690be1 100644
> --- a/include/hw/arm/aspeed_soc.h
> +++ b/include/hw/arm/aspeed_soc.h
> @@ -20,6 +20,7 @@
>  #include "hw/i2c/aspeed_i2c.h"
>  #include "hw/ssi/aspeed_smc.h"
>  #include "hw/watchdog/wdt_aspeed.h"
> +#include "hw/net/ftgmac100.h"
>  
>  #define ASPEED_SPIS_NUM  2
>  
> @@ -39,6 +40,7 @@ typedef struct AspeedSoCState {
>      AspeedSMCState spi[ASPEED_SPIS_NUM];
>      AspeedSDMCState sdmc;
>      AspeedWDTState wdt;
> +    Ftgmac100State ftgmac100;
>  } AspeedSoCState;
>  
>  #define TYPE_ASPEED_SOC "aspeed-soc"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20161128/c44d00b3/attachment.sig>


More information about the openbmc mailing list