// SPDX-License-Identifier: GPL-2.0-only /* * extcon_gpio.c - Single-state GPIO extcon driver based on extcon class * * Copyright (C) 2008 Google, Inc. * Author: Mike Lockwood <[email protected]> * * Modified by MyungJoo Ham <[email protected]> to support extcon * (originally switch class is supported) */ #include <linux/devm-helpers.h> #include <linux/extcon-provider.h> #include <linux/gpio/consumer.h> #include <linux/init.h> #include <linux/interrupt.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/workqueue.h> /** * struct gpio_extcon_data - A simple GPIO-controlled extcon device state container. * @edev: Extcon device. * @work: Work fired by the interrupt. * @debounce_jiffies: Number of jiffies to wait for the GPIO to stabilize, from the debounce * value. * @gpiod: GPIO descriptor for this external connector. * @extcon_id: The unique id of specific external connector. * @debounce: Debounce time for GPIO IRQ in ms. * @check_on_resume: Boolean describing whether to check the state of gpio * while resuming from sleep. */ struct gpio_extcon_data { … }; static void gpio_extcon_work(struct work_struct *work) { … } static irqreturn_t gpio_irq_handler(int irq, void *dev_id) { … } static int gpio_extcon_probe(struct platform_device *pdev) { … } #ifdef CONFIG_PM_SLEEP static int gpio_extcon_resume(struct device *dev) { … } #endif static SIMPLE_DEV_PM_OPS(gpio_extcon_pm_ops, NULL, gpio_extcon_resume); static struct platform_driver gpio_extcon_driver = …; module_platform_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;