From patchwork Tue Mar 14 10:15:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13174694 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 509C3C6FD1C for ; Tue, 14 Mar 2023 16:18:41 +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=F28mbOVW+X6SL29tHwQkFJoMB67JVGh/9pvK8CTzXwE=; b=WpO/PAKHKtmCpk 8+1JjUFrmxjmmtqq5JRK7eRRrCP9tmxE4ECTQ2dqqvkcZl4Qu0VlydQTLYvzJ43NO7aiYq/ffzWoQ NJN/nwKKcj/0KVm95fOoecfKn3uosk+4KcJdnuGXXY6gD5/lA9Q/0MXOxCm7zZIauNngYsjtoaSk3 qtZaVJD+BOoehk0q5FrnSmfX25VC1WnK5F4388G5sq6wRvGvhXc81F7OlT9lMOjdoeePJmNwquFZ2 PD1smNE2KQENIDIS/Wccx4L5zaj+lmsXN8kRifKbIjDUn2iZuzFsqqymji4lSMgA2Cm5UwlUEeIVN HicdvVvC+J8gmRCd//gw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pc7LJ-00AmPp-2g; Tue, 14 Mar 2023 16:17:41 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pc7LA-00AmLo-0o for linux-arm-kernel@lists.infradead.org; Tue, 14 Mar 2023 16:17:33 +0000 Received: by mail-wr1-x434.google.com with SMTP id i9so5866435wrp.3 for ; Tue, 14 Mar 2023 09:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678810651; 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=frwVXNK7BvlIsgBhXHgTowPejdqKimT7IaqvOMFSkJUyihwIEAbG769U0YDB1n5tHV pec/8mkp9KDVjBeIV3t0gKysg05mTJAH909NCT/iAaq7IPpgnqrwpBt5I7qs21wb8EH7 gzjxvYCw3TjAQ4nkPe7eVGTVrF6QiIhwtQxST0iEs5mUFREItlaMbJdZe0p2bgzJtMuz EwtfOCoGV+W4G72HUQURjnTwPJ6nyOoOtKOVFlVE6QcKtnEs0j+hPf3s+3VKxQr72Uyf wCGULVk+bAGSH4kvAvSnka7/cmyLt422JuSJOKeSAeGk2XA6t6zaMfI7z7dDAzeFvEQ7 592Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678810651; 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=Tp5aEXkhT9w4qcUkOTWrIuuvUqcI9tGKJqtLaAAHHsA8xN9aC6oS+DdTj9kDqVL0nG ktMZpj12Gf6pwRbfFoWINE4wQhZ9NK2B5xI0pKjmPiSfO6Bv63sODc4Uxm+c3h/+1lFH 0dO+fhTRLeDEDCk9vuvjqLN4fJ+g2ja5cUw1Oybq2a/ddJh8v7jtgpea5YiMnqp4vZnH BGtKwiPM4ytRB+11K5qWeRAdjE+RXHg3WAI2TsmY5BSOs0v74C/T4KdknpBn+9TXGR1x OObPEQes/jSyvrtm8D5maV1GjsgCQnOoEYzLpxJxTWukS0k+WkDMgcVGqKGEJ0OYo9bK HjKQ== X-Gm-Message-State: AO0yUKUP6VN/HPpfau4ABoumicVG5uRT0YQ0AjDkUYZkaYWmHH1X3Y3s dKH1AoO7ri17Pkx9sM7jliw= X-Google-Smtp-Source: AK7set+mqaSObXHOfJkh5HjPCMjpisiRhXVRSJmoJGgR22VpkvTUnB4Yfjrf757TSQIHgdLwe4TCTg== X-Received: by 2002:a5d:4012:0:b0:2c5:532a:98c4 with SMTP id n18-20020a5d4012000000b002c5532a98c4mr10942379wrp.33.1678810650821; Tue, 14 Mar 2023 09:17:30 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id a16-20020a5d4570000000b002c5539171d1sm2426821wrc.41.2023.03.14.09.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 09:17:30 -0700 (PDT) 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 v3 07/14] net: phy: phy_device: Call into the PHY driver to set LED blinking. Date: Tue, 14 Mar 2023 11:15:09 +0100 Message-Id: <20230314101516.20427-8-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314101516.20427-1-ansuelsmth@gmail.com> References: <20230314101516.20427-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230314_091732_580349_2834F4D9 X-CRM114-Status: GOOD ( 16.78 ) 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 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)