From patchwork Wed Sep 9 16:25:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 261248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9125BC2D0A8 for ; Wed, 9 Sep 2020 16:29:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4D3162166E for ; Wed, 9 Sep 2020 16:29:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="f87YnBrk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730969AbgIIQ1d (ORCPT ); Wed, 9 Sep 2020 12:27:33 -0400 Received: from mail.nic.cz ([217.31.204.67]:34622 "EHLO mail.nic.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731052AbgIIQ0D (ORCPT ); Wed, 9 Sep 2020 12:26:03 -0400 Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id C2F08140A64; Wed, 9 Sep 2020 18:25:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1599668754; bh=GiMyA6x4ElsGNt3VmolCaxWgc8p8+8SuvAMrXWbJfso=; h=From:To:Date; b=f87YnBrkbGhc0mIVSyThy0I8tEFadbY7bRevzKURZ9u8FsqdUpA2/lTT/7rnUADVz YpnEVtE4a7UcqDL5SUwko8Q7h8/8pJC0mgawuhLM6VqjkGqnUJPvleJRn4k2ROwRdS kCtCRgAacYXe2/ZszbGkdU37lhlonyDym53MpG/s= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org Cc: linux-leds@vger.kernel.org, Pavel Machek , Dan Murphy , =?utf-8?q?Ond=C5=99ej_Jirman?= , Russell King , Andrew Lunn , linux-kernel@vger.kernel.org, Matthias Schiffer , "David S. Miller" , =?utf-8?q?Marek_Beh=C3=BAn?= , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH net-next + leds v2 1/7] dt-bindings: leds: document binding for HW controlled LEDs Date: Wed, 9 Sep 2020 18:25:46 +0200 Message-Id: <20200909162552.11032-2-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909162552.11032-1-marek.behun@nic.cz> References: <20200909162552.11032-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Document binding for LEDs connected to and controlled by various chips (such as ethernet PHY chips). Signed-off-by: Marek Behún Cc: Rob Herring Cc: devicetree@vger.kernel.org --- .../leds/linux,hw-controlled-leds.yaml | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/linux,hw-controlled-leds.yaml diff --git a/Documentation/devicetree/bindings/leds/linux,hw-controlled-leds.yaml b/Documentation/devicetree/bindings/leds/linux,hw-controlled-leds.yaml new file mode 100644 index 0000000000000..eaf6e5d80c5f5 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/linux,hw-controlled-leds.yaml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/linux,hw-controlled-leds.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LEDs that can be controlled by hardware (eg. by an ethernet PHY chip) + +maintainers: + - Marek Behún + +description: + Many an ethernet PHY (and other chips) supports various HW control modes + for LEDs connected directly to them. With this binding such LEDs can be + described. + +properties: + compatible: + const: linux,hw-controlled-leds + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^led@[0-9a-f]+$": + type: object + allOf: + - $ref: common.yaml# + description: + This node represents a LED device connected to a chip that can control + the LED in various HW controlled modes. + + properties: + reg: + maxItems: 1 + description: + This property identifies the LED to the chip the LED is connected to + (eg. an ethernet PHY chip can have multiple LEDs connected to it). + + enable-active-high: + description: + Polarity of LED is active high. If missing, assumed default is active + low. + type: boolean + + led-tristate: + description: + LED pin is tristate type. If missing, assumed false. + type: boolean + + linux,default-hw-mode: + description: + This parameter, if present, specifies the default HW triggering mode + of the LED when LED trigger is set to `dev-hw-mode`. + Available values are specific per device the LED is connected to and + per LED itself. + $ref: /schemas/types.yaml#definitions/string + + required: + - reg + +additionalProperties: false + +examples: + - | + + #include + + ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c45"; + reg = <0>; + + leds { + compatible = "linux,hw-controlled-leds"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = ; + linux,default-trigger = "dev-hw-mode"; + linux,default-hw-mode = "1Gbps"; + }; + + led@1 { + reg = <1>; + color = ; + function = ; + linux,default-trigger = "dev-hw-mode"; + linux,default-hw-mode = "activity"; + }; + }; + }; + +... From patchwork Wed Sep 9 16:25:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 261244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8961C433E2 for ; Wed, 9 Sep 2020 16:37:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC75C2087C for ; Wed, 9 Sep 2020 16:37:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="Y3DvO2vk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730964AbgIIQgp (ORCPT ); Wed, 9 Sep 2020 12:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730550AbgIIQ0D (ORCPT ); Wed, 9 Sep 2020 12:26:03 -0400 Received: from mail.nic.cz (mail.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CAD3C061756; Wed, 9 Sep 2020 09:25:59 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 29126140A72; Wed, 9 Sep 2020 18:25:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1599668755; bh=FR7+inwZvbFVAUyvtRKpQapSQN3oEXOfxjaahzSXaLs=; h=From:To:Date; b=Y3DvO2vkbr4CDz6hfyGSc2Tt7tvL65TSQAvTKBJaLK65CPVJLSceKrKy4iXRxjEYl 7vahHqtEdfyLlFVWHvqaRX68H2UiEmMDbbeIXV0pc6tyf2UR4LtZtA0Vrv2Bump1H4 GG4U/VQU1x1Khvj3+YShPfDfo772ZezJ9xqRxQO8= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org Cc: linux-leds@vger.kernel.org, Pavel Machek , Dan Murphy , =?utf-8?q?Ond=C5=99ej_Jirman?= , Russell King , Andrew Lunn , linux-kernel@vger.kernel.org, Matthias Schiffer , "David S. Miller" , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH net-next + leds v2 3/7] net: phy: add simple incrementing phyindex member to phy_device struct Date: Wed, 9 Sep 2020 18:25:48 +0200 Message-Id: <20200909162552.11032-4-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909162552.11032-1-marek.behun@nic.cz> References: <20200909162552.11032-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a new integer member phyindex to struct phy_device. This member is unique for every phy_device. Atomic incrementation occurs in phy_device_register. This can be used for example in LED sysfs API. The LED subsystem names each LED in format `device:color:function`, but currently the PHY device names are not suited for this, since in some situations a PHY device name can look like this d0032004.mdio-mii:01 or even like this /soc/internal-regs@d0000000/mdio@32004/switch0@10/mdio:08 Clearly this cannot be used as the `device` part of a LED name. Signed-off-by: Marek Behún --- drivers/net/phy/phy_device.c | 3 +++ include/linux/phy.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 8adfbad0a1e8f..38f56d39f1229 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -9,6 +9,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -892,6 +893,7 @@ EXPORT_SYMBOL(get_phy_device); */ int phy_device_register(struct phy_device *phydev) { + static atomic_t phyindex; int err; err = mdiobus_register_device(&phydev->mdio); @@ -908,6 +910,7 @@ int phy_device_register(struct phy_device *phydev) goto out; } + phydev->phyindex = atomic_inc_return(&phyindex) - 1; err = device_add(&phydev->mdio.dev); if (err) { phydev_err(phydev, "failed to add\n"); diff --git a/include/linux/phy.h b/include/linux/phy.h index 3a09d2bf69ea4..52881e21ad951 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -406,6 +406,7 @@ struct macsec_ops; /* phy_device: An instance of a PHY * * drv: Pointer to the driver for this PHY instance + * phyindex: a simple incrementing PHY index * phy_id: UID for this device found during discovery * c45_ids: 802.3-c45 Device Identifers if is_c45. * is_c45: Set to true if this phy uses clause 45 addressing. @@ -446,6 +447,8 @@ struct phy_device { /* And management functions */ struct phy_driver *drv; + int phyindex; + u32 phy_id; struct phy_c45_device_ids c45_ids; From patchwork Wed Sep 9 16:25:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 261249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F6A2C43461 for ; Wed, 9 Sep 2020 16:28:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53C572080A for ; Wed, 9 Sep 2020 16:28:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=nic.cz header.i=@nic.cz header.b="fCs8lADv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731042AbgIIQ2O (ORCPT ); Wed, 9 Sep 2020 12:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731022AbgIIQ0G (ORCPT ); Wed, 9 Sep 2020 12:26:06 -0400 Received: from mail.nic.cz (lists.nic.cz [IPv6:2001:1488:800:400::400]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DA41C061795; Wed, 9 Sep 2020 09:26:05 -0700 (PDT) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id D5423140A7D; Wed, 9 Sep 2020 18:25:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1599668755; bh=ETijTD2hHqyWxW2zwXhqdFU5Xk5g005codDN5mEO12w=; h=From:To:Date; b=fCs8lADvaSZx/tRW4It7vvjDQqLxXSf0ofh5ycAqs4qKwAnJ4M6nEOm7C/kWYjWzS ldSpXT1S247pBH6u+pIBV4mjNWMCYm3h+/2ed8WqrHa7K9IgMbq5PVpQOMQnqiu28j QeqYGFpVaS3hXsCIXMtHtGEsFgOywhS5gt+T5jio= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: netdev@vger.kernel.org Cc: linux-leds@vger.kernel.org, Pavel Machek , Dan Murphy , =?utf-8?q?Ond=C5=99ej_Jirman?= , Russell King , Andrew Lunn , linux-kernel@vger.kernel.org, Matthias Schiffer , "David S. Miller" , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH net-next + mvebu v2 7/7] arm64: dts: armada-3720-turris-mox: add nodes for ethernet PHY LEDs Date: Wed, 9 Sep 2020 18:25:52 +0200 Message-Id: <20200909162552.11032-8-marek.behun@nic.cz> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200909162552.11032-1-marek.behun@nic.cz> References: <20200909162552.11032-1-marek.behun@nic.cz> MIME-Version: 1.0 X-Spamd-Bar: / X-Virus-Scanned: clamav-milter 0.102.2 at mail X-Virus-Status: Clean Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add nodes for the green and yellow LEDs that are connected to the ethernet PHY chip on Turris MOX A. Signed-off-by: Marek Behún --- .../dts/marvell/armada-3720-turris-mox.dts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts index f3a678e0fd99b..6da03b6c69c0a 100644 --- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts +++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts @@ -9,6 +9,7 @@ #include #include #include +#include #include "armada-372x.dtsi" / { @@ -273,6 +274,28 @@ &mdio { phy1: ethernet-phy@1 { reg = <1>; + + leds { + compatible = "linux,hw-controlled-leds"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_STATUS; + linux,default-trigger = "dev-hw-mode"; + linux,default-hw-mode = "1Gbps/100Mbps/10Mbps"; + }; + + led@1 { + reg = <1>; + color = ; + function = LED_FUNCTION_ACTIVITY; + linux,default-trigger = "dev-hw-mode"; + linux,default-hw-mode = "blink-act"; + }; + }; }; /* switch nodes are enabled by U-Boot if modules are present */