mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-22 13:37:49 +07:00
eb7046e9bf
Move the Dell dcdbas and dell_rbu drivers into platform/drivers/x86 as they are closely coupled with other drivers in this location. Improve _init* usage for acerhdf and fix some usage issues with messages and module parameters. Simplify asus-wmi by calling ACPI/WMI methods directly, eliminating workqueue overhead, eliminate double reporting of keyboard backlight. Fix wake from USB failure on Bay Trail devices (intel_int0002_vgpio). Notify intel_telemetry users when IPC1 device is not enabled. Update various drivers with new laptop model IDs. Update several intel drivers to use SPDX identifers and order headers alphabetically. The following is an automated git shortlog grouped by driver: Add Intel AtomISP2 dummy / power-management driver: - Add Intel AtomISP2 dummy / power-management driver lg-laptop: - Add LG Gram laptop special features driver HID: - asus: only support backlight when it's not driven by WMI MAINTAINERS: - intel_telemetry: Update maintainers info - intel_pmc_core: Update MAINTAINERS - Update maintainer for dcdbas and dell_rbu - Use my infradead account exclusively for PDx86 work acerhdf: - restructure to allow large BIOS table be __initconst - mark appropriate content with __init prefix - Add BIOS entry for Gateway LT31 v1.3307 - Remove cut-and-paste trap from instructions - Enable ability to list supported systems - clarify modinfo messages for BIOS override asus-wmi: - export function for evaluating WMI methods - Only notify kbd LED hw_change by fn-key pressed - Simplify the keyboard brightness updating process firmware: - dcdbas: include linux/io.h - dcdbas: Move dcdbas to drivers/platform/x86 - dell_rbu: Move dell_rbu to drivers/platform/x86 - dcdbas: Add support for WSMT ACPI table - dell_rbu: Make payload memory uncachable ideapad-laptop: - Add Y530-15ICH to no_hw_rfkill - Use __func__ instead of read_ec_cmd in pr_err intel-hid: - Convert to use SPDX identifier intel-ips: - Convert to use SPDX identifier intel-rst: - Convert to use SPDX identifier - Sort headers alphabetically intel-smartconnect: - Convert to use SPDX identifier - Sort headers alphabetically intel-wmi-thunderbolt: - Add dynamic debugging - Convert to use SPDX identifier intel_bxtwc_tmu: - Convert to use SPDX identifier intel_cht_int33fe: - Convert to use SPDX identifier intel_chtdc_ti_pwrbtn: - Add SPDX identifier intel_int0002_vgpio: - Convert to use SPDX identifier - Implement irq_set_wake - Enable the driver on Bay Trail platforms intel_menlow: - Convert to use SPDX identifier - Sort headers alphabetically intel_mid_powerbtn: - Convert to use SPDX identifier - Remove unnecessary init.h inclusion - Get rid of custom ICPU() macro intel_mid_thermal: - Convert to use SPDX identifier - Sort headers alphabetically intel_oaktrail: - Convert to use SPDX identifier - Sort headers alphabetically intel_pmc: - Convert to use SPDX identifier - Sort headers alphabetically intel_punit_ipc: - Convert to use SPDX identifier - Sort headers alphabetically intel_scu_ipc: - Convert to use SPDX identifier - Sort headers alphabetically intel_telemetry: - Get rid of custom macro - report debugfs failure - Convert to use SPDX identifier intel_turbo_max_3: - Convert to use SPDX identifier - Sort headers alphabetically mlx-platform: - Properly use mlxplat_mlxcpld_msn201x_items touchscreen_dmi: - Add min-x and min-y settings for various models - Add info for the Onda V80 Plus v3 tablet - Add info for the Trekstor Primetab T13B tablet - Add info for the Trekstor Primebook C11 convertible tracing: - Trivia spelling fix containerof() -> container_of() wmi: - declare device_type structure as constant -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJb2mDCAAoJEKbMaAwKp364KdkH/Rar8cenw7uFeVzT5o4fGzTn 0Oo1Pnwh+hPgmQwmf8O/mHsa/1Zb9nX4nNLU/ysDUjAAZ9wZLoB57HlImQquPA74 c8lXTz5MVF140WB1f1Ck5PmeonJR2Xve7HTYCoBmGo71jOxHxCgJbp1Giiho0Imd 3NXzzahEnAiy/L5PhqqYTmIfTeAHQ2Fo7GkHCjMnS20FP2fBtvPrc7db03F+FZ4y QTfbT0oR42NdeW21AbCRGY3P47axB3xDJX4LOYrb4uo4CIzd1yatlHk407NRRyv8 pab6aeJR23FouA/tcvv+T36D3vqRw78e6BWdoyowWOd7CUOgjtSC3lKGzfT6hSY= =0BDZ -----END PGP SIGNATURE----- Merge tag 'platform-drivers-x86-v4.20-1' of git://git.infradead.org/linux-platform-drivers-x86 Pull x86 platform driver updates from Darren Hart: - Move the Dell dcdbas and dell_rbu drivers into platform/drivers/x86 as they are closely coupled with other drivers in this location. - Improve _init* usage for acerhdf and fix some usage issues with messages and module parameters. - Simplify asus-wmi by calling ACPI/WMI methods directly, eliminating workqueue overhead, eliminate double reporting of keyboard backlight. - Fix wake from USB failure on Bay Trail devices (intel_int0002_vgpio). - Notify intel_telemetry users when IPC1 device is not enabled. - Update various drivers with new laptop model IDs. - Update several intel drivers to use SPDX identifers and order headers alphabetically. * tag 'platform-drivers-x86-v4.20-1' of git://git.infradead.org/linux-platform-drivers-x86: (64 commits) HID: asus: only support backlight when it's not driven by WMI platform/x86: asus-wmi: export function for evaluating WMI methods platform/x86: asus-wmi: Only notify kbd LED hw_change by fn-key pressed platform/x86: wmi: declare device_type structure as constant platform/x86: ideapad: Add Y530-15ICH to no_hw_rfkill platform/x86: Add Intel AtomISP2 dummy / power-management driver platform/x86: touchscreen_dmi: Add min-x and min-y settings for various models platform/x86: touchscreen_dmi: Add info for the Onda V80 Plus v3 tablet platform/x86: touchscreen_dmi: Add info for the Trekstor Primetab T13B tablet platform/x86: intel_telemetry: Get rid of custom macro platform/x86: intel_telemetry: report debugfs failure MAINTAINERS: intel_telemetry: Update maintainers info platform/x86: Add LG Gram laptop special features driver platform/x86: asus-wmi: Simplify the keyboard brightness updating process platform/x86: touchscreen_dmi: Add info for the Trekstor Primebook C11 convertible platform/x86: mlx-platform: Properly use mlxplat_mlxcpld_msn201x_items MAINTAINERS: intel_pmc_core: Update MAINTAINERS firmware: dcdbas: include linux/io.h platform/x86: intel-wmi-thunderbolt: Add dynamic debugging platform/x86: intel-wmi-thunderbolt: Convert to use SPDX identifier ...
229 lines
5.8 KiB
C
229 lines
5.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Intel INT0002 "Virtual GPIO" driver
|
|
*
|
|
* Copyright (C) 2017 Hans de Goede <hdegoede@redhat.com>
|
|
*
|
|
* Loosely based on android x86 kernel code which is:
|
|
*
|
|
* Copyright (c) 2014, Intel Corporation.
|
|
*
|
|
* Author: Dyut Kumar Sil <dyut.k.sil@intel.com>
|
|
*
|
|
* 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_device.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/suspend.h>
|
|
|
|
#include <asm/cpu_device_id.h>
|
|
#include <asm/intel-family.h>
|
|
|
|
#define DRV_NAME "INT0002 Virtual GPIO"
|
|
|
|
/* For some reason the virtual GPIO pin tied to the GPE is numbered pin 2 */
|
|
#define GPE0A_PME_B0_VIRT_GPIO_PIN 2
|
|
|
|
#define GPE0A_PME_B0_STS_BIT BIT(13)
|
|
#define GPE0A_PME_B0_EN_BIT BIT(13)
|
|
#define GPE0A_STS_PORT 0x420
|
|
#define GPE0A_EN_PORT 0x428
|
|
|
|
#define ICPU(model) { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
|
|
|
|
static const struct x86_cpu_id int0002_cpu_ids[] = {
|
|
ICPU(INTEL_FAM6_ATOM_SILVERMONT), /* Valleyview, Bay Trail */
|
|
ICPU(INTEL_FAM6_ATOM_AIRMONT), /* Braswell, Cherry Trail */
|
|
{}
|
|
};
|
|
|
|
/*
|
|
* 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)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
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)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static void int0002_irq_ack(struct irq_data *data)
|
|
{
|
|
outl(GPE0A_PME_B0_STS_BIT, GPE0A_STS_PORT);
|
|
}
|
|
|
|
static void int0002_irq_unmask(struct irq_data *data)
|
|
{
|
|
u32 gpe_en_reg;
|
|
|
|
gpe_en_reg = inl(GPE0A_EN_PORT);
|
|
gpe_en_reg |= GPE0A_PME_B0_EN_BIT;
|
|
outl(gpe_en_reg, GPE0A_EN_PORT);
|
|
}
|
|
|
|
static void int0002_irq_mask(struct irq_data *data)
|
|
{
|
|
u32 gpe_en_reg;
|
|
|
|
gpe_en_reg = inl(GPE0A_EN_PORT);
|
|
gpe_en_reg &= ~GPE0A_PME_B0_EN_BIT;
|
|
outl(gpe_en_reg, GPE0A_EN_PORT);
|
|
}
|
|
|
|
static int int0002_irq_set_wake(struct irq_data *data, unsigned int on)
|
|
{
|
|
struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
|
|
struct platform_device *pdev = to_platform_device(chip->parent);
|
|
int irq = platform_get_irq(pdev, 0);
|
|
|
|
/* Propagate to parent irq */
|
|
if (on)
|
|
enable_irq_wake(irq);
|
|
else
|
|
disable_irq_wake(irq);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static irqreturn_t int0002_irq(int irq, void *data)
|
|
{
|
|
struct gpio_chip *chip = data;
|
|
u32 gpe_sts_reg;
|
|
|
|
gpe_sts_reg = inl(GPE0A_STS_PORT);
|
|
if (!(gpe_sts_reg & GPE0A_PME_B0_STS_BIT))
|
|
return IRQ_NONE;
|
|
|
|
generic_handle_irq(irq_find_mapping(chip->irq.domain,
|
|
GPE0A_PME_B0_VIRT_GPIO_PIN));
|
|
|
|
pm_system_wakeup();
|
|
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static struct irq_chip int0002_irqchip = {
|
|
.name = DRV_NAME,
|
|
.irq_ack = int0002_irq_ack,
|
|
.irq_mask = int0002_irq_mask,
|
|
.irq_unmask = int0002_irq_unmask,
|
|
.irq_set_wake = int0002_irq_set_wake,
|
|
};
|
|
|
|
static int int0002_probe(struct platform_device *pdev)
|
|
{
|
|
struct device *dev = &pdev->dev;
|
|
const struct x86_cpu_id *cpu_id;
|
|
struct gpio_chip *chip;
|
|
int irq, ret;
|
|
|
|
/* Menlow has a different INT0002 device? <sigh> */
|
|
cpu_id = x86_match_cpu(int0002_cpu_ids);
|
|
if (!cpu_id)
|
|
return -ENODEV;
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0) {
|
|
dev_err(dev, "Error getting IRQ: %d\n", irq);
|
|
return irq;
|
|
}
|
|
|
|
chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL);
|
|
if (!chip)
|
|
return -ENOMEM;
|
|
|
|
chip->label = DRV_NAME;
|
|
chip->parent = dev;
|
|
chip->owner = THIS_MODULE;
|
|
chip->get = int0002_gpio_get;
|
|
chip->set = int0002_gpio_set;
|
|
chip->direction_input = int0002_gpio_get;
|
|
chip->direction_output = int0002_gpio_direction_output;
|
|
chip->base = -1;
|
|
chip->ngpio = GPE0A_PME_B0_VIRT_GPIO_PIN + 1;
|
|
chip->irq.need_valid_mask = true;
|
|
|
|
ret = devm_gpiochip_add_data(&pdev->dev, chip, NULL);
|
|
if (ret) {
|
|
dev_err(dev, "Error adding gpio chip: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
bitmap_clear(chip->irq.valid_mask, 0, GPE0A_PME_B0_VIRT_GPIO_PIN);
|
|
|
|
/*
|
|
* We manually request the irq here instead of passing a flow-handler
|
|
* to gpiochip_set_chained_irqchip, because the irq is shared.
|
|
*/
|
|
ret = devm_request_irq(dev, irq, int0002_irq,
|
|
IRQF_SHARED, "INT0002", chip);
|
|
if (ret) {
|
|
dev_err(dev, "Error requesting IRQ %d: %d\n", irq, ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = gpiochip_irqchip_add(chip, &int0002_irqchip, 0, handle_edge_irq,
|
|
IRQ_TYPE_NONE);
|
|
if (ret) {
|
|
dev_err(dev, "Error adding irqchip: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
gpiochip_set_chained_irqchip(chip, &int0002_irqchip, irq, NULL);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct acpi_device_id int0002_acpi_ids[] = {
|
|
{ "INT0002", 0 },
|
|
{ },
|
|
};
|
|
MODULE_DEVICE_TABLE(acpi, int0002_acpi_ids);
|
|
|
|
static struct platform_driver int0002_driver = {
|
|
.driver = {
|
|
.name = DRV_NAME,
|
|
.acpi_match_table = int0002_acpi_ids,
|
|
},
|
|
.probe = int0002_probe,
|
|
};
|
|
|
|
module_platform_driver(int0002_driver);
|
|
|
|
MODULE_AUTHOR("Hans de Goede <hdegoede@redhat.com>");
|
|
MODULE_DESCRIPTION("Intel INT0002 Virtual GPIO driver");
|
|
MODULE_LICENSE("GPL v2");
|