generic: ar8216: allow to configure AR8327 LEDs via platform data
authorGabor Juhos <juhosg@openwrt.org>
Tue, 19 Jun 2012 10:44:16 +0000 (10:44 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Tue, 19 Jun 2012 10:44:16 +0000 (10:44 +0000)
SVN-Revision: 32456

target/linux/generic/files/drivers/net/phy/ar8216.c
target/linux/generic/files/drivers/net/phy/ar8216.h
target/linux/generic/files/include/linux/ar8216_platform.h

index 97ce04720c0b4b2e775b286c66a289b85dc0bf50..698d92dd7d334c77359f21d42bc85867edaf03c4 100644 (file)
@@ -733,6 +733,8 @@ static int
 ar8327_hw_init(struct ar8216_priv *priv)
 {
        struct ar8327_platform_data *pdata;
+       struct ar8327_led_cfg *led_cfg;
+       u32 pos, new_pos;
        u32 t;
        int i;
 
@@ -747,7 +749,26 @@ ar8327_hw_init(struct ar8216_priv *priv)
        t = ar8327_get_pad_cfg(pdata->pad6_cfg);
        priv->write(priv, AR8327_REG_PAD6_MODE, t);
 
-       priv->write(priv, AR8327_REG_POWER_ON_STRIP, 0x40000000);
+       pos = priv->read(priv, AR8327_REG_POWER_ON_STRIP);
+       new_pos = pos;
+
+       led_cfg = pdata->led_cfg;
+       if (led_cfg) {
+               if (led_cfg->open_drain)
+                       new_pos |= AR8327_POWER_ON_STRIP_LED_OPEN_EN;
+               else
+                       new_pos &= ~AR8327_POWER_ON_STRIP_LED_OPEN_EN;
+
+               priv->write(priv, AR8327_REG_LED_CTRL0, led_cfg->led_ctrl0);
+               priv->write(priv, AR8327_REG_LED_CTRL1, led_cfg->led_ctrl1);
+               priv->write(priv, AR8327_REG_LED_CTRL2, led_cfg->led_ctrl2);
+               priv->write(priv, AR8327_REG_LED_CTRL3, led_cfg->led_ctrl3);
+       }
+
+       if (new_pos != pos) {
+               new_pos |= AR8327_POWER_ON_STRIP_POWER_ON_SEL;
+               priv->write(priv, AR8327_REG_POWER_ON_STRIP, new_pos);
+       }
 
        for (i = 0; i < AR8327_NUM_PHYS; i++)
                ar8327_phy_fixup(priv, i);
index c9b5e9f579e859c9df23a77077a526972163ed51..8948c52054160908022bb92b3913fba659ab960e 100644 (file)
 #define   AR8327_PAD_RGMII_EN                  BIT(26)
 
 #define AR8327_REG_POWER_ON_STRIP              0x010
+#define   AR8327_POWER_ON_STRIP_POWER_ON_SEL   BIT(31)
+#define   AR8327_POWER_ON_STRIP_LED_OPEN_EN    BIT(24)
 
 #define AR8327_REG_INT_STATUS0                 0x020
 #define   AR8327_INT0_VT_DONE                  BIT(20)
index 1ecb6e5bf248fed9fdf64cee6c34da9207d467ea..f5c2ef065f6a4154671171ece6ece50ef2b6bf37 100644 (file)
@@ -62,11 +62,20 @@ struct ar8327_port_cfg {
        int duplex:1;
 };
 
+struct ar8327_led_cfg {
+       u32 led_ctrl0;
+       u32 led_ctrl1;
+       u32 led_ctrl2;
+       u32 led_ctrl3;
+       bool open_drain;
+};
+
 struct ar8327_platform_data {
        struct ar8327_pad_cfg *pad0_cfg;
        struct ar8327_pad_cfg *pad5_cfg;
        struct ar8327_pad_cfg *pad6_cfg;
        struct ar8327_port_cfg cpuport_cfg;
+       struct ar8327_led_cfg *led_cfg;
 };
 
 #endif /* AR8216_PLATFORM_H */
\ No newline at end of file