Author: adrian
Date: Wed Feb 26 01:46:42 2014
New Revision: 262517
URL: http://svnweb.freebsd.org/changeset/base/262517

Log:
  Add in the SGMII configuration code.  The DB120 doesn't use it, so I
  have no way to evaluate it.
  
  Obtained from:        OpenWRT

Modified:
  head/sys/dev/etherswitch/arswitch/arswitch_8327.c

Modified: head/sys/dev/etherswitch/arswitch/arswitch_8327.c
==============================================================================
--- head/sys/dev/etherswitch/arswitch/arswitch_8327.c   Wed Feb 26 01:36:02 
2014        (r262516)
+++ head/sys/dev/etherswitch/arswitch/arswitch_8327.c   Wed Feb 26 01:46:42 
2014        (r262517)
@@ -407,6 +407,34 @@ ar8327_fetch_pdata_pad(struct arswitch_s
 }
 
 /*
+ * Fetch the SGMII configuration block from the boot hints.
+ */
+static int
+ar8327_fetch_pdata_sgmii(struct arswitch_softc *sc,
+    struct ar8327_sgmii_cfg *scfg)
+{
+       int val;
+
+       /* sgmii_ctrl */
+       val = 0;
+       if (resource_int_value(device_get_name(sc->sc_dev),
+           device_get_unit(sc->sc_dev),
+           "sgmii.ctrl", &val) != 0)
+               return (0);
+       scfg->sgmii_ctrl = val;
+
+       /* serdes_aen */
+       val = 0;
+       if (resource_int_value(device_get_name(sc->sc_dev),
+           device_get_unit(sc->sc_dev),
+           "sgmii.serdes_aen", &val) != 0)
+               return (0);
+       scfg->serdes_aen = val;
+
+       return (1);
+}
+
+/*
  * Initialise the ar8327 specific hardware features from
  * the hints provided in the boot environment.
  */
@@ -415,7 +443,8 @@ ar8327_init_pdata(struct arswitch_softc 
 {
        struct ar8327_pad_cfg pc;
        struct ar8327_port_cfg port_cfg;
-       uint32_t t;
+       struct ar8327_sgmii_cfg scfg;
+       uint32_t t, new_pos, pos;
 
        /* Port 0 */
        bzero(&port_cfg, sizeof(port_cfg));
@@ -454,9 +483,33 @@ ar8327_init_pdata(struct arswitch_softc 
                t = ar8327_get_pad_cfg(&pc);
        arswitch_writereg(sc->sc_dev, AR8327_REG_PAD6_MODE, t);
 
+       pos = arswitch_readreg(sc->sc_dev, AR8327_REG_POWER_ON_STRIP);
+       new_pos = pos;
+
        /* XXX LED config */
 
-       /* XXX SGMII config */
+       /* SGMII config */
+       bzero(&scfg, sizeof(scfg));
+       if (ar8327_fetch_pdata_sgmii(sc, &scfg)) {
+               t = scfg.sgmii_ctrl;
+               if (sc->chip_rev == 1)
+                       t |= AR8327_SGMII_CTRL_EN_PLL |
+                           AR8327_SGMII_CTRL_EN_RX |
+                           AR8327_SGMII_CTRL_EN_TX;
+               else
+                       t &= ~(AR8327_SGMII_CTRL_EN_PLL |
+                           AR8327_SGMII_CTRL_EN_RX |
+                           AR8327_SGMII_CTRL_EN_TX);
+
+               arswitch_writereg(sc->sc_dev, AR8327_REG_SGMII_CTRL, t);
+
+               if (scfg.serdes_aen)
+                       new_pos &= ~AR8327_POWER_ON_STRIP_SERDES_AEN;
+               else
+                       new_pos |= AR8327_POWER_ON_STRIP_SERDES_AEN;
+       }
+
+       arswitch_writereg(sc->sc_dev, AR8327_REG_POWER_ON_STRIP, new_pos);
 
        return (0);
 }
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to