Re: [PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
Hello Olof, On 06/08/2015 10:46 PM, Olof Johansson wrote: > On Fri, Jun 05, 2015 at 11:17:30AM +0100, Lee Jones wrote: >> On Thu, 04 Jun 2015, Javier Martinez Canillas wrote: >> >> > From: Gwendal Grignou >> > >> > Chromebooks can have more than one Embedded Controller so the >> > cros_ec device id has to be incremented for each EC registered. >> > >> > 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 >> > Reviewed-by: Dmitry Torokhov >> > Signed-off-by: Javier Martinez Canillas >> > Tested-by: Heiko Stuebner >> > --- >> > >> > Changes since v5: >> > - Don't allow to change the device name from DT. Suggested by Lee Jones. >> > - Expand error messages in case of mfd_add_devices() failure. >> >Suggested by Lee Jones. >> > >> > Changes since v4: >> > - Use cros-ec-name DT property instead of devname. Suggested by Lee Jones. >> > - Pass PLATFORM_DEVID_AUTO directly to mfd_add_devices(). >> >Suggested by Lee Jones. >> > - Add Heiko Stuebner tested-by tag. >> > - Fix get_version by passing the cmd_offset to EC_CMD_GET_VERSION. >> > >> > 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 | 52 ++-- >> > drivers/mfd/cros_ec_i2c.c | 1 - >> > drivers/mfd/cros_ec_spi.c | 1 - >> > drivers/platform/chrome/cros_ec_dev.c | 130 >> > - >> > 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, 234 insertions(+), 127 deletions(-) >> >> For my own reference: >> Acked-by: Lee Jones >> >> Let me know when you have all the appropriate Acks and I'll apply the >> set. > > Whole series: > > Acked-by: Olof Johansson > > I'm OK with this going through the mfd tree, since there's nothing queued up > for chrome-platform that this would conflict with. > Thanks a lot for the acks, I'll resend a v7 with your Acked-by tags and fixing a small nit Lee pointed out on patch 6/8. > > -Olof > Best regards, Javier -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
On Fri, Jun 05, 2015 at 11:17:30AM +0100, Lee Jones wrote: > On Thu, 04 Jun 2015, Javier Martinez Canillas wrote: > > > From: Gwendal Grignou > > > > Chromebooks can have more than one Embedded Controller so the > > cros_ec device id has to be incremented for each EC registered. > > > > 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 > > Reviewed-by: Dmitry Torokhov > > Signed-off-by: Javier Martinez Canillas > > Tested-by: Heiko Stuebner > > --- > > > > Changes since v5: > > - Don't allow to change the device name from DT. Suggested by Lee Jones. > > - Expand error messages in case of mfd_add_devices() failure. > >Suggested by Lee Jones. > > > > Changes since v4: > > - Use cros-ec-name DT property instead of devname. Suggested by Lee Jones. > > - Pass PLATFORM_DEVID_AUTO directly to mfd_add_devices(). > >Suggested by Lee Jones. > > - Add Heiko Stuebner tested-by tag. > > - Fix get_version by passing the cmd_offset to EC_CMD_GET_VERSION. > > > > 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 | 52 ++-- > > drivers/mfd/cros_ec_i2c.c | 1 - > > drivers/mfd/cros_ec_spi.c | 1 - > > drivers/platform/chrome/cros_ec_dev.c | 130 > > - > > 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, 234 insertions(+), 127 deletions(-) > > For my own reference: > Acked-by: Lee Jones > > Let me know when you have all the appropriate Acks and I'll apply the > set. Whole series: Acked-by: Olof Johansson I'm OK with this going through the mfd tree, since there's nothing queued up for chrome-platform that this would conflict with. -Olof -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
Hello Lee, On 06/05/2015 12:38 PM, Lee Jones wrote: [...] >> >> -err = mfd_add_devices(dev, 0, cros_devs, >> - ARRAY_SIZE(cros_devs), >> +err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 1, >>NULL, ec_dev->irq, NULL); >> if (err) { >> -dev_err(dev, "failed to add mfd devices\n"); >> +dev_err(dev, "add Embedded Controller mfd device failed %d\n", > > Nit: As you're likely to resubmit anyway, when do do so, can you turn > this into an English sentence? > > "failed to register Embedded Controller's sub-devices" > > ... or something. > Ok, I will. Best regards, Javier -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
On Thu, 04 Jun 2015, Javier Martinez Canillas wrote: > From: Gwendal Grignou > > Chromebooks can have more than one Embedded Controller so the > cros_ec device id has to be incremented for each EC registered. > > 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 > Reviewed-by: Dmitry Torokhov > Signed-off-by: Javier Martinez Canillas > Tested-by: Heiko Stuebner > --- > > Changes since v5: > - Don't allow to change the device name from DT. Suggested by Lee Jones. > - Expand error messages in case of mfd_add_devices() failure. >Suggested by Lee Jones. > > Changes since v4: > - Use cros-ec-name DT property instead of devname. Suggested by Lee Jones. > - Pass PLATFORM_DEVID_AUTO directly to mfd_add_devices(). >Suggested by Lee Jones. > - Add Heiko Stuebner tested-by tag. > - Fix get_version by passing the cmd_offset to EC_CMD_GET_VERSION. > > 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 | 52 ++-- > drivers/mfd/cros_ec_i2c.c | 1 - > drivers/mfd/cros_ec_spi.c | 1 - > drivers/platform/chrome/cros_ec_dev.c | 130 > - > 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, 234 insertions(+), 127 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..d5919ee65059 100644 > --- a/drivers/mfd/cros_ec.c > +++ b/drivers/mfd/cros_ec.c > @@ -24,11 +24,29 @@ > #include > #include > > -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 = { > + .ec_name = CROS_EC_DEV_NAME, > + .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_EC_INDEX), > +}; > + > +struct cros_ec_platform pd_p = { > + .ec_name = CROS_EC_DEV_PD_NAME, > + .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX), > +}; > + > +struct mfd_cell ec_cell = { > + .name = "cros-ec-ctl", > + .platform_data = &ec_p, > + .pdata_size = sizeof(ec_p), > +}; > + > +struct mfd_cell ec_pd_cell = { > + .name = "cros-ec-ctl", > + .platform_data = &pd_p, > + .pdata_size = sizeof(pd_p), > }; > > int cros_ec_register(struct cros_ec_device *ec_dev) > @@ -52,14 +70,32 @@ 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), > + err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 1, > NULL, ec_dev->irq, NULL); > if (err) { > - dev_err(dev, "failed to add mfd devices\n"); > + dev_err(dev, "add Embedded Controller mfd device failed %d\n", Nit: As you're likely to resubmit anyway, when do do so, can you turn this into an English sentence? "failed to register Embedded Controller's sub-devices" ... or something. > + err); > return err; > } > > + if (ec_dev->max_passthru) { > + /* > +
Re: [PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
Hello Lee, On 06/05/2015 12:17 PM, Lee Jones wrote: > On Thu, 04 Jun 2015, Javier Martinez Canillas wrote: > >> From: Gwendal Grignou >> >> Chromebooks can have more than one Embedded Controller so the >> cros_ec device id has to be incremented for each EC registered. >> >> 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 >> Reviewed-by: Dmitry Torokhov >> Signed-off-by: Javier Martinez Canillas >> Tested-by: Heiko Stuebner >> --- >> >> Changes since v5: >> - Don't allow to change the device name from DT. Suggested by Lee Jones. >> - Expand error messages in case of mfd_add_devices() failure. >>Suggested by Lee Jones. >> >> Changes since v4: >> - Use cros-ec-name DT property instead of devname. Suggested by Lee Jones. >> - Pass PLATFORM_DEVID_AUTO directly to mfd_add_devices(). >>Suggested by Lee Jones. >> - Add Heiko Stuebner tested-by tag. >> - Fix get_version by passing the cmd_offset to EC_CMD_GET_VERSION. >> >> 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 | 52 ++-- >> drivers/mfd/cros_ec_i2c.c | 1 - >> drivers/mfd/cros_ec_spi.c | 1 - >> drivers/platform/chrome/cros_ec_dev.c | 130 >> - >> 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, 234 insertions(+), 127 deletions(-) > > For my own reference: > Acked-by: Lee Jones > > Let me know when you have all the appropriate Acks and I'll apply the > set. > I will, thanks a lot for your help and all the feedback. Best regards, Javier -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
On Thu, 04 Jun 2015, Javier Martinez Canillas wrote: > From: Gwendal Grignou > > Chromebooks can have more than one Embedded Controller so the > cros_ec device id has to be incremented for each EC registered. > > 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 > Reviewed-by: Dmitry Torokhov > Signed-off-by: Javier Martinez Canillas > Tested-by: Heiko Stuebner > --- > > Changes since v5: > - Don't allow to change the device name from DT. Suggested by Lee Jones. > - Expand error messages in case of mfd_add_devices() failure. >Suggested by Lee Jones. > > Changes since v4: > - Use cros-ec-name DT property instead of devname. Suggested by Lee Jones. > - Pass PLATFORM_DEVID_AUTO directly to mfd_add_devices(). >Suggested by Lee Jones. > - Add Heiko Stuebner tested-by tag. > - Fix get_version by passing the cmd_offset to EC_CMD_GET_VERSION. > > 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 | 52 ++-- > drivers/mfd/cros_ec_i2c.c | 1 - > drivers/mfd/cros_ec_spi.c | 1 - > drivers/platform/chrome/cros_ec_dev.c | 130 > - > 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, 234 insertions(+), 127 deletions(-) For my own reference: Acked-by: Lee Jones Let me know when you have all the appropriate Acks and I'll apply the set. > 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..d5919ee65059 100644 > --- a/drivers/mfd/cros_ec.c > +++ b/drivers/mfd/cros_ec.c > @@ -24,11 +24,29 @@ > #include > #include > > -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 = { > + .ec_name = CROS_EC_DEV_NAME, > + .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_EC_INDEX), > +}; > + > +struct cros_ec_platform pd_p = { > + .ec_name = CROS_EC_DEV_PD_NAME, > + .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX), > +}; > + > +struct mfd_cell ec_cell = { > + .name = "cros-ec-ctl", > + .platform_data = &ec_p, > + .pdata_size = sizeof(ec_p), > +}; > + > +struct mfd_cell ec_pd_cell = { > + .name = "cros-ec-ctl", > + .platform_data = &pd_p, > + .pdata_size = sizeof(pd_p), > }; > > int cros_ec_register(struct cros_ec_device *ec_dev) > @@ -52,14 +70,32 @@ 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), > + err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 1, > NULL, ec_dev->irq, NULL); > if (err) { > - dev_err(dev, "failed to add mfd devices\n"); > + dev_err(dev, "add Embedded Controller mfd device failed %d\n", > + err); > return err; > } > > + if (ec_dev->max_passthru) { > + /* > + * Register a PD device as well on top of this
[PATCH v6 6/8] mfd: cros_ec: Support multiple EC in a system
From: Gwendal Grignou Chromebooks can have more than one Embedded Controller so the cros_ec device id has to be incremented for each EC registered. 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 Reviewed-by: Dmitry Torokhov Signed-off-by: Javier Martinez Canillas Tested-by: Heiko Stuebner --- Changes since v5: - Don't allow to change the device name from DT. Suggested by Lee Jones. - Expand error messages in case of mfd_add_devices() failure. Suggested by Lee Jones. Changes since v4: - Use cros-ec-name DT property instead of devname. Suggested by Lee Jones. - Pass PLATFORM_DEVID_AUTO directly to mfd_add_devices(). Suggested by Lee Jones. - Add Heiko Stuebner tested-by tag. - Fix get_version by passing the cmd_offset to EC_CMD_GET_VERSION. 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 | 52 ++-- drivers/mfd/cros_ec_i2c.c | 1 - drivers/mfd/cros_ec_spi.c | 1 - drivers/platform/chrome/cros_ec_dev.c | 130 - 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, 234 insertions(+), 127 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..d5919ee65059 100644 --- a/drivers/mfd/cros_ec.c +++ b/drivers/mfd/cros_ec.c @@ -24,11 +24,29 @@ #include #include -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 = { + .ec_name = CROS_EC_DEV_NAME, + .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_EC_INDEX), +}; + +struct cros_ec_platform pd_p = { + .ec_name = CROS_EC_DEV_PD_NAME, + .cmd_offset = EC_CMD_PASSTHRU_OFFSET(CROS_EC_DEV_PD_INDEX), +}; + +struct mfd_cell ec_cell = { + .name = "cros-ec-ctl", + .platform_data = &ec_p, + .pdata_size = sizeof(ec_p), +}; + +struct mfd_cell ec_pd_cell = { + .name = "cros-ec-ctl", + .platform_data = &pd_p, + .pdata_size = sizeof(pd_p), }; int cros_ec_register(struct cros_ec_device *ec_dev) @@ -52,14 +70,32 @@ 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), + err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 1, NULL, ec_dev->irq, NULL); if (err) { - dev_err(dev, "failed to add mfd devices\n"); + dev_err(dev, "add Embedded Controller mfd device failed %d\n", + err); return err; } + if (ec_dev->max_passthru) { + /* +* Register a PD device as well on top of this device. +* We make the following assumptions: +* - behind an EC, we have a pd +* - only one device added. +* - the EC is responsive at init time (it is not true for a +* sensor hub. +*/ + err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, +