From: dillon.minfei@gmail.com To: krzysztof.kozlowski@canonical.com, robh+dt@kernel.org, shawnguo@kernel.org, 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, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, prabhakar.csengg@gmail.com, mchehab@kernel.org Cc: 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 <dillon.minfei@gmail.com> Subject: [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off Date: Thu, 15 Apr 2021 12:05:35 +0800 [thread overview] Message-ID: <1618459535-8141-5-git-send-email-dillon.minfei@gmail.com> (raw) In-Reply-To: <1618459535-8141-1-git-send-email-dillon.minfei@gmail.com> From: dillon min <dillon.minfei@gmail.com> 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 <dillon.minfei@gmail.com> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: dillon.minfei@gmail.com To: krzysztof.kozlowski@canonical.com, robh+dt@kernel.org, shawnguo@kernel.org, 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, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, prabhakar.csengg@gmail.com, mchehab@kernel.org Cc: 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 <dillon.minfei@gmail.com> Subject: [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable, disable_unprepare}() to set xvclk on/off Date: Thu, 15 Apr 2021 12:05:35 +0800 [thread overview] Message-ID: <1618459535-8141-5-git-send-email-dillon.minfei@gmail.com> (raw) In-Reply-To: <1618459535-8141-1-git-send-email-dillon.minfei@gmail.com> From: dillon min <dillon.minfei@gmail.com> 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 <dillon.minfei@gmail.com> --- 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-04-15 4:06 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-15 4:05 [PATCH v3 0/4] arm: imx: Add i.mx6q DaSheng COM-9XX SBC board support dillon.minfei 2021-04-15 4:05 ` dillon.minfei 2021-04-15 4:05 ` [PATCH v3 1/4] dt-bindings: add dasheng vendor prefix dillon.minfei 2021-04-15 4:05 ` dillon.minfei 2021-04-15 20:37 ` Rob Herring 2021-04-15 20:37 ` Rob Herring 2021-04-15 4:05 ` [PATCH v3 2/4] dt-bindings: arm: imx: Add i.mx6q DaSheng COM-9XX SBC dillon.minfei 2021-04-15 4:05 ` dillon.minfei 2021-04-15 6:29 ` Krzysztof Kozlowski 2021-04-15 6:29 ` Krzysztof Kozlowski 2021-04-15 20:37 ` Rob Herring 2021-04-15 20:37 ` Rob Herring 2021-04-15 4:05 ` [PATCH v3 3/4] arm: dts: imx: Add i.mx6q DaSheng COM-9XX SBC board support dillon.minfei 2021-04-15 4:05 ` dillon.minfei 2021-04-20 6:43 ` dillon min 2021-04-20 6:43 ` dillon min 2021-04-20 14:27 ` Fabio Estevam 2021-04-20 14:27 ` Fabio Estevam 2021-04-21 3:40 ` dillon min 2021-04-21 3:40 ` dillon min 2021-04-15 4:05 ` dillon.minfei [this message] 2021-04-15 4:05 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable, disable_unprepare}() to set xvclk on/off dillon.minfei 2021-04-20 6:45 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() " dillon min 2021-04-20 6:45 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable, disable_unprepare}() " dillon min 2021-04-20 6:52 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() " Krzysztof Kozlowski 2021-04-20 6:52 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable, disable_unprepare}() " Krzysztof Kozlowski 2021-04-20 7:02 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() " dillon min 2021-04-20 7:02 ` [PATCH v3 4/4] media: i2c: ov2659: Use clk_{prepare_enable, disable_unprepare}() " dillon min
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1618459535-8141-5-git-send-email-dillon.minfei@gmail.com \ --to=dillon.minfei@gmail.com \ --cc=arnd@arndb.de \ --cc=devicetree@vger.kernel.org \ --cc=festevam@gmail.com \ --cc=kernel@pengutronix.de \ --cc=krzk@kernel.org \ --cc=krzysztof.kozlowski@canonical.com \ --cc=leoyang.li@nxp.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-imx@nxp.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux@rempel-privat.de \ --cc=matthias.schiffer@ew.tq-group.com \ --cc=mchehab@kernel.org \ --cc=olof@lixom.net \ --cc=prabhakar.csengg@gmail.com \ --cc=robh+dt@kernel.org \ --cc=s.hauer@pengutronix.de \ --cc=s.riedmueller@phytec.de \ --cc=shawnguo@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.