linux/drivers/platform/x86/intel/int0002_vgpio.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Intel INT0002 "Virtual GPIO" driver
 *
 * Copyright (C) 2017 Hans de Goede <[email protected]>
 *
 * Loosely based on android x86 kernel code which is:
 *
 * Copyright (c) 2014, Intel Corporation.
 *
 * Author: Dyut Kumar Sil <[email protected]>
 *
 * Some peripherals on Bay Trail and Cherry Trail platforms signal a Power
 * Management Event (PME) to the Power Management Controller (PMC) to wakeup
 * the system. When this happens software needs to clear the PME bus 0 status
 * bit in the GPE0a_STS register to avoid an IRQ storm on IRQ 9.
 *
 * This is modelled in ACPI through the INT0002 ACPI device, which is
 * called a "Virtual GPIO controller" in ACPI because it defines the event
 * handler to call when the PME triggers through _AEI and _L02 / _E02
 * methods as would be done for a real GPIO interrupt in ACPI. Note this
 * is a hack to define an AML event handler for the PME while using existing
 * ACPI mechanisms, this is not a real GPIO at all.
 *
 * This driver will bind to the INT0002 device, and register as a GPIO
 * controller, letting gpiolib-acpi.c call the _L02 handler as it would
 * for a real GPIO controller.
 */

#include <linux/acpi.h>
#include <linux/bitmap.h>
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_data/x86/soc.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/suspend.h>

#define DRV_NAME

/* For some reason the virtual GPIO pin tied to the GPE is numbered pin 2 */
#define GPE0A_PME_B0_VIRT_GPIO_PIN

#define GPE0A_PME_B0_STS_BIT
#define GPE0A_PME_B0_EN_BIT
#define GPE0A_STS_PORT
#define GPE0A_EN_PORT

struct int0002_data {};

/*
 * As this is not a real GPIO at all, but just a hack to model an event in
 * ACPI the get / set functions are dummy functions.
 */

static int int0002_gpio_get(struct gpio_chip *chip, unsigned int offset)
{}

static void int0002_gpio_set(struct gpio_chip *chip, unsigned int offset,
			     int value)
{}

static int int0002_gpio_direction_output(struct gpio_chip *chip,
					 unsigned int offset, int value)
{}

static void int0002_irq_ack(struct irq_data *data)
{}

static void int0002_irq_unmask(struct irq_data *data)
{}

static void int0002_irq_mask(struct irq_data *data)
{}

static int int0002_irq_set_wake(struct irq_data *data, unsigned int on)
{}

static irqreturn_t int0002_irq(int irq, void *data)
{}

static bool int0002_check_wake(void *data)
{}

static struct irq_chip int0002_irqchip =;

static void int0002_init_irq_valid_mask(struct gpio_chip *chip,
					unsigned long *valid_mask,
					unsigned int ngpios)
{}

static int int0002_probe(struct platform_device *pdev)
{}

static void int0002_remove(struct platform_device *pdev)
{}

static int int0002_suspend(struct device *dev)
{}

static int int0002_resume(struct device *dev)
{}

static const struct dev_pm_ops int0002_pm_ops =;

static const struct acpi_device_id int0002_acpi_ids[] =;
MODULE_DEVICE_TABLE(acpi, int0002_acpi_ids);

static struct platform_driver int0002_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();