From patchwork Sun Mar 19 19:18:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 71849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp842992wrt; Sun, 19 Mar 2023 12:20:18 -0700 (PDT) X-Google-Smtp-Source: AK7set8GxtRNUbGO9u43rJeDZ3mrJQiIvjVNGDnvmQmdyxUry88LtMF/pT7ScrFSH1GgGyRtHloS X-Received: by 2002:a17:902:ea05:b0:19f:27fd:7cb5 with SMTP id s5-20020a170902ea0500b0019f27fd7cb5mr17466222plg.10.1679253618395; Sun, 19 Mar 2023 12:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679253618; cv=none; d=google.com; s=arc-20160816; b=OOvNAyETLksDW6ZszlQuxH5qPvehtYImvbcQ5AQQkaQaLIxM3qSpUlRewtvUIVsyAu 2Qws1N82diteT/zhmCZSY2Ds5HOWU97/8mibLWNpTpE6jMahPv0qCw8w/tViTNZ1m8Es QNFMZMht3bJifXTtF6TahG5lMByxcPdmNSffdniLVG+OZhaJTBXNHDpf3c4OHtpXNXfY 1WssBh75ydRkHCZxvKReG7nW0ekx0bboKHJt+v6T+7jjnDfpC9LDje5xDN1SRsa42Adj RJikjTJHENS+GP3lENhM6KqC+gF6fo0YWRX5DikfVsEFsBgZDRz7jCOmxj1E1rMCob86 nFrA== 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=/fQAP8qao36Gp1ceTdiBEfkcCfyz+YfQuWedgI+BBH4=; b=oj4pU9uZf2Rf8QgdFMr43Vc6qtNXnnTq8sY+iKBW7bAK6TJCBMyUDdjXKT9JS6Mfs8 B5u8qIjmOGPaW9GWrsC7PMnSiHlgVMK2pRnhWqfevmNG4z9rDlbaywF4vgXFFtdTERap NwUMSC8LynSesnwP4sL0xsz7s+fnwseLTNDJU7SiIEtzjVaGPpG1PGDAIG7Rhu41lIyL 5FVgFXIhk3IcenTwbnW/C2wv8dTOWv6s0JHPQx1UfZir3BEPmCmy+CC5a0uJpawvPiOu leDqjJ/8jI2Sgm1sOOJ10g8m1xD1WFaBRX6nx/DsgEjnYx+efimloXgmpMs0LaP64yvr HNVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=R5aCMvKE; 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 u6-20020a17090341c600b001a186b471e9si9282872ple.418.2023.03.19.12.20.05; Sun, 19 Mar 2023 12:20:18 -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=R5aCMvKE; 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 S229779AbjCSTTJ (ORCPT + 99 others); Sun, 19 Mar 2023 15:19:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbjCSTSl (ORCPT ); Sun, 19 Mar 2023 15:18:41 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAA3314EA3; Sun, 19 Mar 2023 12:18:39 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id y14so8526069wrq.4; Sun, 19 Mar 2023 12:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679253519; 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=/fQAP8qao36Gp1ceTdiBEfkcCfyz+YfQuWedgI+BBH4=; b=R5aCMvKEnY1JXb3Bwxg3BhQLkx8pqC3K5PScNmGBJyUAqbUfNPQpPTrRJbjJB0U6Pr Pw5S5VmAv7WokWlVFdjFeYx8oSDMxOlKkOcMpUFDBmlgRtXllba8BHARazAgK/EwRpqZ 3wjIom5VY5+lLBs1S7jU19gQr989J2ofpHC/l0YoIGhRWtA0H2O9dKi0G6UDVDylI3CV btHMDg5D8ZXy2/+HR/sWfhiGvclGQoc7hkFVDoZ6LTVIQUy8ys88GJaE8+o8UqMIR/sA 3c7x5x5WQlb4AEuar1C7xop1+VaAhjL4aE/YJEji3Zn6vxrIWEm0K9b/uBuwqYPVxivP Tg1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679253519; 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=/fQAP8qao36Gp1ceTdiBEfkcCfyz+YfQuWedgI+BBH4=; b=EKr25dMF/SV8YyUocDF9wMPe+VmxSd0v/qrRRU2xwi7cmwEsFuTi/cEZUvDJWRsOCX 3SDS4hDrG/PO1M4S64NDq0agxG5ilLa2MZYxkXvGesayqATLPYRLrhW5qm1N4h7q7S+a rSAJRg00GtolQmdM7/9YNuyJ57sbbt+q7OOUoi9VqPgqszPv0JBlefjvNXlPJDJcTLl8 B6h7P3yF4qepWgxqPeRiHYGoYdJV4a3wlGrfLVqm4U5vP1idqAoEUIjic6a4OoL7N0yd Pj4gmhsFeCDodlfn9JPvRykgAd4r32fJJTVuKeeSalJSEBNyptTmX0WiRm4S1vn3OBJ5 KuGQ== X-Gm-Message-State: AO0yUKWRhHa4T0/if+Tu59rAzGqMYTfzBw4LU6oI6y5PH6chb8obNx4E MBNGJkqtegaD/xX/xb0SQ+iDijKxc/4= X-Received: by 2002:a05:6000:104c:b0:2d4:a2c5:9f80 with SMTP id c12-20020a056000104c00b002d4a2c59f80mr4021247wrx.23.1679253519007; Sun, 19 Mar 2023 12:18:39 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id b7-20020a5d4b87000000b002cfe0ab1246sm7165167wrt.20.2023.03.19.12.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 12:18:38 -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 , Pavel Machek , Lee Jones , 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, linux-leds@vger.kernel.org Subject: [net-next PATCH v5 03/15] net: dsa: qca8k: add LEDs blink_set() support Date: Sun, 19 Mar 2023 20:18:02 +0100 Message-Id: <20230319191814.22067-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230319191814.22067-1-ansuelsmth@gmail.com> References: <20230319191814.22067-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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?1760825042322443658?= X-GMAIL-MSGID: =?utf-8?q?1760825042322443658?= Add LEDs blink_set() support to qca8k Switch Family. These LEDs support hw accellerated blinking at a fixed rate of 4Hz. Reject any other value since not supported by the LEDs switch. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn Acked-by: Pavel Machek --- drivers/net/dsa/qca/qca8k-leds.c | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/net/dsa/qca/qca8k-leds.c b/drivers/net/dsa/qca/qca8k-leds.c index 5a29413ba94a..d0a37660faa2 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -127,6 +127,43 @@ qca8k_led_brightness_get(struct qca8k_led *led) return val == QCA8K_LED_ALWAYS_ON; } +static int +qca8k_cled_blink_set(struct led_classdev *ldev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct qca8k_led *led = container_of(ldev, struct qca8k_led, cdev); + u32 mask, val = QCA8K_LED_ALWAYS_BLINK_4HZ; + struct qca8k_led_pattern_en reg_info; + struct qca8k_priv *priv = led->priv; + + if (*delay_on == 0 && *delay_off == 0) { + *delay_on = 125; + *delay_off = 125; + } + + if (*delay_on != 125 || *delay_off != 125) { + /* The hardware only supports blinking at 4Hz. Fall back + * to software implementation in other cases. + */ + return -EINVAL; + } + + qca8k_get_enable_led_reg(led->port_num, led->led_num, ®_info); + + if (led->port_num == 0 || led->port_num == 4) { + mask = QCA8K_LED_PATTERN_EN_MASK; + val <<= QCA8K_LED_PATTERN_EN_SHIFT; + } else { + mask = QCA8K_LED_PHY123_PATTERN_EN_MASK; + } + + regmap_update_bits(priv->regmap, reg_info.reg, mask << reg_info.shift, + val << reg_info.shift); + + return 0; +} + static int qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int port_num) { @@ -185,6 +222,7 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p port_led->cdev.max_brightness = 1; port_led->cdev.brightness_set_blocking = qca8k_cled_brightness_set_blocking; + port_led->cdev.blink_set = qca8k_cled_blink_set; init_data.default_label = ":port"; init_data.devicename = "qca8k"; init_data.fwnode = led;