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
Initial Commit
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
From 51b77e4f052b0717eaa69cfd9b62978da58d9d02 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/3] 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/scs.h>
|
||||
#include <linux/io_uring.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.30.0
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
From af5906764eea0c609d9d0dfc2c9834c6b72c88e6 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/3] 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.30.0
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
From 545d6504ef3c786b8294ca2129111227a7bb6515 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Dumazet <edumazet@google.com>
|
||||
Date: Mon, 25 Jan 2021 07:09:49 -0800
|
||||
Subject: [PATCH 3/3] iwlwifi: provide gso_type to GSO packets
|
||||
|
||||
commit 81a86e1bd8e7060ebba1718b284d54f1238e9bf9 upstream.
|
||||
|
||||
net/core/tso.c got recent support for USO, and this broke iwlfifi
|
||||
because the driver implemented a limited form of GSO.
|
||||
|
||||
Providing ->gso_type allows for skb_is_gso_tcp() to provide
|
||||
a correct result.
|
||||
|
||||
Fixes: 3d5b459ba0e3 ("net: tso: add UDP segmentation support")
|
||||
Signed-off-by: Eric Dumazet <edumazet@google.com>
|
||||
Reported-by: Ben Greear <greearb@candelatech.com>
|
||||
Tested-by: Ben Greear <greearb@candelatech.com>
|
||||
Cc: Luca Coelho <luciano.coelho@intel.com>
|
||||
Cc: Johannes Berg <johannes@sipsolutions.net>
|
||||
Link: https://bugzilla.kernel.org/show_bug.cgi?id=209913
|
||||
Link: https://lore.kernel.org/r/20210125150949.619309-1-eric.dumazet@gmail.com
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
Cc: Robert Hancock <hancockrwd@gmail.com>
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
|
||||
index fe1c538cd718..7626117c01fa 100644
|
||||
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
|
||||
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c
|
||||
@@ -833,6 +833,7 @@ iwl_mvm_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
|
||||
|
||||
next = skb_gso_segment(skb, netdev_flags);
|
||||
skb_shinfo(skb)->gso_size = mss;
|
||||
+ skb_shinfo(skb)->gso_type = ipv4 ? SKB_GSO_TCPV4 : SKB_GSO_TCPV6;
|
||||
if (WARN_ON_ONCE(IS_ERR(next)))
|
||||
return -EINVAL;
|
||||
else if (next)
|
||||
@@ -855,6 +856,8 @@ iwl_mvm_tx_tso_segment(struct sk_buff *skb, unsigned int num_subframes,
|
||||
|
||||
if (tcp_payload_len > mss) {
|
||||
skb_shinfo(tmp)->gso_size = mss;
|
||||
+ skb_shinfo(tmp)->gso_type = ipv4 ? SKB_GSO_TCPV4 :
|
||||
+ SKB_GSO_TCPV6;
|
||||
} else {
|
||||
if (qos) {
|
||||
u8 *qc;
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
From b6740001d1adbfe84768b859bee038ceeccdc50c Mon Sep 17 00:00:00 2001
|
||||
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
Date: Wed, 29 Jul 2020 08:04:54 -0500
|
||||
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>
|
||||
---
|
||||
.../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 fbcd979438e2..8f78f9928df6 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
|
||||
@@ -3465,6 +3465,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.28.0
|
||||
|
||||
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 = 1;
|
||||
|
||||
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 snprintf(sysfsbuf, PAGE_SIZE, "%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 snprintf(sysfsbuf, PAGE_SIZE, "%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 dea63f5efd772740758cc78cde6c94a3df2ebde8 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/8] 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 e82f604d33e9..bcebd6ecb2f2 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
|
||||
#define APPLE_IGNORE_HIDINPUT 0x0080
|
||||
#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.0
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
From 66b51e1a4c6730ebd926ead0163f7240ef23ec95 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/8] 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 bcebd6ecb2f2..e0b7b2f2a899 100644
|
||||
--- a/drivers/hid/hid-apple.c
|
||||
+++ b/drivers/hid/hid-apple.c
|
||||
@@ -729,6 +729,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 a6d63a759043..aedecbb1624c 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.0
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
From cca73561d936d960f17f4861e98844441e610d05 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/8] 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 e0b7b2f2a899..9c4903b3a1c1 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 | 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 aedecbb1624c..b0574939b59f 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.0
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
From 257aca65118f370840d6206d821ff4233cae6816 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/8] 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 9c4903b3a1c1..bf8dfca762a7 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_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 b0574939b59f..c5340b03a56a 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.0
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
From 3c0c9c386f44263d0003e0cc148cff10a61f5a37 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/8] 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 bf8dfca762a7..11bfc6b16778 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_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 c5340b03a56a..1e28f1f54de8 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.0
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
From 30592af9908905aaa13579e31c85c6fc9ff5e8d1 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/8] 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 11bfc6b16778..f4df537c2141 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_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 1e28f1f54de8..3f9ebb04858e 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.0
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
From 7d0a89b5be341ef58bf5a509c3c1f5abae6b72d6 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 7/8] 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 f4df537c2141..bb21fa2cc3cd 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_J214K),
|
||||
.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 3f9ebb04858e..604bbeca64c7 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_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 d15b6fe0c8c2..c9b5eab5118c 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_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) },
|
||||
@@ -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_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 00116c57d6cd..5214b9cb6709 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
|
||||
+/* MacbookAir9,1 (2020) */
|
||||
+#define USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K 0x0280
|
||||
|
||||
#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),
|
||||
+ /* MacbookAir9,1 */
|
||||
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
||||
/* 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_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.0
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
From b0ca7f7f2b8e714f68021b705ac21edf45ae8959 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 8/8] 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 bb21fa2cc3cd..471268af21d6 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_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 604bbeca64c7..3e87df966ab7 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_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 c9b5eab5118c..79aa08364eec 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_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) },
|
||||
@@ -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_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 5214b9cb6709..bc332d092859 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
|
||||
/* 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 | \
|
||||
@@ -173,6 +175,8 @@ static const struct usb_device_id bcm5974_table[] = {
|
||||
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K),
|
||||
/* MacbookAir9,1 */
|
||||
BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K),
|
||||
+ /* MacbookPro16,1 */
|
||||
+ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F),
|
||||
/* 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_J152F,
|
||||
+ 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.0
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
From ca775a3e16ac138ff47fcc3eccacd154ee35e9c2 Mon Sep 17 00:00:00 2001
|
||||
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
Date: Fri, 10 Jan 2020 12:47:25 -0600
|
||||
Subject: [PATCH 1/2] brcmfmac: move brcmf_mp_device into its own header
|
||||
|
||||
This commit relocates the brcmf_mp_device struct into its own header. This
|
||||
aids in utilizing the struct without the redefinition of the existing
|
||||
included headers found in common.h, such as fwil_types.h.
|
||||
|
||||
Tested-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
---
|
||||
.../broadcom/brcm80211/brcmfmac/common.h | 36 +++---------------
|
||||
.../broadcom/brcm80211/brcmfmac/settings.h | 37 +++++++++++++++++++
|
||||
2 files changed, 42 insertions(+), 31 deletions(-)
|
||||
create mode 100644 drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h
|
||||
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
|
||||
index 8b5f49997c8b..6cde5ee13e7a 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
|
||||
@@ -8,15 +8,14 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/platform_data/brcmfmac.h>
|
||||
#include "fwil_types.h"
|
||||
+#include "settings.h"
|
||||
|
||||
#define BRCMF_FW_ALTPATH_LEN 256
|
||||
|
||||
-/* Definitions for the module global and device specific settings are defined
|
||||
- * here. Two structs are used for them. brcmf_mp_global_t and brcmf_mp_device.
|
||||
- * The mp_global is instantiated once in a global struct and gets initialized
|
||||
- * by the common_attach function which should be called before any other
|
||||
- * (module) initiliazation takes place. The device specific settings is part
|
||||
- * of the drvr struct and should be initialized on every brcmf_attach.
|
||||
+/* Definition for the module global settings are defined here. One struct is
|
||||
+ * used called brcmf_mp_global_t. The mp_global is instantiated once in a
|
||||
+ * global struct and gets initialized by the common_attach function which
|
||||
+ * should be called before any other (module) initiliazation takes place.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -30,31 +29,6 @@ struct brcmf_mp_global_t {
|
||||
|
||||
extern struct brcmf_mp_global_t brcmf_mp_global;
|
||||
|
||||
-/**
|
||||
- * struct brcmf_mp_device - Device module paramaters.
|
||||
- *
|
||||
- * @p2p_enable: Legacy P2P0 enable (old wpa_supplicant).
|
||||
- * @feature_disable: Feature_disable bitmask.
|
||||
- * @fcmode: FWS flow control.
|
||||
- * @roamoff: Firmware roaming off?
|
||||
- * @ignore_probe_fail: Ignore probe failure.
|
||||
- * @country_codes: If available, pointer to struct for translating country codes
|
||||
- * @bus: Bus specific platform data. Only SDIO at the mmoment.
|
||||
- */
|
||||
-struct brcmf_mp_device {
|
||||
- bool p2p_enable;
|
||||
- unsigned int feature_disable;
|
||||
- int fcmode;
|
||||
- bool roamoff;
|
||||
- bool iapp;
|
||||
- bool ignore_probe_fail;
|
||||
- struct brcmfmac_pd_cc *country_codes;
|
||||
- const char *board_type;
|
||||
- union {
|
||||
- struct brcmfmac_sdio_pd sdio;
|
||||
- } bus;
|
||||
-};
|
||||
-
|
||||
void brcmf_c_set_joinpref_default(struct brcmf_if *ifp);
|
||||
|
||||
struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h
|
||||
new file mode 100644
|
||||
index 000000000000..7bab0d362cdd
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h
|
||||
@@ -0,0 +1,37 @@
|
||||
+/* SPDX-License-Identifier: ISC */
|
||||
+/* Copyright (c) 2014 Broadcom Corporation */
|
||||
+
|
||||
+#ifndef BRCMFMAC_SETTINGS_H
|
||||
+#define BRCMFMAC_SETTINGS_H
|
||||
+
|
||||
+/* Definition for the device specific settings are defined here. One struct
|
||||
+ * is used called brcmf_mp_device. The device specific settings is part of
|
||||
+ * the drvr struct and should be initialized on every brcmf_attach.
|
||||
+ */
|
||||
+
|
||||
+/**
|
||||
+ * struct brcmf_mp_device - Device module parameters.
|
||||
+ *
|
||||
+ * @p2p_enable: Legacy P2P0 enable (old wpa_supplicant).
|
||||
+ * @feature_disable: Feature_disable bitmask.
|
||||
+ * @fcmode: FWS flow control.
|
||||
+ * @roamoff: Firmware roaming off?
|
||||
+ * @ignore_probe_fail: Ignore probe failure.
|
||||
+ * @country_codes: If available, pointer to struct for translating country codes
|
||||
+ * @bus: Bus specific platform data. Only SDIO at the mmoment.
|
||||
+ */
|
||||
+struct brcmf_mp_device {
|
||||
+ bool p2p_enable;
|
||||
+ unsigned int feature_disable;
|
||||
+ int fcmode;
|
||||
+ bool roamoff;
|
||||
+ bool iapp;
|
||||
+ bool ignore_probe_fail;
|
||||
+ struct brcmfmac_pd_cc *country_codes;
|
||||
+ const char *board_type;
|
||||
+ union {
|
||||
+ struct brcmfmac_sdio_pd sdio;
|
||||
+ } bus;
|
||||
+};
|
||||
+
|
||||
+#endif /* BRCMFMAC_SETTINGS_H */
|
||||
--
|
||||
2.30.0
|
||||
|
||||
@@ -0,0 +1,224 @@
|
||||
From 26c44d268ac1d328ef4cbd35a2a1a3d703346903 Mon Sep 17 00:00:00 2001
|
||||
From: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
Date: Fri, 10 Jan 2020 19:41:21 -0600
|
||||
Subject: [PATCH 2/2] brcmfmac: Add ability to manually specify FW rambase
|
||||
address
|
||||
|
||||
This commit introduces the ability to manually pass the rambase address
|
||||
for the brcmfmac chip as a kernel module option. The existing
|
||||
brcmf_chip_tcm_rambase() function is bypassed when this option is
|
||||
supplied. This is very useful when debugging support for newer chipsets
|
||||
that are not provided by the aforementioned function.
|
||||
|
||||
Tested-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
Signed-off-by: Aun-Ali Zaidi <admin@kodeit.net>
|
||||
---
|
||||
.../broadcom/brcm80211/brcmfmac/chip.c | 19 ++++++++++++-------
|
||||
.../broadcom/brcm80211/brcmfmac/chip.h | 7 +++++--
|
||||
.../broadcom/brcm80211/brcmfmac/common.c | 5 +++++
|
||||
.../broadcom/brcm80211/brcmfmac/common.h | 1 -
|
||||
.../broadcom/brcm80211/brcmfmac/pcie.c | 4 ++--
|
||||
.../broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
|
||||
.../broadcom/brcm80211/brcmfmac/settings.h | 4 ++++
|
||||
7 files changed, 29 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
|
||||
index a3a257089696..039dcf7853a6 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
|
||||
@@ -733,7 +733,7 @@ static u32 brcmf_chip_tcm_rambase(struct brcmf_chip_priv *ci)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-int brcmf_chip_get_raminfo(struct brcmf_chip *pub)
|
||||
+int brcmf_chip_get_raminfo(struct brcmf_chip *pub, struct brcmf_mp_device *settings)
|
||||
{
|
||||
struct brcmf_chip_priv *ci = container_of(pub, struct brcmf_chip_priv,
|
||||
pub);
|
||||
@@ -744,7 +744,9 @@ int brcmf_chip_get_raminfo(struct brcmf_chip *pub)
|
||||
if (mem) {
|
||||
mem_core = container_of(mem, struct brcmf_core_priv, pub);
|
||||
ci->pub.ramsize = brcmf_chip_tcm_ramsize(mem_core);
|
||||
- ci->pub.rambase = brcmf_chip_tcm_rambase(ci);
|
||||
+ ci->pub.rambase = (settings &&
|
||||
+ settings->rambase_addr > 0) ? settings->rambase_addr
|
||||
+ : brcmf_chip_tcm_rambase(ci);
|
||||
if (!ci->pub.rambase) {
|
||||
brcmf_err("RAM base not provided with ARM CR4 core\n");
|
||||
return -EINVAL;
|
||||
@@ -755,7 +757,9 @@ int brcmf_chip_get_raminfo(struct brcmf_chip *pub)
|
||||
mem_core = container_of(mem, struct brcmf_core_priv,
|
||||
pub);
|
||||
ci->pub.ramsize = brcmf_chip_sysmem_ramsize(mem_core);
|
||||
- ci->pub.rambase = brcmf_chip_tcm_rambase(ci);
|
||||
+ ci->pub.rambase = (settings &&
|
||||
+ settings->rambase_addr > 0) ? settings->rambase_addr
|
||||
+ : brcmf_chip_tcm_rambase(ci);
|
||||
if (!ci->pub.rambase) {
|
||||
brcmf_err("RAM base not provided with ARM CA7 core\n");
|
||||
return -EINVAL;
|
||||
@@ -941,7 +945,7 @@ int brcmf_chip_dmp_erom_scan(struct brcmf_chip_priv *ci)
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)
|
||||
+static int brcmf_chip_recognition(struct brcmf_chip_priv *ci, struct brcmf_mp_device *settings)
|
||||
{
|
||||
struct brcmf_core *core;
|
||||
u32 regdata;
|
||||
@@ -1014,7 +1018,7 @@ static int brcmf_chip_recognition(struct brcmf_chip_priv *ci)
|
||||
brcmf_chip_set_passive(&ci->pub);
|
||||
}
|
||||
|
||||
- return brcmf_chip_get_raminfo(&ci->pub);
|
||||
+ return brcmf_chip_get_raminfo(&ci->pub, settings);
|
||||
}
|
||||
|
||||
static void brcmf_chip_disable_arm(struct brcmf_chip_priv *chip, u16 id)
|
||||
@@ -1088,7 +1092,8 @@ static int brcmf_chip_setup(struct brcmf_chip_priv *chip)
|
||||
}
|
||||
|
||||
struct brcmf_chip *brcmf_chip_attach(void *ctx,
|
||||
- const struct brcmf_buscore_ops *ops)
|
||||
+ const struct brcmf_buscore_ops *ops,
|
||||
+ struct brcmf_mp_device *settings)
|
||||
{
|
||||
struct brcmf_chip_priv *chip;
|
||||
int err = 0;
|
||||
@@ -1117,7 +1122,7 @@ struct brcmf_chip *brcmf_chip_attach(void *ctx,
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
|
||||
- err = brcmf_chip_recognition(chip);
|
||||
+ err = brcmf_chip_recognition(chip, settings);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
|
||||
index 8fa38658e727..7da0ef3129a0 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
+#include "settings.h"
|
||||
+
|
||||
#define CORE_CC_REG(base, field) \
|
||||
(base + offsetof(struct chipcregs, field))
|
||||
|
||||
@@ -69,9 +71,10 @@ struct brcmf_buscore_ops {
|
||||
void (*activate)(void *ctx, struct brcmf_chip *chip, u32 rstvec);
|
||||
};
|
||||
|
||||
-int brcmf_chip_get_raminfo(struct brcmf_chip *pub);
|
||||
+int brcmf_chip_get_raminfo(struct brcmf_chip *pub, struct brcmf_mp_device *settings);
|
||||
struct brcmf_chip *brcmf_chip_attach(void *ctx,
|
||||
- const struct brcmf_buscore_ops *ops);
|
||||
+ const struct brcmf_buscore_ops *ops,
|
||||
+ struct brcmf_mp_device *settings);
|
||||
void brcmf_chip_detach(struct brcmf_chip *chip);
|
||||
struct brcmf_core *brcmf_chip_get_core(struct brcmf_chip *chip, u16 coreid);
|
||||
struct brcmf_core *brcmf_chip_get_d11core(struct brcmf_chip *pub, u8 unit);
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
|
||||
index e3758bd86acf..46a525278848 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
|
||||
@@ -67,6 +67,10 @@ static int brcmf_iapp_enable;
|
||||
module_param_named(iapp, brcmf_iapp_enable, int, 0);
|
||||
MODULE_PARM_DESC(iapp, "Enable partial support for the obsoleted Inter-Access Point Protocol");
|
||||
|
||||
+static uint brcmf_rambase_addr;
|
||||
+module_param_named(rambase_addr, brcmf_rambase_addr, uint, 0);
|
||||
+MODULE_PARM_DESC(rambase_addr, "Manually specify FW shared rambase address");
|
||||
+
|
||||
#ifdef DEBUG
|
||||
/* always succeed brcmf_bus_started() */
|
||||
static int brcmf_ignore_probe_fail;
|
||||
@@ -416,6 +420,7 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
|
||||
#ifdef DEBUG
|
||||
settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
|
||||
#endif
|
||||
+ settings->rambase_addr = brcmf_rambase_addr;
|
||||
|
||||
if (bus_type == BRCMF_BUSTYPE_SDIO)
|
||||
settings->bus.sdio.txglomsz = brcmf_sdiod_txglomsz;
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
|
||||
index 6cde5ee13e7a..0da7eeeb7768 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
|
||||
@@ -6,7 +6,6 @@
|
||||
#define BRCMFMAC_COMMON_H
|
||||
|
||||
#include <linux/platform_device.h>
|
||||
-#include <linux/platform_data/brcmfmac.h>
|
||||
#include "fwil_types.h"
|
||||
#include "settings.h"
|
||||
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
|
||||
index 39381cbde89e..a9575ae8add1 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
|
||||
@@ -1772,7 +1772,7 @@ static void brcmf_pcie_setup(struct device *dev, int ret,
|
||||
nvram_len = fwreq->items[BRCMF_PCIE_FW_NVRAM].nv_data.len;
|
||||
kfree(fwreq);
|
||||
|
||||
- ret = brcmf_chip_get_raminfo(devinfo->ci);
|
||||
+ ret = brcmf_chip_get_raminfo(devinfo->ci, devinfo->settings);
|
||||
if (ret) {
|
||||
brcmf_err(bus, "Failed to get RAM info\n");
|
||||
goto fail;
|
||||
@@ -1884,7 +1884,7 @@ brcmf_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||
|
||||
devinfo->pdev = pdev;
|
||||
pcie_bus_dev = NULL;
|
||||
- devinfo->ci = brcmf_chip_attach(devinfo, &brcmf_pcie_buscore_ops);
|
||||
+ devinfo->ci = brcmf_chip_attach(devinfo, &brcmf_pcie_buscore_ops, devinfo->settings);
|
||||
if (IS_ERR(devinfo->ci)) {
|
||||
ret = PTR_ERR(devinfo->ci);
|
||||
devinfo->ci = NULL;
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
|
||||
index ac3ee93a2378..d4bf1c7e3c81 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
|
||||
@@ -3962,7 +3962,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
- bus->ci = brcmf_chip_attach(sdiodev, &brcmf_sdio_buscore_ops);
|
||||
+ bus->ci = brcmf_chip_attach(sdiodev, &brcmf_sdio_buscore_ops, sdiodev->settings);
|
||||
if (IS_ERR(bus->ci)) {
|
||||
brcmf_err("brcmf_chip_attach failed!\n");
|
||||
bus->ci = NULL;
|
||||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h
|
||||
index 7bab0d362cdd..160e32f32bd8 100644
|
||||
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h
|
||||
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/settings.h
|
||||
@@ -4,6 +4,8 @@
|
||||
#ifndef BRCMFMAC_SETTINGS_H
|
||||
#define BRCMFMAC_SETTINGS_H
|
||||
|
||||
+#include <linux/platform_data/brcmfmac.h>
|
||||
+
|
||||
/* Definition for the device specific settings are defined here. One struct
|
||||
* is used called brcmf_mp_device. The device specific settings is part of
|
||||
* the drvr struct and should be initialized on every brcmf_attach.
|
||||
@@ -19,6 +21,7 @@
|
||||
* @ignore_probe_fail: Ignore probe failure.
|
||||
* @country_codes: If available, pointer to struct for translating country codes
|
||||
* @bus: Bus specific platform data. Only SDIO at the mmoment.
|
||||
+ * @rambase_addr: Manually specified FW shared rambase address.
|
||||
*/
|
||||
struct brcmf_mp_device {
|
||||
bool p2p_enable;
|
||||
@@ -32,6 +35,7 @@ struct brcmf_mp_device {
|
||||
union {
|
||||
struct brcmfmac_sdio_pd sdio;
|
||||
} bus;
|
||||
+ u32 rambase_addr;
|
||||
};
|
||||
|
||||
#endif /* BRCMFMAC_SETTINGS_H */
|
||||
--
|
||||
2.30.0
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user