// SPDX-License-Identifier: GPL-2.0-only /* * ChromeOS EC multi-function device * * Copyright (C) 2012 Google, Inc * * The ChromeOS EC multi function device is used to mux all the requests * to the EC device for its multiple features: keyboard controller, * battery charging and regulator control, firmware update. */ #include <linux/interrupt.h> #include <linux/module.h> #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/platform_data/cros_ec_commands.h> #include <linux/platform_data/cros_ec_proto.h> #include <linux/slab.h> #include <linux/suspend.h> #include "cros_ec.h" static struct cros_ec_platform ec_p = …; static struct cros_ec_platform pd_p = …; /** * cros_ec_irq_handler() - top half part of the interrupt handler * @irq: IRQ id * @data: (ec_dev) Device with events to process. * * Return: Wakeup the bottom half */ static irqreturn_t cros_ec_irq_handler(int irq, void *data) { … } /** * cros_ec_handle_event() - process and forward pending events on EC * @ec_dev: Device with events to process. * * Call this function in a loop when the kernel is notified that the EC has * pending events. * * Return: true if more events are still pending and this function should be * called again. */ static bool cros_ec_handle_event(struct cros_ec_device *ec_dev) { … } /** * cros_ec_irq_thread() - bottom half part of the interrupt handler * @irq: IRQ id * @data: (ec_dev) Device with events to process. * * Return: Interrupt handled. */ irqreturn_t cros_ec_irq_thread(int irq, void *data) { … } EXPORT_SYMBOL(…); static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) { … } static int cros_ec_ready_event(struct notifier_block *nb, unsigned long queued_during_suspend, void *_notify) { … } /** * cros_ec_register() - Register a new ChromeOS EC, using the provided info. * @ec_dev: Device to register. * * Before calling this, allocate a pointer to a new device and then fill * in all the fields up to the --private-- marker. * * Return: 0 on success or negative error code. */ int cros_ec_register(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); /** * cros_ec_unregister() - Remove a ChromeOS EC. * @ec_dev: Device to unregister. * * Call this to deregister a ChromeOS EC, then clean up any private data. * * Return: 0 on success or negative error code. */ void cros_ec_unregister(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); #ifdef CONFIG_PM_SLEEP static void cros_ec_send_suspend_event(struct cros_ec_device *ec_dev) { … } /** * cros_ec_suspend_prepare() - Handle a suspend prepare operation for the ChromeOS EC device. * @ec_dev: Device to suspend. * * This can be called by drivers to handle a suspend prepare stage of suspend. * * Return: 0 always. */ int cros_ec_suspend_prepare(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); static void cros_ec_disable_irq(struct cros_ec_device *ec_dev) { … } /** * cros_ec_suspend_late() - Handle a suspend late operation for the ChromeOS EC device. * @ec_dev: Device to suspend. * * This can be called by drivers to handle a suspend late stage of suspend. * * Return: 0 always. */ int cros_ec_suspend_late(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); /** * cros_ec_suspend() - Handle a suspend operation for the ChromeOS EC device. * @ec_dev: Device to suspend. * * This can be called by drivers to handle a suspend event. * * Return: 0 always. */ int cros_ec_suspend(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); static void cros_ec_report_events_during_suspend(struct cros_ec_device *ec_dev) { … } static void cros_ec_send_resume_event(struct cros_ec_device *ec_dev) { … } /** * cros_ec_resume_complete() - Handle a resume complete operation for the ChromeOS EC device. * @ec_dev: Device to resume. * * This can be called by drivers to handle a resume complete stage of resume. */ void cros_ec_resume_complete(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); static void cros_ec_enable_irq(struct cros_ec_device *ec_dev) { … } /** * cros_ec_resume_early() - Handle a resume early operation for the ChromeOS EC device. * @ec_dev: Device to resume. * * This can be called by drivers to handle a resume early stage of resume. * * Return: 0 always. */ int cros_ec_resume_early(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); /** * cros_ec_resume() - Handle a resume operation for the ChromeOS EC device. * @ec_dev: Device to resume. * * This can be called by drivers to handle a resume event. * * Return: 0 always. */ int cros_ec_resume(struct cros_ec_device *ec_dev) { … } EXPORT_SYMBOL(…); #endif MODULE_LICENSE(…) …; MODULE_DESCRIPTION(…) …;