From patchwork Tue Mar 14 10:15:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13174807 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 DADA6C05027 for ; Tue, 14 Mar 2023 17:31:32 +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=b0FY/LXKmfKfK3OVn5c1Fgw4OnDDKXvwNb8U0kHvuyE=; b=HVPWUzSN38EvnH u62VKNXoOMnBWR1uOdtYmzETdUSSGMUDg2Q+IoVFpWsdnbC0S/rSsWds0qq/0/NUofkQThniiZiSK ZA5nqzVjl+IQn8IhyLRt+GlLbLMmwL/uKxV2bLcbzP2rlH9TN+9KQlBF9NWMZ7QRZF9kcv0IszTsQ TcCtoBMIS56FPqCR0/o7i9ZBfW9hMPUvLPenT36ABvuyDGW62viuybSaqcN3ekE0KVb46fzfPkK69 6yG5n3EruQ13wEf8G6WaVWDjqLzlyf1+lbfrMmLCuv0990tCJ7TWVWxTQ5queCKREFe0174F2u2bU s9giCmWx7O6TqKRbyybA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pc8U6-00B1C6-1k; Tue, 14 Mar 2023 17:30:50 +0000 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pc7L4-00AmJk-2p for linux-arm-kernel@lists.infradead.org; Tue, 14 Mar 2023 16:17:28 +0000 Received: by mail-wr1-x435.google.com with SMTP id h17so865088wrt.8 for ; Tue, 14 Mar 2023 09:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678810645; 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=vBkEcvNWhfAeeyo/X+X9rMIXx/nIzS4f74zU0rzzLQA=; b=XwtBhJd3if9M6A2OTMozEfIevA56cKlK/3J24Es8Wx8pn21l24IRpLcZov5eApGPXg B6aaMDVCwSCITNdbxG9CU8hkYZDmt+h3wTx7CoR7yG4Rkl/JR2KvlX7ZJWfNl9NGU3YB sylASw/zC9HiwlC+o1r4dCh53uwHMXgqZTIfgcp0+WRNO31uj1bghz2S7HqM2jjod5fN +SZ+DDS7+aMIhgqOGb+RF8Rc0X49G8p8b1cCuywQtRQwcW0u9YGn7POMKlAhF9MwYqOr spgSLUkwkVu5xRh8774GBxaseYSVIszcwNar7/w2zkeOCbNE4EeRBhQibwgd4OS9On/p TM8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678810645; 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=vBkEcvNWhfAeeyo/X+X9rMIXx/nIzS4f74zU0rzzLQA=; b=CcTuRUq26NemneKiCAXZHte4ThlIVnqJIv6FjivrA3pP5o3iP5fbeMskZr7ZMEVQ1D ArohmDphJ8OD6XsgK3OfjUqG6HqHdlt2uHJMSy+Te8br4baMPLdkYSsNoYc5JiTgTINh mpZhamyJ7Rfe+lkFTwBB01H1cD6ntjLfa+kZe/zK3jS0vP52Uu/Hw8A4W9QHqVFv1bqo HOWsidn+w7rv5X0nB3DHQPpVhriDhANV7ffy8mmnAW6s9hpxshmNDJxjJ9s1ehmFBFZi EWthj5ITsx62QtCCmOhkVFnGLmP4JNnvr4wePhde9iErsPk2KgOP3AXZ/Yu3QkSwJD5A WWgg== X-Gm-Message-State: AO0yUKXS9IcBaGnTX0P4LOZQv6+QzCcJATSCfDJIOMWPnTBr+KkaW4XM TVoI27vtJYRkur7/vXOW/k0= X-Google-Smtp-Source: AK7set91N6D+TbS1Q6evWps/LGSkChlhlymj34KF/r9uNA41U7SiRaE+dc/9RhX2lqOGgcbMOWzKpw== X-Received: by 2002:a5d:52cc:0:b0:2ca:2794:87e8 with SMTP id r12-20020a5d52cc000000b002ca279487e8mr24642900wrv.21.1678810645067; Tue, 14 Mar 2023 09:17:25 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 09:17:24 -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 03/14] net: dsa: qca8k: add LEDs blink_set() support Date: Tue, 14 Mar 2023 11:15:05 +0100 Message-Id: <20230314101516.20427-4-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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230314_091726_912199_031421A4 X-CRM114-Status: GOOD ( 15.31 ) 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 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 --- 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 7e1e1cc123cd..8054f867c708 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -91,6 +91,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) { @@ -148,6 +185,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;