Am 23.04.2015 um 14:43 schrieb Christian Mehlis:
> Am 22.04.2015 um 19:01 schrieb Heiner Kallweit:
>> Can you provide a complete dmesg output?
> 
> Bootlog is available here:
> http://wiki.openwrt.org/toh/compex/wpj344#openwrt_upstream_bootlog
> 
> Dmesg is attached.
> 
>> W/o having seen the datasheets for AR8337/AR8334 I'm hesitant to propose a 
>> patch.
>> 1. AR8334 identifies itself as AR8337/rev.2. There might be a real 
>> AR8337/rev.2 with 7 ports. How to tell between these two chips?
> 
> Perhaps there are some other registers where the number of ports are 
> available? But I don't have any datasheets to look into...
> 
> Best
> Christian

This patch tries to identify an AR8334/AR8335 by checking for non-existent PHYs.
I have systems with AR8327 only, the patch doesn't do any harm on them at least.
Could you please test this patch and provide the dmesg output?

Rgds, Heiner

---
 target/linux/generic/files/drivers/net/phy/ar8216.c |  8 ++++----
 target/linux/generic/files/drivers/net/phy/ar8216.h | 21 +++++++++++++++++++--
 target/linux/generic/files/drivers/net/phy/ar8327.c | 17 ++++++++++++++---
 3 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c 
b/target/linux/generic/files/drivers/net/phy/ar8216.c
index e39d540..25bbfc2 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -38,7 +38,7 @@
 #include "ar8216.h"
 
 extern const struct ar8xxx_chip ar8327_chip;
-extern const struct ar8xxx_chip ar8337_chip;
+extern const struct ar8xxx_chip ar833x_chip;
 
 #define AR8XXX_MIB_WORK_DELAY  2000 /* msecs */
 
@@ -1576,8 +1576,8 @@ ar8xxx_id_chip(struct ar8xxx_priv *priv)
        case AR8XXX_VER_AR8327:
                priv->chip = &ar8327_chip;
                break;
-       case AR8XXX_VER_AR8337:
-               priv->chip = &ar8337_chip;
+       case AR8XXX_VER_AR833X:
+               priv->chip = &ar833x_chip;
                break;
        default:
                pr_err("ar8216: Unknown Atheros device [ver=%d, rev=%d]\n",
@@ -1856,7 +1856,7 @@ ar8xxx_phy_config_aneg(struct phy_device *phydev)
 static const u32 ar8xxx_phy_ids[] = {
        0x004dd033,
        0x004dd034, /* AR8327 */
-       0x004dd036, /* AR8337 */
+       0x004dd036, /* AR833X */
        0x004dd041,
        0x004dd042,
        0x004dd043, /* AR8236 */
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h 
b/target/linux/generic/files/drivers/net/phy/ar8216.h
index 0f53f23..a50fb9d 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.h
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.h
@@ -334,7 +334,7 @@ enum {
        AR8XXX_VER_AR8236 = 0x03,
        AR8XXX_VER_AR8316 = 0x10,
        AR8XXX_VER_AR8327 = 0x12,
-       AR8XXX_VER_AR8337 = 0x13,
+       AR8XXX_VER_AR833X = 0x13,
 };
 
 #define AR8XXX_NUM_ARL_RECORDS 100
@@ -409,6 +409,8 @@ struct ar8xxx_priv {
        void *chip_data;
        bool initialized;
        bool port4_phy;
+       bool unavailable_phys[AR8XXX_NUM_PHYS];
+       int num_unavailable_phys;
        char buf[2048];
        struct arl_entry arl_table[AR8XXX_NUM_ARL_RECORDS];
        char arl_buf[AR8XXX_NUM_ARL_RECORDS * 32 + 256];
@@ -562,9 +564,24 @@ static inline bool chip_is_ar8327(struct ar8xxx_priv *priv)
        return priv->chip_ver == AR8XXX_VER_AR8327;
 }
 
+static inline bool chip_is_ar833x(struct ar8xxx_priv *priv)
+{
+       return priv->chip_ver == AR8XXX_VER_AR833X;
+}
+
+static inline bool chip_is_ar8334(struct ar8xxx_priv *priv)
+{
+       return chip_is_ar833x(priv) && priv->num_unavailable_phys == 3;
+}
+
+static inline bool chip_is_ar8335(struct ar8xxx_priv *priv)
+{
+       return chip_is_ar833x(priv) && priv->num_unavailable_phys == 2;
+}
+
 static inline bool chip_is_ar8337(struct ar8xxx_priv *priv)
 {
-       return priv->chip_ver == AR8XXX_VER_AR8337;
+       return chip_is_ar833x(priv) && priv->num_unavailable_phys == 0;
 }
 
 static inline void
diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c 
b/target/linux/generic/files/drivers/net/phy/ar8327.c
index 07e837e..a25372f 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8327.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8327.c
@@ -620,7 +620,18 @@ ar8327_hw_config_of(struct ar8xxx_priv *priv, struct 
device_node *np)
 static int
 ar8327_hw_init(struct ar8xxx_priv *priv)
 {
-       int ret;
+       int i, ret;
+
+       for (i = 0; i < AR8XXX_NUM_PHYS; i++)
+               /* certain bits are always set if the PHY exists */
+               if (!mdiobus_read(priv->mii_bus, i, MII_BMSR)) {
+                       priv->unavailable_phys[i] = true;
+                       priv->num_unavailable_phys++;
+                       dev_info(&priv->phy->dev, "PHY %d not available\n", i);
+               }
+       if (chip_is_ar833x(priv))
+                dev_info(&priv->phy->dev, "Detected AR833%d switch\n",
+                         AR8327_NUM_PORTS - priv->num_unavailable_phys);
 
        priv->chip_data = kzalloc(sizeof(struct ar8327_data), GFP_KERNEL);
        if (!priv->chip_data)
@@ -1201,12 +1212,12 @@ const struct ar8xxx_chip ar8327_chip = {
        .mib_func = AR8327_REG_MIB_FUNC
 };
 
-const struct ar8xxx_chip ar8337_chip = {
+const struct ar8xxx_chip ar833x_chip = {
        .caps = AR8XXX_CAP_GIGE | AR8XXX_CAP_MIB_COUNTERS,
        .config_at_probe = true,
        .mii_lo_first = true,
 
-       .name = "Atheros AR8337",
+       .name = "Atheros AR833X",
        .ports = AR8327_NUM_PORTS,
        .vlans = AR8X16_MAX_VLANS,
        .swops = &ar8327_sw_ops,
-- 
2.3.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to