Re: [PATCH V3 3/4] soc: imx: Add generic blk-ctl driver

From: Frieder Schrempf
Date: Thu May 06 2021 - 03:31:26 EST


On 06.05.21 06:15, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@xxxxxxx>
>
> The i.MX8MM introduces an IP named BLK_CTL and usually is comprised of
> some GPRs.
>
> The GPRs has some clock bits and reset bits, but here we take it
> as virtual PDs, because of the clock and power domain A/B lock issue
> when taking it as a clock controller.
>
> For some bits, it might be good to also make it as a reset controller,
> but to i.MX8MM, we not add that support for now.
>
> Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> ---
> drivers/soc/imx/Makefile | 2 +-
> drivers/soc/imx/blk-ctl.c | 307 ++++++++++++++++++++++++++++++++++++++
> drivers/soc/imx/blk-ctl.h | 77 ++++++++++
> 3 files changed, 385 insertions(+), 1 deletion(-)
> create mode 100644 drivers/soc/imx/blk-ctl.c
> create mode 100644 drivers/soc/imx/blk-ctl.h
>
> diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile
> index 078dc918f4f3..d3d2b49a386c 100644
> --- a/drivers/soc/imx/Makefile
> +++ b/drivers/soc/imx/Makefile
> @@ -4,4 +4,4 @@ obj-$(CONFIG_ARCH_MXC) += soc-imx.o
> endif
> obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
> obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
> -obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o
> +obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o blk-ctl.o
> diff --git a/drivers/soc/imx/blk-ctl.c b/drivers/soc/imx/blk-ctl.c
> new file mode 100644
> index 000000000000..e184d862b26b
> --- /dev/null
> +++ b/drivers/soc/imx/blk-ctl.c
> @@ -0,0 +1,307 @@
[...]
> +
> + blk_ctl->power_count--;
> +
> + if (!blk_ctl->power_count) {
> + ret = imx_blk_ctl_enable_hsk(blk_ctl->dev);
> + if (ret)
> + dev_err(blk_ctl->dev, "Hankshake failed when power off\n");

You still have a 'k' instead of a 'd' in "Handshake"!

> + }
> +
> +hsk_fail:
> + clk_bulk_disable_unprepare(blk_ctl->num_clks, blk_ctl->clks);
> +
> + mutex_unlock(&blk_ctl->lock);
> +
> + return ret;
> +}
> +
> +int imx_blk_ctl_power_on(struct generic_pm_domain *domain)
> +{
> + struct imx_blk_ctl_domain *pd = to_imx_blk_ctl_pd(domain);
> + struct imx_blk_ctl *blk_ctl = pd->blk_ctl;
> + struct regmap *regmap = blk_ctl->regmap;
> + const struct imx_blk_ctl_hw *hw = &blk_ctl->dev_data->pds[pd->id];
> + int ret;
> +
> + mutex_lock(&blk_ctl->lock);
> +
> + ret = clk_bulk_prepare_enable(blk_ctl->num_clks, blk_ctl->clks);
> + if (ret) {
> + mutex_unlock(&blk_ctl->lock);
> + return ret;
> + }
> +
> + if (!blk_ctl->power_count) {
> + ret = imx_blk_ctl_enable_hsk(blk_ctl->dev);
> + if (ret) {
> + dev_err(blk_ctl->dev, "Hankshake failed when power on\n");

You still have a 'k' instead of a 'd' in "Handshake"!

> + goto disable_clk;
> + }
> + }
> +
[...]