From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Rui Miguel Silva <rmfrfs@gmail.com>,
kernel@pengutronix.de, Fabio Estevam <festevam@gmail.com>,
linux-imx@nxp.com, Steve Longerbeam <slongerbeam@gmail.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Marek Vasut <marex@denx.de>,
Frieder Schrempf <frieder.schrempf@kontron.de>,
Marco Felsch <m.felsch@pengutronix.de>,
Martin Kepplinger <martin.kepplinger@puri.sm>,
Tim Harvey <tharvey@gateworks.com>
Subject: Re: [PATCH v2 22/25] media: imx: imx7_mipi_csis: Move PHY control to dedicated functions
Date: Sun, 16 May 2021 05:18:45 +0300 [thread overview]
Message-ID: <YKCBBc9XEYCbb1kv@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20210516014441.5508-23-laurent.pinchart@ideasonboard.com>
On Sun, May 16, 2021 at 04:44:38AM +0300, Laurent Pinchart wrote:
> Move the PHY regulator and reset handling to dedicated functions. This
> groups all related code together, and prepares for i.MX8 support that
> doesn't require control of the PHY regulator and reset.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Acked-by: Rui Miguel Silva <rmfrfs@gmail.com>
My apologies, this is a new patch in v2, and Rui hasn't acked it. I'll
thus wait for acks and reviews before sending a pull request.
> ---
> drivers/staging/media/imx/imx7-mipi-csis.c | 64 +++++++++++++---------
> 1 file changed, 38 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
> index 6e235c86e0aa..a8da8d6ddb7d 100644
> --- a/drivers/staging/media/imx/imx7-mipi-csis.c
> +++ b/drivers/staging/media/imx/imx7-mipi-csis.c
> @@ -457,25 +457,6 @@ static void mipi_csis_sw_reset(struct csi_state *state)
> usleep_range(10, 20);
> }
>
> -static int mipi_csis_phy_init(struct csi_state *state)
> -{
> - state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
> - if (IS_ERR(state->mipi_phy_regulator))
> - return PTR_ERR(state->mipi_phy_regulator);
> -
> - return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
> - 1000000);
> -}
> -
> -static void mipi_csis_phy_reset(struct csi_state *state)
> -{
> - reset_control_assert(state->mrst);
> -
> - msleep(20);
> -
> - reset_control_deassert(state->mrst);
> -}
> -
> static void mipi_csis_system_enable(struct csi_state *state, int on)
> {
> u32 val, mask;
> @@ -679,6 +660,42 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +/* -----------------------------------------------------------------------------
> + * PHY regulator and reset
> + */
> +
> +static int mipi_csis_phy_enable(struct csi_state *state)
> +{
> + return regulator_enable(state->mipi_phy_regulator);
> +}
> +
> +static int mipi_csis_phy_disable(struct csi_state *state)
> +{
> + return regulator_disable(state->mipi_phy_regulator);
> +}
> +
> +static void mipi_csis_phy_reset(struct csi_state *state)
> +{
> + reset_control_assert(state->mrst);
> + msleep(20);
> + reset_control_deassert(state->mrst);
> +}
> +
> +static int mipi_csis_phy_init(struct csi_state *state)
> +{
> + /* Get MIPI PHY reset and regulator. */
> + state->mrst = devm_reset_control_get_exclusive(state->dev, NULL);
> + if (IS_ERR(state->mrst))
> + return PTR_ERR(state->mrst);
> +
> + state->mipi_phy_regulator = devm_regulator_get(state->dev, "phy");
> + if (IS_ERR(state->mipi_phy_regulator))
> + return PTR_ERR(state->mipi_phy_regulator);
> +
> + return regulator_set_voltage(state->mipi_phy_regulator, 1000000,
> + 1000000);
> +}
> +
> /* -----------------------------------------------------------------------------
> * Debug
> */
> @@ -1178,7 +1195,7 @@ static int mipi_csis_pm_suspend(struct device *dev, bool runtime)
> mutex_lock(&state->lock);
> if (state->state & ST_POWERED) {
> mipi_csis_stop_stream(state);
> - ret = regulator_disable(state->mipi_phy_regulator);
> + ret = mipi_csis_phy_disable(state);
> if (ret)
> goto unlock;
> mipi_csis_clk_disable(state);
> @@ -1204,7 +1221,7 @@ static int mipi_csis_pm_resume(struct device *dev, bool runtime)
> goto unlock;
>
> if (!(state->state & ST_POWERED)) {
> - ret = regulator_enable(state->mipi_phy_regulator);
> + ret = mipi_csis_phy_enable(state);
> if (ret)
> goto unlock;
>
> @@ -1288,11 +1305,6 @@ static int mipi_csis_parse_dt(struct csi_state *state)
> &state->clk_frequency))
> state->clk_frequency = DEFAULT_SCLK_CSIS_FREQ;
>
> - /* Get MIPI PHY resets */
> - state->mrst = devm_reset_control_get_exclusive(state->dev, NULL);
> - if (IS_ERR(state->mrst))
> - return PTR_ERR(state->mrst);
> -
> return 0;
> }
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2021-05-16 2:18 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-16 1:44 [PATCH v2 00/25] media: imx: imx7-mipi-csis: Add i.MX8MM support Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 01/25] media: imx: imx7_mipi_csis: Fix logging of only error event counters Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 02/25] media: imx: imx7_mipi_csis: Count the CSI-2 debug interrupts Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 03/25] media: imx: imx7_mipi_csis: Update ISP_CONFIG macros for quad pixel mode Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 04/25] media: imx: imx7_mipi_csis: Move static data to top of mipi_csis_dump_regs() Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 05/25] media: imx: imx7_mipi_csis: Minimize locking in get/set format Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 06/25] media: imx: imx7_mipi_csis: Don't set subdev data Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 07/25] media: imx: imx7_mipi_csis: Reorganize code in sections Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 08/25] media: imx: imx7_mipi_csis: Set the CLKSETTLE register field Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 09/25] media: imx: imx7_mipi_csis: Drop unused csis_hw_reset structure Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 10/25] media: imx: imx7_mipi_csis: Store CSI-2 data type in format structure Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 11/25] media: imx: imx7_mipi_csis: Drop csi_state phy field Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 12/25] media: imx: imx7_mipi_csis: Rename mipi_sd to sd Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 13/25] media: imx: imx7_mipi_csis: Rename csi_state flag field to state Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 14/25] media: imx: imx7_mipi_csis: Turn csi_state irq field into local variable Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 15/25] media: imx: imx7_mipi_csis: Don't pass pdev to mipi_csis_parse_dt() Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 16/25] media: imx: imx7_mipi_csis: Pass csi_state to mipi_csis_subdev_init() Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 17/25] media: imx: imx7_mipi_csis: Drop csi_state pdev field Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 18/25] media: imx: imx7_mipi_csis: Make csi_state num_clocks field unsigned Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 19/25] media: imx: imx7_mipi_csis: Reorganize csi_state structure Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 20/25] media: imx: imx7_mipi_csis: Reorganize mipi_csis_probe() Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 21/25] media: imx: imx7_mipi_csis: Reject invalid data-lanes settings Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 22/25] media: imx: imx7_mipi_csis: Move PHY control to dedicated functions Laurent Pinchart
2021-05-16 2:18 ` Laurent Pinchart [this message]
2021-05-16 22:00 ` Rui Miguel Silva
2021-05-16 1:44 ` [PATCH v2 23/25] dt-bindings: media: nxp,imx7-mipi-csi2: Add i.MX8MM support Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 24/25] media: imx: imx7_mipi_csis: " Laurent Pinchart
2021-05-16 1:44 ` [PATCH v2 25/25] media: imx: imx7_mipi_csis: Update MAINTAINERS Laurent Pinchart
2021-05-16 2:24 ` [PATCH v2 00/25] media: imx: imx7-mipi-csis: Add i.MX8MM support Laurent Pinchart
2021-05-17 9:57 ` Frieder Schrempf
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=YKCBBc9XEYCbb1kv@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=festevam@gmail.com \
--cc=frieder.schrempf@kontron.de \
--cc=kernel@pengutronix.de \
--cc=linux-imx@nxp.com \
--cc=linux-media@vger.kernel.org \
--cc=m.felsch@pengutronix.de \
--cc=marex@denx.de \
--cc=martin.kepplinger@puri.sm \
--cc=p.zabel@pengutronix.de \
--cc=rmfrfs@gmail.com \
--cc=slongerbeam@gmail.com \
--cc=tharvey@gateworks.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox