[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/20] hw/rx/rx62n: Add Ethernet support.
From: |
Yoshinori Sato |
Subject: |
[PATCH 17/20] hw/rx/rx62n: Add Ethernet support. |
Date: |
Thu, 27 Aug 2020 21:38:56 +0900 |
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
include/hw/rx/rx62n.h | 3 +++
hw/rx/rx62n.c | 26 ++++++++++++++++++++++++++
hw/rx/Kconfig | 3 ++-
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/include/hw/rx/rx62n.h b/include/hw/rx/rx62n.h
index 170c8cb6fc..4f11ca3fd9 100644
--- a/include/hw/rx/rx62n.h
+++ b/include/hw/rx/rx62n.h
@@ -30,6 +30,7 @@
#include "hw/timer/renesas_timer.h"
#include "hw/timer/renesas_mtu.h"
#include "hw/char/renesas_sci.h"
+#include "hw/net/renesas_eth.h"
#include "hw/rx/rx62n-cpg.h"
#include "qemu/units.h"
@@ -74,6 +75,8 @@ typedef struct RX62NState {
RenesasCMTState cmt[RX62N_NR_CMT];
RenesasMTU2State mtu[RX62N_NR_MTU];
RSCIAState sci[RX62N_NR_SCI];
+ RenesasEthState ether;
+ MDIOState *mdio;
RX62NCPGState cpg;
MemoryRegion *sysmem;
diff --git a/hw/rx/rx62n.c b/hw/rx/rx62n.c
index 344be846bc..8b41cdf90c 100644
--- a/hw/rx/rx62n.c
+++ b/hw/rx/rx62n.c
@@ -28,6 +28,7 @@
#include "hw/loader.h"
#include "hw/sysbus.h"
#include "hw/qdev-properties.h"
+#include "hw/net/mdio.h"
#include "sysemu/sysemu.h"
#include "sysemu/qtest.h"
#include "cpu.h"
@@ -48,6 +49,8 @@
#define RX62N_CMT_BASE 0x00088000
#define RX62N_MTU_BASE 0x00088600
#define RX62N_SCI_BASE 0x00088240
+#define RX62N_EDMAC_BASE 0x000c0000
+#define RX62N_ETHER_BASE 0x000c0100
#define RX62N_CPG_BASE 0x00080010
/*
@@ -58,6 +61,7 @@
#define RX62N_CMT_IRQ 28
#define RX62N_MTU_IRQ 114
#define RX62N_SCI_IRQ 214
+#define RX62N_EDMAC_IRQ 32
/*
* IRQ -> IPR mapping table
@@ -236,6 +240,25 @@ static void register_sci(RX62NState *s, int unit)
qdev_get_clock_out(DEVICE(&s->cpg), ckname));
}
+static void register_eth(RX62NState *s, NICInfo *nd)
+{
+ SysBusDevice *etherc;
+
+ qemu_check_nic_model(nd, TYPE_RENESAS_ETH);
+ object_initialize_child(OBJECT(s), "ether",
+ &s->ether, TYPE_RENESAS_ETH);
+ etherc = SYS_BUS_DEVICE(&s->ether);
+ qdev_set_nic_properties(DEVICE(etherc), nd);
+ object_property_set_link(OBJECT(etherc), "mdio",
+ OBJECT(s->mdio), &error_abort);
+ sysbus_realize(etherc, &error_abort);
+ sysbus_connect_irq(etherc, 0, s->irq[RX62N_EDMAC_IRQ]);
+ sysbus_mmio_map(etherc, 0, RX62N_ETHER_BASE);
+ sysbus_mmio_map(etherc, 1, RX62N_EDMAC_BASE);
+ qdev_connect_clock_in(DEVICE(etherc), "ick",
+ qdev_get_clock_out(DEVICE(&s->cpg), "ick_edmac"));
+}
+
static void register_cpg(RX62NState *s)
{
SysBusDevice *cpg;
@@ -277,6 +300,7 @@ static void rx62n_realize(DeviceState *dev, Error **errp)
register_mtu(s, 0);
register_mtu(s, 1);
register_sci(s, 0);
+ register_eth(s, nd_table);
sysbus_realize(SYS_BUS_DEVICE(&s->cpg), &error_abort);
}
@@ -284,6 +308,8 @@ static Property rx62n_properties[] = {
DEFINE_PROP_LINK("main-bus", RX62NState, sysmem, TYPE_MEMORY_REGION,
MemoryRegion *),
DEFINE_PROP_UINT32("xtal-frequency-hz", RX62NState, xtal_freq_hz, 0),
+ DEFINE_PROP_LINK("mdiodev", RX62NState, mdio, TYPE_ETHER_MDIO_BB,
+ MDIOState *),
DEFINE_PROP_END_OF_LIST(),
};
diff --git a/hw/rx/Kconfig b/hw/rx/Kconfig
index 887a5782bb..f20ea63fd9 100644
--- a/hw/rx/Kconfig
+++ b/hw/rx/Kconfig
@@ -3,8 +3,9 @@ config RX62N_MCU
select RX_ICU
select RENESAS_TMR8
select RENESAS_TIMER
- select RENESAS_SCI
select RENESAS_MTU
+ select RENESAS_SCI
+ select RENESAS_ETH
config RX_GDBSIM
bool
--
2.20.1
- [PATCH 00/20] RX target update, Yoshinori Sato, 2020/08/27
- [PATCH 03/20] hw/rx: Firmware and kernel loader., Yoshinori Sato, 2020/08/27
- [PATCH 02/20] include/elf.h: Add EM_RX., Yoshinori Sato, 2020/08/27
- [PATCH 07/20] hw/rx: RX62N convert new 8bit timer., Yoshinori Sato, 2020/08/27
- [PATCH 09/20] hw/timer: Remove renesas_cmt., Yoshinori Sato, 2020/08/27
- [PATCH 01/20] loader.c: Add support Motrola S-record format., Yoshinori Sato, 2020/08/27
- [PATCH 10/20] hw/rx: Convert to renesas_timer, Yoshinori Sato, 2020/08/27
- [PATCH 17/20] hw/rx/rx62n: Add Ethernet support.,
Yoshinori Sato <=
- [PATCH 08/20] hw/timer: Renesas TMU/CMT module., Yoshinori Sato, 2020/08/27
- [PATCH 04/20] hw/rx: New firmware loader., Yoshinori Sato, 2020/08/27
- [PATCH 05/20] hw/rx: Add RX62N Clock generator, Yoshinori Sato, 2020/08/27
- [PATCH 06/20] hw/timer: Renesas 8bit timer emulation., Yoshinori Sato, 2020/08/27
- [PATCH 19/20] hw/rx: Add CQ-FRK-RX62N target, Yoshinori Sato, 2020/08/27
- [PATCH 14/20] hw/rx/rx62n: RX62N Add MTU module, Yoshinori Sato, 2020/08/27
- [PATCH 13/20] hw/timer: Add Renesas MTU2, Yoshinori Sato, 2020/08/27
- [PATCH 16/20] hw/net: Add Renesas On-chip Ethernet MAC, Yoshinori Sato, 2020/08/27
- [PATCH 18/20] hw/rx: Add Tokudenkairo TKDN-RX62N-BRD, Yoshinori Sato, 2020/08/27
- [PATCH 11/20] hw/char: Renesas SCI module., Yoshinori Sato, 2020/08/27