From owner-svn-src-head@FreeBSD.ORG Wed Feb 26 01:46:42 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B1705B26; Wed, 26 Feb 2014 01:46:42 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 81B1515DA; Wed, 26 Feb 2014 01:46:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1Q1kgnc030714; Wed, 26 Feb 2014 01:46:42 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1Q1kg7V030713; Wed, 26 Feb 2014 01:46:42 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201402260146.s1Q1kg7V030713@svn.freebsd.org> From: Adrian Chadd Date: Wed, 26 Feb 2014 01:46:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262517 - head/sys/dev/etherswitch/arswitch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Feb 2014 01:46:42 -0000 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); }