svn commit: r262519 - head/sys/dev/etherswitch/arswitch

Adrian Chadd adrian at FreeBSD.org
Wed Feb 26 02:00:37 UTC 2014


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));


More information about the svn-src-all mailing list