From nobody Tue Jun 16 11:19:19 2026 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 4EB95372EF3 for ; Sun, 19 Apr 2026 09:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591278; cv=none; b=Ynr3dP+TAMVfoE62M0pljEg1zHvR3JJc3anHgSBd7XqpYNfBVeY6bf9tjm1xJNhG13gbzPDKk0du92N9vOelFAW+X0uQ6lNUV9Kq0sIQ2eFTMzxKjtsh4V8S08wjsT49KLSP3G8cfUOnh3ABpqMrOfIdodOCEFenPfr+EDjWCXs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591278; c=relaxed/simple; bh=BK0hEglzpcSXJd/OKj+ViYaIq6REZlgwXiNFnkXSX+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OZbMD3X5sra6rXxXyjvNYDYZTeRfHL6ayU3mDQjGSgoT87+zR81WaVEmi7iw3a9odfHe0Ycn13Jb7uxdKidGgt5iFnIP+pqF0lr+bm2ppLWYkBFxr++7wNmk3XoplnWrqCsJdbIunjCN+d/xN39NM1V6UHQUi2yKYzbBg2rD4Nk= 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=Dfxa+x+T; arc=none smtp.client-ip=209.85.208.176 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="Dfxa+x+T" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-38e9653b580so21221531fa.2 for ; Sun, 19 Apr 2026 02:34:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776591275; x=1777196075; 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=6tC+sS2x5WFciQYjGn4heKGQVAU6/El17ETWgsL8Nkk=; b=Dfxa+x+TFYxbRiPLvAOSDD5gQyWf3Neo7Fhoy7DC0EKqY8Ls5R+P/M73cNpDV6Indo nEvpzVuqnaE+PsJckN3iDmttByc1zcAR7brI+Gsl9X6LEF2lv46rtbV78ajhBW/o8V4g qNOywOdrgjhtZjhRAEF7RGlOXAxeVlmfsRnf41uhivjLFSAtIrNsA82MDN2BKhwsFYJC d/PQ7hF0DN3wvkaN25HFgecAbSN5BZSMHD6SCVE//Rg3x3Mope9cccngwrYlGx9oiSuN J4QQEPTtBo1jpxbkxfeQmoD4g5R9P7pxwHfEKmfpqzg0/qx5NAPSTsD0A4VBOyYDnvt9 6dMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776591275; x=1777196075; 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=6tC+sS2x5WFciQYjGn4heKGQVAU6/El17ETWgsL8Nkk=; b=DqbqcKuKScHmjgTUCitIELcHvDlatKGq14p0/1+h3L8FkALQDi8wTxa28CCJ4SFrdj 1kDh9R55MceNj1j60nCFvGW9Ejdbw0n8vJlWRpjDPjQLqfx1XlTPZvpCTK50nYaKTRTj TywF+fenAE9X0xFVIjThEQ8d45ZLfdISWyKk+CRpYzJcsBCoGGhJjJE0FB7JsWjZgFcE UgcHthd2Yb6zXqgEYmx28BUS0lPhVssTwy6lVFWvteupPtQVquY7ksfIOPM8tziCxEIu Sprqu9QipmPSLDdtGxs9O3XnVoE4zWrb/SGPMV+60NhG5jY5rGUYu1Gm7JrnNVGEi0dT Is0w== X-Forwarded-Encrypted: i=1; AFNElJ+SrlG7e6P3CRK44j9m7rYMqojQCiOCwoKHBED79DDFP6SXmSzmuXIbc8nE6sOEJD0Esqt9gAG+tUp/HQ8=@vger.kernel.org X-Gm-Message-State: AOJu0YwQiUVwQbwVxPa8vsc9Om/s8uflO/1yi2mA8ubEf8Bk2hihRhYQ bnKDyru2TU1iUfvwHMeMeB4hpGE48/jrhlLeOppJlq2J6Ua1fcUht4rw X-Gm-Gg: AeBDieuwL2Ffz3vZQQCa/EABsYx84Llizs46hgS6l7WSIEep3F60Qy6x08fZhmmcslw X1di3zHRnQZxRF16qP8OlJMi2x/9zUozfxCxezd02HoDdwtPn1USUh29QHb/+MfARkMGl256mRH +ep0DrEdssdDj60o/FQThix2y2m4bBNYiCoZ/LkJysxZjKZNWyNhFBbBgdSesGR/701iBPaotgU 0Lg1amGCdSN2J8UT5n4UFFsyE/LwyeCi/+aAuZD/AjYLtFE2OrV8LV4co7qsSPJ6n3gTutjmL4u pQSxeYm3DYs3IUHOvhMKAiI3LWvITc8QqccUXpR+sbrqku0xWA4nAFpulggyciezzCl75KiVEOp alR5s1zNr9lFKe+YKFy63j1SsB+iAd7AtAnrALQmFrQycjHlZW10L4hKOsJYr2NAOe5s/ulHumA u0K0XBW23RtGT5+aV6jNn5E5o= X-Received: by 2002:a2e:a549:0:b0:38e:1ebe:95f6 with SMTP id 38308e7fff4ca-38ec7b2a3camr30908711fa.28.1776591275270; Sun, 19 Apr 2026 02:34:35 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb7613a9sm18221671fa.41.2026.04.19.02.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 02:34:34 -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 v2 1/5] dt-bindings: leds: Document TI LM3560 Synchronous Boost Flash Driver Date: Sun, 19 Apr 2026 12:34:08 +0300 Message-ID: <20260419093412.40796-2-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260419093412.40796-1-clamor95@gmail.com> References: <20260419093412.40796-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" Document TI LM3560 Synchronous Boost Flash Driver used for camera flash LEDs. 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 Tue Jun 16 11:19:19 2026 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 BA2BE3002BB for ; Sun, 19 Apr 2026 09:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591281; cv=none; b=H+qGuPFBvrCRURdEKBZDIImZ0BAw/2CWkQeWxVQDxvkUFyG7QArNfSgAQV8yR5226M28UIQVean0zv+I1RG0bE5rIGxtJIus9AEYqEwFFnnTJGEdlRN3swc2D5VsokUAyVAVZ8sQEEl55OnKIkytnhm1fKiGnn1WNSAUFLpHEtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591281; c=relaxed/simple; bh=NnTZhLTZnNfRAZTpInLPnO6pd8hHUs/jOhkVX7vXeK4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IRb05XBzjPjI2xHuKozrZRuTTLpyS2o5xB9zshVYdW3/6LNNvEa5OC3RsacZFwrCeNlFKKtmHo9j1JaqYqHE3ms0w4CgnKVh3G4/R5V8tBvKguIk1pUFzSqFZbD4f9pRBvMFZFosFfd7VkuY4Se4684XG07i3i/nbtVJmRUvrgA= 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=b1UirRBg; arc=none smtp.client-ip=209.85.208.178 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="b1UirRBg" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-38e7d983f79so15946161fa.0 for ; Sun, 19 Apr 2026 02:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776591277; x=1777196077; 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=b1UirRBgWKe01ZefHYhHt1bIkKPpu++bcmRdJHnOQMF9ezzyrG6OjGKTq1n43OEFQt 0TdIMRMlYaNV2F5StHZG7tQoL4cWFnL2cT4NXCui0E3xMmnpvet+fzPLNOtZytMvfPCi z7xojrwVGisE517O659eDeEUUMXkWSJmvae4qE5S/U7rnTfw2UgTRe9ctWzUL0vZRgYY KN5qIvKuoPwixGZ58Fs9x9Eggvxsw+GW0PvYWxQyY8D/jHuWbaJRz3qyEcS4BX+CYmbn eWG7HLw92kzgY3ds0vBv91DFwD0xFv6ClSU33c09AaPWdnwC741Vy3Wuh55IWrsz24LL MYng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776591277; x=1777196077; 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=lLqdhI6Zj5K/jKi7bmxw4yvc/QZZ51GbTqB4ShJJYzxEa385TwN2q5ck1hs15nEydC QmcLRHPQ6yCqgB6qtbRBw2OKcnTK3Qr7Tr+zOR/5+eRoOo3RXG5sFon/ElSkTP4zeLrh x/t+Yvildzmflb1nc2CYXuAVfAtUCo5xEnH1h/nFUiOySg7fN0dCSf6uJTuoZar2Ir+4 CiJeZ/KusiYwnaYiWv+yjCYVa5bkzpdnh66UoQmA9263brZ8clwugQtbL10X5EHzMdc0 RUyahzyJInCracwKf0JMeXLPC6H3VLGdBLJjkuDyLclxD5Eqi5IolksNJqFB2KtylQQ/ lTcw== X-Forwarded-Encrypted: i=1; AFNElJ9ejJfLuOxNwtd3R333EsqXtwyohvRvlhen8dQ/qsu2QmG6Z+rD8AgTaOFTYMs7Q5T34R6Wk8YEsQQfGi0=@vger.kernel.org X-Gm-Message-State: AOJu0YwJHWSeP7zmpZpdipx+Qy/rvNJSS7PUQibwUjrdVyUABe+VBGjs tIb6tCkx3Bxk1IcOTdQwBtbTCSHEtmvXTwKLXUSw+XSj23Jvxr33k3Qw X-Gm-Gg: AeBDiesDX3AmWMI83wK2ZKnDHuBwrXBlSjt3+OV3HH7V6GEl8jEwtJkgagg9W0cNTB6 LfqY52Q2dGCIgPb8nKbmiPN8nTpGilQczypk4Xnau0AbmSAn3y/f+r8x/Gr42m5gIE6Jd0IibBC rvAGlSFBNnq971czks8atTw3HK1Eac9GY6BuUnyPNNNbV+rXNJ+oYdLwZ6s2dov9ZOTMQerRFBz CO26X4IMcfl+OD3T+3+g5cEh2I4K7h6Y7HzH0uhDiuvf1H9USugnp5XbKuFQCAkJSPOMzg016CB 97TyiZoEuDDNds7RWaUkDD5oq/Gk25vG/8tuO4CImwuQhAA4EY6fey2wJptgpy2rpywhfIwYmZY X80tUBGWJSPKam8AUtmCj2SBz0moKy/dN7m1PTFgwNjPjzE2PLFBWGIhTq5YMIaQUgEsPH/kWB+ 4H35etv93lA6JOQWmi8LPPo+0QRzLtyOPkgQ== X-Received: by 2002:a05:651c:1604:b0:38e:9ef0:58be with SMTP id 38308e7fff4ca-38ec77f5aafmr27047701fa.5.1776591276767; Sun, 19 Apr 2026 02:34:36 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb7613a9sm18221671fa.41.2026.04.19.02.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 02:34:36 -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 v2 2/5] media: i2c: lm3560: Fix v4l2 subdev registration Date: Sun, 19 Apr 2026 12:34:09 +0300 Message-ID: <20260419093412.40796-3-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260419093412.40796-1-clamor95@gmail.com> References: <20260419093412.40796-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 Tue Jun 16 11:19:19 2026 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 095B337BE8E for ; Sun, 19 Apr 2026 09:34:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591281; cv=none; b=F70blOpmnywrlKUWRBGP+DHI7nuVLdkP/RXC/b89qvga27cftoBzmbiIz3IOXwg7UTcFu64XCfpL2CKPFT4DenHsW1DAiPkhadIc6xDYpMFLeV+CfnA7J1OLrGIpt7DvNp4L8aC8PmQHuu/otkR5QN2iAuDG97wlCFP4JfBtz0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591281; c=relaxed/simple; bh=DPuU9UKzjNveL2Uy3y9tUPnjY6ZhEX35Z5uqTrDGofg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UttUgqoikope8rYFLkV9Tlouko8GjN+OSk+cTAM4ffIAGJ4QfpDZLo2PXd3rC9mQmOlIYupVfpphsRQZcup3hK27vpkvSF3p+HjdDXsRKESf9i7y8mpL4idhc4guMs4skNZOFUn4q2cgC9NwpopcbQZ2tg0gZ3QLzQY4JuGBWK4= 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=gNDW6PJy; arc=none smtp.client-ip=209.85.208.170 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="gNDW6PJy" Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-38ccde812ecso20054251fa.0 for ; Sun, 19 Apr 2026 02:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776591278; x=1777196078; 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=gNDW6PJyeJ00F1zQsh4NhPP1dxsb4kvt0G2Bfbo0y8O0DXc86Vvapzj20VCp5R2y04 4wxpxLLRN6ynpvk9FBeK1Q8Ej3wy3ndl+ZQ8dyP/fy+Ie0ObMYnNF7uflfEGJKUU0HGK eWVHXz3V8a/PizH5f7VQ78uct+V1Uz2fubwrCP4gaSpWRk7mI/aECcnY0hvxqifcX3JL COZq2Yg7ZqlfbOKGH+lpq/DlM8iITrTwjOfRQ9agI4DflhUEuSBMQ/7APJtv6tjnqQLd cQTybS5r5AE9S1QBJINjvUZImmx2uZQYeNki2ATbThKiy60vxJOsnPRKhiWQaPZTWil9 sWlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776591278; x=1777196078; 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=pUL6IsQQUxfXbZYs/Qx6PTAXhsNFYjCxkPsNG6tOt2XE/LRu+RelCulLKhkgMdZiHX SxwKOSSqU0HhyeC83JYP4SNRruEIaMTdTJbI1G9SXCgQ2IcZAHiVRblhV2pWoRfrp0Be NhgGj8jG8cRCKrLvC365T9P5Z7BVD7O74yxsSiMcV81pf6lPzFjtWJbnyyHRsGT4qC4f 4YfeX8RAAozqz0UnsIJM+ULO5DHV90hc77UzXf62d5bm8wtfaaC0YgiXHAPl7KZ2cjo3 ByUg6ru7Ff4oFiLPya8eHesggT3w9UHpURKc8MaHd5iE7I8MoWH3PF7BgpzSngxpaMDV 1Omw== X-Forwarded-Encrypted: i=1; AFNElJ/eglwnFV7YkOHa1HKCNkc9dtztljXLr7W1ZbauIsaQ0e6/metxfl2hB1w5gHNBF3BT/WH8XvcacJfmREg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1WXl0eNC3f1gp2Iwvz+lF0jinMJ78w7gKuK/kvfMYTZdAeMV4 reuAqxF42CEz7sgzeC6nWOpsxNLVJ9Za9uKHepwqrcCXishmwdXl8GZi X-Gm-Gg: AeBDievVdZQH8bG+YGyrrJkWsQGMrVEQc7/ny2bMeYV+2QitfyoY0CfUsk/pdWm+vjb BJBX9Cg3buO0d195dzAvt5O0+OEE9LdGHNte3YcF/39hn1VCqJuqVM5ANrX1OCw8uGAGABAAcgu 84rDISPbd3kjCtd9CR3UzWRIWRan+AptDrSv84VRMthpoUzuqZfV+Dlwnm821L3Y1xmeJGBODht 0wDDWc74HuT76nW81Pg6I8081whpeASlXBM6D+OZw4ZRuFts5ayGHRQtalEmQ6DNEDabeH6T1Oh meTn7m6tpGDu/gP1DOdFb/QDKfaBFjGMlx6fpqcT9w3ztd/Q3xgYS1NgHaQsSNBZQkO8AnSdsLC awEoSPKhQ+iW3As8htE90xtL/Ch+Eu2ZDDe7Uf1mW5b+rFip0nBjZ99VRtxSVUsnKyblScFLWBH S3qcE7nO0G7xuB56Hd8cZEO8QeJUIKnH1rbg== X-Received: by 2002:a05:651c:2344:20b0:389:e2e8:4f4c with SMTP id 38308e7fff4ca-38ec951d010mr18302131fa.21.1776591278096; Sun, 19 Apr 2026 02:34:38 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb7613a9sm18221671fa.41.2026.04.19.02.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 02:34:37 -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 v2 3/5] media: i2c: lm3560: Optimize mutex lock usage Date: Sun, 19 Apr 2026 12:34:10 +0300 Message-ID: <20260419093412.40796-4-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260419093412.40796-1-clamor95@gmail.com> References: <20260419093412.40796-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 Tue Jun 16 11:19:19 2026 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 8C3A037C0F2 for ; Sun, 19 Apr 2026 09:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591283; cv=none; b=OMru58dWMsQo1E8YBCm9db9/jPgdxII4r+K3x+hFJ7l7MCCVkB7Zuql9PT8wTc90mQtHbENW/cFnKke6iRd1jruy9ilDiWLFiaWnYc+ABw3EfZRC4Ro9qouLE4gGlEfSFK9SWbxKe1ST1owjnkf2bEp8BGIQJBudKJ/Rf2bQqP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591283; c=relaxed/simple; bh=AaqElH9zuTNCv1HJ0+GB1hU2qCY3xf1+6Kn/cjf0+eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SIZILibTCPLcR+WIW0ypI+0BqrASS7LJUu/lrXtR6GgMdhHbm6l0arSu7Gk5AuF66z4FohO4IndpRtuBUQgvt0J2IqMK25yLz/ga3b9jbvXJZWKzJUXR+QH/hmpdHLOH6p6zI3q8aVDEVAbg50uwuVOyu5Bd4nW/FcRqDxnP4oM= 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=KKYD7h5t; arc=none smtp.client-ip=209.85.167.46 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="KKYD7h5t" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5a3d1561e38so1758608e87.0 for ; Sun, 19 Apr 2026 02:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776591280; x=1777196080; 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=KKYD7h5txO1H9kd7zkSNSeEt91dMvR7KBLUVn8I8MLa7b1Ocb5jD6BJp0neDROBHie DNVmlPyzk4s4WESUYGuBE9HUIsIdmoegC+A8ywALAQFmdE77V7CTy3ukzXSQPBJwchQ8 qSTUVlLeXTmGdMD0r+di7eIIYqWF/DSVbzOTwDOmzDrIXE8lrdZqUye2mr0xApYnuRo/ KfdkCZGg05GKRN4RXif6K/v7umPGVZ3J9M5RFDAPl2os0P8pvywVGppNcAUwP+2+kaTh QPS9drRFjcmrir0I56tFSV29uXlYNckP5c1IwPHfHCs2KRPK/jwizJd5qi+0oLCVVmYH p2sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776591280; x=1777196080; 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=BEfVZ4gSCdc589+QE0HVshXi8ShO6H7E+IWXJ+caTqsibl8bvifeJzn1LK7pWFyvY6 +/1Y/kRvqk+PuAFl9AaCxnV3hjQ8WAFTOI3oG3cBNRQsIM7a38mTJ/7YeTS+NWdSMS4O oHj3Qmv24uJKV/SC3nkVNJQtSf4m+aX0ksSnlOSlmiPWyGJw8PdfCIZb+8JYl4tKXqlS 9Gi+DaldCUWxSz9VoqVKPPG34PjR/FPiMwreRBGP5qm5vQLMt4Qch9hCxC8PLGHm/va5 UrvdJw86GglYQsSNiNM5DYhQHtt/cZxveFmvd0zKV9Wprwwjz/C9jcW5bkqZ3Kh7JzOC lHHA== X-Forwarded-Encrypted: i=1; AFNElJ8rO5LCuY6Ob+mmznaJOe369I6/BoNSfIeo025jNdnsqepBkN2N/sLMJtvB/zQ11sLirCY1DxQd7SEgFjE=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/+9YzKa6fm+fJD8DQ2tLyo51uOWpnnRFkB08lyjAonIq02OiS HGyktDyEJuU2ojm0b1ALe/ZzN5zrnIu8blCGAOiCAlt663GRG/n0XFEn X-Gm-Gg: AeBDieumq0l/oKaut2ElF1jAaMTtRUQjdZ0YU3pmXCVfssNh2PNe9T6TY85986EsnKy yBP8C/i6v9H8FebR2E09VtnDC8pD8nZ4ypKgijya7HIsQg+njoJwP4k3/4Qiay9ixXGIT5rOIL/ pXf6FpSW0qoTX9LuW5ZxLq5loflWFn/Va3MDuW6wWmycpVZLW/wNlWhRpXlJ0uh7NA/Iz8gBQs0 pcYkweiIjjR7OvnQHav/BR8+LC3B1+W+ebPX5bWdIj5yjKcFmyfApfIfpw8vGMlXzcwKI2og7aN svSd5h/Mg4tBc7bEk+QcHnHOaqh8RyjqxmCsMdnY56OjPuZCXxQ3/XpT+pUS1DbZLg+WrnlqHZY n4ouapThHFcw3QgsP87EOJTJVmw+5g+IOOo69QhF0GTZpg3inOahFi8UW9dxy6RUA1m5XHpByFy H5mX4KmAnZv+SN9gTObYe9mNVcKlbVc8Dqkg== X-Received: by 2002:a05:6512:39cc:b0:5a4:ab6:81ac with SMTP id 2adb3069b0e04-5a417302144mr3422597e87.34.1776591279593; Sun, 19 Apr 2026 02:34:39 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb7613a9sm18221671fa.41.2026.04.19.02.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 02:34:38 -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 v2 4/5] media: i2c: lm3560: Convert to use OF bindings Date: Sun, 19 Apr 2026 12:34:11 +0300 Message-ID: <20260419093412.40796-5-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260419093412.40796-1-clamor95@gmail.com> References: <20260419093412.40796-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 Tue Jun 16 11:19:19 2026 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (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 D322B37D125 for ; Sun, 19 Apr 2026 09:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591285; cv=none; b=bATIUJgYOVkvBEuIx81Ac3kLQQRUYeH/TdRuc8PQ6s6daMXN1h30t0vF8IaJBfVXu/tw+yBvZ8Ih+g69FyAn/6+MjSdEXkaTv3xtrhoR+njtiIV1GH5AqOcsNeIVZd4of7BfOragL/4GFflfh9wUR4mZ8GChRQlT1oY24yXjxno= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776591285; c=relaxed/simple; bh=ZK2PZapdmsACBN8s8mYncIJi9NrYgSvG33Qhg9WudsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=myi9XuvRV2WAN6qJ6TOF8sGw6yLqfBCxo66cot6lZQ7uKvjcBEyvbB85FaNcbMnk+tisn82T9cs0AAlX8Mtgz15bAtawGRP99fkw9AcdRLNa3/iKYb5Zbj03yNQ3MyEWO9Ec1FCgxC5hKOsviKz374plARSihiSETrHbeuie8jc= 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=D5192/ac; arc=none smtp.client-ip=209.85.167.54 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="D5192/ac" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-5a3cee3a271so2283747e87.3 for ; Sun, 19 Apr 2026 02:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776591281; x=1777196081; 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=duqXMxrwVP9xmPVimr0jG3GpsUd0+k6xNRj5bMFCO5o=; b=D5192/acvcXgXI5a5s4MTKLlL+BGC4bK9KiHO9UOyo6wJRZG5WbpQXuUCJEE2JfPeA ae0i1RwQCEtI3m8sKR5GdLBlGaOoYp/U7j9vjF5MgBsiiFk9FXIJwl5WLpH4vvMgfa6d oips6zI18dmNpfDKATr/QVbsRwSREmJ8UoBsNtjeNW3KrHaoBKgg6Fii1FhYAUMhda5a 9gmXWxcUaL9F2DPdB77cc9UTOmEgiNxoJNdKZDZRInbjfoPm7cnbrDLgFRvNzwCLX6Tg N83k+em9U7lztjX4TP+Pfg/DQqO6zGKjrG0JyG5lp0hy73iJEfU8Dbb9VsHdz8oMpCGf /y/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776591281; x=1777196081; 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=duqXMxrwVP9xmPVimr0jG3GpsUd0+k6xNRj5bMFCO5o=; b=RGM1YuR5D2nCoLsu3r6TxD9l4q7I1SisZVOjp3RitBDysXj1i21+QHxTR5it6F6hxW X2AQKRcfzTzjhvlg2fSZAEiNvwuAifuvUezJJ5HPszcm0JaaauLUZsCgzyXcHHmYnoGV 6SuSfmd2ojJw7HoTaDPSn5rGEaMd3TIyNjIJo6G4jl3MncmWmHia6oKssiBNrg+SqtFC R7zGMkWgTJ9mtcpkTw6eZ1wXpymxwLKYzlACJDw/OtSyCehNDvtiQ81/m4AXfuoMPZHS 07hGv/gZl/FjvV1VSN+cbnhNqBVx/Na2znazLGxq8R/hRoT1igZQ2DqYNiQJEBIS+c2D TEJQ== X-Forwarded-Encrypted: i=1; AFNElJ8Bx19Wlf+o4Mw2VMWS11BfFKlBPXn209pttDtqAPdd6v0aUL/gY4pDMIUWck64+5JXpR6H+GloQJSP1RA=@vger.kernel.org X-Gm-Message-State: AOJu0YzYI9oxug85ZsnpS78miXkwkb+AfLsRaAf9LR/HVz+ecK/P6q73 0C4YO1NinxnU9mPs9KqD/jmbumPgBvSpyMvv7ycTmfSV5Qrrb9XjS9CV X-Gm-Gg: AeBDieuVMI5xk+zRtIVksAoWrOAvsjFVJnH7ytGhch0XRSewV0c1R/IYDXj4fkr/RGr zWmsMZHt5p8tB5NQqlnecB0k/3Ri/LRV2KZYfrWzcWIBwbZ/szCeqRWrsf3dXib7n1auVl5MCyz /FPAZm9sBY3/qnLaXsI/fQtjY7kDmgtIp/T9/6DkfE1ZIO/gExyQHUkRgmviDLmHAx23GNN1wZk zFI2eFr+JgfSMWezuOvFifBJEinWjUO2bKUHOFnUdl05tAUuZfe5ptABF/KpgQUVO+rUaixnR5l YfyPxMPUm6acGeWGNvEZz913SQA7Dy092dcVJK3FZO+SZwpvwzZa+OY0DnRI9oMWe+re8DTgpUh CMYKEVQaA6DA13V6JTjgl/iZE4UCogke5KVFIdbyCE9Ofru+XJmTLYdoyNYkNUN0LJudd1Q0Hhc eh/K10NsGNzyTASC3hqGPcUhg= X-Received: by 2002:a05:6512:159f:b0:5a3:f0f7:7da1 with SMTP id 2adb3069b0e04-5a4172cd17amr3379372e87.17.1776591280877; Sun, 19 Apr 2026 02:34:40 -0700 (PDT) Received: from xeon ([188.163.112.56]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-38ecb7613a9sm18221671fa.41.2026.04.19.02.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Apr 2026 02:34:40 -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 v2 5/5] media: i2c: lm3560: Add support for PM features Date: Sun, 19 Apr 2026 12:34:12 +0300 Message-ID: <20260419093412.40796-6-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260419093412.40796-1-clamor95@gmail.com> References: <20260419093412.40796-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 | 135 +++++++++++++++++++++++++++++++++---- 1 file changed, 123 insertions(+), 12 deletions(-) diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c index 022a6a76befb..8f5156a80a99 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,60 @@ static int lm3560_init_device(struct lm3560_flash *fla= sh) return rval; } =20 +static void lm3560_power_off(struct lm3560_flash *flash) +{ + gpiod_set_value_cansleep(flash->hwen_gpio, 0); + regulator_disable(flash->vin_supply); +} + +static int lm3560_power_on(struct lm3560_flash *flash) +{ + 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(flash); + return rval; + } + + return 0; +} + +static int __maybe_unused lm3560_pm_runtime_resume(struct device *dev) +{ + struct lm3560_flash *flash =3D dev_get_drvdata(dev); + + return lm3560_power_on(flash); +} + +static int __maybe_unused lm3560_pm_runtime_suspend(struct device *dev) +{ + struct lm3560_flash *flash =3D dev_get_drvdata(dev); + + lm3560_power_off(flash); + + 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 +497,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 +535,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); 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 +555,53 @@ 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); + + 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(flash); + pm_runtime_set_suspended(&client->dev); } } =20 +static const struct dev_pm_ops lm3560_pm_ops =3D { + SET_RUNTIME_PM_OPS(lm3560_pm_runtime_suspend, + lm3560_pm_runtime_resume, NULL) +}; + static const struct of_device_id lm3560_of_match[] =3D { { .compatible =3D "ti,lm3559" }, { .compatible =3D "ti,lm3560" }, @@ -509,7 +620,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