[PATCH] m68k: add simple phy support to fec driver

From: Greg Ungerer
Date: Thu Jun 18 2015 - 09:27:13 EST


The Linux fec driver needs at least basic PHY support to probe and work.

This code adds a very simple set of register results for a fixed PHY
setup - very similar to that used on an m5208evb board.

Signed-off-by: Greg Ungerer <gerg@xxxxxxxxxxx>
---
hw/net/mcf_fec.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/hw/net/mcf_fec.c b/hw/net/mcf_fec.c
index 4bff3de..2df062f 100644
--- a/hw/net/mcf_fec.c
+++ b/hw/net/mcf_fec.c
@@ -216,6 +216,33 @@ static void mcf_fec_reset(mcf_fec_state *s)
s->rfsr = 0x500;
}

+#define MMFR_WRITE_OP (1 << 28)
+#define MMFR_READ_OP (2 << 28)
+#define MMFR_PHYADDR(v) (((v) >> 23) & 0x1f)
+#define MMFR_REGNUM(v) (((v) >> 18) & 0x1f)
+
+static uint64_t mcf_fec_read_mdio(mcf_fec_state *s)
+{
+ uint64_t v;
+
+ if (s->mmfr & MMFR_WRITE_OP)
+ return s->mmfr;
+ if (MMFR_PHYADDR(s->mmfr) != 1)
+ return s->mmfr |= 0xffff;
+
+ switch (MMFR_REGNUM(s->mmfr)) {
+ case 0x00: v = 0x3100; break;
+ case 0x01: v = 0x786d; break;
+ case 0x02: v = 0x2000; break;
+ case 0x03: v = 0x5c90; break;
+ case 0x04: v = 0x01e1; break;
+ case 0x05: v = 0xc1e1; break;
+ default: v = 0xffff ; break;
+ }
+ s->mmfr = (s->mmfr & ~0xffff) | v;
+ return s->mmfr;
+}
+
static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
unsigned size)
{
@@ -226,7 +253,7 @@ static uint64_t mcf_fec_read(void *opaque, hwaddr addr,
case 0x010: return s->rx_enabled ? (1 << 24) : 0; /* RDAR */
case 0x014: return 0; /* TDAR */
case 0x024: return s->ecr;
- case 0x040: return s->mmfr;
+ case 0x040: return mcf_fec_read_mdio(s);
case 0x044: return s->mscr;
case 0x064: return 0; /* MIBC */
case 0x084: return s->rcr;
@@ -287,8 +314,8 @@ static void mcf_fec_write(void *opaque, hwaddr addr,
}
break;
case 0x040:
- /* TODO: Implement MII. */
s->mmfr = value;
+ s->eir |= FEC_INT_MII;
break;
case 0x044:
s->mscr = value & 0xfe;
--
1.9.1


--------------040302080101060407020307--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/