Skip to content

Commit

Permalink
hw/arm/xlnx-versal-virt: modify gem/phy DT nodes
Browse files Browse the repository at this point in the history
Modify the gem/phy device tree nodes so that VxWorks
properly binds the genericPhy driver to the ethernet-phy
DT node. Previously, the phy was represented using a
fixed-link node that VxWorks does not parse properly.

The compatible string for the gem node has been modified
from "cdns,zynqmp-gem" to "cdns,versal-gem". The VxWorks
gem driver does not match "cdns,zynqmp-gem".

Note: VxWorks needs additional property "phy-mode" to
properly bind the driver against "cdns,versal-gem".

Signed-off-by: Nelson Ho <[email protected]>
  • Loading branch information
ho28 committed Sep 17, 2024
1 parent 4c9e68e commit 9f9f05a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 10 additions & 7 deletions hw/arm/xlnx-versal-virt.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,31 +276,34 @@ static void fdt_add_canfd_nodes(VersalVirt *s)
}
}

static void fdt_add_fixed_link_nodes(VersalVirt *s, char *gemname,
uint32_t phandle)
static void fdt_add_generic_phy_node(VersalVirt *s, char *gemname,
uint64_t phy_id, uint32_t phandle)
{
char *name = g_strdup_printf("%s/fixed-link", gemname);
char *name = g_strdup_printf("%s/ethernet-phy@%" PRIx64, gemname, phy_id);
const char compat_phy[] = "genericPhy";

qemu_fdt_add_subnode(s->fdt, name);
qemu_fdt_setprop_cell(s->fdt, name, "phandle", phandle);
qemu_fdt_setprop(s->fdt, name, "full-duplex", NULL, 0);
qemu_fdt_setprop_cell(s->fdt, name, "speed", 1000);
qemu_fdt_setprop_cell(s->fdt, name, "reg", phy_id);
qemu_fdt_setprop(s->fdt, name, "compatible",
compat_phy, sizeof(compat_phy));
g_free(name);
}

static void fdt_add_gem_nodes(VersalVirt *s)
{
uint64_t addrs[] = { MM_GEM1, MM_GEM0 };
uint64_t phy_ids[] = { MM_GEM0_PHY_ID, MM_GEM1_PHY_ID };
unsigned int irqs[] = { VERSAL_GEM1_IRQ_0, VERSAL_GEM0_IRQ_0 };
const char clocknames[] = "pclk\0hclk\0tx_clk\0rx_clk";
const char compat_gem[] = "cdns,zynqmp-gem\0cdns,gem";
const char compat_gem[] = "cdns,versal-gem\0cdns,gem";
int i;

for (i = 0; i < ARRAY_SIZE(addrs); i++) {
char *name = g_strdup_printf("/ethernet@%" PRIx64, addrs[i]);
qemu_fdt_add_subnode(s->fdt, name);

fdt_add_fixed_link_nodes(s, name, s->phandle.ethernet_phy[i]);
fdt_add_generic_phy_node(s, name, phy_ids[i], s->phandle.ethernet_phy[i]);
qemu_fdt_setprop_string(s->fdt, name, "phy-mode", "rgmii-id");
qemu_fdt_setprop_cell(s->fdt, name, "phy-handle",
s->phandle.ethernet_phy[i]);
Expand Down
2 changes: 2 additions & 0 deletions include/hw/arm/xlnx-versal.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ struct Versal {

#define MM_GEM0 0xff0c0000U
#define MM_GEM0_SIZE 0x10000
#define MM_GEM0_PHY_ID 0xc
#define MM_GEM1 0xff0d0000U
#define MM_GEM1_SIZE 0x10000
#define MM_GEM1_PHY_ID 0xd

#define MM_ADMA_CH0 0xffa80000U
#define MM_ADMA_CH0_SIZE 0x10000
Expand Down

0 comments on commit 9f9f05a

Please sign in to comment.