From owner-svn-src-head@FreeBSD.ORG Wed Feb 26 02:00:37 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 DB3EF73C; Wed, 26 Feb 2014 02:00:37 +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 ACC5E18ED; Wed, 26 Feb 2014 02:00:37 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1Q20bL2035252; Wed, 26 Feb 2014 02:00:37 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1Q20bMB035251; Wed, 26 Feb 2014 02:00:37 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201402260200.s1Q20bMB035251@svn.freebsd.org> From: Adrian Chadd Date: Wed, 26 Feb 2014 02:00:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262519 - 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 02:00:37 -0000 Author: adrian Date: Wed Feb 26 02:00:37 2014 New Revision: 262519 URL: http://svnweb.freebsd.org/changeset/base/262519 Log: Add LED setup support for the AR8327. Tested: * DB120 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:57:55 2014 (r262518) +++ head/sys/dev/etherswitch/arswitch/arswitch_8327.c Wed Feb 26 02:00:37 2014 (r262519) @@ -435,6 +435,53 @@ ar8327_fetch_pdata_sgmii(struct arswitch } /* + * Fetch the LED configuration from the boot hints. + */ +static int +ar8327_fetch_pdata_led(struct arswitch_softc *sc, + struct ar8327_led_cfg *lcfg) +{ + int val; + + val = 0; + if (resource_int_value(device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev), + "led.ctrl0", &val) != 0) + return (0); + lcfg->led_ctrl0 = val; + + val = 0; + if (resource_int_value(device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev), + "led.ctrl1", &val) != 0) + return (0); + lcfg->led_ctrl1 = val; + + val = 0; + if (resource_int_value(device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev), + "led.ctrl2", &val) != 0) + return (0); + lcfg->led_ctrl2 = val; + + val = 0; + if (resource_int_value(device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev), + "led.ctrl3", &val) != 0) + return (0); + lcfg->led_ctrl3 = val; + + val = 0; + if (resource_int_value(device_get_name(sc->sc_dev), + device_get_unit(sc->sc_dev), + "led.open_drain", &val) != 0) + return (0); + lcfg->open_drain = val; + + return (1); +} + +/* * Initialise the ar8327 specific hardware features from * the hints provided in the boot environment. */ @@ -444,6 +491,7 @@ ar8327_init_pdata(struct arswitch_softc struct ar8327_pad_cfg pc; struct ar8327_port_cfg port_cfg; struct ar8327_sgmii_cfg scfg; + struct ar8327_led_cfg lcfg; uint32_t t, new_pos, pos; /* Port 0 */ @@ -487,6 +535,25 @@ ar8327_init_pdata(struct arswitch_softc new_pos = pos; /* XXX LED config */ + bzero(&lcfg, sizeof(lcfg)); + if (ar8327_fetch_pdata_led(sc, &lcfg)) { + if (lcfg.open_drain) + new_pos |= AR8327_POWER_ON_STRIP_LED_OPEN_EN; + else + new_pos &= ~AR8327_POWER_ON_STRIP_LED_OPEN_EN; + + arswitch_writereg(sc->sc_dev, AR8327_REG_LED_CTRL0, + lcfg.led_ctrl0); + arswitch_writereg(sc->sc_dev, AR8327_REG_LED_CTRL1, + lcfg.led_ctrl1); + arswitch_writereg(sc->sc_dev, AR8327_REG_LED_CTRL2, + lcfg.led_ctrl2); + arswitch_writereg(sc->sc_dev, AR8327_REG_LED_CTRL3, + lcfg.led_ctrl3); + + if (new_pos != pos) + new_pos |= AR8327_POWER_ON_STRIP_POWER_ON_SEL; + } /* SGMII config */ bzero(&scfg, sizeof(scfg));