Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp311699rdb; Thu, 19 Oct 2023 05:29:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHn2JkX+f5d8IEAsXaRlHT2vmZgVVMxBG/vC5xmjWae3er8VNSOOiqxgOCEAmPfjXFhyX3h X-Received: by 2002:a05:6870:c14f:b0:1ea:2506:3e90 with SMTP id g15-20020a056870c14f00b001ea25063e90mr1939158oad.35.1697718566976; Thu, 19 Oct 2023 05:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697718566; cv=none; d=google.com; s=arc-20160816; b=kkuWdFBHRUmqTSt5HA4tgz/ykdS66fOusrIBZFaFwcVsUXiyUw+KfvUR89n59o1fSe oDYTF1CntDM+CRaY+qIgXixliUb5UPrrgKEkbgfL0zbwjp8pltyvaqXCgCu+MnOR7JDj kikMXse6dvcA0dwZ0JARwYlhMKbB3vqBS94y3RqxMfJ2rKUMAm8U5D9pNV6319tjeWkW 2T1PcgOkgYqfP5KLRW10ch5wDBancfLIk3NTFAa2Kj5ufE2zRBOMvSpKf8P4GdLpqXUM RutVitMgo83+tXGTTAeRy/We6Bm7LvIKL8AB1z1zAXjprX2Vhwbxinc0+kokauSzqNh1 mh+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=DCpPslErGiTsqxLc72Zy9rbsDc8Fvpzvk0RrsyMdWN0=; fh=J4gjwt0mePoRaYCjaHLm28JnUFi5LyPM6ZZbSRFLAL0=; b=nwJPXAjCxXx5/IQBX8ZEWg2Q2jH8VJkPeNVzT1/3Vaj485zZ/0mOyjI9Va9rtWPbqG 7jWCG3bKTbNnvUztf1u/BYChqmvsc4epQa6Ouen0cPEwc2oNB0dG30t4W41TWTurlCFJ 3sPGsBf5IQ27LLVvdGKxxbA8LI75lI9Ygum4R0S+cqkHTdnpaAXq2J50oBv1T1YjnXUx DpEIDvt6LIX9cXAGwJep850vhOsUcZJGgWbZhU3aXtzI4SRu9fugO/6TCpZstIVGDRgX ql8xey/QHqoc5jKX+1fLwe1qhIFjUBuYOJfOlI3ecN8bewwy7wBVcoMdx1j2wIN23Q2C 0rfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id 7-20020a631647000000b00578d3f8d4d4si4198732pgw.448.2023.10.19.05.29.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 05:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1B7D0826C4C2; Thu, 19 Oct 2023 05:29:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235325AbjJSM3P (ORCPT + 99 others); Thu, 19 Oct 2023 08:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233195AbjJSM3N (ORCPT ); Thu, 19 Oct 2023 08:29:13 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF7DDBE for ; Thu, 19 Oct 2023 05:29:10 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qtS8y-0006Kr-D7; Thu, 19 Oct 2023 14:28:52 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtS8x-002mri-Ea; Thu, 19 Oct 2023 14:28:51 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qtS8x-00528Y-1F; Thu, 19 Oct 2023 14:28:51 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean , Woojung Huh , Arun Ramadoss , Conor Dooley , Krzysztof Kozlowski , Rob Herring Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, UNGLinuxDriver@microchip.com, "Russell King (Oracle)" , devicetree@vger.kernel.org Subject: [PATCH net-next v6 0/9] net: dsa: microchip: provide Wake on LAN support Date: Thu, 19 Oct 2023 14:28:41 +0200 Message-Id: <20231019122850.1199821-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 05:29:24 -0700 (PDT) This patch series introduces extensive Wake on LAN (WoL) support for the Microchip KSZ9477 family of switches, coupled with some code refactoring and error handling enhancements. The principal aim is to enable and manage Wake on Magic Packet and other PHY event triggers for waking up the system, whilst ensuring that the switch isn't reset during a shutdown if WoL is active. The Wake on LAN functionality is optional and is particularly beneficial if the PME pins are connected to the SoC as a wake source or to a PMIC that can enable or wake the SoC. changes v6: - add variables magic_switched_off and magic_switched_on for readability - EXPORT_SYMBOL(ksz_switch_shutdown); to fix build as module changes v5: - rework Wake on Magic Packet support. - Make sure we show more or less realistic information on get_wol by comparing refcounted mac address against the ports address - fix mac address refcounting on set_wol() - rework shutdown sequence by to handle PMIC related issues. Make sure PME pin is net frequently toggled. - use wakeup_source variable instead of reading PME pin register. changes v4: - add ksz_switch_shutdown() and do not skip dsa_switch_shutdown() and etc. - try to configure MAC address on WAKE_MAGIC. If not possible, prevent WAKE_MAGIC configuration - use ksz_switch_macaddr_get() for WAKE_MAGIC. - prevent ksz_port_set_mac_address if WAKE_MAGIC is active - do some more refactoring and patch reordering changes v3: - use ethernet address of DSA master instead from devicetree - use dev_ops->wol* instead of list of supported switch - don't shutdown the switch if WoL is enabled - rework on top of latest HSR changes changes v2: - rebase against latest next Oleksij Rempel (9): net: dsa: microchip: Add missing MAC address register offset for ksz8863 dt-bindings: net: dsa: microchip: add wakeup-source property net: dsa: microchip: use wakeup-source DT property to enable PME output net: dsa: microchip: ksz9477: add Wake on LAN support net: dsa: microchip: ksz9477: Add Wake on Magic Packet support net: dsa: microchip: Refactor comment for ksz_switch_macaddr_get() function net: dsa: microchip: Add error handling for ksz_switch_macaddr_get() net: dsa: microchip: Refactor switch shutdown routine for WoL preparation net: dsa: microchip: Ensure Stable PME Pin State for Wake-on-LAN .../bindings/net/dsa/microchip,ksz.yaml | 2 + drivers/net/dsa/microchip/ksz9477.c | 198 ++++++++++++++++++ drivers/net/dsa/microchip/ksz9477.h | 5 + drivers/net/dsa/microchip/ksz9477_i2c.c | 5 +- drivers/net/dsa/microchip/ksz_common.c | 97 +++++++-- drivers/net/dsa/microchip/ksz_common.h | 10 + drivers/net/dsa/microchip/ksz_spi.c | 5 +- 7 files changed, 302 insertions(+), 20 deletions(-) -- 2.39.2