From patchwork Fri Apr 24 18:05:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 464354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2393E14011B for ; Sat, 25 Apr 2015 04:05:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=exHA/qPE; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id EBBCF28022B; Fri, 24 Apr 2015 20:04:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, T_DKIM_INVALID autolearn=no version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 991012801B5 for ; Fri, 24 Apr 2015 20:04:08 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Fri, 24 Apr 2015 20:04:07 +0200 (CEST) Received: by wgyo15 with SMTP id o15so58640758wgy.2 for ; Fri, 24 Apr 2015 11:05:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=w46iq3eEOVA87nGxfS9k/JoOEN94mLGlJKfcjixxXas=; b=exHA/qPEPx0eqbOsv/NkKw6kwHnMd7Za+2CwOaTFTGWLH2TIqGEihdkkQ1aNBZgw+u X2LzZgHuScKJYpU7oTRidaIAVfuk2u2FWFuxDqBPvG1tKuhwy+1UBlzkBkeIIr8P9DMC Vy7qcC2KE13OKVXnAHQLWB8C/j4n8Rts78iD7mOlqFukS3XL5b5gjXPQFCAhJjaO3JhX qGLvJPZ6OF+PzzAUeNpD/QrzhOAjhMfA6Bk3ZCqPk3ueyMhAftt8b91XS2+kmKasMzmK QsH6LVfn3UlvFcstFvoTf2Ot76I2Xrr98IfmnFw9sxArZjLUtIxV4Ju8atGRgh6evbfN XawQ== X-Received: by 10.194.59.199 with SMTP id b7mr18232008wjr.26.1429898707547; Fri, 24 Apr 2015 11:05:07 -0700 (PDT) Received: from ?IPv6:2003:62:5f15:1700:5db4:179a:c70f:105c? (p200300625F1517005DB4179AC70F105C.dip0.t-ipconnect.de. [2003:62:5f15:1700:5db4:179a:c70f:105c]) by mx.google.com with ESMTPSA id pv2sm17882259wjc.33.2015.04.24.11.05.05 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Apr 2015 11:05:06 -0700 (PDT) Message-ID: <553A85CD.7000003@gmail.com> Date: Fri, 24 Apr 2015 20:05:01 +0200 From: Heiner Kallweit User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Christian Mehlis References: <553639D5.6090508@m3hlis.de> <553683AB.2030708@m3hlis.de> <5537D3D5.3070104@gmail.com> <5538E8E0.2030702@m3hlis.de> In-Reply-To: <5538E8E0.2030702@m3hlis.de> Cc: OpenWrt Development List Subject: Re: [OpenWrt-Devel] AR8334 switch support X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" 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,