| From a627181d9c62796cdea494330c77d15b0a122cbd Mon Sep 17 00:00:00 2001 |
| From: Prashant Malani <pmalani@chromium.org> |
| Date: Wed, 26 Feb 2020 12:55:45 -0800 |
| Subject: [PATCH] CHROMIUM: platform/chrome: pd_update: Use usbpd notifier |
| |
| Now that the GOOG0003 device has been made a separate notifier device, |
| convert the cros-ec-pd-update driver into a platform driver agnostic of |
| ACPI/DT definitions. |
| |
| As a result, we also update the cros_ec_platform_cells to enumerate the |
| driver from the cros EC mfd. |
| |
| BUG=chromium:965213,b:150649744 |
| TEST=Build and boot on ACPI and non-ACPI platforms, and verify that |
| notification events are generated appropriately. |
| TEST=Build with CROS_USBPD_NOTIFY=n |
| |
| [rebase510(gwendal): Squash 20f8464b7b3a ("FIXUP: CHROMIUM: |
| platform/chrome: pd_update: Use usbpd notifier")] |
| |
| Signed-off-by: Prashant Malani <pmalani@chromium.org> |
| Change-Id: I36a706e326897a1878f1ab0ed19d6c80deba993f |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2075987 |
| Reviewed-by: Benson Leung <bleung@google.com> |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/2081098 |
| --- |
| drivers/mfd/cros_ec_dev.c | 1 + |
| drivers/platform/chrome/Kconfig | 1 + |
| drivers/platform/chrome/cros_ec_pd_update.c | 74 +++------------------ |
| 3 files changed, 10 insertions(+), 66 deletions(-) |
| |
| diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c |
| index 6d0cc3307a32..2bf369c0469c 100644 |
| --- a/drivers/mfd/cros_ec_dev.c |
| +++ b/drivers/mfd/cros_ec_dev.c |
| @@ -116,6 +116,7 @@ static const struct mfd_cell cros_ec_platform_cells[] = { |
| { .name = "cros-ec-pd-sysfs" }, |
| { .name = "cros-ec-sysfs", }, |
| { .name = "cros-ec-pchg", }, |
| + { .name = "cros-ec-pd-update", }, |
| }; |
| |
| static const struct mfd_cell cros_ec_lightbar_cells[] = { |
| diff --git a/drivers/platform/chrome/Kconfig b/drivers/platform/chrome/Kconfig |
| index 7e364616cf89..d283b2d6198d 100644 |
| --- a/drivers/platform/chrome/Kconfig |
| +++ b/drivers/platform/chrome/Kconfig |
| @@ -215,6 +215,7 @@ config CROS_EC_SYSFS |
| config CROS_EC_PD_UPDATE |
| tristate "ChromeOS Embedded Controller PD device update driver" |
| depends on MFD_CROS_EC_DEV |
| + depends on CROS_USBPD_NOTIFY |
| |
| help |
| If you say Y here, you get support for updating ChromeOS |
| diff --git a/drivers/platform/chrome/cros_ec_pd_update.c b/drivers/platform/chrome/cros_ec_pd_update.c |
| index ccfad472a4c8..b671df36d685 100644 |
| --- a/drivers/platform/chrome/cros_ec_pd_update.c |
| +++ b/drivers/platform/chrome/cros_ec_pd_update.c |
| @@ -16,16 +16,16 @@ |
| * related to auto-updating its firmware. |
| */ |
| |
| -#include <linux/acpi.h> |
| #include <linux/delay.h> |
| #include <linux/firmware.h> |
| #include <linux/kernel.h> |
| #include <linux/kobject.h> |
| +#include <linux/slab.h> |
| #include <linux/module.h> |
| -#include <linux/of.h> |
| #include <linux/platform_data/cros_ec_commands.h> |
| #include <linux/platform_data/cros_ec_pd_update.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> |
| |
| @@ -841,68 +841,22 @@ static int cros_ec_pd_suspend(struct device *dev) |
| static SIMPLE_DEV_PM_OPS(cros_ec_pd_pm, |
| cros_ec_pd_suspend, cros_ec_pd_resume); |
| |
| -#ifdef CONFIG_ACPI |
| -static void acpi_cros_ec_pd_notify(struct acpi_device *acpi_device, u32 event) |
| -{ |
| - cros_ec_pd_notify(&acpi_device->dev, event); |
| -} |
| - |
| -static int acpi_cros_ec_pd_add(struct acpi_device *acpi_device) |
| -{ |
| - return cros_ec_pd_add(&acpi_device->dev); |
| -} |
| - |
| -static int acpi_cros_ec_pd_remove(struct acpi_device *acpi_device) |
| -{ |
| - return cros_ec_pd_remove(&acpi_device->dev); |
| -} |
| - |
| -static const struct acpi_device_id pd_device_ids[] = { |
| - { "GOOG0003", 0 }, |
| - { } |
| -}; |
| - |
| -MODULE_DEVICE_TABLE(acpi, pd_device_ids); |
| - |
| -static struct acpi_driver acpi_cros_ec_pd_driver = { |
| - .name = "cros_ec_pd_update", |
| - .class = "cros_ec_pd_update", |
| - .ids = pd_device_ids, |
| - .ops = { |
| - .add = acpi_cros_ec_pd_add, |
| - .remove = acpi_cros_ec_pd_remove, |
| - .notify = acpi_cros_ec_pd_notify, |
| - }, |
| - .drv.pm = &cros_ec_pd_pm, |
| -}; |
| - |
| -module_acpi_driver(acpi_cros_ec_pd_driver); |
| -#else /* CONFIG_ACPI */ |
| static int _ec_pd_notify(struct notifier_block *nb, |
| - unsigned long queued_during_suspend, void *_notify) |
| + unsigned long host_event, void *_notify) |
| { |
| struct cros_ec_pd_update_data *drv_data; |
| struct device *dev; |
| - struct cros_ec_device *ec; |
| - u32 host_event; |
| |
| drv_data = container_of(nb, struct cros_ec_pd_update_data, notifier); |
| dev = drv_data->dev; |
| - ec = dev_get_drvdata(dev->parent); |
| - |
| - host_event = cros_ec_get_host_event(ec); |
| - if (host_event & EC_HOST_EVENT_MASK(EC_HOST_EVENT_PD_MCU)) { |
| - cros_ec_pd_notify(dev, host_event); |
| - return NOTIFY_OK; |
| - } else { |
| - return NOTIFY_DONE; |
| - } |
| + |
| + cros_ec_pd_notify(dev, host_event); |
| + return NOTIFY_OK; |
| } |
| |
| static int plat_cros_ec_pd_probe(struct platform_device *pdev) |
| { |
| struct device *dev = &pdev->dev; |
| - struct cros_ec_device *ec = dev_get_drvdata(dev->parent); |
| struct cros_ec_pd_update_data *drv_data = |
| (struct cros_ec_pd_update_data *)dev_get_drvdata(dev); |
| int ret; |
| @@ -914,8 +868,7 @@ static int plat_cros_ec_pd_probe(struct platform_device *pdev) |
| drv_data = (struct cros_ec_pd_update_data *)dev_get_drvdata(dev); |
| /* Get PD events from the EC */ |
| drv_data->notifier.notifier_call = _ec_pd_notify; |
| - ret = blocking_notifier_chain_register(&ec->event_notifier, |
| - &drv_data->notifier); |
| + ret = cros_usbpd_register_notify(&drv_data->notifier); |
| if (ret < 0) |
| dev_warn(dev, "failed to register notifier\n"); |
| |
| @@ -925,26 +878,17 @@ static int plat_cros_ec_pd_probe(struct platform_device *pdev) |
| static int plat_cros_ec_pd_remove(struct platform_device *pdev) |
| { |
| struct device *dev = &pdev->dev; |
| - struct cros_ec_device *ec = dev_get_drvdata(dev->parent); |
| struct cros_ec_pd_update_data *drv_data = |
| (struct cros_ec_pd_update_data *)dev_get_drvdata(dev); |
| |
| - blocking_notifier_chain_unregister(&ec->event_notifier, |
| - &drv_data->notifier); |
| + cros_usbpd_unregister_notify(&drv_data->notifier); |
| |
| return cros_ec_pd_remove(dev); |
| } |
| |
| -static const struct of_device_id cros_ec_pd_of_match[] = { |
| - { .compatible = "google,cros-ec-pd-update" }, |
| - { /* sentinel */ } |
| -}; |
| -MODULE_DEVICE_TABLE(of, cros_ec_pd_of_match); |
| - |
| static struct platform_driver cros_ec_pd_driver = { |
| .driver = { |
| .name = DRV_NAME, |
| - .of_match_table = of_match_ptr(cros_ec_pd_of_match), |
| .pm = &cros_ec_pd_pm, |
| }, |
| .remove = plat_cros_ec_pd_remove, |
| @@ -953,8 +897,6 @@ static struct platform_driver cros_ec_pd_driver = { |
| |
| module_platform_driver(cros_ec_pd_driver); |
| |
| -#endif /* CONFIG_ACPI */ |
| - |
| MODULE_LICENSE("GPL"); |
| MODULE_DESCRIPTION("ChromeOS power device FW update driver"); |
| MODULE_ALIAS("platform:" DRV_NAME); |
| -- |
| 2.17.1 |
| |