From patchwork Wed Jun 15 15:22:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 2086 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1B5C33F03E for ; Wed, 15 Jun 2022 17:23:04 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id a4-20020a056402168400b0042dc5b94da6sf8811083edv.10 for ; Wed, 15 Jun 2022 08:23:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655306584; cv=pass; d=google.com; s=arc-20160816; b=Yt1YQpM7nyUkXdMng0zeiNEjjFdZ7HeD/iZznUKOVJDFXiezgRTlBt3GBI0vJWVDnN i1Y1uiYiCW1BrPGL42MP1zEuL9T5APU5j2JWkDpNiI9pK2lh4Ijp4KwzI1u7msIfiJOy xdpGR/F6lbWVTqxmu4w0MhLl+Uphj9qNv79WSA6kTKq1cO57vpJdHxmc9ybfUsYTXSic DT/QAmqRLI9H/PUaiqoTNdrzJpZPwG7o9BEwFvteE7KkWG0R9wFxe/ozu0VGM/Hul1UN 7xQiM55dX3cDv/SfXjx74hhIWyOKNxevWR08xmBUvYO083JM16lrDEHwrFrNM1gIulGr bbcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=BVyH74LHTbLd78Nt8b8YWVSCOpCO/Qy/ALWeZIDuwx0=; b=Gf1r2odHGSQMqXJHO1AXZREGwPE4/xhWHsC4SVhJAwHtlHa7d1UcPWzbGLU2CnAvuF JWzRBraTFbWiJZ7HazbtT9NjhwV2wY6mRqlljm8pV94SbF/T44pYZEA5EEtJ+fAuwJdZ c/qdEj529wPcMWuRyrRUdV3Yiggx2kB+u6zbrJVcp173c7rbWCZjEw433fZHbGte4trq PKL/RzDXZQ+mQwc+jwDDMVpvzi/q/iaiueJF+iRmINNorrecQ38Or6yRB9SbsqFIU7c9 g9J2Ufd3W48mxEQyfkrlwJbyAGeynAPtAU6tuP84QA+uWAB1727LXUTaKbOPSpQP+/qi Ldbw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KBTccaWp; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=BVyH74LHTbLd78Nt8b8YWVSCOpCO/Qy/ALWeZIDuwx0=; b=VD+hofGbFB8BfcCyUswEpyHJsdb5YjpmgD3BUbdOncEOd53kDSKfDvkDoHrsP2tJCI 5tuibndXqcxnbSsev1iuLgrlC5uvaf9DRzFoTJKDL84gMS3d+j1Vr2H200NSnfV5bufi 86DRWdjDXazoHKUiBWHyu2Jqk1aZY0pzJMmr4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=BVyH74LHTbLd78Nt8b8YWVSCOpCO/Qy/ALWeZIDuwx0=; b=12yb7hMWLi7r7QU8t701U73sjwCwGiWDB4kpKhig6YHTi/1b755ja6ze4iiGoY+ZHc IrAZKYqP1hYLdEatvu7bUU99+8gt6pP/LSSpdVUwO0ymlFnx+rx77v76UcjEgK5E/YGp Td7Kn6n0sMVwJUVRBVjBAQO1LXQzw7EegseA898W2BqEpQdp8niSIFEW+kKWWAwiWXST t3TAezWYFgoepZKpfiq8i6BpjoSeh40htid3+owujUVjDxHfJXMN23KFOou6w4J+gZ9j hrJpQRfhFHSewsErIqTvMiyXFulzCrjyK7PweOkDjEyh1yHaHWdKBh5dr2BEVXooUh/o sexg== X-Gm-Message-State: AJIora9qlquWIKzf7V7fPiC7AKqflm1vbKOhiIfIFulMNPz3ciP7SC0p v0zE3M6aMW/GkaZ8URDaqTXDyJzT X-Google-Smtp-Source: AGRyM1t0HFxCX0MAeoooOJSWX8Pe+lhm3Vz9Io6RbM1+ASQKnxCwyEoNIbrVMSPZ9IMxaF+vQZ651Q== X-Received: by 2002:a17:907:3f97:b0:711:d61d:df9 with SMTP id hr23-20020a1709073f9700b00711d61d0df9mr315596ejc.644.1655306583852; Wed, 15 Jun 2022 08:23:03 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:70cf:b0:6fe:d027:3c1f with SMTP id g15-20020a17090670cf00b006fed0273c1fls143106ejk.2.gmail; Wed, 15 Jun 2022 08:23:02 -0700 (PDT) X-Received: by 2002:a17:907:1b25:b0:6da:8206:fc56 with SMTP id mp37-20020a1709071b2500b006da8206fc56mr296138ejc.81.1655306582746; Wed, 15 Jun 2022 08:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655306582; cv=none; d=google.com; s=arc-20160816; b=O3Hg91QhsBeUxKn7oa7HQ3w7X7dPnMzVL6BOhZxi1ZCyLq/778HFLnRyC8F5obUvsE vzmW4BARR+ANO6VHynrBAJ7tchDly21pBzvNxKRcrKzu7Bchuti9yZr8Mw7uUkacsZJM 1zDVypnMYqv3Ec+/A7PCgsErmPhbvmV+xm+oJnAhc+1MxRsNqbemaNHRq14YPy5IiFXo 9zSTqoEknPgBB2qvXPbTriYPi/p7QerQ2MW+0apgg0aGv19ZQKJFoICGInhDcoOIL7w4 BGOpw5OYti+1fGkc3b9JBQHGC+0/ClbPYgfIE6f1NYui2nL1c5bMLEWkEuouGfMVtgqr 7ORg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=wY8/z2qvEqqf5wiwAGPDiET4OePeatEXdcOFfJLQyGw=; b=mGCNxk0wjLBkShhw7Ae5Tg/r3cKcHbzYhKQxzVLRoc7zTqGf5Gr7x1waEmQ54LmkJ/ 4BBN3D5y8yg/dB3NxANHgjL6q+jPs013iUHsXpdhiAAZJXEm1fKLWHI+11SeedQ3/LI8 i5USuGE6gQDZppp7oubMf7V7mx9dy6uUwJhjJzA/vh/2Nfuy5QUHy3HzxhJpf7DrNMOo OXQWDIO9gAxSXsezlwKtQGVc78M/c7Y+3JKHcnvfIxOJUOYrIZ4ONjOKTM4htIoQZ6gM eCP7Xb16+CtwbfqLlmaaTeXYwQmtJ58zEYd01xBkDPp6ZWi3RGmwkX+vkecFTJBAOGRO Iweg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KBTccaWp; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ov11-20020a170906fc0b00b00711e5f2f823sor4744175ejb.16.2022.06.15.08.23.02 for (Google Transport Security); Wed, 15 Jun 2022 08:23:02 -0700 (PDT) Received-SPF: pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:907:d05:b0:6f4:3729:8e36 with SMTP id gn5-20020a1709070d0500b006f437298e36mr262122ejc.475.1655306582353; Wed, 15 Jun 2022 08:23:02 -0700 (PDT) Received: from tom-ThinkPad-T14s-Gen-2i.station (net-188-217-51-34.cust.vodafonedsl.it. [188.217.51.34]) by smtp.gmail.com with ESMTPSA id a11-20020aa7cf0b000000b0042be14040c1sm9446272edy.86.2022.06.15.08.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jun 2022 08:23:02 -0700 (PDT) From: Tommaso Merciai To: Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, dario.binacchi@amarulasolutions.com, angelo@amarulasolutions.com, Tommaso Merciai Subject: [PATCH 5/7] media: ov5693: move hw cfg functions into ov5693_check_hwcfg Date: Wed, 15 Jun 2022 17:22:52 +0200 Message-Id: <20220615152254.794909-6-tommaso.merciai@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220615152254.794909-1-tommaso.merciai@amarulasolutions.com> References: <20220615152254.794909-1-tommaso.merciai@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: tommaso.merciai@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KBTccaWp; spf=pass (google.com: domain of tommaso.merciai@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=tommaso.merciai@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Move hw configuration functions into ov5693_check_hwcfg. This is done to separe the clode that handle the hw cfg from probe in a clean way Signed-off-by: Tommaso Merciai Reviewed-by: Dario Binacchi --- drivers/media/i2c/ov5693.c | 53 +++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/media/i2c/ov5693.c b/drivers/media/i2c/ov5693.c index d2adc5513a21..d5a934ace597 100644 --- a/drivers/media/i2c/ov5693.c +++ b/drivers/media/i2c/ov5693.c @@ -1348,6 +1348,38 @@ static int ov5693_check_hwcfg(struct ov5693_device *ov5693) struct fwnode_handle *endpoint; unsigned int i; int ret; + u32 xvclk_rate; + + ov5693->xvclk = devm_clk_get(ov5693->dev, "xvclk"); + if (IS_ERR(ov5693->xvclk)) + return dev_err_probe(ov5693->dev, PTR_ERR(ov5693->xvclk), + "failed to get xvclk: %ld\n", + PTR_ERR(ov5693->xvclk)); + + if (ov5693->xvclk) { + xvclk_rate = clk_get_rate(ov5693->xvclk); + } else { + ret = fwnode_property_read_u32(fwnode, "clock-frequency", + &xvclk_rate); + + if (ret) { + dev_err(ov5693->dev, "can't get clock frequency"); + return ret; + } + } + + if (xvclk_rate != OV5693_XVCLK_FREQ) + dev_warn(ov5693->dev, "Found clk freq %u, expected %u\n", + xvclk_rate, OV5693_XVCLK_FREQ); + + ret = ov5693_configure_gpios(ov5693); + if (ret) + return ret; + + ret = ov5693_get_regulators(ov5693); + if (ret) + return dev_err_probe(ov5693->dev, ret, + "Error fetching regulators\n"); endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!endpoint) @@ -1390,7 +1422,6 @@ static int ov5693_check_hwcfg(struct ov5693_device *ov5693) static int ov5693_probe(struct i2c_client *client) { struct ov5693_device *ov5693; - u32 xvclk_rate; int ret = 0; ov5693 = devm_kzalloc(&client->dev, sizeof(*ov5693), GFP_KERNEL); @@ -1408,26 +1439,6 @@ static int ov5693_probe(struct i2c_client *client) v4l2_i2c_subdev_init(&ov5693->sd, client, &ov5693_ops); - ov5693->xvclk = devm_clk_get(&client->dev, "xvclk"); - if (IS_ERR(ov5693->xvclk)) { - dev_err(&client->dev, "Error getting clock\n"); - return PTR_ERR(ov5693->xvclk); - } - - xvclk_rate = clk_get_rate(ov5693->xvclk); - if (xvclk_rate != OV5693_XVCLK_FREQ) - dev_warn(&client->dev, "Found clk freq %u, expected %u\n", - xvclk_rate, OV5693_XVCLK_FREQ); - - ret = ov5693_configure_gpios(ov5693); - if (ret) - return ret; - - ret = ov5693_get_regulators(ov5693); - if (ret) - return dev_err_probe(&client->dev, ret, - "Error fetching regulators\n"); - ov5693->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; ov5693->pad.flags = MEDIA_PAD_FL_SOURCE; ov5693->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;