From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>,
Prashant Malani <pmalani@chromium.org>
Cc: groeck@chromium.org, bleung@chromium.org, lee.jones@linaro.org,
linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
Jon Flatley <jflat@chromium.org>
Subject: Re: [PATCH v7 3/3] power: supply: cros-ec-usbpd-charger: Fix host events
Date: Fri, 17 Jan 2020 17:36:48 +0100 [thread overview]
Message-ID: <cc46a6a3-706e-06df-882f-10e66cf89735@collabora.com> (raw)
In-Reply-To: <20200117011216.p7etrc6oarptmhcb@earth.universe>
Hi Sebastian,
On 17/1/20 2:12, Sebastian Reichel wrote:
> Hi,
>
> On Thu, Jan 16, 2020 at 04:28:24PM -0800, Prashant Malani wrote:
>> From: Jon Flatley <jflat@chromium.org>
>>
>> There's a bug on ACPI platforms where host events from the ECPD ACPI
>> device never make their way to the cros-ec-usbpd-charger driver. This
>> makes it so the only time the charger driver updates its state is when
>> user space accesses its sysfs attributes.
>>
>> Now that these events have been unified into a single notifier chain on
>> both ACPI and non-ACPI platforms, update the charger driver to use this
>> new notifier.
>>
>> Reviewed-by: Benson Leung <bleung@chromium.org>
>> Co-Developed-by: Prashant Malani <pmalani@chromium.org>
>> Signed-off-by: Jon Flatley <jflat@chromium.org>
>> Signed-off-by: Prashant Malani <pmalani@chromium.org>
>> ---
>
> Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>
>
> I currently have one cros_usbpd-charger patch queued in -next.
> This patch looks like it should not create conflicts, but it's
> probably better to merge an immutable branch.
>
I still have some concerns on the platform/chrome side and I have some problems
with this driver testing it on Samsung Chromebook Plus (kevin). So it is not
ready yet to merge, I'll create an im when ready.
Thanks,
Enric
> -- Sebastian
>
>>
>> Changes in v7(pmalani@chromium.org):
>> - Alphabetize #include header.
>>
>> Changes in v6(pmalani@chromium.org):
>> - Patch first introduced into the series in v6.
>>
>> drivers/power/supply/Kconfig | 2 +-
>> drivers/power/supply/cros_usbpd-charger.c | 50 ++++++++---------------
>> 2 files changed, 19 insertions(+), 33 deletions(-)
>>
>> diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
>> index 27164a1d3c7c4..ba74ddd793c3d 100644
>> --- a/drivers/power/supply/Kconfig
>> +++ b/drivers/power/supply/Kconfig
>> @@ -659,7 +659,7 @@ config CHARGER_RT9455
>>
>> config CHARGER_CROS_USBPD
>> tristate "ChromeOS EC based USBPD charger"
>> - depends on CROS_EC
>> + depends on CROS_USBPD_NOTIFY
>> default n
>> help
>> Say Y here to enable ChromeOS EC based USBPD charger
>> diff --git a/drivers/power/supply/cros_usbpd-charger.c b/drivers/power/supply/cros_usbpd-charger.c
>> index 6cc7c3910e098..7eea080048f43 100644
>> --- a/drivers/power/supply/cros_usbpd-charger.c
>> +++ b/drivers/power/supply/cros_usbpd-charger.c
>> @@ -9,6 +9,7 @@
>> #include <linux/module.h>
>> #include <linux/platform_data/cros_ec_commands.h>
>> #include <linux/platform_data/cros_ec_proto.h>
>> +#include <linux/platform_data/cros_usbpd_notify.h>
>> #include <linux/platform_device.h>
>> #include <linux/power_supply.h>
>> #include <linux/slab.h>
>> @@ -524,32 +525,21 @@ static int cros_usbpd_charger_property_is_writeable(struct power_supply *psy,
>> }
>>
>> static int cros_usbpd_charger_ec_event(struct notifier_block *nb,
>> - unsigned long queued_during_suspend,
>> + unsigned long host_event,
>> void *_notify)
>> {
>> - struct cros_ec_device *ec_device;
>> - struct charger_data *charger;
>> - u32 host_event;
>> + struct charger_data *charger = container_of(nb, struct charger_data,
>> + notifier);
>>
>> - charger = container_of(nb, struct charger_data, notifier);
>> - ec_device = charger->ec_device;
>> -
>> - host_event = cros_ec_get_host_event(ec_device);
>> - if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) {
>> - cros_usbpd_charger_power_changed(charger->ports[0]->psy);
>> - return NOTIFY_OK;
>> - } else {
>> - return NOTIFY_DONE;
>> - }
>> + cros_usbpd_charger_power_changed(charger->ports[0]->psy);
>> + return NOTIFY_OK;
>> }
>>
>> static void cros_usbpd_charger_unregister_notifier(void *data)
>> {
>> struct charger_data *charger = data;
>> - struct cros_ec_device *ec_device = charger->ec_device;
>>
>> - blocking_notifier_chain_unregister(&ec_device->event_notifier,
>> - &charger->notifier);
>> + cros_usbpd_unregister_notify(&charger->notifier);
>> }
>>
>> static int cros_usbpd_charger_probe(struct platform_device *pd)
>> @@ -683,21 +673,17 @@ static int cros_usbpd_charger_probe(struct platform_device *pd)
>> goto fail;
>> }
>>
>> - if (ec_device->mkbp_event_supported) {
>> - /* Get PD events from the EC */
>> - charger->notifier.notifier_call = cros_usbpd_charger_ec_event;
>> - ret = blocking_notifier_chain_register(
>> - &ec_device->event_notifier,
>> - &charger->notifier);
>> - if (ret < 0) {
>> - dev_warn(dev, "failed to register notifier\n");
>> - } else {
>> - ret = devm_add_action_or_reset(dev,
>> - cros_usbpd_charger_unregister_notifier,
>> - charger);
>> - if (ret < 0)
>> - goto fail;
>> - }
>> + /* Get PD events from the EC */
>> + charger->notifier.notifier_call = cros_usbpd_charger_ec_event;
>> + ret = cros_usbpd_register_notify(&charger->notifier);
>> + if (ret < 0) {
>> + dev_warn(dev, "failed to register notifier\n");
>> + } else {
>> + ret = devm_add_action_or_reset(dev,
>> + cros_usbpd_charger_unregister_notifier,
>> + charger);
>> + if (ret < 0)
>> + goto fail;
>> }
>>
>> return 0;
>> --
>> 2.25.0.341.g760bfbb309-goog
>>
next prev parent reply other threads:[~2020-01-17 16:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-17 0:28 [PATCH v7 1/3] platform: chrome: Add cros-usbpd-notify driver Prashant Malani
2020-01-17 0:28 ` [PATCH v7 2/3] mfd: cros_ec: Add cros-usbpd-notify subdevice Prashant Malani
2020-01-17 11:35 ` Lee Jones
2020-01-17 0:28 ` [PATCH v7 3/3] power: supply: cros-ec-usbpd-charger: Fix host events Prashant Malani
2020-01-17 1:12 ` Sebastian Reichel
2020-01-17 16:36 ` Enric Balletbo i Serra [this message]
2020-01-21 12:10 ` [PATCH v7 1/3] platform: chrome: Add cros-usbpd-notify driver Enric Balletbo i Serra
2020-01-21 21:17 ` Prashant Malani
2020-01-24 19:35 ` Enric Balletbo i Serra
2020-01-24 21:52 ` Prashant Malani
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=cc46a6a3-706e-06df-882f-10e66cf89735@collabora.com \
--to=enric.balletbo@collabora.com \
--cc=bleung@chromium.org \
--cc=groeck@chromium.org \
--cc=jflat@chromium.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pmalani@chromium.org \
--cc=sebastian.reichel@collabora.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox