Re: [PATCH v7 7/7] cros_ec: differentiate SCP from EC by feature bit.

Enric Balletbo Serra
2019-03-28T10:54:47Z

Hi,

Thanks for submitting this upstream. Some few comments below.

Please prepend the subsystem for the commit. I.e:

mfd: cros_ec: differentiate SCP from EC by feature bit.

Missatge de Peter Shih <pihsun@chromium.org> del dia dc., 27 de març
2019 a les 6:18:
>
> From: Pi-Hsun Shih <pihsun@chromium.org>
>
> Since a SCP and EC would both exist on a system, and use the cros_ec_dev

Could you also explain what an SCP is?

> driver, we need to differentiate between them for the userspace, or they
> would both be registered at /dev/cros_ec, causing a conflict.
>
> Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
> ---
> Changes from v6:
> - No change.
>
> Changes from v5:
> - No change.
>
> Changes from v4:
> - No change.
>
> Changes from v3:
> - No change.
>
> Changes from v2:
> - No change.
>
> Changes from v1:
> - New patch extracted from Patch 5.
> ---
> drivers/mfd/cros_ec_dev.c | 10 ++++++++++
> include/linux/mfd/cros_ec.h | 1 +
> include/linux/mfd/cros_ec_commands.h | 2 ++
> 3 files changed, 13 insertions(+)
>
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index d275deaecb12..da2f2145d31d 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -418,6 +418,16 @@ static int ec_device_probe(struct platform_device *pdev)
> device_initialize(&ec->class_dev);
> cdev_init(&ec->cdev, &fops);
>
> + /* check whether this is actually a SCP rather than an EC */

Capitalize the phrase.

> + if (cros_ec_check_features(ec, EC_FEATURE_SCP)) {
> + dev_info(dev, "SCP detected.\n");

dev_info(dev, "CrOS SCP MCU detected.\n")

To be coherent with other messages like this that are already sent upstream.

> + /*
> + * 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 8f2a8918bfa3..a971399bad82 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 fc91082d4c35..3e5da6e93b2f 100644
> --- a/include/linux/mfd/cros_ec_commands.h
> +++ b/include/linux/mfd/cros_ec_commands.h

Remove this change and base your work on top of [1]

> @@ -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.21.0.392.gf8f6787159e-goog
>
Thanks,
Enric

[1] https://lkml.org/lkml/2019/2/27/723