Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3323622pxy; Mon, 3 May 2021 22:26:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfLHjUA8RKOA5c6v4MQFlSSBZnHsZwlX5S9HLCFL8lZGEdcT2usUepWwasgtygzXTU4o4R X-Received: by 2002:aa7:d14e:: with SMTP id r14mr23631949edo.119.1620106001255; Mon, 03 May 2021 22:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620106001; cv=none; d=google.com; s=arc-20160816; b=Hy0+mrD1Z4p01tCDCzZyzvAg/sDuQxKh4SHDbUgt6GKE2MDG+On5KmRsZYPt7Eze7z ihx8uB5naeqiRX/BnC+hO2uXwLIgVm7VPSAhf6Ow69iWMuXZ7Ojol5EK9iMdO1qiLPA/ Ppp4rxhmrQODK/Sr63tiZU0kB5tlkBpkMaMUf9zjCet+NoyvpNMIT98blVPeUwboaCHy rATRi5dYoNjYQCi8HdEBpl6QMiypW/IsNZ28jwD0RisgB7Scglr/bavdu2vxlHeQj81o yxRUskpnbRxLfiBdZVexyXohEdEVHWfF+Q7qbmW6uKJju4Tnb5Eu9D3vq4qrGld16gov cNIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=DDm+IUuMuEMjBqzuCfuKqp0I9bKlFQdWahJfgNfmLoE=; b=IRxGNFXZM2CZf2bZbbow3dOqulM+p1JPZQLHlprZfOxZSxXlcMPaJ3ROjZocJM1vX6 Pf82sbHVqpQNax6Lg2E8FVJvyYsXWCkW7PIBqL4gm+WtXu1TzAzkaIH/WMxVRa8fSStD 9T8sKv4HjIvK/usjn9lLGRc5pvUl+ihf+eECywoE4WBzS3Yie6XYefpWkbqFyIzyd9TL A0RzUZy0Qr32D5HqBgPu3QbtycgjZpiok1b7OeRnNTrpehu6Uglmvjm6jKZI4qiZb0H1 TzDzIIz6wvcpVw0uqtG+9OleP68NQ4tnzT3Uc2OeKwnmq2O/Bo6/8NXuNdQ1Zh8hv/HF YSVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="iNp//tlg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gy3si1672843ejb.557.2021.05.03.22.26.16; Mon, 03 May 2021 22:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="iNp//tlg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbhEDFLk (ORCPT + 99 others); Tue, 4 May 2021 01:11:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbhEDFLZ (ORCPT ); Tue, 4 May 2021 01:11:25 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 974B5C06138D; Mon, 3 May 2021 22:10:29 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id m124so367286pgm.13; Mon, 03 May 2021 22:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DDm+IUuMuEMjBqzuCfuKqp0I9bKlFQdWahJfgNfmLoE=; b=iNp//tlggIAsYmIJCRwYiOelXJRiE3KlLPgXSXL6Q0m5bbK0CmMVr5Yuq69hj8DQaZ vIIgDS3OBWyzBOs+RLM1CHdHf7AEoRO40KJeg/lV1aTUuEnC8somJAX9Uc+XCSlGCIB+ s2zenw0p2hCY++2nFxSUbHwZaPB9ARlozIWk8JTY723AdR3iMyczNNMcxoOZAvCL/OfM YbHzvLlXEhNa3Pld7EhInBW4F5yDIBRx8J6chx+aRhXWIaygOTw82TUF49ArVSHWx5wA novmsqVBIwF13UE0RUt/xSyMDNn1+gxH1KbNzaTqNasD3dQcU0rkCXoeatUA7fURvBqG aA1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DDm+IUuMuEMjBqzuCfuKqp0I9bKlFQdWahJfgNfmLoE=; b=Bvep0cYED5j6roaymbZoK/pwFsUjdyQiEJ5zGFNSlXs5/qtwfifflpFWVJ3exdbxyv Bs3T2XHOvBM443bylMSZ/Z9bWGxYvJ/5exHm34yO54YDYnpniT8UDu6yB8zcZwk2hu3o 7NtPyHOlR4JF31H+S3erA1bBWIupcEV0fl8/62E5qejKSPc/Hf92kU4NDIIAS0d4d4v5 zSP1nr4N8LIq2nJxmnSQzSCJIe8qYiaJffrrotcrONOvOY5rcqk/gIgkotyjMaHiVsiv teOJVXJkEqjPyTOuPyAd/QS6CqsW0uvyDAt+NBJuwU4FIOCZCYOv4XYLn5j1yM1q4YNK 0mIg== X-Gm-Message-State: AOAM533h9zHRM8ZpIp+A+xs51Lt3tuUOMbnmQU2I8a/G4n6Fgz+bUfKd qmvV4ERm1e9T1o+uldge9kM= X-Received: by 2002:a63:38d:: with SMTP id 135mr13391680pgd.285.1620105029188; Mon, 03 May 2021 22:10:29 -0700 (PDT) Received: from localhost.localdomain ([63.143.61.57]) by smtp.gmail.com with ESMTPSA id 3sm10457815pff.132.2021.05.03.22.10.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 May 2021 22:10:28 -0700 (PDT) From: dillon.minfei@gmail.com To: festevam@gmail.com, shawnguo@kernel.org, s.riedmueller@phytec.de, matthias.schiffer@ew.tq-group.com, leoyang.li@nxp.com, arnd@arndb.de, olof@lixom.net, s.hauer@pengutronix.de, kernel@pengutronix.de, prabhakar.csengg@gmail.com, mchehab@kernel.org, mchehab+huawei@kernel.org Cc: krzysztof.kozlowski@canonical.com, krzk@kernel.org, robh+dt@kernel.org, linux@rempel-privat.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-media@vger.kernel.org, Dillon Min Subject: [PATCH v5 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off Date: Tue, 4 May 2021 13:09:53 +0800 Message-Id: <1620104993-5850-5-git-send-email-dillon.minfei@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1620104993-5850-1-git-send-email-dillon.minfei@gmail.com> References: <1620104993-5850-1-git-send-email-dillon.minfei@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dillon Min On some platform(imx6q), xvclk might not switch on in advance, also for power save purpose, xvclk should not be always on. so, add clk_prepare_enable(), clk_disable_unprepare() in driver side to set xvclk on/off at proper stage. Add following changes: - add 'struct clk *clk;' in 'struct ov2659 {}' - enable xvclk in ov2659_power_on() - disable xvclk in ov2659_power_off() Signed-off-by: Dillon Min Acked-by: Lad Prabhakar --- v5: - no code change, just change my git author name from lower case to higher case - add 'Acked-by: Lad Prabhakar ' drivers/media/i2c/ov2659.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c index 42f64175a6df..fb78a1cedc03 100644 --- a/drivers/media/i2c/ov2659.c +++ b/drivers/media/i2c/ov2659.c @@ -204,6 +204,7 @@ struct ov2659 { struct i2c_client *client; struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl *link_frequency; + struct clk *clk; const struct ov2659_framesize *frame_size; struct sensor_register *format_ctrl_regs; struct ov2659_pll_ctrl pll; @@ -1270,6 +1271,8 @@ static int ov2659_power_off(struct device *dev) gpiod_set_value(ov2659->pwdn_gpio, 1); + clk_disable_unprepare(ov2659->clk); + return 0; } @@ -1278,9 +1281,17 @@ static int ov2659_power_on(struct device *dev) struct i2c_client *client = to_i2c_client(dev); struct v4l2_subdev *sd = i2c_get_clientdata(client); struct ov2659 *ov2659 = to_ov2659(sd); + int ret; dev_dbg(&client->dev, "%s:\n", __func__); + ret = clk_prepare_enable(ov2659->clk); + if (ret) { + dev_err(&client->dev, "%s: failed to enable clock\n", + __func__); + return ret; + } + gpiod_set_value(ov2659->pwdn_gpio, 0); if (ov2659->resetb_gpio) { @@ -1425,7 +1436,6 @@ static int ov2659_probe(struct i2c_client *client) const struct ov2659_platform_data *pdata = ov2659_get_pdata(client); struct v4l2_subdev *sd; struct ov2659 *ov2659; - struct clk *clk; int ret; if (!pdata) { @@ -1440,11 +1450,11 @@ static int ov2659_probe(struct i2c_client *client) ov2659->pdata = pdata; ov2659->client = client; - clk = devm_clk_get(&client->dev, "xvclk"); - if (IS_ERR(clk)) - return PTR_ERR(clk); + ov2659->clk = devm_clk_get(&client->dev, "xvclk"); + if (IS_ERR(ov2659->clk)) + return PTR_ERR(ov2659->clk); - ov2659->xvclk_frequency = clk_get_rate(clk); + ov2659->xvclk_frequency = clk_get_rate(ov2659->clk); if (ov2659->xvclk_frequency < 6000000 || ov2659->xvclk_frequency > 27000000) return -EINVAL; @@ -1506,7 +1516,9 @@ static int ov2659_probe(struct i2c_client *client) ov2659->frame_size = &ov2659_framesizes[2]; ov2659->format_ctrl_regs = ov2659_formats[0].format_ctrl_regs; - ov2659_power_on(&client->dev); + ret = ov2659_power_on(&client->dev); + if (ret < 0) + goto error; ret = ov2659_detect(sd); if (ret < 0) -- 1.9.1