From patchwork Tue Mar 7 17:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13164875 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 EC44FC6FA99 for ; Tue, 7 Mar 2023 22:35:07 +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=iRGRcV4+jwfu7ajVbPzRAJauOxWhrtYbdAXDVb1Sfc0=; b=wCXhzunrr7OrM0 4XTN1Ju0y1d/uFj1uW2LDbJsRdJ0uvdkc8Tyu8lNEHXI1KD4N7OOIX0pPVHCdfVi7n1LYccxY3bI+ osZ5tQCZhzpQ6rkH+e64Sj87IC79nvz1xpMj6a21vmnw0NkTqOdPxnLEndUgrQxu7DtH+BaMf7mTP BqBslUKcsoeWwauk2Q4AGWHE9pB+UKehNwURUjHNuQfp8uLl7VKVpNji5HDlctxQ7L0BOIwTh4ZBv ASSJZEUUfa7KGwW1jgDG8CD3x3vcMvwrwZ7QjjG/Ad2xaWK5XFmB3rXIZCLDE78VcdF7YWKxYuDzo 5LIKcT5NyC26LzZb+5IQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsv-002h8i-8L; Tue, 07 Mar 2023 22:34:17 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZfsB-002gmV-92 for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 22:33:36 +0000 Received: by mail-wm1-x330.google.com with SMTP id j19-20020a05600c1c1300b003e9b564fae9so96550wms.2 for ; Tue, 07 Mar 2023 14:33:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678228407; 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=nDSS3ewB7gG1U+v8T7rnOXrGZSm+UO+B7Lfb/7bhXAg=; b=blz3/ELBOXjUrdpi07dtGFW6XFc748WAF+shCc4Fr8mm44kTCg6M/mJ3MTyY+QY6Xj HUFb89ZpGWr8FXC5jEvTsI3N/N3+bXy09ur7qmeKjP0idN9vd/Kb7N69FcJyeQF6fZvK K5fLOK9MSyCRDeFCnT3bLQ+J5CKFi8x6vv9Efp8dvBjgmBSsm/xP30sLXQ6vGVRBZnDL +DA1xIh+PIHUtWm5Ya4XQHrHo0mvCl98DdXUAW0FnuJSO4Cw/5xyI1AKNZOKf7o+KPOk zsO+0Wn57TIU2rFc5uM1hm6S6CTyvhn5aceIC6o8l/eTkYnB8gESS8Q5jzv6ZuG3RaKy 2Lfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678228407; 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=nDSS3ewB7gG1U+v8T7rnOXrGZSm+UO+B7Lfb/7bhXAg=; b=uSwEHR/xkAx+ySL8LUJz0qZdkoPEC7fDJ7cTxtoufLKixBms7LhzwAM0OyKeB3+U5f hSMb66POIXhYu0ZYQ6oV4p9rgMLjRKZ2TffljZnI3+CgX5Qop3gwz6vUBRtoDedOGxVq FCYQ6BPZ82aVXsNt0rmpFI5CkP7b8JRRyU6xjzqdoRuuEDIEuJdTqkMPGDYSFr1PidAr PGvvXtherylbzSmC+hFGcnS3JgSuhxkMLPwL6wmjlsa8qrUkggu0eSR+GsNvLabmtENt Ws9vY0+WM5QZgd+g4fGcbV+2ZeOxxW7Z0cWWCKT0Rd7NnSbuCRC/oCMWXZjDQcvF7rs6 FyTw== X-Gm-Message-State: AO0yUKUm3Y9sbbYs+0Yibeu+An8vjJU6Kp8b3HlkdMxQusfqdpg9/SQw QSC8QT5BpnWAG6kOhur8XlI= X-Google-Smtp-Source: AK7set/RMdqTxdOk4/p5y0aZH3QBbMwhSDw9pPagi1QOQdzjMzgGd2yZuM7LJ8k8DM9k9S+APgYOhA== X-Received: by 2002:a05:600c:354e:b0:3eb:38e6:f652 with SMTP id i14-20020a05600c354e00b003eb38e6f652mr13920493wmq.13.1678228407200; Tue, 07 Mar 2023 14:33:27 -0800 (PST) Received: from localhost.localdomain (93-34-89-197.ip49.fastwebnet.it. [93.34.89.197]) by smtp.googlemail.com with ESMTPSA id q11-20020a05600c46cb00b003dc1d668866sm19233101wmo.10.2023.03.07.14.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 14:33:26 -0800 (PST) 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 , Christian Marangi , John Crispin , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Lee Jones , linux-leds@vger.kernel.org Subject: [net-next PATCH 02/11] net: dsa: qca8k: add LEDs blink_set() support Date: Tue, 7 Mar 2023 18:00:37 +0100 Message-Id: <20230307170046.28917-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170046.28917-1-ansuelsmth@gmail.com> References: <20230307170046.28917-1-ansuelsmth@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_143331_341193_0A1A64CA X-CRM114-Status: GOOD ( 15.76 ) 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 079f1b423f9a..821ffa1f5b5d 100644 --- a/drivers/net/dsa/qca/qca8k-leds.c +++ b/drivers/net/dsa/qca/qca8k-leds.c @@ -98,6 +98,43 @@ qca8k_cled_brightness_get(struct led_classdev *ldev) return qca8k_led_brightness_get(led); } +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) { @@ -155,6 +192,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.brightness_get = qca8k_cled_brightness_get; + port_led->cdev.blink_set = qca8k_cled_blink_set; init_data.default_label = ":port"; init_data.devicename = "qca8k"; init_data.fwnode = led;