From patchwork Wed Dec 27 09:02:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13505231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36E9EC46CD2 for ; Wed, 27 Dec 2023 09:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KUdWdgPmM2oZd15ufQHgW9dbrrWnSaL9y+wFgklRA40=; b=XS0An8fJ2urpuV t/0fGJp+YNHxgzE8uvaAr/TLfHgyGGY463HFkiIzsI2RWLI9AxX1CYJgYPUUIZnsifhjPHT9AHu0v 9k01qeGnMrfV+IsDJipUqxfbGpya9G1QDhTBzNRhVg7gR0ezJ+oxSzZEf7KYX20A8JuqnAffYQRnH eNoRr/n1lbbiFxt3ZszUfQ2b6gsUMfUZL6QNXV+uUNRZMUpBx1pZIerqsnGNCXlu3H2V5hI2svf7+ sm7pl+USpybQlchgiSJKHRqEzURUWK2v8rLGfEUp92lESmp4WeHTlOr3BMD6NESvq8MhrAU9XS7QD eyEbio4uPO77AG2dBlHw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIPoq-00EFPz-03; Wed, 27 Dec 2023 09:03:16 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIPoi-00EFLC-0c for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 09:03:09 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-336746a545fso2837753f8f.0 for ; Wed, 27 Dec 2023 01:03:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703667786; x=1704272586; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HEHmC5iKOCQu4l12DtoKmZcnhnrMLLjw+Ox9XPLFhKQ=; b=AKOaiyvH9qK4tiRx5g+ZvjLatn6XmWci913BNDIJ7bypDvfYfR+le8lCcGWOXD5SxF qUwD0nkzT77ZKi5zJ3shj/VSCLlqcCuT5oUshzV0ctt/9UHGxcIUA3KQZid74hO5vFF+ 4OH4P8kSdO9AdE5Xb1qbwAtvXwA8sR2e/zo3EU6Ta1eZoymY4QHg+rc9P0S3U5x3J4b2 SBbH8sl6OZ4PIHPOfJp/bGHo4fS7mAp352jEThCNrjoOHYgvmo8E+8nm9WWSoAgo77bO fWZ95VOsBqHluV6aluUIAmyTRAccm0HVWc5AzH9oGVig9QL4twbxskv/7j/6kRzX9Q7e ZONA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703667786; x=1704272586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HEHmC5iKOCQu4l12DtoKmZcnhnrMLLjw+Ox9XPLFhKQ=; b=UtKRSAODUvhpYpckHm7XKBF6i56sE4EXLdd7azmHFUvMRxIoRT5rN5mTMM/kS8i3em uinQ893NNWytAU1hlTX+KXLh45/Kvd/h/DCScQC9XgpghXYPmVTwHf0JBq2uNNZ41IK3 fKQ9nZw2SRMOBoyOcsWDqze0CHO13VTc82Kzfo+vMryK/I6kWtDFtu7ujs0+VJ0L2sb/ XIr2CFDYwPnPJVbybwQTHGHi0TcWO9YgqzqLIk/5hT1Kg5pz+Lm5GbmsLy6tHqtBQy3+ R2knHAaa80Dr0PFJuwWDAkuRtrC1PazWrCbmjp/WhaLibf1k5Vr5yu2BE01BgJTh7mOc rpBg== X-Gm-Message-State: AOJu0YxK8Fzb93JqNRBuWNxRWCof6oFMQZ+/IkjR5YeQ+i0U+7f0UuIq QVRkSaK10Rm8JIGAIuwNWL8= X-Google-Smtp-Source: AGHT+IGsJLUrt/3CLFq83TJylEE3sXQAo8ZuPSwcXKHb6YUaJxdO62Bce1ZfcGgV4upAb7C6VKcX3g== X-Received: by 2002:adf:9bcc:0:b0:336:5499:47dd with SMTP id e12-20020adf9bcc000000b00336549947ddmr4499910wrc.6.1703667786095; Wed, 27 Dec 2023 01:03:06 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id c9-20020a056000104900b003368849129dsm13616525wrx.15.2023.12.27.01.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 01:03:05 -0800 (PST) From: Christian Marangi To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , Jacek Anaszewski , =?utf-8?q?Fern=C3=A1ndez_Roj?= =?utf-8?q?as?= , Sven Schwermer , Christian Marangi , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [net-next PATCH v5 1/5] dt-bindings: net: phy: Make LED active-low property common Date: Wed, 27 Dec 2023 10:02:27 +0100 Message-Id: <20231227090231.4246-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231227090231.4246-1-ansuelsmth@gmail.com> References: <20231227090231.4246-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_010308_230394_23289E0A X-CRM114-Status: GOOD ( 15.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Move LED active-low property to common.yaml. This property is currently defined multiple times by bcm LEDs. This property will now be supported in a generic way for PHY LEDs with the use of a generic function. With active-low bool property not defined, active-high is always assumed. Signed-off-by: Christian Marangi --- Changes v5: - Make active-low generic Changes v4: - Drop support for global active-low - Rework to polarity option (for marvell10g series support) Changes v3: - Out of RFC Changes v2: - Add this patch Documentation/devicetree/bindings/leds/common.yaml | 6 ++++++ Documentation/devicetree/bindings/leds/leds-bcm63138.yaml | 4 ---- Documentation/devicetree/bindings/leds/leds-bcm6328.yaml | 4 ---- Documentation/devicetree/bindings/leds/leds-bcm6358.txt | 2 -- .../devicetree/bindings/leds/leds-pwm-multicolor.yaml | 4 ---- Documentation/devicetree/bindings/leds/leds-pwm.yaml | 5 ----- 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index c8d0ba5f2327..f5b40df6b421 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -200,6 +200,12 @@ properties: #trigger-source-cells property in the source node. $ref: /schemas/types.yaml#/definitions/phandle-array + active-low: + type: boolean + description: + Makes LED active low. To turn the LED ON, line needs to be + set to low voltage instead of high. + # Required properties for flash LED child nodes: flash-max-microamp: description: diff --git a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml index 52252fb6bb32..bb20394fca5c 100644 --- a/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml +++ b/Documentation/devicetree/bindings/leds/leds-bcm63138.yaml @@ -52,10 +52,6 @@ patternProperties: maxItems: 1 description: LED pin number - active-low: - type: boolean - description: Makes LED active low - required: - reg diff --git a/Documentation/devicetree/bindings/leds/leds-bcm6328.yaml b/Documentation/devicetree/bindings/leds/leds-bcm6328.yaml index 51cc0d82c12e..f3a3ef992929 100644 --- a/Documentation/devicetree/bindings/leds/leds-bcm6328.yaml +++ b/Documentation/devicetree/bindings/leds/leds-bcm6328.yaml @@ -78,10 +78,6 @@ patternProperties: - maximum: 23 description: LED pin number (only LEDs 0 to 23 are valid). - active-low: - type: boolean - description: Makes LED active low. - brcm,hardware-controlled: type: boolean description: Makes this LED hardware controlled. diff --git a/Documentation/devicetree/bindings/leds/leds-bcm6358.txt b/Documentation/devicetree/bindings/leds/leds-bcm6358.txt index 6e51c6b91ee5..211ffc3c4a20 100644 --- a/Documentation/devicetree/bindings/leds/leds-bcm6358.txt +++ b/Documentation/devicetree/bindings/leds/leds-bcm6358.txt @@ -25,8 +25,6 @@ LED sub-node required properties: LED sub-node optional properties: - label : see Documentation/devicetree/bindings/leds/common.txt - - active-low : Boolean, makes LED active low. - Default : false - default-state : see Documentation/devicetree/bindings/leds/common.txt - linux,default-trigger : see diff --git a/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml b/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml index bd6ec04a8727..5edfbe347341 100644 --- a/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml +++ b/Documentation/devicetree/bindings/leds/leds-pwm-multicolor.yaml @@ -41,10 +41,6 @@ properties: pwm-names: true - active-low: - description: For PWMs where the LED is wired to supply rather than ground. - type: boolean - color: true required: diff --git a/Documentation/devicetree/bindings/leds/leds-pwm.yaml b/Documentation/devicetree/bindings/leds/leds-pwm.yaml index 7de6da58be3c..113b7c218303 100644 --- a/Documentation/devicetree/bindings/leds/leds-pwm.yaml +++ b/Documentation/devicetree/bindings/leds/leds-pwm.yaml @@ -34,11 +34,6 @@ patternProperties: Maximum brightness possible for the LED $ref: /schemas/types.yaml#/definitions/uint32 - active-low: - description: - For PWMs where the LED is wired to supply rather than ground. - type: boolean - required: - pwms - max-brightness From patchwork Wed Dec 27 09:02:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13505232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4E844C46CD2 for ; Wed, 27 Dec 2023 09:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2IckP87kZMAl//IVH3pM8GXUpH9Esz+4Ky1fW2MOJ34=; b=D1BvkSEbDWGZjx t/vZm8Y2vtOGaHTbhrCCZYkM42Vhz+GuIj+7HsHrFEWhlyGD36ibNeQmIfMA6/qwobhZF3ia43zHj F1DhDFndJLjY8FYdLQlGG/ArsC1BGw4YSCHklW/P/TgP9t/+ts8yYqS05+Of7KBCpcK9R8jRdW0Xj LFIrapbT+go7LlUNmWNUbvpWIO7bzcM9WVp5OKQJObbhNMzTqXuA6ADuWyj/5+SFikR/n4pC1BCLo 0zitztn/Jmu9auDCMsuKDvsokYyDZQ0gxLQrNQooY7kAfYtD7AfnxKzkueMws46C+Vt8Qw6Otd0TV bu/1kr2teGcappjoXuHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIPoq-00EFQN-1s; Wed, 27 Dec 2023 09:03:16 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIPok-00EFN8-06 for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 09:03:11 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-33694bf8835so3688705f8f.3 for ; Wed, 27 Dec 2023 01:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703667789; x=1704272589; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Cmsj+MoZd6CCP0Gk1jswJO8zXGhPor2mMopnaqDXKNM=; b=RQ7+nBWGNM32Gf/coFJIfU3S8Ww5/o80oNna3+pv/AfOCGX6BUkHCryHyc/qmhkTTg xlQJZBEjcTYDR8rgYR704JX9qt7hDRJ7UeAWUL9Mf20J59ay/an/TRJG2spQXVC2VzCr FSL9L99MNNtM4Za9q6JSZKMDXPVtPSSeI5l785+6+8OU2W5cHp/3Y3p+xBJjFgKRdy+O rfhg6xKR+2nqrsj2GDNAB57q8QWMFisOfoO1kLQCRms2axn3NU8sFaKeZ1j1SWnIAoXa PT9h5r2DUQVun2lO++P0PjeHKTlOSjRCw874iDtX/V2zq7UBfw9wL6/tkR+BegBQFW09 Kucw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703667789; x=1704272589; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cmsj+MoZd6CCP0Gk1jswJO8zXGhPor2mMopnaqDXKNM=; b=e72OSKMkODwoTSJzeyQ4786OANVOvXR1JV8xyDbbQ4+mnintkzmb3CkOR4N+JEKLIT Q8pQPtlBHfDuyWna0SIg4DAIz4bPT/7i7JLDyq39FUJwzuyjkdDGFjqLe479LOSxIM/h i7hPwhg20xhMiPcAguwqFbv2osvyvInsz0vb/B5yt+AjmJVy12ohO2kMNbdlxlkz16x7 RMcIHxfY6xxDSvVZbVprzqPZKDxWEtuX2MDT7fHtBfJue8+d4ZAudwhPspB2bjSZdYbx wXUbNjKdpFiOOs7ZhGIJuOIOINsIOJwHn511rFiKxd+PtEjAEeuRXytm4P+vy9JaNxhF J6fw== X-Gm-Message-State: AOJu0Yzq0z8xXITzuS9JsaYsVIU82gncxgazEea2YU/KX7qmpIS1K49G dKjir0y9cdbiyqbctDXvb0E= X-Google-Smtp-Source: AGHT+IHHsaIuTdzyY6EGsQXG120Hnd9I7mUH54bEZwAsYXgidJXrJL92gmVnfimcwq3PRJHagcE36A== X-Received: by 2002:a5d:65cc:0:b0:336:7bf2:89da with SMTP id e12-20020a5d65cc000000b003367bf289damr4865220wrw.95.1703667788502; Wed, 27 Dec 2023 01:03:08 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id c9-20020a056000104900b003368849129dsm13616525wrx.15.2023.12.27.01.03.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 01:03:08 -0800 (PST) From: Christian Marangi To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , Jacek Anaszewski , =?utf-8?q?Fern=C3=A1ndez_Roj?= =?utf-8?q?as?= , Sven Schwermer , Christian Marangi , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [net-next PATCH v5 2/5] dt-bindings: net: phy: Document LED inactive high impedance mode Date: Wed, 27 Dec 2023 10:02:28 +0100 Message-Id: <20231227090231.4246-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231227090231.4246-1-ansuelsmth@gmail.com> References: <20231227090231.4246-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_010310_075426_F4DACF8C X-CRM114-Status: GOOD ( 12.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Document LED inactive high impedance mode to set the LED to require high impedance configuration to be turned OFF. Signed-off-by: Christian Marangi --- Changes v5: - Add this patch Documentation/devicetree/bindings/leds/common.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index f5b40df6b421..9e7b4aabe0bb 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -206,6 +206,12 @@ properties: Makes LED active low. To turn the LED ON, line needs to be set to low voltage instead of high. + inactive-high-impedance: + type: boolean + description: + Set LED to high-impedance mode to turn the LED OFF. LED might also + describe this mode as tristate. + # Required properties for flash LED child nodes: flash-max-microamp: description: From patchwork Wed Dec 27 09:02:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13505230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D097C4706F for ; Wed, 27 Dec 2023 09:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0DGg0rlWNBPG/gdEsI0YOYpewv7It7JpVZ66liCFHRc=; b=fjxJrljVEj2Rz3 SxHybmnBubkIcJ85bbr8xQNcXJyaCnlEik59epnC/HMol8EWhA3/j03SwMEXAJAxHfvpSrNbvutQW x3Ro5kfXH94uIC6jfkcUlS6UJ6URBIvG9Zv4zaUtcqFgNVd0982NKK9OZ5MjLUzUJXbJ85QuYFm13 9cXGKIpKYmWl2Ktk8u3k2fSHopuhdWmx5mpoVAHOZUgPt7QyUBa/iJCXynkcfJ8jgQOD9yMV0kfPg 4qoIKc++UV/UzlvRSAtZYx+cDoOa5GwFufIM490n9KMy6WGN2tbh/bF4tXoi5RWHZ3qfgquDCS70d rOp6NY2/WIGXVEAyNUEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIPor-00EFQg-0T; Wed, 27 Dec 2023 09:03:17 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIPom-00EFNv-2r for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 09:03:14 +0000 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3368d1c7b23so4199154f8f.0 for ; Wed, 27 Dec 2023 01:03:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703667791; x=1704272591; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=RraVKdn/3CtUzdc/GUkx4wIWX/WntChO7vtqlU3szKo=; b=Jh2ca8IFRkxHuMd/noyo4nz2EBKxe5RIBxcv1mfJR2R+2r4+Y7zbn7yd4dhCHaVSR0 xnMN7gb/EAr9Yem/80muPoLqVnrE1U8/AR4s8SgpWjf8Ne4SPHOLp4l6vx6twZW4c1TX IKPdcmkr+TxlnT9tLNq5GnVxDCrXI95rwmRVWAZplrCAp8aofKyWDP64SsFA09yZ8ok5 pj7D/yYZNoMLFt5XEMGLJxVD/YvN7wSeFmDjzSXmmmxQinFP+5a2mbLmjQIHxWuC55zO cF/fZMZsQD+i/SMV80hJBlxZXFixN5qnHTM1kJ5q0BFET8CsOfEJkJdwz1yKz2cPdV7H MouA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703667791; x=1704272591; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RraVKdn/3CtUzdc/GUkx4wIWX/WntChO7vtqlU3szKo=; b=GUHxPDqT5M8ECA3saoUla1L8gQJ7U2ztrUWtgz9sUGksmYyaGE3c38X5DIZHR/5T9K zIGlqE8vwWdfJGmZf3b6noJWcw7LITwSz76HeVWBbT3EqcyZb6iStNMd/6JNWb30LV5t bIKBZCyI+F04h7ij86HwePTCWcgbvyfQksCmxSjrR8+Cq7muqniSG68OW8j0q3jg5gMH nnCpJWranfWR7ByIgVel9hnY+lBvdpG7n1YfWQXxVmY1swm6xVlgDVjbL3xzvCJVSROz gg+VII0n7gJJDv/USqtjVNyiiMxnMHgfZd0tXeKGJ9ssjeeJrNXZIagpKRP4ejxfjfqh s22Q== X-Gm-Message-State: AOJu0Yyp1CyCw2lK7ywBFUZuM+hhFml+nnKarvZydpxCf5f1g25PYILh CGUZqEg+Dyz8X1V97+Eo95o= X-Google-Smtp-Source: AGHT+IHzsOs4p8HP8d1yYaPv2Nuxy0oYAJxlZLFgEmeJWBl/k5eA1TsyrGHT0l7hkmB3olgSIFB2wA== X-Received: by 2002:a05:6000:1042:b0:336:73d6:b42b with SMTP id c2-20020a056000104200b0033673d6b42bmr4549978wrx.117.1703667791035; Wed, 27 Dec 2023 01:03:11 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id c9-20020a056000104900b003368849129dsm13616525wrx.15.2023.12.27.01.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 01:03:10 -0800 (PST) From: Christian Marangi To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , Jacek Anaszewski , =?utf-8?q?Fern=C3=A1ndez_Roj?= =?utf-8?q?as?= , Sven Schwermer , Christian Marangi , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [net-next PATCH v5 3/5] net: phy: add support for PHY LEDs polarity modes Date: Wed, 27 Dec 2023 10:02:29 +0100 Message-Id: <20231227090231.4246-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231227090231.4246-1-ansuelsmth@gmail.com> References: <20231227090231.4246-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_010312_921307_84EF0CE3 X-CRM114-Status: GOOD ( 19.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for PHY LEDs polarity modes. Some PHY require LED to be set to active low to be turned ON. Adds support for this by declaring active-low property in DT. PHY driver needs to declare .led_polarity_set() to configure LED polarity modes. Function will pass the index with the LED index and a bitmap with all the required modes to set. Current supported modes are: - active-low with the flag PHY_LED_ACTIVE_LOW. LED is set to active-low to turn it ON. - inactive-high-impedance with the flag PHY_LED_INACTIVE_HIGH_IMPEDANCE. LED is set to high impedance to turn it OFF. Signed-off-by: Christian Marangi --- Changes v5: - Rework to LED modes bitmap Changes v4: - Drop for global active-low - Rework to polarity option (for marvell10g series support) Changes v3: - Out of RFC Changes v2: - Add this patch drivers/net/phy/phy_device.c | 12 ++++++++++++ include/linux/phy.h | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 3611ea64875e..b99c7579d9c4 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3097,6 +3097,7 @@ static int of_phy_led(struct phy_device *phydev, struct device *dev = &phydev->mdio.dev; struct led_init_data init_data = {}; struct led_classdev *cdev; + unsigned long modes = 0; struct phy_led *phyled; u32 index; int err; @@ -3114,6 +3115,17 @@ static int of_phy_led(struct phy_device *phydev, if (index > U8_MAX) return -EINVAL; + if (phydev->drv->led_polarity_set) { + if (of_property_read_bool(led, "active-low")) + set_bit(PHY_LED_ACTIVE_LOW, &modes); + if (of_property_read_bool(led, "inactive-high-impedance")) + set_bit(PHY_LED_INACTIVE_HIGH_IMPEDANCE, &modes); + + err = phydev->drv->led_polarity_set(phydev, index, modes); + if (err) + return err; + } + phyled->index = index; if (phydev->drv->led_brightness_set) cdev->brightness_set_blocking = phy_led_set_brightness; diff --git a/include/linux/phy.h b/include/linux/phy.h index e9e85d347587..5ac54f9eee82 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -853,6 +853,15 @@ struct phy_plca_status { bool pst; }; +/* Modes for PHY LED configuration */ +enum phy_led_modes { + PHY_LED_ACTIVE_LOW = 0, + PHY_LED_INACTIVE_HIGH_IMPEDANCE = 1, + + /* keep it last */ + __PHY_LED_MODES_NUM, +}; + /** * struct phy_led: An LED driven by the PHY * @@ -1146,6 +1155,19 @@ struct phy_driver { int (*led_hw_control_get)(struct phy_device *dev, u8 index, unsigned long *rules); + /** + * @led_polarity_set: Set the LED polarity if active low + * @dev: PHY device which has the LED + * @index: Which LED of the PHY device or -1 + * @modes: bitmap of LED polarity modes + * + * Configure LED with all the required polarity modes in @modes + * to make it correctly turn ON or OFF. + * + * Returns 0, or an error code. + */ + int (*led_polarity_set)(struct phy_device *dev, int index, + unsigned long modes); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv) From patchwork Wed Dec 27 09:02:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13505233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DA06C46CD2 for ; Wed, 27 Dec 2023 09:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ifC5+KWs+R8o+nZkMOnYZneUHGCUYCL7W31n33rtumw=; b=Bn69jO2+N2ky1N MJaXMs2V0RGH0y8kzmGJqZAcWyqgSk70zdByiEgfVg9uorJwwYrV6mV5s5pd02mpqt/OdAnm79fdr 9h9C15OhYcSdZyaqbTA76Y1NraAMlHY+msQa1n7Pkp+qC6+8PqXeHPgICRADyKWDBKWvAa4PTm05j WYUxYP4CNRcDtgwk6SoexJn6ntYw0eam000T62vWhIice9DF2xKOmkDltsumHC2C+ggYbIftvkkE2 gOMPE/EMXMM13ShI5AiSSHjcpSDivTrZzMac0cNyOGhT6UBkR6VkAsV4zVRL12wTYmUwveER8FzBg Fh7B/l5n/V8Z4Em12TcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIPpB-00EFZW-3A; Wed, 27 Dec 2023 09:03:37 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIPop-00EFPB-1V for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 09:03:16 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40d4ebcc207so37457365e9.3 for ; Wed, 27 Dec 2023 01:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703667793; x=1704272593; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o6LKt+ontTXHu1XtoIYFtpLE+AnFf2w4c9A2s2xTblA=; b=QVljwNudIZ8KyAPaX7IQH4brngHQNlfORbO5879XNn07XPDPGNai1vRHrF7D1Vsyoz wRhYjhLDbGFLaR4+eI0XDAFu4rt88lpYiAh3Oo4bL8W5eoSZXnwtDkCLx42gPpOTxDCt ImCEJa/Lan77fLUurWeM92MAxWm9Xy/W8LrMIeFhVf1dGkyT8QHRTQBCgIkBdodRouLI NLIe8Qq3QF4uDlcyrylljf/6XL3ovIYIPdPOQgOdwzLoZBqAe8FKbwJocY7KgcpbTMi9 LRt8FPyOJKR5QlDFzx0ce5fwAoZ8tJ4ffyI5ojYUjnKXzjbSOHpZXYNN9XoOJEsnirpG 4rXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703667793; x=1704272593; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o6LKt+ontTXHu1XtoIYFtpLE+AnFf2w4c9A2s2xTblA=; b=Q8DLYEWRWBvQ/+ZHU9zR4y+NgY0gVDZZh9/iqK0O9xzdvDeIRqJN9XgUDKIqrG11J2 edMl9OTrZT47if+Fuvl0jyTeCwJuMwrKJg2tj/pyVcVpzbdfMXUQfdzTaYSveFN1Kz0k ZxRK/XUNM+yPm8yA/l97ixcwMV5HQJprZaf8ZbFydvfnpZ6dWoyvLxZNTny3KV/VTmz0 638t1qXzSw5BYKDxNC8RL2GUYvDmENSp/t5EkFTOZgM7uUIZLwrK2+PRFdnvkC+jfx2H 5sbWuVPHH1NnPgvz09GnHfkqvEAcnFOn/lNkpzxcin6SsOo+u/G+b5FCc8mjrE0f3Ufz U3uA== X-Gm-Message-State: AOJu0Yxau2fo5YzKmNSvFomeoPa7g2/j5BQEXCcHEPbew9/s89J1Q/zh F6M+AReMQqsdkpTwNq9v+B0= X-Google-Smtp-Source: AGHT+IG8mHhNfgK90bB/CfsGqDGPIVH5z9muWmeD4Vnd+0RauHcX1m+CzQx0/hAokpmViinA+RwFjA== X-Received: by 2002:a05:600c:3c90:b0:40c:2d78:c766 with SMTP id bg16-20020a05600c3c9000b0040c2d78c766mr4563795wmb.134.1703667793645; Wed, 27 Dec 2023 01:03:13 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id c9-20020a056000104900b003368849129dsm13616525wrx.15.2023.12.27.01.03.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 01:03:13 -0800 (PST) From: Christian Marangi To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , Jacek Anaszewski , =?utf-8?q?Fern=C3=A1ndez_Roj?= =?utf-8?q?as?= , Sven Schwermer , Christian Marangi , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Cc: Rob Herring Subject: [net-next PATCH v5 4/5] dt-bindings: net: Document QCA808x PHYs Date: Wed, 27 Dec 2023 10:02:30 +0100 Message-Id: <20231227090231.4246-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231227090231.4246-1-ansuelsmth@gmail.com> References: <20231227090231.4246-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_010315_500456_713DB0E0 X-CRM114-Status: GOOD ( 16.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add Documentation for QCA808x PHYs for the additional LED configuration for this PHY. Signed-off-by: Christian Marangi Reviewed-by: Rob Herring --- Changes v4: - Add Reviewed-by tag Changes v3: - Use compatible instead of select - Out of RFC Changes v2: - Fix License warning from checkpatch - Drop redundant Description phrase - Improve commit tile - Drop special property (generalized) .../devicetree/bindings/net/qca,qca808x.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/qca,qca808x.yaml diff --git a/Documentation/devicetree/bindings/net/qca,qca808x.yaml b/Documentation/devicetree/bindings/net/qca,qca808x.yaml new file mode 100644 index 000000000000..e2552655902a --- /dev/null +++ b/Documentation/devicetree/bindings/net/qca,qca808x.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/qca,qca808x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm Atheros QCA808X PHY + +maintainers: + - Christian Marangi + +description: + QCA808X PHYs can have up to 3 LEDs attached. + All 3 LEDs are disabled by default. + 2 LEDs have dedicated pins with the 3rd LED having the + double function of Interrupt LEDs/GPIO or additional LED. + + By default this special PIN is set to LED function. + +allOf: + - $ref: ethernet-phy.yaml# + +properties: + compatible: + enum: + - ethernet-phy-id004d.d101 + +unevaluatedProperties: false + +examples: + - | + #include + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethernet-phy@0 { + compatible = "ethernet-phy-id004d.d101"; + reg = <0>; + + leds { + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + color = ; + function = LED_FUNCTION_WAN; + default-state = "keep"; + }; + }; + }; + }; From patchwork Wed Dec 27 09:02:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13505234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ABF7AC46CD4 for ; Wed, 27 Dec 2023 09:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P8/Vo3bnvaM6CNk1jD4/KgtQx8DcQANPafeGuT45tes=; b=dh/Qgl8+8g4NoV qAItgts0roVCrO4avhQ5hGq4g1yakh7q3VveW58AgYnMcDdGaYdo/lNTZjD5tqu+G8AwvvmcNGvFv s9Iuj2GjF727ivtHhRXZoIg9pvu+R7OZC8U9GOsW+77gm0P1ZR01NuDl99AUY4yFgsLEIe9ZWknum AkQeMSw5HsBRPUyTRJPuaPIb2uBV/vs3fIqbbH8IGe6zWPriZoouhMOeV/LwuH9iibY2zcnWVIKHT reWs1+Dukr6+67UbmxNOCss79hb0jHbLSn9Zx9mKOc9871WLd7CK8Bn+/LGZh60L/VgFl4v7NLcnL By/Q/a63jkfazQwCnOxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rIPpC-00EFZo-1c; Wed, 27 Dec 2023 09:03:38 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rIPos-00EFQa-0Z for linux-arm-kernel@lists.infradead.org; Wed, 27 Dec 2023 09:03:21 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3368fe4dcb1so3712091f8f.1 for ; Wed, 27 Dec 2023 01:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703667796; x=1704272596; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rE3ALPeUuEqamhSlDxXFJPlshirPh4FE3yKiEyXjTRU=; b=LHyY15x4kWbhRfA0BXpP36xwpJYqB68om2fCrPZbgZ8VNS8vw7cKWFr42VgneCFXh9 uENFQ92LyLMiFCxR2xG01XzsbiPXvLIU3rE7hYrxbiBXVfFnMFHpriii8kuNpL0AFLoQ kg9439/JjVFDgI2GgwNn/XGJ0z/+FZQgqrfQJsqoRDBwpi3ZgSflFe1ml9Xk20c49HbH kHOifJbf4LqA6IE92DiU3fqmH6CkaOekWvnwvFhg0I1hPi/Vrbo0byh8Ekf5/6D7/H3A 6Kgex6FYBfefsoyHImfZOErzELZv5BItxyHniQ+FBhtgLGVGdBA7KzGYQAYoc/8ZsGcA qaEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703667796; x=1704272596; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rE3ALPeUuEqamhSlDxXFJPlshirPh4FE3yKiEyXjTRU=; b=RwtU7Cp4yPWTQXAGYMNdFAdeAIkTiANgLZu5H+KUfEWdBy2trNNNOrPjycW8/mbzwg wiPqsCWNe4KhCyDnIFg8xX+Vca5yAcsVoG7M4u1O8Obng1KhZJ6FMdT99uq8xyIgOIgw B3So+TBXAqxey4mBKot73Q04q3bl54Genxz2ccwWcegCDDbd2gTQwET0RXw/70VmDkff Ivg77X7Q9Geb+bhD6KHRGFpEkDejtNviYOBmM4ixRNp2bHFDoKK0c3NziBkxZrufKvBa eSk54TGjSlvvFt3Sfb/P4lwtCcdwly7+8REmTXaB3iQndkHfYs5Dv2yu7mYGC3jVyJYu 5WPQ== X-Gm-Message-State: AOJu0YwNFV8u5xtRjsqZoWRjpOYO1Tn+x4X2jkCbSdOQOfIuI9MVydIY XzxDEsjtBorpPV9MPJy89TU= X-Google-Smtp-Source: AGHT+IFk9oHEYSIe4gNk982lbgEtvH/Ml7rU5vc8KiA01xtAzlGFQ2OdSc53wQNwsKEeQWvn/NGIwQ== X-Received: by 2002:adf:e942:0:b0:336:bf6a:50f9 with SMTP id m2-20020adfe942000000b00336bf6a50f9mr2272323wrn.64.1703667796140; Wed, 27 Dec 2023 01:03:16 -0800 (PST) Received: from localhost.localdomain (host-95-250-248-68.retail.telecomitalia.it. [95.250.248.68]) by smtp.googlemail.com with ESMTPSA id c9-20020a056000104900b003368849129dsm13616525wrx.15.2023.12.27.01.03.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 01:03:15 -0800 (PST) From: Christian Marangi To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , William Zhang , Anand Gore , Kursad Oney , Florian Fainelli , =?utf-8?b?UmFmYcWCIE1p?= =?utf-8?b?xYJlY2tp?= , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Heiner Kallweit , Russell King , Jacek Anaszewski , =?utf-8?q?Fern=C3=A1ndez_Roj?= =?utf-8?q?as?= , Sven Schwermer , Christian Marangi , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [net-next PATCH v5 5/5] net: phy: at803x: add LED support for qca808x Date: Wed, 27 Dec 2023 10:02:31 +0100 Message-Id: <20231227090231.4246-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231227090231.4246-1-ansuelsmth@gmail.com> References: <20231227090231.4246-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231227_010318_222183_1D012FFE X-CRM114-Status: GOOD ( 28.76 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add LED support for QCA8081 PHY. Documentation for this LEDs PHY is very scarce even with NDA access to Documentation for OEMs. Only the blink pattern are documented and are very confusing most of the time. No documentation is present about forcing the LED on/off or to always blink. Those settings were reversed by poking the regs and trying to find the correct bits to trigger these modes. Some bits mode are not clear and maybe the documentation option are not 100% correct. For the sake of LED support the reversed option are enough to add support for current LED APIs. Supported HW control modes are: - tx - rx - link10 - link100 - link1000 - half_duplex - full_duplex Also add support for LED polarity set to set LED polarity to active high or low. QSDK sets this value to high by default but PHY reset value doesn't have this enabled by default. QSDK also sets 2 additional bits but their usage is not clear, info about this is added in the header. It was verified that for correct function of the LED if active high is needed, only BIT 6 is needed. Signed-off-by: Christian Marangi --- Changes v5: - Rework to polarity option bitmap - Rafactor with new finding from further reverse Changes v4: - Rework to polarity option (for marvell10g series support) - Rework logic to enforce single PHY polarity mode Changes v3: - Out of RFC - Drop link_25000 and add TODO commends waiting for the netdev trigger thing to be merged (I will take care of sending a followup patch later) Changes v2: - Move to new led_polarity_set implementation - Drop special probe drivers/net/phy/at803x.c | 333 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 333 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index d5dc927618ab..bc9a219fd499 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -272,6 +272,87 @@ #define QCA808X_CDT_STATUS_STAT_OPEN 2 #define QCA808X_CDT_STATUS_STAT_SHORT 3 +#define QCA808X_MMD7_LED_GLOBAL 0x8073 +#define QCA808X_LED_BLINK_1 GENMASK(11, 6) +#define QCA808X_LED_BLINK_2 GENMASK(5, 0) +/* Values are the same for both BLINK_1 and BLINK_2 */ +#define QCA808X_LED_BLINK_FREQ_MASK GENMASK(5, 3) +#define QCA808X_LED_BLINK_FREQ_2HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x0) +#define QCA808X_LED_BLINK_FREQ_4HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x1) +#define QCA808X_LED_BLINK_FREQ_8HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x2) +#define QCA808X_LED_BLINK_FREQ_16HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x3) +#define QCA808X_LED_BLINK_FREQ_32HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x4) +#define QCA808X_LED_BLINK_FREQ_64HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x5) +#define QCA808X_LED_BLINK_FREQ_128HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x6) +#define QCA808X_LED_BLINK_FREQ_256HZ FIELD_PREP(QCA808X_LED_BLINK_FREQ_MASK, 0x7) +#define QCA808X_LED_BLINK_DUTY_MASK GENMASK(2, 0) +#define QCA808X_LED_BLINK_DUTY_50_50 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x0) +#define QCA808X_LED_BLINK_DUTY_75_25 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x1) +#define QCA808X_LED_BLINK_DUTY_25_75 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x2) +#define QCA808X_LED_BLINK_DUTY_33_67 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x3) +#define QCA808X_LED_BLINK_DUTY_67_33 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x4) +#define QCA808X_LED_BLINK_DUTY_17_83 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x5) +#define QCA808X_LED_BLINK_DUTY_83_17 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x6) +#define QCA808X_LED_BLINK_DUTY_8_92 FIELD_PREP(QCA808X_LED_BLINK_DUTY_MASK, 0x7) + +#define QCA808X_MMD7_LED2_CTRL 0x8074 +#define QCA808X_MMD7_LED2_FORCE_CTRL 0x8075 +#define QCA808X_MMD7_LED1_CTRL 0x8076 +#define QCA808X_MMD7_LED1_FORCE_CTRL 0x8077 +#define QCA808X_MMD7_LED0_CTRL 0x8078 +#define QCA808X_MMD7_LED_CTRL(x) (0x8078 - ((x) * 2)) + +/* LED hw control pattern is the same for every LED */ +#define QCA808X_LED_PATTERN_MASK GENMASK(15, 0) +#define QCA808X_LED_SPEED2500_ON BIT(15) +#define QCA808X_LED_SPEED2500_BLINK BIT(14) +/* Follow blink trigger even if duplex or speed condition doesn't match */ +#define QCA808X_LED_BLINK_CHECK_BYPASS BIT(13) +#define QCA808X_LED_FULL_DUPLEX_ON BIT(12) +#define QCA808X_LED_HALF_DUPLEX_ON BIT(11) +#define QCA808X_LED_TX_BLINK BIT(10) +#define QCA808X_LED_RX_BLINK BIT(9) +#define QCA808X_LED_TX_ON_10MS BIT(8) +#define QCA808X_LED_RX_ON_10MS BIT(7) +#define QCA808X_LED_SPEED1000_ON BIT(6) +#define QCA808X_LED_SPEED100_ON BIT(5) +#define QCA808X_LED_SPEED10_ON BIT(4) +#define QCA808X_LED_COLLISION_BLINK BIT(3) +#define QCA808X_LED_SPEED1000_BLINK BIT(2) +#define QCA808X_LED_SPEED100_BLINK BIT(1) +#define QCA808X_LED_SPEED10_BLINK BIT(0) + +#define QCA808X_MMD7_LED0_FORCE_CTRL 0x8079 +#define QCA808X_MMD7_LED_FORCE_CTRL(x) (0x8079 - ((x) * 2)) + +/* LED force ctrl is the same for every LED + * No documentation exist for this, not even internal one + * with NDA as QCOM gives only info about configuring + * hw control pattern rules and doesn't indicate any way + * to force the LED to specific mode. + * These define comes from reverse and testing and maybe + * lack of some info or some info are not entirely correct. + * For the basic LED control and hw control these finding + * are enough to support LED control in all the required APIs. + * + * On doing some comparison with implementation with qca807x, + * it was found that it's 1:1 equal to it and confirms all the + * reverse done. It was also found further specification with the + * force mode and the blink modes. + */ +#define QCA808X_LED_FORCE_EN BIT(15) +#define QCA808X_LED_FORCE_MODE_MASK GENMASK(14, 13) +#define QCA808X_LED_FORCE_BLINK_1 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x3) +#define QCA808X_LED_FORCE_BLINK_2 FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x2) +#define QCA808X_LED_FORCE_ON FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x1) +#define QCA808X_LED_FORCE_OFF FIELD_PREP(QCA808X_LED_FORCE_MODE_MASK, 0x0) + +#define QCA808X_MMD7_LED_POLARITY_CTRL 0x901a +/* QSDK sets by default 0x46 to this reg that sets BIT 6 for + * LED to active high. It's not clear what BIT 3 and BIT 4 does. + */ +#define QCA808X_LED_ACTIVE_HIGH BIT(6) + /* QCA808X 1G chip type */ #define QCA808X_PHY_MMD7_CHIP_TYPE 0x901d #define QCA808X_PHY_CHIP_TYPE_1G BIT(0) @@ -317,6 +398,7 @@ struct at803x_priv { struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; u64 stats[ARRAY_SIZE(qca83xx_hw_stats)]; + int led_polarity_mode; }; struct at803x_context { @@ -677,6 +759,9 @@ static int at803x_probe(struct phy_device *phydev) if (!priv) return -ENOMEM; + /* Init LED polarity mode to -1 */ + priv->led_polarity_mode = -1; + phydev->priv = priv; ret = at803x_parse_dt(phydev); @@ -2152,6 +2237,248 @@ static void qca808x_link_change_notify(struct phy_device *phydev) QCA8081_PHY_FIFO_RSTN, phydev->link ? QCA8081_PHY_FIFO_RSTN : 0); } +static int qca808x_led_parse_netdev(struct phy_device *phydev, unsigned long rules, + u16 *offload_trigger) +{ + /* TODO: add link_2500 when added to netdev trigger */ + /* Parsing specific to netdev trigger */ + if (test_bit(TRIGGER_NETDEV_TX, &rules)) + *offload_trigger |= QCA808X_LED_TX_BLINK; + if (test_bit(TRIGGER_NETDEV_RX, &rules)) + *offload_trigger |= QCA808X_LED_RX_BLINK; + if (test_bit(TRIGGER_NETDEV_LINK_10, &rules)) + *offload_trigger |= QCA808X_LED_SPEED10_ON; + if (test_bit(TRIGGER_NETDEV_LINK_100, &rules)) + *offload_trigger |= QCA808X_LED_SPEED100_ON; + if (test_bit(TRIGGER_NETDEV_LINK_1000, &rules)) + *offload_trigger |= QCA808X_LED_SPEED1000_ON; + if (test_bit(TRIGGER_NETDEV_HALF_DUPLEX, &rules)) + *offload_trigger |= QCA808X_LED_HALF_DUPLEX_ON; + if (test_bit(TRIGGER_NETDEV_FULL_DUPLEX, &rules)) + *offload_trigger |= QCA808X_LED_FULL_DUPLEX_ON; + + if (rules && !*offload_trigger) + return -EOPNOTSUPP; + + /* Enable BLINK_CHECK_BYPASS by default to make the LED + * blink even with duplex or speed mode not enabled. + */ + *offload_trigger |= QCA808X_LED_BLINK_CHECK_BYPASS; + + return 0; +} + +static int qca808x_led_hw_control_enable(struct phy_device *phydev, u8 index) +{ + u16 reg; + + if (index > 2) + return -EINVAL; + + reg = QCA808X_MMD7_LED_FORCE_CTRL(index); + + return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_FORCE_EN); +} + +static int qca808x_led_hw_is_supported(struct phy_device *phydev, u8 index, + unsigned long rules) +{ + u16 offload_trigger = 0; + + if (index > 2) + return -EINVAL; + + return qca808x_led_parse_netdev(phydev, rules, &offload_trigger); +} + +static int qca808x_led_hw_control_set(struct phy_device *phydev, u8 index, + unsigned long rules) +{ + u16 reg, offload_trigger = 0; + int ret; + + if (index > 2) + return -EINVAL; + + reg = QCA808X_MMD7_LED_CTRL(index); + + ret = qca808x_led_parse_netdev(phydev, rules, &offload_trigger); + if (ret) + return ret; + + ret = qca808x_led_hw_control_enable(phydev, index); + if (ret) + return ret; + + return phy_modify_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_PATTERN_MASK, + offload_trigger); +} + +static bool qca808x_led_hw_control_status(struct phy_device *phydev, u8 index) +{ + u16 reg; + int val; + + if (index > 2) + return false; + + reg = QCA808X_MMD7_LED_FORCE_CTRL(index); + + val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); + + return !(val & QCA808X_LED_FORCE_EN); +} + +static int qca808x_led_hw_control_get(struct phy_device *phydev, u8 index, + unsigned long *rules) +{ + u16 reg; + int val; + + if (index > 2) + return -EINVAL; + + /* Check if we have hw control enabled */ + if (qca808x_led_hw_control_status(phydev, index)) + return -EINVAL; + + reg = QCA808X_MMD7_LED_CTRL(index); + + /* TODO: add link_2500 when added to netdev trigger */ + val = phy_read_mmd(phydev, MDIO_MMD_AN, reg); + if (val & QCA808X_LED_TX_BLINK) + set_bit(TRIGGER_NETDEV_TX, rules); + if (val & QCA808X_LED_RX_BLINK) + set_bit(TRIGGER_NETDEV_RX, rules); + if (val & QCA808X_LED_SPEED10_ON) + set_bit(TRIGGER_NETDEV_LINK_10, rules); + if (val & QCA808X_LED_SPEED100_ON) + set_bit(TRIGGER_NETDEV_LINK_100, rules); + if (val & QCA808X_LED_SPEED1000_ON) + set_bit(TRIGGER_NETDEV_LINK_1000, rules); + if (val & QCA808X_LED_HALF_DUPLEX_ON) + set_bit(TRIGGER_NETDEV_HALF_DUPLEX, rules); + if (val & QCA808X_LED_FULL_DUPLEX_ON) + set_bit(TRIGGER_NETDEV_FULL_DUPLEX, rules); + + return 0; +} + +static int qca808x_led_hw_control_reset(struct phy_device *phydev, u8 index) +{ + u16 reg; + + if (index > 2) + return -EINVAL; + + reg = QCA808X_MMD7_LED_CTRL(index); + + return phy_clear_bits_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_PATTERN_MASK); +} + +static int qca808x_led_brightness_set(struct phy_device *phydev, + u8 index, enum led_brightness value) +{ + u16 reg; + int ret; + + if (index > 2) + return -EINVAL; + + if (!value) { + ret = qca808x_led_hw_control_reset(phydev, index); + if (ret) + return ret; + } + + reg = QCA808X_MMD7_LED_FORCE_CTRL(index); + + return phy_modify_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK, + QCA808X_LED_FORCE_EN | value ? QCA808X_LED_FORCE_ON : + QCA808X_LED_FORCE_OFF); +} + +static int qca808x_led_blink_set(struct phy_device *phydev, u8 index, + unsigned long *delay_on, + unsigned long *delay_off) +{ + int ret; + u16 reg; + + if (index > 2) + return -EINVAL; + + reg = QCA808X_MMD7_LED_FORCE_CTRL(index); + + /* Set blink to 50% off, 50% on at 4Hz by default */ + ret = phy_modify_mmd(phydev, MDIO_MMD_AN, QCA808X_MMD7_LED_GLOBAL, + QCA808X_LED_BLINK_FREQ_MASK | QCA808X_LED_BLINK_DUTY_MASK, + QCA808X_LED_BLINK_FREQ_256HZ | QCA808X_LED_BLINK_DUTY_50_50); + if (ret) + return ret; + + /* We use BLINK_1 for normal blinking */ + ret = phy_modify_mmd(phydev, MDIO_MMD_AN, reg, + QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_MODE_MASK, + QCA808X_LED_FORCE_EN | QCA808X_LED_FORCE_BLINK_1); + if (ret) + return ret; + + /* We set blink to 4Hz, aka 250ms */ + *delay_on = 250 / 2; + *delay_off = 250 / 2; + + return 0; +} + +static int qca808x_led_polarity_set(struct phy_device *phydev, int index, + unsigned long modes) +{ + struct at803x_priv *priv = phydev->priv; + bool active_low = false; + u32 mode; + int ret; + + for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) { + switch (mode) { + case PHY_LED_ACTIVE_LOW: + active_low = true; + break; + default: + return -EINVAL; + } + } + + /* PHY polarity is global and can't be set per LED. + * To detect this, check if last requested polarity mode + * match the new one. + */ + if (priv->led_polarity_mode >= 0 && + priv->led_polarity_mode != active_low) { + phydev_err(phydev, "PHY polarity is global. Mismatched polarity on different LED\n"); + return -EINVAL; + } + + /* Save the last PHY polarity mode */ + priv->led_polarity_mode = active_low; + + if (active_low) { + ret = phy_clear_bits_mmd(phydev, MDIO_MMD_AN, + QCA808X_MMD7_LED_POLARITY_CTRL, + QCA808X_LED_ACTIVE_HIGH); + } else { + ret = phy_set_bits_mmd(phydev, MDIO_MMD_AN, + QCA808X_MMD7_LED_POLARITY_CTRL, + QCA808X_LED_ACTIVE_HIGH); + } + + return ret; +} + static struct phy_driver at803x_driver[] = { { /* Qualcomm Atheros AR8035 */ @@ -2328,6 +2655,12 @@ static struct phy_driver at803x_driver[] = { .cable_test_start = qca808x_cable_test_start, .cable_test_get_status = qca808x_cable_test_get_status, .link_change_notify = qca808x_link_change_notify, + .led_brightness_set = qca808x_led_brightness_set, + .led_blink_set = qca808x_led_blink_set, + .led_hw_is_supported = qca808x_led_hw_is_supported, + .led_hw_control_set = qca808x_led_hw_control_set, + .led_hw_control_get = qca808x_led_hw_control_get, + .led_polarity_set = qca808x_led_polarity_set, }, }; module_phy_driver(at803x_driver);