Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch The ETSEC on the P1025 has been moved/split so the ...
details: https://anonhg.NetBSD.org/src/rev/e99cb54064fa
branches: trunk
changeset: 780229:e99cb54064fa
user: matt <matt%NetBSD.org@localhost>
date: Tue Jul 17 01:36:12 2012 +0000
description:
The ETSEC on the P1025 has been moved/split so the MDIO stayed in the same
place but each ETSEC has been split into two virtual halves (G0 and G1) and
each one has a new different base address.
For some reason, tsec1 connects to phy 2 and tsec2 connects to phy 1.
Adjust config file to match
diffstat:
sys/arch/evbppc/conf/TWRP1025 | 8 +-
sys/arch/evbppc/mpc85xx/machdep.c | 50 +++++++++++++++-
sys/arch/powerpc/booke/dev/pq3etsec.c | 93 ++++++++++++++++++++++++++----
sys/arch/powerpc/include/booke/e500reg.h | 8 ++-
sys/arch/powerpc/include/booke/etsecreg.h | 3 +-
5 files changed, 137 insertions(+), 25 deletions(-)
diffs (truncated from 340 to 300 lines):
diff -r 03eae71719d4 -r e99cb54064fa sys/arch/evbppc/conf/TWRP1025
--- a/sys/arch/evbppc/conf/TWRP1025 Mon Jul 16 18:19:04 2012 +0000
+++ b/sys/arch/evbppc/conf/TWRP1025 Tue Jul 17 01:36:12 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: TWRP1025,v 1.1 2012/07/15 08:44:56 matt Exp $
+# $NetBSD: TWRP1025,v 1.2 2012/07/17 01:36:12 matt Exp $
#
# TWRP1025 -- everything that's currently supported
#
@@ -7,7 +7,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-ident "TWRP1025-$Revision: 1.1 $"
+ident "TWRP1025-$Revision: 1.2 $"
maxusers 32
@@ -167,8 +167,8 @@
com* at duart? port ?
options CONSADDR="DUART1_BASE"
-tsec0 at cpunode? flags 0x002 # Enhanced 3-Speed Ethernet Controller
-tsec1 at cpunode? flags 0x103 # Enhanced 3-Speed Ethernet Controller
+tsec0 at cpunode? instance 1 flags 0x003 # Enhanced 3-Speed Ethernet Controller
+tsec1 at cpunode? instance 3 flags 0x102 # Enhanced 3-Speed Ethernet Controller
ukphy* at mii?
#options ETSEC_EVENT_COUNTERS
diff -r 03eae71719d4 -r e99cb54064fa sys/arch/evbppc/mpc85xx/machdep.c
--- a/sys/arch/evbppc/mpc85xx/machdep.c Mon Jul 16 18:19:04 2012 +0000
+++ b/sys/arch/evbppc/mpc85xx/machdep.c Tue Jul 17 01:36:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.25 2012/07/15 08:44:56 matt Exp $ */
+/* $NetBSD: machdep.c,v 1.26 2012/07/17 01:36:12 matt Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -221,9 +221,23 @@
1 + ilog2(DEVDISR_DUART) },
{ "tsec", ETSEC1_BASE, ETSEC_SIZE, 1,
3, { ISOURCE_ETSEC1_TX, ISOURCE_ETSEC1_RX, ISOURCE_ETSEC1_ERR },
- 1 + ilog2(DEVDISR_TSEC1) },
+ 1 + ilog2(DEVDISR_TSEC1),
+ { 0xffff, SVR_P1025v1 >> 16 } },
+#if defined(P1025)
+ { "tsec", ETSEC1_G0_BASE, ETSEC_SIZE, 1,
+ 3, { ISOURCE_ETSEC1_TX, ISOURCE_ETSEC1_RX, ISOURCE_ETSEC1_ERR },
+ 1 + ilog2(DEVDISR_TSEC1),
+ { SVR_P1025v1 >> 16 } },
+#if 0
+ { "tsec", ETSEC1_G1_BASE, ETSEC_SIZE, 1,
+ 3, { ISOURCE_ETSEC1_G1_TX, ISOURCE_ETSEC1_G1_RX,
+ ISOURCE_ETSEC1_G1_ERR },
+ 1 + ilog2(DEVDISR_TSEC1),
+ { SVR_P1025v1 >> 16 } },
+#endif
+#endif
#if defined(MPC8548) || defined(MPC8555) || defined(MPC8572) \
- || defined(P2020) || defined(P1025)
+ || defined(P2020)
{ "tsec", ETSEC2_BASE, ETSEC_SIZE, 2,
3, { ISOURCE_ETSEC2_TX, ISOURCE_ETSEC2_RX, ISOURCE_ETSEC2_ERR },
1 + ilog2(DEVDISR_TSEC2),
@@ -231,18 +245,44 @@
SVR_MPC8572v1 >> 16, SVR_P2020v2 >> 16,
SVR_P1025v1 >> 16 } },
#endif
+#if defined(P1025)
+ { "tsec", ETSEC2_G0_BASE, ETSEC_SIZE, 2,
+ 3, { ISOURCE_ETSEC2_TX, ISOURCE_ETSEC2_RX, ISOURCE_ETSEC2_ERR },
+ 1 + ilog2(DEVDISR_TSEC2),
+ { SVR_P1025v1 >> 16 } },
+#if 0
+ { "tsec", ETSEC2_G1_BASE, ETSEC_SIZE, 5,
+ 3, { ISOURCE_ETSEC2_G1_TX, ISOURCE_ETSEC2_G1_RX,
+ ISOURCE_ETSEC2_G1_ERR },
+ 1 + ilog2(DEVDISR_TSEC2),
+ { SVR_P1025v1 >> 16 } },
+#endif
+#endif
#if defined(MPC8544) || defined(MPC8536)
{ "tsec", ETSEC3_BASE, ETSEC_SIZE, 2,
3, { ISOURCE_ETSEC3_TX, ISOURCE_ETSEC3_RX, ISOURCE_ETSEC3_ERR },
1 + ilog2(DEVDISR_TSEC3),
{ SVR_MPC8536v1 >> 16, SVR_MPC8544v1 >> 16 } },
#endif
-#if defined(MPC8548) || defined(MPC8572) || defined(P1025) || defined(P2020)
+#if defined(MPC8548) || defined(MPC8572) || defined(P2020)
{ "tsec", ETSEC3_BASE, ETSEC_SIZE, 3,
3, { ISOURCE_ETSEC3_TX, ISOURCE_ETSEC3_RX, ISOURCE_ETSEC3_ERR },
1 + ilog2(DEVDISR_TSEC3),
{ SVR_MPC8548v1 >> 16, SVR_MPC8572v1 >> 16,
- SVR_P2020v2 >> 16, SVR_P1025v1 >> 16 } },
+ SVR_P2020v2 >> 16 } },
+#endif
+#if defined(P1025)
+ { "tsec", ETSEC3_G0_BASE, ETSEC_SIZE, 3,
+ 3, { ISOURCE_ETSEC3_TX, ISOURCE_ETSEC3_RX, ISOURCE_ETSEC3_ERR },
+ 1 + ilog2(DEVDISR_TSEC3),
+ { SVR_P1025v1 >> 16 } },
+#if 0
+ { "tsec", ETSEC3_G1_BASE, ETSEC_SIZE, 3,
+ 3, { ISOURCE_ETSEC3_G1_TX, ISOURCE_ETSEC3_G1_RX,
+ ISOURCE_ETSEC3_G1_ERR },
+ 1 + ilog2(DEVDISR_TSEC3),
+ { SVR_P1025v1 >> 16 } },
+#endif
#endif
#if defined(MPC8548) || defined(MPC8572)
{ "tsec", ETSEC4_BASE, ETSEC_SIZE, 4,
diff -r 03eae71719d4 -r e99cb54064fa sys/arch/powerpc/booke/dev/pq3etsec.c
--- a/sys/arch/powerpc/booke/dev/pq3etsec.c Mon Jul 16 18:19:04 2012 +0000
+++ b/sys/arch/powerpc/booke/dev/pq3etsec.c Tue Jul 17 01:36:12 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pq3etsec.c,v 1.14 2012/07/15 08:44:56 matt Exp $ */
+/* $NetBSD: pq3etsec.c,v 1.15 2012/07/17 01:36:13 matt Exp $ */
/*-
* Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -35,10 +35,11 @@
*/
#include "opt_inet.h"
+#include "opt_mpc85xx.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.14 2012/07/15 08:44:56 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pq3etsec.c,v 1.15 2012/07/17 01:36:13 matt Exp $");
#include <sys/param.h>
#include <sys/cpu.h>
@@ -170,6 +171,7 @@
struct mii_data sc_mii;
bus_space_tag_t sc_bst;
bus_space_handle_t sc_bsh;
+ bus_space_handle_t sc_mdio_bsh;
bus_dma_tag_t sc_dmat;
int sc_phy_addr;
prop_dictionary_t sc_intrmap;
@@ -303,6 +305,18 @@
bus_space_write_4(sc->sc_bst, sc->sc_bsh, off, data);
}
+static inline uint32_t
+etsec_mdio_read(struct pq3etsec_softc *sc, bus_size_t off)
+{
+ return bus_space_read_4(sc->sc_bst, sc->sc_mdio_bsh, off);
+}
+
+static inline void
+etsec_mdio_write(struct pq3etsec_softc *sc, bus_size_t off, uint32_t data)
+{
+ bus_space_write_4(sc->sc_bst, sc->sc_mdio_bsh, off, data);
+}
+
static int
pq3etsec_mii_readreg(device_t self, int phy, int reg)
{
@@ -311,24 +325,24 @@
// int s = splnet();
- etsec_write(sc, MIIMADD,
+ etsec_mdio_write(sc, MIIMADD,
__SHIFTIN(phy, MIIMADD_PHY) | __SHIFTIN(reg, MIIMADD_REG));
etsec_write(sc, IEVENT, IEVENT_MMRD);
- etsec_write(sc, MIIMCOM, 0); /* clear any past bits */
- etsec_write(sc, MIIMCOM, MIIMCOM_READ);
+ etsec_mdio_write(sc, MIIMCOM, 0); /* clear any past bits */
+ etsec_mdio_write(sc, MIIMCOM, MIIMCOM_READ);
#if 0
sc->sc_imask |= IEVENT_MMRD;
etsec_write(sc, IMASK, sc->sc_imask);
#endif
- while (etsec_read(sc, MIIMIND) != 0) {
+ while (etsec_mdio_read(sc, MIIMIND) != 0) {
delay(1);
}
- int data = etsec_read(sc, MIIMSTAT);
+ int data = etsec_mdio_read(sc, MIIMSTAT);
if (miimcom == MIIMCOM_SCAN)
- etsec_write(sc, MIIMCOM, miimcom);
+ etsec_mdio_write(sc, MIIMCOM, miimcom);
#if 0
aprint_normal_dev(sc->sc_dev, "%s: phy %d reg %d: %#x\n",
@@ -343,7 +357,7 @@
pq3etsec_mii_writereg(device_t self, int phy, int reg, int data)
{
struct pq3etsec_softc * const sc = device_private(self);
- uint32_t miimcom = etsec_read(sc, MIIMCOM);
+ uint32_t miimcom = etsec_mdio_read(sc, MIIMCOM);
#if 0
aprint_normal_dev(sc->sc_dev, "%s: phy %d reg %d: %#x\n",
@@ -352,10 +366,10 @@
// int s = splnet();
etsec_write(sc, IEVENT, IEVENT_MMWR);
- etsec_write(sc, MIIMADD,
+ etsec_mdio_write(sc, MIIMADD,
__SHIFTIN(phy, MIIMADD_PHY) | __SHIFTIN(reg, MIIMADD_REG));
- etsec_write(sc, MIIMCOM, 0); /* clear any past bits */
- etsec_write(sc, MIIMCON, data);
+ etsec_mdio_write(sc, MIIMCOM, 0); /* clear any past bits */
+ etsec_mdio_write(sc, MIIMCON, data);
#if 0
sc->sc_imask |= IEVENT_MMWR;
@@ -363,12 +377,12 @@
#endif
int timo = 1000; /* 1ms */
- while ((etsec_read(sc, MIIMIND) & MIIMIND_BUSY) && --timo > 0) {
+ while ((etsec_mdio_read(sc, MIIMIND) & MIIMIND_BUSY) && --timo > 0) {
delay(1);
}
if (miimcom == MIIMCOM_SCAN)
- etsec_write(sc, MIIMCOM, miimcom);
+ etsec_mdio_write(sc, MIIMCOM, miimcom);
etsec_write(sc, IEVENT, IEVENT_MMWR);
// splx(s);
}
@@ -453,6 +467,50 @@
}
#endif
+
+static const struct {
+ bus_addr_t reg_base;
+ bus_addr_t mdio_base;
+} etsec_mdio_map[] = {
+ { ETSEC1_BASE, ETSEC1_BASE },
+ { ETSEC2_BASE, ETSEC2_BASE },
+ { ETSEC3_BASE, ETSEC3_BASE },
+ { ETSEC4_BASE, ETSEC4_BASE },
+#if defined(P1025)
+ { ETSEC1_G0_BASE, ETSEC1_BASE },
+ { ETSEC1_G1_BASE, ETSEC1_BASE },
+ { ETSEC2_G0_BASE, ETSEC2_BASE },
+ { ETSEC2_G1_BASE, ETSEC2_BASE },
+ { ETSEC3_G0_BASE, ETSEC3_BASE },
+ { ETSEC3_G1_BASE, ETSEC3_BASE },
+#endif
+};
+
+static bool
+pq3etsec_mdio_map(struct pq3etsec_softc *sc, bus_addr_t reg_base,
+ bus_addr_t *mdio_basep)
+{
+ *mdio_basep = 0;
+ for (size_t i = 0; i < __arraycount(etsec_mdio_map); i++) {
+ if (etsec_mdio_map[i].reg_base == reg_base) {
+ bus_addr_t mdio_base = etsec_mdio_map[i].mdio_base;
+ if (mdio_base == reg_base) {
+ sc->sc_mdio_bsh = sc->sc_bsh;
+ return true;
+ }
+ if (!bus_space_map(sc->sc_bst,
+ mdio_base,
+ ETSEC_SIZE, 0, &sc->sc_mdio_bsh)) {
+ return true;
+ }
+ *mdio_basep = mdio_base;
+ break;
+ }
+ }
+
+ return false;
+}
+
static void
pq3etsec_attach(device_t parent, device_t self, void *aux)
{
@@ -462,6 +520,7 @@
struct cpunode_locators * const cnl = &cna->cna_locs;
cfdata_t cf = device_cfdata(self);
int error;
+ bus_addr_t mdio_base;
psc->sc_children |= cna->cna_childmask;
sc->sc_dev = self;
@@ -494,6 +553,12 @@
return;
}
+ if (!pq3etsec_mdio_map(sc, cnl->cnl_addr, &mdio_base)) {
+ aprint_error(": error mapping mdio registers @ %#x\n",
+ mdio_base);
+ return;
+ }
+
/*
* Assume firmware has aready set the mac address and fetch it
Home |
Main Index |
Thread Index |
Old Index