From patchwork Sat Oct 5 16:24:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13823373 X-Patchwork-Delegate: kuba@kernel.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6BD7155382; Sat, 5 Oct 2024 16:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145480; cv=none; b=fZ56M69y2oaEG1bTOGMWGJyrbEwqP9Rvl2iLw+/BJt6W94imDeURj2UtEex1N1ezD9CO+3v5yFN7T0jETWFLeJ/d2lEJ/2vEE+mDb+nQAC+KLOCwf8V2PT5kWNktO7c+ws+F7Q2hgFPo3hGXnnHNLN+PHm+6wcJPjU23H+dfBFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145480; c=relaxed/simple; bh=Pz6y3RVpUOlfgcBuail+i/YSJfZ2G/ZQCi1nZWUTkEw=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=n7upFb52VASRQsms395rN/fGmsEWpvHeZ3IPGnuWSP7WIkX7i4HlQ2k3DLfRvCHskd/9XgohHkVQNt7C5pEGZvYYc9MkX+aVceon6xk4onX2B9MJf23J7/YNFG21neR40wFpqfS+b7a768zR/g/gr+vYJo2VhPe+u6BMqCtRuPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98) (envelope-from ) id 1sx7Zw-0000000044D-0vFj; Sat, 05 Oct 2024 16:24:24 +0000 Date: Sat, 5 Oct 2024 17:24:20 +0100 From: Daniel Golle To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xu Liang , Christian Marangi , Bartosz Golaszewski , Daniel Golle , Robert Marko , Russell King , Abhishek Chauhan , Jacek Anaszewski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 1/4] dt-bindings: leds: add 'active-high' property Message-ID: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Patchwork-Delegate: kuba@kernel.org Other than described in commit c94d1783136 ("dt-bindings: net: phy: Make LED active-low property common") the absence of the 'active-low' property means not to touch the polarity settings which are inherited from reset defaults, the bootloader or bootstrap configuration. Hence, in order to override a LED pin being active-high in case of the default, bootloader or bootstrap setting being active-low an additional property 'active-high' is required. Document that property and make it mutually exclusive to the existing 'active-low' property. Signed-off-by: Daniel Golle Reviewed-by: Krzysztof Kozlowski --- Documentation/devicetree/bindings/leds/common.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index bf9a101e4d42..7c3cd7b7412e 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -202,6 +202,12 @@ properties: #trigger-source-cells property in the source node. $ref: /schemas/types.yaml#/definitions/phandle-array + active-high: + type: boolean + description: + Makes LED active high. To turn the LED ON, line needs to be + set to high voltage instead of low. + active-low: type: boolean description: @@ -225,6 +231,14 @@ properties: Maximum timeout in microseconds after which the flash LED is turned off. Required for flash LED nodes with configurable timeout. +allOf: + - if: + required: + - active-low + then: + properties: + active-high: false + additionalProperties: true examples: From patchwork Sat Oct 5 16:24:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13823374 X-Patchwork-Delegate: kuba@kernel.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73A4214A4F7; Sat, 5 Oct 2024 16:25:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145502; cv=none; b=CaaGHyNQCL54eBntg/iQ88jngyUE3D7ZaMidvzXTv5sHyzhNfZ+HVj95B0zySqsBYdrnZVIa3oLP43xRNdL2jX1c9ATLsyQDmEoeUVGn+rPQM0r69nFqY2QUuN8VNDQfzlxUqq/BqrquSqU5yApKfvnplmd9+mtpRKzjHwHvtjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145502; c=relaxed/simple; bh=/eUWtaBY0uWZ/lz1sHWviqJKBLa0Eu6JNXikC033Ej0=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZdSpsZC1Pk8OzeNTlbJqTSxxOhTUKS43i5nAzmETScno99wjOyP9TWniIpNHhYqhuN1zZGFecEAGJAqGHh+5+x719YsTl4imP2o9+xEYlnjtGraq2cZQtTUtWFhH6+ww0otma/zD0QS+tLEMjiLB+DmzPfKnbN7cmfhUvdedi1Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98) (envelope-from ) id 1sx7aQ-0000000044p-1Fzd; Sat, 05 Oct 2024 16:24:54 +0000 Date: Sat, 5 Oct 2024 17:24:50 +0100 From: Daniel Golle To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xu Liang , Christian Marangi , Bartosz Golaszewski , Daniel Golle , Robert Marko , Russell King , Abhishek Chauhan , Jacek Anaszewski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 2/4] net: phy: support 'active-high' property for PHY LEDs Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org In addition to 'active-low' and 'inactive-high-impedance' also support 'active-high' property for PHY LED pin configuration. Signed-off-by: Daniel Golle --- drivers/net/phy/phy_device.c | 2 ++ include/linux/phy.h | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 560e338b307a..df67d9297253 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3357,6 +3357,8 @@ static int of_phy_led(struct phy_device *phydev, if (index > U8_MAX) return -EINVAL; + if (of_property_read_bool(led, "active-high")) + set_bit(PHY_LED_ACTIVE_HIGH, &modes); if (of_property_read_bool(led, "active-low")) set_bit(PHY_LED_ACTIVE_LOW, &modes); if (of_property_read_bool(led, "inactive-high-impedance")) diff --git a/include/linux/phy.h b/include/linux/phy.h index a98bc91a0cde..22dde07cbec7 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -877,8 +877,9 @@ struct phy_plca_status { /* Modes for PHY LED configuration */ enum phy_led_modes { - PHY_LED_ACTIVE_LOW = 0, - PHY_LED_INACTIVE_HIGH_IMPEDANCE = 1, + PHY_LED_ACTIVE_HIGH = 0, + PHY_LED_ACTIVE_LOW = 1, + PHY_LED_INACTIVE_HIGH_IMPEDANCE = 2, /* keep it last */ __PHY_LED_MODES_NUM, From patchwork Sat Oct 5 16:28:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13823375 X-Patchwork-Delegate: kuba@kernel.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB6C314B94B; Sat, 5 Oct 2024 16:28:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145706; cv=none; b=iYrPxyiLECK+cAkVD/s+MBiaOL+C2WP3gn27ZYYVRTs6a1dfJVCWQtqujI8Bst4cA2funvrqOmFrAikoBWmnDEzOoVH83HbHH+lHd6V5nKc3d4PYnGLhxfnX0kEySIh/a9iGTj9ffjbVNlnh4M8ZAZGhOZS8Ay2/fLme0YKR2YY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145706; c=relaxed/simple; bh=mfY8SjHy1iBJk5oaEJ2SJrGLxqt7p0f0z8HzXY/WCXE=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PoCpz6nyEABDYlFIBijxYyd9HkuWZStDpv8ZSfVnNKJZ+hXqssLMNIh6zxXSB52whM7ZUYlK8CAHY9dZRWPXsSbOH4r/utkkcbxmre8BBC9wm/gjDvDI2W118IWkuevTaciEiUlKqNyLLAbfdEjXQZSLPp9cnI+iG8G86ua8gew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98) (envelope-from ) id 1sx7dh-0000000045x-1TwZ; Sat, 05 Oct 2024 16:28:17 +0000 Date: Sat, 5 Oct 2024 17:28:13 +0100 From: Daniel Golle To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xu Liang , Christian Marangi , Bartosz Golaszewski , Daniel Golle , Robert Marko , Russell King , Abhishek Chauhan , Jacek Anaszewski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 3/4] net: phy: aquantia: correctly describe LED polarity override Message-ID: <2d59088ac85d78b9bf4b54c2de9442e89eacf790.1728145095.git.daniel@makrotopia.org> References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org Use newly defined 'active-high' property to set the VEND1_GLOBAL_LED_DRIVE_VDD bit and let 'active-low' clear that bit. This reflects the technical reality which was inverted in the previous description in which the 'active-low' property was used to actually set the VEND1_GLOBAL_LED_DRIVE_VDD bit, which means that VDD (ie. supply voltage) of the LED is driven rather than GND. Signed-off-by: Daniel Golle --- drivers/net/phy/aquantia/aquantia.h | 1 + drivers/net/phy/aquantia/aquantia_leds.c | 6 +++++- drivers/net/phy/aquantia/aquantia_main.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/aquantia/aquantia.h b/drivers/net/phy/aquantia/aquantia.h index 2465345081f8..0c78bfabace5 100644 --- a/drivers/net/phy/aquantia/aquantia.h +++ b/drivers/net/phy/aquantia/aquantia.h @@ -177,6 +177,7 @@ static const struct aqr107_hw_stat aqr107_hw_stats[] = { struct aqr107_priv { u64 sgmii_stats[AQR107_SGMII_STAT_SZ]; unsigned long leds_active_low; + unsigned long leds_active_high; }; #if IS_REACHABLE(CONFIG_HWMON) diff --git a/drivers/net/phy/aquantia/aquantia_leds.c b/drivers/net/phy/aquantia/aquantia_leds.c index 201c8df93fad..21b8ede2a105 100644 --- a/drivers/net/phy/aquantia/aquantia_leds.c +++ b/drivers/net/phy/aquantia/aquantia_leds.c @@ -121,7 +121,7 @@ int aqr_phy_led_active_low_set(struct phy_device *phydev, int index, bool enable { return phy_modify_mmd(phydev, MDIO_MMD_VEND1, AQR_LED_DRIVE(index), VEND1_GLOBAL_LED_DRIVE_VDD, - enable ? VEND1_GLOBAL_LED_DRIVE_VDD : 0); + enable ? 0 : VEND1_GLOBAL_LED_DRIVE_VDD); } int aqr_phy_led_polarity_set(struct phy_device *phydev, int index, unsigned long modes) @@ -138,6 +138,8 @@ int aqr_phy_led_polarity_set(struct phy_device *phydev, int index, unsigned long case PHY_LED_ACTIVE_LOW: active_low = true; break; + case PHY_LED_ACTIVE_HIGH: + break; default: return -EINVAL; } @@ -146,6 +148,8 @@ int aqr_phy_led_polarity_set(struct phy_device *phydev, int index, unsigned long /* Save LED driver vdd state to restore on SW reset */ if (active_low) priv->leds_active_low |= BIT(index); + else + priv->leds_active_high |= BIT(index); return aqr_phy_led_active_low_set(phydev, index, active_low); } diff --git a/drivers/net/phy/aquantia/aquantia_main.c b/drivers/net/phy/aquantia/aquantia_main.c index c33a5ef34ba0..c7381d5ede37 100644 --- a/drivers/net/phy/aquantia/aquantia_main.c +++ b/drivers/net/phy/aquantia/aquantia_main.c @@ -488,7 +488,7 @@ static void aqr107_chip_info(struct phy_device *phydev) static int aqr107_config_init(struct phy_device *phydev) { struct aqr107_priv *priv = phydev->priv; - u32 led_active_low; + u32 led_idx; int ret; /* Check that the PHY interface type is compatible */ @@ -515,8 +515,14 @@ static int aqr107_config_init(struct phy_device *phydev) return ret; /* Restore LED polarity state after reset */ - for_each_set_bit(led_active_low, &priv->leds_active_low, AQR_MAX_LEDS) { - ret = aqr_phy_led_active_low_set(phydev, led_active_low, true); + for_each_set_bit(led_idx, &priv->leds_active_low, AQR_MAX_LEDS) { + ret = aqr_phy_led_active_low_set(phydev, led_idx, true); + if (ret) + return ret; + } + + for_each_set_bit(led_idx, &priv->leds_active_high, AQR_MAX_LEDS) { + ret = aqr_phy_led_active_low_set(phydev, led_idx, false); if (ret) return ret; } From patchwork Sat Oct 5 16:28:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 13823376 X-Patchwork-Delegate: kuba@kernel.org Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3321D14A4F7; Sat, 5 Oct 2024 16:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145727; cv=none; b=J7+0lBq8i1gGhS6nltdyXvgGD25Mq6PFbLAY2Fbg5+G6GaL/0f920e6UT8h7KqrhL6hrOhMOioDkfRJwdDw5IKvupAAlzljqQIg7I4Nv96ZwH1jFBRvKRZVZ4/zigfBFu2W5Lna3aor9JfQ/JmwHBci5GgJJBwpEDBosViEAA6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728145727; c=relaxed/simple; bh=/1zA0mp9VAeBlM8oa9n+jmxw+nSew2/1tOt5CK4IRHM=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=DcZTDy1ScAlyGH3EFKEjDIlb+idZrSjTWdxVw2Gxf2CuZ5ABJ5ofMHIcZJ81UXYfIrO5DdLAmgl6nqmOmZ23K4BzwvDGoQVl2OMgIqeXxjMQD2xr6BecTJkTFDm9hqow3JeHBcU6dut15dzpA0DW4b5UoWZkImuKi/hdBtjmrj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.98) (envelope-from ) id 1sx7e4-0000000046L-3MCW; Sat, 05 Oct 2024 16:28:40 +0000 Date: Sat, 5 Oct 2024 17:28:37 +0100 From: Daniel Golle To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Xu Liang , Christian Marangi , Bartosz Golaszewski , Daniel Golle , Robert Marko , Russell King , Abhishek Chauhan , Jacek Anaszewski , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next 4/4] net: phy: mxl-gpy: correctly describe LED polarity Message-ID: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Patchwork-Delegate: kuba@kernel.org According the datasheet covering the LED (0x1b) register: 0B Active High LEDx pin driven high when activated 1B Active Low LEDx pin driven low when activated Make use of the now available 'active-high' property and correctly reflect the polarity setting which was previously inverted. Signed-off-by: Daniel Golle --- drivers/net/phy/mxl-gpy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/mxl-gpy.c b/drivers/net/phy/mxl-gpy.c index 1c9cd00c7bee..f50697f35160 100644 --- a/drivers/net/phy/mxl-gpy.c +++ b/drivers/net/phy/mxl-gpy.c @@ -1013,13 +1013,15 @@ static int gpy_led_polarity_set(struct phy_device *phydev, int index, case PHY_LED_ACTIVE_LOW: active_low = true; break; + case PHY_LED_ACTIVE_HIGH: + break; default: return -EINVAL; } } return phy_modify(phydev, PHY_LED, PHY_LED_POLARITY(index), - active_low ? 0 : PHY_LED_POLARITY(index)); + active_low ? PHY_LED_POLARITY(index) : 0); } static struct phy_driver gpy_drivers[] = {