Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3090917pxb; Mon, 19 Apr 2021 23:47:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGi6S0QyYrLI92eOJe3rk4LB8rhPTetz34jHZcmNMlCrTfTtePy0OmbVh7N8oiqWpDow/r X-Received: by 2002:a17:90a:4b8c:: with SMTP id i12mr3349381pjh.66.1618901238582; Mon, 19 Apr 2021 23:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618901238; cv=none; d=google.com; s=arc-20160816; b=MozzfoZ7iZXCHTA1tudpllhRsETD+O2IvudbJhqZ84F08BCyWgTHMm457GnOWpAPob h44F9ZHW3Zkah40tumywCucwAuUyJOQ5lNB9d3I9rIabXZ1Zt6X+wF/X+d8BqSgWiY9M 4O9z7Ncq5X67knGxxghvvM92RTJ8kzXOcchG5mZmezwz1fE5WA6GU9npx1e+6Nv5xcs4 jafrBrAMIwP1F0FQVyjv+XDLfZfIK4HOZkkKXF+YakJs+vjZmiADe26VFFWFpl0IcFZj /UPdesKxnEUPr/ZqEc0k7Mw77KF2RZZZEipnOn2xSMDOtPGzBBuPAY67M5daijwcuYcE dWjw== 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=3qxPUUEpSWeJekWw581+kjJxj0KS+o4El6IFU4SLTKE=; b=y3gU1EldP2guwNrfefuXgEY0RVkvUlTg29pEkx0uEwvbDjq4SvbiXVW7nTtxIsEI/H yyXfj0M9+SAlJUXLCjW0YAyMju+9lyvcL8Xqg4rHKfwMAVKth6cQGryxQ7SDJfzRbWIB zTnQwXAMsHqMjERHbClTJt9J4rEXcQuYO217VsuSBbbhplls+7EaSR2inoCxEmBeq7P2 hscvegWV9iSCnrf0CeyLfP1pKjod87o6j3A0UBRoOOn2D4AoFNUfVy3D8QiU59MIHwPY FoX8kjHbm+NxKk9efvcrOy+VuBs7VOLSE0LkJ4JRwKKGHpOzxqaNPypIyDFaaAGH6/yo iKig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JeHXqEWC; 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 j11si18114884plj.168.2021.04.19.23.47.05; Mon, 19 Apr 2021 23:47:18 -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=JeHXqEWC; 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 S230172AbhDTGq4 (ORCPT + 99 others); Tue, 20 Apr 2021 02:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229577AbhDTGqz (ORCPT ); Tue, 20 Apr 2021 02:46:55 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B885C06174A; Mon, 19 Apr 2021 23:46:24 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id a11so35310470ioo.0; Mon, 19 Apr 2021 23:46:24 -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=3qxPUUEpSWeJekWw581+kjJxj0KS+o4El6IFU4SLTKE=; b=JeHXqEWCEGg+IH8zFO2SXV/COmpHUy0QJcJViTHz3Gh/k66JB9Cf6c0kwuxBDln2Tv /42Jdk/8sOG8CFsElnzKah3yQl+c3u8V0nY7Z1fQp40SpI5s9aFNcHjCCEdt7lVQu+aD uZGA9Z5Bw04GmklvjqB+V4h/8eaM0lCIHmEd/M2rKRVd5UR7gs0cy4XJg1wGr+qRk3Ux nqrZtSnsH0sK1m9RtxkzR9PQwCiehn8JJolBz6g/SQsHzMbKUBxuh/sRIcMKqa32eTqP 2qXcnsA/sD98BhK75kqmPEJGNr2zLw/hRpGRhQru+L9rYS+q3689hizltQRzNsM3dUKB yjcw== 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=3qxPUUEpSWeJekWw581+kjJxj0KS+o4El6IFU4SLTKE=; b=AUE4XJwHhUlTMe/nFuaM0vls5oz0eU/RBxLj0nlp1DnqL2Jozcp4eSSqS3KY6yrsA3 94+q2cctugp0HHvQBsu54Ttiyl4jBehuIzcfB2nWpvdrsSs2mdG59MTxjyF8vrUW/GBH gvRNDoIC3LRwDhocfbiiHJr/ccxLsqjAMMUUNQ7PsRHcrI9khJvZvfH07pdKVQ85WbIJ HRA76juLGGfISYGDVz3ktKkiiHnpXhcu/zBMbd5bcS1ero9U+18w2mnM5dzlw88hW92j 2+0+yHynP4JqWPngxgMZq5/tIYWe3cy9czSkwpMbHlvF4o+EmUD/gopF4UPAYHNAmJeX CQWA== X-Gm-Message-State: AOAM530UfE4nFaByZb2ef0yIsT9z0HAn8I33OkhJq22f4dYQ91zpaJgI 3Od1Tfpb3tyanyZDa2bP3Heg67DstlaB2GKMQw4QwrzLLsOtng== X-Received: by 2002:a02:4e45:: with SMTP id r66mr19454263jaa.137.1618901183758; Mon, 19 Apr 2021 23:46:23 -0700 (PDT) MIME-Version: 1.0 References: <1618459535-8141-1-git-send-email-dillon.minfei@gmail.com> <1618459535-8141-5-git-send-email-dillon.minfei@gmail.com> In-Reply-To: <1618459535-8141-5-git-send-email-dillon.minfei@gmail.com> From: dillon min Date: Tue, 20 Apr 2021 14:45:47 +0800 Message-ID: Subject: Re: [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off To: Krzysztof Kozlowski , Rob Herring , Shawn Guo , krzk@kernel.org, linux@rempel-privat.de, s.riedmueller@phytec.de, matthias.schiffer@ew.tq-group.com, leoyang.li@nxp.com, arnd@arndb.de, olof@lixom.net, Sascha Hauer , kernel@pengutronix.de, festevam@gmail.com, prabhakar.csengg@gmail.com, mchehab@kernel.org Cc: "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux Kernel Mailing List , Linux ARM , linux-imx@nxp.com, linux-media@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi All, Just a gentle ping, hope some expert could take a look, thanks. Best regards. Dillon On Thu, Apr 15, 2021 at 12:06 PM 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 > --- > v3: optimize commit message > > 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.7.4 >