From patchwork Fri Nov 18 00:15:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Harvey X-Patchwork-Id: 21996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp707856wrr; Thu, 17 Nov 2022 16:53:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6eaSPv3xdjXlE0GvIg4X/Sc8rBFvavNEbeKWT/6KhMino5zI2iLBCPMZ6z1W/+x0Zwv55J X-Received: by 2002:aa7:9159:0:b0:572:24c7:34da with SMTP id 25-20020aa79159000000b0057224c734damr5429423pfi.73.1668732816410; Thu, 17 Nov 2022 16:53:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668732816; cv=none; d=google.com; s=arc-20160816; b=kQu9kxYPHjnTBeJxqlOcUnbsH0+2MJbeNO5nO2X7w/REbUXQnZCU/Mc2ogD0pXcMjN 8ns6VME8epgfNOBk7O6wTqm4lzrqcib4bTFuNYqdMm8PdpOfrQqaBVNVK9bAISE4OSi2 60gFTQoIH8E5bW62aqTD3ZpvjjJYT20TE6BymKQpkinlIC2rd5jOVUIYAVLvYlVtdVRu L/i8YPwOUx5VQxVPODelkxFxMUm7Lxyx/ol7FlKUzInPsqmz2WQhyCEXYYEYjwdkX+IG XARNBDRHMQY4DKU+u4a8qJzvTp6XTAyvgZCANIywPHL2vF8vhke5uHuJn4YQpGZ79jcP 4e4Q== 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:cc:to:from; bh=qOeIanogyrUO+V41ZkQRtbsVyTti1MLtZ3Agi2yLn7A=; b=015RE8KFbhmTdGNtlfPT3wuTKmJ01Ramy5MbXxjO+de0+bJ3tkSaRprZzr564fUs78 xtldb7nqNnZCxvL3YwRrXD1n+ZciM1ai7JlRZ8YaQKadvxqP00u5wAfR/w4a1aJfcHcg NkMQ8ACnkAbvZjOiR8+m5RuORdN3p7l9epoWXjvngzsR1E2F1jQVOV+JiLqYlI+veHKt sM7vezFnKOmt58ZCaCOwOa8JQzejpdpPEkVzysXdswPnyq02pW3oS410/Zc+vyjD4pdE SqFBd8EUbyrqSHO/vsMsBRLmF1BEmyDj8K/46E6nUbIhoMiwdVDIMpmfDsB99qMpxLAp VoBg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br3-20020a056a00440300b005251a2f06bbsi2263135pfb.59.2022.11.17.16.53.22; Thu, 17 Nov 2022 16:53:36 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240676AbiKRAoS (ORCPT + 99 others); Thu, 17 Nov 2022 19:44:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240226AbiKRAoO (ORCPT ); Thu, 17 Nov 2022 19:44:14 -0500 Received: from finn.localdomain (finn.gateworks.com [108.161.129.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C09B62078; Thu, 17 Nov 2022 16:44:13 -0800 (PST) Received: from 068-189-091-139.biz.spectrum.com ([68.189.91.139] helo=tharvey.pdc.gateworks.com) by finn.localdomain with esmtp (Exim 4.93) (envelope-from ) id 1ovp2u-000nxs-JY; Fri, 18 Nov 2022 00:15:52 +0000 From: Tim Harvey To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, netdev@vger.kernel.org, Andrew Lunn , Heiner Kallweit , Russell King , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski Cc: Tim Harvey Subject: [PATCH 2/3] net: phy: dp83867: add LED mode configuration via dt Date: Thu, 17 Nov 2022 16:15:47 -0800 Message-Id: <20221118001548.635752-3-tharvey@gateworks.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221118001548.635752-1-tharvey@gateworks.com> References: <20221118001548.635752-1-tharvey@gateworks.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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?1749793181719656613?= X-GMAIL-MSGID: =?utf-8?q?1749793181719656613?= Add configuration of LED modes per device-tree property ti,led-modes. Signed-off-by: Tim Harvey --- drivers/net/phy/dp83867.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 6939563d3b7c..008941a8d6aa 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -26,6 +26,7 @@ #define MII_DP83867_MICR 0x12 #define MII_DP83867_ISR 0x13 #define DP83867_CFG2 0x14 +#define DP83867_LEDCR1 0x18 #define DP83867_CFG3 0x1e #define DP83867_CTRL 0x1f @@ -150,6 +151,10 @@ /* FLD_THR_CFG */ #define DP83867_FLD_THR_CFG_ENERGY_LOST_THR_MASK 0x7 +/* LED Configuration 1 bits */ +#define DP83867_LED_MODE_SHIFT 4 +#define DP83867_LED_MODE_MASK 0xf + enum { DP83867_PORT_MIRROING_KEEP, DP83867_PORT_MIRROING_EN, @@ -167,6 +172,7 @@ struct dp83867_private { bool set_clk_output; u32 clk_output_sel; bool sgmii_ref_clk_en; + int led_modes[4]; }; static int dp83867_ack_interrupt(struct phy_device *phydev) @@ -573,7 +579,7 @@ static int dp83867_of_init(struct phy_device *phydev) struct dp83867_private *dp83867 = phydev->priv; struct device *dev = &phydev->mdio.dev; struct device_node *of_node = dev->of_node; - int ret; + int ret, led; if (!of_node) return -ENODEV; @@ -658,6 +664,13 @@ static int dp83867_of_init(struct phy_device *phydev) return -EINVAL; } + if (of_property_read_u32_array(of_node, "ti,led-modes", + dp83867->led_modes, + ARRAY_SIZE(dp83867->led_modes))) { + for (led = 0; led < ARRAY_SIZE(dp83867->led_modes); led++) + dp83867->led_modes[led] = -EINVAL; + } + return 0; } #else @@ -665,6 +678,7 @@ static int dp83867_of_init(struct phy_device *phydev) { struct dp83867_private *dp83867 = phydev->priv; u16 delay; + int led; /* For non-OF device, the RX and TX ID values are either strapped * or take from default value. So, we init RX & TX ID values here @@ -682,6 +696,10 @@ static int dp83867_of_init(struct phy_device *phydev) */ dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN / 2; + /* LED mode unconfigured */ + for (led = 0; led < ARRAY_SIZE(dp83867->led_modes); led++) + dp83867->led_modes[led] = -EINVAL; + return 0; } #endif /* CONFIG_OF_MDIO */ @@ -703,7 +721,7 @@ static int dp83867_probe(struct phy_device *phydev) static int dp83867_config_init(struct phy_device *phydev) { struct dp83867_private *dp83867 = phydev->priv; - int ret, val, bs; + int ret, val, bs, led; u16 delay; /* Force speed optimization for the PHY even if it strapped */ @@ -882,6 +900,16 @@ static int dp83867_config_init(struct phy_device *phydev) mask, val); } + /* LED Configuration */ + val = phy_read(phydev, DP83867_LEDCR1); + for (led = 0; led < ARRAY_SIZE(dp83867->led_modes); led++) { + if (dp83867->led_modes[led] != -EINVAL) { + val &= ~(DP83867_LED_MODE_MASK << (DP83867_LED_MODE_SHIFT * led)); + val |= (dp83867->led_modes[led] << (DP83867_LED_MODE_SHIFT * led)); + } + } + phy_write(phydev, DP83867_LEDCR1, val); + return 0; }