From patchwork Thu Mar 9 22:35:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 661212 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E34BC6FD1F for ; Thu, 9 Mar 2023 22:38:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231500AbjCIWil (ORCPT ); Thu, 9 Mar 2023 17:38:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231313AbjCIWiY (ORCPT ); Thu, 9 Mar 2023 17:38:24 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76347E04A; Thu, 9 Mar 2023 14:38:08 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id t25-20020a1c7719000000b003eb052cc5ccso4760681wmi.4; Thu, 09 Mar 2023 14:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678401487; 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=cWl8tt6nddXYjDq6pzISEdAAK++EcnsjtXcgJ1R08pw=; b=JTu31Ve2uMOa0DO/Q88ivYP2vPQ4zDyJxtst3rMTz0vTYDCwb9tkhwc2CjoySBigGN 0vJy4MWyg/xSOXAdfCqXTDS0Uns/1cgJRiQleHi6NLW44vTRpCo7nAyk93QzwEznOCMX +5eYVjVRsYK6DoVRUPtvB15+8Ib9RETLrPmHbWIF+3O1xc69Fw7ZGLuT/U+kTehkOSHz mYojPGpg9Z8rmdjwgyGAmcvf8CLA2iYNTratgfT23fJGVMWTERPuHCNRol65R7C1H112 WLTotJZ15QqpY106x/SeZezoOqnvR8XcbhC+ye7UMfHhUKVwyNlJBtzNBU1pmqna8XZD W/xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678401487; 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=cWl8tt6nddXYjDq6pzISEdAAK++EcnsjtXcgJ1R08pw=; b=rw+s+6AasXDDW3XTbs/OvSt733Z1WDhrPu8F7cZvjTSHI5bE83J7j9WDCjsv8eC+fT UIElrnApOFEJtwTSk3voiXBNe/zAmTFPlAl1dyg5FoKQH1E82daOS7rPJ8MoJfCBELMb if7X+xLQTbPemAG9aji1tiG5I4kC38/qylLkb6BgAZcc0morqYysW4oyyogz/Y20dG9E ljPzXzXh39pLbrv8n1n3X4hIQH7gJuCEWpBc25v/F1KqLiOqk8trjCjnUx1s1c4OulCY VIaJgfTVjFXdzf3dl/CAof2cYmVrbOX0dzYqaQgo+KjweSEHIyzIiVZG7u5y3ZEgD4Xb yI7w== X-Gm-Message-State: AO0yUKU0QUtVHB6tt7P3PwnG7TRZtVnut4xtKmd8b/vfk8os/Jwn58PH AMdA/x+j7JPox538daoQkt8= X-Google-Smtp-Source: AK7set/s6/9QBTqK5hPpMNLlD1UzOJgGbcqX5V3wcYLCfxKxUP8bPaYfzxUK3pfdSIyvkumKCx5ifA== X-Received: by 2002:a7b:c403:0:b0:3e2:669:757 with SMTP id k3-20020a7bc403000000b003e206690757mr144905wmi.10.1678401486594; Thu, 09 Mar 2023 14:38:06 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id g12-20020a05600c310c00b003e209b45f6bsm1183981wmo.29.2023.03.09.14.38.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 14:38:06 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH v2 07/14] net: phy: phy_device: Call into the PHY driver to set LED blinking. Date: Thu, 9 Mar 2023 23:35:17 +0100 Message-Id: <20230309223524.23364-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230309223524.23364-1-ansuelsmth@gmail.com> References: <20230309223524.23364-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Andrew Lunn Linux LEDs can be requested to perform hardware accelerated blinking. Pass this to the PHY driver, if it implements the op. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi --- drivers/net/phy/phy_device.c | 18 ++++++++++++++++++ include/linux/phy.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index e4df4fcb6b05..ae8ec721353d 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2981,6 +2981,22 @@ static int phy_led_set_brightness(struct led_classdev *led_cdev, return err; } +static int phy_led_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct phy_led *phyled = to_phy_led(led_cdev); + struct phy_device *phydev = phyled->phydev; + int err; + + mutex_lock(&phydev->lock); + err = phydev->drv->led_blink_set(phydev, phyled->index, + delay_on, delay_off); + mutex_unlock(&phydev->lock); + + return err; +} + static int of_phy_led(struct phy_device *phydev, struct device_node *led) { @@ -3004,6 +3020,8 @@ static int of_phy_led(struct phy_device *phydev, if (phydev->drv->led_brightness_set) cdev->brightness_set_blocking = phy_led_set_brightness; + if (phydev->drv->led_blink_set) + cdev->blink_set = phy_led_blink_set; cdev->max_brightness = 1; init_data.devicename = dev_name(&phydev->mdio.dev); init_data.fwnode = of_fwnode_handle(led); diff --git a/include/linux/phy.h b/include/linux/phy.h index 83d3ed7485e0..b1ac3c8a97e6 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1072,6 +1072,14 @@ struct phy_driver { */ int (*led_brightness_set)(struct phy_device *dev, u32 index, enum led_brightness value); + /* Activate hardware accelerated blink, delays are in milliseconds + * and if both are zero then a sensible default should be chosen. + * The call should adjust the timings in that case and if it can't + * match the values specified exactly. + */ + int (*led_blink_set)(struct phy_device *dev, u32 index, + unsigned long *delay_on, + unsigned long *delay_off); }; #define to_phy_driver(d) container_of(to_mdio_common_driver(d), \ struct phy_driver, mdiodrv)