From patchwork Mon Apr 17 15:17: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: 13214249 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 44513C77B7C for ; Mon, 17 Apr 2023 15:22:11 +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=0Vl7M/B+bL6A4SoWFJ9ribABwGViDHzGVueDgoZQvAo=; b=1ghz1lJDUp6Lyl QJFw1/SamG7HoB7V7xtvH+6LdbVuzUIb8+PFmVMrzRBLgPyZHN0IuHcxtQzYaYmr8qfPRxSLBqjpJ /e69MQ9YTo65MrioCxANlAXIbC+doN6ioT2BayqkILj+8tl4mY3K/OtBFX7bCq0TegbBb0Mk7kNcr JbrE8bMLLep3E9wmqNVUGzsygFVlwWyDIp4C/MPW6fMlQksBI+fna93QQwHBWevHUQzGEcsDRu0qZ TmNknLma6LuZMDw2ofgyUWont80kcHdBTciL8CDfj21CO9JUuQfGzcmekK/Qn3sYQ0tQVt1Xnyayv Fu8XsdFDK/aeLXzoQMeg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfT-00Gpr6-2J; Mon, 17 Apr 2023 15:21:23 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQfL-00Gpmg-2U for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:18 +0000 Received: by mail-wm1-x334.google.com with SMTP id v10so7367698wmn.5 for ; Mon, 17 Apr 2023 08:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744874; x=1684336874; 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=E1ISj2J2PV03tP4krHTpRHjfXqHsXcJJVLFtazUDZkU=; b=B93Ol3o2J5Ek8f9qxd0WyFR5pu8RcoK4bPoIaVzz5FOjINaPjMdIqbXFz/hDOyjnQR MJEuYDi+D6GP3/bkUGLMAQ7/pvBFY5xCfKj0p8hvE0WdEJff8qg2h7oWbLrK8frRhnuC t6GZAhlfrz0wzhNoJn94qXxc3R0YsqYNiwEpOOd11FLdpWKCUqTx82VjZSpVsrZSIKiO hpmg4bKHhgPr7UI6i+gQS9NfZoHu/0MdCUZnv6VHmQB0uOBv6h4LrMsOhJy7nORod0nd PcOAF9O5iaNOzLzL6vLISO+FtlM1W4r7gEr/oiQ8GFpjMRl50gjBC5hny9DuEGza4Av8 tstg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744874; x=1684336874; 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=E1ISj2J2PV03tP4krHTpRHjfXqHsXcJJVLFtazUDZkU=; b=haUOBsg+18WcmFb6YWl90e9ZChDgNowEU6kkjbCA/5Qb+ziA115PGukzg79H02hJIi 0asU11VCOomUKelcv7lDYce55AxJ+2DOW8FveAocuCE/yObLEkhQ7GCvUnEewiF1tOg/ +P4dSdM3RoUdHzzagpacFptV+tLcBXISOgBtHVf+CWy2EO9rb9owObJqK7pLJ6Z0MFuR aOWwwAT4SMRhx3XiIIdt17LkN1Bxet1ZrtP857QYpIX/YNLoX9kMFXtP6JaBIuo0o5wK 9TIvX7zSm0uMLOHH+KLNo0zFjIxfbEyFFU1A9m9eB8oBoz+FZdyB8h1YCNyDtAoyQq4w o0Dg== X-Gm-Message-State: AAQBX9eA+H0CORWo/oNbt0sqqBukySpXuNsY8rMp77IDJ68BRAskIBLz Syx2TTwVu4dRFSbNjeEntUM= X-Google-Smtp-Source: AKy350aEvCB4SkeGEMEgvBixg+WJApsZ++SBQQbR/m8GUqCbS1JahWn+Vkxap90hMcHbMQihvoCB/A== X-Received: by 2002:a7b:ce10:0:b0:3ed:2606:d236 with SMTP id m16-20020a7bce10000000b003ed2606d236mr11175269wmc.38.1681744874295; Mon, 17 Apr 2023 08:21:14 -0700 (PDT) Received: from localhost.localdomain (host-87-7-13-196.retail.telecomitalia.it. [87.7.13.196]) by smtp.googlemail.com with ESMTPSA id j15-20020a05600c1c0f00b003f173be2ccfsm3501354wms.2.2023.04.17.08.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:21:13 -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 , Jonathan Corbet , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Pavel Machek , Lee Jones , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org Subject: [net-next PATCH v7 09/16] net: phy: marvell: Implement led_blink_set() Date: Mon, 17 Apr 2023 17:17:31 +0200 Message-Id: <20230417151738.19426-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417151738.19426-1-ansuelsmth@gmail.com> References: <20230417151738.19426-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230417_082115_810086_09A26DBD X-CRM114-Status: GOOD ( 15.85 ) 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 The Marvell PHY can blink the LEDs, simple on/off. All LEDs blink at the same rate, and the reset default is 84ms per blink, which is around 12Hz. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi Reviewed-by: Florian Fainelli --- drivers/net/phy/marvell.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 8d1eb4c4e1ab..cd5d0ed9c5e5 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -147,6 +147,8 @@ #define MII_88E1318S_PHY_LED_FUNC 0x10 #define MII_88E1318S_PHY_LED_FUNC_OFF (0x8) #define MII_88E1318S_PHY_LED_FUNC_ON (0x9) +#define MII_88E1318S_PHY_LED_FUNC_HI_Z (0xa) +#define MII_88E1318S_PHY_LED_FUNC_BLINK (0xb) #define MII_88E1318S_PHY_LED_TCR 0x12 #define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) #define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) @@ -2862,6 +2864,35 @@ static int m88e1318_led_brightness_set(struct phy_device *phydev, MII_88E1318S_PHY_LED_FUNC, reg); } +static int m88e1318_led_blink_set(struct phy_device *phydev, u8 index, + unsigned long *delay_on, + unsigned long *delay_off) +{ + int reg; + + reg = phy_read_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC); + if (reg < 0) + return reg; + + switch (index) { + case 0: + case 1: + case 2: + reg &= ~(0xf << (4 * index)); + reg |= MII_88E1318S_PHY_LED_FUNC_BLINK << (4 * index); + /* Reset default is 84ms */ + *delay_on = 84 / 2; + *delay_off = 84 / 2; + break; + default: + return -EINVAL; + } + + return phy_write_paged(phydev, MII_MARVELL_LED_PAGE, + MII_88E1318S_PHY_LED_FUNC, reg); +} + static int marvell_probe(struct phy_device *phydev) { struct marvell_priv *priv; @@ -3112,6 +3143,7 @@ static struct phy_driver marvell_drivers[] = { .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1145, @@ -3219,6 +3251,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1540, @@ -3246,6 +3279,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E1545, @@ -3273,6 +3307,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_tdr_start = marvell_vct5_cable_test_tdr_start, .cable_test_get_status = marvell_vct7_cable_test_get_status, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, { .phy_id = MARVELL_PHY_ID_88E3016, @@ -3415,6 +3450,7 @@ static struct phy_driver marvell_drivers[] = { .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, .led_brightness_set = m88e1318_led_brightness_set, + .led_blink_set = m88e1318_led_blink_set, }, };