devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
Cc: djakov@kernel.org, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	festevam@gmail.com, linux-imx@nxp.com, l.stach@pengutronix.de,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: Re: [PATCH 5/5] soc: imx: imx8mp-blk-ctrl: introduce HSIO blk ctrl noc settings
Date: Wed, 6 Apr 2022 12:45:48 +0300	[thread overview]
Message-ID: <Yk1hTNYYY47Pau8/@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220406082330.2681591-6-peng.fan@oss.nxp.com>

Hi Peng,

Thank you for the patch.

On Wed, Apr 06, 2022 at 04:23:30PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> The out of reset value of HSIO NoC is not a valid value, we need
> set it to a correct value. We only need to set it after power on.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/soc/imx/imx8mp-blk-ctrl.c | 74 +++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/drivers/soc/imx/imx8mp-blk-ctrl.c b/drivers/soc/imx/imx8mp-blk-ctrl.c
> index e832c007b063..929fd9b770ae 100644
> --- a/drivers/soc/imx/imx8mp-blk-ctrl.c
> +++ b/drivers/soc/imx/imx8mp-blk-ctrl.c
> @@ -12,6 +12,7 @@
>  #include <linux/pm_domain.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/regmap.h>
> +#include <linux/mfd/syscon.h>
>  
>  #include <dt-bindings/power/imx8mp-power.h>
>  
> @@ -26,14 +27,24 @@ struct imx8mp_hsio_blk_ctrl {
>  	struct notifier_block power_nb;
>  	struct device *bus_power_dev;
>  	struct regmap *regmap;
> +	struct regmap *noc_regmap;
>  	struct imx8mp_hsio_blk_ctrl_domain *domains;
>  	struct genpd_onecell_data onecell_data;
>  };
>  
> +struct imx8mp_hsio_blk_ctrl_noc_data {
> +	u32 off;
> +	u32 priority;
> +	u32 mode;
> +	u32 extctrl;
> +};

Maybe the data structure, and possibly the imx8mp_hsio_noc_set()
function, could be shared with imx8m-blk-ctrl.c ? It's much code, so if
it causes too much trouble, feel free to ignore.

The other comments on patch 4/5 apply to this one too.

> +
> +#define DOMAIN_MAX_NOC	2
>  struct imx8mp_hsio_blk_ctrl_domain_data {
>  	const char *name;
>  	const char *clk_name;
>  	const char *gpc_name;
> +	const struct imx8mp_hsio_blk_ctrl_noc_data *noc_data[DOMAIN_MAX_NOC];
>  };
>  
>  struct imx8mp_hsio_blk_ctrl_domain {
> @@ -41,6 +52,7 @@ struct imx8mp_hsio_blk_ctrl_domain {
>  	struct clk *clk;
>  	struct device *power_dev;
>  	struct imx8mp_hsio_blk_ctrl *bc;
> +	const struct imx8mp_hsio_blk_ctrl_domain_data *data;
>  	int id;
>  };
>  
> @@ -50,6 +62,27 @@ to_imx8mp_hsio_blk_ctrl_domain(struct generic_pm_domain *genpd)
>  	return container_of(genpd, struct imx8mp_hsio_blk_ctrl_domain, genpd);
>  }
>  
> +static int imx8mp_hsio_noc_set(struct imx8mp_hsio_blk_ctrl_domain *domain)
> +{
> +	const struct imx8mp_hsio_blk_ctrl_domain_data *data = domain->data;
> +	struct imx8mp_hsio_blk_ctrl *bc = domain->bc;
> +	struct regmap *regmap = bc->noc_regmap;
> +	int i;
> +
> +	if (!data || !regmap)
> +		return 0;
> +
> +	for (i = 0; i < DOMAIN_MAX_NOC; i++) {
> +		if (!data->noc_data[i])
> +			continue;
> +		regmap_write(regmap, data->noc_data[i]->off + 0x8, data->noc_data[i]->priority);
> +		regmap_write(regmap, data->noc_data[i]->off + 0xc, data->noc_data[i]->mode);
> +		regmap_write(regmap, data->noc_data[i]->off + 0x18, data->noc_data[i]->extctrl);
> +	}
> +
> +	return 0;
> +}
> +
>  static int imx8mp_hsio_blk_ctrl_power_on(struct generic_pm_domain *genpd)
>  {
>  	struct imx8mp_hsio_blk_ctrl_domain *domain =
> @@ -89,6 +122,8 @@ static int imx8mp_hsio_blk_ctrl_power_on(struct generic_pm_domain *genpd)
>  		goto clk_disable;
>  	}
>  
> +	imx8mp_hsio_noc_set(domain);
> +
>  	return 0;
>  
>  clk_disable:
> @@ -143,11 +178,39 @@ imx8m_blk_ctrl_xlate(struct of_phandle_args *args, void *data)
>  
>  static struct lock_class_key blk_ctrl_genpd_lock_class;
>  
> +#define IMX8MP_HSIOBLK_NOC_PCIE	0
> +#define IMX8MP_HSIOBLK_USB1	1
> +#define IMX8MP_HSIOBLK_USB2	2
> +#define IMX8MP_HSIOBLK_PCIE	3
> +
> +static const struct imx8mp_hsio_blk_ctrl_noc_data imx8mp_hsio_noc_data[] = {
> +	[IMX8MP_HSIOBLK_NOC_PCIE] = {
> +		.off = 0x780,
> +		.priority = 0x80000303,
> +	},
> +	[IMX8MP_HSIOBLK_USB1] = {
> +		.off = 0x800,
> +		.priority = 0x80000303,
> +	},
> +	[IMX8MP_HSIOBLK_USB2] = {
> +		.off = 0x880,
> +		.priority = 0x80000303,
> +	},
> +	[IMX8MP_HSIOBLK_PCIE] = {
> +		.off = 0x900,
> +		.priority = 0x80000303,
> +	},
> +};
> +
>  static const struct imx8mp_hsio_blk_ctrl_domain_data imx8mp_hsio_domain_data[] = {
>  	[IMX8MP_HSIOBLK_PD_USB] = {
>  		.name = "hsioblk-usb",
>  		.clk_name = "usb",
>  		.gpc_name = "usb",
> +		.noc_data = {
> +			&imx8mp_hsio_noc_data[IMX8MP_HSIOBLK_USB1],
> +			&imx8mp_hsio_noc_data[IMX8MP_HSIOBLK_USB2]
> +		},
>  	},
>  	[IMX8MP_HSIOBLK_PD_USB_PHY1] = {
>  		.name = "hsioblk-usb-phy1",
> @@ -161,6 +224,10 @@ static const struct imx8mp_hsio_blk_ctrl_domain_data imx8mp_hsio_domain_data[] =
>  		.name = "hsioblk-pcie",
>  		.clk_name = "pcie",
>  		.gpc_name = "pcie",
> +		.noc_data = {
> +			&imx8mp_hsio_noc_data[IMX8MP_HSIOBLK_NOC_PCIE],
> +			&imx8mp_hsio_noc_data[IMX8MP_HSIOBLK_PCIE]
> +		},
>  	},
>  	[IMX8MP_HSIOBLK_PD_PCIE_PHY] = {
>  		.name = "hsioblk-pcie-phy",
> @@ -215,6 +282,7 @@ static int imx8mp_hsio_blk_ctrl_probe(struct platform_device *pdev)
>  	int num_domains = ARRAY_SIZE(imx8mp_hsio_domain_data);
>  	struct device *dev = &pdev->dev;
>  	struct imx8mp_hsio_blk_ctrl *bc;
> +	struct regmap *regmap;
>  	void __iomem *base;
>  	int i, ret;
>  
> @@ -259,11 +327,17 @@ static int imx8mp_hsio_blk_ctrl_probe(struct platform_device *pdev)
>  		return dev_err_probe(dev, PTR_ERR(bc->bus_power_dev),
>  				     "failed to attach bus power domain\n");
>  
> +	regmap = syscon_regmap_lookup_by_compatible("fsl,imx8m-noc");
> +	if (!IS_ERR(regmap))
> +		bc->noc_regmap = regmap;
> +
>  	for (i = 0; i < num_domains; i++) {
>  		const struct imx8mp_hsio_blk_ctrl_domain_data *data =
>  				&imx8mp_hsio_domain_data[i];
>  		struct imx8mp_hsio_blk_ctrl_domain *domain = &bc->domains[i];
>  
> +		domain->data = data;
> +
>  		if (data->clk_name) {
>  			domain->clk = devm_clk_get(dev, data->clk_name);
>  			if (IS_ERR(domain->clk)) {
> -- 
> 2.25.1
> 

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2022-04-06 13:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  8:23 [PATCH 0/5] imx: support noc settings with power domain Peng Fan (OSS)
2022-04-06  8:23 ` [PATCH 1/5] dt-bindings: interconnect: imx8m: Add bindings for imx8mp noc Peng Fan (OSS)
2022-04-06  8:40   ` Laurent Pinchart
2022-04-06 11:21     ` Peng Fan
2022-04-06  8:23 ` [PATCH 2/5] arm64: dts: imx8mp: add noc node Peng Fan (OSS)
2022-04-06  8:57   ` Laurent Pinchart
2022-04-06  9:33     ` Peng Fan
2022-04-06  8:23 ` [PATCH 3/5] soc: imx: gpcv2: support i.MX8MP NoC settings Peng Fan (OSS)
2022-04-06  8:23 ` [PATCH 4/5] soc: imx: imx8m-blk-ctrl: support i.MX8MP media blk ctrl noc settings Peng Fan (OSS)
2022-04-06  9:42   ` Laurent Pinchart
2022-04-06  8:23 ` [PATCH 5/5] soc: imx: imx8mp-blk-ctrl: introduce HSIO " Peng Fan (OSS)
2022-04-06  9:45   ` Laurent Pinchart [this message]
2022-04-06  9:47 ` [PATCH 0/5] imx: support noc settings with power domain Lucas Stach
2022-04-06 10:55   ` Peng Fan
2022-04-06 11:56     ` Lucas Stach

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=Yk1hTNYYY47Pau8/@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djakov@kernel.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=l.stach@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peng.fan@nxp.com \
    --cc=peng.fan@oss.nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=s.hauer@pengutronix.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: 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;
as well as URLs for NNTP newsgroup(s).