[PATCH qemu 12/12] ast2400: add a FTGMAC100 nic

Cédric Le Goater clg at kaod.org
Mon May 30 07:20:05 AEST 2016


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>
---
 hw/arm/ast2400.c         | 18 ++++++++++++++++++
 include/hw/arm/ast2400.h |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/hw/arm/ast2400.c b/hw/arm/ast2400.c
index a4a7c10e4361..67ae91f5f977 100644
--- a/hw/arm/ast2400.c
+++ b/hw/arm/ast2400.c
@@ -19,6 +19,7 @@
 #include "hw/char/serial.h"
 #include "hw/boards.h"
 #include "hw/i2c/aspeed_i2c.h"
+#include "net/net.h"
 
 #define AST2400_UART_5_BASE      0x00184000
 #define AST2400_IOMEM_SIZE       0x00200000
@@ -32,6 +33,8 @@
 #define AST2400_LPC_BASE         0x1E789000
 #define AST2400_IBT_BASE         (AST2400_LPC_BASE + 0x140)
 #define AST2400_I2C_BASE         0x1E78A000
+#define AST2400_ETH1_BASE        0x1E660000
+#define AST2400_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, };
@@ -95,6 +98,10 @@ static void ast2400_init(Object *obj)
     object_initialize(&s->bt, sizeof(s->bt), TYPE_ASPEED_BT);
     object_property_add_child(obj, "bt", OBJECT(&s->bt), NULL);
     qdev_set_parent_bus(DEVICE(&s->bt), sysbus_get_default());
+
+    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 void ast2400_realize(DeviceState *dev, Error **errp)
@@ -221,6 +228,17 @@ static void ast2400_realize(DeviceState *dev, Error **errp)
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->bt), 0, AST2400_IBT_BASE);
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->bt), 0,
                        qdev_get_gpio_in(DEVICE(&s->vic), 10));
+
+    /* Net */
+    qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
+    object_property_set_bool(OBJECT(&s->ftgmac100), true, "realized", &err);
+    if (err) {
+        error_propagate(errp, err);
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->ftgmac100), 0, AST2400_ETH1_BASE);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->ftgmac100), 0,
+                       qdev_get_gpio_in(DEVICE(&s->vic), 2));
 }
 
 static void ast2400_class_init(ObjectClass *oc, void *data)
diff --git a/include/hw/arm/ast2400.h b/include/hw/arm/ast2400.h
index 2b517e89eeea..bb221734c7b1 100644
--- a/include/hw/arm/ast2400.h
+++ b/include/hw/arm/ast2400.h
@@ -19,6 +19,7 @@
 #include "hw/i2c/aspeed_i2c.h"
 #include "hw/ssi/aspeed_smc.h"
 #include "hw/misc/aspeed_bt.h"
+#include "hw/net/ftgmac100.h"
 
 typedef struct AST2400State {
     /*< private >*/
@@ -35,6 +36,7 @@ typedef struct AST2400State {
     AspeedSMCState smc;
     AspeedSMCState spi;
     AspeedBTState bt;
+    Ftgmac100State ftgmac100;
 } AST2400State;
 
 #define TYPE_AST2400 "ast2400"
-- 
2.1.4



More information about the openbmc mailing list