From patchwork Mon Feb 10 08:19:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Val Packett X-Patchwork-Id: 13967452 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CDD51C07C4 for ; Mon, 10 Feb 2025 08:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175682; cv=none; b=pKzSKs4GYmdBmUMGoU/hnARLns8Z7oX2tUwNctVGQyZ+kyZ5O77yE5RTvd3n/mlOArxTU1uR92VzLWydfYLz9cfeQe3GieQlanBVepBNGy5OFfpkNIuZX1453cTW0XwwtKa9JjHE7qBleD+ZHc8d3y/GD/N+U2DGnMHYT4aOTK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175682; c=relaxed/simple; bh=KhGb/9SxbyxpeT8+zSuAk9qCVcXcY7x2UfLZVXGxtc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LGFvhqvtJJkQOmDNDXm49qylMO/QbGDgQd9yZzzVjOXMEUY4T5Hp8o0SodP0g1p6tWh4yZeC9xzN2BsYwCoKO5MBGMHvtHcfruOljMbsWtzCj3QE85frVLjJwFGKOkMAYMmiHLwYFkpQDRzYoMCy6y7ICSW/vsLvBrljV31TZwY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool; spf=pass smtp.mailfrom=packett.cool; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b=ULPsU6ld; arc=none smtp.client-ip=95.215.58.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=packett.cool Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b="ULPsU6ld" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=packett.cool; s=key1; t=1739175678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OB9aSO2g4DlrBMgHzU59SnbKaWT6bVOPaBsyKw9AqEM=; b=ULPsU6ldY03eiFXO+Vhcu8eecoZ22b3N6wLAKHvhTBDnQmdWsOBz1usZUUWGdbi4o0Z2BH 5x7xRCvMaA+LjMcDpLOneSxZK2GjkIKEd3B5Lok51KBRWhcNvGLm+zom4OAQMTDPB5GFyM pQ1eD7t9MqcshEVOjhNmSORfyvLyQFyYqDwdmoSguH/HON7bt5REj2Hze26KVz9xbFmTxQ N0jS5TYwhSbRigM60eYkKMOzeKs3v6bM4hvY3VSxNs1HmYBt4ps54nDOUJ0nNvRfy6ktX/ H88mPaKjhDRYECinL7PlM6yJcPDNKAnr1JcvupUxaEeePecWwveSTeSq11jjjw== From: Val Packett To: Cc: Val Packett , Daniel Scally , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] media: dt-bindings: i2c: add DW9719/DW9718S VCM binding Date: Mon, 10 Feb 2025 05:19:16 -0300 Message-ID: <20250210082035.8670-2-val@packett.cool> In-Reply-To: <20250210082035.8670-1-val@packett.cool> References: <20250210082035.8670-1-val@packett.cool> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Add DT bindings for the dw9719 voice coil motor driver, which is getting devicetree compatibles added along with DW9718S support. Also mention the binding file in the corresponding MAINTAINERS entry. Signed-off-by: Val Packett --- .../bindings/media/i2c/dongwoon,dw9719.yaml | 110 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 111 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/i2c/dongwoon,dw9719.yaml diff --git a/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9719.yaml b/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9719.yaml new file mode 100644 index 000000000000..88161038223f --- /dev/null +++ b/Documentation/devicetree/bindings/media/i2c/dongwoon,dw9719.yaml @@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/media/i2c/dongwoon,dw9719.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Dongwoon Anatech DW9719 Voice Coil Motor (VCM) DAC + +maintainers: + - Daniel Scally + +description: |- + The Dongwoon DW9719/DW9718S is a single 10-bit digital-to-analog converter + with 100 mA output current sink capability, designed for linear control of + voice coil motors (VCM) in camera lenses. This chip provides a Smart Actuator + Control (SAC) mode intended for driving voice coil lenses in camera modules. + +properties: + compatible: + enum: + - dongwoon,dw9719 + - dongwoon,dw9718s + + reg: + maxItems: 1 + + vdd-supply: + description: VDD power supply + + dongwoon,sac-mode: + description: | + Slew Rate Control mode to use: direct, LSC (Linear Slope Control) or + SAC1-SAC6 (Smart Actuator Control). + $ref: /schemas/types.yaml#/definitions/uint32 + enum: + - 0 # Direct mode + - 1 # LSC mode + - 2 # SAC1 mode (operation time# 0.32 x Tvib) + - 3 # SAC2 mode (operation time# 0.48 x Tvib) + - 4 # SAC3 mode (operation time# 0.72 x Tvib) + - 5 # SAC4 mode (operation time# 1.20 x Tvib) + - 6 # SAC5 mode (operation time# 1.64 x Tvib) + - 7 # SAC6 mode (operation time# 1.88 x Tvib) + default: 4 + + dongwoon,vcm-freq: + description: + The switching frequency for the voice coil motor. + $ref: /schemas/types.yaml#/definitions/uint32 + +allOf: + - if: + properties: + compatible: + contains: + const: dongwoon,dw9718s + then: + properties: + dongwoon,vcm-freq: + default: 0 + enum: + - 0 # 5.00 MHz + - 1 # 3.33 MHz + - 2 # 2.50 MHz + - 3 # 2.00 MHz + - 4 # 1.67 MHz + - 5 # 1.43 MHz + - 6 # 1.25 MHz + - 7 # 1.11 MHz + - 8 # 1.00 MHz + - 9 # 0.91 MHz + - 10 # 0.83 MHz + - 11 # 0.77 MHz + - 12 # 0.71 MHz + - 13 # 0.67 MHz + - 14 # 0.63 MHz + - 15 # 0.59 MHz + - if: + properties: + compatible: + contains: + const: dongwoon,dw9719 + then: + properties: + dongwoon,vcm-freq: + default: 0x60 + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +examples: + - | + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + vcm_rear: camera-lens@c { + compatible = "dongwoon,dw9718s"; + reg = <0x0c>; + + vdd-supply = <&pm8937_l17>; + }; + }; + +... diff --git a/MAINTAINERS b/MAINTAINERS index 603b11222d67..42dd86f5d5c8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6932,6 +6932,7 @@ M: Daniel Scally L: linux-media@vger.kernel.org S: Maintained T: git git://linuxtv.org/media.git +F: Documentation/devicetree/bindings/media/i2c/dongwoon,dw9719.yaml F: drivers/media/i2c/dw9719.c DONGWOON DW9768 LENS VOICE COIL DRIVER From patchwork Mon Feb 10 08:19:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Val Packett X-Patchwork-Id: 13967454 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 624FF1BD9FA for ; Mon, 10 Feb 2025 08:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175690; cv=none; b=UWgHCt/H8TbdB4zMUWsGalO04MGRLi89lxoDmEDdu1jXp27m+jqtErY1owOKrbJlJsxrszbrEcGfJs48j2LaTj4z/r1hUo7EwXHzqUsLJdhejndXEER5idwvhTV9AeWBIys6xYnHb0I8Rs2bSMMPUFrJhq/OqiXc3Qt+D69HEwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175690; c=relaxed/simple; bh=aXBVOhTcAS0juVanJzYNC9/sNyXD79Srm/3EYvO4HX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I2dEBywDKCNEwKy2Sf8XOmME3d0qECEI5ahw2WwfIuIp3auR/9u6qAWiq1Yz+b+xlz8JHiZA4ZLAzabz1UrxGWT1K8+odmC6Lbgf61AAw84JmZ/9VyBq3aI7dRgqouaQ5U0lG5Zvy5WtJos22zmbBzR5Zc+GGjtzmrN+I4MDx8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool; spf=pass smtp.mailfrom=packett.cool; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b=cYiEAE7t; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=packett.cool Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b="cYiEAE7t" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=packett.cool; s=key1; t=1739175686; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FMPspReONBF5sJhVHTUN14XLSKQUNMx2wupSgm08Nx8=; b=cYiEAE7teIhehz9EBC3z4j2Okd0/87ACa6gX/09Aw0MLr345kcjyJDfL5twaC0WNt2yUbS 5APzNk4bVjDpOwTNRQU5TVrxbpwoEO/gpuaL+JJqazA37m6nYmH7ef9hBqBd74dsyh7uUt jKhSmMjvn647XuJcM+zOqMZd0bAhDo9dDcjk4sVa6uoqmUxl706qgbTKlpiH544D45grao LE8joDVlycOn0FlWhTuCdQ9vaV7UPz+0SqwlsAeKZF49TXaWmWW1C9X0JmPbkjIkIEjkn8 YsMXDnZr1vLV30Tqh3OAFN1O4Vwk9XNFPED5PRkwSXfqwnYj5MIAaovlkHWSfA== From: Val Packett To: Cc: Val Packett , Daniel Scally , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] media: i2c: dw9719: add an of_match_table Date: Mon, 10 Feb 2025 05:19:17 -0300 Message-ID: <20250210082035.8670-3-val@packett.cool> In-Reply-To: <20250210082035.8670-1-val@packett.cool> References: <20250210082035.8670-1-val@packett.cool> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Allow this driver to be used from device trees using the dongwoon,dw9719 OFW compatible string. Signed-off-by: Val Packett --- drivers/media/i2c/dw9719.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c index c626ed845928..b6859cfd216c 100644 --- a/drivers/media/i2c/dw9719.c +++ b/drivers/media/i2c/dw9719.c @@ -331,6 +331,12 @@ static const struct i2c_device_id dw9719_id_table[] = { }; MODULE_DEVICE_TABLE(i2c, dw9719_id_table); +static const struct of_device_id dw9719_of_table[] = { + { .compatible = "dongwoon,dw9719" }, + { { 0 } } +}; +MODULE_DEVICE_TABLE(of, dw9719_of_table); + static DEFINE_RUNTIME_DEV_PM_OPS(dw9719_pm_ops, dw9719_suspend, dw9719_resume, NULL); @@ -338,6 +344,7 @@ static struct i2c_driver dw9719_i2c_driver = { .driver = { .name = "dw9719", .pm = pm_sleep_ptr(&dw9719_pm_ops), + .of_match_table = dw9719_of_table, }, .probe = dw9719_probe, .remove = dw9719_remove, From patchwork Mon Feb 10 08:19:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Val Packett X-Patchwork-Id: 13967455 Received: from out-184.mta1.migadu.com (out-184.mta1.migadu.com [95.215.58.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DF111C07C6 for ; Mon, 10 Feb 2025 08:21:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175698; cv=none; b=aCKpX/R47setCzdG+fCSYeDTBACAMFGqPOHr8lkhjvL7NPolGyKZQvzwHQINUMXgMH7lFdOOYdH0efqlSEhb8UuwqyQxBPXOmJWtAxhziDiTbQApTV6vnxon8Xnaxjy4tO9uyWIkz/mHaHkqd72MUqbaRki1dRTyJownQ+18dSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175698; c=relaxed/simple; bh=+LOzBTGhH5B3UV2t8GcpDgCFnM0o7P5ERB31Po4SRpI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c9ju92aJIio2YGfIoJQ7TzdytpG1G0bOwukR1GGXZ0I04AB12hhZvPHQuG5wFMBYJXxSb4vBH8WYawp/LULtS5niN0GDlOvRG3W1ga7zKL5yrGEoNply8JluVLlW+nOuomSe819wsC5fuDJcGYSvIEvlaTZiXg49W01pja2+esI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool; spf=pass smtp.mailfrom=packett.cool; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b=Mhx9SsUt; arc=none smtp.client-ip=95.215.58.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=packett.cool Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b="Mhx9SsUt" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=packett.cool; s=key1; t=1739175693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7d/LiHxu7rXsjVphqf8bNbNa/SaROfhj8tAchzj9/30=; b=Mhx9SsUtliJd00sVU2UpgJSgSzuP3DiUQK3xe33yLMXak7bYVqRcnxfw+OA+gFGhBQb0OM /+cS88Vaa0WjHWahbIbWjl4e1FPnkqH5CbJB26fOJZBklUcKeSZJ4yhvtMCQ1ZNVx0AIWo EJeQhXbQ4VOpDbIYH6cmS12XDiuEHdw7GPfSTgCu3BlRdCAlRHF4hpb6UzeHWY+LIgBeGA TzQ7CBo03gVjRu/9HlQsikZ4gQ1qwMbmJHWsMKlzGvzHBTp78Et6drnuinIjT/UvVLA6fC 5RXnDAmaUryHQpjPt9bnr/Ytp3UOX3TYs0Y1iR56GmLOh5TIjoZnYbWRboW/Rw== From: Val Packett To: Cc: Val Packett , Daniel Scally , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] media: i2c: dw9719: increase tOPR wait time Date: Mon, 10 Feb 2025 05:19:18 -0300 Message-ID: <20250210082035.8670-4-val@packett.cool> In-Reply-To: <20250210082035.8670-1-val@packett.cool> References: <20250210082035.8670-1-val@packett.cool> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Use usleep_range and a named define, and increase from 100 to 200us because in practice 100us turns out to be too low, particularly after a suspend-resume cycle. Signed-off-by: Val Packett --- drivers/media/i2c/dw9719.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c index b6859cfd216c..f2cf3bcd4dd3 100644 --- a/drivers/media/i2c/dw9719.c +++ b/drivers/media/i2c/dw9719.c @@ -20,6 +20,8 @@ #define DW9719_MAX_FOCUS_POS 1023 #define DW9719_CTRL_STEPS 16 #define DW9719_CTRL_DELAY_US 1000 +/* 100 us is not enough on resume */ +#define DW9719_T_OPR_US 200 #define DW9719_INFO CCI_REG8(0) #define DW9719_ID 0xF1 @@ -85,8 +87,8 @@ static int dw9719_power_up(struct dw9719_device *dw9719) /* Jiggle SCL pin to wake up device */ cci_write(dw9719->regmap, DW9719_CONTROL, 1, &ret); - /* Need 100us to transit from SHUTDOWN to STANDBY */ - fsleep(100); + /* Need tOPR to transition from SHUTDOWN to STANDBY */ + usleep_range(DW9719_T_OPR_US, DW9719_T_OPR_US + 10); cci_write(dw9719->regmap, DW9719_CONTROL, DW9719_ENABLE_RINGING, &ret); cci_write(dw9719->regmap, DW9719_MODE, From patchwork Mon Feb 10 08:19:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Val Packett X-Patchwork-Id: 13967456 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 522771C07CB for ; Mon, 10 Feb 2025 08:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175704; cv=none; b=NB5H7oUTruuqHMgkKBa+NIHEpIZWjha6H3G5Tup7ZlHrFu5jCBjulu1E5/iAeliktXzEC6zBu1BCjay5Y1Smnyo098jtVbnkv8EUKv8nxBNr4LqFgW0w7VdGq49jUr8STMLEVAKdpPduXjUkeUqP+MkXbhA0ctMRTupTLANzjV0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175704; c=relaxed/simple; bh=kkitMgcce5LX5agqzNgk6J0eaNnB/hOLrzm4OBEZ+5U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AGeqADlfbncDFe9jS7xkH9WoH1WxjaSHRZybuRf1JEUOlXYMz67BayqGIlfy2+uwQ9bxSSU4PUBgPTx63j7/r8F1wSm6TGmMNQBXnElHXOyB+14JW07/Adt2dmfF06iRdTC6BeGvgewYQq3wGJr1ll3XPUMsq637UVw6DN8Jy+8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool; spf=pass smtp.mailfrom=packett.cool; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b=v9ejuOsN; arc=none smtp.client-ip=95.215.58.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=packett.cool Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b="v9ejuOsN" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=packett.cool; s=key1; t=1739175700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aiP0T69xWJh68F8scJK++6YlobxLpWOoIVSQLlWtZU4=; b=v9ejuOsNf8Fhh7AUTHExRNf3+HkhWRAEYaMk3TL23hBPLndlzo3fNAGSCT9NoYb5kku80d 7IpWtIFavLE10U3X2oxiX9wTFMrbBudavWKiqupQI60JJ02YLi4H2QwHaBaeSxNSXkrgGt Kr47MzZUDU1OVXDLdEYwKYR/nvN4Oen/q/Ci1osOjY7Pkzcqm2mJtOjx4Hnim3g85N27tg U9r+8ReR/f79249OrCR3wLhFFkc4KYtTwv7P2bajEVB/N5x7tpgVqiiBuPnMfY+gYzLqkP hKQzmWrH8vLQex4lf657Bixed7D/ugWFXTxelORT2/ouUEj5Oi8ELJrSfDoHQQ== From: Val Packett To: Cc: Val Packett , Daniel Scally , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] media: i2c: dw9719: update PM last busy time upon close Date: Mon, 10 Feb 2025 05:19:19 -0300 Message-ID: <20250210082035.8670-5-val@packett.cool> In-Reply-To: <20250210082035.8670-1-val@packett.cool> References: <20250210082035.8670-1-val@packett.cool> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Update the close callback to match other similar drivers like dw9768. Signed-off-by: Val Packett --- drivers/media/i2c/dw9719.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c index f2cf3bcd4dd3..74a57c2f59ae 100644 --- a/drivers/media/i2c/dw9719.c +++ b/drivers/media/i2c/dw9719.c @@ -188,7 +188,8 @@ static int dw9719_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) static int dw9719_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) { - pm_runtime_put(sd->dev); + pm_runtime_mark_last_busy(sd->dev); + __pm_runtime_put_autosuspend(sd->dev); return 0; } From patchwork Mon Feb 10 08:19:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Val Packett X-Patchwork-Id: 13967457 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 662601BD4E4 for ; Mon, 10 Feb 2025 08:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175711; cv=none; b=BWW6xTKA3SDDQ24Q71bHNkymFKiVmZgifmR2dgHhN126Te6UHsH5wQ2F14WKjyl98qhK5Y6/d+lMRHgKG4nl1IJ0mvo3zg/+BKCDapN+syCY+N/gLEEeIGzResKCXayW2rVWr1sXNimy7ZobEo1nykfm5ca0KYfNHvPJ3eFI0eA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739175711; c=relaxed/simple; bh=mMYOsNnWbT8DnH83HSNKLNG8UmCTA4XmU454SsOoLJc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lG7h440HYhkVkAXqbgZjNcC5fhF8ukMUgDIMiRfsDrX8gZotp/Ti5aBBZe1GMjCef767Y5fr4lmtY6QpxCK8lwuV1zdQFFlwe+2nJl6hQ4is1s5xIt5a6kad051eXvEV+3zuI6iT0OHwT5QX4SpDDURwW42DY+qf2TiSNpWErHw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool; spf=pass smtp.mailfrom=packett.cool; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b=wrvWp65k; arc=none smtp.client-ip=95.215.58.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=packett.cool Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=packett.cool Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=packett.cool header.i=@packett.cool header.b="wrvWp65k" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=packett.cool; s=key1; t=1739175707; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6owXxJrOUwngLDg4I3rLqCGx4W0Djeg4pCidwLLEZT4=; b=wrvWp65kn45e5bVSANPVol7sSzX3inaJAR7WyWPjVYVMu4vi/rRIX6r0g5H1BWc7uZPg5L BwPFBe3VrLR9bb9ewsSx7R6B7oSShOU70NxHvwV14vw3NYq0W6ZOGCTWfvzvCh95ocosik gqnMyqjQZbwzcOuD9u+Q1V1c8FNJMR1vdUWGCE+VjV5CB5JJoOUu/3Z1tRA4TZbOo37sv4 5r8zwE3+uyAYZMA7EgY18qaMnTHiepImNKWJ0wv9vrA8LfjAvBVNmW1i0r3HafIFrqALsE PtAsPBI/AmwHyg/rk4vZBVnWnEDGNb83M+dvBfe1qgIBOc28pKv/tNTQVrfAQA== From: Val Packett To: Cc: Val Packett , Daniel Scally , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] media: i2c: dw9719: add support for dw9718s Date: Mon, 10 Feb 2025 05:19:20 -0300 Message-ID: <20250210082035.8670-6-val@packett.cool> In-Reply-To: <20250210082035.8670-1-val@packett.cool> References: <20250210082035.8670-1-val@packett.cool> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT The DW9718S is a similar part that uses a different register set but follows the same method of operation otherwise. Add support for it to the existing dw9719 driver. While here, ensure suspend-resume works. Tested on the Moto E5 (motorola-nora) smartphone. Signed-off-by: Val Packett --- drivers/media/i2c/dw9719.c | 104 ++++++++++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c index 74a57c2f59ae..4a07684af52e 100644 --- a/drivers/media/i2c/dw9719.c +++ b/drivers/media/i2c/dw9719.c @@ -23,6 +23,22 @@ /* 100 us is not enough on resume */ #define DW9719_T_OPR_US 200 +#define DW9718_CONTROL CCI_REG8(1) +#define DW9718_CONTROL_SW_LINEAR BIT(0) +#define DW9718_CONTROL_SAC_SHIFT 1 +#define DW9718_CONTROL_SAC_MASK 0x7 +#define DW9718_CONTROL_OCP_DISABLE BIT(4) +#define DW9718_CONTROL_UVLO_DISABLE BIT(5) + +#define DW9718_VCM_CURRENT CCI_REG16(2) + +#define DW9718_SW CCI_REG8(4) +#define DW9718_SW_VCM_FREQ_MASK 0xF +#define DW9718_DEFAULT_VCM_FREQ 0 + +#define DW9718_SACT CCI_REG8(5) +#define DW9718_SACT_PERIOD_8_8MS 0x19 + #define DW9719_INFO CCI_REG8(0) #define DW9719_ID 0xF1 @@ -48,12 +64,25 @@ struct dw9719_device { u32 sac_mode; u32 vcm_freq; + const struct dw9719_cfg { + int reg_current; + int default_vcm_freq; + int (*power_up)(struct dw9719_device *dw9719); + int (*detect)(struct dw9719_device *dw9719); + } *cfg; + struct dw9719_v4l2_ctrls { struct v4l2_ctrl_handler handler; struct v4l2_ctrl *focus; } ctrls; }; +static int dw9718_detect(struct dw9719_device *dw9719) +{ + /* Unfortunately, there is no ID register */ + return 0; +} + static int dw9719_detect(struct dw9719_device *dw9719) { int ret; @@ -73,9 +102,50 @@ static int dw9719_detect(struct dw9719_device *dw9719) static int dw9719_power_down(struct dw9719_device *dw9719) { + int ret; + + cci_write(dw9719->regmap, DW9718_CONTROL, 1, &ret); + if (ret) + return ret; + + /* Need tOPR to transition from STANDBY to SHUTDOWN */ + usleep_range(DW9719_T_OPR_US, DW9719_T_OPR_US + 10); + return regulator_disable(dw9719->regulator); } +static int dw9718_power_up(struct dw9719_device *dw9719) +{ + int ret; + + ret = regulator_enable(dw9719->regulator); + if (ret) + return ret; + + /* Need tOPR to transition from SHUTDOWN to STANDBY */ + usleep_range(DW9719_T_OPR_US, DW9719_T_OPR_US + 10); + + /* Datasheet says [OCP/UVLO] should be disabled below 2.5V */ + cci_write(dw9719->regmap, DW9718_CONTROL, + DW9718_CONTROL_SW_LINEAR | + ((dw9719->sac_mode & DW9718_CONTROL_SAC_MASK) + << DW9718_CONTROL_SAC_SHIFT) | + DW9718_CONTROL_OCP_DISABLE | + DW9718_CONTROL_UVLO_DISABLE, + &ret); + cci_write(dw9719->regmap, DW9718_SACT, + DW9718_SACT_PERIOD_8_8MS, + &ret); + cci_write(dw9719->regmap, DW9718_SW, + dw9719->vcm_freq & DW9718_SW_VCM_FREQ_MASK, + &ret); + + if (ret) + dw9719_power_down(dw9719); + + return ret; +} + static int dw9719_power_up(struct dw9719_device *dw9719) { int ret; @@ -103,7 +173,7 @@ static int dw9719_power_up(struct dw9719_device *dw9719) static int dw9719_t_focus_abs(struct dw9719_device *dw9719, s32 value) { - return cci_write(dw9719->regmap, DW9719_VCM_CURRENT, value, NULL); + return cci_write(dw9719->regmap, dw9719->cfg->reg_current, value, NULL); } static int dw9719_set_ctrl(struct v4l2_ctrl *ctrl) @@ -161,7 +231,7 @@ static int dw9719_resume(struct device *dev) int ret; int val; - ret = dw9719_power_up(dw9719); + ret = dw9719->cfg->power_up(dw9719); if (ret) return ret; @@ -235,13 +305,17 @@ static int dw9719_probe(struct i2c_client *client) if (!dw9719) return -ENOMEM; + dw9719->cfg = i2c_get_match_data(client); + if (!dw9719->cfg) + return -ENODEV; + dw9719->regmap = devm_cci_regmap_init_i2c(client, 8); if (IS_ERR(dw9719->regmap)) return PTR_ERR(dw9719->regmap); dw9719->dev = &client->dev; dw9719->sac_mode = DW9719_MODE_SAC3; - dw9719->vcm_freq = DW9719_DEFAULT_VCM_FREQ; + dw9719->vcm_freq = dw9719->cfg->default_vcm_freq; /* Optional indication of SAC mode select */ device_property_read_u32(&client->dev, "dongwoon,sac-mode", @@ -277,11 +351,11 @@ static int dw9719_probe(struct i2c_client *client) * will work. */ - ret = dw9719_power_up(dw9719); + ret = dw9719->cfg->power_up(dw9719); if (ret) goto err_cleanup_media; - ret = dw9719_detect(dw9719); + ret = dw9719->cfg->detect(dw9719); if (ret) goto err_powerdown; @@ -328,14 +402,30 @@ static void dw9719_remove(struct i2c_client *client) pm_runtime_set_suspended(&client->dev); } +static const struct dw9719_cfg dw9718_cfg = { + .reg_current = DW9718_VCM_CURRENT, + .default_vcm_freq = DW9718_DEFAULT_VCM_FREQ, + .power_up = dw9718_power_up, + .detect = dw9718_detect, +}; + +static const struct dw9719_cfg dw9719_cfg = { + .reg_current = DW9719_VCM_CURRENT, + .default_vcm_freq = DW9719_DEFAULT_VCM_FREQ, + .power_up = dw9719_power_up, + .detect = dw9719_detect, +}; + static const struct i2c_device_id dw9719_id_table[] = { - { "dw9719" }, + { "dw9718s", .driver_data = (kernel_ulong_t)&dw9718_cfg, }, + { "dw9719", .driver_data = (kernel_ulong_t)&dw9719_cfg, }, { } }; MODULE_DEVICE_TABLE(i2c, dw9719_id_table); static const struct of_device_id dw9719_of_table[] = { - { .compatible = "dongwoon,dw9719" }, + { .compatible = "dongwoon,dw9718s", .data = &dw9718_cfg }, + { .compatible = "dongwoon,dw9719", .data = &dw9719_cfg }, { { 0 } } }; MODULE_DEVICE_TABLE(of, dw9719_of_table);