From patchwork Mon Apr 27 18:56:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 465201 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 D7C4214007D for ; Tue, 28 Apr 2015 04:56:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=yIcUuAQP; 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 78E10280226; Mon, 27 Apr 2015 20:55:35 +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 252DB280192 for ; Mon, 27 Apr 2015 20:55:29 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 27 Apr 2015 20:55:27 +0200 (CEST) Received: by wief7 with SMTP id f7so56598wie.0 for ; Mon, 27 Apr 2015 11:56:26 -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=BzL6Pku7ghXYKF/FIseMKqAz/Vu4QlI3kVhqOCYyME0=; b=yIcUuAQP+BKebGC1ZzXobmUv5kdBC9N9RmOpX321QuSTrO9YXqwi3eyakwNAmpXAwT jmKJbicTPBvqu2/P00Jhsatj+Bug5FClU7Otw6PKijYljb4JBRvZQTTONCHVZ+E116g1 PjIcu5iuLz27rkrHRsoxSKraZ9PIkcz+O2FVgfB3ZioHizFfyPbYLO+1IHfHz7yDhx94 bnprYRgXuiMhDqRcJ3RisRkeUbtk5avo7BB1xHdvjNi6zizAi6gOM6zl1tKlm+4M2OdO EKh8Yep1olEdG0eBDbo5SJ6Gz57Da67GF1ifDivAC9TQhKkhMGQpsaapKjnGdYCH+686 wPlw== X-Received: by 10.194.71.168 with SMTP id w8mr24391227wju.80.1430160986737; Mon, 27 Apr 2015 11:56:26 -0700 (PDT) Received: from ?IPv6:2003:62:5f15:1700:d900:faf5:92e1:4b7f? (p200300625F151700D900FAF592E14B7F.dip0.t-ipconnect.de. [2003:62:5f15:1700:d900:faf5:92e1:4b7f]) by mx.google.com with ESMTPSA id o6sm12795516wiz.24.2015.04.27.11.56.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 Apr 2015 11:56:25 -0700 (PDT) Message-ID: <553E8654.6000103@gmail.com> Date: Mon, 27 Apr 2015 20:56:20 +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> <553A85CD.7000003@gmail.com> <553E297E.10509@m3hlis.de> <553E5A0E.9000409@m3hlis.de> In-Reply-To: <553E5A0E.9000409@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 27.04.2015 um 17:47 schrieb Christian Mehlis: > Am 27.04.2015 um 15:06 schrieb Heiner Kallweit: >> Could you please provide te dmesg output of this patch version? > > [ 0.850000] switch0: Atheros AR833X rev. 2 switch registered on ag71xx-mdio.0 > [ 0.860000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 0 available, BMSR = 0x7949 > [ 0.870000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 1 available, BMSR = 0x7949 > [ 0.870000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 2 available, BMSR = 0x7969 > [ 0.880000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 3 available, BMSR = 0x7949 > [ 0.890000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 4 available, BMSR = 0x7949 > [ 0.900000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 5 available, BMSR = 0xffff > [ 0.910000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: PHY 6 available, BMSR = 0xffff > [ 0.920000] Atheros AR8216/AR8236/AR8316 ag71xx-mdio.0:00: Detected AR8337 switch > > Best > Christian > Thanks for testing. Seems like PHY's 0, 3 and 4 are there but just not connected to any pin on the chip. So we have to look for something else to tell a 8334 from a 8337. The only other difference I found is the initial setting of LED_CTRL3 register. Could you please test the following patch (first remove the initial patch attempt)? Rgds, Heiner PS: I have no datasheet for AR8335 and don't know how LED_CTRL3 is set initially on this chip. Therefore AR8335 might not work correctly. However no router with this chip is known yet. --- target/linux/generic/files/drivers/net/phy/ar8216.h | 13 ++++++++++++- target/linux/generic/files/drivers/net/phy/ar8327.c | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h b/target/linux/generic/files/drivers/net/phy/ar8216.h index 0f53f23..a23c3be 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.h +++ b/target/linux/generic/files/drivers/net/phy/ar8216.h @@ -405,6 +405,7 @@ struct ar8xxx_priv { struct mutex reg_mutex; u8 chip_ver; u8 chip_rev; + u8 chip_subver; const struct ar8xxx_chip *chip; void *chip_data; bool initialized; @@ -562,11 +563,21 @@ static inline bool chip_is_ar8327(struct ar8xxx_priv *priv) return priv->chip_ver == AR8XXX_VER_AR8327; } -static inline bool chip_is_ar8337(struct ar8xxx_priv *priv) +static inline bool chip_is_ar833x(struct ar8xxx_priv *priv) { return priv->chip_ver == AR8XXX_VER_AR8337; } +static inline bool chip_is_ar8334(struct ar8xxx_priv *priv) +{ + return chip_is_ar833x(priv) && priv->chip_subver == 4; +} + +static inline bool chip_is_ar8337(struct ar8xxx_priv *priv) +{ + return chip_is_ar833x(priv) && priv->chip_subver == 7; +} + static inline void ar8xxx_reg_set(struct ar8xxx_priv *priv, int reg, u32 val) { diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c b/target/linux/generic/files/drivers/net/phy/ar8327.c index 07e837e..96f3378 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8327.c +++ b/target/linux/generic/files/drivers/net/phy/ar8327.c @@ -621,6 +621,22 @@ static int ar8327_hw_init(struct ar8xxx_priv *priv) { int ret; + u32 led_val; + + if (chip_is_ar833x(priv)) { + led_val = ar8xxx_read(priv, AR8327_REG_LED_CTRL3); + /* + * no default LED pattern is set for PHY 1 on AR8334 + * this code might not work correctly on AR8335 + */ + led_val = (led_val & BITS(8, 6)) >> 8; + dev_info(&priv->phy->dev, "led_val = %x\n", led_val); + if (led_val) + priv->chip_subver = 7; + else + priv->chip_subver = 4; + dev_info(&priv->phy->dev, "Detected AR833%d\n", priv->chip_subver); + } priv->chip_data = kzalloc(sizeof(struct ar8327_data), GFP_KERNEL); if (!priv->chip_data) @@ -1206,7 +1222,7 @@ const struct ar8xxx_chip ar8337_chip = { .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,