From patchwork Wed Nov 1 10:22:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 740220 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 CDF5010781 for ; Wed, 1 Nov 2023 10:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mailoo.org header.i=@mailoo.org header.b="aaMOPazM" Received: from mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE59E8; Wed, 1 Nov 2023 03:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1698834192; bh=LulnQVU2LGroW0Qu5VgPRqq9wD46yJr/35l8o6hbSh4=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=aaMOPazMbCrS/2CWeb5BRZEj4btnQEQT/aCDiGoCNPUD71KmP5zwPbqPK0RH/9nNQ z/hELE95uvZ97uiU2gSCYtqXT3Qhlvz2I9XxDGxM9rvYeIgpUCDD9pIVg/uiFrAJbX IZFmbFlOx/ViYJe/GSXJA3eWkjOMAtCnrBaBCcbs= Received: by b221-2.in.mailobj.net [192.168.90.22] with ESMTP via ip-22.mailoo.org [213.182.54.22] Wed, 1 Nov 2023 11:23:11 +0100 (CET) X-EA-Auth: BVb0ILTlpz9169UulICTfvd2SidbhkX2Cm3cPMSGy9Y7QlUsIMoiJhzNJqkxUSTlHnlgvycagn6A0zErM0fjp940yupvJJMO0P6GZ/HaA/Q= From: Vincent Knecht To: Tianshu Qiu , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Yassine Oudjana , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vincent Knecht Subject: [PATCH 2/3] media: dt-bindings: ak7375: Add ak7345 support Date: Wed, 1 Nov 2023 11:22:56 +0100 Message-ID: <20231101102257.1232179-2-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231101102257.1232179-1-vincent.knecht@mailoo.org> References: <20231101102257.1232179-1-vincent.knecht@mailoo.org> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document AK7345 bindings. Signed-off-by: Vincent Knecht --- .../devicetree/bindings/media/i2c/asahi-kasei,ak7375.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/media/i2c/asahi-kasei,ak7375.yaml b/Documentation/devicetree/bindings/media/i2c/asahi-kasei,ak7375.yaml index 22a810fc7222..fe312cc6a873 100644 --- a/Documentation/devicetree/bindings/media/i2c/asahi-kasei,ak7375.yaml +++ b/Documentation/devicetree/bindings/media/i2c/asahi-kasei,ak7375.yaml @@ -15,7 +15,9 @@ description: properties: compatible: - const: asahi-kasei,ak7375 + enum: + - asahi-kasei,ak7345 + - asahi-kasei,ak7375 reg: maxItems: 1 From patchwork Wed Nov 1 10:22:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Knecht X-Patchwork-Id: 740221 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (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 581063D7B for ; Wed, 1 Nov 2023 10:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mailoo.org header.i=@mailoo.org header.b="R7Nb12ez" Received: from mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E63DE; Wed, 1 Nov 2023 03:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailoo.org; s=mailo; t=1698834192; bh=6VizajUNQEgnBxKKZlvp+xi15aQXeLOvCXt7ptXDwW8=; h=X-EA-Auth:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding; b=R7Nb12ezOSPaYNtNDBHayMH3P/uUJoS7up6sfWYlkNbyT8lcY318KIVSXkfa9Dfdw Zj5zVOZ2hZDV76KKCKXLEBlTYyE/iL6hK6s2TAiyVD1j8Um+Wq0WkhBqVe/QcHy/07 3mieP/ljEdepleYSoSqBfST8lteV2zHVp0ZOWX0o= Received: by b221-2.in.mailobj.net [192.168.90.22] with ESMTP via ip-22.mailoo.org [213.182.54.22] Wed, 1 Nov 2023 11:23:12 +0100 (CET) X-EA-Auth: l+2Oq4EcCO1iMqaLAnm4sPaHK3LEdykeI2KD/pdjHX90Oat10Igsskk5x0gKY/imrrvjIYBEw3VV0rarcUQ9MNKeQwxsP2vTMAtCPde2AuA= From: Vincent Knecht To: Tianshu Qiu , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sakari Ailus , Yassine Oudjana , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vincent Knecht Subject: [PATCH 3/3] media: i2c: ak7375: Add support for ak7345 Date: Wed, 1 Nov 2023 11:22:57 +0100 Message-ID: <20231101102257.1232179-3-vincent.knecht@mailoo.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231101102257.1232179-1-vincent.knecht@mailoo.org> References: <20231101102257.1232179-1-vincent.knecht@mailoo.org> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for ak7345 VCM, which has 9 bits position values, longer power-up delay, and no known standby register setting. Might be compatible as-is with ak7348. Tested on msm8916-alcatel-idol347 phone. Signed-off-by: Vincent Knecht --- drivers/media/i2c/ak7375.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ak7375.c b/drivers/media/i2c/ak7375.c index 3a14eff41531..9a2432cea3ff 100644 --- a/drivers/media/i2c/ak7375.c +++ b/drivers/media/i2c/ak7375.c @@ -16,6 +16,7 @@ struct ak73xx_chipdef { u8 shift_pos; u8 mode_active; u8 mode_standby; + bool has_standby; /* Some chips may not have standby mode */ u16 focus_pos_max; /* * This sets the minimum granularity for the focus positions. @@ -37,12 +38,26 @@ struct ak73xx_chipdef { u16 power_delay_us; }; +static const struct ak73xx_chipdef ak7345_cdef = { + .reg_position = 0x0, + .reg_cont = 0x2, + .shift_pos = 7, /* 9 bits position values, need to << 7 */ + .mode_active = 0x0, + .has_standby = false, + .focus_pos_max = 511, + .focus_steps = 1, + .ctrl_steps = 16, + .ctrl_delay_us = 1000, + .power_delay_us = 20000, +}; + static const struct ak73xx_chipdef ak7375_cdef = { .reg_position = 0x0, .reg_cont = 0x2, .shift_pos = 4, /* 12 bits position values, need to << 4 */ .mode_active = 0x0, .mode_standby = 0x40, + .has_standby = true, .focus_pos_max = 4095, .focus_steps = 1, .ctrl_steps = 64, @@ -249,10 +264,12 @@ static int __maybe_unused ak7375_vcm_suspend(struct device *dev) usleep_range(cdef->ctrl_delay_us, cdef->ctrl_delay_us + 10); } - ret = ak7375_i2c_write(ak7375_dev, cdef->reg_cont, - cdef->mode_standby, 1); - if (ret) - dev_err(dev, "%s I2C failure: %d\n", __func__, ret); + if (cdef->has_standby) { + ret = ak7375_i2c_write(ak7375_dev, cdef->reg_cont, + cdef->mode_standby, 1); + if (ret) + dev_err(dev, "%s I2C failure: %d\n", __func__, ret); + } ret = regulator_bulk_disable(ARRAY_SIZE(ak7375_supply_names), ak7375_dev->supplies); @@ -312,6 +329,7 @@ static int __maybe_unused ak7375_vcm_resume(struct device *dev) } static const struct of_device_id ak7375_of_table[] = { + { .compatible = "asahi-kasei,ak7345", .data = &ak7345_cdef, }, { .compatible = "asahi-kasei,ak7375", .data = &ak7375_cdef, }, { /* sentinel */ } };