You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
Revert "v5.16.11, use t2linux/kernel repo"
This reverts commit 70181d5e8e.
This commit is contained in:
@@ -5,4 +5,3 @@ src/
|
|||||||
pkg/
|
pkg/
|
||||||
apple-bce/
|
apple-bce/
|
||||||
apple-ibridge/
|
apple-ibridge/
|
||||||
t2linux-linux
|
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
From f615330c6169a5fe5750706f1db7cbdd520f9534 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
|
||||||
|
Date: Mon, 16 Sep 2019 04:53:20 +0200
|
||||||
|
Subject: [PATCH 1/2] ZEN: Add sysctl and CONFIG to disallow unprivileged
|
||||||
|
CLONE_NEWUSER
|
||||||
|
|
||||||
|
Our default behavior continues to match the vanilla kernel.
|
||||||
|
---
|
||||||
|
include/linux/user_namespace.h | 4 ++++
|
||||||
|
init/Kconfig | 16 ++++++++++++++++
|
||||||
|
kernel/fork.c | 14 ++++++++++++++
|
||||||
|
kernel/sysctl.c | 12 ++++++++++++
|
||||||
|
kernel/user_namespace.c | 7 +++++++
|
||||||
|
5 files changed, 53 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
|
||||||
|
index 6ef1c7109fc4..2140091b0b8d 100644
|
||||||
|
--- a/include/linux/user_namespace.h
|
||||||
|
+++ b/include/linux/user_namespace.h
|
||||||
|
@@ -106,6 +106,8 @@ void dec_ucount(struct ucounts *ucounts, enum ucount_type type);
|
||||||
|
|
||||||
|
#ifdef CONFIG_USER_NS
|
||||||
|
|
||||||
|
+extern int unprivileged_userns_clone;
|
||||||
|
+
|
||||||
|
static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
|
||||||
|
{
|
||||||
|
if (ns)
|
||||||
|
@@ -139,6 +141,8 @@ extern bool current_in_userns(const struct user_namespace *target_ns);
|
||||||
|
struct ns_common *ns_get_owner(struct ns_common *ns);
|
||||||
|
#else
|
||||||
|
|
||||||
|
+#define unprivileged_userns_clone 0
|
||||||
|
+
|
||||||
|
static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
|
||||||
|
{
|
||||||
|
return &init_user_ns;
|
||||||
|
diff --git a/init/Kconfig b/init/Kconfig
|
||||||
|
index 0872a5a2e759..a40d8afeb1bb 100644
|
||||||
|
--- a/init/Kconfig
|
||||||
|
+++ b/init/Kconfig
|
||||||
|
@@ -1173,6 +1173,22 @@ config USER_NS
|
||||||
|
|
||||||
|
If unsure, say N.
|
||||||
|
|
||||||
|
+config USER_NS_UNPRIVILEGED
|
||||||
|
+ bool "Allow unprivileged users to create namespaces"
|
||||||
|
+ default y
|
||||||
|
+ depends on USER_NS
|
||||||
|
+ help
|
||||||
|
+ When disabled, unprivileged users will not be able to create
|
||||||
|
+ new namespaces. Allowing users to create their own namespaces
|
||||||
|
+ has been part of several recent local privilege escalation
|
||||||
|
+ exploits, so if you need user namespaces but are
|
||||||
|
+ paranoid^Wsecurity-conscious you want to disable this.
|
||||||
|
+
|
||||||
|
+ This setting can be overridden at runtime via the
|
||||||
|
+ kernel.unprivileged_userns_clone sysctl.
|
||||||
|
+
|
||||||
|
+ If unsure, say Y.
|
||||||
|
+
|
||||||
|
config PID_NS
|
||||||
|
bool "PID Namespaces"
|
||||||
|
default y
|
||||||
|
diff --git a/kernel/fork.c b/kernel/fork.c
|
||||||
|
index c675fdbd3dce..9266039e28e4 100644
|
||||||
|
--- a/kernel/fork.c
|
||||||
|
+++ b/kernel/fork.c
|
||||||
|
@@ -97,6 +97,10 @@
|
||||||
|
#include <linux/io_uring.h>
|
||||||
|
#include <linux/bpf.h>
|
||||||
|
|
||||||
|
+#ifdef CONFIG_USER_NS
|
||||||
|
+#include <linux/user_namespace.h>
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
#include <asm/pgalloc.h>
|
||||||
|
#include <linux/uaccess.h>
|
||||||
|
#include <asm/mmu_context.h>
|
||||||
|
@@ -1863,6 +1867,10 @@ static __latent_entropy struct task_struct *copy_process(
|
||||||
|
if ((clone_flags & (CLONE_NEWUSER|CLONE_FS)) == (CLONE_NEWUSER|CLONE_FS))
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
|
+ if ((clone_flags & CLONE_NEWUSER) && !unprivileged_userns_clone)
|
||||||
|
+ if (!capable(CAP_SYS_ADMIN))
|
||||||
|
+ return ERR_PTR(-EPERM);
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Thread groups must share signals as well, and detached threads
|
||||||
|
* can only be started up within the thread group.
|
||||||
|
@@ -2928,6 +2936,12 @@ int ksys_unshare(unsigned long unshare_flags)
|
||||||
|
if (unshare_flags & CLONE_NEWNS)
|
||||||
|
unshare_flags |= CLONE_FS;
|
||||||
|
|
||||||
|
+ if ((unshare_flags & CLONE_NEWUSER) && !unprivileged_userns_clone) {
|
||||||
|
+ err = -EPERM;
|
||||||
|
+ if (!capable(CAP_SYS_ADMIN))
|
||||||
|
+ goto bad_unshare_out;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
err = check_unshare_flags(unshare_flags);
|
||||||
|
if (err)
|
||||||
|
goto bad_unshare_out;
|
||||||
|
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
|
||||||
|
index afad085960b8..a94828fb31c2 100644
|
||||||
|
--- a/kernel/sysctl.c
|
||||||
|
+++ b/kernel/sysctl.c
|
||||||
|
@@ -103,6 +103,9 @@
|
||||||
|
#ifdef CONFIG_LOCKUP_DETECTOR
|
||||||
|
#include <linux/nmi.h>
|
||||||
|
#endif
|
||||||
|
+#ifdef CONFIG_USER_NS
|
||||||
|
+#include <linux/user_namespace.h>
|
||||||
|
+#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSCTL)
|
||||||
|
|
||||||
|
@@ -1902,6 +1905,15 @@ static struct ctl_table kern_table[] = {
|
||||||
|
.proc_handler = proc_dointvec,
|
||||||
|
},
|
||||||
|
#endif
|
||||||
|
+#ifdef CONFIG_USER_NS
|
||||||
|
+ {
|
||||||
|
+ .procname = "unprivileged_userns_clone",
|
||||||
|
+ .data = &unprivileged_userns_clone,
|
||||||
|
+ .maxlen = sizeof(int),
|
||||||
|
+ .mode = 0644,
|
||||||
|
+ .proc_handler = proc_dointvec,
|
||||||
|
+ },
|
||||||
|
+#endif
|
||||||
|
#ifdef CONFIG_PROC_SYSCTL
|
||||||
|
{
|
||||||
|
.procname = "tainted",
|
||||||
|
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
|
||||||
|
index e703d5d9cbe8..5758274feaee 100644
|
||||||
|
--- a/kernel/user_namespace.c
|
||||||
|
+++ b/kernel/user_namespace.c
|
||||||
|
@@ -21,6 +21,13 @@
|
||||||
|
#include <linux/bsearch.h>
|
||||||
|
#include <linux/sort.h>
|
||||||
|
|
||||||
|
+/* sysctl */
|
||||||
|
+#ifdef CONFIG_USER_NS_UNPRIVILEGED
|
||||||
|
+int unprivileged_userns_clone = 1;
|
||||||
|
+#else
|
||||||
|
+int unprivileged_userns_clone;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
static struct kmem_cache *user_ns_cachep __read_mostly;
|
||||||
|
static DEFINE_MUTEX(userns_state_mutex);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
From 3df6111e2ffaf7a57dd245a9df1997f773840b74 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Felix=20H=C3=A4dicke?= <felixhaedicke@web.de>
|
||||||
|
Date: Thu, 19 Nov 2020 09:22:32 +0100
|
||||||
|
Subject: [PATCH 2/2] HID: quirks: Add Apple Magic Trackpad 2 to
|
||||||
|
hid_have_special_driver list
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
The Apple Magic Trackpad 2 is handled by the magicmouse driver. And
|
||||||
|
there were severe stability issues when both drivers (hid-generic and
|
||||||
|
hid-magicmouse) were loaded for this device.
|
||||||
|
|
||||||
|
Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=210241
|
||||||
|
|
||||||
|
Signed-off-by: Felix Hädicke <felixhaedicke@web.de>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index bf7ecab5d9e5..142e9dae2837 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -478,6 +478,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
#if IS_ENABLED(CONFIG_HID_MAGICMOUSE)
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICMOUSE) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD) },
|
||||||
|
+ { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) },
|
||||||
|
#endif
|
||||||
|
#if IS_ENABLED(CONFIG_HID_MAYFLASH)
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3) },
|
||||||
|
--
|
||||||
|
2.31.1
|
||||||
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
From b6740001d1adbfe84768b859bee038ceeccdc50c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Wed, 12 Jan 2022 22:38:15 +1100
|
||||||
|
Subject: [PATCH] drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels
|
||||||
|
|
||||||
|
The eDP link rate reported by the DP_MAX_LINK_RATE dpcd register (0xa) is
|
||||||
|
contradictory to the highest rate supported reported by
|
||||||
|
EDID (0xc = LINK_RATE_RBR2). The effects of this compounded with commit
|
||||||
|
'4a8ca46bae8a ("drm/amd/display: Default max bpc to 16 for eDP")' results
|
||||||
|
in no display modes being found and a dark panel.
|
||||||
|
|
||||||
|
For now, simply force the maximum supported link rate for the eDP attached
|
||||||
|
2018 15" Apple Retina panels.
|
||||||
|
|
||||||
|
Additionally, we must also check the firmware revision since the device ID
|
||||||
|
reported by the DPCD is identical to that of the more capable 16,1,
|
||||||
|
incorrectly quirking it. We also use said firmware check to quirk the
|
||||||
|
refreshed 15,1 models with Vega graphics as they use a slightly newer
|
||||||
|
firmware version.
|
||||||
|
|
||||||
|
Tested-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||||
|
---
|
||||||
|
.../gpu/drm/amd/display/dc/core/dc_link_dp.c | 19 +++++++++++++++++++
|
||||||
|
1 file changed, 19 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
|
||||||
|
index 05e216524..17939ad17 100644
|
||||||
|
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
|
||||||
|
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
|
||||||
|
@@ -5597,6 +5597,25 @@ static bool retrieve_link_cap(struct dc_link *link)
|
||||||
|
dp_hw_fw_revision.ieee_fw_rev,
|
||||||
|
sizeof(dp_hw_fw_revision.ieee_fw_rev));
|
||||||
|
|
||||||
|
+ /* Quirk for Apple MBP 2018 15" Retina panels: wrong DP_MAX_LINK_RATE */
|
||||||
|
+ {
|
||||||
|
+ uint8_t str_mbp_2018[] = { 101, 68, 21, 103, 98, 97 };
|
||||||
|
+ uint8_t fwrev_mbp_2018[] = { 7, 4 };
|
||||||
|
+ uint8_t fwrev_mbp_2018_vega[] = { 8, 4 };
|
||||||
|
+
|
||||||
|
+ // We also check for the firmware revision as 16,1 models have an
|
||||||
|
+ // identical device id and are incorrectly quirked otherwise.
|
||||||
|
+ if ((link->dpcd_caps.sink_dev_id == 0x0010fa) &&
|
||||||
|
+ !memcmp(link->dpcd_caps.sink_dev_id_str, str_mbp_2018,
|
||||||
|
+ sizeof(str_mbp_2018)) &&
|
||||||
|
+ (!memcmp(link->dpcd_caps.sink_fw_revision, fwrev_mbp_2018,
|
||||||
|
+ sizeof(fwrev_mbp_2018)) ||
|
||||||
|
+ !memcmp(link->dpcd_caps.sink_fw_revision, fwrev_mbp_2018_vega,
|
||||||
|
+ sizeof(fwrev_mbp_2018_vega)))) {
|
||||||
|
+ link->reported_link_cap.link_rate = LINK_RATE_RBR2;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
memset(&link->dpcd_caps.dsc_caps, '\0',
|
||||||
|
sizeof(link->dpcd_caps.dsc_caps));
|
||||||
|
memset(&link->dpcd_caps.fec_cap, '\0', sizeof(link->dpcd_caps.fec_cap));
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,312 @@
|
|||||||
|
From 713e78b8dbb8adb92d4ee09ea11e726b05577689 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Pawlowski <paul@mrarm.io>
|
||||||
|
Date: Sun, 17 Nov 2019 23:11:56 +0100
|
||||||
|
Subject: [PATCH 2/6] applesmc: make io port base addr dynamic
|
||||||
|
|
||||||
|
This change makes the port base runtime configurable.
|
||||||
|
The reason why this change is made is so that when we switch to an
|
||||||
|
acpi_device we can resolve the port base addr from ACPI.
|
||||||
|
|
||||||
|
This change is not strictly required for T2 support - the base
|
||||||
|
address is still 0x300 on T2 Macs.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 91 +++++++++++++++++++++-------------------
|
||||||
|
1 file changed, 49 insertions(+), 42 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 62211b590a61..39ed0bb21365 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -35,10 +35,11 @@
|
||||||
|
#include <linux/err.h>
|
||||||
|
#include <linux/bits.h>
|
||||||
|
|
||||||
|
+#define APPLESMC_PORT_BASE 0x300
|
||||||
|
/* data port used by Apple SMC */
|
||||||
|
-#define APPLESMC_DATA_PORT 0x300
|
||||||
|
+#define APPLESMC_DATA_PORT 0
|
||||||
|
/* command/status port used by Apple SMC */
|
||||||
|
-#define APPLESMC_CMD_PORT 0x304
|
||||||
|
+#define APPLESMC_CMD_PORT 4
|
||||||
|
|
||||||
|
#define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
|
||||||
|
|
||||||
|
@@ -140,6 +141,8 @@ struct applesmc_device {
|
||||||
|
struct platform_device *dev;
|
||||||
|
struct applesmc_registers reg;
|
||||||
|
|
||||||
|
+ u16 port_base;
|
||||||
|
+
|
||||||
|
s16 rest_x;
|
||||||
|
s16 rest_y;
|
||||||
|
|
||||||
|
@@ -169,7 +172,7 @@ static const int debug;
|
||||||
|
* run out past 500ms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-static int wait_status(u8 val, u8 mask)
|
||||||
|
+static int wait_status(struct applesmc_device *smc, u8 val, u8 mask)
|
||||||
|
{
|
||||||
|
u8 status;
|
||||||
|
int us;
|
||||||
|
@@ -177,7 +180,7 @@ static int wait_status(u8 val, u8 mask)
|
||||||
|
|
||||||
|
us = APPLESMC_MIN_WAIT;
|
||||||
|
for (i = 0; i < 24 ; i++) {
|
||||||
|
- status = inb(APPLESMC_CMD_PORT);
|
||||||
|
+ status = inb(smc->port_base + APPLESMC_CMD_PORT);
|
||||||
|
if ((status & mask) == val)
|
||||||
|
return 0;
|
||||||
|
usleep_range(us, us * 2);
|
||||||
|
@@ -189,11 +192,11 @@ static int wait_status(u8 val, u8 mask)
|
||||||
|
|
||||||
|
/* send_byte - Write to SMC data port. Callers must hold applesmc_lock. */
|
||||||
|
|
||||||
|
-static int send_byte(u8 cmd, u16 port)
|
||||||
|
+static int send_byte(struct applesmc_device *smc, u8 cmd, u16 port)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
- status = wait_status(0, SMC_STATUS_IB_CLOSED);
|
||||||
|
+ status = wait_status(smc, 0, SMC_STATUS_IB_CLOSED);
|
||||||
|
if (status)
|
||||||
|
return status;
|
||||||
|
/*
|
||||||
|
@@ -202,24 +205,24 @@ static int send_byte(u8 cmd, u16 port)
|
||||||
|
* this extra read may not happen if status returns both
|
||||||
|
* simultaneously and this would appear to be required.
|
||||||
|
*/
|
||||||
|
- status = wait_status(SMC_STATUS_BUSY, SMC_STATUS_BUSY);
|
||||||
|
+ status = wait_status(smc, SMC_STATUS_BUSY, SMC_STATUS_BUSY);
|
||||||
|
if (status)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
- outb(cmd, port);
|
||||||
|
+ outb(cmd, smc->port_base + port);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* send_command - Write a command to the SMC. Callers must hold applesmc_lock. */
|
||||||
|
|
||||||
|
-static int send_command(u8 cmd)
|
||||||
|
+static int send_command(struct applesmc_device *smc, u8 cmd)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = wait_status(0, SMC_STATUS_IB_CLOSED);
|
||||||
|
+ ret = wait_status(smc, 0, SMC_STATUS_IB_CLOSED);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
- outb(cmd, APPLESMC_CMD_PORT);
|
||||||
|
+ outb(cmd, smc->port_base + APPLESMC_CMD_PORT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -229,108 +232,112 @@ static int send_command(u8 cmd)
|
||||||
|
* If busy is stuck high after the command then the SMC is jammed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-static int smc_sane(void)
|
||||||
|
+static int smc_sane(struct applesmc_device *smc)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = wait_status(0, SMC_STATUS_BUSY);
|
||||||
|
+ ret = wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
if (!ret)
|
||||||
|
return ret;
|
||||||
|
- ret = send_command(APPLESMC_READ_CMD);
|
||||||
|
+ ret = send_command(smc, APPLESMC_READ_CMD);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
- return wait_status(0, SMC_STATUS_BUSY);
|
||||||
|
+ return wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int send_argument(const char *key)
|
||||||
|
+static int send_argument(struct applesmc_device *smc, const char *key)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
- if (send_byte(key[i], APPLESMC_DATA_PORT))
|
||||||
|
+ if (send_byte(smc, key[i], APPLESMC_DATA_PORT))
|
||||||
|
return -EIO;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int read_smc(u8 cmd, const char *key, u8 *buffer, u8 len)
|
||||||
|
+static int read_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
+ u8 *buffer, u8 len)
|
||||||
|
{
|
||||||
|
u8 status, data = 0;
|
||||||
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = smc_sane();
|
||||||
|
+ ret = smc_sane(smc);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (send_command(cmd) || send_argument(key)) {
|
||||||
|
+ if (send_command(smc, cmd) || send_argument(smc, key)) {
|
||||||
|
pr_warn("%.4s: read arg fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This has no effect on newer (2012) SMCs */
|
||||||
|
- if (send_byte(len, APPLESMC_DATA_PORT)) {
|
||||||
|
+ if (send_byte(smc, len, APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%.4s: read len fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
- if (wait_status(SMC_STATUS_AWAITING_DATA | SMC_STATUS_BUSY,
|
||||||
|
+ if (wait_status(smc,
|
||||||
|
+ SMC_STATUS_AWAITING_DATA | SMC_STATUS_BUSY,
|
||||||
|
SMC_STATUS_AWAITING_DATA | SMC_STATUS_BUSY)) {
|
||||||
|
pr_warn("%.4s: read data[%d] fail\n", key, i);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
- buffer[i] = inb(APPLESMC_DATA_PORT);
|
||||||
|
+ buffer[i] = inb(smc->port_base + APPLESMC_DATA_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read the data port until bit0 is cleared */
|
||||||
|
for (i = 0; i < 16; i++) {
|
||||||
|
udelay(APPLESMC_MIN_WAIT);
|
||||||
|
- status = inb(APPLESMC_CMD_PORT);
|
||||||
|
+ status = inb(smc->port_base + APPLESMC_CMD_PORT);
|
||||||
|
if (!(status & SMC_STATUS_AWAITING_DATA))
|
||||||
|
break;
|
||||||
|
- data = inb(APPLESMC_DATA_PORT);
|
||||||
|
+ data = inb(smc->port_base + APPLESMC_DATA_PORT);
|
||||||
|
}
|
||||||
|
if (i)
|
||||||
|
pr_warn("flushed %d bytes, last value is: %d\n", i, data);
|
||||||
|
|
||||||
|
- return wait_status(0, SMC_STATUS_BUSY);
|
||||||
|
+ return wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int write_smc(u8 cmd, const char *key, const u8 *buffer, u8 len)
|
||||||
|
+static int write_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
+ const u8 *buffer, u8 len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = smc_sane();
|
||||||
|
+ ret = smc_sane(smc);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (send_command(cmd) || send_argument(key)) {
|
||||||
|
+ if (send_command(smc, cmd) || send_argument(smc, key)) {
|
||||||
|
pr_warn("%s: write arg fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (send_byte(len, APPLESMC_DATA_PORT)) {
|
||||||
|
+ if (send_byte(smc, len, APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%.4s: write len fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
- if (send_byte(buffer[i], APPLESMC_DATA_PORT)) {
|
||||||
|
+ if (send_byte(smc, buffer[i], APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%s: write data fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- return wait_status(0, SMC_STATUS_BUSY);
|
||||||
|
+ return wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int read_register_count(unsigned int *count)
|
||||||
|
+static int read_register_count(struct applesmc_device *smc,
|
||||||
|
+ unsigned int *count)
|
||||||
|
{
|
||||||
|
__be32 be;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = read_smc(APPLESMC_READ_CMD, KEY_COUNT_KEY, (u8 *)&be, 4);
|
||||||
|
+ ret = read_smc(smc, APPLESMC_READ_CMD, KEY_COUNT_KEY, (u8 *)&be, 4);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
@@ -353,7 +360,7 @@ static int applesmc_read_entry(struct applesmc_device *smc,
|
||||||
|
if (entry->len != len)
|
||||||
|
return -EINVAL;
|
||||||
|
mutex_lock(&smc->reg.mutex);
|
||||||
|
- ret = read_smc(APPLESMC_READ_CMD, entry->key, buf, len);
|
||||||
|
+ ret = read_smc(smc, APPLESMC_READ_CMD, entry->key, buf, len);
|
||||||
|
mutex_unlock(&smc->reg.mutex);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
@@ -367,7 +374,7 @@ static int applesmc_write_entry(struct applesmc_device *smc,
|
||||||
|
if (entry->len != len)
|
||||||
|
return -EINVAL;
|
||||||
|
mutex_lock(&smc->reg.mutex);
|
||||||
|
- ret = write_smc(APPLESMC_WRITE_CMD, entry->key, buf, len);
|
||||||
|
+ ret = write_smc(smc, APPLESMC_WRITE_CMD, entry->key, buf, len);
|
||||||
|
mutex_unlock(&smc->reg.mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -388,10 +395,10 @@ static const struct applesmc_entry *applesmc_get_entry_by_index(
|
||||||
|
if (cache->valid)
|
||||||
|
goto out;
|
||||||
|
be = cpu_to_be32(index);
|
||||||
|
- ret = read_smc(APPLESMC_GET_KEY_BY_INDEX_CMD, (u8 *)&be, key, 4);
|
||||||
|
+ ret = read_smc(smc, APPLESMC_GET_KEY_BY_INDEX_CMD, (u8 *)&be, key, 4);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
- ret = read_smc(APPLESMC_GET_KEY_TYPE_CMD, key, info, 6);
|
||||||
|
+ ret = read_smc(smc, APPLESMC_GET_KEY_TYPE_CMD, key, info, 6);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
@@ -589,7 +596,7 @@ static int applesmc_init_smcreg_try(struct applesmc_device *smc)
|
||||||
|
if (s->init_complete)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- ret = read_register_count(&count);
|
||||||
|
+ ret = read_register_count(smc, &count);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
@@ -1468,7 +1475,7 @@ static int __init applesmc_init(void)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!request_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS,
|
||||||
|
+ if (!request_region(APPLESMC_PORT_BASE, APPLESMC_NR_PORTS,
|
||||||
|
"applesmc")) {
|
||||||
|
ret = -ENXIO;
|
||||||
|
goto out;
|
||||||
|
@@ -1490,7 +1497,7 @@ static int __init applesmc_init(void)
|
||||||
|
out_driver:
|
||||||
|
platform_driver_unregister(&applesmc_driver);
|
||||||
|
out_region:
|
||||||
|
- release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
|
||||||
|
+ release_region(APPLESMC_PORT_BASE, APPLESMC_NR_PORTS);
|
||||||
|
out:
|
||||||
|
pr_warn("driver init failed (ret=%d)!\n", ret);
|
||||||
|
return ret;
|
||||||
|
@@ -1500,7 +1507,7 @@ static void __exit applesmc_exit(void)
|
||||||
|
{
|
||||||
|
platform_device_unregister(pdev);
|
||||||
|
platform_driver_unregister(&applesmc_driver);
|
||||||
|
- release_region(APPLESMC_DATA_PORT, APPLESMC_NR_PORTS);
|
||||||
|
+ release_region(APPLESMC_PORT_BASE, APPLESMC_NR_PORTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
module_init(applesmc_init);
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
From ee3d4bf4a01bc94553bde2ae3e806a63a13faa12 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Pawlowski <paul@mrarm.io>
|
||||||
|
Date: Sun, 17 Nov 2019 23:12:08 +0100
|
||||||
|
Subject: [PATCH 3/6] applesmc: switch to acpi_device (from platform)
|
||||||
|
|
||||||
|
This change makes the change from platform_device
|
||||||
|
to acpi_device. The rationale for this change is
|
||||||
|
that on T2 Macs, an additional FixedMemory32
|
||||||
|
region is needed for device operation, and it can
|
||||||
|
be easily resolved via ACPI tables (this will be
|
||||||
|
done in another commit).
|
||||||
|
|
||||||
|
Additionally, on older Macs, the OS X driver also
|
||||||
|
looks for the specified ACPI device to resolve
|
||||||
|
its memory regions, and therefore this change
|
||||||
|
should not result in any incompatibilities.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 125 ++++++++++++++++++++++++++-------------
|
||||||
|
1 file changed, 85 insertions(+), 40 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 39ed0bb21365..bdaaf696f7b6 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -19,7 +19,7 @@
|
||||||
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||||
|
|
||||||
|
#include <linux/delay.h>
|
||||||
|
-#include <linux/platform_device.h>
|
||||||
|
+#include <linux/acpi.h>
|
||||||
|
#include <linux/input.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
@@ -35,7 +35,6 @@
|
||||||
|
#include <linux/err.h>
|
||||||
|
#include <linux/bits.h>
|
||||||
|
|
||||||
|
-#define APPLESMC_PORT_BASE 0x300
|
||||||
|
/* data port used by Apple SMC */
|
||||||
|
#define APPLESMC_DATA_PORT 0
|
||||||
|
/* command/status port used by Apple SMC */
|
||||||
|
@@ -138,9 +137,10 @@ struct applesmc_registers {
|
||||||
|
};
|
||||||
|
|
||||||
|
struct applesmc_device {
|
||||||
|
- struct platform_device *dev;
|
||||||
|
+ struct acpi_device *dev;
|
||||||
|
struct applesmc_registers reg;
|
||||||
|
|
||||||
|
+ bool port_base_set;
|
||||||
|
u16 port_base;
|
||||||
|
|
||||||
|
s16 rest_x;
|
||||||
|
@@ -692,9 +692,13 @@ static int applesmc_init_smcreg(struct applesmc_device *smc)
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Device model stuff */
|
||||||
|
+
|
||||||
|
+static int applesmc_init_resources(struct applesmc_device *smc);
|
||||||
|
+static void applesmc_free_resources(struct applesmc_device *smc);
|
||||||
|
static int applesmc_create_modules(struct applesmc_device *smc);
|
||||||
|
static void applesmc_destroy_modules(struct applesmc_device *smc);
|
||||||
|
-static int applesmc_probe(struct platform_device *dev)
|
||||||
|
+
|
||||||
|
+static int applesmc_add(struct acpi_device *dev)
|
||||||
|
{
|
||||||
|
struct applesmc_device *smc;
|
||||||
|
int ret;
|
||||||
|
@@ -705,12 +709,16 @@ static int applesmc_probe(struct platform_device *dev)
|
||||||
|
smc->dev = dev;
|
||||||
|
mutex_init(&smc->reg.mutex);
|
||||||
|
|
||||||
|
- platform_set_drvdata(dev, smc);
|
||||||
|
+ dev_set_drvdata(&dev->dev, smc);
|
||||||
|
|
||||||
|
- ret = applesmc_init_smcreg(smc);
|
||||||
|
+ ret = applesmc_init_resources(smc);
|
||||||
|
if (ret)
|
||||||
|
goto out_mem;
|
||||||
|
|
||||||
|
+ ret = applesmc_init_smcreg(smc);
|
||||||
|
+ if (ret)
|
||||||
|
+ goto out_res;
|
||||||
|
+
|
||||||
|
applesmc_device_init(smc);
|
||||||
|
|
||||||
|
ret = applesmc_create_modules(smc);
|
||||||
|
@@ -721,20 +729,23 @@ static int applesmc_probe(struct platform_device *dev)
|
||||||
|
|
||||||
|
out_reg:
|
||||||
|
applesmc_destroy_smcreg(smc);
|
||||||
|
+out_res:
|
||||||
|
+ applesmc_free_resources(smc);
|
||||||
|
out_mem:
|
||||||
|
- platform_set_drvdata(dev, NULL);
|
||||||
|
+ dev_set_drvdata(&dev->dev, NULL);
|
||||||
|
mutex_destroy(&smc->reg.mutex);
|
||||||
|
kfree(smc);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int applesmc_remove(struct platform_device *dev)
|
||||||
|
+static int applesmc_remove(struct acpi_device *dev)
|
||||||
|
{
|
||||||
|
- struct applesmc_device *smc = platform_get_drvdata(dev);
|
||||||
|
+ struct applesmc_device *smc = dev_get_drvdata(&dev->dev);
|
||||||
|
|
||||||
|
applesmc_destroy_modules(smc);
|
||||||
|
applesmc_destroy_smcreg(smc);
|
||||||
|
+ applesmc_free_resources(smc);
|
||||||
|
|
||||||
|
mutex_destroy(&smc->reg.mutex);
|
||||||
|
kfree(smc);
|
||||||
|
@@ -742,6 +753,52 @@ static int applesmc_remove(struct platform_device *dev)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static acpi_status applesmc_walk_resources(struct acpi_resource *res,
|
||||||
|
+ void *data)
|
||||||
|
+{
|
||||||
|
+ struct applesmc_device *smc = data;
|
||||||
|
+
|
||||||
|
+ switch (res->type) {
|
||||||
|
+ case ACPI_RESOURCE_TYPE_IO:
|
||||||
|
+ if (!smc->port_base_set) {
|
||||||
|
+ if (res->data.io.address_length < APPLESMC_NR_PORTS)
|
||||||
|
+ return AE_ERROR;
|
||||||
|
+ smc->port_base = res->data.io.minimum;
|
||||||
|
+ smc->port_base_set = true;
|
||||||
|
+ }
|
||||||
|
+ return AE_OK;
|
||||||
|
+
|
||||||
|
+ case ACPI_RESOURCE_TYPE_END_TAG:
|
||||||
|
+ if (smc->port_base_set)
|
||||||
|
+ return AE_OK;
|
||||||
|
+ else
|
||||||
|
+ return AE_NOT_FOUND;
|
||||||
|
+
|
||||||
|
+ default:
|
||||||
|
+ return AE_OK;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int applesmc_init_resources(struct applesmc_device *smc)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+
|
||||||
|
+ ret = acpi_walk_resources(smc->dev->handle, METHOD_NAME__CRS,
|
||||||
|
+ applesmc_walk_resources, smc);
|
||||||
|
+ if (ACPI_FAILURE(ret))
|
||||||
|
+ return -ENXIO;
|
||||||
|
+
|
||||||
|
+ if (!request_region(smc->port_base, APPLESMC_NR_PORTS, "applesmc"))
|
||||||
|
+ return -ENXIO;
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void applesmc_free_resources(struct applesmc_device *smc)
|
||||||
|
+{
|
||||||
|
+ release_region(smc->port_base, APPLESMC_NR_PORTS);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* Synchronize device with memorized backlight state */
|
||||||
|
static int applesmc_pm_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
@@ -763,18 +820,28 @@ static int applesmc_pm_restore(struct device *dev)
|
||||||
|
return applesmc_pm_resume(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static const struct acpi_device_id applesmc_ids[] = {
|
||||||
|
+ {"APP0001", 0},
|
||||||
|
+ {"", 0},
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static const struct dev_pm_ops applesmc_pm_ops = {
|
||||||
|
.resume = applesmc_pm_resume,
|
||||||
|
.restore = applesmc_pm_restore,
|
||||||
|
};
|
||||||
|
|
||||||
|
-static struct platform_driver applesmc_driver = {
|
||||||
|
- .probe = applesmc_probe,
|
||||||
|
- .remove = applesmc_remove,
|
||||||
|
- .driver = {
|
||||||
|
- .name = "applesmc",
|
||||||
|
- .pm = &applesmc_pm_ops,
|
||||||
|
+static struct acpi_driver applesmc_driver = {
|
||||||
|
+ .name = "applesmc",
|
||||||
|
+ .class = "applesmc",
|
||||||
|
+ .ids = applesmc_ids,
|
||||||
|
+ .ops = {
|
||||||
|
+ .add = applesmc_add,
|
||||||
|
+ .remove = applesmc_remove
|
||||||
|
},
|
||||||
|
+ .drv = {
|
||||||
|
+ .pm = &applesmc_pm_ops
|
||||||
|
+ },
|
||||||
|
+ .owner = THIS_MODULE
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -1262,7 +1329,6 @@ static int applesmc_create_nodes(struct applesmc_device *smc,
|
||||||
|
static int applesmc_create_accelerometer(struct applesmc_device *smc)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
-
|
||||||
|
if (!smc->reg.has_accelerometer)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
@@ -1463,8 +1529,6 @@ static void applesmc_destroy_modules(struct applesmc_device *smc)
|
||||||
|
applesmc_destroy_nodes(smc, info_group);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static struct platform_device *pdev;
|
||||||
|
-
|
||||||
|
static int __init applesmc_init(void)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
@@ -1475,29 +1539,12 @@ static int __init applesmc_init(void)
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (!request_region(APPLESMC_PORT_BASE, APPLESMC_NR_PORTS,
|
||||||
|
- "applesmc")) {
|
||||||
|
- ret = -ENXIO;
|
||||||
|
- goto out;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- ret = platform_driver_register(&applesmc_driver);
|
||||||
|
+ ret = acpi_bus_register_driver(&applesmc_driver);
|
||||||
|
if (ret)
|
||||||
|
- goto out_region;
|
||||||
|
-
|
||||||
|
- pdev = platform_device_register_simple("applesmc", APPLESMC_DATA_PORT,
|
||||||
|
- NULL, 0);
|
||||||
|
- if (IS_ERR(pdev)) {
|
||||||
|
- ret = PTR_ERR(pdev);
|
||||||
|
- goto out_driver;
|
||||||
|
- }
|
||||||
|
+ goto out;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
-out_driver:
|
||||||
|
- platform_driver_unregister(&applesmc_driver);
|
||||||
|
-out_region:
|
||||||
|
- release_region(APPLESMC_PORT_BASE, APPLESMC_NR_PORTS);
|
||||||
|
out:
|
||||||
|
pr_warn("driver init failed (ret=%d)!\n", ret);
|
||||||
|
return ret;
|
||||||
|
@@ -1505,9 +1552,7 @@ static int __init applesmc_init(void)
|
||||||
|
|
||||||
|
static void __exit applesmc_exit(void)
|
||||||
|
{
|
||||||
|
- platform_device_unregister(pdev);
|
||||||
|
- platform_driver_unregister(&applesmc_driver);
|
||||||
|
- release_region(APPLESMC_PORT_BASE, APPLESMC_NR_PORTS);
|
||||||
|
+ acpi_bus_unregister_driver(&applesmc_driver);
|
||||||
|
}
|
||||||
|
|
||||||
|
module_init(applesmc_init);
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,298 @@
|
|||||||
|
From 43df89a1377782788760808d8ea4bcf0730effbb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Pawlowski <paul@mrarm.io>
|
||||||
|
Date: Sun, 17 Nov 2019 23:12:14 +0100
|
||||||
|
Subject: [PATCH 4/6] applesmc: key interface wrappers
|
||||||
|
|
||||||
|
This change replaces the read_smc and write_smc
|
||||||
|
methods with wrappers, additionally removing the
|
||||||
|
command id parameter from them (and introducing
|
||||||
|
get_smc_key_by_index and get_smc_key_info).
|
||||||
|
|
||||||
|
This is done as to allow simple implementation
|
||||||
|
replacement on T2 Macs. The newly introduced
|
||||||
|
methods mentioned in the previous paragraph need
|
||||||
|
special handling on T2 and as such had to be
|
||||||
|
separated.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 119 ++++++++++++++++++++++++++-------------
|
||||||
|
1 file changed, 79 insertions(+), 40 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index bdaaf696f7b6..3017d8ca2c79 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -172,7 +172,7 @@ static const int debug;
|
||||||
|
* run out past 500ms.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-static int wait_status(struct applesmc_device *smc, u8 val, u8 mask)
|
||||||
|
+static int port_wait_status(struct applesmc_device *smc, u8 val, u8 mask)
|
||||||
|
{
|
||||||
|
u8 status;
|
||||||
|
int us;
|
||||||
|
@@ -190,13 +190,13 @@ static int wait_status(struct applesmc_device *smc, u8 val, u8 mask)
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* send_byte - Write to SMC data port. Callers must hold applesmc_lock. */
|
||||||
|
+/* port_send_byte - Write to SMC data port. Callers must hold applesmc_lock. */
|
||||||
|
|
||||||
|
-static int send_byte(struct applesmc_device *smc, u8 cmd, u16 port)
|
||||||
|
+static int port_send_byte(struct applesmc_device *smc, u8 cmd, u16 port)
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
|
||||||
|
- status = wait_status(smc, 0, SMC_STATUS_IB_CLOSED);
|
||||||
|
+ status = port_wait_status(smc, 0, SMC_STATUS_IB_CLOSED);
|
||||||
|
if (status)
|
||||||
|
return status;
|
||||||
|
/*
|
||||||
|
@@ -205,7 +205,7 @@ static int send_byte(struct applesmc_device *smc, u8 cmd, u16 port)
|
||||||
|
* this extra read may not happen if status returns both
|
||||||
|
* simultaneously and this would appear to be required.
|
||||||
|
*/
|
||||||
|
- status = wait_status(smc, SMC_STATUS_BUSY, SMC_STATUS_BUSY);
|
||||||
|
+ status = port_wait_status(smc, SMC_STATUS_BUSY, SMC_STATUS_BUSY);
|
||||||
|
if (status)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
@@ -213,15 +213,16 @@ static int send_byte(struct applesmc_device *smc, u8 cmd, u16 port)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* send_command - Write a command to the SMC. Callers must hold applesmc_lock. */
|
||||||
|
+/* port_send_command - Write a command to the SMC. Callers must hold applesmc_lock. */
|
||||||
|
|
||||||
|
-static int send_command(struct applesmc_device *smc, u8 cmd)
|
||||||
|
+static int port_send_command(struct applesmc_device *smc, u8 cmd)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = wait_status(smc, 0, SMC_STATUS_IB_CLOSED);
|
||||||
|
+ ret = port_wait_status(smc, 0, SMC_STATUS_IB_CLOSED);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
+
|
||||||
|
outb(cmd, smc->port_base + APPLESMC_CMD_PORT);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -232,53 +233,53 @@ static int send_command(struct applesmc_device *smc, u8 cmd)
|
||||||
|
* If busy is stuck high after the command then the SMC is jammed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
-static int smc_sane(struct applesmc_device *smc)
|
||||||
|
+static int port_smc_sane(struct applesmc_device *smc)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
+ ret = port_wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
if (!ret)
|
||||||
|
return ret;
|
||||||
|
- ret = send_command(smc, APPLESMC_READ_CMD);
|
||||||
|
+ ret = port_send_command(smc, APPLESMC_READ_CMD);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
- return wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
+ return port_wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int send_argument(struct applesmc_device *smc, const char *key)
|
||||||
|
+static int port_send_argument(struct applesmc_device *smc, const char *key)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
- if (send_byte(smc, key[i], APPLESMC_DATA_PORT))
|
||||||
|
+ if (port_send_byte(smc, key[i], APPLESMC_DATA_PORT))
|
||||||
|
return -EIO;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int read_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
+static int port_read_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
u8 *buffer, u8 len)
|
||||||
|
{
|
||||||
|
u8 status, data = 0;
|
||||||
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = smc_sane(smc);
|
||||||
|
+ ret = port_smc_sane(smc);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (send_command(smc, cmd) || send_argument(smc, key)) {
|
||||||
|
+ if (port_send_command(smc, cmd) || port_send_argument(smc, key)) {
|
||||||
|
pr_warn("%.4s: read arg fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This has no effect on newer (2012) SMCs */
|
||||||
|
- if (send_byte(smc, len, APPLESMC_DATA_PORT)) {
|
||||||
|
+ if (port_send_byte(smc, len, APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%.4s: read len fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
- if (wait_status(smc,
|
||||||
|
+ if (port_wait_status(smc,
|
||||||
|
SMC_STATUS_AWAITING_DATA | SMC_STATUS_BUSY,
|
||||||
|
SMC_STATUS_AWAITING_DATA | SMC_STATUS_BUSY)) {
|
||||||
|
pr_warn("%.4s: read data[%d] fail\n", key, i);
|
||||||
|
@@ -298,37 +299,80 @@ static int read_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
if (i)
|
||||||
|
pr_warn("flushed %d bytes, last value is: %d\n", i, data);
|
||||||
|
|
||||||
|
- return wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
+ return port_wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int write_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
+static int port_write_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
const u8 *buffer, u8 len)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = smc_sane(smc);
|
||||||
|
+ ret = port_smc_sane(smc);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- if (send_command(smc, cmd) || send_argument(smc, key)) {
|
||||||
|
+ if (port_send_command(smc, cmd) || port_send_argument(smc, key)) {
|
||||||
|
pr_warn("%s: write arg fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (send_byte(smc, len, APPLESMC_DATA_PORT)) {
|
||||||
|
+ if (port_send_byte(smc, len, APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%.4s: write len fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
- if (send_byte(smc, buffer[i], APPLESMC_DATA_PORT)) {
|
||||||
|
+ if (port_send_byte(smc, buffer[i], APPLESMC_DATA_PORT)) {
|
||||||
|
pr_warn("%s: write data fail\n", key);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- return wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
+ return port_wait_status(smc, 0, SMC_STATUS_BUSY);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int port_get_smc_key_info(struct applesmc_device *smc,
|
||||||
|
+ const char *key, struct applesmc_entry *info)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+ u8 raw[6];
|
||||||
|
+
|
||||||
|
+ ret = port_read_smc(smc, APPLESMC_GET_KEY_TYPE_CMD, key, raw, 6);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+ info->len = raw[0];
|
||||||
|
+ memcpy(info->type, &raw[1], 4);
|
||||||
|
+ info->flags = raw[5];
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int read_smc(struct applesmc_device *smc, const char *key,
|
||||||
|
+ u8 *buffer, u8 len)
|
||||||
|
+{
|
||||||
|
+ return port_read_smc(smc, APPLESMC_READ_CMD, key, buffer, len);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int write_smc(struct applesmc_device *smc, const char *key,
|
||||||
|
+ const u8 *buffer, u8 len)
|
||||||
|
+{
|
||||||
|
+ return port_write_smc(smc, APPLESMC_WRITE_CMD, key, buffer, len);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int get_smc_key_by_index(struct applesmc_device *smc,
|
||||||
|
+ unsigned int index, char *key)
|
||||||
|
+{
|
||||||
|
+ __be32 be;
|
||||||
|
+
|
||||||
|
+ be = cpu_to_be32(index);
|
||||||
|
+ return port_read_smc(smc, APPLESMC_GET_KEY_BY_INDEX_CMD,
|
||||||
|
+ (const char *) &be, (u8 *) key, 4);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int get_smc_key_info(struct applesmc_device *smc, const char *key,
|
||||||
|
+ struct applesmc_entry *info)
|
||||||
|
+{
|
||||||
|
+ return port_get_smc_key_info(smc, key, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_register_count(struct applesmc_device *smc,
|
||||||
|
@@ -337,8 +381,8 @@ static int read_register_count(struct applesmc_device *smc,
|
||||||
|
__be32 be;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
- ret = read_smc(smc, APPLESMC_READ_CMD, KEY_COUNT_KEY, (u8 *)&be, 4);
|
||||||
|
- if (ret)
|
||||||
|
+ ret = read_smc(smc, KEY_COUNT_KEY, (u8 *)&be, 4);
|
||||||
|
+ if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
*count = be32_to_cpu(be);
|
||||||
|
@@ -360,7 +404,7 @@ static int applesmc_read_entry(struct applesmc_device *smc,
|
||||||
|
if (entry->len != len)
|
||||||
|
return -EINVAL;
|
||||||
|
mutex_lock(&smc->reg.mutex);
|
||||||
|
- ret = read_smc(smc, APPLESMC_READ_CMD, entry->key, buf, len);
|
||||||
|
+ ret = read_smc(smc, entry->key, buf, len);
|
||||||
|
mutex_unlock(&smc->reg.mutex);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
@@ -374,7 +418,7 @@ static int applesmc_write_entry(struct applesmc_device *smc,
|
||||||
|
if (entry->len != len)
|
||||||
|
return -EINVAL;
|
||||||
|
mutex_lock(&smc->reg.mutex);
|
||||||
|
- ret = write_smc(smc, APPLESMC_WRITE_CMD, entry->key, buf, len);
|
||||||
|
+ ret = write_smc(smc, entry->key, buf, len);
|
||||||
|
mutex_unlock(&smc->reg.mutex);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@@ -383,8 +427,7 @@ static const struct applesmc_entry *applesmc_get_entry_by_index(
|
||||||
|
struct applesmc_device *smc, int index)
|
||||||
|
{
|
||||||
|
struct applesmc_entry *cache = &smc->reg.cache[index];
|
||||||
|
- u8 key[4], info[6];
|
||||||
|
- __be32 be;
|
||||||
|
+ char key[4];
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (cache->valid)
|
||||||
|
@@ -394,18 +437,14 @@ static const struct applesmc_entry *applesmc_get_entry_by_index(
|
||||||
|
|
||||||
|
if (cache->valid)
|
||||||
|
goto out;
|
||||||
|
- be = cpu_to_be32(index);
|
||||||
|
- ret = read_smc(smc, APPLESMC_GET_KEY_BY_INDEX_CMD, (u8 *)&be, key, 4);
|
||||||
|
+ ret = get_smc_key_by_index(smc, index, key);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
- ret = read_smc(smc, APPLESMC_GET_KEY_TYPE_CMD, key, info, 6);
|
||||||
|
+ memcpy(cache->key, key, 4);
|
||||||
|
+
|
||||||
|
+ ret = get_smc_key_info(smc, key, cache);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
-
|
||||||
|
- memcpy(cache->key, key, 4);
|
||||||
|
- cache->len = info[0];
|
||||||
|
- memcpy(cache->type, &info[1], 4);
|
||||||
|
- cache->flags = info[5];
|
||||||
|
cache->valid = true;
|
||||||
|
|
||||||
|
out:
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,343 @@
|
|||||||
|
From 799e7a54c62a36007f7874c58d7dac87c9651759 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 17 Nov 2019 23:12:16 +0100
|
||||||
|
Subject: [PATCH 5/6] applesmc: basic mmio interface implementation
|
||||||
|
|
||||||
|
This change introduces a basic MMIO-based
|
||||||
|
interface implementation required to communicate
|
||||||
|
with the SMC on T2 Macs. The MMIO interface is
|
||||||
|
enabled only when it's supported on the running
|
||||||
|
system.
|
||||||
|
|
||||||
|
The MMIO interface replaces legacy port-based SMC
|
||||||
|
key reads, writes and metadata requests (getting
|
||||||
|
key by index and getting key info).
|
||||||
|
|
||||||
|
(Based on patch by @mcmrarm)
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 237 ++++++++++++++++++++++++++++++++++++++-
|
||||||
|
1 file changed, 231 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 3017d8ca2c79..2d23bb9ad9dd 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -42,6 +42,18 @@
|
||||||
|
|
||||||
|
#define APPLESMC_NR_PORTS 32 /* 0x300-0x31f */
|
||||||
|
|
||||||
|
+#define APPLESMC_IOMEM_KEY_DATA 0
|
||||||
|
+#define APPLESMC_IOMEM_KEY_STATUS 0x4005
|
||||||
|
+#define APPLESMC_IOMEM_KEY_NAME 0x78
|
||||||
|
+#define APPLESMC_IOMEM_KEY_DATA_LEN 0x7D
|
||||||
|
+#define APPLESMC_IOMEM_KEY_SMC_ID 0x7E
|
||||||
|
+#define APPLESMC_IOMEM_KEY_CMD 0x7F
|
||||||
|
+#define APPLESMC_IOMEM_MIN_SIZE 0x4006
|
||||||
|
+
|
||||||
|
+#define APPLESMC_IOMEM_KEY_TYPE_CODE 0
|
||||||
|
+#define APPLESMC_IOMEM_KEY_TYPE_DATA_LEN 5
|
||||||
|
+#define APPLESMC_IOMEM_KEY_TYPE_FLAGS 6
|
||||||
|
+
|
||||||
|
#define APPLESMC_MAX_DATA_LENGTH 32
|
||||||
|
|
||||||
|
/* Apple SMC status bits */
|
||||||
|
@@ -138,10 +150,13 @@ struct applesmc_registers {
|
||||||
|
|
||||||
|
struct applesmc_device {
|
||||||
|
struct acpi_device *dev;
|
||||||
|
+ struct device *ldev;
|
||||||
|
struct applesmc_registers reg;
|
||||||
|
|
||||||
|
- bool port_base_set;
|
||||||
|
+ bool port_base_set, iomem_base_set;
|
||||||
|
u16 port_base;
|
||||||
|
+ u8 *__iomem iomem_base;
|
||||||
|
+ u32 iomem_base_addr, iomem_base_size;
|
||||||
|
|
||||||
|
s16 rest_x;
|
||||||
|
s16 rest_y;
|
||||||
|
@@ -347,16 +362,156 @@ static int port_get_smc_key_info(struct applesmc_device *smc,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * MMIO based communication.
|
||||||
|
+ * TODO: Use updated mechanism for cmd timeout/retry
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+static void iomem_clear_status(struct applesmc_device *smc)
|
||||||
|
+{
|
||||||
|
+ if (ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_STATUS))
|
||||||
|
+ iowrite8(0, smc->iomem_base + APPLESMC_IOMEM_KEY_STATUS);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int iomem_wait_read(struct applesmc_device *smc)
|
||||||
|
+{
|
||||||
|
+ u8 status;
|
||||||
|
+ int us;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ us = APPLESMC_MIN_WAIT;
|
||||||
|
+ for (i = 0; i < 24 ; i++) {
|
||||||
|
+ status = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_STATUS);
|
||||||
|
+ if (status & 0x20)
|
||||||
|
+ return 0;
|
||||||
|
+ usleep_range(us, us * 2);
|
||||||
|
+ if (i > 9)
|
||||||
|
+ us <<= 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ dev_warn(smc->ldev, "%s... timeout\n", __func__);
|
||||||
|
+ return -EIO;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int iomem_read_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
+ u8 *buffer, u8 len)
|
||||||
|
+{
|
||||||
|
+ u8 err, remote_len;
|
||||||
|
+ u32 key_int = *((u32 *) key);
|
||||||
|
+
|
||||||
|
+ iomem_clear_status(smc);
|
||||||
|
+ iowrite32(key_int, smc->iomem_base + APPLESMC_IOMEM_KEY_NAME);
|
||||||
|
+ iowrite32(0, smc->iomem_base + APPLESMC_IOMEM_KEY_SMC_ID);
|
||||||
|
+ iowrite32(cmd, smc->iomem_base + APPLESMC_IOMEM_KEY_CMD);
|
||||||
|
+
|
||||||
|
+ if (iomem_wait_read(smc))
|
||||||
|
+ return -EIO;
|
||||||
|
+
|
||||||
|
+ err = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_CMD);
|
||||||
|
+ if (err != 0) {
|
||||||
|
+ dev_warn(smc->ldev, "read_smc_mmio(%x %8x/%.4s) failed: %u\n",
|
||||||
|
+ cmd, key_int, key, err);
|
||||||
|
+ return -EIO;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (cmd == APPLESMC_READ_CMD) {
|
||||||
|
+ remote_len = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_DATA_LEN);
|
||||||
|
+ if (remote_len != len) {
|
||||||
|
+ dev_warn(smc->ldev,
|
||||||
|
+ "read_smc_mmio(%x %8x/%.4s) failed: buffer length mismatch (remote = %u, requested = %u)\n",
|
||||||
|
+ cmd, key_int, key, remote_len, len);
|
||||||
|
+ return -EINVAL;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ remote_len = len;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ memcpy_fromio(buffer, smc->iomem_base + APPLESMC_IOMEM_KEY_DATA,
|
||||||
|
+ remote_len);
|
||||||
|
+
|
||||||
|
+ dev_dbg(smc->ldev, "read_smc_mmio(%x %8x/%.4s): buflen=%u reslen=%u\n",
|
||||||
|
+ cmd, key_int, key, len, remote_len);
|
||||||
|
+ print_hex_dump_bytes("read_smc_mmio(): ", DUMP_PREFIX_NONE, buffer, remote_len);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int iomem_get_smc_key_type(struct applesmc_device *smc, const char *key,
|
||||||
|
+ struct applesmc_entry *e)
|
||||||
|
+{
|
||||||
|
+ u8 err;
|
||||||
|
+ u8 cmd = APPLESMC_GET_KEY_TYPE_CMD;
|
||||||
|
+ u32 key_int = *((u32 *) key);
|
||||||
|
+
|
||||||
|
+ iomem_clear_status(smc);
|
||||||
|
+ iowrite32(key_int, smc->iomem_base + APPLESMC_IOMEM_KEY_NAME);
|
||||||
|
+ iowrite32(0, smc->iomem_base + APPLESMC_IOMEM_KEY_SMC_ID);
|
||||||
|
+ iowrite32(cmd, smc->iomem_base + APPLESMC_IOMEM_KEY_CMD);
|
||||||
|
+
|
||||||
|
+ if (iomem_wait_read(smc))
|
||||||
|
+ return -EIO;
|
||||||
|
+
|
||||||
|
+ err = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_CMD);
|
||||||
|
+ if (err != 0) {
|
||||||
|
+ dev_warn(smc->ldev, "get_smc_key_type_mmio(%.4s) failed: %u\n", key, err);
|
||||||
|
+ return -EIO;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ e->len = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_TYPE_DATA_LEN);
|
||||||
|
+ *((uint32_t *) e->type) = ioread32(
|
||||||
|
+ smc->iomem_base + APPLESMC_IOMEM_KEY_TYPE_CODE);
|
||||||
|
+ e->flags = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_TYPE_FLAGS);
|
||||||
|
+
|
||||||
|
+ dev_dbg(smc->ldev, "get_smc_key_type_mmio(%.4s): len=%u type=%.4s flags=%x\n",
|
||||||
|
+ key, e->len, e->type, e->flags);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int iomem_write_smc(struct applesmc_device *smc, u8 cmd, const char *key,
|
||||||
|
+ const u8 *buffer, u8 len)
|
||||||
|
+{
|
||||||
|
+ u8 err;
|
||||||
|
+ u32 key_int = *((u32 *) key);
|
||||||
|
+
|
||||||
|
+ iomem_clear_status(smc);
|
||||||
|
+ iowrite32(key_int, smc->iomem_base + APPLESMC_IOMEM_KEY_NAME);
|
||||||
|
+ memcpy_toio(smc->iomem_base + APPLESMC_IOMEM_KEY_DATA, buffer, len);
|
||||||
|
+ iowrite32(len, smc->iomem_base + APPLESMC_IOMEM_KEY_DATA_LEN);
|
||||||
|
+ iowrite32(0, smc->iomem_base + APPLESMC_IOMEM_KEY_SMC_ID);
|
||||||
|
+ iowrite32(cmd, smc->iomem_base + APPLESMC_IOMEM_KEY_CMD);
|
||||||
|
+
|
||||||
|
+ if (iomem_wait_read(smc))
|
||||||
|
+ return -EIO;
|
||||||
|
+
|
||||||
|
+ err = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_CMD);
|
||||||
|
+ if (err != 0) {
|
||||||
|
+ dev_warn(smc->ldev, "write_smc_mmio(%x %.4s) failed: %u\n", cmd, key, err);
|
||||||
|
+ print_hex_dump_bytes("write_smc_mmio(): ", DUMP_PREFIX_NONE, buffer, len);
|
||||||
|
+ return -EIO;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ dev_dbg(smc->ldev, "write_smc_mmio(%x %.4s): buflen=%u\n", cmd, key, len);
|
||||||
|
+ print_hex_dump_bytes("write_smc_mmio(): ", DUMP_PREFIX_NONE, buffer, len);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
static int read_smc(struct applesmc_device *smc, const char *key,
|
||||||
|
u8 *buffer, u8 len)
|
||||||
|
{
|
||||||
|
- return port_read_smc(smc, APPLESMC_READ_CMD, key, buffer, len);
|
||||||
|
+ if (smc->iomem_base_set)
|
||||||
|
+ return iomem_read_smc(smc, APPLESMC_READ_CMD, key, buffer, len);
|
||||||
|
+ else
|
||||||
|
+ return port_read_smc(smc, APPLESMC_READ_CMD, key, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int write_smc(struct applesmc_device *smc, const char *key,
|
||||||
|
const u8 *buffer, u8 len)
|
||||||
|
{
|
||||||
|
- return port_write_smc(smc, APPLESMC_WRITE_CMD, key, buffer, len);
|
||||||
|
+ if (smc->iomem_base_set)
|
||||||
|
+ return iomem_write_smc(smc, APPLESMC_WRITE_CMD, key, buffer, len);
|
||||||
|
+ else
|
||||||
|
+ return port_write_smc(smc, APPLESMC_WRITE_CMD, key, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_smc_key_by_index(struct applesmc_device *smc,
|
||||||
|
@@ -365,14 +520,21 @@ static int get_smc_key_by_index(struct applesmc_device *smc,
|
||||||
|
__be32 be;
|
||||||
|
|
||||||
|
be = cpu_to_be32(index);
|
||||||
|
- return port_read_smc(smc, APPLESMC_GET_KEY_BY_INDEX_CMD,
|
||||||
|
- (const char *) &be, (u8 *) key, 4);
|
||||||
|
+ if (smc->iomem_base_set)
|
||||||
|
+ return iomem_read_smc(smc, APPLESMC_GET_KEY_BY_INDEX_CMD,
|
||||||
|
+ (const char *) &be, (u8 *) key, 4);
|
||||||
|
+ else
|
||||||
|
+ return port_read_smc(smc, APPLESMC_GET_KEY_BY_INDEX_CMD,
|
||||||
|
+ (const char *) &be, (u8 *) key, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int get_smc_key_info(struct applesmc_device *smc, const char *key,
|
||||||
|
struct applesmc_entry *info)
|
||||||
|
{
|
||||||
|
- return port_get_smc_key_info(smc, key, info);
|
||||||
|
+ if (smc->iomem_base_set)
|
||||||
|
+ return iomem_get_smc_key_type(smc, key, info);
|
||||||
|
+ else
|
||||||
|
+ return port_get_smc_key_info(smc, key, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_register_count(struct applesmc_device *smc,
|
||||||
|
@@ -746,6 +908,7 @@ static int applesmc_add(struct acpi_device *dev)
|
||||||
|
if (!smc)
|
||||||
|
return -ENOMEM;
|
||||||
|
smc->dev = dev;
|
||||||
|
+ smc->ldev = &dev->dev;
|
||||||
|
mutex_init(&smc->reg.mutex);
|
||||||
|
|
||||||
|
dev_set_drvdata(&dev->dev, smc);
|
||||||
|
@@ -807,6 +970,20 @@ static acpi_status applesmc_walk_resources(struct acpi_resource *res,
|
||||||
|
}
|
||||||
|
return AE_OK;
|
||||||
|
|
||||||
|
+ case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
|
||||||
|
+ if (!smc->iomem_base_set) {
|
||||||
|
+ if (res->data.fixed_memory32.address_length <
|
||||||
|
+ APPLESMC_IOMEM_MIN_SIZE) {
|
||||||
|
+ dev_warn(smc->ldev, "found iomem but it's too small: %u\n",
|
||||||
|
+ res->data.fixed_memory32.address_length);
|
||||||
|
+ return AE_OK;
|
||||||
|
+ }
|
||||||
|
+ smc->iomem_base_addr = res->data.fixed_memory32.address;
|
||||||
|
+ smc->iomem_base_size = res->data.fixed_memory32.address_length;
|
||||||
|
+ smc->iomem_base_set = true;
|
||||||
|
+ }
|
||||||
|
+ return AE_OK;
|
||||||
|
+
|
||||||
|
case ACPI_RESOURCE_TYPE_END_TAG:
|
||||||
|
if (smc->port_base_set)
|
||||||
|
return AE_OK;
|
||||||
|
@@ -818,6 +995,8 @@ static acpi_status applesmc_walk_resources(struct acpi_resource *res,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int applesmc_try_enable_iomem(struct applesmc_device *smc);
|
||||||
|
+
|
||||||
|
static int applesmc_init_resources(struct applesmc_device *smc)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
@@ -830,11 +1009,57 @@ static int applesmc_init_resources(struct applesmc_device *smc)
|
||||||
|
if (!request_region(smc->port_base, APPLESMC_NR_PORTS, "applesmc"))
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
|
+ if (smc->iomem_base_set) {
|
||||||
|
+ if (applesmc_try_enable_iomem(smc))
|
||||||
|
+ smc->iomem_base_set = false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int applesmc_try_enable_iomem(struct applesmc_device *smc)
|
||||||
|
+{
|
||||||
|
+ u8 test_val, ldkn_version;
|
||||||
|
+
|
||||||
|
+ dev_dbg(smc->ldev, "Trying to enable iomem based communication\n");
|
||||||
|
+ smc->iomem_base = ioremap(smc->iomem_base_addr, smc->iomem_base_size);
|
||||||
|
+ if (!smc->iomem_base)
|
||||||
|
+ goto out;
|
||||||
|
+
|
||||||
|
+ /* Apple's driver does this check for some reason */
|
||||||
|
+ test_val = ioread8(smc->iomem_base + APPLESMC_IOMEM_KEY_STATUS);
|
||||||
|
+ if (test_val == 0xff) {
|
||||||
|
+ dev_warn(smc->ldev,
|
||||||
|
+ "iomem enable failed: initial status is 0xff (is %x)\n",
|
||||||
|
+ test_val);
|
||||||
|
+ goto out_iomem;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (read_smc(smc, "LDKN", &ldkn_version, 1)) {
|
||||||
|
+ dev_warn(smc->ldev, "iomem enable failed: ldkn read failed\n");
|
||||||
|
+ goto out_iomem;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (ldkn_version < 2) {
|
||||||
|
+ dev_warn(smc->ldev,
|
||||||
|
+ "iomem enable failed: ldkn version %u is less than minimum (2)\n",
|
||||||
|
+ ldkn_version);
|
||||||
|
+ goto out_iomem;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+out_iomem:
|
||||||
|
+ iounmap(smc->iomem_base);
|
||||||
|
+
|
||||||
|
+out:
|
||||||
|
+ return -ENXIO;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void applesmc_free_resources(struct applesmc_device *smc)
|
||||||
|
{
|
||||||
|
+ if (smc->iomem_base_set)
|
||||||
|
+ iounmap(smc->iomem_base);
|
||||||
|
release_region(smc->port_base, APPLESMC_NR_PORTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
From 4e63e9b77422aae8e7411ddc7a8458c2585c86df Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Pawlowski <paul@mrarm.io>
|
||||||
|
Date: Sun, 17 Nov 2019 23:12:18 +0100
|
||||||
|
Subject: [PATCH 6/6] applesmc: fan support on T2 Macs
|
||||||
|
|
||||||
|
T2 Macs changed the fan values from shorts to
|
||||||
|
floats, and changed the fan manual override
|
||||||
|
setting from a bitmask to a per-fan boolean
|
||||||
|
named F0Md (thanks to @kleuter for mentioning
|
||||||
|
it).
|
||||||
|
|
||||||
|
A minimal soft-float implementation has been
|
||||||
|
written for convert floats to integers (and vice
|
||||||
|
versa).
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hwmon/applesmc.c | 119 +++++++++++++++++++++++++++++++++------
|
||||||
|
1 file changed, 102 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
|
||||||
|
index 2d23bb9ad9dd..0938227be612 100644
|
||||||
|
--- a/drivers/hwmon/applesmc.c
|
||||||
|
+++ b/drivers/hwmon/applesmc.c
|
||||||
|
@@ -87,6 +87,7 @@
|
||||||
|
#define FAN_ID_FMT "F%dID" /* r-o char[16] */
|
||||||
|
|
||||||
|
#define TEMP_SENSOR_TYPE "sp78"
|
||||||
|
+#define FLOAT_TYPE "flt "
|
||||||
|
|
||||||
|
/* List of keys used to read/write fan speeds */
|
||||||
|
static const char *const fan_speed_fmt[] = {
|
||||||
|
@@ -96,6 +97,7 @@ static const char *const fan_speed_fmt[] = {
|
||||||
|
"F%dSf", /* safe speed - not all models */
|
||||||
|
"F%dTg", /* target speed (manual: rw) */
|
||||||
|
};
|
||||||
|
+#define FAN_MANUAL_FMT "F%dMd"
|
||||||
|
|
||||||
|
#define INIT_TIMEOUT_MSECS 5000 /* wait up to 5s for device init ... */
|
||||||
|
#define INIT_WAIT_MSECS 50 /* ... in 50ms increments */
|
||||||
|
@@ -734,6 +736,42 @@ static int applesmc_read_s16(struct applesmc_device *smc,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+/**
|
||||||
|
+ * applesmc_float_to_u32 - Retrieve the integral part of a float.
|
||||||
|
+ * This is needed because Apple made fans use float values in the T2.
|
||||||
|
+ * The fractional point is not significantly useful though, and the integral
|
||||||
|
+ * part can be easily extracted.
|
||||||
|
+ */
|
||||||
|
+static inline u32 applesmc_float_to_u32(u32 d)
|
||||||
|
+{
|
||||||
|
+ u8 sign = (u8) ((d >> 31) & 1);
|
||||||
|
+ s32 exp = (s32) ((d >> 23) & 0xff) - 0x7f;
|
||||||
|
+ u32 fr = d & ((1u << 23) - 1);
|
||||||
|
+
|
||||||
|
+ if (sign || exp < 0)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ return (u32) ((1u << exp) + (fr >> (23 - exp)));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/**
|
||||||
|
+ * applesmc_u32_to_float - Convert an u32 into a float.
|
||||||
|
+ * See applesmc_float_to_u32 for a rationale.
|
||||||
|
+ */
|
||||||
|
+static inline u32 applesmc_u32_to_float(u32 d)
|
||||||
|
+{
|
||||||
|
+ u32 dc = d, bc = 0, exp;
|
||||||
|
+
|
||||||
|
+ if (!d)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ while (dc >>= 1)
|
||||||
|
+ ++bc;
|
||||||
|
+ exp = 0x7f + bc;
|
||||||
|
+
|
||||||
|
+ return (u32) ((exp << 23) |
|
||||||
|
+ ((d << (23 - (exp - 0x7f))) & ((1u << 23) - 1)));
|
||||||
|
+}
|
||||||
|
/*
|
||||||
|
* applesmc_device_init - initialize the accelerometer. Can sleep.
|
||||||
|
*/
|
||||||
|
@@ -1242,6 +1280,7 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
|
||||||
|
struct device_attribute *attr, char *sysfsbuf)
|
||||||
|
{
|
||||||
|
struct applesmc_device *smc = dev_get_drvdata(dev);
|
||||||
|
+ const struct applesmc_entry *entry;
|
||||||
|
int ret;
|
||||||
|
unsigned int speed = 0;
|
||||||
|
char newkey[5];
|
||||||
|
@@ -1250,11 +1289,21 @@ static ssize_t applesmc_show_fan_speed(struct device *dev,
|
||||||
|
scnprintf(newkey, sizeof(newkey), fan_speed_fmt[to_option(attr)],
|
||||||
|
to_index(attr));
|
||||||
|
|
||||||
|
- ret = applesmc_read_key(smc, newkey, buffer, 2);
|
||||||
|
+ entry = applesmc_get_entry_by_key(smc, newkey);
|
||||||
|
+ if (IS_ERR(entry))
|
||||||
|
+ return PTR_ERR(entry);
|
||||||
|
+
|
||||||
|
+ if (!strcmp(entry->type, FLOAT_TYPE)) {
|
||||||
|
+ ret = applesmc_read_entry(smc, entry, (u8 *) &speed, 4);
|
||||||
|
+ speed = applesmc_float_to_u32(speed);
|
||||||
|
+ } else {
|
||||||
|
+ ret = applesmc_read_entry(smc, entry, buffer, 2);
|
||||||
|
+ speed = ((buffer[0] << 8 | buffer[1]) >> 2);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- speed = ((buffer[0] << 8 | buffer[1]) >> 2);
|
||||||
|
return sysfs_emit(sysfsbuf, "%u\n", speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1263,6 +1312,7 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
|
||||||
|
const char *sysfsbuf, size_t count)
|
||||||
|
{
|
||||||
|
struct applesmc_device *smc = dev_get_drvdata(dev);
|
||||||
|
+ const struct applesmc_entry *entry;
|
||||||
|
int ret;
|
||||||
|
unsigned long speed;
|
||||||
|
char newkey[5];
|
||||||
|
@@ -1274,9 +1324,18 @@ static ssize_t applesmc_store_fan_speed(struct device *dev,
|
||||||
|
scnprintf(newkey, sizeof(newkey), fan_speed_fmt[to_option(attr)],
|
||||||
|
to_index(attr));
|
||||||
|
|
||||||
|
- buffer[0] = (speed >> 6) & 0xff;
|
||||||
|
- buffer[1] = (speed << 2) & 0xff;
|
||||||
|
- ret = applesmc_write_key(smc, newkey, buffer, 2);
|
||||||
|
+ entry = applesmc_get_entry_by_key(smc, newkey);
|
||||||
|
+ if (IS_ERR(entry))
|
||||||
|
+ return PTR_ERR(entry);
|
||||||
|
+
|
||||||
|
+ if (!strcmp(entry->type, FLOAT_TYPE)) {
|
||||||
|
+ speed = applesmc_u32_to_float(speed);
|
||||||
|
+ ret = applesmc_write_entry(smc, entry, (u8 *) &speed, 4);
|
||||||
|
+ } else {
|
||||||
|
+ buffer[0] = (speed >> 6) & 0xff;
|
||||||
|
+ buffer[1] = (speed << 2) & 0xff;
|
||||||
|
+ ret = applesmc_write_key(smc, newkey, buffer, 2);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
@@ -1291,12 +1350,26 @@ static ssize_t applesmc_show_fan_manual(struct device *dev,
|
||||||
|
int ret;
|
||||||
|
u16 manual = 0;
|
||||||
|
u8 buffer[2];
|
||||||
|
+ char newkey[5];
|
||||||
|
+ bool has_newkey = false;
|
||||||
|
+
|
||||||
|
+ scnprintf(newkey, sizeof(newkey), FAN_MANUAL_FMT, to_index(attr));
|
||||||
|
+
|
||||||
|
+ ret = applesmc_has_key(smc, newkey, &has_newkey);
|
||||||
|
+ if (ret)
|
||||||
|
+ return ret;
|
||||||
|
+
|
||||||
|
+ if (has_newkey) {
|
||||||
|
+ ret = applesmc_read_key(smc, newkey, buffer, 1);
|
||||||
|
+ manual = buffer[0];
|
||||||
|
+ } else {
|
||||||
|
+ ret = applesmc_read_key(smc, FANS_MANUAL, buffer, 2);
|
||||||
|
+ manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- ret = applesmc_read_key(smc, FANS_MANUAL, buffer, 2);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
- manual = ((buffer[0] << 8 | buffer[1]) >> to_index(attr)) & 0x01;
|
||||||
|
return sysfs_emit(sysfsbuf, "%d\n", manual);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1307,27 +1380,39 @@ static ssize_t applesmc_store_fan_manual(struct device *dev,
|
||||||
|
struct applesmc_device *smc = dev_get_drvdata(dev);
|
||||||
|
int ret;
|
||||||
|
u8 buffer[2];
|
||||||
|
+ char newkey[5];
|
||||||
|
+ bool has_newkey = false;
|
||||||
|
unsigned long input;
|
||||||
|
u16 val;
|
||||||
|
|
||||||
|
if (kstrtoul(sysfsbuf, 10, &input) < 0)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
- ret = applesmc_read_key(smc, FANS_MANUAL, buffer, 2);
|
||||||
|
+ scnprintf(newkey, sizeof(newkey), FAN_MANUAL_FMT, to_index(attr));
|
||||||
|
+
|
||||||
|
+ ret = applesmc_has_key(smc, newkey, &has_newkey);
|
||||||
|
if (ret)
|
||||||
|
- goto out;
|
||||||
|
+ return ret;
|
||||||
|
|
||||||
|
- val = (buffer[0] << 8 | buffer[1]);
|
||||||
|
+ if (has_newkey) {
|
||||||
|
+ buffer[0] = input & 1;
|
||||||
|
+ ret = applesmc_write_key(smc, newkey, buffer, 1);
|
||||||
|
+ } else {
|
||||||
|
+ ret = applesmc_read_key(smc, FANS_MANUAL, buffer, 2);
|
||||||
|
+ val = (buffer[0] << 8 | buffer[1]);
|
||||||
|
+ if (ret)
|
||||||
|
+ goto out;
|
||||||
|
|
||||||
|
- if (input)
|
||||||
|
- val = val | (0x01 << to_index(attr));
|
||||||
|
- else
|
||||||
|
- val = val & ~(0x01 << to_index(attr));
|
||||||
|
+ if (input)
|
||||||
|
+ val = val | (0x01 << to_index(attr));
|
||||||
|
+ else
|
||||||
|
+ val = val & ~(0x01 << to_index(attr));
|
||||||
|
|
||||||
|
- buffer[0] = (val >> 8) & 0xFF;
|
||||||
|
- buffer[1] = val & 0xFF;
|
||||||
|
+ buffer[0] = (val >> 8) & 0xFF;
|
||||||
|
+ buffer[1] = val & 0xFF;
|
||||||
|
|
||||||
|
- ret = applesmc_write_key(smc, FANS_MANUAL, buffer, 2);
|
||||||
|
+ ret = applesmc_write_key(smc, FANS_MANUAL, buffer, 2);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (ret)
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,195 @@
|
|||||||
|
From a6bf93712831ea518fcd342c3720b34f96afcd78 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Paul Pawlowski <paul@mrarm.io>
|
||||||
|
Date: Sat, 30 Jan 2021 23:42:14 -0600
|
||||||
|
Subject: [PATCH 1/9] HID: apple: Add support for keyboard backlight on
|
||||||
|
supported models
|
||||||
|
|
||||||
|
This commit introduces the requisite plumbing for supporting keyboard
|
||||||
|
backlight on T2-attached, USB exposed models. The quirk mechanism was
|
||||||
|
used to reuse the existing hid-apple driver.
|
||||||
|
|
||||||
|
Devices that support this feature will be added in subsequent patches.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 124 ++++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 124 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 6b8f0d004d34..e03a621bc741 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -7,6 +7,7 @@
|
||||||
|
* Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
|
||||||
|
* Copyright (c) 2006-2007 Jiri Kosina
|
||||||
|
* Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
|
||||||
|
+ * Copyright (c) 2019 Paul Pawlowski <paul@mrarm.io>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -30,6 +31,7 @@
|
||||||
|
#define APPLE_INVERT_HWHEEL 0x0040
|
||||||
|
/* 0x0080 reserved, was: APPLE_IGNORE_HIDINPUT */
|
||||||
|
#define APPLE_NUMLOCK_EMULATION 0x0100
|
||||||
|
+#define APPLE_BACKLIGHT_CTL 0x0200
|
||||||
|
|
||||||
|
#define APPLE_FLAG_FKEY 0x01
|
||||||
|
|
||||||
|
@@ -57,11 +59,18 @@ MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
|
||||||
|
"(For people who want to keep PC keyboard muscle memory. "
|
||||||
|
"[0] = as-is, Mac layout, 1 = swapped, PC layout)");
|
||||||
|
|
||||||
|
+struct apple_sc_backlight {
|
||||||
|
+ struct led_classdev cdev;
|
||||||
|
+ struct hid_device *hdev;
|
||||||
|
+ unsigned short backlight_off, backlight_on_min, backlight_on_max;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
struct apple_sc {
|
||||||
|
unsigned long quirks;
|
||||||
|
unsigned int fn_on;
|
||||||
|
unsigned int fn_found;
|
||||||
|
DECLARE_BITMAP(pressed_numlock, KEY_CNT);
|
||||||
|
+ struct apple_sc_backlight *backlight;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct apple_key_translation {
|
||||||
|
@@ -70,6 +79,19 @@ struct apple_key_translation {
|
||||||
|
u8 flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
+struct apple_backlight_config_report {
|
||||||
|
+ u8 report_id;
|
||||||
|
+ u8 version;
|
||||||
|
+ u16 backlight_off, backlight_on_min, backlight_on_max;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+struct apple_backlight_set_report {
|
||||||
|
+ u8 report_id;
|
||||||
|
+ u8 version;
|
||||||
|
+ u16 backlight;
|
||||||
|
+ u16 rate;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static const struct apple_key_translation macbookair_fn_keys[] = {
|
||||||
|
{ KEY_BACKSPACE, KEY_DELETE },
|
||||||
|
{ KEY_ENTER, KEY_INSERT },
|
||||||
|
@@ -414,6 +436,105 @@ static int apple_input_configured(struct hid_device *hdev,
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static bool apple_backlight_check_support(struct hid_device *hdev)
|
||||||
|
+{
|
||||||
|
+ int i;
|
||||||
|
+ unsigned int hid;
|
||||||
|
+ struct hid_report *report;
|
||||||
|
+
|
||||||
|
+ list_for_each_entry(report, &hdev->report_enum[HID_INPUT_REPORT].report_list, list) {
|
||||||
|
+ for (i = 0; i < report->maxfield; i++) {
|
||||||
|
+ hid = report->field[i]->usage->hid;
|
||||||
|
+ if ((hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR && (hid & HID_USAGE) == 0xf)
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return false;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int apple_backlight_set(struct hid_device *hdev, u16 value, u16 rate)
|
||||||
|
+{
|
||||||
|
+ int ret = 0;
|
||||||
|
+ struct apple_backlight_set_report *rep;
|
||||||
|
+
|
||||||
|
+ rep = kmalloc(sizeof(*rep), GFP_KERNEL);
|
||||||
|
+ if (rep == NULL)
|
||||||
|
+ return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ rep->report_id = 0xB0;
|
||||||
|
+ rep->version = 1;
|
||||||
|
+ rep->backlight = value;
|
||||||
|
+ rep->rate = rate;
|
||||||
|
+
|
||||||
|
+ ret = hid_hw_raw_request(hdev, 0xB0u, (u8 *) rep, sizeof(*rep),
|
||||||
|
+ HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
|
||||||
|
+
|
||||||
|
+ kfree(rep);
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int apple_backlight_led_set(struct led_classdev *led_cdev,
|
||||||
|
+ enum led_brightness brightness)
|
||||||
|
+{
|
||||||
|
+ struct apple_sc_backlight *backlight = container_of(led_cdev,
|
||||||
|
+ struct apple_sc_backlight, cdev);
|
||||||
|
+
|
||||||
|
+ return apple_backlight_set(backlight->hdev, brightness, 0);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int apple_backlight_init(struct hid_device *hdev)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+ struct apple_sc *asc = hid_get_drvdata(hdev);
|
||||||
|
+ struct apple_backlight_config_report *rep;
|
||||||
|
+
|
||||||
|
+ if (!apple_backlight_check_support(hdev))
|
||||||
|
+ return -EINVAL;
|
||||||
|
+
|
||||||
|
+ rep = kmalloc(0x200, GFP_KERNEL);
|
||||||
|
+ if (rep == NULL)
|
||||||
|
+ return -ENOMEM;
|
||||||
|
+
|
||||||
|
+ ret = hid_hw_raw_request(hdev, 0xBFu, (u8 *) rep, sizeof(*rep),
|
||||||
|
+ HID_FEATURE_REPORT, HID_REQ_GET_REPORT);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ hid_err(hdev, "backlight request failed: %d\n", ret);
|
||||||
|
+ goto cleanup_and_exit;
|
||||||
|
+ }
|
||||||
|
+ if (ret < 8 || rep->version != 1) {
|
||||||
|
+ hid_err(hdev, "backlight config struct: bad version %i\n", rep->version);
|
||||||
|
+ ret = -EINVAL;
|
||||||
|
+ goto cleanup_and_exit;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ hid_dbg(hdev, "backlight config: off=%u, on_min=%u, on_max=%u\n",
|
||||||
|
+ rep->backlight_off, rep->backlight_on_min, rep->backlight_on_max);
|
||||||
|
+
|
||||||
|
+ asc->backlight = devm_kzalloc(&hdev->dev, sizeof(*asc->backlight), GFP_KERNEL);
|
||||||
|
+ if (!asc->backlight) {
|
||||||
|
+ ret = -ENOMEM;
|
||||||
|
+ goto cleanup_and_exit;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ asc->backlight->hdev = hdev;
|
||||||
|
+ asc->backlight->cdev.name = "apple::kbd_backlight";
|
||||||
|
+ asc->backlight->cdev.max_brightness = rep->backlight_on_max;
|
||||||
|
+ asc->backlight->cdev.brightness_set_blocking = apple_backlight_led_set;
|
||||||
|
+
|
||||||
|
+ ret = apple_backlight_set(hdev, 0, 0);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ hid_err(hdev, "backlight set request failed: %d\n", ret);
|
||||||
|
+ goto cleanup_and_exit;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ret = devm_led_classdev_register(&hdev->dev, &asc->backlight->cdev);
|
||||||
|
+
|
||||||
|
+cleanup_and_exit:
|
||||||
|
+ kfree(rep);
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int apple_probe(struct hid_device *hdev,
|
||||||
|
const struct hid_device_id *id)
|
||||||
|
{
|
||||||
|
@@ -449,6 +570,9 @@ static int apple_probe(struct hid_device *hdev,
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (quirks & APPLE_BACKLIGHT_CTL)
|
||||||
|
+ apple_backlight_init(hdev);
|
||||||
|
+
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
From 7d6971c788f4c89fdc43f370943bd4082be74279 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 00:39:07 -0600
|
||||||
|
Subject: [PATCH 2/9] HID: apple: Add support for MacbookAir8,1
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Air
|
||||||
|
(Retina, 13-inch, 2018) [MacBookAir8,1 J140K iBridge2,8].
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 19 +++++++++++++++++++
|
||||||
|
4 files changed, 24 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index e03a621bc741..1f923565f9e9 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -731,6 +731,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index 94180c63571e..3d22da749aa3 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -165,6 +165,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI 0x0272
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index 142e9dae2837..fdd0b212cfcb 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -289,6 +289,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -923,6 +924,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index 59a14505b9cd..bf610d2d8c69 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -83,6 +83,10 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
|
||||||
|
|
||||||
|
+/* T2-Attached Devices */
|
||||||
|
+/* MacbookAir8,1 (2018) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
+
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
USB_DEVICE_ID_MATCH_INT_CLASS | \
|
||||||
|
@@ -147,6 +151,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI),
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_ISO),
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
|
||||||
|
+ /* MacbookAir8,1 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -483,6 +489,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -203, 6803 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -6243, 6749 },
|
||||||
|
+ { SN_COORD, -170, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
From af20038d6da35329434a447d1e70c3f18a532a33 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 01:04:22 -0600
|
||||||
|
Subject: [PATCH 3/9] HID: apple: Add support for MacBookPro15,2
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Pro
|
||||||
|
(13-inch, 2019, Four Thunderbolt 3 ports) [MacBookPro15,2 J132 iBridge2,4]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 1f923565f9e9..76d6535fc663 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -733,6 +733,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index 3d22da749aa3..9741153715ff 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -166,6 +166,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_ISO 0x0273
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index fdd0b212cfcb..7df65c99e984 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -290,6 +290,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -925,6 +926,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index bf610d2d8c69..81c1dac1da81 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -86,6 +86,8 @@
|
||||||
|
/* T2-Attached Devices */
|
||||||
|
/* MacbookAir8,1 (2018) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
+/* MacbookPro15,2 (2018) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -153,6 +155,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING9_JIS),
|
||||||
|
/* MacbookAir8,1 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
|
||||||
|
+ /* MacbookPro15,2 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -502,6 +506,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -170, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -6243, 6749 },
|
||||||
|
+ { SN_COORD, -170, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
From 2e8c510fb3fe48deec46fd3be7c5838c6cd9ed74 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 01:16:37 -0600
|
||||||
|
Subject: [PATCH 4/9] HID: apple: Add support for MacBookPro15,1
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Pro
|
||||||
|
(15-inch, 2018) [MacBookPro15,1 J680 iBridge2,3]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 76d6535fc663..9ee795dcfa83 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -735,6 +735,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index 9741153715ff..b3e37a63e47e 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -167,6 +167,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRING9_JIS 0x0274
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index 7df65c99e984..32419a34a64d 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -291,6 +291,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -927,6 +928,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index 81c1dac1da81..e7280b3c1a08 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -88,6 +88,8 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
/* MacbookPro15,2 (2018) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
+/* MacbookPro15,1 (2018) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -157,6 +159,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K),
|
||||||
|
/* MacbookPro15,2 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
|
||||||
|
+ /* MacbookPro15,1 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -519,6 +523,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -170, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -7456, 7976 },
|
||||||
|
+ { SN_COORD, -1768, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
From f00e6b0e89c89233ca43348f2c74b93757cd7deb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 01:56:59 -0600
|
||||||
|
Subject: [PATCH 5/9] HID: apple: Add support for MacBookPro15,4
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Pro
|
||||||
|
(13-inch, 2019, Two Thunderbolt 3 ports) [MacBookPro15,4 J213 iBridge2,10]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 9ee795dcfa83..d59d6de017d6 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -737,6 +737,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index b3e37a63e47e..aaa7cdf96481 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -168,6 +168,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K 0x027a
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index 32419a34a64d..ee698d275427 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -292,6 +292,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -929,6 +930,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index e7280b3c1a08..3964f58fb870 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -90,6 +90,8 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
/* MacbookPro15,1 (2018) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
+/* MacbookPro15,4 (2019) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -161,6 +163,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132),
|
||||||
|
/* MacbookPro15,1 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
|
||||||
|
+ /* MacbookPro15,4 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -536,6 +540,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -1768, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -6243, 6749 },
|
||||||
|
+ { SN_COORD, -170, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
From 6ebbc10ae708e487bca63bbc59f1ba51a90e4f4c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 02:00:14 -0600
|
||||||
|
Subject: [PATCH 6/9] HID: apple: Add support for MacBookPro16,2
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Pro
|
||||||
|
(13-inch, 2020, Four Thunderbolt 3 ports) [MacBookPro16,2 J214K
|
||||||
|
iBridge2,16]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index d59d6de017d6..4d1b88b57142 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -739,6 +739,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index aaa7cdf96481..861069c765c7 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -169,6 +169,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 0x027b
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index ee698d275427..d15b6fe0c8c2 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -293,6 +293,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -931,6 +932,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index 3964f58fb870..00116c57d6cd 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -92,6 +92,8 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
/* MacbookPro15,4 (2019) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
+/* MacbookPro16,2 (2020) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -165,6 +167,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680),
|
||||||
|
/* MacbookPro15,4 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
|
||||||
|
+ /* MacbookPro16,2 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -553,6 +557,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -170, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -6243, 6749 },
|
||||||
|
+ { SN_COORD, -170, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
From 019200008a92c81db744f30ed5087633c48409ff Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sat, 13 Feb 2021 21:06:50 -0500
|
||||||
|
Subject: [PATCH 7/9] HID: apple: Add support for MacBookPro16,3
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Pro
|
||||||
|
(13-inch, 2020, Two Thunderbolt 3 ports) [MacBookPro16,3 J223 iBridge2,21]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 4d1b88b57142..65e4137497b3 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -741,6 +741,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index 861069c765c7..2a50ffd71e4e 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -170,6 +170,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 0x027c
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index d15b6fe0c8c2..73e07b1b8bf5 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -294,6 +294,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -933,6 +934,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index 00116c57d6cd..e50aec0c865e 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -94,6 +94,8 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
/* MacbookPro16,2 (2020) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
+/* MacbookPro16,3 (2020) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -169,6 +171,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213),
|
||||||
|
/* MacbookPro16,2 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
||||||
|
+ /* MacbookPro16,3 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -570,6 +574,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -170, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -6243, 6749 },
|
||||||
|
+ { SN_COORD, -170, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
From 8e1462a94ac6c6e2fe407c88084beb03aa5a485f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 02:16:15 -0600
|
||||||
|
Subject: [PATCH 8/9] HID: apple: Add support for MacBookAir9,1
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Air
|
||||||
|
(Retina, 13-inch, 2020) [MacBookAir9,1 J230K iBridge2,15]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 65e4137497b3..2585986250d3 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -743,6 +743,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index 2a50ffd71e4e..a113c30f3898 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -171,6 +171,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213 0x027d
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K 0x0280
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index 73e07b1b8bf5..d9707ba949ee 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -295,6 +295,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -935,6 +936,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index e50aec0c865e..861afa9ac300 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -96,6 +96,8 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
/* MacbookPro16,3 (2020) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f
|
||||||
|
+/* MacbookAir9,1 (2020) */
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K 0x0280
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -173,6 +175,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
||||||
|
/* MacbookPro16,3 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
|
||||||
|
+ /* MacbookAir9,1 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -587,6 +591,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -170, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -6243, 6749 },
|
||||||
|
+ { SN_COORD, -170, 7685 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
From 3aec4416855e679c6e64c4f92428680def85d03f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
Date: Sun, 31 Jan 2021 02:26:18 -0600
|
||||||
|
Subject: [PATCH 9/9] HID: apple: Add support for MacBookPro16,1
|
||||||
|
keyboard/trackpad
|
||||||
|
|
||||||
|
This commit adds the necessary IDs and configuration for the MacBook Pro
|
||||||
|
(16-inch, 2019) [MacBookPro16,1 J152F iBridge2,14]
|
||||||
|
|
||||||
|
This model uses the APPLE_BACKLIGHT_CTL quirk to expose keyboard
|
||||||
|
backlight controls.
|
||||||
|
|
||||||
|
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 2 ++
|
||||||
|
drivers/hid/hid-ids.h | 1 +
|
||||||
|
drivers/hid/hid-quirks.c | 2 ++
|
||||||
|
drivers/input/mouse/bcm5974.c | 17 +++++++++++++++++
|
||||||
|
4 files changed, 22 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index 2585986250d3..e68fe6855d3f 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -745,6 +745,8 @@ static const struct hid_device_id apple_devices[] = {
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
||||||
|
.driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F),
|
||||||
|
+ .driver_data = APPLE_HAS_FN | APPLE_BACKLIGHT_CTL },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
|
||||||
|
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
|
||||||
|
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
|
||||||
|
index a113c30f3898..c15ed9687f97 100644
|
||||||
|
--- a/drivers/hid/hid-ids.h
|
||||||
|
+++ b/drivers/hid/hid-ids.h
|
||||||
|
@@ -172,6 +172,7 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K 0x027e
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K 0x0280
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F 0x0340
|
||||||
|
#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
|
||||||
|
#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
|
||||||
|
#define USB_DEVICE_ID_APPLE_IRCONTROL 0x8240
|
||||||
|
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
|
||||||
|
index d9707ba949ee..62f85c976759 100644
|
||||||
|
--- a/drivers/hid/hid-quirks.c
|
||||||
|
+++ b/drivers/hid/hid-quirks.c
|
||||||
|
@@ -296,6 +296,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
|
||||||
|
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
|
||||||
|
@@ -937,6 +938,7 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K) },
|
||||||
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
|
||||||
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
|
||||||
|
{ }
|
||||||
|
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
|
||||||
|
index 861afa9ac300..83f08e4b47d0 100644
|
||||||
|
--- a/drivers/input/mouse/bcm5974.c
|
||||||
|
+++ b/drivers/input/mouse/bcm5974.c
|
||||||
|
@@ -98,6 +98,8 @@
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 0x027f
|
||||||
|
/* MacbookAir9,1 (2020) */
|
||||||
|
#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K 0x0280
|
||||||
|
+/* MacbookPro16,1 (2019)*/
|
||||||
|
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F 0x0340
|
||||||
|
|
||||||
|
#define BCM5974_DEVICE(prod) { \
|
||||||
|
.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
|
||||||
|
@@ -177,6 +179,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223),
|
||||||
|
/* MacbookAir9,1 */
|
||||||
|
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
||||||
|
+ /* MacbookPro16,1 */
|
||||||
|
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F),
|
||||||
|
/* Terminating entry */
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
@@ -604,6 +608,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
|
||||||
|
{ SN_COORD, -170, 7685 },
|
||||||
|
{ SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
},
|
||||||
|
+ {
|
||||||
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F,
|
||||||
|
+ 0,
|
||||||
|
+ 0,
|
||||||
|
+ HAS_INTEGRATED_BUTTON,
|
||||||
|
+ 0, sizeof(struct bt_data),
|
||||||
|
+ 0x83, DATAFORMAT(TYPE4),
|
||||||
|
+ { SN_PRESSURE, 0, 300 },
|
||||||
|
+ { SN_WIDTH, 0, 2048 },
|
||||||
|
+ { SN_COORD, -8916, 9918 },
|
||||||
|
+ { SN_COORD, -1934, 9835 },
|
||||||
|
+ { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
|
||||||
|
+ },
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.1
|
||||||
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
From: Aditya Garg <gargaditya08@live.com>
|
||||||
|
|
||||||
|
This patch adds the Fn mapping for keyboards on certain T2 Macs.
|
||||||
|
|
||||||
|
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
||||||
|
---
|
||||||
|
drivers/hid/hid-apple.c | 64 ++++++++++++++++++++++++++++++++++++++++-
|
||||||
|
1 file changed, 63 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
|
||||||
|
index b6e1a29a2..70e9f6f74 100644
|
||||||
|
--- a/drivers/hid/hid-apple.c
|
||||||
|
+++ b/drivers/hid/hid-apple.c
|
||||||
|
@@ -113,6 +113,51 @@ static const struct apple_key_translation macbookair_fn_keys[] = {
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
+static const struct apple_key_translation macbookpro_no_esc_fn_keys[] = {
|
||||||
|
+ { KEY_BACKSPACE, KEY_DELETE },
|
||||||
|
+ { KEY_ENTER, KEY_INSERT },
|
||||||
|
+ { KEY_GRAVE, KEY_ESC },
|
||||||
|
+ { KEY_1, KEY_F1 },
|
||||||
|
+ { KEY_2, KEY_F2 },
|
||||||
|
+ { KEY_3, KEY_F3 },
|
||||||
|
+ { KEY_4, KEY_F4 },
|
||||||
|
+ { KEY_5, KEY_F5 },
|
||||||
|
+ { KEY_6, KEY_F6 },
|
||||||
|
+ { KEY_7, KEY_F7 },
|
||||||
|
+ { KEY_8, KEY_F8 },
|
||||||
|
+ { KEY_9, KEY_F9 },
|
||||||
|
+ { KEY_0, KEY_F10 },
|
||||||
|
+ { KEY_MINUS, KEY_F11 },
|
||||||
|
+ { KEY_EQUAL, KEY_F12 },
|
||||||
|
+ { KEY_UP, KEY_PAGEUP },
|
||||||
|
+ { KEY_DOWN, KEY_PAGEDOWN },
|
||||||
|
+ { KEY_LEFT, KEY_HOME },
|
||||||
|
+ { KEY_RIGHT, KEY_END },
|
||||||
|
+ { }
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static const struct apple_key_translation macbookpro_dedicated_esc_fn_keys[] = {
|
||||||
|
+ { KEY_BACKSPACE, KEY_DELETE },
|
||||||
|
+ { KEY_ENTER, KEY_INSERT },
|
||||||
|
+ { KEY_1, KEY_F1 },
|
||||||
|
+ { KEY_2, KEY_F2 },
|
||||||
|
+ { KEY_3, KEY_F3 },
|
||||||
|
+ { KEY_4, KEY_F4 },
|
||||||
|
+ { KEY_5, KEY_F5 },
|
||||||
|
+ { KEY_6, KEY_F6 },
|
||||||
|
+ { KEY_7, KEY_F7 },
|
||||||
|
+ { KEY_8, KEY_F8 },
|
||||||
|
+ { KEY_9, KEY_F9 },
|
||||||
|
+ { KEY_0, KEY_F10 },
|
||||||
|
+ { KEY_MINUS, KEY_F11 },
|
||||||
|
+ { KEY_EQUAL, KEY_F12 },
|
||||||
|
+ { KEY_UP, KEY_PAGEUP },
|
||||||
|
+ { KEY_DOWN, KEY_PAGEDOWN },
|
||||||
|
+ { KEY_LEFT, KEY_HOME },
|
||||||
|
+ { KEY_RIGHT, KEY_END },
|
||||||
|
+ { }
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
static const struct apple_key_translation apple_fn_keys[] = {
|
||||||
|
{ KEY_BACKSPACE, KEY_DELETE },
|
||||||
|
{ KEY_ENTER, KEY_INSERT },
|
||||||
|
@@ -236,7 +281,18 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fnmode) {
|
||||||
|
- if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
|
||||||
|
+ if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 ||
|
||||||
|
+ hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 ||
|
||||||
|
+ hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213)
|
||||||
|
+ table = macbookpro_no_esc_fn_keys;
|
||||||
|
+ else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K ||
|
||||||
|
+ hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223 ||
|
||||||
|
+ hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F)
|
||||||
|
+ table = macbookpro_dedicated_esc_fn_keys;
|
||||||
|
+ else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K ||
|
||||||
|
+ hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K)
|
||||||
|
+ table = apple_fn_keys;
|
||||||
|
+ else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
|
||||||
|
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
|
||||||
|
table = macbookair_fn_keys;
|
||||||
|
else if (hid->product < 0x21d || hid->product >= 0x300)
|
||||||
|
@@ -386,6 +442,12 @@ static void apple_setup_input(struct input_dev *input)
|
||||||
|
set_bit(KEY_NUMLOCK, input->keybit);
|
||||||
|
|
||||||
|
/* Enable all needed keys */
|
||||||
|
+ for (trans = macbookpro_no_esc_fn_keys; trans->from; trans++)
|
||||||
|
+ set_bit(trans->to, input->keybit);
|
||||||
|
+
|
||||||
|
+ for (trans = macbookpro_dedicated_esc_fn_keys; trans->from; trans++)
|
||||||
|
+ set_bit(trans->to, input->keybit);
|
||||||
|
+
|
||||||
|
for (trans = apple_fn_keys; trans->from; trans++)
|
||||||
|
set_bit(trans->to, input->keybit);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user