From patchwork Mon Apr 17 15:17:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13214247 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 D0909C77B76 for ; Mon, 17 Apr 2023 15:22:01 +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=eb8053fxGWYYM9/5+0cA7W1wbh6j9optVwCKCWZxR9E=; b=bfpGfG12u7Og5e 4hDMK9ouDZxV+f/bM9PjiHAT0f8x/5ekd4DVPrh7FRkXGrxu3mv6D3hE85XHcMRxnjO2ZlnfJ0LMu V6CRZllfufRbuP/5YBBz8ULSnLtmTA202wH/UMG8dwtnM93L+ErjHSKE7zxlKZFF4MwlnZa7Y3gF3 h3nDdABzfeFoa9tfMEKMMSEEcUAiI9K6rpVy3TTJ0zQBE1oCzv+4lS630YZlDccvdsJWu8aZhJ1j1 A4jdw2azZcU6/65ssbGArq7xL1qSS3vl2Ys9jYjtgKBmKE94prMihsW9RKmAEiegJ3y00FPmIsMBh DEOg5o1PLVp3TB2FSW4g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1poQfB-00Gphn-2Y; Mon, 17 Apr 2023 15:21:05 +0000 Received: from mail-wm1-f51.google.com ([209.85.128.51]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1poQf7-00Gpe0-26 for linux-arm-kernel@lists.infradead.org; Mon, 17 Apr 2023 15:21:04 +0000 Received: by mail-wm1-f51.google.com with SMTP id hg25-20020a05600c539900b003f05a99a841so21225584wmb.3 for ; Mon, 17 Apr 2023 08:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681744855; x=1684336855; 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=Y9JlsERZxRAysF1OXmKg0b+HpklwlxOxkniV02+TBEI=; b=LAZZxjJsOwUZ/sE1o8nYTYBulM25lMrgdyvQurhhvYpFH/Ww7bS5AFP0iesQaoR7oS 4tH93IMi/1lGcgy21Bk9BRx5NiHf1oHHXUElb+vcJbyNyQMGmUMomGlM1KgklJcGzGfA W7Vtwp0fNC5Bt5Nl+FrI8RSTKZC+5QmR1GLTwvp9JbFSshS1yXO1NpoJusiW6b9yplAD TNPqMC/Wp/OTw38CdtCkPGorNzi+1jAXNi4nNzd+k1krBmmwzQL4KiuTf3Iud3NaKzEN a/VOc5A2oUWWWXdctaoWfv0vp/MbTqLoQ/qJMfo8npdhQUBUJaVT2IBrUCeICoBAr8G5 Sl6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681744855; x=1684336855; 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=Y9JlsERZxRAysF1OXmKg0b+HpklwlxOxkniV02+TBEI=; b=K0MQvVWHMPVf9cJH4WVVMeIPzm/XtE94ZoXYm5CqArtaR0plUeDu0ULsTbsiRjr7ax gtFX+ec22Bwl67/9/PqTcJwr9Rd3yZIWmlI/lo2aMNBioWvxJSIVPlXtEGbLaBteiuse wG4dHKZ22X0lgy2KFNNTLX09lYEyq+3wXy6Qn1czpOGaZt4BUpDRv1mdq1v6/zf5K4/V GysV4MwQLBe8v8PGZAuOWxosSyOsTTqGTd0oluQP379SH0dqlqiqdeg+1sCK43qhGbsT KtRUiyvyAcHArT4bwTflzNsb32Fn2MTJlf3OSMMYJ/vGZ8Vurt63oEvFrQ+3JyOC5NIb zxkQ== X-Gm-Message-State: AAQBX9fu2axG54fMkIyLKSyULYGWLjdj+hn5QgUM61g5oERIKFsQQrpu jtlmzY8tu0IhJFCMctSyfsg= X-Google-Smtp-Source: AKy350YDjkgW5+FGV2rl9VjXreEK2H0WzLXx9qAi/BtaTOcKaFc4PYiWdODow7vRCsJXq529fvGEJg== X-Received: by 2002:a7b:c8c9:0:b0:3f1:727d:77a6 with SMTP id f9-20020a7bc8c9000000b003f1727d77a6mr3916198wml.3.1681744855421; Mon, 17 Apr 2023 08:20:55 -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.20.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 08:20:48 -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 07/16] net: phy: marvell: Add software control of the LEDs Date: Mon, 17 Apr 2023 17:17:29 +0200 Message-Id: <20230417151738.19426-8-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_082101_704697_9E48E843 X-CRM114-Status: GOOD ( 16.23 ) 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 Add a brightness function, so the LEDs can be controlled from software using the standard Linux LED infrastructure. Signed-off-by: Andrew Lunn Signed-off-by: Christian Marangi Reviewed-by: Florian Fainelli --- drivers/net/phy/marvell.c | 45 ++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 24853e9a889e..8d1eb4c4e1ab 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -144,11 +144,13 @@ /* WOL Event Interrupt Enable */ #define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7) -/* LED Timer Control Register */ -#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) -#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) +#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_TCR 0x12 +#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15) +#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7) +#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11) /* Magic Packet MAC address registers */ #define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17 @@ -2832,6 +2834,34 @@ static int marvell_hwmon_probe(struct phy_device *phydev) } #endif +static int m88e1318_led_brightness_set(struct phy_device *phydev, + u8 index, enum led_brightness value) +{ + 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)); + if (value == LED_OFF) + reg |= MII_88E1318S_PHY_LED_FUNC_OFF << (4 * index); + else + reg |= MII_88E1318S_PHY_LED_FUNC_ON << (4 * index); + 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; @@ -3081,6 +3111,7 @@ static struct phy_driver marvell_drivers[] = { .get_sset_count = marvell_get_sset_count, .get_strings = marvell_get_strings, .get_stats = marvell_get_stats, + .led_brightness_set = m88e1318_led_brightness_set, }, { .phy_id = MARVELL_PHY_ID_88E1145, @@ -3187,6 +3218,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .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, }, { .phy_id = MARVELL_PHY_ID_88E1540, @@ -3213,6 +3245,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .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, }, { .phy_id = MARVELL_PHY_ID_88E1545, @@ -3239,6 +3272,7 @@ static struct phy_driver marvell_drivers[] = { .cable_test_start = marvell_vct7_cable_test_start, .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, }, { .phy_id = MARVELL_PHY_ID_88E3016, @@ -3380,6 +3414,7 @@ static struct phy_driver marvell_drivers[] = { .get_stats = marvell_get_stats, .get_tunable = m88e1540_get_tunable, .set_tunable = m88e1540_set_tunable, + .led_brightness_set = m88e1318_led_brightness_set, }, };