RE: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-05-10 Thread Anson Huang
Hi, Aisheng
Thanks for comments, I plan to resend this patch to make it align with 
current drivers/soc/imx/soc-imx8.c implementation about the soc id/revision 
generation, the ONLY difference would be the system controller SoC driver needs 
to use platform driver model as it needs to use defer probe to make sure SCU 
driver is ready, and need to use SCU API for getting soc id, will resend a 
patch soon, sorry for wasting your time on this patch.

Anson.

> -Original Message-
> From: Aisheng Dong
> Sent: Friday, May 10, 2019 5:17 PM
> To: Anson Huang ; catalin.mari...@arm.com;
> will.dea...@arm.com; shawn...@kernel.org; s.ha...@pengutronix.de;
> ker...@pengutronix.de; feste...@gmail.com; he...@sntech.de;
> horms+rene...@verge.net.au; o...@lixom.net; Andy Gross
> ; bjorn.anders...@linaro.org;
> ja...@amarulasolutions.com; enric.balle...@collabora.com;
> stefan.wah...@i2se.com; ezequ...@collabora.com;
> marc.w.gonza...@free.fr; r...@kernel.org; l.st...@pengutronix.de; Abel
> Vesa ; linux-arm-ker...@lists.infradead.org; linux-
> ker...@vger.kernel.org
> Cc: dl-linux-imx 
> Subject: RE: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver
> support
> 
> > From: Anson Huang
> > Sent: Thursday, April 11, 2019 2:49 PM
> >
> > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> > inside, the system controller is in charge of controlling power, clock and
> fuse etc..
> >
> > This patch adds i.MX system controller soc driver support, Linux
> > kernel has to communicate with system controller via MU (message unit)
> > IPC to get soc revision, uid etc..
> >
> > With this patch, soc info can be read from sysfs:
> >
> > i.mx8qxp-mek# cat /sys/devices/soc0/family Freescale i.MX
> >
> > i.mx8qxp-mek# cat /sys/devices/soc0/soc_id i.MX8QXP
> >
> > i.mx8qxp-mek# cat /sys/devices/soc0/machine Freescale i.MX8QXP MEK
> >
> > i.mx8qxp-mek# cat /sys/devices/soc0/revision
> > 1.1
> >
> > i.mx8qxp-mek# cat /sys/devices/soc0/soc_uid
> > 7B64280B57AC1898
> >
> > Signed-off-by: Anson Huang 
> > ---
> >  drivers/soc/imx/Kconfig  |   7 ++
> >  drivers/soc/imx/Makefile |   1 +
> >  drivers/soc/imx/soc-imx-sc.c | 220
> > +++
> >  3 files changed, 228 insertions(+)
> >  create mode 100644 drivers/soc/imx/soc-imx-sc.c
> >
> > diff --git a/drivers/soc/imx/Kconfig b/drivers/soc/imx/Kconfig index
> > d80f899..c902b89 100644
> > --- a/drivers/soc/imx/Kconfig
> > +++ b/drivers/soc/imx/Kconfig
> > @@ -7,4 +7,11 @@ config IMX_GPCV2_PM_DOMAINS
> > select PM_GENERIC_DOMAINS
> > default y if SOC_IMX7D
> >
> > +config IMX_SC_SOC
> > +   depends on IMX_SCU || COMPILE_TEST
> 
> COMPILE_TEST may not work due to dependency
> 
> > +   tristate "i.MX System Controller SoC support"
> 
> Can it build as module?
> I did not see soc_device_register() is exported.
> 
> > +   help
> > +  If you say yes here you get support for the i.MX System
> > +  Controller SoC module.
> > +
> >  endmenu
> > diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index
> > 506a6f3..d00606d 100644
> > --- a/drivers/soc/imx/Makefile
> > +++ b/drivers/soc/imx/Makefile
> > @@ -1,2 +1,3 @@
> >  obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
> >  obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
> > +obj-$(CONFIG_IMX_SC_SOC) += soc-imx-sc.o
> > diff --git a/drivers/soc/imx/soc-imx-sc.c
> > b/drivers/soc/imx/soc-imx-sc.c new file mode 100644 index
> > 000..029d754
> > --- /dev/null
> > +++ b/drivers/soc/imx/soc-imx-sc.c
> > @@ -0,0 +1,220 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + * Copyright 2019 NXP.
> > + */
> > +
> > +#include  #include
> > + #include  #include
> > + #include  #include
> > + #include 
> > +
> > +#include 
> > +
> > +#define IMX_SC_SOC_DRIVER_NAME "imx-sc-soc"
> > +
> > +#define SOC_REV_MAJOR_OFFSET   0x4
> > +#define SOC_REV_MAJOR_MASK 0xf
> > +#define SOC_REV_MINOR_OFFSET   0x4
> > +#define SOC_REV_MINOR_MASK 0xf
> > +
> > +#define get_soc_rev_major(rev) ((rev >> SOC_REV_MAJOR_OFFSET) &
> > +SOC_REV_MAJOR_MASK) #define get_soc_rev_minor(rev) ((rev >>
> > +SOC_REV_MINOR_OFFSET) & SOC_REV_MINOR_MASK)
> > +
> > +static u32 imx_sc_soc_rev = IMX_CHIP_REVISION_UNKNOWN; static u64
> > +imx_sc_soc_uid;
> > +
> > +static struct imx_sc_ipc *soc_ipc_handle; static struct
> > +platform_d

RE: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-05-10 Thread Aisheng Dong
> From: Anson Huang
> Sent: Thursday, April 11, 2019 2:49 PM
> 
> i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller inside,
> the system controller is in charge of controlling power, clock and fuse etc..
> 
> This patch adds i.MX system controller soc driver support, Linux kernel has to
> communicate with system controller via MU (message unit) IPC to get soc
> revision, uid etc..
> 
> With this patch, soc info can be read from sysfs:
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/family Freescale i.MX
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/soc_id i.MX8QXP
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/machine Freescale i.MX8QXP MEK
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/revision
> 1.1
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/soc_uid
> 7B64280B57AC1898
> 
> Signed-off-by: Anson Huang 
> ---
>  drivers/soc/imx/Kconfig  |   7 ++
>  drivers/soc/imx/Makefile |   1 +
>  drivers/soc/imx/soc-imx-sc.c | 220
> +++
>  3 files changed, 228 insertions(+)
>  create mode 100644 drivers/soc/imx/soc-imx-sc.c
> 
> diff --git a/drivers/soc/imx/Kconfig b/drivers/soc/imx/Kconfig index
> d80f899..c902b89 100644
> --- a/drivers/soc/imx/Kconfig
> +++ b/drivers/soc/imx/Kconfig
> @@ -7,4 +7,11 @@ config IMX_GPCV2_PM_DOMAINS
>   select PM_GENERIC_DOMAINS
>   default y if SOC_IMX7D
> 
> +config IMX_SC_SOC
> + depends on IMX_SCU || COMPILE_TEST

COMPILE_TEST may not work due to dependency

> + tristate "i.MX System Controller SoC support"

Can it build as module?
I did not see soc_device_register() is exported.

> + help
> +If you say yes here you get support for the i.MX System
> +Controller SoC module.
> +
>  endmenu
> diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index
> 506a6f3..d00606d 100644
> --- a/drivers/soc/imx/Makefile
> +++ b/drivers/soc/imx/Makefile
> @@ -1,2 +1,3 @@
>  obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o
>  obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o
> +obj-$(CONFIG_IMX_SC_SOC) += soc-imx-sc.o
> diff --git a/drivers/soc/imx/soc-imx-sc.c b/drivers/soc/imx/soc-imx-sc.c new 
> file
> mode 100644 index 000..029d754
> --- /dev/null
> +++ b/drivers/soc/imx/soc-imx-sc.c
> @@ -0,0 +1,220 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright 2019 NXP.
> + */
> +
> +#include  #include
> + #include  #include
> + #include  #include
> + #include 
> +
> +#include 
> +
> +#define IMX_SC_SOC_DRIVER_NAME   "imx-sc-soc"
> +
> +#define SOC_REV_MAJOR_OFFSET 0x4
> +#define SOC_REV_MAJOR_MASK   0xf
> +#define SOC_REV_MINOR_OFFSET 0x4
> +#define SOC_REV_MINOR_MASK   0xf
> +
> +#define get_soc_rev_major(rev) ((rev >> SOC_REV_MAJOR_OFFSET) &
> +SOC_REV_MAJOR_MASK) #define get_soc_rev_minor(rev) ((rev >>
> +SOC_REV_MINOR_OFFSET) & SOC_REV_MINOR_MASK)
> +
> +static u32 imx_sc_soc_rev = IMX_CHIP_REVISION_UNKNOWN; static u64
> +imx_sc_soc_uid;
> +
> +static struct imx_sc_ipc *soc_ipc_handle; static struct platform_device
> +*imx_sc_soc_pdev;
> +
> +struct imx_sc_msg_misc_get_soc_id {
> + struct imx_sc_rpc_msg hdr;
> + union {
> + struct {
> + u32 control;
> + u16 resource;
> + } __packed send;
> + struct {
> + u32 id;
> + u16 reserved;
> + } __packed resp;
> + } data;
> +};

By learned more, I think probably a more safe reference is to
have one more __packed outside. Then we can unified in this way.

> +
> +struct imx_sc_msg_misc_get_soc_uid {
> + struct imx_sc_rpc_msg hdr;
> + u32 id_l;
> + u32 id_h;
> +};
> +
> +static inline void imx_sc_set_soc_revision(u32 rev) {
> + imx_sc_soc_rev = rev;
> +}
> +
> +unsigned int imx_get_soc_revision(void) {
> + return imx_sc_soc_rev;
> +}
> +EXPORT_SYMBOL(imx_get_soc_revision);
> +
> +static u32 imx_init_revision_from_scu(void) {
> + struct imx_sc_msg_misc_get_soc_id msg;
> + struct imx_sc_msg_misc_get_soc_uid msg1;
> + struct imx_sc_rpc_msg *hdr = 
> + struct imx_sc_rpc_msg *hdr1 = 
> + u32 id, rev;
> + int ret;
> +
> + hdr->ver = IMX_SC_RPC_VERSION;
> + hdr->svc = IMX_SC_RPC_SVC_MISC;
> + hdr->func = IMX_SC_MISC_FUNC_GET_CONTROL;
> + hdr->size = 3;
> +
> + msg.data.send.control = IMX_SC_C_ID;
> + msg.data.send.resource = IMX_SC_R_SYSTEM;
> +
> + ret = imx_scu_call_rpc(soc_ipc_handle, , true);
> + if (ret) {
> + pr_err("misc get control failed, ret %d\n", ret);

Pls improve the message

> + return ret;
> + }
> +
> + id = msg.data.resp.id;
> +
> + rev = (id >> 5) & 0xf;
> + rev = (((rev >> 2) + 1) << 4) | (rev & 0x3);
> +
> + imx_sc_set_soc_revision(rev);
> +
> + hdr1->ver = IMX_SC_RPC_VERSION;
> + hdr1->svc = IMX_SC_RPC_SVC_MISC;
> + hdr1->func = IMX_SC_MISC_FUNC_UNIQUE_ID;
> + hdr1->size = 1;

Can't we reuse the first one?

> +
> + /* the return value of SCU FW is in correct, can NOT check the ret */
> + 

Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-05-10 Thread Abel Vesa
On 19-05-10 10:42:17, Shawn Guo wrote:
> On Mon, Apr 22, 2019 at 08:48:56AM +, Leonard Crestez wrote:
> > On 4/22/2019 9:46 AM, Anson Huang wrote:
> > >> -Original Message-
> > >> From: Anson Huang
> > >>> From: Shawn Guo [mailto:shawn...@kernel.org]
> > >>> On Sun, Apr 21, 2019 at 03:40:00PM +0800, Shawn Guo wrote:
> >  On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> > > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> > > inside, the system controller is in charge of controlling power,
> > > clock and fuse etc..
> > >
> > > This patch adds i.MX system controller soc driver support, Linux
> > > kernel has to communicate with system controller via MU (message
> > > unit) IPC to get soc revision, uid etc..
> > >
> > > With this patch, soc info can be read from sysfs:
> > >
> > >   drivers/soc/imx/Kconfig  |   7 ++
> > >   drivers/soc/imx/Makefile |   1 +
> > >   drivers/soc/imx/soc-imx-sc.c | 220
> > > +++
> > >   3 files changed, 228 insertions(+)  create mode 100644
> > > drivers/soc/imx/soc-imx-sc.c
> > 
> >  Rather than creating a new driver, please take a look at Abel's
> >  generic
> >  i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.
> > >>
> > >> Got it, I didn't notice that this patch bas been accepted, I will redo 
> > >> the patch
> > >> based on it, thanks.
> > > 
> > > I have sent the new patch set to support i.MX8QXP SoC revision based on 
> > > generic i.MX8
> > > SoC driver, however, the Kconfig modification is NOT good, it may break 
> > > i.MX8MQ if IMX_SCU
> > > is NOT enabled, although we can add some warp function for SCU firmware 
> > > API call to fix it,
> > > but after further thought and discussion with Dong Aisheng, I think we 
> > > may need to roll back to
> > > use this patch series to create a new SoC driver dedicated for i.MX8 SoCs
> > > with system controller inside, such as i.MX8QXP, i.MX8QM etc., the reason 
> > > are as below:
> > > 
> > > For i.MX8MQ/i.MX8MM:
> > >   1. SoC driver does NOT depends on i.MX SCU firmware, so no need to use 
> > > platform driver
> > >probe model, just device_init phase call is good enough;
> > >   2. The SoC driver no need to depends on IMX_SCU, so it can be always 
> > > built in, no need to
> > >check IMX_SCU config;
> > >   3. The fuse check for CPU speed grading, HDCP status, NoC settings etc. 
> > > could be added to this driver,
> > >   but they are ONLY for i.MX8MQ/i.MX8MM etc..
> > > For i.MX8QXP/i.MX8QM:
> > >   1. SoC driver MUST depends on IMX_SCU;
> > >   2. MUST use platform model to support defer probe;
> > >   3. No fuse check for CPU speed grading.
> > > 
> > > So, I guess the reused code for i.MX8MQ and i.MX8QXP is ONLY those part 
> > > of creating SoC id device node (less than
> > > 30% I think), all other functions are implemented in total different 
> > > ways, that is why I created the imx_sc_soc driver
> > > in this patch series, so do you think we can add new SoC driver for i.MX8 
> > > SoC with SCU inside? Putting 2 different architecture
> > > SoCs' driver into 1 file looks like NOT making enough sense.
> > 
> > +1 for separate SOC driver. The 8mq/8mm and 8qm/8qxp families are very 
> > different, they just happen to share the imx8 prefix.
> > 
> > It makes sense to allow people to compile one without the other and this 
> > is easier with distinct SOC drivers.

Totally agree.

> 
> Leonard, Abel,
> 
> Can you guys help review the patch?  Thanks.
> 
> Shawn

Looks good to me.

Reviewed-by: Abel Vesa 

Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-05-09 Thread Shawn Guo
On Mon, Apr 22, 2019 at 08:48:56AM +, Leonard Crestez wrote:
> On 4/22/2019 9:46 AM, Anson Huang wrote:
> >> -Original Message-
> >> From: Anson Huang
> >>> From: Shawn Guo [mailto:shawn...@kernel.org]
> >>> On Sun, Apr 21, 2019 at 03:40:00PM +0800, Shawn Guo wrote:
>  On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> > inside, the system controller is in charge of controlling power,
> > clock and fuse etc..
> >
> > This patch adds i.MX system controller soc driver support, Linux
> > kernel has to communicate with system controller via MU (message
> > unit) IPC to get soc revision, uid etc..
> >
> > With this patch, soc info can be read from sysfs:
> >
> >   drivers/soc/imx/Kconfig  |   7 ++
> >   drivers/soc/imx/Makefile |   1 +
> >   drivers/soc/imx/soc-imx-sc.c | 220
> > +++
> >   3 files changed, 228 insertions(+)  create mode 100644
> > drivers/soc/imx/soc-imx-sc.c
> 
>  Rather than creating a new driver, please take a look at Abel's
>  generic
>  i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.
> >>
> >> Got it, I didn't notice that this patch bas been accepted, I will redo the 
> >> patch
> >> based on it, thanks.
> > 
> > I have sent the new patch set to support i.MX8QXP SoC revision based on 
> > generic i.MX8
> > SoC driver, however, the Kconfig modification is NOT good, it may break 
> > i.MX8MQ if IMX_SCU
> > is NOT enabled, although we can add some warp function for SCU firmware API 
> > call to fix it,
> > but after further thought and discussion with Dong Aisheng, I think we may 
> > need to roll back to
> > use this patch series to create a new SoC driver dedicated for i.MX8 SoCs
> > with system controller inside, such as i.MX8QXP, i.MX8QM etc., the reason 
> > are as below:
> > 
> > For i.MX8MQ/i.MX8MM:
> > 1. SoC driver does NOT depends on i.MX SCU firmware, so no need to use 
> > platform driver
> >  probe model, just device_init phase call is good enough;
> > 2. The SoC driver no need to depends on IMX_SCU, so it can be always 
> > built in, no need to
> >  check IMX_SCU config;
> > 3. The fuse check for CPU speed grading, HDCP status, NoC settings etc. 
> > could be added to this driver,
> > but they are ONLY for i.MX8MQ/i.MX8MM etc..
> > For i.MX8QXP/i.MX8QM:
> > 1. SoC driver MUST depends on IMX_SCU;
> > 2. MUST use platform model to support defer probe;
> > 3. No fuse check for CPU speed grading.
> > 
> > So, I guess the reused code for i.MX8MQ and i.MX8QXP is ONLY those part of 
> > creating SoC id device node (less than
> > 30% I think), all other functions are implemented in total different ways, 
> > that is why I created the imx_sc_soc driver
> > in this patch series, so do you think we can add new SoC driver for i.MX8 
> > SoC with SCU inside? Putting 2 different architecture
> > SoCs' driver into 1 file looks like NOT making enough sense.
> 
> +1 for separate SOC driver. The 8mq/8mm and 8qm/8qxp families are very 
> different, they just happen to share the imx8 prefix.
> 
> It makes sense to allow people to compile one without the other and this 
> is easier with distinct SOC drivers.

Leonard, Abel,

Can you guys help review the patch?  Thanks.

Shawn


Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-04-22 Thread Leonard Crestez
On 4/22/2019 9:46 AM, Anson Huang wrote:
>> -Original Message-
>> From: Anson Huang
>>> From: Shawn Guo [mailto:shawn...@kernel.org]
>>> On Sun, Apr 21, 2019 at 03:40:00PM +0800, Shawn Guo wrote:
 On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> inside, the system controller is in charge of controlling power,
> clock and fuse etc..
>
> This patch adds i.MX system controller soc driver support, Linux
> kernel has to communicate with system controller via MU (message
> unit) IPC to get soc revision, uid etc..
>
> With this patch, soc info can be read from sysfs:
>
>   drivers/soc/imx/Kconfig  |   7 ++
>   drivers/soc/imx/Makefile |   1 +
>   drivers/soc/imx/soc-imx-sc.c | 220
> +++
>   3 files changed, 228 insertions(+)  create mode 100644
> drivers/soc/imx/soc-imx-sc.c

 Rather than creating a new driver, please take a look at Abel's
 generic
 i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.
>>
>> Got it, I didn't notice that this patch bas been accepted, I will redo the 
>> patch
>> based on it, thanks.
> 
> I have sent the new patch set to support i.MX8QXP SoC revision based on 
> generic i.MX8
> SoC driver, however, the Kconfig modification is NOT good, it may break 
> i.MX8MQ if IMX_SCU
> is NOT enabled, although we can add some warp function for SCU firmware API 
> call to fix it,
> but after further thought and discussion with Dong Aisheng, I think we may 
> need to roll back to
> use this patch series to create a new SoC driver dedicated for i.MX8 SoCs
> with system controller inside, such as i.MX8QXP, i.MX8QM etc., the reason are 
> as below:
> 
> For i.MX8MQ/i.MX8MM:
>   1. SoC driver does NOT depends on i.MX SCU firmware, so no need to use 
> platform driver
>probe model, just device_init phase call is good enough;
>   2. The SoC driver no need to depends on IMX_SCU, so it can be always 
> built in, no need to
>check IMX_SCU config;
>   3. The fuse check for CPU speed grading, HDCP status, NoC settings etc. 
> could be added to this driver,
>   but they are ONLY for i.MX8MQ/i.MX8MM etc..
> For i.MX8QXP/i.MX8QM:
>   1. SoC driver MUST depends on IMX_SCU;
>   2. MUST use platform model to support defer probe;
>   3. No fuse check for CPU speed grading.
> 
> So, I guess the reused code for i.MX8MQ and i.MX8QXP is ONLY those part of 
> creating SoC id device node (less than
> 30% I think), all other functions are implemented in total different ways, 
> that is why I created the imx_sc_soc driver
> in this patch series, so do you think we can add new SoC driver for i.MX8 SoC 
> with SCU inside? Putting 2 different architecture
> SoCs' driver into 1 file looks like NOT making enough sense.

+1 for separate SOC driver. The 8mq/8mm and 8qm/8qxp families are very 
different, they just happen to share the imx8 prefix.

It makes sense to allow people to compile one without the other and this 
is easier with distinct SOC drivers.

--
Regards,
Leonard


RE: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-04-22 Thread Anson Huang
Hi, Shawn

Best Regards!
Anson Huang

> -Original Message-
> From: Anson Huang
> Sent: Monday, April 22, 2019 8:52 AM
> To: Shawn Guo 
> Cc: stefan.wah...@i2se.com; enric.balle...@collabora.com; linux-
> ker...@vger.kernel.org; he...@sntech.de; marc.w.gonza...@free.fr;
> ezequ...@collabora.com; catalin.mari...@arm.com;
> s.ha...@pengutronix.de; will.dea...@arm.com; Abel Vesa
> ; bjorn.anders...@linaro.org; Andy Gross
> ; ja...@amarulasolutions.com;
> ker...@pengutronix.de; dl-linux-imx ; o...@lixom.net;
> horms+rene...@verge.net.au; feste...@gmail.com; r...@kernel.org;
> linux-arm-ker...@lists.infradead.org; l.st...@pengutronix.de
> Subject: RE: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver
> support
> 
> Hi, Shawn
> 
> Best Regards!
> Anson Huang
> 
> > -Original Message-
> > From: Shawn Guo [mailto:shawn...@kernel.org]
> > Sent: Sunday, April 21, 2019 3:42 PM
> > To: Anson Huang 
> > Cc: stefan.wah...@i2se.com; enric.balle...@collabora.com; linux-
> > ker...@vger.kernel.org; he...@sntech.de; marc.w.gonza...@free.fr;
> > ezequ...@collabora.com; catalin.mari...@arm.com;
> > s.ha...@pengutronix.de; will.dea...@arm.com; Abel Vesa
> > ; bjorn.anders...@linaro.org; Andy Gross
> > ; ja...@amarulasolutions.com;
> > ker...@pengutronix.de; dl-linux-imx ;
> > o...@lixom.net;
> > horms+rene...@verge.net.au; feste...@gmail.com; r...@kernel.org;
> > linux-arm-ker...@lists.infradead.org; l.st...@pengutronix.de
> > Subject: Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc
> > driver support
> >
> > On Sun, Apr 21, 2019 at 03:40:00PM +0800, Shawn Guo wrote:
> > > On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> > > > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> > > > inside, the system controller is in charge of controlling power,
> > > > clock and fuse etc..
> > > >
> > > > This patch adds i.MX system controller soc driver support, Linux
> > > > kernel has to communicate with system controller via MU (message
> > > > unit) IPC to get soc revision, uid etc..
> > > >
> > > > With this patch, soc info can be read from sysfs:
> > > >
> > > > i.mx8qxp-mek# cat /sys/devices/soc0/family Freescale i.MX
> > > >
> > > > i.mx8qxp-mek# cat /sys/devices/soc0/soc_id i.MX8QXP
> > > >
> > > > i.mx8qxp-mek# cat /sys/devices/soc0/machine Freescale i.MX8QXP
> MEK
> > > >
> > > > i.mx8qxp-mek# cat /sys/devices/soc0/revision
> > > > 1.1
> > > >
> > > > i.mx8qxp-mek# cat /sys/devices/soc0/soc_uid
> > > > 7B64280B57AC1898
> > > >
> > > > Signed-off-by: Anson Huang 
> > > > ---
> > > >  drivers/soc/imx/Kconfig  |   7 ++
> > > >  drivers/soc/imx/Makefile |   1 +
> > > >  drivers/soc/imx/soc-imx-sc.c | 220
> > > > +++
> > > >  3 files changed, 228 insertions(+)  create mode 100644
> > > > drivers/soc/imx/soc-imx-sc.c
> > >
> > > Rather than creating a new driver, please take a look at Abel's
> > > generic
> > > i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.
> >
> > Forgot to give pointer to Abel's driver.
> >
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.
> > ker
> nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fshawnguo%2Flinux.git%
> >
> 2Fcommit%2F%3Fh%3Dimx%2Fdrivers%26id%3Da7e26f356ca12906a164d83c
> >
> 9e9f8527ee7da022data=02%7C01%7Canson.huang%40nxp.com%7C9
> >
> e2705d7449b4c2e23ed08d6c62ce0bb%7C686ea1d3bc2b4c6fa92cd99c5c3016
> >
> 35%7C0%7C0%7C636914293400307709sdata=6ySEs%2B4SE8bvcBCkfoi
> > VBafseAYthTED9%2F5qcf25xds%3Dreserved=0
> >
> 
> Got it, I didn't notice that this patch bas been accepted, I will redo the 
> patch
> based on it, thanks.

I have sent the new patch set to support i.MX8QXP SoC revision based on generic 
i.MX8
SoC driver, however, the Kconfig modification is NOT good, it may break i.MX8MQ 
if IMX_SCU
is NOT enabled, although we can add some warp function for SCU firmware API 
call to fix it,
but after further thought and discussion with Dong Aisheng, I think we may need 
to roll back to
use this patch series to create a new SoC driver dedicated for i.MX8 SoCs
with system controller inside, such as i.MX8QXP, i.MX8QM etc., the reason are 
as below:

For i.MX8MQ/i.MX8MM:
1. SoC driver does NOT depends on i.MX SCU firmware, so no need to use 
platform driver
 pr

RE: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-04-21 Thread Anson Huang
Hi, Shawn

Best Regards!
Anson Huang

> -Original Message-
> From: Shawn Guo [mailto:shawn...@kernel.org]
> Sent: Sunday, April 21, 2019 3:42 PM
> To: Anson Huang 
> Cc: stefan.wah...@i2se.com; enric.balle...@collabora.com; linux-
> ker...@vger.kernel.org; he...@sntech.de; marc.w.gonza...@free.fr;
> ezequ...@collabora.com; catalin.mari...@arm.com;
> s.ha...@pengutronix.de; will.dea...@arm.com; Abel Vesa
> ; bjorn.anders...@linaro.org; Andy Gross
> ; ja...@amarulasolutions.com;
> ker...@pengutronix.de; dl-linux-imx ; o...@lixom.net;
> horms+rene...@verge.net.au; feste...@gmail.com; r...@kernel.org;
> linux-arm-ker...@lists.infradead.org; l.st...@pengutronix.de
> Subject: Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver
> support
> 
> On Sun, Apr 21, 2019 at 03:40:00PM +0800, Shawn Guo wrote:
> > On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> > > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> > > inside, the system controller is in charge of controlling power,
> > > clock and fuse etc..
> > >
> > > This patch adds i.MX system controller soc driver support, Linux
> > > kernel has to communicate with system controller via MU (message
> > > unit) IPC to get soc revision, uid etc..
> > >
> > > With this patch, soc info can be read from sysfs:
> > >
> > > i.mx8qxp-mek# cat /sys/devices/soc0/family Freescale i.MX
> > >
> > > i.mx8qxp-mek# cat /sys/devices/soc0/soc_id i.MX8QXP
> > >
> > > i.mx8qxp-mek# cat /sys/devices/soc0/machine Freescale i.MX8QXP MEK
> > >
> > > i.mx8qxp-mek# cat /sys/devices/soc0/revision
> > > 1.1
> > >
> > > i.mx8qxp-mek# cat /sys/devices/soc0/soc_uid
> > > 7B64280B57AC1898
> > >
> > > Signed-off-by: Anson Huang 
> > > ---
> > >  drivers/soc/imx/Kconfig  |   7 ++
> > >  drivers/soc/imx/Makefile |   1 +
> > >  drivers/soc/imx/soc-imx-sc.c | 220
> > > +++
> > >  3 files changed, 228 insertions(+)
> > >  create mode 100644 drivers/soc/imx/soc-imx-sc.c
> >
> > Rather than creating a new driver, please take a look at Abel's
> > generic
> > i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.
> 
> Forgot to give pointer to Abel's driver.
> 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ker
> nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fshawnguo%2Flinux.git%
> 2Fcommit%2F%3Fh%3Dimx%2Fdrivers%26id%3Da7e26f356ca12906a164d83c
> 9e9f8527ee7da022data=02%7C01%7Canson.huang%40nxp.com%7C9
> e2705d7449b4c2e23ed08d6c62ce0bb%7C686ea1d3bc2b4c6fa92cd99c5c3016
> 35%7C0%7C0%7C636914293400307709sdata=6ySEs%2B4SE8bvcBCkfoi
> VBafseAYthTED9%2F5qcf25xds%3Dreserved=0
> 

Got it, I didn't notice that this patch bas been accepted, I will redo the 
patch based on it,
thanks.

Anson.

> Shawn


Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-04-21 Thread Shawn Guo
On Sun, Apr 21, 2019 at 03:40:00PM +0800, Shawn Guo wrote:
> On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> > i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> > inside, the system controller is in charge of controlling power,
> > clock and fuse etc..
> > 
> > This patch adds i.MX system controller soc driver support,
> > Linux kernel has to communicate with system controller via MU
> > (message unit) IPC to get soc revision, uid etc..
> > 
> > With this patch, soc info can be read from sysfs:
> > 
> > i.mx8qxp-mek# cat /sys/devices/soc0/family
> > Freescale i.MX
> > 
> > i.mx8qxp-mek# cat /sys/devices/soc0/soc_id
> > i.MX8QXP
> > 
> > i.mx8qxp-mek# cat /sys/devices/soc0/machine
> > Freescale i.MX8QXP MEK
> > 
> > i.mx8qxp-mek# cat /sys/devices/soc0/revision
> > 1.1
> > 
> > i.mx8qxp-mek# cat /sys/devices/soc0/soc_uid
> > 7B64280B57AC1898
> > 
> > Signed-off-by: Anson Huang 
> > ---
> >  drivers/soc/imx/Kconfig  |   7 ++
> >  drivers/soc/imx/Makefile |   1 +
> >  drivers/soc/imx/soc-imx-sc.c | 220 
> > +++
> >  3 files changed, 228 insertions(+)
> >  create mode 100644 drivers/soc/imx/soc-imx-sc.c
> 
> Rather than creating a new driver, please take a look at Abel's generic
> i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.

Forgot to give pointer to Abel's driver.

https://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git/commit/?h=imx/drivers=a7e26f356ca12906a164d83c9e9f8527ee7da022

Shawn


Re: [PATCH 1/2] soc: imx-sc: add i.MX system controller soc driver support

2019-04-21 Thread Shawn Guo
On Thu, Apr 11, 2019 at 06:49:12AM +, Anson Huang wrote:
> i.MX8QXP is an ARMv8 SoC which has a Cortex-M4 system controller
> inside, the system controller is in charge of controlling power,
> clock and fuse etc..
> 
> This patch adds i.MX system controller soc driver support,
> Linux kernel has to communicate with system controller via MU
> (message unit) IPC to get soc revision, uid etc..
> 
> With this patch, soc info can be read from sysfs:
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/family
> Freescale i.MX
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/soc_id
> i.MX8QXP
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/machine
> Freescale i.MX8QXP MEK
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/revision
> 1.1
> 
> i.mx8qxp-mek# cat /sys/devices/soc0/soc_uid
> 7B64280B57AC1898
> 
> Signed-off-by: Anson Huang 
> ---
>  drivers/soc/imx/Kconfig  |   7 ++
>  drivers/soc/imx/Makefile |   1 +
>  drivers/soc/imx/soc-imx-sc.c | 220 
> +++
>  3 files changed, 228 insertions(+)
>  create mode 100644 drivers/soc/imx/soc-imx-sc.c

Rather than creating a new driver, please take a look at Abel's generic
i.MX8 SoC driver, and see if it can be extended to cover i.MX8QXP.

Shawn