Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3344171pxv; Sun, 4 Jul 2021 16:06:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjbnDv05P8d57pGK/vnV79+k7nKCy9kxiuiwdSfomb+fycDUy1BzGIeDyO7cdEXfSUlJYl X-Received: by 2002:a05:6638:3819:: with SMTP id i25mr3076641jav.44.1625440008471; Sun, 04 Jul 2021 16:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440008; cv=none; d=google.com; s=arc-20160816; b=UbU/fC1v8UGXHr1gAXttDgGAv3wJ2we3342FZCNySn5MVOPh6U7/5pfY5Fcf/iBkIb lLO4Q+9QjW+ExnbSwi8keSAvO96z8OiRl8fXQ5mt+9GPkwv/riNA35U4Bjsnr9jqfg/d bHY/3TCqklIktK6GcuYqkkpExPk0UMeslekiuINC40PxLXXYMsbr4XdwXv+OaYRPWnEc y8q8T8RBrAz8jhkzp709rWkJKBx3GmXAnb0hcJUUEyoDpsOGxY8+lR6j8f1B9c8hkmt0 7RpgNLLyizurGvoSTmPc4BiOSkDNPUzKN9MQNMKvJrEORFEgEdBsFDf5wSYU/+z6+ODa iCcQ== 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=rextwkoAp2yUB/AGpJNKY1e26PDRXPDO+DV6yuW2lhnI8oMyExbGhUJ9fawZRFW/Rq jRrWUeL7Pwgm5Luj3+j+CCcrhAme9Te5eAaOqXrQuAUs4mumZATVHTptljfE4xJpiSNE gQ8AWQ1Rbo/aXWqn7GcHfd+ZbQU0DUergA2Y5W5OpPp25lAm1bAxi7rVHRVxE4S2T5e+ ZkSdNg4VgiV00JVIjtUufhnVlzoQfhzrrPyCENdyPadpRkTzRFvsF73KdejZOjIE297R a8N3EmAsf2YTwFQ5tVx0z34ASwqL2Tc02WiV1m1IT1UhuhqrBjSm2kx2TJZfCSaXP0oA WlTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Jvg4CMt1; 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 b6si1342050ilv.22.2021.07.04.16.06.36; Sun, 04 Jul 2021 16:06:48 -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=Jvg4CMt1; 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 S230386AbhGDXIS (ORCPT + 99 others); Sun, 4 Jul 2021 19:08:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:46062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230427AbhGDXHu (ORCPT ); Sun, 4 Jul 2021 19:07:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D0E76135D; Sun, 4 Jul 2021 23:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439915; bh=kzLbysrn0WTVXqGNPCytiyLqvBomL/QjZ69Hv/nPQ3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jvg4CMt1/j7FjW8NBBG8JctaI6ErzKPz1J//pSdHEQYQJDmAH7HQ/xhBwufmrJ5g4 q+HxFdo2dRUYdOyprmW7muDn5UbBIhPO4lHVdGn3WkQQV8+Sv9R16VValwpY9HhReo 4bSEkfAMwED1ZZzqs2U3+qWLgbFFflpwubPJyDVfyHeca8KzfToOaFWbRiGbFCxtOu I2fqT+BW2HK5//RZvY3PcMDmZmAYmmmBm1uXAgWzKCljRgLe2HSZPtyl2ehAM4vRYP Hg+U2CbLJy19f1k65ajfPM2jHGBs9Ar+QzCtBim1uEPzwtWN12AAcSLyYtJq/k81z/ qDtOx37IleCWw== 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.13 39/85] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off Date: Sun, 4 Jul 2021 19:03:34 -0400 Message-Id: <20210704230420.1488358-39-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-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