All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Olof Johansson <olof@lixom.net>,
	Doug Anderson <dianders@chromium.org>,
	Bill Richardson <wfrichar@chromium.org>,
	Simon Glass <sjg@google.com>,
	Gwendal Grignou <gwendal@google.com>,
	Stephen Barber <smbarber@chromium.org>,
	Filipe Brandenburger <filbranden@google.com>,
	Todd Broch <tbroch@chromium.org>,
	Alexandru M Stan <amstan@chromium.org>,
	Heiko Stuebner <heiko@sntech.de>,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Gwendal Grignou <gwendal@chromium.org>
Subject: Re: [PATCH v4 6/8] mfd: cros_ec: Support multiple EC in a system
Date: Wed, 3 Jun 2015 12:27:41 +0100	[thread overview]
Message-ID: <20150603112741.GA12304@x1> (raw)
In-Reply-To: <556ED303.6090401@collabora.co.uk>

On Wed, 03 Jun 2015, Javier Martinez Canillas wrote:

> Hello Lee,
> 
> Thanks a lot for your feedback.
> 
> On 06/03/2015 10:53 AM, Lee Jones wrote:
> > On Tue, 02 Jun 2015, Javier Martinez Canillas wrote:
> > 
> >> From: Gwendal Grignou <gwendal@chromium.org>
> >> 
> >> Chromebooks can have more than one Embedded Controller so the
> >> cros_ec device id has to be incremented for each EC registered.
> >> 
> >> Add code to handle multiple EC. First ec found is cros-ec0,
> >> second cros-ec1 and so on.
> >> 
> >> Add a new structure to represent multiple EC as different char
> >> devices (e.g: /dev/cros_ec, /dev/cros_pd). It connects to
> >> cros_ec_device and allows sysfs inferface for cros_pd.
> >> 
> >> Also reduce number of allocated objects, make chromeos sysfs
> >> class object a static and add refcounting to prevent object
> >> deletion while command is in progress.
> >> 
> >> Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
> >> Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
> >> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> >> ---
> >> 
> >> Changes since v3:
> >>  - Add defines for the EC and PD index constants.
> >>  - Remove cros_ec_dev_register() and declare the mfd_cells as static structs.
> >>    Suggested by Lee Jones.
> >>  - Add a new line before the return statement in cros_ec_dev_register().
> >>    Suggested by Lee Jones.
> >> 
> >> Changes since v2: None
> >> 
> >> Changes since v1:
> >>   - Squash patch that adds support to represent EC's as different
> >>     char devices (e.g: /dev/cros_ec, /dev/cros_pd):
> >>     https://chromium-review.googlesource.com/#/c/217297/
> >>     Suggested by Gwendal Grignou
> >>   - Use cros_ec instead of cros-ec in the subject line to be consistent.
> >>     Suggested by Gwendal Grignou
> >> ---
> >>  drivers/input/keyboard/cros_ec_keyb.c      |   2 +-
> >>  drivers/mfd/cros_ec.c                      |  59 +++++++++++--
> >>  drivers/mfd/cros_ec_i2c.c                  |   1 -
> >>  drivers/mfd/cros_ec_spi.c                  |   1 -
> >>  drivers/platform/chrome/cros_ec_dev.c      | 128 ++++++++++++++++++++---------
> >>  drivers/platform/chrome/cros_ec_dev.h      |   7 --
> >>  drivers/platform/chrome/cros_ec_lightbar.c |  75 +++++++++--------
> >>  drivers/platform/chrome/cros_ec_lpc.c      |   1 -
> >>  drivers/platform/chrome/cros_ec_sysfs.c    |  48 +++++------
> >>  include/linux/mfd/cros_ec.h                |  44 ++++++++--
> >>  10 files changed, 240 insertions(+), 126 deletions(-)
> >> 
> >> diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
> >> index 974154a74505..b01966dc7eb3 100644
> >> --- a/drivers/input/keyboard/cros_ec_keyb.c
> >> +++ b/drivers/input/keyboard/cros_ec_keyb.c
> >> @@ -275,7 +275,7 @@ static int cros_ec_keyb_probe(struct platform_device *pdev)
> >>  	ckdev->dev = dev;
> >>  	dev_set_drvdata(&pdev->dev, ckdev);
> >>  
> >> -	idev->name = ec->ec_name;
> >> +	idev->name = CROS_EC_DEV_NAME;
> >>  	idev->phys = ec->phys_name;
> >>  	__set_bit(EV_REP, idev->evbit);
> >>  
> >> diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
> >> index 08d82bfc5268..4fbb4ce8f81e 100644
> >> --- a/drivers/mfd/cros_ec.c
> >> +++ b/drivers/mfd/cros_ec.c
> >> @@ -24,11 +24,29 @@
> >>  #include <linux/mfd/core.h>
> >>  #include <linux/mfd/cros_ec.h>
> >>  
> >> -static const struct mfd_cell cros_devs[] = {
> >> -	{
> >> -		.name = "cros-ec-ctl",
> >> -		.id = PLATFORM_DEVID_AUTO,
> >> -	},
> >> +#define CROS_EC_DEV_EC_INDEX 0
> >> +#define CROS_EC_DEV_PD_INDEX 1
> >> +
> >> +struct cros_ec_platform ec_p = {
> >> +	.cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_EC_INDEX),
> >> +};
> >> +
> >> +struct cros_ec_platform pd_p = {
> >> +	.cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX),
> >> +};
> >> +
> >> +struct mfd_cell ec_cell = {
> >> +	.name = "cros-ec-ctl",
> >> +	.id = PLATFORM_DEVID_AUTO,
> >> +	.platform_data = &ec_p,
> >> +	.pdata_size = sizeof(ec_p),
> >> +};
> >> +
> >> +struct mfd_cell ec_pd_cell = {
> >> +	.name = "cros-ec-ctl",
> >> +	.id = PLATFORM_DEVID_AUTO,
> >> +	.platform_data = &pd_p,
> >> +	.pdata_size = sizeof(pd_p),
> >>  };
> >>  
> >>  int cros_ec_register(struct cros_ec_device *ec_dev)
> >> @@ -52,14 +70,39 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
> >>  
> >>  	cros_ec_query_all(ec_dev);
> >>  
> >> -	err = mfd_add_devices(dev, 0, cros_devs,
> >> -			      ARRAY_SIZE(cros_devs),
> >> +	if (IS_ENABLED(CONFIG_OF) && dev->of_node)
> >> +		ec_p.ec_name = of_get_property(dev->of_node, "devname",
> >> +					       NULL);
> > 
> > Has this binding already been accepted?  We don't normally allow
> > "device name"properties in DT.
> > 
> 
> Sigh, I now noticed that I missed the DT binding change when originally
> forward porting the patches from the downstream ChromiumOS tree. I'm so
> sorry about that.
> 
> ChromiumOS tree has in Documentation/devicetree/bindings/mfd/cros-ec.txt:
> 
> Optional properties (All):
> - devname: name of the EC. Can be based on its function: for instance,
>   for Sensor Hub, 'cros_sh', for Power Delivery MCU 'cros_pd'.
>   If not present, 'cros_ec' can be assumed.
> 
> When you say that normally device names are not allowed in DT, do you mean
> that "devname" is a too generic property name? (which I totally agree) or
> that DT bindings shouldn't have a property to change a device's name for
> something more descriptive?
> 
> Because for example, the regulator bindings has a "regulator-name" property.
> If you agree I can change the property to "google,cros-ec-name" which should
> be more precise.

I mean, no names of devices are allowed in Device Tree:

  `git grep name -- arch/arm/boot/dts/ | grep dev`

> >> +	if (!ec_p.ec_name)
> >> +		ec_p.ec_name = CROS_EC_DEV_NAME;
> >> +
> >> +	err = mfd_add_devices(ec_dev->dev, CROS_EC_DEV_EC_INDEX, &ec_cell, 1,
> >>  			      NULL, ec_dev->irq, NULL);
> > 
> > Take a look at how 'id' (second argument) is handled in mfd-core, then
> > try to figure out why what you're doing is not correct.
> >
> 
> I see, so I should not set the struct mfd_cell .id to PLATFORM_DEVID_AUTO and
> just pass PLATFORM_DEVID_AUTO to mfd_add_devices() so platform_device_add()
> automatically allocates a device ID and sets pdev->id_auto = true.
> 
> It was only working because CROS_EC_DEV_EC_INDEX was zero so id + cell->id
> was still PLATFORM_DEVID_AUTO but for CROS_EC_DEV_PD_INDEX, it was set to
> PLATFORM_DEVID_NONE...
> 
> I'll change that, thanks for pointing it out.

No problem

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2015-06-03 11:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02  8:11 [PATCH v4 0/8] mfd: cros_ec: Add multi EC and proto v3 support Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 1/8] mfd: cros_ec: Use a zero-length array for command data Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 2/8] mfd: cros_ec: rev cros_ec_commands.h Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 3/8] mfd: cros_ec: Move protocol helpers out of the MFD driver Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 4/8] mfd: cros_ec: add proto v3 skeleton Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 5/8] mfd: cros_ec: add bus-specific proto v3 code Javier Martinez Canillas
2015-06-02  8:11   ` Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 6/8] mfd: cros_ec: Support multiple EC in a system Javier Martinez Canillas
2015-06-02  8:11   ` Javier Martinez Canillas
2015-06-03  8:53   ` Lee Jones
2015-06-03 10:12     ` Javier Martinez Canillas
2015-06-03 11:27       ` Lee Jones [this message]
2015-06-03 11:49         ` Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 7/8] mfd: cros_ec: spi: Add a DT property to delay asserting the CS Javier Martinez Canillas
2015-06-02  8:11   ` Javier Martinez Canillas
2015-06-02  8:11 ` [PATCH v4 8/8] mfd: cros_ec: spi: Add delay for asserting CS Javier Martinez Canillas
2015-06-02 21:15 ` [PATCH v4 0/8] mfd: cros_ec: Add multi EC and proto v3 support Heiko Stübner
2015-06-03  6:45   ` Javier Martinez Canillas
2015-06-03  6:45     ` Javier Martinez Canillas

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=20150603112741.GA12304@x1 \
    --to=lee.jones@linaro.org \
    --cc=amstan@chromium.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=filbranden@google.com \
    --cc=gwendal@chromium.org \
    --cc=gwendal@google.com \
    --cc=heiko@sntech.de \
    --cc=javier.martinez@collabora.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=sameo@linux.intel.com \
    --cc=sjg@google.com \
    --cc=smbarber@chromium.org \
    --cc=tbroch@chromium.org \
    --cc=wfrichar@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.