[V7,3/3] firmware: imx: imx-scu: register build-in child devices
diff mbox series

Message ID 1551834095-19950-3-git-send-email-Anson.Huang@nxp.com
State Superseded
Headers show
Series
  • [V7,1/3] watchdog: imx_sc: Add i.MX system controller watchdog support
Related show

Commit Message

Anson Huang March 6, 2019, 1:06 a.m. UTC
For some devices which are controlled by system controller,
they are NOT present in device tree since no hardware info
needed, just register these devices as children of SCU device.
This patch registers i.MX system controller watchdog platform
device as child device of SCU.

Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
No changes.
---
 drivers/firmware/imx/imx-scu.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Guenter Roeck March 6, 2019, 4:05 p.m. UTC | #1
Hi,

On 3/5/19 5:06 PM, Anson Huang wrote:
> For some devices which are controlled by system controller,
> they are NOT present in device tree since no hardware info
> needed, just register these devices as children of SCU device.
> This patch registers i.MX system controller watchdog platform
> device as child device of SCU.
> 
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> No changes.
> ---
>   drivers/firmware/imx/imx-scu.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c
> index 2bb1a19..df75ead 100644
> --- a/drivers/firmware/imx/imx-scu.c
> +++ b/drivers/firmware/imx/imx-scu.c
> @@ -196,6 +196,7 @@ EXPORT_SYMBOL(imx_scu_call_rpc);
>   
>   static int imx_scu_probe(struct platform_device *pdev)
>   {
> +	struct platform_device *child_pdev;
>   	struct device *dev = &pdev->dev;
>   	struct imx_sc_ipc *sc_ipc;
>   	struct imx_sc_chan *sc_chan;
> @@ -248,6 +249,13 @@ static int imx_scu_probe(struct platform_device *pdev)
>   
>   	dev_info(dev, "NXP i.MX SCU Initialized\n");
>   
> +	/* register SCU child devices which are NOT in device tree */
> +	child_pdev = platform_device_register_data(dev, "imx-sc-wdt",
> +				PLATFORM_DEVID_NONE, NULL, 0);
> +	if (IS_ERR(child_pdev))
> +		dev_warn(dev, "failed to register scu watchdog device %ld!\n",
> +			 PTR_ERR(child_pdev));
> +

I just realized ... since this is not a devm_ function, we now also need
error handling (if devm_of_platform_populate() fails) and a remove function.
Sorry for that - I should have noticed earlier.

Guenter

>   	return devm_of_platform_populate(dev);
>   }
>   
>
Anson Huang March 7, 2019, 12:46 a.m. UTC | #2
Hi, Guenter

Best Regards!
Anson Huang

> -----Original Message-----
> From: Guenter Roeck [mailto:groeck7@gmail.com] On Behalf Of Guenter
> Roeck
> Sent: 2019年3月7日 0:06
> To: Anson Huang <anson.huang@nxp.com>; catalin.marinas@arm.com;
> will.deacon@arm.com; shawnguo@kernel.org; s.hauer@pengutronix.de;
> kernel@pengutronix.de; festevam@gmail.com; wim@linux-watchdog.org;
> Andy Gross <andy.gross@linaro.org>; heiko@sntech.de;
> horms+renesas@verge.net.au; arnd@arndb.de;
> maxime.ripard@bootlin.com; jagan@amarulasolutions.com;
> bjorn.andersson@linaro.org; enric.balletbo@collabora.com;
> marc.w.gonzalez@free.fr; olof@lixom.net; Aisheng Dong
> <aisheng.dong@nxp.com>; linux-arm-kernel@lists.infradead.org; linux-
> kernel@vger.kernel.org; linux-watchdog@vger.kernel.org
> Cc: dl-linux-imx <linux-imx@nxp.com>
> Subject: Re: [PATCH V7 3/3] firmware: imx: imx-scu: register build-in child
> devices
> 
> Hi,
> 
> On 3/5/19 5:06 PM, Anson Huang wrote:
> > For some devices which are controlled by system controller, they are
> > NOT present in device tree since no hardware info needed, just
> > register these devices as children of SCU device.
> > This patch registers i.MX system controller watchdog platform device
> > as child device of SCU.
> >
> > Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> > ---
> > No changes.
> > ---
> >   drivers/firmware/imx/imx-scu.c | 8 ++++++++
> >   1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/firmware/imx/imx-scu.c
> > b/drivers/firmware/imx/imx-scu.c index 2bb1a19..df75ead 100644
> > --- a/drivers/firmware/imx/imx-scu.c
> > +++ b/drivers/firmware/imx/imx-scu.c
> > @@ -196,6 +196,7 @@ EXPORT_SYMBOL(imx_scu_call_rpc);
> >
> >   static int imx_scu_probe(struct platform_device *pdev)
> >   {
> > +	struct platform_device *child_pdev;
> >   	struct device *dev = &pdev->dev;
> >   	struct imx_sc_ipc *sc_ipc;
> >   	struct imx_sc_chan *sc_chan;
> > @@ -248,6 +249,13 @@ static int imx_scu_probe(struct platform_device
> > *pdev)
> >
> >   	dev_info(dev, "NXP i.MX SCU Initialized\n");
> >
> > +	/* register SCU child devices which are NOT in device tree */
> > +	child_pdev = platform_device_register_data(dev, "imx-sc-wdt",
> > +				PLATFORM_DEVID_NONE, NULL, 0);
> > +	if (IS_ERR(child_pdev))
> > +		dev_warn(dev, "failed to register scu watchdog
> device %ld!\n",
> > +			 PTR_ERR(child_pdev));
> > +
> 
> I just realized ... since this is not a devm_ function, we now also need error
> handling (if devm_of_platform_populate() fails) and a remove function.
> Sorry for that - I should have noticed earlier.

Thanks, I will add error handling here once we make decision of putting device register
here, we have other scenarios may need to have watchdog node in DT, if Rob agree
to have it in DT, this patch will be discarded.

Anson.

> 
> Guenter
> 
> >   	return devm_of_platform_populate(dev);
> >   }
> >
> >
Aisheng Dong March 7, 2019, 12:26 p.m. UTC | #3
[...]

> > diff --git a/drivers/firmware/imx/imx-scu.c
> > b/drivers/firmware/imx/imx-scu.c index 2bb1a19..df75ead 100644
> > --- a/drivers/firmware/imx/imx-scu.c
> > +++ b/drivers/firmware/imx/imx-scu.c
...
> > +	/* register SCU child devices which are NOT in device tree */
> > +	child_pdev = platform_device_register_data(dev, "imx-sc-wdt",
> > +				PLATFORM_DEVID_NONE, NULL, 0);
> > +	if (IS_ERR(child_pdev))
> > +		dev_warn(dev, "failed to register scu watchdog device %ld!\n",
> > +			 PTR_ERR(child_pdev));
> > +
> 
> I just realized ... since this is not a devm_ function, we now also need error
> handling (if devm_of_platform_populate() fails) and a remove function.
> Sorry for that - I should have noticed earlier.
> 

It looks strange to me that instantiate the watchdog device in SCU driver which
actually does not use SCU.

For me, it's actually a watchdog provided by ATF firmware, not SCU.
I explained this to Rob in another mail.
Let's see Rob's comments on it.

If Rob agrees, we can move watchdog node out of SCU and also do not
need instantiate it in SCU driver.

Regards
Dong Aisheng

> Guenter
> 
> >   	return devm_of_platform_populate(dev);
> >   }
> >
> >

Patch
diff mbox series

diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c
index 2bb1a19..df75ead 100644
--- a/drivers/firmware/imx/imx-scu.c
+++ b/drivers/firmware/imx/imx-scu.c
@@ -196,6 +196,7 @@  EXPORT_SYMBOL(imx_scu_call_rpc);
 
 static int imx_scu_probe(struct platform_device *pdev)
 {
+	struct platform_device *child_pdev;
 	struct device *dev = &pdev->dev;
 	struct imx_sc_ipc *sc_ipc;
 	struct imx_sc_chan *sc_chan;
@@ -248,6 +249,13 @@  static int imx_scu_probe(struct platform_device *pdev)
 
 	dev_info(dev, "NXP i.MX SCU Initialized\n");
 
+	/* register SCU child devices which are NOT in device tree */
+	child_pdev = platform_device_register_data(dev, "imx-sc-wdt",
+				PLATFORM_DEVID_NONE, NULL, 0);
+	if (IS_ERR(child_pdev))
+		dev_warn(dev, "failed to register scu watchdog device %ld!\n",
+			 PTR_ERR(child_pdev));
+
 	return devm_of_platform_populate(dev);
 }