Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2727566pxy; Mon, 3 May 2021 06:47:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYUQ9PsFAEC0GZAceKyrY3CxZ2iJwCT1cyal+C4dZ+5sTs3ZJuMNKPbWPUiuBNf+I1trAm X-Received: by 2002:a17:906:1185:: with SMTP id n5mr17094449eja.468.1620049646454; Mon, 03 May 2021 06:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620049646; cv=none; d=google.com; s=arc-20160816; b=OSOWXqVS6NzL7uFviOecEYZK3icjKn0yNfqrNJc5gPTM6cXHZvyPN0p3068cRKAH95 B6gpPrJ1kCS6YF/CwqqMcP7lryl9rvayBMXD2jDlm7ACFuB1moMekWw1jQ628WkOBNHC DhtBs5h+Q5J7oQst+BaKyDjYZc73+OaObR66gCDgUwQ9uKPopGtw90WnD4sM4DiJbbXd rLxNxAM+g0U5vhWB6HteaVmsjOK9HbZQgfsV1CI+52Ptk53mP6LNf1vkc3T2RTA8DZSM UpS8raoD+vptohilHl374KaUraD9knwnRfcZMtRVw7V6zSDYsUBCQrS59yIhD370XjvU XKug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wftONSeKaH/t9zIDsYi/8TKzB3BgvM7TR3cIowzjwPE=; b=nuZnCfq/Cuxs5tyLoz7rVlgNQK8nw3NYywHzwvw7SWKgCsX/Xsz3hFM6CJl3anJjlA Je6/PiXEoi2M4riK9k2M/FtFXh336F5BBizTiejWhsWm3ik8fAFcPDnIAD0JefSdSNbn szZm93THp5lgV8GUzq2jx4R39mmne1beZ/Pxumz+ULeewtXrCFe0/B2ZL0PGSf9W0VDB XjIToIdE+/PiRDg4quM0whk6FNUXLOyfEetVLso5lp5IMg1tnJRtV4Gq59paKvPgRWxY JIFqQDEdN10BGb/jX6EQ24kiNVka1leL9RlgfL19bqQCnqy1iTN+wjJIbkAhLb+WlQ4m b98g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qgKSMjOh; 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 gy3si10773416ejb.557.2021.05.03.06.46.59; Mon, 03 May 2021 06:47:26 -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=qgKSMjOh; 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 S233571AbhECMZ3 (ORCPT + 99 others); Mon, 3 May 2021 08:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbhECMZ2 (ORCPT ); Mon, 3 May 2021 08:25:28 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6306C06174A; Mon, 3 May 2021 05:24:35 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id g38so7216761ybi.12; Mon, 03 May 2021 05:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wftONSeKaH/t9zIDsYi/8TKzB3BgvM7TR3cIowzjwPE=; b=qgKSMjOhwgpBkSbQT5/4waE9LrtLmLbOPawIZb1f74qpN+IGqU+mXibYgP84EQ6YiV t/6IB9RYOiZ0MUfyRnt/+kw+vqOPSYPGOetsKzbKM5UHFOwipj339Lnm36TPHdz3kHgT b05tO2wQFUoSVx5kFKQyPX0kWE5jhyyNN75GjuJBu1wOqzOs3aYnhKCrQxUPGdTpcRwj nyZXgaOvY2n4A892YPcHEqo8gM8vVlyrUpkjzpxLYqqrW7vQFjj3s3tmnVDYZTbI4fEZ Jdzi8WDDspEra4MKOyuOOmZ5K73Hbd3yjIctY98oivJjWhxL9OueZWiGt9T5E7cWAp0V Q7hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wftONSeKaH/t9zIDsYi/8TKzB3BgvM7TR3cIowzjwPE=; b=oCMxlMgVEegub7NpWzRjXmHKl0v14lMtWxEMeoeDbc103Ex5aUbwsok6T+DsgmfwwI vIv50VoaYkR567nNVPYPggT92k0A2dvOfpdJPYLzsYFRveLB21mH25X+KkgIR7OMvJSU 4Ewo9clx39JQngXuVvvpa7IhwTU+YK9Kohn0LxI9Y120aomm6RDM1zql9eWJ3UZXq7TY jQ8rfPZY5UNP864dkGwpk2Hgqw/PDF5ds5YBRTqwLoCvtNjBdq13wghmks1/QFOHTGX+ 0zYvhrVhu5epU+NhBOJd43eTIQF6yt1fvAL9079w6Tcc1Xf9JsCbt4ETGLMfTD6pFyyq PQdQ== X-Gm-Message-State: AOAM5326OBi6WzMjv9ITRHk0nkXDgRGPeIO8tIzl1Emi2kHom5651T4j YRmxiy7A+dBrlsW4/IbKQ0SKeYtZat+FVr01JXaVOJg2tss= X-Received: by 2002:a25:5741:: with SMTP id l62mr25646407ybb.119.1620044675017; Mon, 03 May 2021 05:24:35 -0700 (PDT) MIME-Version: 1.0 References: <1618976938-20834-1-git-send-email-dillon.minfei@gmail.com> <1618976938-20834-5-git-send-email-dillon.minfei@gmail.com> In-Reply-To: <1618976938-20834-5-git-send-email-dillon.minfei@gmail.com> From: "Lad, Prabhakar" Date: Mon, 3 May 2021 13:24:08 +0100 Message-ID: Subject: Re: [PATCH v4 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off To: dillon.minfei@gmail.com Cc: Fabio Estevam , Shawn Guo , s.riedmueller@phytec.de, matthias.schiffer@ew.tq-group.com, leoyang.li@nxp.com, Arnd Bergmann , Olof Johansson , Sascha Hauer , Sascha Hauer , Mauro Carvalho Chehab , krzysztof.kozlowski@canonical.com, Krzysztof Kozlowski , Rob Herring , linux@rempel-privat.de, "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , LKML , LAK , NXP Linux Team , linux-media Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dillon, Thank you for the patch. On Wed, Apr 21, 2021 at 4:49 AM wrote: > > 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 s / dillon min /Dillon Min (unless you prefer in lower case) ? > --- > v4: no changes > > drivers/media/i2c/ov2659.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > Acked-by: Lad Prabhakar Cheers, Prabhakar > 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.7.4 >