From patchwork Wed Jan 3 14:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184859 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5311505dyb; Wed, 3 Jan 2024 15:06:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdJkN9kh3sh0jCMqp0ie40Aw0pbbtKa1rvnOCvKy1bmiv9j+KXHNxHoNHd7bDn4enHS5qQ X-Received: by 2002:a6b:e40d:0:b0:7ba:7c57:f19e with SMTP id u13-20020a6be40d000000b007ba7c57f19emr25908677iog.14.1704323188110; Wed, 03 Jan 2024 15:06:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704323188; cv=none; d=google.com; s=arc-20160816; b=eo12uWiphlIAIEzg2LSWCwSXGXlxfRS1mrdeHPLvAzMZ7emJMQtTQjgpy4xxzOVE75 FwI3yZkiJiTMShc1KdbAULdMTbE1JWoymJMxblyyTI52dWrZ0g/rbX6AuPFBg2eEYIAx zI3OCKyiJbsH/F1xJTG01elnP3Og9FyXk9b7KdOccYwZVKCcFotxKdnh9i0iy8CTrhkw PWAERvq+EMf88Aqk+oS/wGl809x0pG/NwdY7D9xteC+7Tx2+G2fMZnCdzIDN18NESw64 44oZJo3Vzcx6ZBJW82FkTFwGWRyIfF+7WQ5tlmmBdFojZMPzlKcZ4fvSPwIS39cNvDjc /xkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=h5mxLkh2hEgcMvbfMMh1KibA3U7+O5yTNHMAUzMLGy8=; fh=t/rEUYZBrjIVtJtvItkK7O2t2zLyO6TH9UCXgO6Lsag=; b=uN8Be2YsASelQpY9SNfn83XeHcZPIJW7MT00dAwkjqKc07xcgwQ93JEKeHQO6X0uP8 mtTP/GZm1mgJ6WK7b32fWeytXSaPw9XtcyeC1YgTR8+jUL2yCN00m36I6ZH20LiRywZ+ HLbm+AvTrMVZIb48YQ0hH6fgG+4lUtTHvRdMktwmSMiwGEtheePmgObPZUSTjQmxw6DL DcV44bGSsFHkoBSDasi2hOQMb7qRZvcbH+d2ucvqBKzUc+L1v0DoBs2bL0EE0/vsUoIp LPp8B9AJGvGy2ucW7+QXL2Huz4cUQMkT4ES5CWyp+FQQyHt3rYPVaqTMyVDGRLuHahbM 6/nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UM9pj0wD; spf=pass (google.com: domain of linux-kernel+bounces-16099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16099-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id by33-20020a056a0205a100b005cddb743bc7si20004985pgb.709.2024.01.03.15.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:06:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=UM9pj0wD; spf=pass (google.com: domain of linux-kernel+bounces-16099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16099-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6F96DB23F15 for ; Wed, 3 Jan 2024 23:05:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E63C9200DD; Wed, 3 Jan 2024 23:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UM9pj0wD" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9B5A1EB4D; Wed, 3 Jan 2024 23:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-40d8991f1acso30176745e9.1; Wed, 03 Jan 2024 15:04:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704323094; x=1704927894; darn=vger.kernel.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=h5mxLkh2hEgcMvbfMMh1KibA3U7+O5yTNHMAUzMLGy8=; b=UM9pj0wDPp7q7hu6peH7kQvotbkNn5y6McrJLMb7zmHdcOwjINfXX1k28C6ADKVdXW DtwlgFLU2WmAwlMzkmI0IRNchcSh9EhI/OPJWw9nZTeaDoH0vOw+AuK0EeuB0tnIrTrG SJ/9Dw6fWWrB85nsBkvhvYvPrTM62yCGFcjuvAjvxjIP8ePO52k/ofyu6hnzS6JrzIxG fAQ6b50Gtq4vjJOimEiVMVWdU1NEcY9qkaxKjwvohvN0NCu7OQ1zHmsmJnsGPK4BGqws RNgS60BqNfZHQMa9yWDwrTkk9F3EJdaZm7BieCkifgfmvJOFX8UVHcUUa/b6se9gdgzT SjoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704323094; x=1704927894; 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=h5mxLkh2hEgcMvbfMMh1KibA3U7+O5yTNHMAUzMLGy8=; b=D5veB5JqOn1rcg9y/6jjqeEtjCPEfC9KWMeIWFhnH/u0JK6WZNU+savDUiaTvDNhFr AVvhYfrATlfqW44QZPnpA70olfIpyDTA+BOgkje/ZjDdINlbov55C8wt7qsgdcgblFW5 Ij1WLiiPvPhjloJ4+cSStdpuqqcxXdZBaG2/Q2eGKk/zCFcfgtsAbFYPvotOMqnUQG1P qFyvPJVHoEI7vx7I8UigpOxifgnOd04I4oWLo099+/5lsVIWjkGB4mDANaGvSC87cCWi xEPaaF6GA5Xfbe8xCsQyF5wkwjbLcg75Cnawh9LKoH3LZcQuIVf6jW8deYri9L1gkuZU NdyA== X-Gm-Message-State: AOJu0YyDL60bN3h+9zGs8mRP603xmVBSBDUE4/OlqUeiFHFCilzjDhkR Dlv9ufWiq2YzNbmw0PpSbv8jeDOnJBY= X-Received: by 2002:a05:600c:474b:b0:40d:7247:2846 with SMTP id w11-20020a05600c474b00b0040d72472846mr5192909wmo.110.1704323093646; Wed, 03 Jan 2024 15:04:53 -0800 (PST) Received: from localhost.localdomain (host-80-116-159-187.retail.telecomitalia.it. [80.116.159.187]) by smtp.googlemail.com with ESMTPSA id w13-20020a05600c474d00b0040c46719966sm3740969wmo.25.2024.01.03.15.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:04:53 -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 v7 1/5] dt-bindings: net: phy: Make LED active-low property common Date: Wed, 3 Jan 2024 15:12:34 +0100 Message-ID: <20240103141251.23446-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103141251.23446-1-ansuelsmth@gmail.com> References: <20240103141251.23446-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787112390919854929 X-GMAIL-MSGID: 1787112390919854929 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 Jan 3 14:12:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5311525dyb; Wed, 3 Jan 2024 15:06:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IGu9WoaMLlwGoJy2ttTFLCDEAYEzsD+Mc2YJvNPrWTxSp8qXWwPXnIrdxYBRSCUny35d9lU X-Received: by 2002:a17:906:3148:b0:a28:7191:b45c with SMTP id e8-20020a170906314800b00a287191b45cmr1565884eje.37.1704323190843; Wed, 03 Jan 2024 15:06:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704323190; cv=none; d=google.com; s=arc-20160816; b=CQ3D9UF7dCs54Hl/kjfj7Omo4OkENYW0dBx5+WzzffJhlyQpNzMHr4ILYiP4IcRm2x GV08m2fQAU85nJOiMDyl8ev2R8lf737j7LJ2xTx+8IaZ6x6MFp28GLs4ZTSruHU4zpig TJM0Ms8c4KKucWCc7alrKQAf5AzSCle8ih8O3PS3KFDZnueSKik/daGwkkKLBf26C4nw 8HuRqpgLvslHbHGsJVRsmFHUbONPvuBXT4KnS2qP5ntcvcSV2Q7bb3M38OhAixx4GZIp V66aPR9/5PFg2wqZaYUsYXrmb7psfb1x7HikoWXm70gCyYuzuZh8v4ApLLikzT7VnAUn YSWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=fQabVWmpmoZU8yQyfqwraJ/6CaCvr56KIOoajwAPETc=; fh=t/rEUYZBrjIVtJtvItkK7O2t2zLyO6TH9UCXgO6Lsag=; b=TaUJZNsUiSwD2ljGZS5TvUlezyFkwIPu2G9Nkw0gnZKlDvvL721V3DAlcS0Qr7Tae4 Jdjh0HarBtEMHzqQi+VWJs6N1gKJncXNXugrV8WhoUWPZFql/LAecNqbE8rBscAqIZs6 Dv+j0SjxR33iarwAkVhAiicA0QSsDRD0DkFjOyVFsrMQ+Gl1ft/wOmD+zL6VfG5ZtFST Hnqle6SshLFj5tKgqyQJevYQdZqYbS5vc0R3w8ZXmEs6sK29zUzqnmKKn3MnBzuLumDf +G28ZO0qPhmhTFFajIKaIcDCQyML54b91oMQMDqhvcdG2WVIwAcMlPnGpdKw8vMYPEME c8KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MxDse3hW; spf=pass (google.com: domain of linux-kernel+bounces-16101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f17-20020a170906139100b00a26a961bda6si10769642ejc.384.2024.01.03.15.06.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:06:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MxDse3hW; spf=pass (google.com: domain of linux-kernel+bounces-16101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4955E1F224B5 for ; Wed, 3 Jan 2024 23:06:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75C55208A8; Wed, 3 Jan 2024 23:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MxDse3hW" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E78C2030C; Wed, 3 Jan 2024 23:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40d2e56f3a6so5832835e9.1; Wed, 03 Jan 2024 15:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704323098; x=1704927898; darn=vger.kernel.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=fQabVWmpmoZU8yQyfqwraJ/6CaCvr56KIOoajwAPETc=; b=MxDse3hWvNUKQcWTfGWcSkDMqkngH3VYgZlEkZFrgbt3j0DjM7GDw9frQboyT0J+Yd dgmiaBUVUbkd2TVcbDpSE3RSYsCkONzFQknw3h8HPSfhlQBisLFjSHRW6Nzicnib9yub O2sKciBHGgW+Nl9Kfog29FxRm+0bU2QM1X3aiQZFHL3/b5O0IYibngSj60Mh0Na7SDlF yDtK0Cp4jKPKYPAh2Lvg7EiC20Nw5Ig+wN4/P4ebbdWXduwrnN7FPxUfXCajpny4hnKY PnkYDODkzCRKHR0WgUkzkER9+QC9stMg/moDGfypuv29zBlQVIneUIN3JTj0V7n7sLIw rD9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704323098; x=1704927898; 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=fQabVWmpmoZU8yQyfqwraJ/6CaCvr56KIOoajwAPETc=; b=bvt10lEgyAOt4AiA1GYk9NaOoAJL1X1AGa+yhgIE1Bd01ALU3IY/wL6j1wBQKxQ06F e2vn7SKIxSkuLBGuxAlhJS7rpHZPr+9desuG7AQ5Y9poLcO0sooBzyEweFFoBC8Vg2D+ wgHcM7UQ9bQY5Qu/B7SN/ACB2Dyh1CrEB5Cp+Pa+GDijYnxRDVOi7uLnZoP5OhJY7ZBw G+RB1GPRLJpulmuCFYvhUmdF+mtKZeXTjpK7GAzJHr7/BjQNFBllBw8NaFPGT0MldC2w te07kPEnW4FOx3IZwTLZPv8lN3hnOdo3cpIU6niDuRLBAG6kueYtzHE+jyGq777OjMYV QFVA== X-Gm-Message-State: AOJu0YzG+cwnobxcOc8K5L5hWMgbXj1AtA+nPdDLVnvsgjg3sbKNONxv aYNFUvbP7wcszHq3OacEkPA= X-Received: by 2002:a05:600c:2a4e:b0:40d:8f7a:9f9e with SMTP id x14-20020a05600c2a4e00b0040d8f7a9f9emr934834wme.73.1704323098376; Wed, 03 Jan 2024 15:04:58 -0800 (PST) Received: from localhost.localdomain (host-80-116-159-187.retail.telecomitalia.it. [80.116.159.187]) by smtp.googlemail.com with ESMTPSA id w13-20020a05600c474d00b0040c46719966sm3740969wmo.25.2024.01.03.15.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:04:57 -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 v7 3/5] net: phy: add support for PHY LEDs polarity modes Date: Wed, 3 Jan 2024 15:12:36 +0100 Message-ID: <20240103141251.23446-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103141251.23446-1-ansuelsmth@gmail.com> References: <20240103141251.23446-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787112394230506564 X-GMAIL-MSGID: 1787112394230506564 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 1e595762afea..437a1c6046ab 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3152,6 +3152,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; @@ -3169,6 +3170,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 ac22b8e28a85..da0a15a6d638 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -860,6 +860,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 * @@ -1153,6 +1162,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 Jan 3 14:12:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5311996dyb; Wed, 3 Jan 2024 15:07:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOWmNpRVumTBDdSKT9U+F+KLP1vQiXVc5zNEocnHGHkyZZFUKWRmrfbtVD1EAsgEbiV4Ly X-Received: by 2002:a05:6a20:8e09:b0:199:ded:6eb5 with SMTP id y9-20020a056a208e0900b001990ded6eb5mr61716pzj.84.1704323256527; Wed, 03 Jan 2024 15:07:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704323256; cv=none; d=google.com; s=arc-20160816; b=yDRPLHitQkiOpQD9mp2EYMiKEJbIalvod6R+iyyLV90YLNCM5Sa6dO29Tg6kVyMItN ry+HHARc2wpU5DynNr710RQxj1zHgazEGMQ87YSuS1qHySHH3wgb3vSOpVZOvU9kxk2w kwcL4eXnnIgHQAGThgHmBSsYmhtrFmyOA1S+RVnlokQfTWPZYxLAk7bzyKS9A2mwlE8Q G8mSNWJutbqxmidWbzEDiOmFZsNzdLJnuuV5vokycdKt0r/DttOnDP348THeqaB0YU8l ImneHKJTZC55ScDGyU7MDfXvMveGJMPcAL1+umzO6WMeATD11Nnzsua5WhfSRDpK2CAg mEug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Y5KF7aYsnQjm8O6McJy/qfQDXWU9jFx2zhlXwRq6wUk=; fh=j0L8y0dZVS02WChc7Vt2DURt1HbUN50bnOhhpNDzNJY=; b=ybT/mHbsf+vQNLHuXla+RhZBHbrFW/rSNsLCU7JLjT3LYoom03LVao61PSQRmP8xty JxCldkdqE7BOX0l/1WQSpZSP9LBH4/ULBGBZAAXDSStNdApZtXIQ944/6II+M5bTo22k lJuYUUCvQ6rcofgJBoiK7ZnmjOmSmyMRTuygYavWFWpD/QUfWU0sriVJCr3EQQ/L1Pco KjNUkZ0LoBQ1mfWAOV7Q95x5GzSKikQCornDUn2a2TeaRBPHwaW/rfGcnwfYuoH9i/r6 zVxQz0hDX1B3r6dwW3wsw3xB1VpsFdoEY8hdKbK98A7WGiZHOX+vhJYqNgMFqy2zwH0F WY7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HlNGmmiM; spf=pass (google.com: domain of linux-kernel+bounces-16102-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id by33-20020a056a0205a100b005cddb743bc7si20004985pgb.709.2024.01.03.15.07.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:07:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16102-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HlNGmmiM; spf=pass (google.com: domain of linux-kernel+bounces-16102-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 98E19B24333 for ; Wed, 3 Jan 2024 23:06:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA10320B1B; Wed, 3 Jan 2024 23:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HlNGmmiM" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB99C208AE; Wed, 3 Jan 2024 23:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40d88fff7faso27458255e9.3; Wed, 03 Jan 2024 15:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704323101; x=1704927901; darn=vger.kernel.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=Y5KF7aYsnQjm8O6McJy/qfQDXWU9jFx2zhlXwRq6wUk=; b=HlNGmmiMar+TmE9+Et6dmNsoqL9+OPkjfEYDBe8zDiVTjJTRUtEjg3skgDKRaJZeL1 /yttE9CtJ72PC0iOpYkyueOE3RJUZEzifYpH2kMvRwWf93jWzZcIXv8maZhQPPrLAFqu PU5KvtybRWHXZ7NvM1rhBTP4fzu3zrkIPIpjd39CTx07DTridk2FMgBcQClUMTgRGSwI w5T1l3DoYCSydMYa6WWvA5hNHsjo5veEQUdsdbmw8ibPYbheP/zdEiphZPf318uLw3am t4WKQf93QPYno4HzTs1nOfVAfJ7uAEtHRwTnM9keaks+bXn0U7NUJDY9PilqJkpxbSp+ 2opw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704323101; x=1704927901; 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=Y5KF7aYsnQjm8O6McJy/qfQDXWU9jFx2zhlXwRq6wUk=; b=U/2ij5x2tc/IpSela3w9BjZkNtwFDKUcAFNpXzVE09Yu4b9aIvSfUQWOs1jR9sciUu Fpmx7HwqrKHcfXpqW9ZQqv/VOuxX+cdeMFcrhfdeOKYOZPnGDwofVr5K4dnYSxxdynBG r3cgfxFNRU0sttzG8ZFdtTnP0KH2cXmU5qE/Aaf4pDZX8e0Q0fDcsBTQmhlFbzy9mSUm +TRW8/AFuyPvfg/7pncpUCFAsOBGWEM/Fnczb7re+VDTuPEFpaw3sdskozIYpcm1yv6B AyPh7r2qMcTBJ5q5jC4fd/zo/BNHuOs5Lq6Z4Cg4vzdhPaOA6NazzfWDxBDISRctGo32 4M+g== X-Gm-Message-State: AOJu0YwtOZumY1aLbVo1wwZt6teE2ZUDf6Tdb+RLnj7CRMY6lujyeva3 6VXr9xAsJTaOxSFH3KA/sno= X-Received: by 2002:a05:600c:4fc1:b0:40d:5db1:7c72 with SMTP id o1-20020a05600c4fc100b0040d5db17c72mr2780914wmq.95.1704323100808; Wed, 03 Jan 2024 15:05:00 -0800 (PST) Received: from localhost.localdomain (host-80-116-159-187.retail.telecomitalia.it. [80.116.159.187]) by smtp.googlemail.com with ESMTPSA id w13-20020a05600c474d00b0040c46719966sm3740969wmo.25.2024.01.03.15.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:05:00 -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 v7 4/5] dt-bindings: net: Document QCA808x PHYs Date: Wed, 3 Jan 2024 15:12:37 +0100 Message-ID: <20240103141251.23446-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103141251.23446-1-ansuelsmth@gmail.com> References: <20240103141251.23446-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787112463099022444 X-GMAIL-MSGID: 1787112463099022444 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 Jan 3 14:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 184861 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5311841dyb; Wed, 3 Jan 2024 15:07:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUpqOQ92alm2IH2ipeTsOGKLhCrIYlBw9jQPRhKncOCZZQDTjDPSR7UjzQXcwcE0pQa1Oj X-Received: by 2002:a17:906:b1da:b0:a27:b251:e17f with SMTP id bv26-20020a170906b1da00b00a27b251e17fmr1649242ejb.65.1704323234457; Wed, 03 Jan 2024 15:07:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704323234; cv=none; d=google.com; s=arc-20160816; b=tHNVQ6oPaxc57twQt+iiPvQgIhTLoG34vZpIBNcaKgwsji4w8OYlvq+VlYV5adlnu2 uPfKwc2QqaQifGzfM+ehh8xohf7qhK/ZgIYKMdk8Eecb91/pZsKugvdHHfSms+ilF7Ht z8l/b19d/tmV1CM2G/tQJWqUQYbx0aVExtvuZy/riG/pMMco7lO2SpT5enaFGmqU0mbY GqpMcrRPspKeHDtEUmohoH0SC6dWxGDgIaIn9g1NstXYX6sAZrpOPxrLhfb8IDCxTjAH XP8qhdjmEUghRIvPcDVWaUjj6JJVAu2vn6IEqqTRZLjygr+4P98XaLI/k2r2DciQccqX h+3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=ZqPAgEt1wsWwkIB1xYnt0KsYR+M4zDduKTHLIHm/++w=; fh=t/rEUYZBrjIVtJtvItkK7O2t2zLyO6TH9UCXgO6Lsag=; b=zSZ9X+Rlwn3kdMfCRw6Rn9tj9/uw0m9qnwPl0JzpbpWWCq9+ANkYa9sjjZwpkch98B zgjoFzXJqgPvuWXioqvMXXAViYeifEVpYTXw25UWDhyR9O6YgM2DcefV+pfMoabSYqs2 k3dLnR7piO1IYbxifUCtp8FEsqOj7NE5KU/Sro76v/rUxfK0Edrk/fpmgeSQQSI22zWg RMo9TUnL/3iWir5KBWZgF+Zrg4ykXWYlUXdgN4zpIrZr/23hFpc+4ZV6Py+7yel9RyWV wER2MEH2OriJfEKlJUXf2S+qQykJcDF9TOHvAHO0tdAlEHwkCWG+45d9NZsiEfFAdKD3 qApw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Rt6A90/9"; spf=pass (google.com: domain of linux-kernel+bounces-16103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r18-20020a170906281200b00a2471c2c393si11469761ejc.624.2024.01.03.15.07.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:07:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="Rt6A90/9"; spf=pass (google.com: domain of linux-kernel+bounces-16103-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16103-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DFE8C1F248D3 for ; Wed, 3 Jan 2024 23:07:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C759520DC4; Wed, 3 Jan 2024 23:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rt6A90/9" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2834020B01; Wed, 3 Jan 2024 23:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-40d4a222818so5808695e9.0; Wed, 03 Jan 2024 15:05:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704323103; x=1704927903; darn=vger.kernel.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=ZqPAgEt1wsWwkIB1xYnt0KsYR+M4zDduKTHLIHm/++w=; b=Rt6A90/9/Wu+szWDHKYZaYNVQIUdAF3LolqxOyMAYU5jUPOpIL3BBkhKmW5r/1jZI/ nfTS5oUwYM6TW1En75gsZJ06MBdSK3M0MmyIv1PU7odQuZNhLabI0N5npJu8Vr2gw+p0 wmUhajuBS+cT6aRGD9Djo90nvwwqzwuOxeAbVcq6ScHz9ek0TavUgCVPYHY86IFNVW+g qqGdS7ocC6FMmXbu9+lnxCSt6ceb7Ehx2G1/4OEu3FRlkL6mIEYShVc50RF79zzIt1er 8LZe7Za3teSrdDql23BTSzCGDUN6kD+KbMWLxhlBfuuYfmPT87FU3B0ChqMBZwIz7jFL V2Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704323103; x=1704927903; 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=ZqPAgEt1wsWwkIB1xYnt0KsYR+M4zDduKTHLIHm/++w=; b=Jl1feUy2WzVuuBhgK7gHX9B9N6QDWOBGBcUThK+bMpwC48mQronwzMN6Hleyvf4m+Y WmX3fatSlk9UUWsl35Rjs8Ig2B+WBlvciNpMAq78FM35ZlP8DLOFvsEsC9+4MkE0IxDO 3ULk11/iurNLgHqi193lujxQPbvLrB9rozYQsdT7Vi/QfWlpxVrW2kxaxPlYtEOMqTDW eAXq5S2DJ1VyKmH8DnPW+zquypwL354ZP1kpX794vkvoxttASN2Bt7TeNUFtdRMCjbX+ /Jl/QlMcT+f8fWrAFtwUefYvtJXM+/4zVCHnm0HOev1+aArOCwr3/UEty64QdU8QUiGP 4bNA== X-Gm-Message-State: AOJu0YxKmcMWoZU3pCHaGQ3e4G1YNLS5uWQ38ZQmWGgdL99vs4vjZ9wv gR/mQSgLwo2J0JiR9lLiswA= X-Received: by 2002:a7b:ce0e:0:b0:40d:310c:b445 with SMTP id m14-20020a7bce0e000000b0040d310cb445mr934258wmc.176.1704323103171; Wed, 03 Jan 2024 15:05:03 -0800 (PST) Received: from localhost.localdomain (host-80-116-159-187.retail.telecomitalia.it. [80.116.159.187]) by smtp.googlemail.com with ESMTPSA id w13-20020a05600c474d00b0040c46719966sm3740969wmo.25.2024.01.03.15.05.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 15:05:02 -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 v7 5/5] net: phy: at803x: add LED support for qca808x Date: Wed, 3 Jan 2024 15:12:38 +0100 Message-ID: <20240103141251.23446-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103141251.23446-1-ansuelsmth@gmail.com> References: <20240103141251.23446-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787112440021483823 X-GMAIL-MSGID: 1787112440021483823 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 v7: - Improve set polarity settings (Suggested by Russell) Changes v6: - Rebase on top of net-next 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 | 326 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 326 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index aaf6c654aaed..0218d75efb56 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); @@ -2161,6 +2246,241 @@ static void qca808x_link_change_notify(struct phy_device *phydev) 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; + + return phy_modify_mmd(phydev, MDIO_MMD_AN, + QCA808X_MMD7_LED_POLARITY_CTRL, + QCA808X_LED_ACTIVE_HIGH, + active_low ? 0 : QCA808X_LED_ACTIVE_HIGH); +} + static struct phy_driver at803x_driver[] = { { /* Qualcomm Atheros AR8035 */ @@ -2337,6 +2657,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);