From patchwork Wed Apr 29 17:41:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 466209 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 E81B91402D0 for ; Thu, 30 Apr 2015 03:42:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=ugW4RROU; 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 007FD2803CC; Wed, 29 Apr 2015 19:41:11 +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 B24A228AE02 for ; Wed, 29 Apr 2015 19:41:05 +0200 (CEST) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Wed, 29 Apr 2015 19:41:05 +0200 (CEST) Received: by wgen6 with SMTP id n6so36413989wge.3 for ; Wed, 29 Apr 2015 10:42: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 :content-type:content-transfer-encoding; bh=YLr10GE+P4NVG1UVcnwXhbU5E2jYhNqeytpY9RdDing=; b=ugW4RROUl3liopROdqws6ocyr4N1jR29g3zJmiV8HplKuCr3j7Sq7e3A11GPaqDyqE v0MWPdEkY9bc6OyaR6XRgoPuVgibWfflJog3vpwjez8Rfi3+xTfblQq42QWznQ0fdNWD pIAwqdvzWQ0yCb95woqUF+ZWbp4AilFDailO6zkpz08pG2+0gdEy3oSwchZwDyz46f3G piItqbRx4kWlF2kt5zQWrzyVgG9P90mcKeYH38qCKr8n4yV/ud8CS/oI10q8YZv/nfM7 jCiLT5a+emnHOzvBqq0/+mnzcoq8ZId9DvTOLMuDVj/oJA61Yqxqr/2S8o5qTVo4J8vE yRkw== X-Received: by 10.194.5.103 with SMTP id r7mr359221wjr.47.1430329327661; Wed, 29 Apr 2015 10:42:07 -0700 (PDT) Received: from ?IPv6:2003:62:5f15:1700:2d27:eac9:2f4b:c739? (p200300625F1517002D27EAC92F4BC739.dip0.t-ipconnect.de. [2003:62:5f15:1700:2d27:eac9:2f4b:c739]) by mx.google.com with ESMTPSA id ub1sm39971734wjc.43.2015.04.29.10.42.06 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2015 10:42:07 -0700 (PDT) Message-ID: <554117E7.2090303@gmail.com> Date: Wed, 29 Apr 2015 19:41:59 +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: Felix Fietkau Cc: OpenWrt Development List Subject: [OpenWrt-Devel] [PATCH] ar8216: Fix problem with AR8337 MAC swap handling 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" AR8337 supports a configuration bit to swap MAC0 and MAC6. Currently this is set in general if an AR8337 is detected and causes issues with devices using an AR8334 (internally an AR8337, just less chip pins). And it might even cause issues with AR8337-based devices with different board designs. Swapping the MAC's however isn't needed for AR8337 in general. It's just needed in case of certain board designs (affected devices seem to be based on Atheros reference board AP135/136-010). Therefore this configuration bit should be moved to platform data. The patch includes the needed changes to the device initialization code of affected devices. Hopefully I didn't miss any .. Signed-off-by: Heiner Kallweit --- target/linux/ar71xx/files/arch/mips/ath79/mach-esr1750.c | 1 + target/linux/ar71xx/files/arch/mips/ath79/mach-f9k1115v2.c | 1 + target/linux/ar71xx/files/arch/mips/ath79/mach-nbg6716.c | 1 + target/linux/ar71xx/files/arch/mips/ath79/mach-wlr8100.c | 1 + target/linux/generic/files/drivers/net/phy/ar8327.c | 6 +++--- target/linux/generic/files/include/linux/ar8216_platform.h | 4 +++- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-esr1750.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-esr1750.c index 2a34b3a..d2bc177 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-esr1750.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-esr1750.c @@ -97,6 +97,7 @@ static struct ar8327_pad_cfg esr1750_ar8327_pad0_cfg = { .rxclk_delay_en = true, .txclk_delay_sel = AR8327_CLK_DELAY_SEL2, .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2, + .mac06_exchange_en = true, }; static struct ar8327_platform_data esr1750_ar8327_data = { diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-f9k1115v2.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-f9k1115v2.c index 69d005d..9e86e9a 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-f9k1115v2.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-f9k1115v2.c @@ -98,6 +98,7 @@ static struct ar8327_pad_cfg f9k1115v2_ar8327_pad0_cfg = { .rxclk_delay_en = true, .txclk_delay_sel = AR8327_CLK_DELAY_SEL1, .rxclk_delay_sel = AR8327_CLK_DELAY_SEL2, + .mac06_exchange_en = true, }; static struct ar8327_pad_cfg f9k1115v2_ar8327_pad6_cfg = { diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-nbg6716.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-nbg6716.c index 0ca2e56..69a73cc 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-nbg6716.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-nbg6716.c @@ -251,6 +251,7 @@ static void __init nbg6716_010_setup(void) nbg6716_ar8327_pad0_cfg.rxclk_delay_en = true; nbg6716_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1; nbg6716_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2; + nbg6716_ar8327_pad0_cfg.mac06_exchange_en = true; /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */ nbg6716_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII; diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wlr8100.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wlr8100.c index 88022e7..6a90c6e 100644 --- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wlr8100.c +++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wlr8100.c @@ -186,6 +186,7 @@ static void __init wlr8100_010_setup(void) wlr8100_ar8327_pad0_cfg.rxclk_delay_en = true; wlr8100_ar8327_pad0_cfg.txclk_delay_sel = AR8327_CLK_DELAY_SEL1; wlr8100_ar8327_pad0_cfg.rxclk_delay_sel = AR8327_CLK_DELAY_SEL2; + wlr8100_ar8327_pad0_cfg.mac06_exchange_en = true; /* GMAC6 of the AR8337 switch is connected to GMAC1 via SGMII */ wlr8100_ar8327_pad6_cfg.mode = AR8327_PAD_MAC_SGMII; diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c b/target/linux/generic/files/drivers/net/phy/ar8327.c index 07e837e..a6dd7d8 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8327.c +++ b/target/linux/generic/files/drivers/net/phy/ar8327.c @@ -124,6 +124,9 @@ ar8327_get_pad_cfg(struct ar8327_pad_cfg *cfg) break; } + if (cfg->mac06_exchange_en) + t |= AR8337_PAD_MAC06_EXCHANGE_EN; + return t; } @@ -508,9 +511,6 @@ ar8327_hw_config_pdata(struct ar8xxx_priv *priv, data->port6_status = ar8327_get_port_init_status(&pdata->port6_cfg); t = ar8327_get_pad_cfg(pdata->pad0_cfg); - if (chip_is_ar8337(priv)) - t |= AR8337_PAD_MAC06_EXCHANGE_EN; - ar8xxx_write(priv, AR8327_REG_PAD0_MODE, t); t = ar8327_get_pad_cfg(pdata->pad5_cfg); ar8xxx_write(priv, AR8327_REG_PAD5_MODE, t); diff --git a/target/linux/generic/files/include/linux/ar8216_platform.h b/target/linux/generic/files/include/linux/ar8216_platform.h index 4935ad3..d70f11a 100644 --- a/target/linux/generic/files/include/linux/ar8216_platform.h +++ b/target/linux/generic/files/include/linux/ar8216_platform.h @@ -47,6 +47,7 @@ struct ar8327_pad_cfg { bool sgmii_delay_en; enum ar8327_clk_delay_sel txclk_delay_sel; enum ar8327_clk_delay_sel rxclk_delay_sel; + bool mac06_exchange_en; }; enum ar8327_port_speed { @@ -128,4 +129,5 @@ struct ar8327_platform_data { const struct ar8327_led_info *leds; }; -#endif /* AR8216_PLATFORM_H */ \ No newline at end of file +#endif /* AR8216_PLATFORM_H */ +