From patchwork Fri Mar 17 02:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 71034 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp106617wrt; Thu, 16 Mar 2023 19:34:31 -0700 (PDT) X-Google-Smtp-Source: AK7set/r7lRAnyw9adt4/0/+FaAuBTdOzVfhh8PHLdbqeC5kLKGrtfGXGVBEkrdTQVkWMaIufZGO X-Received: by 2002:a17:90b:2241:b0:23b:3f18:a8f9 with SMTP id hk1-20020a17090b224100b0023b3f18a8f9mr6737955pjb.16.1679020471260; Thu, 16 Mar 2023 19:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679020471; cv=none; d=google.com; s=arc-20160816; b=KKv6tyK7bUiPpkL4VA2f6s0oODa23QquOVwlD/J+6dLY352BGsSbtxrdUN2C8th04F sH94JxwNUkx4AIvqDUH9fJEbQS9sryBKjmQWiSWYWsTjxo6m+z9YPqzI1UdpJCO3ZuZP ajhjs/QlhXR/tQIT/FW+MPgLnqR8AfCJO0TdDQrFzLsGr+fbRPWiXizhHl5ATXybDupN lMkPN4tszLIsJfURYX9bMWutl/gu5BjDinfgUMcDYspERiPE265vOPtbGgPG72OY7Byl ZfeQeSxkbT8OVYCm2cINuBd1lbhmKDakWuyLP/oS/s9kf6DS8wB1rKXa86hbq6BltGk3 1noA== 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=afDlpxoJaGOlge6oF8HK8w7bmxxAcRYUXmg7BTlAgHY=; b=xp2GDzf+7uvLqZP053FhiO9FfkGPocDJz+LOuMcBXKgPk0R3L+xZt3IS90navyEuP6 fsDJr6ykMX1bAgC3Uh8D0dr47mgqnuxw03Xap3Fy+JLJlSsGTtyXezkg0jQlOCzt88X5 +q36fnuaflQYByN/369k+IsVNggloZOGF4Y0oRibFOYqAxQW1ASoJTciBMTDnE/7Ghce yA45adGe9TJ1Z/IAX+RD6s0T4BHuPdIQyTbkPlFa0YnJiSkRTZjueiKsshLRnKIaazcQ +3PQ2EXZOiqElr0+625YuTv5JtVVtdZ91n1didcCT0OYFdWKf5V84RO4Jef2+/j+fT9A pYIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FKAuylYM; 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 o3-20020a17090aac0300b0023b4d01f319si866114pjq.75.2023.03.16.19.34.18; Thu, 16 Mar 2023 19:34:31 -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=FKAuylYM; 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 S229928AbjCQCdi (ORCPT + 99 others); Thu, 16 Mar 2023 22:33:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjCQCd1 (ORCPT ); Thu, 16 Mar 2023 22:33:27 -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 B28E32E0C0; Thu, 16 Mar 2023 19:33:25 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id m2so3186805wrh.6; Thu, 16 Mar 2023 19:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679020404; 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=afDlpxoJaGOlge6oF8HK8w7bmxxAcRYUXmg7BTlAgHY=; b=FKAuylYM2ILHFDRqDE7mBB8P8EzedX9Ga+jNpeK44hfNSKZUjsOqRsShUjLMHTJi1C tfHNagocmUOHYAq22hcqMXbJOM+MNzCn0T07uZWFKVhEWBNBmzpaeUHKYJZeOQet+XqP pUFC1pjHzLjBoPs6SJ9plyBgOu0va1ObyPpfkSwAus+cXoJjJUfilUJq4eBEfd41sRDu nMQEZibL8MipUEeU1igSeqx8uIEk864xehzTp9paNjBPTRIZWh8VdH/kE5WecR7cv7ti 4O+QtNtXRoD+P+qwiemcebIaASbVDVMXncGibDYJyPQ9P6BCr3JPgFAy1KM8BP11I6eL iytQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679020404; 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=afDlpxoJaGOlge6oF8HK8w7bmxxAcRYUXmg7BTlAgHY=; b=gY5TIFpwVW0+zLM+DmVUffnA8VP28OvPQWTHczPMyaVkYHl0ysTFRijzu/9GneAXqv vEN4ZlODarCSHe1aQHawW6CBHdeV7GP8qkj+TIyEzvV8zI8OueG2K36cRD9pQG/h1Ast BjnraeUoL85rVxqDUu3h12AeYy2QqWstf2zqjkMYKcFhhCjnbq1DOl0H89KOFJ9/vJP8 nTsA6Doh50fRY4tB5K/0oH5WJL5YGGDqIN9o60rnM/Fhmg9srxCOWp1E0E9IxMhn+O/x ViLZVIN8F+XlNGUh/Ia2jeR0tUh4thWe5XH6WUStQ+Pb7eXSkgYIW6uUUbye3RqRk9lc EMPQ== X-Gm-Message-State: AO0yUKU1tDQ5ZecNU2SjTaHGYziOFFM+6I4VcXPVC0ePHjrarU/NWFea GU5pG5BUZLT14l96C5SWcvs= X-Received: by 2002:a5d:5003:0:b0:2cf:3396:9126 with SMTP id e3-20020a5d5003000000b002cf33969126mr6507894wrt.10.1679020403968; Thu, 16 Mar 2023 19:33:23 -0700 (PDT) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id z15-20020a5d44cf000000b002ce9f0e4a8fsm782313wrr.84.2023.03.16.19.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 19:33:23 -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 v4 03/14] net: dsa: qca8k: add LEDs blink_set() support Date: Fri, 17 Mar 2023 03:31:14 +0100 Message-Id: <20230317023125.486-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317023125.486-1-ansuelsmth@gmail.com> References: <20230317023125.486-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?1760580569591228486?= X-GMAIL-MSGID: =?utf-8?q?1760580569591228486?= 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 adbe7f6e2994..c229575c7e8c 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -92,6 +92,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) { @@ -149,6 +186,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;