From patchwork Mon May 28 17:47:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 921816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HPqfgn8X"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jOJwgk31"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40w30b3xNlz9s1B for ; Tue, 29 May 2018 15:57:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lH14IMLrLM/u63D1gkJohrPJQlhxvslxYzNY+EdnlOw=; b=HPqfgn8XJk/R79 Qq8o+G59UDz1cE5WQjFBlaUfzgKme5auMrJkyfLF9JHjecqopJFxV9PeywWm0tTRhDWyOdBRt17C6 BN/MMiMmeeD3Hq6HGZk2Og2PhCsDUhhrsklgvcdi3six9XqgYkAkL1+hBZZhkbfgRLTlxf6Es2nnH XrQl0j9SYbwI5FOR6qSgvcLMuIvGKRNSCerGxQSKqhOTsRfnJglKJy44ZfGhqY28EHSyj+7SDVRKQ hGM5XGIbVZFlqc2hhf0TgyDP4PDTgp8vZ2WWDnYOQH/uTMEW2ycN6jrif0Hq/y23SzEdFKq2rjxH0 TQm6fV9qIqD2AB+lbekg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNXdO-0008QX-UU; Tue, 29 May 2018 05:57:26 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNMJ8-0007yb-Rf for lede-dev@lists.infradead.org; Mon, 28 May 2018 17:51:48 +0000 Received: by mail-wr0-x244.google.com with SMTP id l41-v6so21468071wre.7 for ; Mon, 28 May 2018 10:51:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LNix/pWXG4cyMYYMCB5RmL4+QAwfG2Xg+mq/FukztZs=; b=jOJwgk31IlSN6pU0HnOznH6Dx6RBWcBUaMR7FrJRonDFEw7vAAZDkWR1uk1CcWaAFN B7D/7+KU22zFkKHDytARSRqmdyzokWNHzYm2J3IDBdIrvN6k4DTeRXjo2yTkxV50/FKY fpf6mOzRTxieiMgSS+mnB37VYiwixDGCaYbUk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LNix/pWXG4cyMYYMCB5RmL4+QAwfG2Xg+mq/FukztZs=; b=aiU0WlJhUokCbaaMyX0+/WkKRPiRWTvDmLuqsF4Sa6GfY/giABCoq7tuDbe2fenrfg HDyXi/e+2tsFTGd30NzFcNS+CS8HvQmFZvltrEI7iTA9Jm/1EcV6iMNSwQy4dAdJcZUn 0qwBlyqrHV7C+JXCQ6/GJR9RahrtQ4HdsiVozSTOM8q/CGSdJtl6hsK90S/QbYTsAkHB AM/VgaToj9YsTkbU5tF6bltsN5NNZXPt4e+JdUFRyLF9L4DsduSJfr/qhp6Y79xCrTPR kKXrbLmLpdrlxuvdl5+jzcXRKfamUaM1aw+YS7Y1L9WfSbSIfRW9kAvGI/1ejJb73eg4 1unA== X-Gm-Message-State: ALKqPweavX6TpqZcbJN26J6BdyRSIDf1Xzi395g87kLJhPqWWSS3UvrF z+n6RvQdsCRc3D10YtheyrTd5g== X-Google-Smtp-Source: ADUXVKKFqZeGOR+Paglmj47ybOfzrMySScaMTrizJfCF4GUZybZAdXVm8vvrxIMwGWpxChOc3CLfWQ== X-Received: by 2002:a19:c90d:: with SMTP id z13-v6mr5670860lff.0.1527529895182; Mon, 28 May 2018 10:51:35 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id p76-v6sm6913861lfp.44.2018.05.28.10.51.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 May 2018 10:51:33 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Date: Mon, 28 May 2018 19:47:49 +0200 Message-Id: <20180528174752.6806-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528174752.6806-1-linus.walleij@linaro.org> References: <20180528174752.6806-1-linus.walleij@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180528_105146_929772_7CF432AD X-CRM114-Status: GOOD ( 14.29 ) X-Spam-Score: 0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid X-Mailman-Approved-At: Mon, 28 May 2018 22:57:03 -0700 Subject: [OpenWrt-Devel] [PATCH 1/4 RFCv2] net: phy: realtek: Support RTL8366RB variant X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Yeryomin , netdev@vger.kernel.org, Linus Walleij , =?utf-8?b?QW50dGkgU2VwcMOkbMOk?= , Gabor Juhos , Colin Leitner , LEDE Development List Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The RTL8366RB is an ASIC with five internal PHYs for LAN0..LAN3 and WAN. The PHYs are spawn off the main device so they can be handled in a distributed manner by the Realtek PHY driver. All that is really needed is the power save feature enablement and letting the PHY driver core pick up the IRQ from the switch chip. Cc: Antti Seppälä Cc: Roman Yeryomin Cc: Colin Leitner Cc: Gabor Juhos Cc: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog RFCv1->RFCv2: - No real changes. --- drivers/net/phy/realtek.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 9f48ecf9c627..21624d1c9d38 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -37,6 +37,9 @@ #define RTL8201F_ISR 0x1e #define RTL8201F_IER 0x13 +#define RTL8366RB_POWER_SAVE 0x21 +#define RTL8366RB_POWER_SAVE_ON 0x1000 + MODULE_DESCRIPTION("Realtek PHY driver"); MODULE_AUTHOR("Johnson Leung"); MODULE_LICENSE("GPL"); @@ -145,6 +148,22 @@ static int rtl8211f_config_init(struct phy_device *phydev) return phy_modify_paged(phydev, 0xd08, 0x11, RTL8211F_TX_DELAY, val); } +static int rtl8366rb_config_init(struct phy_device *phydev) +{ + int ret; + u16 reg; + + ret = genphy_config_init(phydev); + if (ret < 0) + return ret; + + reg = phy_read(phydev, RTL8366RB_POWER_SAVE); + reg |= RTL8366RB_POWER_SAVE_ON; + phy_write(phydev, RTL8366RB_POWER_SAVE, reg); + + return 0; +} + static struct phy_driver realtek_drvs[] = { { .phy_id = 0x00008201, @@ -207,6 +226,18 @@ static struct phy_driver realtek_drvs[] = { .resume = genphy_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + }, { + /* The main part of this DSA is in drivers/net/dsa */ + .phy_id = 0x001cc961, + .name = "RTL8366RB Gigabit Ethernet", + .phy_id_mask = 0x001fffff, + .features = PHY_GBIT_FEATURES, + .flags = PHY_HAS_INTERRUPT, + .config_aneg = &genphy_config_aneg, + .config_init = &rtl8366rb_config_init, + .read_status = &genphy_read_status, + .suspend = genphy_suspend, + .resume = genphy_resume, }, }; @@ -218,6 +249,7 @@ static struct mdio_device_id __maybe_unused realtek_tbl[] = { { 0x001cc914, 0x001fffff }, { 0x001cc915, 0x001fffff }, { 0x001cc916, 0x001fffff }, + { 0x001cc961, 0x001fffff }, { } };