From patchwork Tue Mar 14 10:15:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 69712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1851550wrd; Tue, 14 Mar 2023 09:19:36 -0700 (PDT) X-Google-Smtp-Source: AK7set8dGbPwa1LXJX5ahSF+smWe3qM5crvHFt6qaYeqi7qIFeUh7iauTsRKf499wdEePaewe95a X-Received: by 2002:a17:90b:3b90:b0:234:b35b:f905 with SMTP id pc16-20020a17090b3b9000b00234b35bf905mr40860363pjb.2.1678810776330; Tue, 14 Mar 2023 09:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678810776; cv=none; d=google.com; s=arc-20160816; b=sMQza2kCx4hvOJ2pIohFDzlPN5SOwTmuoAahk1Y/HfcCz8RQ346UfHXouZYdVFh0V0 ZPyUBaYIxADYvjK35kmE+AfptIkd9MSXZzFisXE0E++b2pHv5wbAMpFqhP6oN9DhCGBG 8aNMJECeJO7xKI4Bd0MTD0Vpl6PmaBl1HXUXuQPqDghm9REUZmWmfRlyBlATHF2aHBsg sBoxtorwIs4qj0YPlTEw1DeCxtusZxb+uD0dOqBj8XSF9/HtpgbXq5uPCd8jZjKyER2S F96ehURsyh4GbTu601kLtvdrInfNmH2VJ7QxtQvqR3QHDInam7Vs/ZiL1elsI4XmjI3c BxQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mcPDqv1MH0gdrEhrxsDvDnbiYWzw+6vrk0oNxbr+mS0=; b=OQt4xpsym32DbEjS9XCRyFu6yTfnyRVuJBEDZaBWmujeFvTE+mwkDesFLGqW2KRbaG FTpralW1YQRVH1GJDZUss2ihsw/llA2P5vFZt/tVA1JoRzN9i04Nbd70SdmIMTZ9RwAG BTw9fk4aP06xOjJQIn+Nw4ExNmTE3mgVdqdos9/9qeHqzH7TGQhY1Rj1m5IcovDtP6Aw D0DZh5Lg1am0CHKz1HBWxDKnhgE+kNRCe9emr+NdGXp1G8ePVq9YRzUjur3RQwf1Y/nF NUrH2W3nIvpA2RmEniAuqU1qUqK+LkDNTNK5nYT8BQ1efMVxKL1k432h/5XcmpxdYdAH C2Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="D1e2CH/f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i19-20020a17090acf9300b002367f75aa40si2596529pju.150.2023.03.14.09.19.19; Tue, 14 Mar 2023 09:19:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="D1e2CH/f"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230416AbjCNQSz (ORCPT + 99 others); Tue, 14 Mar 2023 12:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231363AbjCNQSB (ORCPT ); Tue, 14 Mar 2023 12:18:01 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67D1DACE2C; Tue, 14 Mar 2023 09:17:36 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id y14so2211381wrq.4; Tue, 14 Mar 2023 09:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678810652; 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=mcPDqv1MH0gdrEhrxsDvDnbiYWzw+6vrk0oNxbr+mS0=; b=D1e2CH/f1ZCpmavJDAsroXoWcjiMQI/0VbpSHMMGtGkrnOo8btyw5KwJE2cPL4Zmuq uWvdBMTtHTuKWN//E1vyNY0kAavHh07YZYE3PTG1HwtD00TKJ8AyRenztNeuZUKGL1/n xMblzmMl5564QkdZfwgkBJ1yS5yq8vTwSrLeHBCjs6pwOG5u2PGzjgDcDig4SAkW22b+ +xrB+VNRwUXiXko8a2vzKqWFCiD3zGN/A1zXHeeQ1uGPcuyXayjq/gWX8d88Dksf9PcM RUIvcmL4VAjczpWHkAQJnxPXZR+LYIUkLDwA6NAkjy9v3HP/c4uI2mGkcJe1SNuUt5gI V7JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678810652; 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=mcPDqv1MH0gdrEhrxsDvDnbiYWzw+6vrk0oNxbr+mS0=; b=AhU4TODBMM8WbBJ6jtFycQ0yqTUON83/m5gfG8foVcsqXUqKXD+YhBJ/xjjEulCVpC yIOTPIOs79o0WnmX/3YZY6upByh2ULnVmSr4DMZs5HxYEwooAIiQmii9VXWUoVcxslg+ vxMs29WoAZ1DC0aQZhzw8gUA/E4HG9jZuQ8mDDEmSWNcMfCQwO6hDmh8hbGemZA0w3Sl sfVVesnkZk5A6omQcFlbZbeO0h3UigVWiJ0xp62Y/ugRZc+mrZkG8cSrAbKnwbGntvuC eee1NjeHj2RCPvDI/2ogD9beQTPBalarUrL4+NaW4m8eZWyP+2dljNnH48d7j4RBOuI+ xqXg== X-Gm-Message-State: AO0yUKUD1Ma6h0rHB4lH87iH/3j/nujkTC1L8z2txID8x7XoDp1O2L8K V89LKmBT92GiD7iE+23VFeQ= X-Received: by 2002:adf:eb46:0:b0:2cf:e8f4:d1ea with SMTP id u6-20020adfeb46000000b002cfe8f4d1eamr2530041wrn.29.1678810652188; Tue, 14 Mar 2023 09:17:32 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 09:17:31 -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 08/14] net: phy: marvell: Implement led_blink_set() Date: Tue, 14 Mar 2023 11:15:10 +0100 Message-Id: <20230314101516.20427-9-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-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760360688331230862?= X-GMAIL-MSGID: =?utf-8?q?1760360688331230862?= 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 --- 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 e44a4a26346a..3252b15266e2 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, u32 index, + unsigned long *delay_on, + unsigned long *delay_off) +{ + u16 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, }, };