From patchwork Thu Jun 16 19:35:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommaso Merciai X-Patchwork-Id: 2093 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id E55263F0B6 for ; Thu, 16 Jun 2022 21:36:09 +0200 (CEST) Received: by mail-ed1-f72.google.com with SMTP id v7-20020a056402348700b004351fb80abasf1876992edc.14 for ; Thu, 16 Jun 2022 12:36:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655408169; cv=pass; d=google.com; s=arc-20160816; b=YNxXPleyXZYuv3vZcXAiOnhsKTHZXu3zSHoXiHfR0yDJAchUWlxzPggee7X0MJxjQ+ uvQ1ZzGdZu+kvOsLgTpwryOndOKykNXF6k6Rvx0/xT6vUw024O7u5s5g/pcSWRmb5KqM ACFoyHolY1PCc5m0c4KK6W8R0QzQAn/NcyoeOrwkLRAaFMLrU6UaO4lnzmbdvJsKkBAB MxOKv4kovi9I03BJhNXR+ZsGV341Dbz83+dLp4fv2Mg7HQ0Xvrx7BlyyZT3POiuqbPJi 0+0DJmyFoVJxjDsdNdxQdJwzqdJBct9B1vbjdZzPtCVkMafdKEfK/dnTMaGJUI7y6Gk+ EVAw== 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=Nj5pprS1LE4yxGp9zASkSVlx/JZ9S9Gj64ACLHKKTqg=; b=A9tNgQbvKyQTckUBRNstAyJ8c0M+xJdZXjmZggddX1k1DK8249zQjDyk8y2D++ANsr UP4HjFnHfxE9bxJsa5zHI9Qn/Gp6ilaeUUVIBc8+uzy/qCAo0pjp4012ux0AROQICjIt jfqVnNY6QKZTyd8WeFfh65hjVewFvvppK0LmehbZC5pqN2cbV9UEnVt24SjHXuuWkoiO J5vcCe0ln86kbjVm0sLb/UsuFBPepL5yCY5ZUJRcITml3ENy4pIsc4azXP4csXPt9VPx EkjLloffoqRn5mTuMgZ2uq3lLpJ10Xbxwp6hq2M2S7uABwiJtZz5A6Bpe4dy2NqYDE+M 8oLA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=duW1yvKL; 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=Nj5pprS1LE4yxGp9zASkSVlx/JZ9S9Gj64ACLHKKTqg=; b=NEwXJEKjFLLRv2t1ILcZKWEjfBPyDz0vyVrgwUkj7vM0W1y1q+YideCqAAsy0PeuB2 +OUJLCrFsJGa004BLC6j2sXNZ/97sJe13N+y+hhUrgjM20o5NLMpQZ2uHhpBb4WPkCPf EaBNUs1fJXSY0YkF+MgEhifqJSx5X5R8fAZU0= 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=Nj5pprS1LE4yxGp9zASkSVlx/JZ9S9Gj64ACLHKKTqg=; b=GLfQc6+9Z67SYnoZk1ortWn6KoGaU9p4VgO+MQDZlMs5mmw2YrHdM2gmbVHWxp4DfH Q6mKRxvPnH77zdv9tHzuwwUFcYLtkskhNGRNvR3WuFYbWkvmLlDnQq04HPt49+JGWGA4 v/yPjwwQmD1fb+HQAnGmGv09Kq7WVhPHeIqF0DWEEViVn74fg8ojG5T1mdO9bUs45S5q juNLTf6qnBP4JbhCPekUrYVlL3/sIcR75Nja4ypG08MLL+knb5QFQpmxn9ft6Kieen9i 7bJdpG9tLuPU/XFC993mf0IiLoufv68AOPVk2W9075lfs6BBV0rP+nRwD+stekOGWubl x0kw== X-Gm-Message-State: AJIora8/9KG0X8o9KX/uFKTAEOBTMcICaPcyrsJlT9LbTH8rA6ZGFs+i 7+w+KDx9dBjHWtXOumPdyz3wfV8S X-Google-Smtp-Source: AGRyM1sBRI/wvfqbgfPNEVxgzBRZJVB35dtPNqKCIabkMGl1WzzJyzTLMfXLmyVHjaZkYflJsGjgdQ== X-Received: by 2002:a05:6402:2490:b0:433:5d15:ea71 with SMTP id q16-20020a056402249000b004335d15ea71mr8433825eda.12.1655408169598; Thu, 16 Jun 2022 12:36:09 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:907:9705:b0:70d:ff46:7086 with SMTP id jg5-20020a170907970500b0070dff467086ls150748ejc.4.gmail; Thu, 16 Jun 2022 12:36:08 -0700 (PDT) X-Received: by 2002:a17:906:c154:b0:711:ce44:a0a0 with SMTP id dp20-20020a170906c15400b00711ce44a0a0mr6071774ejc.420.1655408168500; Thu, 16 Jun 2022 12:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655408168; cv=none; d=google.com; s=arc-20160816; b=KrltIkEdx6xTZZC+5hxTuT9bhLtmCBc+c8h7s/RvqYkOwKH9lE6JHEGLP3S6zPxKWz 6KS33LSnXth0B59OzkLEPUBqvvHvS3ygHCaFTJKL6qnywSZBWvA1wrY1IehNzKnIYRgJ Bor2NP1ZFkDQoKaOyhClLuNmwc52p66amAC44FhLrWqrlB5UWLi8BISH2pB47CRYmqp2 5zULCR3a+03BYNWCcgDHf3/YV4H1P48kp+oi/m5qRg/sbqEuIRfweEOVDrsL46pFACyE k4DzJA0SudcwcJy6rwPhitzBMfl+mFI8PO3JE1+DK0ES5uZXiTE1EUHnn794HaNoTIJw k7yA== 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=D9I5L95o8S0by+A9cVvxmobcEEcHkrFh8vGIKK7RWyo=; b=YXlqMYvyiUBKDEyLW6HZRj8+VWOjqauU9iwJ1nzrdA4oS9gnYUCZYPyOPCJnKN8yBm ZlDIY+H3SVb/RgyrZaPnwZ8CgDCRGI0/to73CzJqLpKThQQi77JyZYOIvCnD2uYmdoqA XvFU2QlUwxXm145ZW3j1Q84IfcwFgIcRjg2UkqpnVKOpaNmzb50ot7MxMs0KtAawV7j5 t6w6xQ8X1+nSWdJGEEoqvYHyJtHtzJkICPZ/MxtS7n9ZLM6Sb27+OLKrvwkdYwjby/EG 5FmwISQwgsS3mUOk3nMFhEIuAaahOb9fgw6hsDgWYsiftgnjJozW+7z1qL4Cg3jIl5Zm LW7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=duW1yvKL; 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 c4-20020aa7c744000000b0042defd3be86sor1895929eds.67.2022.06.16.12.36.08 for (Google Transport Security); Thu, 16 Jun 2022 12:36:08 -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:a05:6402:388b:b0:42b:5f20:c616 with SMTP id fd11-20020a056402388b00b0042b5f20c616mr8460238edb.50.1655408168166; Thu, 16 Jun 2022 12:36:08 -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 x24-20020a170906711800b006fec2097d53sm1130255ejj.118.2022.06.16.12.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 12:36:07 -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 v2 4/6] media: ov5693: move hw cfg functions into ov5693_check_hwcfg Date: Thu, 16 Jun 2022 21:35:58 +0200 Message-Id: <20220616193600.1835-5-tommaso.merciai@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220616193600.1835-1-tommaso.merciai@amarulasolutions.com> References: <20220616193600.1835-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=duW1yvKL; 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 code that handle the hw cfg from probe in a clean way Signed-off-by: Tommaso Merciai Reviewed-by: Dario Binacchi --- Changes since v1: - Fix commit msg as suggested by Dario - Add reviewed by tag 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;