From patchwork Thu Apr 13 11:03:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 82917 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp955868vqo; Thu, 13 Apr 2023 04:20:22 -0700 (PDT) X-Google-Smtp-Source: AKy350ZF6r2coKqzgST2KeAcanX3xJoNwNZWIwNccp0CNWYsL5TSdsXlXYZhPrwB6DyDMuDZeBG/ X-Received: by 2002:a05:6402:26c4:b0:4fc:97d9:18ec with SMTP id x4-20020a05640226c400b004fc97d918ecmr5165844edd.21.1681384822309; Thu, 13 Apr 2023 04:20:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681384822; cv=none; d=google.com; s=arc-20160816; b=PTTBgMMTu8Nz1OLFMCH/3rzXUqwHg9OEU9pNaRkvP1aR89Ls5oDUfAAXyDwk7KUGOL oUVoAsv1VKBTticLqMGVKkStSc17zvvMghzpFg5V8EbGRzyz8UqnLbnFjuEqyOga88Aw RNoh8XWfbfa1uIrqvdvNYyXTrtlJuC/5UdK5bcmtejhEyZdJNATnPgqGOgFTA3WrbKrv EpXuNSo9m9KngBqsIWDk3Lll9kU4cyXCgy8P1CNYaAcHLzKksnZefUVUaeEGMzvny/z3 aGTuvMIsJ2q5HRuKidIvOlVvVCGnfLwVl9JG9f/gPftvP4xyls5htELrH3TXtlhTlZe7 D+lg== 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=nIEviHIHu/na4SL+ypr6v80+lzIPVZNHcuSShs5qVYg=; b=PrDk5p2p0A2zwGCtxSSiQTAjYCZ9ZFxdF0uNBtEA8w6sLC4Rj5pyAknOdFRuZTDQfk MMrn5dUFpu+H/wN4zOwq6bgbwC12zv83PyGBVOVXuVAtHk8SWzKAE4thyCpYikl9uBd0 DoELWDgeKqKNZObLD4akwCNsHzKFE9H94Y0LTdqXrfG93iPXdYXemPqaxoLIUlDm3CKb FyjUR7A3iNWZvnMV8o/57VnrVnY3UpPLbh/TK+X/xFRWpcwWc4LBrkogOdKLcFcXFYZm wgEojm1ocPSz/Fkn0cG9eAl1jRDJBKmUotvcrlHB+IEY/v7W2pWq48tFwQErCWQ/ABvN 9s8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20220719 header.b=nbnfhyD3; 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 z13-20020a50eb4d000000b00501d18f4652si1515799edp.501.2023.04.13.04.19.58; Thu, 13 Apr 2023 04:20:22 -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=fail header.i=@kemnade.info header.s=20220719 header.b=nbnfhyD3; 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 S231307AbjDMLDZ (ORCPT + 99 others); Thu, 13 Apr 2023 07:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjDMLDV (ORCPT ); Thu, 13 Apr 2023 07:03:21 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D213C31; Thu, 13 Apr 2023 04:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=nIEviHIHu/na4SL+ypr6v80+lzIPVZNHcuSShs5qVYg=; b=nbnfhyD3lZ44du31Gza+w5vzp7 pZoiHH0wMf6sgA/+BZfrvt7kOieNWNNESHhg9Xxq7zop7oxQGtKYnQ0C39hZ/nFN7Et7azTD/qCrc qh3xGk5Y7eVHAcLd1oVoyWSfU0dnKAz4hDicyH161RP5rToNtqboHb+KbPe5swxy4zIJI2AK356+T dKOx3PCzOphHCcEHBEkjw2HvBP0IP2QjG1UxDRh4FYtcKQPA2x++8DWIuXJkFm4aRXD+F/gQFRxg3 1V/6SQAD7rvSsbc8ENv6oCOqUQ28Tc5RXeYSpJSh+5GYeRj5cxP2DaOPwjL3cir4XAJZS3oQMgGBk G1D/O64g==; Received: from p200300ccff17dc001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff17:dc00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1pmujR-0003My-Rk; Thu, 13 Apr 2023 13:03:14 +0200 Received: from andi by aktux with local (Exim 4.96) (envelope-from ) id 1pmujR-001ItZ-1j; Thu, 13 Apr 2023 13:03:13 +0200 From: Andreas Kemnade To: pavel@ucw.cz, lee@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andreas@kemnade.info, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Matti Vaittinen Subject: [PATCH v3 1/2] dt-bindings: leds: Add ROHM BD2606MVV LED driver Date: Thu, 13 Apr 2023 13:03:06 +0200 Message-Id: <20230413110307.310944-2-andreas@kemnade.info> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230413110307.310944-1-andreas@kemnade.info> References: <20230413110307.310944-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Score: -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,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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?1763059771840532086?= X-GMAIL-MSGID: =?utf-8?q?1763059771840532086?= Document ROHM BD2606MVV LED driver devicetree bindings. Signed-off-by: Andreas Kemnade Reviewed-by: Matti Vaittinen --- .../bindings/leds/rohm,bd2606mvv.yaml | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/rohm,bd2606mvv.yaml diff --git a/Documentation/devicetree/bindings/leds/rohm,bd2606mvv.yaml b/Documentation/devicetree/bindings/leds/rohm,bd2606mvv.yaml new file mode 100644 index 0000000000000..e4327d4cdefa5 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/rohm,bd2606mvv.yaml @@ -0,0 +1,81 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/rohm,bd2606mvv.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD2606MVV LED controller + +maintainers: + - Andreas Kemnade + +description: + The BD2606 MVV is a programmable LED controller connected via I2C that can + drive 6 separate lines. Each of them can be individually switched on and off + but the brightness setting is shared between two of them. + + Datasheet is available at + https://fscdn.rohm.com/en/products/databook/datasheet/ic/power/led_driver/bd2606mvv_1-e.pdf + +properties: + compatible: + const: rohm,bd2606mvv + + reg: + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + enable-gpios: + maxItems: 1 + description: GPIO pin to enable/disable the device. + +patternProperties: + "^led@[0-6]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + minimum: 0 + maximum: 6 + + required: + - reg + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + led-controller@66 { + compatible = "rohm,bd2606mvv"; + reg = <0x66>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0x0>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led@2 { + reg = <0x2>; + color = ; + function = LED_FUNCTION_STATUS; + }; + }; + }; + +... From patchwork Thu Apr 13 11:03:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Kemnade X-Patchwork-Id: 82919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp963689vqo; Thu, 13 Apr 2023 04:35:46 -0700 (PDT) X-Google-Smtp-Source: AKy350ZzFsJA3dtL7EujlwDJShiVoE9Bn5l90wCix0B/hvtRgVMQT7pQWMhTYjMdFQIQsBGNoZM/ X-Received: by 2002:a17:902:fe0c:b0:1a1:f5dd:2dd5 with SMTP id g12-20020a170902fe0c00b001a1f5dd2dd5mr2026646plj.13.1681385746529; Thu, 13 Apr 2023 04:35:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681385746; cv=none; d=google.com; s=arc-20160816; b=S9WveykhLMO8vHP/a1pFKRYgmJCFdLfI5pQ1EQQy1haPug1hhF93RaI79DKLNkkMKb fL1X4zlDeJYUqQH5KxcDiTh/cbdNy9WlC4FIVfniyHrHnehhl5dKMkUZBAuMG1nJ/dtK wEnhgYmZ8wMjZtJfWavjhvjDM82xa86K2VP7NiyJeIYWcHH/IgkmI2OvIbmia8IK7JLI t97Cjz0Tix7nydTK6JNJuw2njJsJjIEkKxl7Yxqj4gW0ST35jNp+25Qpe8umz+k2+PmT mkXDfVQtjirUqbq/dW/co/owH7nWM5nlNujrQaPR3PvWOHng4ZUKHzoJ/FHXWtz1hVxb DDYw== 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=A9921GIRBZJwywgkMiKJHaOD0P9ClMQSHARqbFSJFZI=; b=f+AFduaputD8VS6Xv+pKACXpOm+7yLaYkSQ4lIByJTn224PDc8ea7Ktb9H9xwEtyGB wZ9PI5nHFgENrwgN8xDwJiV/wlnfKqjU1S8Gt19HLQMQSTcDKYkUGM4NKDzeelESGCnC hzH3iop0BN+LUGvJQu0ld4ATv6eify1CCVSqC8V44zeJGtdRaL53L7/2P8ghQLBQeyrI 1JtSP7mHXFmWtPH4mIq0szHOOtRsv4TF9b52dl5uNrfjrqZH8GXxUCwo9bmYYmBWVW5L 1sXBSGTNH5fkgHqpsIUReYqOuc6cq+Sahqzj1zPbHoXy389JDaGnOyoc8oyOQfF08XBd Vi1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kemnade.info header.s=20220719 header.b="00f/az8T"; 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 b11-20020a170903228b00b001a637615a89si2014136plh.561.2023.04.13.04.35.33; Thu, 13 Apr 2023 04:35:46 -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=fail header.i=@kemnade.info header.s=20220719 header.b="00f/az8T"; 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 S230179AbjDMLD1 (ORCPT + 99 others); Thu, 13 Apr 2023 07:03:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbjDMLDW (ORCPT ); Thu, 13 Apr 2023 07:03:22 -0400 Received: from mail.andi.de1.cc (mail.andi.de1.cc [IPv6:2a01:238:4321:8900:456f:ecd6:43e:202c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C59831722; Thu, 13 Apr 2023 04:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kemnade.info; s=20220719; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A9921GIRBZJwywgkMiKJHaOD0P9ClMQSHARqbFSJFZI=; b=00f/az8TNXypUMbab3giBsICz5 oBPXpGxbd+hD7rfVtTMD+twiZGFJXjv67xxWAZXWGAz5W1gciQwzM7zA81dilRTCIQTBl+EoFDu8U 3qflb5g6K+bsx0sUV+v2kN0C41y8IDf23QIJlJtw+YLniBlPG0lRoKv6GuHvW4oZ6b6eS0rLXwfmF F2GY+48oZVsHO6PWEFyJ9xLNicIPcOIqt1gvXhzaeCJvilfbaqLr82egEijVuOcujJY4BjPi6Qh44 MMME1z+MHtPyWk1rFOUW9S4WwySxAvUbAlBwF9LtHlaXyu/5+3Z6vJLoEP0PphnZAqdbQ8o4Nmny2 NGjvhINA==; Received: from p200300ccff17dc001a3da2fffebfd33a.dip0.t-ipconnect.de ([2003:cc:ff17:dc00:1a3d:a2ff:febf:d33a] helo=aktux) by mail.andi.de1.cc with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1pmujS-0003N1-9V; Thu, 13 Apr 2023 13:03:14 +0200 Received: from andi by aktux with local (Exim 4.96) (envelope-from ) id 1pmujR-001Itd-36; Thu, 13 Apr 2023 13:03:13 +0200 From: Andreas Kemnade To: pavel@ucw.cz, lee@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andreas@kemnade.info, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Matti Vaittinen Subject: [PATCH v3 2/2] leds: bd2606mvv: Driver for the Rohm 6 Channel i2c LED driver Date: Thu, 13 Apr 2023 13:03:07 +0200 Message-Id: <20230413110307.310944-3-andreas@kemnade.info> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230413110307.310944-1-andreas@kemnade.info> References: <20230413110307.310944-1-andreas@kemnade.info> MIME-Version: 1.0 X-Spam-Score: -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,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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?1763060740697264064?= X-GMAIL-MSGID: =?utf-8?q?1763060740697264064?= The device provides 6 channels which can be individually turned off and on but groups of two channels share a common brightness register. Limitation: The GPIO to enable the device is not used yet. Signed-off-by: Andreas Kemnade Reviewed-by: Matti Vaittinen --- drivers/leds/Kconfig | 11 +++ drivers/leds/Makefile | 1 + drivers/leds/leds-bd2606mvv.c | 143 ++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+) create mode 100644 drivers/leds/leds-bd2606mvv.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 9dbce09eabacf..cc4eadbb2542e 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -551,6 +551,17 @@ config LEDS_REGULATOR help This option enables support for regulator driven LEDs. +config LEDS_BD2606MVV + tristate "LED driver for BD2606MVV" + depends on LEDS_CLASS + depends on I2C + select REGMAP_I2C + help + This option enables support for BD2606MVV LED driver chips + accessed via the I2C bus. It supports setting brightness, with + the limitiation that there are groups of two channels sharing + a brightness setting, but not the on/off setting. + config LEDS_BD2802 tristate "LED driver for BD2802 RGB LED" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index d30395d11fd84..c07d1512c745a 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -17,6 +17,7 @@ obj-$(CONFIG_LEDS_ARIEL) += leds-ariel.o obj-$(CONFIG_LEDS_AW2013) += leds-aw2013.o obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o +obj-$(CONFIG_LEDS_BD2606MVV) += leds-bd2606mvv.o obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o diff --git a/drivers/leds/leds-bd2606mvv.c b/drivers/leds/leds-bd2606mvv.c new file mode 100644 index 0000000000000..81ceeaa434494 --- /dev/null +++ b/drivers/leds/leds-bd2606mvv.c @@ -0,0 +1,143 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 Andreas Kemnade + * + * Datasheet: + * https://fscdn.rohm.com/en/products/databook/datasheet/ic/power/led_driver/bd2606mvv_1-e.pdf + */ + +#include +#include +#include +#include +#include +#include +#include + +#define BD2606_MAX_LEDS 6 +#define BD2606_MAX_BRIGHTNESS 63 +#define BD2606_REG_PWRCNT 3 +#define ldev_to_led(c) container_of(c, struct bd2606mvv_led, ldev) + +struct bd2606mvv_led { + unsigned int led_no; + struct led_classdev ldev; + struct bd2606mvv_priv *priv; +}; + +struct bd2606mvv_priv { + struct bd2606mvv_led leds[BD2606_MAX_LEDS]; + struct regmap *regmap; +}; + +static int +bd2606mvv_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct bd2606mvv_led *led = ldev_to_led(led_cdev); + struct bd2606mvv_priv *priv = led->priv; + int err; + + if (brightness == 0) + return regmap_update_bits(priv->regmap, + BD2606_REG_PWRCNT, + 1 << led->led_no, + 0); + + /* shared brightness register */ + err = regmap_write(priv->regmap, led->led_no / 2, + brightness); + if (err) + return err; + + return regmap_update_bits(priv->regmap, + BD2606_REG_PWRCNT, + 1 << led->led_no, + 1 << led->led_no); +} + +static const struct regmap_config bd2606mvv_regmap = { + .reg_bits = 8, + .val_bits = 8, + .max_register = 0x3, +}; + +static int bd2606mvv_probe(struct i2c_client *client) +{ + struct fwnode_handle *np, *child; + struct device *dev = &client->dev; + struct bd2606mvv_priv *priv; + bool active[BD2606_MAX_LEDS] = { 0 }; + int err, reg; + + np = dev_fwnode(dev); + if (!np) + return -ENODEV; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->regmap = devm_regmap_init_i2c(client, &bd2606mvv_regmap); + if (IS_ERR(priv->regmap)) { + err = PTR_ERR(priv->regmap); + dev_err(dev, "Failed to allocate register map: %d\n", err); + return err; + } + + i2c_set_clientdata(client, priv); + + fwnode_for_each_available_child_node(np, child) { + struct bd2606mvv_led *led; + struct led_init_data init_data = {}; + + init_data.fwnode = child; + + err = fwnode_property_read_u32(child, "reg", ®); + if (err) { + fwnode_handle_put(child); + return err; + } + if (reg < 0 || reg >= BD2606_MAX_LEDS || + active[reg]) { + fwnode_handle_put(child); + return -EINVAL; + } + led = &priv->leds[reg]; + + active[reg] = true; + led->priv = priv; + led->led_no = reg; + led->ldev.brightness_set_blocking = bd2606mvv_brightness_set; + led->ldev.max_brightness = BD2606_MAX_BRIGHTNESS; + err = devm_led_classdev_register_ext(dev, &led->ldev, + &init_data); + if (err < 0) { + fwnode_handle_put(child); + return dev_err_probe(dev, err, + "couldn't register LED %s\n", + led->ldev.name); + } + } + return 0; +} + +static const struct of_device_id __maybe_unused of_bd2606mvv_leds_match[] = { + { .compatible = "rohm,bd2606mvv", }, + {}, +}; +MODULE_DEVICE_TABLE(of, of_bd2606mvv_leds_match); + +static struct i2c_driver bd2606mvv_driver = { + .driver = { + .name = "leds-bd2606mvv", + .of_match_table = of_match_ptr(of_bd2606mvv_leds_match), + }, + .probe_new = bd2606mvv_probe, +}; + +module_i2c_driver(bd2606mvv_driver); + +MODULE_AUTHOR("Andreas Kemnade "); +MODULE_DESCRIPTION("BD2606 LED driver"); +MODULE_LICENSE("GPL");