From patchwork Sat Jul 14 09:45:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 141953 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp391137ljj; Sat, 14 Jul 2018 02:48:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcmBg4OImV4Eccg9vKOp8MDtPO/mmHS4whHusAMPE/s6PtK1mVzwiicIsjK1qO1LCgu7QLG X-Received: by 2002:a62:1f8c:: with SMTP id l12-v6mr10629361pfj.143.1531561696795; Sat, 14 Jul 2018 02:48:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531561696; cv=none; d=google.com; s=arc-20160816; b=ZdwNBswgGPa1Sw1+aA/k5dh466Nidmp/96Td+isPEMJ39z+YDdHNNDBAoxeSRjba/z HarG3Q0IVUzKa3q9cYyJ6JD/UenqPZElPkP/iYvYRPjuAp/dQP5EMI7vsUpkcPzWQMUs 9v9RaoUde1J4wDTbPnGJbXIeh89pcO9xmzY4qP+pL2qrbIpzKndi+TXBWx5JLHKL/Jt4 355837yci2BEUF++sjor4b6Hh1UIMgg8FyXly043ulMjNO1MgOjRsv0KcyX5eZoCnXDK S5ei09VXFNU5boGU8FlMirILh0xIo/nmtWdR4ny8FS3qja9sE86j/5R73FvuSsCziZ0B Y7uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=cUJgGNGsiB/yDm5beqSvoG+k0w4slll/h4Smf3WF6Mk=; b=fabOePQHQIK70CdOCXxQ3DwZtXuUeczEXIy7V/0/9hc6ov5ile/XaMUhQBp18wOZsk yhudkWE2gdw7/gw7bASkNSi6ddMGz/UJtKu6UDVV/NzQY0ylXDxuiwt194wNqwNuCp/9 /99LaLoU2CNhHotGD5gHTen+3R/mC8A978iQ+sY7TpX5GM3Ckq+CFJ3LNbeqVk4w2Yb7 I8oMXbXZwHAREJUZgGqaTSqBi37aKvH3otzHC8bIhMz3QgFCHMOEaeL4E3w2Oq4+tYOj mfPqjbb2d6pdSc79y5jGq6ik7urKLFSJ/jlLY7bZzcCb9PgYNN1IPeSvLvvt2sAZYXpK QZ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MRyfe0hb; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q12-v6si13605133pgg.532.2018.07.14.02.48.16; Sat, 14 Jul 2018 02:48:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MRyfe0hb; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbeGNKGk (ORCPT + 10 others); Sat, 14 Jul 2018 06:06:40 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35861 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727785AbeGNKGk (ORCPT ); Sat, 14 Jul 2018 06:06:40 -0400 Received: by mail-lf0-f68.google.com with SMTP id b22-v6so16589560lfa.3 for ; Sat, 14 Jul 2018 02:48:08 -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:mime-version :content-transfer-encoding; bh=cUJgGNGsiB/yDm5beqSvoG+k0w4slll/h4Smf3WF6Mk=; b=MRyfe0hbyYAqCO+tRzuT0I6v8gDye8roOfWAWh7Yn872VAJ3WmLQRQGJ8M9eG9pfvS +lwSr0t6AjAHzHLqC0c9zpu8RC0ECBmB+mAkOD8gCIWX3B8fs7n+G+VHmbhe81Izv7RE x/8vCyEPdkeQ6aCJFC1/vojUoumynW4u8GEyU= 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:mime-version :content-transfer-encoding; bh=cUJgGNGsiB/yDm5beqSvoG+k0w4slll/h4Smf3WF6Mk=; b=deAJACvKRtV/QbSohCw68smoRpoHIMxq4ibdSoZ7uIcQtVFTWbHnDpLMSn3alhdMqc I+r+piPidddMkLo8s+4PEFhHyG7XAovWKboTBMgeFUvATs609wZaUwv4XIvMM20JTeHD leEt0wuNVIVNOEnzC/YAkIH5DM4hQZIfYDmtm2ze4pO7a96/3C3hx5v3Qo3V2JRVVITB OLiHhd8cEK5G5eIYNNUbKoloUUSjTw1/ahDrd9D2ncmgYgcMPuv1nfLQoSjZ8ejAwO1O AYCKCEbxM8im2m75THXBNtby4zR6YQJXRzDkBMU5Pw4FWmyQN+U8BER+6HwSb1uSM+c3 G3Vg== X-Gm-Message-State: AOUpUlEZHsn2iWMDTNpXZeYZWjGpUyCPU0PEXU9CRWIVhr2nV6EGgCkH e8mnOR25FkbSSkjOrmsNrSohhg== X-Received: by 2002:a19:c004:: with SMTP id q4-v6mr7100983lff.16.1531561687739; Sat, 14 Jul 2018 02:48:07 -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 i1-v6sm3854344ljg.43.2018.07.14.02.48.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 14 Jul 2018 02:48:06 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli Cc: netdev@vger.kernel.org, openwrt-devel@lists.openwrt.org, LEDE Development List , Linus Walleij , =?utf-8?b?QW50dGkgU2VwcMOkbMOk?= , Roman Yeryomin , Colin Leitner , Gabor Juhos Subject: [PATCH 1/4 v1] net: phy: realtek: Support RTL8366RB variant Date: Sat, 14 Jul 2018 11:45:53 +0200 Message-Id: <20180714094556.30791-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.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 RFCv2->v1 - Correct the PHY power save register from 0x21 to 0x15 as it should be. - Drop the comment about the DSA switch. - Use BIT(12) for power save bit define - Use phy_set_bits() to simplify code - Skip assigning genphy_config_aneg() and genphy_read_status() as this is default anyway ChangeLog RFCv1->RFCv2: - No real changes. --- drivers/net/phy/realtek.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) -- 2.17.1 diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 082fb40c656d..d0d07f22df1f 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 0x15 +#define RTL8366RB_POWER_SAVE_ON BIT(12) + MODULE_DESCRIPTION("Realtek PHY driver"); MODULE_AUTHOR("Johnson Leung"); MODULE_LICENSE("GPL"); @@ -159,6 +162,24 @@ static int rtl8211b_resume(struct phy_device *phydev) return genphy_resume(phydev); } +static int rtl8366rb_config_init(struct phy_device *phydev) +{ + int ret; + + ret = genphy_config_init(phydev); + if (ret < 0) + return ret; + + ret = phy_set_bits(phydev, RTL8366RB_POWER_SAVE, + RTL8366RB_POWER_SAVE_ON); + if (ret) { + dev_err(&phydev->mdio.dev, + "error enabling power management\n"); + } + + return ret; +} + static struct phy_driver realtek_drvs[] = { { .phy_id = 0x00008201, @@ -223,6 +244,15 @@ static struct phy_driver realtek_drvs[] = { .resume = genphy_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + }, { + .phy_id = 0x001cc961, + .name = "RTL8366RB Gigabit Ethernet", + .phy_id_mask = 0x001fffff, + .features = PHY_GBIT_FEATURES, + .flags = PHY_HAS_INTERRUPT, + .config_init = &rtl8366rb_config_init, + .suspend = genphy_suspend, + .resume = genphy_resume, }, }; @@ -234,6 +264,7 @@ static struct mdio_device_id __maybe_unused realtek_tbl[] = { { 0x001cc914, 0x001fffff }, { 0x001cc915, 0x001fffff }, { 0x001cc916, 0x001fffff }, + { 0x001cc961, 0x001fffff }, { } };