On Sun, Dec 03, 2017 at 10:28:02PM +1100, Jonathan Gray wrote: > On Wed, Nov 29, 2017 at 11:32:24AM +0200, Artturi Alm wrote: > > On Wed, Nov 29, 2017 at 12:37:23AM +1100, Jonathan Gray wrote: > > > On Sun, Nov 26, 2017 at 06:52:42PM +0200, Artturi Alm wrote: > > > > Hi, > > > > > > > > unless i failed w/grep, only 4 boards with dts in u-boot/linux need > > > > this, > > > > but i've got one of those, so this would be much appreciated:) > > > > > > > > -Artturi > > > > > > This seems reasonable and there is no non-panic error path > > > there currently to add a regulator_disable() call to. > > > > > > Changing the variable name to phy_supply would match the existing > > > code in sys/dev/fdt. > > > > > > > Like this? > > > > -Artturi > > Yes, but I don't see how this can work with the current dtbs. > > sxie only matches "allwinner,sun4i-a10-emac" so you have one > of the following? > > sun4i-a10-a1000.dtb "Mele A1000" > sun4i-a10-hackberry.dtb "Miniand Hackberry" > sun4i-a10-jesurun-q5.dtb "Jesurun Q5" > > ethernet@1c0b000 { > compatible = "allwinner,sun4i-a10-emac"; > reg = <0x01c0b000 0x00001000>; > interrupts = <0x00000037>; > clocks = <0x00000002 0x0000002a>; > allwinner,sram = <0x0000000b 0x00000001>; > pinctrl-names = "default"; > pinctrl-0 = <0x0000000c>; > status = "okay"; > phy = <0x0000000d>; > }; > mdio@1c0b080 { > compatible = "allwinner,sun4i-a10-mdio"; > reg = <0x01c0b080 0x00000014>; > status = "okay"; > #address-cells = <0x00000001>; > #size-cells = <0x00000000>; > phy-supply = <0x0000000e>; > ethernet-phy@0 { > reg = <0x00000000>; > linux,phandle = <0x0000000d>; > phandle = <0x0000000d>; > }; > }; > > compared to the a20 gmac dwge(4) use > > ethernet@1c50000 { > compatible = "allwinner,sun7i-a20-gmac"; > reg = <0x01c50000 0x00010000>; > interrupts = <0x00000000 0x00000055 0x00000004>; > interrupt-names = "macirq"; > clocks = <0x00000002 0x00000042 0x00000026>; > clock-names = "stmmaceth", "allwinner_gmac_tx"; > snps,pbl = <0x00000002>; > snps,fixed-burst; > snps,force_sf_dma_mode; > status = "okay"; > #address-cells = <0x00000001>; > #size-cells = <0x00000000>; > pinctrl-names = "default"; > pinctrl-0 = <0x00000027>; > phy = <0x00000028>; > phy-mode = "rgmii"; > phy-supply = <0x00000029>; > ethernet-phy@1 { > reg = <0x00000001>; > linux,phandle = <0x00000028>; > phandle = <0x00000028>; > }; > }; > > > > > > > diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c > > index 116fda5f8d7..41c378a7ef7 100644 > > --- a/sys/arch/armv7/sunxi/sxie.c > > +++ b/sys/arch/armv7/sunxi/sxie.c > > @@ -51,6 +51,7 @@ > > #include <dev/ofw/openfirm.h> > > #include <dev/ofw/ofw_clock.h> > > #include <dev/ofw/ofw_pinctrl.h> > > +#include <dev/ofw/ofw_regulator.h> > > #include <dev/ofw/fdt.h> > > > > /* configuration registers */ > > @@ -212,6 +213,7 @@ sxie_attach(struct device *parent, struct device *self, > > void *aux) > > struct fdt_attach_args *faa = aux; > > struct mii_data *mii; > > struct ifnet *ifp; > > + int phy_supply; > > int s; > > > > if (faa->fa_nreg < 1) > > @@ -230,6 +232,11 @@ sxie_attach(struct device *parent, struct device > > *self, void *aux) > > > > clock_enable_all(faa->fa_node); > > > > + /* Power up PHY. */ > > + phy_supply = OF_getpropint(faa->fa_node, "phy-supply", 0); > > + if (phy_supply) > > + regulator_enable(phy_supply); > > + > > sxie_socware_init(sc); > > sc->txf_inuse = 0; > > > >
diff below for what i essentially went with to get it working. thanks in advance:) -Artturi diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index 116fda5f8d7..e7bc6d6b9fd 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -51,6 +51,7 @@ #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_clock.h> #include <dev/ofw/ofw_pinctrl.h> +#include <dev/ofw/ofw_regulator.h> #include <dev/ofw/fdt.h> /* configuration registers */ @@ -212,6 +213,7 @@ sxie_attach(struct device *parent, struct device *self, void *aux) struct fdt_attach_args *faa = aux; struct mii_data *mii; struct ifnet *ifp; + int node, phy_supply, phy = MII_PHY_ANY; int s; if (faa->fa_nreg < 1) @@ -230,6 +232,18 @@ sxie_attach(struct device *parent, struct device *self, void *aux) clock_enable_all(faa->fa_node); + /* Lookup PHY. */ + node = OF_getnodebyphandle(OF_getpropint(faa->fa_node, "phy", 0)); + if (node) { + phy = OF_getpropint(node, "reg", MII_PHY_ANY); + + /* Power up PHY. */ + phy_supply = OF_getpropint(OF_parent(node), "phy-supply", 0); + if (phy_supply) + regulator_enable(phy_supply); + } + sc->sc_phyno = phy == MII_PHY_ANY ? 1 : phy; + sxie_socware_init(sc); sc->txf_inuse = 0; @@ -260,7 +274,7 @@ sxie_attach(struct device *parent, struct device *self, void *aux) mii->mii_statchg = sxie_miibus_statchg; ifmedia_init(&mii->mii_media, 0, sxie_ifm_change, sxie_ifm_status); - mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0); + mii_attach(self, mii, 0xffffffff, phy, MII_OFFSET_ANY, 0); if (LIST_FIRST(&mii->mii_phys) == NULL) { ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL); @@ -320,8 +334,6 @@ sxie_socware_init(struct sxie_softc *sc) if (!have_mac) ether_fakeaddr(&sc->sc_ac.ac_if); - - sc->sc_phyno = 1; } void