Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3346425pxv; Sun, 4 Jul 2021 16:11:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1E6lzw0WxI4cpcOWB81uaRlYBxQMRnnLmGy7Mf/cuO/MKI6Mzko6iHAV2+AFEBXUdNGJ0 X-Received: by 2002:a02:cb8d:: with SMTP id u13mr9667262jap.19.1625440264324; Sun, 04 Jul 2021 16:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440264; cv=none; d=google.com; s=arc-20160816; b=dyJ43jUHGk/nTCPxNLFz8MneaRA4ULeItxFsIcQpsKnKMvrBWzZMBF0NJVwcztj2cQ XNShIiksrzyWmgRGvHd7bwgGMUjwn/eLxjV3XxONdpOz6I58u/8ZhikAgYKIDifHv1A2 7hV+foEcICcEa1PWAEHjzWYZnnZgwC8TOnBr1YMjEJ16xIW0sba6HhiUFO9gejueGwDZ 1VpnwSENGOJ+JkSagV7xpSSt98lSu1k99/VO2C1x4s8weoOAD6AZmCBArk62xdGgnwR/ uujofIWNjR3LTQRwr57WPDWBLS+diHae1wQn3HPqW8fdaNPsGVVchT614nI69eQBv2Hb QW+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fMkTKrH9O78rFX/De/NTocfPC8rfW/kgIstXYoTiuFc=; b=bHqQir0y3iAMRUqOOzEAaqgQ3ONbeJxUTDX2GHRMoZ7CkMvKUFWYDCk3hXg2zubzge ZWkw0IZ+xh/abYSivGx1vDlF1GIH/maN3yS5ODNfn1lvPs+H4uxYUChSDt/uxNN9Jr8l 5UGgeMfpDHYi1I9gu/ZD7EPpfG8TlAR5Mxe1KFXCOXE5Yic79kcE9rpfVS4kZ6iP45Jd orhV9D97MQPYPRR4yE9SoHH0RPFV5e0lpPrIVhFHM89HPUXMXnU64uifP5vtv+Hzu2Q8 OEv2O3iWmsE7emM9qCrJQ9cDo6cZobIJzLfywg2X8bHzpfcOFlo85GUsfTr5Dsd6uA33 CGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QJaqS7b+; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si10706727jag.106.2021.07.04.16.10.52; Sun, 04 Jul 2021 16:11:04 -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=@kernel.org header.s=k20201202 header.b=QJaqS7b+; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232336AbhGDXNB (ORCPT + 99 others); Sun, 4 Jul 2021 19:13:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:49050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231823AbhGDXJu (ORCPT ); Sun, 4 Jul 2021 19:09:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06FE06192E; Sun, 4 Jul 2021 23:07:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625440027; bh=kzLbysrn0WTVXqGNPCytiyLqvBomL/QjZ69Hv/nPQ3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJaqS7b+L2ggG3h4WJFEHxCoVsEZbCMuH2xpty3/AjWzYn2TPW/k3S7KfEPFLJkIL YHhdcbMpq6/l7eQWNUdMwdfXQRXEVOjzlRH4fjpRh1UkQA0zTTccmpc2bgQ7Wj6iM0 wCqt+K4lGY87cyqnGZsZn5f3yCfFFp7WIDxpGe/0xoN1MwFfY2xpC293/YXwHhQ8gN ppmWgujgUS+hv1sfc7+aLhjG2ldUuSbB8VrAN5GoLBnXDh1PqqLpeBhkTr3QBgjVgT Zd4CIea/qzorJcwQ/sPNihP3dedHEp/RRB4H/EknAYIHKya6dB7NXmkM/0sY7Qopdp BBabTBsYbJ6hw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dillon Min , Lad Prabhakar , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 37/80] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off Date: Sun, 4 Jul 2021 19:05:33 -0400 Message-Id: <20210704230616.1489200-37-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dillon Min [ Upstream commit 24786ccd9c80fdb05494aa4d90fcb8f34295c193 ] 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 Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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) -- 2.30.2