From patchwork Mon Mar 27 14:10:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 75469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1547960vqo; Mon, 27 Mar 2023 07:18:57 -0700 (PDT) X-Google-Smtp-Source: AKy350aCgyZMkHHVUiTQDAOaNrIzMndplQfs4yQteWUrb4Rta/f6t4i4Qrr2GOE+9ecYC0KRLL22 X-Received: by 2002:a17:906:2990:b0:92f:a6d3:b941 with SMTP id x16-20020a170906299000b0092fa6d3b941mr12947416eje.30.1679926737660; Mon, 27 Mar 2023 07:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679926737; cv=none; d=google.com; s=arc-20160816; b=kshRZm4PYTM4TVn5WwFDRyHvy3ftlU0QAlXBoAnYo0hbMeJiLwCj9dpIQmSTO69DuD cx48bn5M0YzTTHs+0npAqWT8EdlGTHI92tixxxLHz2UZBUBqkW6ciIVqD/0LJbWpgPO5 5/K2NYeHojbpnBwF3Vpkj1RLxbCOFq1ptBgUAGstm0TPJQf/JOQE3DsT6yTMjfhUfbGZ dZtF6RzCN5nzFp4e0AxEHprFZRU8E+O2+qncdbBsoOPnQoYtQphdJT1fivagdNukErUU JiHwpQpJm1VWS2zEBdLWYC8+deD8PwNJDkXLV7oj5GYYZGBAM//Ou6Sc2g9cU0QfLKPT nJDQ== 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=ZjvAY85UXOr+ThDvTHRudHDXforsIMNPqrBvOVPkO7w=; b=NCfCsSMxpwGHSsj7Bz9G4WIVAvt+yKr61SYQnxmxglWvBYn6Q/8SpmdH6vHUhsSvzH EC+d7VqfNCDeGa/XtN0OldGna/pBB/aD+EiZVxxBuWNuEYOLHOS924W0UDeVpkarHFM0 lhGnM9r25lW53hY5wmWUz4J2M2Vhsm03DDLkrJcWCmX+p5OPlC5U+fw3x9c7gbqdG89h 5qBJ2lUsJcLj9nhw4xVSXToaNKBXmcDdUG0NkTW++NMWJWX3H5/4xOSVvMhWV/UzjY4E OhpG8PtSxuc+8QmV3hEoSf3VilGLlfFWkxawK7Za7rn3s0uafUF9VTNlMwbCiV5BuAkz 7ffQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BnBagk+9; 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 y14-20020a056402134e00b004cf350e3463si13516602edw.185.2023.03.27.07.18.30; Mon, 27 Mar 2023 07:18:57 -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=BnBagk+9; 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 S232812AbjC0OMP (ORCPT + 99 others); Mon, 27 Mar 2023 10:12:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232787AbjC0OLj (ORCPT ); Mon, 27 Mar 2023 10:11:39 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E395C469E; Mon, 27 Mar 2023 07:11:14 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id q19so5881880wrc.5; Mon, 27 Mar 2023 07:11:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679926273; 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=ZjvAY85UXOr+ThDvTHRudHDXforsIMNPqrBvOVPkO7w=; b=BnBagk+9VpROq4Tf1RT9RRu/EhgB2nIGt8rdECWKEYlpOn+2R1KjpHlKJO/6REt+aO XFGR5TfJKQ0nuUN5fTbNDE946t3JktNw9oJj0u4t/vMygscrUNVxoqK4m9qEsN1Z+pJF MZqCGo9dsFhLJG38XvG6OSEUAclg5Tj5K5po1Yxb47WEz0nhRQf4Q4IyHNDQFKXAUx+I BFFlZ4/rZ1JVQEbcq8Swdhj9tMseeAbRbohgKSHGg/WXdpofX69nY9r4m/XLtINhcTT2 cX+l0rouWy4G2Km3KG9sEXFRA2fq72z9y7xKXgubftbKT5GUrdUJc+q1yoBG0Sych1a/ zHWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679926273; 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=ZjvAY85UXOr+ThDvTHRudHDXforsIMNPqrBvOVPkO7w=; b=OxpHOJVSzTu16ML4HbATn3j2Why6WIsDt/vo/4qSrWYDm4DLoj+/xbFEJkAS+KxLkO U84Vw1Qu0DToBXKGQHcse8k1awL2Wb4rlvXkAdLBufLRU29OA1/yW4LGPRNvZ9WWvbs+ XmPPZjevq5gWi5bjSdb9E1HilmzKFaG/f86N3F8sNbuYt8XMIrgtSEiORZX2NdMJinN5 6mQLWXvQ+ZjbA5ofwdhmaHfz/Kwi0x8MKL1VvjzkstRXjfGHK3TQlQSl9nUY8bpvEyRb gx8osmkGI7vfyighexGE6grOF+IVHDWMQwdSUnMHUqOoIhCpQKPBYi2uWYmy4jqZvBDr YJGw== X-Gm-Message-State: AAQBX9d4lDXLx/SG26AEr60iCnjHi3KHcJtlaNmqxoCiKgzNeYE4ZZZq tZ32JDTgXf/00kvBDR7UYg4= X-Received: by 2002:adf:f04f:0:b0:2d7:a918:a2b7 with SMTP id t15-20020adff04f000000b002d7a918a2b7mr9525140wro.48.1679926273273; Mon, 27 Mar 2023 07:11:13 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id p17-20020adfcc91000000b002c71dd1109fsm25307591wrj.47.2023.03.27.07.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Mar 2023 07:11:12 -0700 (PDT) From: Christian Marangi To: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Heiner Kallweit , Russell King , Gregory Clement , Sebastian Hesselbarth , Andy Gross , Bjorn Andersson , Konrad Dybcio , Christian Marangi , John Crispin , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org Subject: [net-next PATCH v6 09/16] net: phy: marvell: Implement led_blink_set() Date: Mon, 27 Mar 2023 16:10:24 +0200 Message-Id: <20230327141031.11904-10-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230327141031.11904-1-ansuelsmth@gmail.com> References: <20230327141031.11904-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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?1761530859029140913?= X-GMAIL-MSGID: =?utf-8?q?1761530859029140913?= 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: Pavel Machek 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 5f4caca93983..c00f67f229f5 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) +{ + 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, }, };