2019-01-21 07:21:41

by Pi-Hsun Shih

[permalink] [raw]
Subject: [RFC v3 5/5] cros_ec: differentiate SCP from EC by feature bit.

Since a SCP and EC would both exist on a system, and use the cros_ec_dev
driver, we need to differentiate between them for the userspace, or they
would both be registered at /dev/cros_ec, causing a conflict.

Cc: Enric Balletbo Serra <[email protected]>
Cc: Guenter Roeck <[email protected]>
Signed-off-by: Pi-Hsun Shih <[email protected]>
---
Changes from v2:
- No change.

Changes from v1:
- New patch extracted from Patch 5.
---
drivers/mfd/cros_ec_dev.c | 9 +++++++++
include/linux/mfd/cros_ec.h | 1 +
include/linux/mfd/cros_ec_commands.h | 2 ++
3 files changed, 12 insertions(+)

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 2d0fee488c5aa8..67983853413d07 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -414,6 +414,15 @@ static int ec_device_probe(struct platform_device *pdev)
device_initialize(&ec->class_dev);
cdev_init(&ec->cdev, &fops);

+ if (cros_ec_check_features(ec, EC_FEATURE_SCP)) {
+ dev_info(dev, "SCP detected.\n");
+ /*
+ * Help userspace differentiating ECs from SCP,
+ * regardless of the probing order.
+ */
+ ec_platform->ec_name = CROS_EC_DEV_SCP_NAME;
+ }
+
/*
* Add the class device
* Link to the character device for creating the /dev entry
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index de8b588c8776da..fd297cf8f97295 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -24,6 +24,7 @@

#define CROS_EC_DEV_NAME "cros_ec"
#define CROS_EC_DEV_PD_NAME "cros_pd"
+#define CROS_EC_DEV_SCP_NAME "cros_scp"

/*
* The EC is unresponsive for a time after a reboot command. Add a
diff --git a/include/linux/mfd/cros_ec_commands.h b/include/linux/mfd/cros_ec_commands.h
index fc91082d4c357b..3e5da6e93b2f42 100644
--- a/include/linux/mfd/cros_ec_commands.h
+++ b/include/linux/mfd/cros_ec_commands.h
@@ -856,6 +856,8 @@ enum ec_feature_code {
EC_FEATURE_RTC = 27,
/* EC supports CEC commands */
EC_FEATURE_CEC = 35,
+ /* The MCU exposes a SCP */
+ EC_FEATURE_SCP = 39,
};

#define EC_FEATURE_MASK_0(event_code) (1UL << (event_code % 32))
--
2.20.1.321.g9e740568ce-goog



2019-01-30 13:09:21

by Lee Jones

[permalink] [raw]
Subject: Re: [RFC v3 5/5] cros_ec: differentiate SCP from EC by feature bit.

On Mon, 21 Jan 2019, Pi-Hsun Shih wrote:

> Since a SCP and EC would both exist on a system, and use the cros_ec_dev
> driver, we need to differentiate between them for the userspace, or they
> would both be registered at /dev/cros_ec, causing a conflict.
>
> Cc: Enric Balletbo Serra <[email protected]>
> Cc: Guenter Roeck <[email protected]>
> Signed-off-by: Pi-Hsun Shih <[email protected]>
> ---
> Changes from v2:
> - No change.
>
> Changes from v1:
> - New patch extracted from Patch 5.
> ---
> drivers/mfd/cros_ec_dev.c | 9 +++++++++
> include/linux/mfd/cros_ec.h | 1 +
> include/linux/mfd/cros_ec_commands.h | 2 ++
> 3 files changed, 12 insertions(+)

Just to clarify to the new Cc'ed list, I'm waiting on one of the
Chromium guys to review before I put my mucky paws over it.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-01-30 15:08:22

by Enric Balletbo Serra

[permalink] [raw]
Subject: Re: [RFC v3 5/5] cros_ec: differentiate SCP from EC by feature bit.

Hi Lee, Pi-Hsun,

Missatge de Lee Jones <[email protected]> del dia dc., 30 de gen.
2019 a les 14:07:
>
> On Mon, 21 Jan 2019, Pi-Hsun Shih wrote:
>
> > Since a SCP and EC would both exist on a system, and use the cros_ec_dev
> > driver, we need to differentiate between them for the userspace, or they
> > would both be registered at /dev/cros_ec, causing a conflict.
> >
> > Cc: Enric Balletbo Serra <[email protected]>
> > Cc: Guenter Roeck <[email protected]>
> > Signed-off-by: Pi-Hsun Shih <[email protected]>
> > ---
> > Changes from v2:
> > - No change.
> >
> > Changes from v1:
> > - New patch extracted from Patch 5.
> > ---
> > drivers/mfd/cros_ec_dev.c | 9 +++++++++
> > include/linux/mfd/cros_ec.h | 1 +
> > include/linux/mfd/cros_ec_commands.h | 2 ++
> > 3 files changed, 12 insertions(+)
>
> Just to clarify to the new Cc'ed list, I'm waiting on one of the
> Chromium guys to review before I put my mucky paws over it.
>

Pi-Hsun, is this patchset still an RFC or you really want to see this
merged ASAP? If I am not mistaken there is still some work in progress
trying to push all the SCP stuff?

Lee, personally I have some concerns. Looks like the cros_* family is
increasing quickly lately (cros_ec, cros_pd, cros_scp, cros_ish,
cros_fp ...) and I am wondering if we are really doing well all this.
To be honest, I'd like to take a deeper look before merge this, btw I
thought there was no hurry because of the RFC and I guess there are
still some scp things that are missing. I might be wrong, and if
that's not the case I can take a look deeper and the end of the week.

Best regards,
Enric


> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

2019-01-31 06:13:12

by Pi-Hsun Shih

[permalink] [raw]
Subject: Re: [RFC v3 5/5] cros_ec: differentiate SCP from EC by feature bit.

Hi Enric,

On Wed, Jan 30, 2019 at 11:06 PM Enric Balletbo Serra
<[email protected]> wrote:
>
> Hi Lee, Pi-Hsun,
>
> Missatge de Lee Jones <[email protected]> del dia dc., 30 de gen.
> 2019 a les 14:07:
> >
> > On Mon, 21 Jan 2019, Pi-Hsun Shih wrote:
> >
> > > Since a SCP and EC would both exist on a system, and use the cros_ec_dev
> > > driver, we need to differentiate between them for the userspace, or they
> > > would both be registered at /dev/cros_ec, causing a conflict.
> > >
> > > Cc: Enric Balletbo Serra <[email protected]>
> > > Cc: Guenter Roeck <[email protected]>
> > > Signed-off-by: Pi-Hsun Shih <[email protected]>
> > > ---
> > > Changes from v2:
> > > - No change.
> > >
> > > Changes from v1:
> > > - New patch extracted from Patch 5.
> > > ---
> > > drivers/mfd/cros_ec_dev.c | 9 +++++++++
> > > include/linux/mfd/cros_ec.h | 1 +
> > > include/linux/mfd/cros_ec_commands.h | 2 ++
> > > 3 files changed, 12 insertions(+)
> >
> > Just to clarify to the new Cc'ed list, I'm waiting on one of the
> > Chromium guys to review before I put my mucky paws over it.
> >
>
> Pi-Hsun, is this patchset still an RFC or you really want to see this
> merged ASAP? If I am not mistaken there is still some work in progress
> trying to push all the SCP stuff?
>
> Lee, personally I have some concerns. Looks like the cros_* family is
> increasing quickly lately (cros_ec, cros_pd, cros_scp, cros_ish,
> cros_fp ...) and I am wondering if we are really doing well all this.
> To be honest, I'd like to take a deeper look before merge this, btw I
> thought there was no hurry because of the RFC and I guess there are
> still some scp things that are missing. I might be wrong, and if
> that's not the case I can take a look deeper and the end of the week.
>
> Best regards,
> Enric

I don't think we need this to be merged ASAP.

I feel that most of the todos are done though, so I'll drop the RFC
tag and resend a v4 (which also contains some bug fixes found when
testing).

>
>
> > --
> > Lee Jones [李琼斯]
> > Linaro Services Technical Lead
> > Linaro.org │ Open source software for ARM SoCs
> > Follow Linaro: Facebook | Twitter | Blog