mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-16 00:56:49 +07:00
899fbc33fd
The driver for Silead touchscreen configurations has been renamed from silead_dmi to touchscreen_dmi since it starts supporting other touchscreens which require some DMI quirks. At the same release cycle it gets expanded to cover cases for Chuwi Vi10, ONDA V891W, Connect Tablet 9, Onda V820w, and Cube KNote i1101 tablets. Another bunch of changes is related to Mellanox platform code to allow user space to communicate with Mellanox for system control and monitoring purposes. The driver notifies user on hotplug device signal receiving. ASUS WMI drivers recognize lid flip action on UX360, and correctly toggles airplane mode LED. In addition the keyboard backlight toggle gets support. ThinkPad ACPI driver enables support for calculator key (on at least P52). It also has been fixed to support three characters model designators, which are used for modern laptops. Earlier the battery, marked as BAT1, on ThinkPad laptops has not been configured properly, which is fixed. On the opposite the multi-battery configurations now probed correctly. Dell SMBIOS driver starts working on some Dell servers which do not support token interface. The regression with backlight detection has also been fixed. In order to support dock mode on some laptops, Intel virtual button driver has been fixed. The last but not least is the fix to Intel HID driver due to changes in Dell systems that prevented to use power button. The following is an automated git shortlog grouped by driver: acer-wmi: - Silence "unsupported" message a bit - refactor function has_cap asus-nb-wmi: - Add keymap entry for lid flip action on UX360 asus-wireless: - Fix uninitialized symbol usage - Toggle airplane mode LED asus-wmi: - Add keyboard backlight toggle support - Call led hw_changed API on kbd brightness change dell-laptop: - Fix backlight detection dell-smbios: - make a function and a pointer static dell-smbios-base: - Support systems without tokens dell-smbios-wmi: - make function dell_smbios_wmi_call static ideapad-laptop: - Add Y520-15IKBM and Y720-15IKBM to no_hw_rfkill - Apply no_hw_rfkill to Y20-15IKBM, too intel-hid: - Add support for Device Specific Methods intel_ips: - remove redundant variables slope and offset intel_pmc_core: - Add CNP SLPS0 debug registers intel_punit_ipc: - fix build errors intel-vbtn: - Add support for dock mode detection mlx-platform: - Fix copy-paste error in mlxplat_init() - Remove unused define - Change mlxreg-io configuration for MSN274x systems - Allow mlxreg-io driver activation for more systems - Add ASIC hotplug device configuration - Add new attribute for mlxreg-io sysfs interfaces - Add mlxreg-fan platform driver activation - Add documentation mlxreg-io sysfs interfaces - Add mlxreg-io platform driver activation platform/mellanox: - mlxreg-hotplug: Add hotplug hwmon uevent notification - mlxreg-hotplug: Improve mechanism of ASIC health discovery - Use 2-factor allocator calls - Introduce support for Mellanox register access driver thinkpad_acpi: - Fix multi-battery bug - extend battery quirk coverage - Support battery quirk - Proper model/release matching - Add support for calculator hotkey toshiba_acpi: - Fix defined but not used build warnings - Update KBD backlight LED on second gen laptops touchscreen_dmi: - Rename silead_dmi to touchscreen_dmi - Add touchscreen info for the Chuwi Vi10 tablet - Sort entries alphabetically - Rename trekstor entries - Add info for the Cube KNote i1101 tablet - Add info for the Onda V820w tablet - Add info for the "Connect Tablet 9" tablet - Add info for the ONDA V891W Dual OS tablet wmi: - Do not mix pages and kmalloc -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEhiZOUlnC9oKN3n3AmT3/83c5Sy0FAlt9wVgACgkQmT3/83c5 Sy3Jdg//WnEJZx7+zEsO+3dJnQGN4Fur6xhP79subRhZPFNTZ+D5vMHC9DL8ZQYx U8Kz1ilxCC5HuOo2S1BlzRG+h6ztMSYIFo2H8KRdygOqALEH7hoStPEGYdZcQ0qE 6SKa4MnRw46UcGPij3f6STPiOjicPaLoUSTXZmi2dbmy6sJZMMJamvnRhezgEgJl rA6xvg+tKNBK2jwLpAVfLhy4Btd6LCE4EGgkYdnytOM9ByHLDsTWCZxd/9h7WjPa L8Zd8rftrazWF6X2tAhpXtUcMPg/D4lfL5HHaMmL9FioycQ88WqDBZN5sEWdIbaP OfaMbcbhCIrrHoMNdq0544IgqRQahX+m3VjSkVf3/Aj5AU0nUJMBWSpGHAs7UCSN 8i8M2jdpVW7CVxA+4OU2l19udKrQzXutfXXhVYX0B3hKCkH7TBKax+m/ev9n2yvZ KoTdSJ/4bB6iGhXF8/MA6H72k0g972d4WXozbTusiBO9grqgU1EIe5bYZ4y+FkJL 9gtK1xgtDJB7J8U14lpGC+zKhcYn1Mn3Iq4i5HD3sfnKsVGGWJIjRZsDtALD2RKT OQe7S8xhQWqsUZFGNflWL+8oHyXOHGD5Q8b/YI92ubriyAzh3I3Ybt/atk20vdmG QfKU46suOoOUwcAs00v13oo+9s9GatekXEjGgdRJ14vgzdgx3lc= =vRud -----END PGP SIGNATURE----- Merge tag 'platform-drivers-x86-v4.19-1' of git://git.infradead.org/linux-platform-drivers-x86 Pull x86 platform driver updates from Andy Shevchenko: - The driver for Silead touchscreen configurations has been renamed from silead_dmi to touchscreen_dmi since it starts supporting other touchscreens which require some DMI quirks It also gets expanded to cover cases for Chuwi Vi10, ONDA V891W, Connect Tablet 9, Onda V820w, and Cube KNote i1101 tablets. - Another bunch of changes is related to Mellanox platform code to allow user space to communicate with Mellanox for system control and monitoring purposes. The driver notifies user on hotplug device signal receiving. - ASUS WMI drivers recognize lid flip action on UX360, and correctly toggles airplane mode LED. In addition the keyboard backlight toggle gets support. - ThinkPad ACPI driver enables support for calculator key (on at least P52). It also has been fixed to support three characters model designators, which are used for modern laptops. Earlier the battery, marked as BAT1, on ThinkPad laptops has not been configured properly, which is fixed. On the opposite the multi-battery configurations now probed correctly. - Dell SMBIOS driver starts working on some Dell servers which do not support token interface. The regression with backlight detection has also been fixed. In order to support dock mode on some laptops, Intel virtual button driver has been fixed. The last but not least is the fix to Intel HID driver due to changes in Dell systems that prevented to use power button. * tag 'platform-drivers-x86-v4.19-1' of git://git.infradead.org/linux-platform-drivers-x86: (47 commits) platform/x86: acer-wmi: Silence "unsupported" message a bit platform/x86: intel_punit_ipc: fix build errors platform/x86: ideapad: Add Y520-15IKBM and Y720-15IKBM to no_hw_rfkill platform/x86: asus-nb-wmi: Add keymap entry for lid flip action on UX360 platform/x86: acer-wmi: refactor function has_cap platform/x86: thinkpad_acpi: Fix multi-battery bug platform/x86: thinkpad_acpi: extend battery quirk coverage platform/x86: touchscreen_dmi: Add info for the Cube KNote i1101 tablet platform/x86: mlx-platform: Fix copy-paste error in mlxplat_init() platform/x86: mlx-platform: Remove unused define platform/x86: mlx-platform: Change mlxreg-io configuration for MSN274x systems Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces platform/x86: mlx-platform: Allow mlxreg-io driver activation for more systems platform/x86: mlx-platform: Add ASIC hotplug device configuration platform/mellanox: mlxreg-hotplug: Add hotplug hwmon uevent notification platform/mellanox: mlxreg-hotplug: Improve mechanism of ASIC health discovery platform/x86: mlx-platform: Add mlxreg-fan platform driver activation platform/x86: dell-laptop: Fix backlight detection platform/x86: toshiba_acpi: Fix defined but not used build warnings platform/x86: thinkpad_acpi: Support battery quirk ...
361 lines
8.9 KiB
C
361 lines
8.9 KiB
C
/*
|
|
* Driver for the Intel P-Unit Mailbox IPC mechanism
|
|
*
|
|
* (C) Copyright 2015 Intel Corporation
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* The heart of the P-Unit is the Foxton microcontroller and its firmware,
|
|
* which provide mailbox interface for power management usage.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/mod_devicetable.h>
|
|
#include <linux/acpi.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/device.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/io.h>
|
|
#include <linux/platform_device.h>
|
|
#include <asm/intel_punit_ipc.h>
|
|
|
|
/* IPC Mailbox registers */
|
|
#define OFFSET_DATA_LOW 0x0
|
|
#define OFFSET_DATA_HIGH 0x4
|
|
/* bit field of interface register */
|
|
#define CMD_RUN BIT(31)
|
|
#define CMD_ERRCODE_MASK GENMASK(7, 0)
|
|
#define CMD_PARA1_SHIFT 8
|
|
#define CMD_PARA2_SHIFT 16
|
|
|
|
#define CMD_TIMEOUT_SECONDS 1
|
|
|
|
enum {
|
|
BASE_DATA = 0,
|
|
BASE_IFACE,
|
|
BASE_MAX,
|
|
};
|
|
|
|
typedef struct {
|
|
struct device *dev;
|
|
struct mutex lock;
|
|
int irq;
|
|
struct completion cmd_complete;
|
|
/* base of interface and data registers */
|
|
void __iomem *base[RESERVED_IPC][BASE_MAX];
|
|
IPC_TYPE type;
|
|
} IPC_DEV;
|
|
|
|
static IPC_DEV *punit_ipcdev;
|
|
|
|
static inline u32 ipc_read_status(IPC_DEV *ipcdev, IPC_TYPE type)
|
|
{
|
|
return readl(ipcdev->base[type][BASE_IFACE]);
|
|
}
|
|
|
|
static inline void ipc_write_cmd(IPC_DEV *ipcdev, IPC_TYPE type, u32 cmd)
|
|
{
|
|
writel(cmd, ipcdev->base[type][BASE_IFACE]);
|
|
}
|
|
|
|
static inline u32 ipc_read_data_low(IPC_DEV *ipcdev, IPC_TYPE type)
|
|
{
|
|
return readl(ipcdev->base[type][BASE_DATA] + OFFSET_DATA_LOW);
|
|
}
|
|
|
|
static inline u32 ipc_read_data_high(IPC_DEV *ipcdev, IPC_TYPE type)
|
|
{
|
|
return readl(ipcdev->base[type][BASE_DATA] + OFFSET_DATA_HIGH);
|
|
}
|
|
|
|
static inline void ipc_write_data_low(IPC_DEV *ipcdev, IPC_TYPE type, u32 data)
|
|
{
|
|
writel(data, ipcdev->base[type][BASE_DATA] + OFFSET_DATA_LOW);
|
|
}
|
|
|
|
static inline void ipc_write_data_high(IPC_DEV *ipcdev, IPC_TYPE type, u32 data)
|
|
{
|
|
writel(data, ipcdev->base[type][BASE_DATA] + OFFSET_DATA_HIGH);
|
|
}
|
|
|
|
static const char *ipc_err_string(int error)
|
|
{
|
|
if (error == IPC_PUNIT_ERR_SUCCESS)
|
|
return "no error";
|
|
else if (error == IPC_PUNIT_ERR_INVALID_CMD)
|
|
return "invalid command";
|
|
else if (error == IPC_PUNIT_ERR_INVALID_PARAMETER)
|
|
return "invalid parameter";
|
|
else if (error == IPC_PUNIT_ERR_CMD_TIMEOUT)
|
|
return "command timeout";
|
|
else if (error == IPC_PUNIT_ERR_CMD_LOCKED)
|
|
return "command locked";
|
|
else if (error == IPC_PUNIT_ERR_INVALID_VR_ID)
|
|
return "invalid vr id";
|
|
else if (error == IPC_PUNIT_ERR_VR_ERR)
|
|
return "vr error";
|
|
else
|
|
return "unknown error";
|
|
}
|
|
|
|
static int intel_punit_ipc_check_status(IPC_DEV *ipcdev, IPC_TYPE type)
|
|
{
|
|
int loops = CMD_TIMEOUT_SECONDS * USEC_PER_SEC;
|
|
int errcode;
|
|
int status;
|
|
|
|
if (ipcdev->irq) {
|
|
if (!wait_for_completion_timeout(&ipcdev->cmd_complete,
|
|
CMD_TIMEOUT_SECONDS * HZ)) {
|
|
dev_err(ipcdev->dev, "IPC timed out\n");
|
|
return -ETIMEDOUT;
|
|
}
|
|
} else {
|
|
while ((ipc_read_status(ipcdev, type) & CMD_RUN) && --loops)
|
|
udelay(1);
|
|
if (!loops) {
|
|
dev_err(ipcdev->dev, "IPC timed out\n");
|
|
return -ETIMEDOUT;
|
|
}
|
|
}
|
|
|
|
status = ipc_read_status(ipcdev, type);
|
|
errcode = status & CMD_ERRCODE_MASK;
|
|
if (errcode) {
|
|
dev_err(ipcdev->dev, "IPC failed: %s, IPC_STS=0x%x\n",
|
|
ipc_err_string(errcode), status);
|
|
return -EIO;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* intel_punit_ipc_simple_command() - Simple IPC command
|
|
* @cmd: IPC command code.
|
|
* @para1: First 8bit parameter, set 0 if not used.
|
|
* @para2: Second 8bit parameter, set 0 if not used.
|
|
*
|
|
* Send a IPC command to P-Unit when there is no data transaction
|
|
*
|
|
* Return: IPC error code or 0 on success.
|
|
*/
|
|
int intel_punit_ipc_simple_command(int cmd, int para1, int para2)
|
|
{
|
|
IPC_DEV *ipcdev = punit_ipcdev;
|
|
IPC_TYPE type;
|
|
u32 val;
|
|
int ret;
|
|
|
|
mutex_lock(&ipcdev->lock);
|
|
|
|
reinit_completion(&ipcdev->cmd_complete);
|
|
type = (cmd & IPC_PUNIT_CMD_TYPE_MASK) >> IPC_TYPE_OFFSET;
|
|
|
|
val = cmd & ~IPC_PUNIT_CMD_TYPE_MASK;
|
|
val |= CMD_RUN | para2 << CMD_PARA2_SHIFT | para1 << CMD_PARA1_SHIFT;
|
|
ipc_write_cmd(ipcdev, type, val);
|
|
ret = intel_punit_ipc_check_status(ipcdev, type);
|
|
|
|
mutex_unlock(&ipcdev->lock);
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(intel_punit_ipc_simple_command);
|
|
|
|
/**
|
|
* intel_punit_ipc_command() - IPC command with data and pointers
|
|
* @cmd: IPC command code.
|
|
* @para1: First 8bit parameter, set 0 if not used.
|
|
* @para2: Second 8bit parameter, set 0 if not used.
|
|
* @in: Input data, 32bit for BIOS cmd, two 32bit for GTD and ISPD.
|
|
* @out: Output data.
|
|
*
|
|
* Send a IPC command to P-Unit with data transaction
|
|
*
|
|
* Return: IPC error code or 0 on success.
|
|
*/
|
|
int intel_punit_ipc_command(u32 cmd, u32 para1, u32 para2, u32 *in, u32 *out)
|
|
{
|
|
IPC_DEV *ipcdev = punit_ipcdev;
|
|
IPC_TYPE type;
|
|
u32 val;
|
|
int ret;
|
|
|
|
mutex_lock(&ipcdev->lock);
|
|
|
|
reinit_completion(&ipcdev->cmd_complete);
|
|
type = (cmd & IPC_PUNIT_CMD_TYPE_MASK) >> IPC_TYPE_OFFSET;
|
|
|
|
if (in) {
|
|
ipc_write_data_low(ipcdev, type, *in);
|
|
if (type == GTDRIVER_IPC || type == ISPDRIVER_IPC)
|
|
ipc_write_data_high(ipcdev, type, *++in);
|
|
}
|
|
|
|
val = cmd & ~IPC_PUNIT_CMD_TYPE_MASK;
|
|
val |= CMD_RUN | para2 << CMD_PARA2_SHIFT | para1 << CMD_PARA1_SHIFT;
|
|
ipc_write_cmd(ipcdev, type, val);
|
|
|
|
ret = intel_punit_ipc_check_status(ipcdev, type);
|
|
if (ret)
|
|
goto out;
|
|
|
|
if (out) {
|
|
*out = ipc_read_data_low(ipcdev, type);
|
|
if (type == GTDRIVER_IPC || type == ISPDRIVER_IPC)
|
|
*++out = ipc_read_data_high(ipcdev, type);
|
|
}
|
|
|
|
out:
|
|
mutex_unlock(&ipcdev->lock);
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(intel_punit_ipc_command);
|
|
|
|
static irqreturn_t intel_punit_ioc(int irq, void *dev_id)
|
|
{
|
|
IPC_DEV *ipcdev = dev_id;
|
|
|
|
complete(&ipcdev->cmd_complete);
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
static int intel_punit_get_bars(struct platform_device *pdev)
|
|
{
|
|
struct resource *res;
|
|
void __iomem *addr;
|
|
|
|
/*
|
|
* The following resources are required
|
|
* - BIOS_IPC BASE_DATA
|
|
* - BIOS_IPC BASE_IFACE
|
|
*/
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (IS_ERR(addr))
|
|
return PTR_ERR(addr);
|
|
punit_ipcdev->base[BIOS_IPC][BASE_DATA] = addr;
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (IS_ERR(addr))
|
|
return PTR_ERR(addr);
|
|
punit_ipcdev->base[BIOS_IPC][BASE_IFACE] = addr;
|
|
|
|
/*
|
|
* The following resources are optional
|
|
* - ISPDRIVER_IPC BASE_DATA
|
|
* - ISPDRIVER_IPC BASE_IFACE
|
|
* - GTDRIVER_IPC BASE_DATA
|
|
* - GTDRIVER_IPC BASE_IFACE
|
|
*/
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
|
|
if (res && resource_size(res) > 1) {
|
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (!IS_ERR(addr))
|
|
punit_ipcdev->base[ISPDRIVER_IPC][BASE_DATA] = addr;
|
|
}
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
|
|
if (res && resource_size(res) > 1) {
|
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (!IS_ERR(addr))
|
|
punit_ipcdev->base[ISPDRIVER_IPC][BASE_IFACE] = addr;
|
|
}
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
|
|
if (res && resource_size(res) > 1) {
|
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (!IS_ERR(addr))
|
|
punit_ipcdev->base[GTDRIVER_IPC][BASE_DATA] = addr;
|
|
}
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 5);
|
|
if (res && resource_size(res) > 1) {
|
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (!IS_ERR(addr))
|
|
punit_ipcdev->base[GTDRIVER_IPC][BASE_IFACE] = addr;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int intel_punit_ipc_probe(struct platform_device *pdev)
|
|
{
|
|
int irq, ret;
|
|
|
|
punit_ipcdev = devm_kzalloc(&pdev->dev,
|
|
sizeof(*punit_ipcdev), GFP_KERNEL);
|
|
if (!punit_ipcdev)
|
|
return -ENOMEM;
|
|
|
|
platform_set_drvdata(pdev, punit_ipcdev);
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0) {
|
|
punit_ipcdev->irq = 0;
|
|
dev_warn(&pdev->dev, "Invalid IRQ, using polling mode\n");
|
|
} else {
|
|
ret = devm_request_irq(&pdev->dev, irq, intel_punit_ioc,
|
|
IRQF_NO_SUSPEND, "intel_punit_ipc",
|
|
&punit_ipcdev);
|
|
if (ret) {
|
|
dev_err(&pdev->dev, "Failed to request irq: %d\n", irq);
|
|
return ret;
|
|
}
|
|
punit_ipcdev->irq = irq;
|
|
}
|
|
|
|
ret = intel_punit_get_bars(pdev);
|
|
if (ret)
|
|
goto out;
|
|
|
|
punit_ipcdev->dev = &pdev->dev;
|
|
mutex_init(&punit_ipcdev->lock);
|
|
init_completion(&punit_ipcdev->cmd_complete);
|
|
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
static int intel_punit_ipc_remove(struct platform_device *pdev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static const struct acpi_device_id punit_ipc_acpi_ids[] = {
|
|
{ "INT34D4", 0 },
|
|
{ }
|
|
};
|
|
|
|
static struct platform_driver intel_punit_ipc_driver = {
|
|
.probe = intel_punit_ipc_probe,
|
|
.remove = intel_punit_ipc_remove,
|
|
.driver = {
|
|
.name = "intel_punit_ipc",
|
|
.acpi_match_table = ACPI_PTR(punit_ipc_acpi_ids),
|
|
},
|
|
};
|
|
|
|
static int __init intel_punit_ipc_init(void)
|
|
{
|
|
return platform_driver_register(&intel_punit_ipc_driver);
|
|
}
|
|
|
|
static void __exit intel_punit_ipc_exit(void)
|
|
{
|
|
platform_driver_unregister(&intel_punit_ipc_driver);
|
|
}
|
|
|
|
MODULE_AUTHOR("Zha Qipeng <qipeng.zha@intel.com>");
|
|
MODULE_DESCRIPTION("Intel P-Unit IPC driver");
|
|
MODULE_LICENSE("GPL v2");
|
|
|
|
/* Some modules are dependent on this, so init earlier */
|
|
fs_initcall(intel_punit_ipc_init);
|
|
module_exit(intel_punit_ipc_exit);
|