From nobody Fri Jun 19 07:48:34 2026 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 847AE36C5BB for ; Fri, 24 Apr 2026 07:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015373; cv=none; b=OvLrct9sgVhRhlSF6cqZqbTrG7fiwQ6J5ZAZi94C3h7JeebDi+kpPhKWv7ybcAdgtL1JCPZ/T8+AjNnB/0xgk+aVEntBrZ7gYu/tn28qdlZBoR49hvidD0to2+jIxJ/ElLoa+pPe957zWYf1HVx3fw2gc3eukaTFQVWM++fI0MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015373; c=relaxed/simple; bh=bWAZFqT4Tb+5f7uG8o8PjY4H1stxGUURcl/qaAWT79w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ugfc+oaf4FjA505Su3+SEeJH45ejTLs9semoBOaYITjKT0tg1MiuK1cC15nNjMZP6/sTnDU0ojSED8KGWo3LloNm50LyJOB5AU7THHV067dwqLaUbgbFNHh2im13nV+HVsPsp5s8HI8R/gXEM9KsZUoRHaxJeC51n6SFkWwFCNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RCdC0Kru; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RCdC0Kru" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-386b553c70eso61146521fa.0 for ; Fri, 24 Apr 2026 00:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777015370; x=1777620170; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mvT9+z0qrm3nOaQPxnVgMXtZ+9QDwe2OUg9PjPNYysQ=; b=RCdC0Kru4royx0BZdUrMH9ls8fgbpqKDQkfQM+SNEgJNanwSN7adI30eNeo0pi56aM d4jByxsFpZF0ewz/jJrawTZpXyT9edfXPFHXbx3qZXEtqziF0OD0bhkyyx0m952ayvip K8hLsJmRDyPObHH/4OYmmAVipK/AQTbSFS0gEmdL+9iBkoGwUSbYsFs9i7zxHEgrBjWe UyC557ivmy6SDLMTbTsfU6yE9HqWmkNefLaa2oY636yGW0rP+uX6zAOa+b92J2x3jBKT xZ9dUTxuLCUWuginnzwRWG+nHu+F/TtB0wU4kEpFw6maYphcDQW+xhbp5cPiDMf2EFdj KvEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777015370; x=1777620170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mvT9+z0qrm3nOaQPxnVgMXtZ+9QDwe2OUg9PjPNYysQ=; b=HGJFtgegzRabXHDwpWQAQGqy7jRZzgNzs3WBoCDEeQIwOwuu7sCxSI+sWDZswRdPsT Soh7qSXBwUW6xczZJyu/+HqFjR8g2ogP9qHWGVRQRY9pJZyRAqtn+cb6dyPo89hKLbOe LUIDFD/rC8lIjfNgEt39DlpSolbbnsphs4tGCw9DWN+XAKzT9CY/pjBgX+HHaZ2MNyBk WPs4vJ7gvB6QEe6tvT4RQ5F0YpwxqIDgLkH92VtzWS1hbrcnkqCobUdjKrEwAPDme/7D 113Eia5krDyGlsO9clrMvtoTBbWDUW36qlDiiKDpxdD59R64HdJ1ZW64JpBl70vSIio4 NcmQ== X-Forwarded-Encrypted: i=1; AFNElJ9OP2P3eJcKHb8GFoTlaZSKryuV5WlMcAfeNqJWgZ7wCg2wb1V/9WXZqztzjkAF4bNrZm7RtSL2C5CltyM=@vger.kernel.org X-Gm-Message-State: AOJu0YwLy9HhhGtpFl2shAHB7TwesmgB8soH69ndDcsGiS/ukRC1+v6K Lyx3q2+UOCxfdHIy8+5p+Vzug4Sc/dYvSW2ZfiqQ17qNLOoxXivd4sTc X-Gm-Gg: AeBDiesoN1AkIqb1ayisaHJRRCGrzF6gnd+lxvSELv0ObWfPYVmiYPf+qaJsj8agIB7 vTdK0FR/Bj6+HJQ+7t6A+0uKVqeFb83vpZbd7Jtp/Rm2gHzulvbWoL+U9Eda8I/W66GSUx9+IF8 FGqe4+P6KGSH0M4eQuDcdf7gP4QlRfBZuiVNlP0XMkFVHzVrIoLC8iu8J9WYe1qdYgK0QXjsGfo mQZTAl93UX0JnAS+X0Zm9jsMosBXJLOkD3/QibkoKQF5d49hYLGk5ZQc6wdJp3HkisowlIj/y3Z iWJINEpztTqBhBcP3IB+mFih7T1RpHcmRhXbZJMkY1cFNAnycg7PgGQZLnpCU5ISN4FyLTElEld U/J9HX/GAOqAXHzNeZ5V2tjXIXkrcc0Jmemdd0hOTzs2tRyjRmBRZQaGak25dSeXCbp3k9zl99z RCmdj9W+i0n44XscWp22qLiYc= X-Received: by 2002:a05:6512:3b26:b0:5a3:ffd1:fbcf with SMTP id 2adb3069b0e04-5a4172cb91emr12006284e87.17.1777015369570; Fri, 24 Apr 2026 00:22:49 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a41a238563sm5612550e87.55.2026.04.24.00.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:22:49 -0700 (PDT) From: Svyatoslav Ryhel To: Lee Jones , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Mauro Carvalho Chehab , Svyatoslav Ryhel Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v3 1/5] dt-bindings: leds: Document TI LM3560 Synchronous Boost Flash Driver Date: Fri, 24 Apr 2026 10:22:26 +0300 Message-ID: <20260424072230.90354-2-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424072230.90354-1-clamor95@gmail.com> References: <20260424072230.90354-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Document TI LM3560 Synchronous Boost Flash Driver used for camera flash LEDs. The TI LM3559 documented in this schema requires a separate compatible, as it utilizes a different programming model =E2=80=94 specifically regarding = the handling of voltage ranges. Signed-off-by: Svyatoslav Ryhel --- .../devicetree/bindings/leds/ti,lm3560.yaml | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/ti,lm3560.yaml diff --git a/Documentation/devicetree/bindings/leds/ti,lm3560.yaml b/Docume= ntation/devicetree/bindings/leds/ti,lm3560.yaml new file mode 100644 index 000000000000..c6c553ad23f9 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/ti,lm3560.yaml @@ -0,0 +1,131 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/ti,lm3560.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: TI LM3560 Synchronous Boost Flash Driver + +maintainers: + - Svyatoslav Ryhel + +description: + The LM3560 is a 2-MHz fixed frequency synchronous boost converter with t= wo + 1000-mA constant current drivers for high-current white LEDs. The dual h= igh- + side current sources allow for grounded cathode LED operation and can be + tied together for providing flash currents at up to 2 A through a single= LED. + An adaptive regulation method ensures the current for each LED remains in + regulation and maximizes efficiency. + +allOf: + - $ref: /schemas/leds/common.yaml + +properties: + compatible: + enum: + - ti,lm3559 + - ti,lm3560 + + reg: + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + enable-gpios: + description: GPIO connected to the HWEN pin. + maxItems: 1 + + vin-supply: + description: Supply connected to the IN line. + + flash-max-timeout-us: + minimum: 32000 + maximum: 1024000 + default: 32000 + + ti,peak-current-microamp: + description: + The LM3560 features 4 selectable current limits 1.6A, 2.3A, 3A, and = 3.6A. + When the current limit is reached, the LM3560 stops switching for the + remainder of the switching cycle. + enum: [16000000, 23000000, 30000000, 36000000] + default: 16000000 + +patternProperties: + '^led@[01]$': + description: LED control bank nodes. + $ref: /schemas/leds/common.yaml# + unevaluatedProperties: false + + properties: + reg: + description: Control bank selection (0 =3D bank A, 1 =3D bank B). + maximum: 1 + + flash-max-microamp: + minimum: 62500 + maximum: 1000000 + + led-max-microamp: + minimum: 31250 + maximum: 250000 + + required: + - reg + - flash-max-microamp + - led-max-microamp + +required: + - compatible + - reg + - '#address-cells' + - '#size-cells' + +additionalProperties: false + +examples: + - | + #include + + i2c { + #address-cells =3D <1>; + #size-cells =3D <0>; + + led-controller@53 { + compatible =3D "ti,lm3560"; + reg =3D <0x53>; + + enable-gpios =3D <&gpio 28 GPIO_ACTIVE_HIGH>; + vin-supply =3D <&vdd_3v3_sys>; + + flash-max-timeout-us =3D <1024000>; + ti,peak-current-microamp =3D <16000000>; + + #address-cells =3D <1>; + #size-cells =3D <0>; + + led@0 { + reg =3D <0>; + + label =3D "white::flash"; + linux,default-trigger =3D "flash"; + + flash-max-microamp =3D <562500>; + led-max-microamp =3D <156250>; + }; + + led@1 { + reg =3D <1>; + + label =3D "yellow::flash"; + linux,default-trigger =3D "flash"; + + flash-max-microamp =3D <562500>; + led-max-microamp =3D <156250>; + }; + }; + }; --=20 2.51.0 From nobody Fri Jun 19 07:48:34 2026 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9899F370D52 for ; Fri, 24 Apr 2026 07:22:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015374; cv=none; b=rI5yqLbziufxQv/+zqmqm6e2GxzDoDlIbuPHOagS3vqshN+A22zn0sDBgIaUs2Cy77vTT0lK6ixwUM8Mbti5HSsxaHq98RFo5+fwzcwqSm9DQdJaBwuGCGeyC8IPYROuQKlA7BtRL4JA34o6diubdQCmlD19SxN4GEKdFXpcXt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015374; c=relaxed/simple; bh=NnTZhLTZnNfRAZTpInLPnO6pd8hHUs/jOhkVX7vXeK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LLVAKnSu7ugeIpxq4HYCtIad8dSo9vM0mFLz/inVnwh7dHHuxVAso/ROJmRAMwwZWGltSSHloB8CBvygO3K19YdX4UyUU8jVYnk0XDFbCaoBjfPw0nZdHDtwSn5K6j1rzOhUc7eT1zHJm4MgiM9pJcqWsLyLcheFz2GjB81Q/ds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rDn4JFzR; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rDn4JFzR" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5a3af1b7549so9451894e87.1 for ; Fri, 24 Apr 2026 00:22:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777015371; x=1777620171; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d0a97i72KVR1eeUiCzxnD93bJZC8Qqjf+srt6bZebIg=; b=rDn4JFzRu2B+Ntr7IzOp2eSJ0UR30SsYAbEH962Iq+huak/sOJKRNI3gyMQe8Q8DpS 8WNSJH6VVa9d3AP3i60m+lks9JPVzrbptvpx2qKw1JA8jYXkG+FoDAy08+zBtPeJ4zYN G6GooWMQCbwg9JYb4LZUpBQ+dQv5kKePE0QmKOxDwLcpQEYldOMZwUxGKvCjOATf+kvq QB0QPCPKGS3XdUmIbCL3syLP40iLJdZeKBL1oqQeYeVi0x+e62/o+lkWGxecvsKUwqVh 4eKrASH3s70BQjLJyxY5Z7N9aVZSxXYtyR+9qwCFpVKXTH1XPFRdTAfGkXBz7xRvz8WT wdKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777015371; x=1777620171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=d0a97i72KVR1eeUiCzxnD93bJZC8Qqjf+srt6bZebIg=; b=R/UDyYHWCMXXYfGs3fV9afUvSYzyOTuJWfeSWdDrAGanAOcJDGwcxHxkGregE5ddRW uipewiyWL50NhNSosfaQhnw5D54Yc3WgvYfaJ5pAHTyKnnDL0Vm5NXQxh5wuLIyBNgpv +c6TTScVLc24K/XI+cAwOZ0yl81RZo8Bf0l2epWEqjaoyYsx58LFDUcjhT+M8MOc6gGl mf3QNdqQcVpSwmAOlgeIfwWN9UK+YXWA7LcfPbYiQNI0n/sPuQpQ0sM/1IPkeFGLCqrn x7kEhqxAza0BBDij9ZpgQq9GsnqXVaUHHdxdp6e73Zsh4N0tmEdoQDfBiBW7lKioJ3Va fiww== X-Forwarded-Encrypted: i=1; AFNElJ+ImvU0qzZP8/w09x2gCkVEu3upi4XJiLDg6GoRboTxLfRydHKnHAZ/Ps1nqfP01Q5aESC+cf1ZcYGu0nA=@vger.kernel.org X-Gm-Message-State: AOJu0YxP4kT3XFiEqAPWSNfhtMjjkBAn/ie1weeBKFZ2JLOiDgHIn/IQ H0puZL7WbhyMZIXjKrph/YMiVQgLLfP/y3zKT0hsmxOsiYzth6C/H54G X-Gm-Gg: AeBDietJzFlXuwaZW7dAi3lBJ7ljZLG4iWV8EtmK1gS0cU5E5qfX1Sw2+jyzs1MDkwp zDgngZkNaR57OAn3EBXJKw+k3vC7x1Gr7c8q60WAaIq0CRcjpI/pwQNXjGLOPUuO112iJdZdSqr BxGASiiB3ztS5RE3m2PIlETaKhzAu62ZUX3WO7B6Cnmkh/Dj09mnOWCKVkJXqvklXOL2YcluGA6 b/XnlKYT0N5rEfHEI3RYhGsJo74b6tvR3r5BN+u6y8LK6HkINQglttcS0TLQvxfh6/cnI4znIvT jsR79JlArYEzNwaXNfjb1uHqGaG6CieeJGWI2WRnan8ZSnUyRsRs/seX+CwD+ZNQD32eqm5hp6/ fYlVViUg6zzqTLNmYhRpNajqwxT0nuIe/+wybIA9AgvNX2kjuwOow3MOW8+d8Z3fmZ1zbo4jKh2 UtbbAgocidKHPnslpwnxozWX0= X-Received: by 2002:ac2:4c4b:0:b0:5a4:b0:a072 with SMTP id 2adb3069b0e04-5a4172ca655mr9466333e87.4.1777015370516; Fri, 24 Apr 2026 00:22:50 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a41a238563sm5612550e87.55.2026.04.24.00.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:22:50 -0700 (PDT) From: Svyatoslav Ryhel To: Lee Jones , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Mauro Carvalho Chehab , Svyatoslav Ryhel Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v3 2/5] media: i2c: lm3560: Fix v4l2 subdev registration Date: Fri, 24 Apr 2026 10:22:27 +0300 Message-ID: <20260424072230.90354-3-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424072230.90354-1-clamor95@gmail.com> References: <20260424072230.90354-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The existing driver does not call media subdev registration, making it invisible to the media framework. Since the LM3560 supports two independent LEDs, register each LED as a separate media entity. Signed-off-by: Svyatoslav Ryhel --- drivers/media/i2c/lm3560.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index f4cc844f4e3c..085a0ef70e39 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -364,8 +364,15 @@ static int lm3560_subdev_init(struct lm3560_flash *fla= sh, goto err_out; flash->subdev_led[led_no].entity.function =3D MEDIA_ENT_F_FLASH; =20 - return rval; + rval =3D v4l2_async_register_subdev(&flash->subdev_led[led_no]); + if (rval < 0) { + dev_err(flash->dev, "failed to register V4L2 subdev"); + goto error_out_media; + } =20 + return rval; +error_out_media: + media_entity_cleanup(&flash->subdev_led[led_no].entity); err_out: v4l2_ctrl_handler_free(&flash->ctrls_led[led_no]); return rval; --=20 2.51.0 From nobody Fri Jun 19 07:48:34 2026 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6235C371CF9 for ; Fri, 24 Apr 2026 07:22:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015375; cv=none; b=EWIEgC/9IzvQlqmARDVIh7CuwiliVpPt0OY8uND72QcH+EC3CVZP/cZZ8VnfzNOA01UOJ7bfFkvQu5iWkYFElFxmZ3Gc3dNlCBABblIllP4ccaE5myffIZmqkhzRWYb3cFFWMrA5BLpjMU98sedyzb+2BDGFmMrQ4eIh6EylxdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015375; c=relaxed/simple; bh=DPuU9UKzjNveL2Uy3y9tUPnjY6ZhEX35Z5uqTrDGofg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HBvnqkMvv4bdQ1uJ2zzDO66VVaESfTmpVlzGIv5JToDi45yp2ieiLGq8sSB3YJvB3ZviRyRhVidYohjbue8bIzGKnzx7XWYEEDiziFjzymZResS79qLDvBbtw7QMlkHzc8j0V+CBYPROJNOpt36JV4MGV4MRsbNx1anB6G+u6Uk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SwT+e/dt; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SwT+e/dt" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-5a2c500750dso8606261e87.1 for ; Fri, 24 Apr 2026 00:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777015372; x=1777620172; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WwldWTVNb+Q/QpXo1IdPnwyyFuA7X8MQ9JBz50beleY=; b=SwT+e/dtnF+HXvdlrQmeEZC0tlVMo9xLCeK2S8w+Bz6R6s4CSOfgxIkfESvU71nkhZ 1P4mHnh84BRTv8JjHhZx7wu4uuFB98c+Gayvq+NeP6+5/hxZ+q7pE6Hv/6Ji/ckT3knR zQ08CcaB/EEz+VSkTvUF1G3jpK4XB2pRkb6Gyuzrrq/2cZLvP3dKuhDZ+KzNBuK6nZ6k LCdBFj1D3xlr9ox0vjcxj13hbye14vQpngehoMZVb9wiDFwIavEp5qJqW6kOJnHlfjzE ZE3pUPDfOh+I8vjMnYcP79740hukY9EqGyF1NznXlg8oKs804BirRCAbXLyoeU+/vS+W fY9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777015372; x=1777620172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WwldWTVNb+Q/QpXo1IdPnwyyFuA7X8MQ9JBz50beleY=; b=l4yw/58QC1ktPK8TVS69AAx0udlpUHJlyhCYTM/APeuYxkUwlQmT7AbWIZ6WArxnJY vT5Axs8tQ7FI5qF/hoE8PWVqL9RTbFqtRr3XmGq5b8eqAJcG1FsT3DBwt25u3JUyF7CK COlHBNbUW9nfrlHXNORSNTIicT4PGa8sh/XZAHCeNYaZO3v/ND5+ZuHqEjZEgKKsotaq fMskxwcDcLTmzKKl3HzOoXJgSWh7Jlt2vm83CoWKjJ9tcx5oNNviWX/vlfFVuefwUT0+ IAZL+1VeAtARWm1jLYKIYZ18a4K9ImbycfaEHqftx7l9rqBpi33ysefW2/Ytro6Bk4th RY9A== X-Forwarded-Encrypted: i=1; AFNElJ+eIgLPW95h4GyHV1Wl5OXDhjThwXnyZSopLkGAX3M6Xk2Ypv1rHbfqxK4ZzFTCKOTaOLh8eEDRA9eq05w=@vger.kernel.org X-Gm-Message-State: AOJu0YyMU00xO7pQqzamfDkMFu2q3lcVUhX2fUvtEIyD4RInWNwSILpe PMdrTmBhYaTIcD+VnH35E3wkPE0+1l87pdnJqLaQ27IaVqkVA9EZJgEk X-Gm-Gg: AeBDietrLnbxX2IFd9SXMfLYyXbGmSJlEadpKeB0uh/svYw0ByDV/rs32zCi/TQkWIo vSJe7FQIQaDkYu/j2MhjVXueAhlYz8A31VIIMniZAlUqrek0qKQAmFEFzZoSBo6tYyN/3CQcwqF FpjujuQS8NSpSo01E/AMwNRpm1eZRYEpuw5sQNZQbuF6hIVC5Xj/E1TzVjOTKQPEVKWS3yRPTLw ZAgK6bUfSGkEzX7BV4HEn5uhVqTNsxBI537mBDiPNs+BxtuDbwlYtuvC7Rh0hJCC3C4ZmIacH8L n/HwwMQCGjON9Wsn9MoCtzGsR5K9amM6mkxcEzKnZ/ZmolBkvCfeGeSZKgZekDg53ax9n6Px8yA /ZA8PYMHp0Z6ZV0RSPw1kuS9QkIQsj2C89iDVzoA4DsYZtXDZT4LtgyoOySyGdLQRiXR7CpxxZA KLs85eVUWILRFe5QvxSCbUj54= X-Received: by 2002:a05:6512:8005:20b0:5a4:1904:b1fb with SMTP id 2adb3069b0e04-5a41904b214mr6711948e87.40.1777015371479; Fri, 24 Apr 2026 00:22:51 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a41a238563sm5612550e87.55.2026.04.24.00.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:22:51 -0700 (PDT) From: Svyatoslav Ryhel To: Lee Jones , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Mauro Carvalho Chehab , Svyatoslav Ryhel Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v3 3/5] media: i2c: lm3560: Optimize mutex lock usage Date: Fri, 24 Apr 2026 10:22:28 +0300 Message-ID: <20260424072230.90354-4-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424072230.90354-1-clamor95@gmail.com> References: <20260424072230.90354-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Pass the device's own mutex lock to the control handler so that the media framework can handle control access instead of managing it manually. The lock must be common to both sub-devices, so the individual sub-device locks will not work here. Signed-off-by: Svyatoslav Ryhel --- drivers/media/i2c/lm3560.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 085a0ef70e39..5cd22c2fbb64 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -162,14 +162,12 @@ static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, en= um lm3560_led_id led_no) struct lm3560_flash *flash =3D to_lm3560_flash(ctrl, led_no); int rval =3D -EINVAL; =20 - mutex_lock(&flash->lock); - if (ctrl->id =3D=3D V4L2_CID_FLASH_FAULT) { s32 fault =3D 0; unsigned int reg_val; rval =3D regmap_read(flash->regmap, REG_FLAG, ®_val); if (rval < 0) - goto out; + return rval; if (reg_val & FAULT_SHORT_CIRCUIT) fault |=3D V4L2_FLASH_FAULT_SHORT_CIRCUIT; if (reg_val & FAULT_OVERTEMP) @@ -179,8 +177,6 @@ static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) ctrl->cur.val =3D fault; } =20 -out: - mutex_unlock(&flash->lock); return rval; } =20 @@ -190,8 +186,6 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) u8 tout_bits; int rval =3D -EINVAL; =20 - mutex_lock(&flash->lock); - switch (ctrl->id) { case V4L2_CID_FLASH_LED_MODE: flash->led_mode =3D ctrl->val; @@ -202,14 +196,12 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, en= um lm3560_led_id led_no) case V4L2_CID_FLASH_STROBE_SOURCE: rval =3D regmap_update_bits(flash->regmap, REG_CONFIG1, 0x04, (ctrl->val) << 2); - if (rval < 0) - goto err_out; break; =20 case V4L2_CID_FLASH_STROBE: if (flash->led_mode !=3D V4L2_FLASH_LED_MODE_FLASH) { rval =3D -EBUSY; - goto err_out; + break; } flash->led_mode =3D V4L2_FLASH_LED_MODE_FLASH; rval =3D lm3560_mode_ctrl(flash); @@ -218,7 +210,7 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) case V4L2_CID_FLASH_STROBE_STOP: if (flash->led_mode !=3D V4L2_FLASH_LED_MODE_FLASH) { rval =3D -EBUSY; - goto err_out; + break; } flash->led_mode =3D V4L2_FLASH_LED_MODE_NONE; rval =3D lm3560_mode_ctrl(flash); @@ -239,8 +231,6 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) break; } =20 -err_out: - mutex_unlock(&flash->lock); return rval; } =20 @@ -332,6 +322,8 @@ static int lm3560_init_controls(struct lm3560_flash *fl= ash, return hdl->error; =20 flash->subdev_led[led_no].ctrl_handler =3D hdl; + flash->subdev_led[led_no].ctrl_handler->lock =3D &flash->lock; + return 0; } =20 --=20 2.51.0 From nobody Fri Jun 19 07:48:34 2026 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DF11373C1E for ; Fri, 24 Apr 2026 07:22:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015376; cv=none; b=qX+BRkrqqDzLA3V3X3jZCLHXHxJ4RFYdfEYhthDPtx5NdZbHMEuMPylmD9bSxMsP0Pt/5tppS913DYkOsZWgl53WWGQO9hT7XK3jszzUNu70BYu34az7D0bYA8pk4z69+edJ+29e22DVWzZvLGoYfRx0iWtGlCKbo/SYp6T6MV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015376; c=relaxed/simple; bh=AaqElH9zuTNCv1HJ0+GB1hU2qCY3xf1+6Kn/cjf0+eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lK4D2RpKtcYenWBTyb5Y0Ah9ZlAvekQM3atTafTHdkJLP4GIgT2L81vJBpKuceBZfHz1nrdfLNuMR4IA1126YYgA5IffoUF7PEmmr8L6ve3Hs6/T02mC7h6i/pQ7fzt5YhMCyUZdyIyciRJ2hpjH6qfbjd6a64SGiFqYNm8mfAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BAmVxJ2u; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BAmVxJ2u" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-38e936caafeso74866811fa.2 for ; Fri, 24 Apr 2026 00:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777015373; x=1777620173; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eaoyCyrMENabXEPbF12o+TCRZ1+bwFFYGgCjy5VoZDY=; b=BAmVxJ2u6VRiC+a2xjjmjaD1Sd1Kst9H66acWDyG6V6plceg5aBDIjELYjlvbmPLY0 NiHf8GcVSBPw/H942QTyXnPQ+Zy0xxhNn2B7zRqv2HpDrmcDrZDHBocBE5UV1D+9Ja2c kq2wkWGBEJQz2pdayZV9v5SkrSiXsVw9Llfxoz7QtuRFUOUBxOcJAH48XHomWMoPxk2D 0Q/Mz1djLE6kLIQEarPYWU2fZcTw29Lso8RAkOqOqGMSBgIMPFuEDakZMqPGUIsGAR7I 5p4lKErLaR4PJLxyU3pPrAGrVwBR4ODBmmdlLfxZIbrYMwj7yGdwLnaXXbF96bZK8ZcI QMlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777015373; x=1777620173; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eaoyCyrMENabXEPbF12o+TCRZ1+bwFFYGgCjy5VoZDY=; b=ThSawfwCqVZecHsKCzf1UHdqO28FclMrHQ5a68qugN+Ch6XNndKR6/770f0qx7lQG0 Kl9Y0EAQkS6M7vlfnMZkWJ0hrAtNZ3VelxDs3JWcyYBHgnDkRMhdAVa3qqoE49rrbHQS 8D4WwLPxmMbJYeaJZ3mQCAqwV69+paXOLgzTA8Nqy7ZqQPofCNDNFh62lCTVZO6JSZUs LLDb1ir7zaSoBfZ26QwfkdPd69ndguzhN3uphrLJR6XkFftSlLu+cjDsBvPncIuzYf1/ oe4P64wlMjgVZqo9uXs542gpzQTjS6xft6TjVPsIsakhdaxNiwJcZfYEKBOebDRRwdKn 7oqw== X-Forwarded-Encrypted: i=1; AFNElJ+Sv7im/HTAz8QAXnAAO8bXqmBFL1Z/6o0e0E191Ycuog/m/MMQXpKMg4dCKipODlT6+JBx05+ERNIBxaQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy2WSU6kzb14+N9VR4hPBbHoOtOP1Vjf7F92IlCW+ya+Ah0GpIh rhBTvwFbyNJ2Bi+XwynhoilmIVYq6XWcfJc5DHalxnABS6c9fbiqVmNR X-Gm-Gg: AeBDievw80gI1+LCeqlab3tsD/lTd1RyQPZnrRQ4I3fGhGGpc8fHr+72nhN40P0GWMo xZxiFAvXERRNgKvZzvK9ugl3MgsrjIqfqHB5F95xKHMiPn6+RmQZCD4OhjHjhqbKBcNnBKTWR6w QFkalvce1mKpiy9BUO9Cm2VVCawb74YEpEiLs2nMojKO2ZV+NkaGYV+JBE+t5UZenyVaIgjLfSg OD1cfqEYQDZ//9yYoweQTpYRYhKTAwp+sn8efFWfVeptuaM/ppLyR3+JlJ3Fs1K2UGLms0QQYrw xg8BImg+PCAD1AR0oHrr6IYcYGzRzKdPDHD8JJb7s2BdUbqPRYCau6EVYDOxljAHcCdu4ePyCNc YbeBh93KRGK7CTtDXI9UzpoK9zs4V7uq4WVQha3gEwk+j+kMbVZU04ZR0lAiydw4hXq+mNVjmt9 J5ekf8jXBYXm0cOpTGsYDwP5c= X-Received: by 2002:a05:6512:b99:b0:5a3:cc81:efdb with SMTP id 2adb3069b0e04-5a4172de867mr9444067e87.21.1777015372443; Fri, 24 Apr 2026 00:22:52 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a41a238563sm5612550e87.55.2026.04.24.00.22.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:22:52 -0700 (PDT) From: Svyatoslav Ryhel To: Lee Jones , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Mauro Carvalho Chehab , Svyatoslav Ryhel Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v3 4/5] media: i2c: lm3560: Convert to use OF bindings Date: Fri, 24 Apr 2026 10:22:29 +0300 Message-ID: <20260424072230.90354-5-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424072230.90354-1-clamor95@gmail.com> References: <20260424072230.90354-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since there are no users of this driver via platform data, remove platform data and switch to using device tree bindings. Signed-off-by: Svyatoslav Ryhel --- drivers/media/i2c/lm3560.c | 112 ++++++++++++++++++++++++++----------- include/media/i2c/lm3560.h | 15 ----- 2 files changed, 79 insertions(+), 48 deletions(-) diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 5cd22c2fbb64..022a6a76befb 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -13,7 +13,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -43,22 +45,30 @@ enum led_enable { * struct lm3560_flash * * @dev: pointer to &struct device - * @pdata: platform data * @regmap: reg. map for i2c * @lock: muxtex for serial access. * @led_mode: V4L2 LED mode * @ctrls_led: V4L2 controls * @subdev_led: V4L2 subdev + * @peak: peak current + * @max_flash_timeout: flash timeout + * @max_flash_brt: flash mode led brightness + * @max_torch_brt: torch mode led brightness */ struct lm3560_flash { struct device *dev; - struct lm3560_platform_data *pdata; struct regmap *regmap; struct mutex lock; =20 enum v4l2_flash_led_mode led_mode; struct v4l2_ctrl_handler ctrls_led[LM3560_LED_MAX]; struct v4l2_subdev subdev_led[LM3560_LED_MAX]; + + enum lm3560_peak_current peak; + u32 max_flash_timeout; + + u32 max_flash_brt[LM3560_LED_MAX]; + u32 max_torch_brt[LM3560_LED_MAX]; }; =20 #define to_lm3560_flash(_ctrl, _no) \ @@ -269,8 +279,8 @@ static int lm3560_init_controls(struct lm3560_flash *fl= ash, enum lm3560_led_id led_no) { struct v4l2_ctrl *fault; - u32 max_flash_brt =3D flash->pdata->max_flash_brt[led_no]; - u32 max_torch_brt =3D flash->pdata->max_torch_brt[led_no]; + u32 max_flash_brt =3D flash->max_flash_brt[led_no]; + u32 max_torch_brt =3D flash->max_torch_brt[led_no]; struct v4l2_ctrl_handler *hdl =3D &flash->ctrls_led[led_no]; const struct v4l2_ctrl_ops *ops =3D &lm3560_led_ctrl_ops[led_no]; =20 @@ -295,9 +305,9 @@ static int lm3560_init_controls(struct lm3560_flash *fl= ash, /* flash strobe timeout */ v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_TIMEOUT, LM3560_FLASH_TOUT_MIN, - flash->pdata->max_flash_timeout, + flash->max_flash_timeout, LM3560_FLASH_TOUT_STEP, - flash->pdata->max_flash_timeout); + flash->max_flash_timeout); =20 /* flash brt */ v4l2_ctrl_new_std(hdl, ops, V4L2_CID_FLASH_INTENSITY, @@ -339,15 +349,18 @@ static const struct regmap_config lm3560_regmap =3D { }; =20 static int lm3560_subdev_init(struct lm3560_flash *flash, - enum lm3560_led_id led_no, char *led_name) + enum lm3560_led_id led_no, + struct fwnode_handle *fwnode) { struct i2c_client *client =3D to_i2c_client(flash->dev); int rval; =20 v4l2_i2c_subdev_init(&flash->subdev_led[led_no], client, &lm3560_ops); flash->subdev_led[led_no].flags |=3D V4L2_SUBDEV_FL_HAS_DEVNODE; - strscpy(flash->subdev_led[led_no].name, led_name, - sizeof(flash->subdev_led[led_no].name)); + snprintf(flash->subdev_led[led_no].name, + sizeof(flash->subdev_led[led_no].name), + "lm3560-led%d", led_no); + flash->subdev_led[led_no].fwnode =3D fwnode; rval =3D lm3560_init_controls(flash, led_no); if (rval) goto err_out; @@ -377,7 +390,7 @@ static int lm3560_init_device(struct lm3560_flash *flas= h) =20 /* set peak current */ rval =3D regmap_update_bits(flash->regmap, - REG_FLASH_TOUT, 0x60, flash->pdata->peak); + REG_FLASH_TOUT, 0x60, flash->peak); if (rval < 0) return rval; /* output disable */ @@ -393,8 +406,9 @@ static int lm3560_init_device(struct lm3560_flash *flas= h) static int lm3560_probe(struct i2c_client *client) { struct lm3560_flash *flash; - struct lm3560_platform_data *pdata =3D dev_get_platdata(&client->dev); - int rval; + struct fwnode_handle *node; + u32 peak_ua; + int rval, reg; =20 flash =3D devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); if (flash =3D=3D NULL) @@ -406,36 +420,60 @@ static int lm3560_probe(struct i2c_client *client) return rval; } =20 - /* if there is no platform data, use chip default value */ - if (pdata =3D=3D NULL) { - pdata =3D devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL); - if (pdata =3D=3D NULL) - return -ENODEV; - pdata->peak =3D LM3560_PEAK_3600mA; - pdata->max_flash_timeout =3D LM3560_FLASH_TOUT_MAX; - /* led 1 */ - pdata->max_flash_brt[LM3560_LED0] =3D LM3560_FLASH_BRT_MAX; - pdata->max_torch_brt[LM3560_LED0] =3D LM3560_TORCH_BRT_MAX; - /* led 2 */ - pdata->max_flash_brt[LM3560_LED1] =3D LM3560_FLASH_BRT_MAX; - pdata->max_torch_brt[LM3560_LED1] =3D LM3560_TORCH_BRT_MAX; - } - flash->pdata =3D pdata; flash->dev =3D &client->dev; mutex_init(&flash->lock); =20 - rval =3D lm3560_subdev_init(flash, LM3560_LED0, "lm3560-led0"); - if (rval < 0) - return rval; + flash->peak =3D LM3560_PEAK_1600mA; + rval =3D device_property_read_u32(flash->dev, + "ti,peak-current-microamp", &peak_ua); + if (!rval) { + switch (peak_ua) { + case 16000000: + flash->peak =3D LM3560_PEAK_1600mA; + break; + case 23000000: + flash->peak =3D LM3560_PEAK_2300mA; + break; + case 30000000: + flash->peak =3D LM3560_PEAK_3000mA; + break; + case 36000000: + flash->peak =3D LM3560_PEAK_3600mA; + break; + default: + return -EINVAL; + } + } =20 - rval =3D lm3560_subdev_init(flash, LM3560_LED1, "lm3560-led1"); - if (rval < 0) - return rval; + flash->max_flash_timeout =3D LM3560_FLASH_TOUT_MIN * 1000; + device_property_read_u32(flash->dev, "flash-max-timeout-us", + &flash->max_flash_timeout); + flash->max_flash_timeout /=3D 1000; =20 rval =3D lm3560_init_device(flash); if (rval < 0) return rval; =20 + device_for_each_child_node(flash->dev, node) { + fwnode_property_read_u32(node, "reg", ®); + + if (reg =3D=3D LM3560_LED0 || reg =3D=3D LM3560_LED1) { + flash->max_flash_brt[reg] =3D LM3560_FLASH_BRT_MIN; + fwnode_property_read_u32(node, "flash-max-microamp", + &flash->max_flash_brt[reg]); + + flash->max_torch_brt[reg] =3D LM3560_TORCH_BRT_MIN; + fwnode_property_read_u32(node, "led-max-microamp", + &flash->max_torch_brt[reg]); + + rval =3D lm3560_subdev_init(flash, reg, node); + if (rval < 0) + return dev_err_probe(flash->dev, rval, + "failed to register led%d\n", + reg); + } + } + i2c_set_clientdata(client, flash); =20 return 0; @@ -453,6 +491,13 @@ static void lm3560_remove(struct i2c_client *client) } } =20 +static const struct of_device_id lm3560_of_match[] =3D { + { .compatible =3D "ti,lm3559" }, + { .compatible =3D "ti,lm3560" }, + { } +}; +MODULE_DEVICE_TABLE(of, lm3560_of_match); + static const struct i2c_device_id lm3560_id_table[] =3D { { LM3559_NAME }, { LM3560_NAME }, @@ -465,6 +510,7 @@ static struct i2c_driver lm3560_i2c_driver =3D { .driver =3D { .name =3D LM3560_NAME, .pm =3D NULL, + .of_match_table =3D lm3560_of_match, }, .probe =3D lm3560_probe, .remove =3D lm3560_remove, diff --git a/include/media/i2c/lm3560.h b/include/media/i2c/lm3560.h index 770d8c72c94a..b56c1ff8fd49 100644 --- a/include/media/i2c/lm3560.h +++ b/include/media/i2c/lm3560.h @@ -66,19 +66,4 @@ enum lm3560_peak_current { LM3560_PEAK_3600mA =3D 0x60 }; =20 -/* struct lm3560_platform_data - * - * @peak : peak current - * @max_flash_timeout: flash timeout - * @max_flash_brt: flash mode led brightness - * @max_torch_brt: torch mode led brightness - */ -struct lm3560_platform_data { - enum lm3560_peak_current peak; - - u32 max_flash_timeout; - u32 max_flash_brt[LM3560_LED_MAX]; - u32 max_torch_brt[LM3560_LED_MAX]; -}; - #endif /* __LM3560_H__ */ --=20 2.51.0 From nobody Fri Jun 19 07:48:34 2026 Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74792378815 for ; Fri, 24 Apr 2026 07:22:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015377; cv=none; b=V4oxUNPzP3WtY9NjDFDYqZPtY1364leb6kOj4uvpQo9dg3bGywWaMUQxE0SXdeKT+reOsX/yU/x3y2tcxhRgmQXmM3xb+l7w+vmGQADgoVK9ym+KenTjc9FsOHo6jlVpFq3l4SrHHL3lGmJdY/MYvwWTucyqEWwTcvI6COTm1N4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777015377; c=relaxed/simple; bh=uYzCO2a7lwvw6rXeiwoe9LzLhm1VKeGalP4isbTrZz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M52km8Hm6DuyKvqlyGPXV0Nj/qZo3+Qb39irk5UJK3iy/keF+rn4tj/l5+mi5Fa5TeCwteqjgxn6pfFpEzZX0lppCPCq+ftLvNkhRZicj0/8YPdt40Q9KYun/5llMBrJcRSEQctbPuEU650oApJ8Hj4Tmg4H/BxvPGtsmQpWTkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a3xwtS0q; arc=none smtp.client-ip=209.85.167.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a3xwtS0q" Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-5a3fcb2c718so6406229e87.0 for ; Fri, 24 Apr 2026 00:22:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777015374; x=1777620174; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MTjooS0n+OLO5qAqY+PpCTXsi3phlO0GRX2wY3bD3Wo=; b=a3xwtS0qEv1Yk0Q2l1h/TXs7UHC6TE4jpBd/SumvBs179pIlmJrjECan/LhKI/3tRP 1quI+kDms/a+8FPdZLjBBH6C6PltS02SrSlNOXhdcpq+rK2BbYWUhcweXMd0u2HEN1MJ Zai/4mnKBmOAEf4NrzmI6dCfEOCcwkydWCBpAfOfcd6b+rCQTyPUOOTxM3xlX44hpV7q OgVxi7ZaQZ3hvsAtiNlTncB0zNCGmu2irZU4kzzI7/2ZN+B/6BZ2boYuiuP8xeV545ea k35JHAjR5xeGstzePAdsyJUcSAijaB/Gh3I3yVIvt5voQfGlJJPixW7F77r+sbJSUk63 T57g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777015374; x=1777620174; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MTjooS0n+OLO5qAqY+PpCTXsi3phlO0GRX2wY3bD3Wo=; b=DnJSytLP52NwkznSePvDvt65vD3qLAlWtU7RLZbmESjNyuS2yzEiIyekKDKBmEOKea 3Cm4oSDMS6NbsMY/H47qNLdMfLatFc10ZONHHPQkA5C3i5Ffkd6tTixsqo0woo7J+2ng hiMyZWBeIwQJxTBSriVJmpeEQhZH/lByEDK0KpvXHJvOPBE2V9ilk8d2+aw7l0jn1DBV q9L45YzZP4vouBf6AJmd/eLGHMqmGGHkGSIiplu0fqH4u96SxIucNl8xxSTgUFisL9UZ uzC/0JVwU9eHI7qydLJBDvG/PeH2umG4VG7p/oc8gdhffOipkFO2rsiGQYarxjj2AgWR lfmw== X-Forwarded-Encrypted: i=1; AFNElJ/BWJX05g5E9U5K143jiWcqrNZ9xlYgpPitEwCklhqNMcK9xS5SV3BI3OzVZrxGaahf/zcYs+ZAIhgWX8o=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+zO/DbaFe1u9s9PJyJ9XaNXkynSiQ4IDA1hoIFxecyZzYWD+6 bRPIaz43H80Flu3IETwMcX0rLXNVwJ37Dc7XF9FIDvFfjN4k/1QCvlw0 X-Gm-Gg: AeBDiesSJsftkTRpT9Grb5wTQD+fmnEYRD+Bs4P8QJXG0LLofWySqXhxHCbETYhbujY Jt4fpqSIFWnIWrEmsUi/mpUD+lPdmQrdmbxcb1GJ7+K4jEUmM8lbpTS6DWS+uj2wJKwERGNdFX8 aH89MQc82y8ivAIqzYTUxaxCJql0A/1sqxbZsNoqfKsZhhSYDqkZ880J7B7IzcHWyLSgYb3LMoo hjIh1VWdebu8Arvn6jXZbAUmlqQmbRKZewOp+g1m61iulKv1BIROiWaShCWLz9+acqawSkIeQm9 QjgpISem3pnnK3iUX19u1qTMkwz+QAZGSIXtGEuCZsbQ0D5dcDHp/glh9tDIaFNj6RpmgnMPQ+F A+pafVGki4QSdOSQXBpSEQp7QRD/41qpwptC/XJnPT6lsYKSCyVI4WSNYQkVbKrmhsLpInWoba/ /gbdh1VNCbhjymK85aTsCiW0Y= X-Received: by 2002:a05:6512:39c7:b0:5a2:a703:969 with SMTP id 2adb3069b0e04-5a4172f61e8mr11674232e87.40.1777015373466; Fri, 24 Apr 2026 00:22:53 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5a41a238563sm5612550e87.55.2026.04.24.00.22.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 00:22:53 -0700 (PDT) From: Svyatoslav Ryhel To: Lee Jones , Pavel Machek , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Mauro Carvalho Chehab , Svyatoslav Ryhel Cc: linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v3 5/5] media: i2c: lm3560: Add support for PM features Date: Fri, 24 Apr 2026 10:22:30 +0300 Message-ID: <20260424072230.90354-6-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260424072230.90354-1-clamor95@gmail.com> References: <20260424072230.90354-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for power management features to better control the LM3560 within the media framework. To achieve the desired PM support, the HWEN GPIO and VIN power supply were added and configured into power on/off sequences. Media device deregistration helpers were grouped into a separate function to simplify the probe/remove process. Added PM operations along with the PM configuration setup. Signed-off-by: Svyatoslav Ryhel --- drivers/media/i2c/lm3560.c | 123 +++++++++++++++++++++++++++++++++---- 1 file changed, 111 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 022a6a76befb..ebb30d45fdfe 100644 --- a/drivers/media/i2c/lm3560.c +++ b/drivers/media/i2c/lm3560.c @@ -11,12 +11,15 @@ =20 #include #include +#include #include #include #include #include +#include #include #include +#include #include #include #include @@ -47,6 +50,8 @@ enum led_enable { * @dev: pointer to &struct device * @regmap: reg. map for i2c * @lock: muxtex for serial access. + * @hwen_gpio: line connected to HWEN pin + * @vin_supply: line connected to IN supply (2.5V - 5.5V) * @led_mode: V4L2 LED mode * @ctrls_led: V4L2 controls * @subdev_led: V4L2 subdev @@ -60,6 +65,9 @@ struct lm3560_flash { struct regmap *regmap; struct mutex lock; =20 + struct gpio_desc *hwen_gpio; + struct regulator *vin_supply; + enum v4l2_flash_led_mode led_mode; struct v4l2_ctrl_handler ctrls_led[LM3560_LED_MAX]; struct v4l2_subdev subdev_led[LM3560_LED_MAX]; @@ -172,12 +180,17 @@ static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, en= um lm3560_led_id led_no) struct lm3560_flash *flash =3D to_lm3560_flash(ctrl, led_no); int rval =3D -EINVAL; =20 + if (!pm_runtime_get_if_in_use(flash->dev)) + return 0; + if (ctrl->id =3D=3D V4L2_CID_FLASH_FAULT) { s32 fault =3D 0; unsigned int reg_val; rval =3D regmap_read(flash->regmap, REG_FLAG, ®_val); - if (rval < 0) + if (rval < 0) { + pm_runtime_put(flash->dev); return rval; + } if (reg_val & FAULT_SHORT_CIRCUIT) fault |=3D V4L2_FLASH_FAULT_SHORT_CIRCUIT; if (reg_val & FAULT_OVERTEMP) @@ -187,6 +200,8 @@ static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) ctrl->cur.val =3D fault; } =20 + pm_runtime_put(flash->dev); + return rval; } =20 @@ -196,6 +211,9 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) u8 tout_bits; int rval =3D -EINVAL; =20 + if (!pm_runtime_get_if_in_use(flash->dev)) + return 0; + switch (ctrl->id) { case V4L2_CID_FLASH_LED_MODE: flash->led_mode =3D ctrl->val; @@ -241,6 +259,8 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum= lm3560_led_id led_no) break; } =20 + pm_runtime_put(flash->dev); + return rval; } =20 @@ -403,6 +423,49 @@ static int lm3560_init_device(struct lm3560_flash *fla= sh) return rval; } =20 +static int lm3560_power_off(struct device *dev) +{ + struct lm3560_flash *flash =3D dev_get_drvdata(dev); + + gpiod_set_value_cansleep(flash->hwen_gpio, 0); + regulator_disable(flash->vin_supply); + + return 0; +} + +static int lm3560_power_on(struct device *dev) +{ + struct lm3560_flash *flash =3D dev_get_drvdata(dev); + int rval; + + rval =3D regulator_enable(flash->vin_supply); + if (rval < 0) { + dev_err(flash->dev, "failed to enable vin power supply\n"); + return rval; + } + + gpiod_set_value_cansleep(flash->hwen_gpio, 1); + + rval =3D lm3560_init_device(flash); + if (rval < 0) { + lm3560_power_off(dev); + return rval; + } + + return 0; +} + +static void lm3560_subdev_cleanup(struct lm3560_flash *flash) +{ + unsigned int i; + + for (i =3D LM3560_LED0; i < LM3560_LED_MAX; i++) { + v4l2_device_unregister_subdev(&flash->subdev_led[i]); + v4l2_ctrl_handler_free(&flash->ctrls_led[i]); + media_entity_cleanup(&flash->subdev_led[i].entity); + } +} + static int lm3560_probe(struct i2c_client *client) { struct lm3560_flash *flash; @@ -423,6 +486,17 @@ static int lm3560_probe(struct i2c_client *client) flash->dev =3D &client->dev; mutex_init(&flash->lock); =20 + flash->hwen_gpio =3D devm_gpiod_get_optional(&client->dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(flash->hwen_gpio)) + return dev_err_probe(&client->dev, PTR_ERR(flash->hwen_gpio), + "failed to get hwen gpio\n"); + + flash->vin_supply =3D devm_regulator_get(&client->dev, "vin"); + if (IS_ERR(flash->vin_supply)) + return dev_err_probe(&client->dev, PTR_ERR(flash->vin_supply), + "failed to get vin-supply\n"); + flash->peak =3D LM3560_PEAK_1600mA; rval =3D device_property_read_u32(flash->dev, "ti,peak-current-microamp", &peak_ua); @@ -450,10 +524,13 @@ static int lm3560_probe(struct i2c_client *client) &flash->max_flash_timeout); flash->max_flash_timeout /=3D 1000; =20 - rval =3D lm3560_init_device(flash); + rval =3D lm3560_power_on(flash->dev); if (rval < 0) return rval; =20 + pm_runtime_set_active(flash->dev); + pm_runtime_enable(flash->dev); + device_for_each_child_node(flash->dev, node) { fwnode_property_read_u32(node, "reg", ®); =20 @@ -467,30 +544,52 @@ static int lm3560_probe(struct i2c_client *client) &flash->max_torch_brt[reg]); =20 rval =3D lm3560_subdev_init(flash, reg, node); - if (rval < 0) - return dev_err_probe(flash->dev, rval, - "failed to register led%d\n", - reg); + if (rval < 0) { + dev_err(flash->dev, + "failed to register led%d\n", reg); + goto error_clean; + } } } =20 i2c_set_clientdata(client, flash); =20 + pm_runtime_set_autosuspend_delay(flash->dev, 1000); + pm_runtime_use_autosuspend(flash->dev); + pm_runtime_idle(flash->dev); + return 0; + +error_clean: + pm_runtime_disable(flash->dev); + pm_runtime_set_suspended(flash->dev); + lm3560_subdev_cleanup(flash); + lm3560_power_off(flash->dev); + + return rval; } =20 static void lm3560_remove(struct i2c_client *client) { struct lm3560_flash *flash =3D i2c_get_clientdata(client); - unsigned int i; =20 - for (i =3D LM3560_LED0; i < LM3560_LED_MAX; i++) { - v4l2_device_unregister_subdev(&flash->subdev_led[i]); - v4l2_ctrl_handler_free(&flash->ctrls_led[i]); - media_entity_cleanup(&flash->subdev_led[i].entity); + lm3560_subdev_cleanup(flash); + + /* + * Disable runtime PM. In case runtime PM is disabled in the kernel, + * make sure to turn power off manually. + */ + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) { + lm3560_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); } } =20 +static const struct dev_pm_ops lm3560_pm_ops =3D { + SET_RUNTIME_PM_OPS(lm3560_power_off, lm3560_power_on, NULL) +}; + static const struct of_device_id lm3560_of_match[] =3D { { .compatible =3D "ti,lm3559" }, { .compatible =3D "ti,lm3560" }, @@ -509,7 +608,7 @@ MODULE_DEVICE_TABLE(i2c, lm3560_id_table); static struct i2c_driver lm3560_i2c_driver =3D { .driver =3D { .name =3D LM3560_NAME, - .pm =3D NULL, + .pm =3D &lm3560_pm_ops, .of_match_table =3D lm3560_of_match, }, .probe =3D lm3560_probe, --=20 2.51.0