diff options
author | 2013-09-16 20:52:13 +0000 | |
---|---|---|
committer | 2013-09-16 20:52:13 +0000 | |
commit | 8d5465ddd2fe30ba8bff20d5af2e82f64a58862d (patch) | |
tree | 0ac57abe1e4071591ad0ad59426a61374bd58fcd | |
parent | Drop the ipl locator from syscon attachments, and have the syscon children (diff) | |
download | wireguard-openbsd-8d5465ddd2fe30ba8bff20d5af2e82f64a58862d.tar.xz wireguard-openbsd-8d5465ddd2fe30ba8bff20d5af2e82f64a58862d.zip |
work out phy addresses before attaching cnmac and pass them to mii_attach
rather than hiding them in the mii read/write functions.
ok dlg@ jasper@ bcallah@
-rw-r--r-- | sys/arch/octeon/dev/cn30xxgmx.c | 22 | ||||
-rw-r--r-- | sys/arch/octeon/dev/cn30xxgmxvar.h | 3 | ||||
-rw-r--r-- | sys/arch/octeon/dev/if_cnmac.c | 34 | ||||
-rw-r--r-- | sys/arch/octeon/dev/if_cnmacvar.h | 3 |
4 files changed, 30 insertions, 32 deletions
diff --git a/sys/arch/octeon/dev/cn30xxgmx.c b/sys/arch/octeon/dev/cn30xxgmx.c index 8ace5384dd3..7c9dae16a10 100644 --- a/sys/arch/octeon/dev/cn30xxgmx.c +++ b/sys/arch/octeon/dev/cn30xxgmx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cn30xxgmx.c,v 1.5 2012/12/05 23:20:14 deraadt Exp $ */ +/* $OpenBSD: cn30xxgmx.c,v 1.6 2013/09/16 20:52:13 jmatthew Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -146,6 +146,15 @@ struct cn30xxgmx_port_ops *cn30xxgmx_port_ops[] = { [GMX_SPI42_PORT] = &cn30xxgmx_port_ops_spi42 }; +int octeon_eth_phy_table[] = { +#if defined __seil5__ + 0x04, 0x01, 0x02 +#else + /* portwell cam-0100 */ + 0x02, 0x03, 0x22 +#endif +}; + #ifdef OCTEON_ETH_DEBUG static void *cn30xxgmx_intr_drop_ih; struct evcnt cn30xxgmx_intr_drop_evcnt = @@ -178,6 +187,14 @@ cn30xxgmx_match(struct device *parent, void *match, void *aux) return 1; } +static int +cn30xxgmx_port_phy_addr(int port) +{ + if (port >= nitems(octeon_eth_phy_table)) + return -1; + return octeon_eth_phy_table[port]; +} + static void cn30xxgmx_attach(struct device *parent, struct device *self, void *aux) { @@ -223,6 +240,9 @@ cn30xxgmx_attach(struct device *parent, struct device *self, void *aux) gmx_aa.ga_port_type = sc->sc_port_types[i]; gmx_aa.ga_gmx = sc; gmx_aa.ga_gmx_port = port_sc; + gmx_aa.ga_phy_addr = cn30xxgmx_port_phy_addr(i); + if (gmx_aa.ga_phy_addr == -1) + panic(": don't know phy address for port %d", i); config_found_sm(self, &gmx_aa, cn30xxgmx_print, cn30xxgmx_submatch); diff --git a/sys/arch/octeon/dev/cn30xxgmxvar.h b/sys/arch/octeon/dev/cn30xxgmxvar.h index f21b8c70ccd..3dbb8e88e92 100644 --- a/sys/arch/octeon/dev/cn30xxgmxvar.h +++ b/sys/arch/octeon/dev/cn30xxgmxvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cn30xxgmxvar.h,v 1.1 2011/06/16 11:22:30 syuu Exp $ */ +/* $OpenBSD: cn30xxgmxvar.h,v 1.2 2013/09/16 20:52:14 jmatthew Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -136,6 +136,7 @@ struct cn30xxgmx_attach_args { const char *ga_name; int ga_portno; int ga_port_type; + int ga_phy_addr; struct cn30xxgmx_softc *ga_gmx; struct cn30xxgmx_port_softc diff --git a/sys/arch/octeon/dev/if_cnmac.c b/sys/arch/octeon/dev/if_cnmac.c index b9af934ae1d..e612856b22f 100644 --- a/sys/arch/octeon/dev/if_cnmac.c +++ b/sys/arch/octeon/dev/if_cnmac.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmac.c,v 1.11 2013/08/17 10:00:09 bluhm Exp $ */ +/* $OpenBSD: if_cnmac.c,v 1.12 2013/09/16 20:52:14 jmatthew Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -259,15 +259,6 @@ static const struct octeon_evcnt_entry octeon_evcnt_entries[] = { }; #endif -/* XXX board-specific */ -static const int octeon_eth_phy_table[] = { -#if defined __seil5__ - 0x04, 0x01, 0x02 -#else - 0x02, 0x03, 0x22 -#endif -}; - /* ---- buffer management */ static const struct octeon_eth_pool_param { @@ -338,6 +329,7 @@ octeon_eth_attach(struct device *parent, struct device *self, void *aux) sc->sc_port_type = ga->ga_port_type; sc->sc_gmx = ga->ga_gmx; sc->sc_gmx_port = ga->ga_gmx_port; + sc->sc_phy_addr = ga->ga_phy_addr; sc->sc_init_flag = 0; @@ -549,30 +541,14 @@ static int octeon_eth_mii_readreg(struct device *self, int phy_no, int reg) { struct octeon_eth_softc *sc = (struct octeon_eth_softc *)self; - int phy_addr = octeon_eth_phy_table[phy_no]; - - if (sc->sc_port >= (int)nitems(octeon_eth_phy_table) || - phy_no != sc->sc_port) { - log(LOG_ERR, - "mii read address mismatch, phy number %d.\n", phy_no); - return -1; - } - return cn30xxsmi_read(sc->sc_smi, phy_addr, reg); + return cn30xxsmi_read(sc->sc_smi, phy_no, reg); } static void octeon_eth_mii_writereg(struct device *self, int phy_no, int reg, int value) { struct octeon_eth_softc *sc = (struct octeon_eth_softc *)self; - int phy_addr = octeon_eth_phy_table[phy_no]; - - if (sc->sc_port >= (int)nitems(octeon_eth_phy_table) || - phy_no != sc->sc_port) { - log(LOG_ERR, - "mii write address mismatch, phy number %d.\n", phy_no); - return; - } - cn30xxsmi_write(sc->sc_smi, phy_addr, reg, value); + cn30xxsmi_write(sc->sc_smi, phy_no, reg, value); } static void @@ -606,7 +582,7 @@ octeon_eth_mediainit(struct octeon_eth_softc *sc) octeon_eth_mediastatus); mii_attach(&sc->sc_dev, &sc->sc_mii, - 0xffffffff, sc->sc_port, MII_OFFSET_ANY, MIIF_DOPAUSE); + 0xffffffff, sc->sc_phy_addr, MII_OFFSET_ANY, MIIF_DOPAUSE); /* XXX */ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL) { diff --git a/sys/arch/octeon/dev/if_cnmacvar.h b/sys/arch/octeon/dev/if_cnmacvar.h index 711bc2063b3..6b6fdf18523 100644 --- a/sys/arch/octeon/dev/if_cnmacvar.h +++ b/sys/arch/octeon/dev/if_cnmacvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cnmacvar.h,v 1.2 2011/06/17 03:36:25 yasuoka Exp $ */ +/* $OpenBSD: if_cnmacvar.h,v 1.3 2013/09/16 20:52:14 jmatthew Exp $ */ /* * Copyright (c) 2007 Internet Initiative Japan, Inc. @@ -90,6 +90,7 @@ struct octeon_eth_softc { uint32_t sc_port; uint32_t sc_port_type; uint32_t sc_init_flag; + int sc_phy_addr; /* * Redirection - received (input) packets are redirected (directly sent) |