From dc067eaadbcb0bdf40d58cf87e96df9e600482a6 Mon Sep 17 00:00:00 2001 From: "Ward Nakchbandi (Cosmic Fusion)" <83735213+CosmicFusion@users.noreply.github.com> Date: Sun, 17 Mar 2024 16:15:34 +0300 Subject: [PATCH] add asus linux patches --- ...add-support-for-2024-ROG-Mini-.patch.patch | 151 + ...s-wmi-add-support-for-Vivobook-GPU-M.patch | 100 + ...s-wmi-add-support-variant-of-TUF-RGB.patch | 74 + ...asus-wmi-support-toggling-POST-sound.patch | 139 + ...s-wmi-store-a-min-default-for-ppt-op.patch | 342 +++ .../asuslinux/ROG-ALLY-NCT6775-PLATFORM.patch | 12 - patches/asuslinux/asus-linux.patch | 390 --- patches/asuslinux/rog-ally-audio-fix.patch | 64 - patches/asuslinux/rog-ally-bmc150.patch | 2672 ----------------- ...asus-wmi-disable-USB0-hub-on-ROG-All.patch | 113 - patches/series | 5 + scripts/build.sh | 2 +- 12 files changed, 812 insertions(+), 3252 deletions(-) create mode 100644 patches/asuslinux/0001-platform-x86-asus-wmi-add-support-for-2024-ROG-Mini-.patch.patch create mode 100644 patches/asuslinux/0002-platform-x86-asus-wmi-add-support-for-Vivobook-GPU-M.patch create mode 100644 patches/asuslinux/0003-platform-x86-asus-wmi-add-support-variant-of-TUF-RGB.patch create mode 100644 patches/asuslinux/0004-platform-x86-asus-wmi-support-toggling-POST-sound.patch create mode 100644 patches/asuslinux/0005-platform-x86-asus-wmi-store-a-min-default-for-ppt-op.patch delete mode 100644 patches/asuslinux/ROG-ALLY-NCT6775-PLATFORM.patch delete mode 100644 patches/asuslinux/asus-linux.patch delete mode 100644 patches/asuslinux/rog-ally-audio-fix.patch delete mode 100644 patches/asuslinux/rog-ally-bmc150.patch delete mode 100644 patches/asuslinux/v2-0001-platform-x86-asus-wmi-disable-USB0-hub-on-ROG-All.patch diff --git a/patches/asuslinux/0001-platform-x86-asus-wmi-add-support-for-2024-ROG-Mini-.patch.patch b/patches/asuslinux/0001-platform-x86-asus-wmi-add-support-for-2024-ROG-Mini-.patch.patch new file mode 100644 index 0000000..fff1b38 --- /dev/null +++ b/patches/asuslinux/0001-platform-x86-asus-wmi-add-support-for-2024-ROG-Mini-.patch.patch @@ -0,0 +1,151 @@ +From 55426abb60d99efed912d8309498c0c365e8dcec Mon Sep 17 00:00:00 2001 +From: "Luke D. Jones" +Date: Sun, 10 Mar 2024 15:14:37 +1300 +Subject: [PATCH 1/5] platform/x86: asus-wmi: add support for 2024 ROG Mini-LED + +Support the 2024 mini-led backlight and adjust the related functions +to select the relevant dev-id. Also add `available_mini_led_mode` to the +platform sysfs since the available mini-led levels can be different. + +Signed-off-by: Luke D. Jones +--- + .../ABI/testing/sysfs-platform-asus-wmi | 8 ++++ + drivers/platform/x86/asus-wmi.c | 48 ++++++++++++++++--- + include/linux/platform_data/x86/asus-wmi.h | 1 + + 3 files changed, 51 insertions(+), 6 deletions(-) + +diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi +index 8a7e25bde085..e32b4f0ae15f 100644 +--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi ++++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi +@@ -126,6 +126,14 @@ Description: + Change the mini-LED mode: + * 0 - Single-zone, + * 1 - Multi-zone ++ * 2 - Multi-zone strong (available on newer generation mini-led) ++ ++What: /sys/devices/platform//avilable_mini_led_mode ++Date: Jun 2023 ++KernelVersion: 6.9 ++Contact: "Luke Jones" ++Description: ++ List the available mini-led modes. + + What: /sys/devices/platform//ppt_pl1_spl + Date: Jun 2023 +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c +index 18be35fdb381..a56152ccfbe7 100644 +--- a/drivers/platform/x86/asus-wmi.c ++++ b/drivers/platform/x86/asus-wmi.c +@@ -297,6 +297,7 @@ struct asus_wmi { + + bool panel_overdrive_available; + bool mini_led_mode_available; ++ u32 mini_led_dev_id; + + struct hotplug_slot hotplug_slot; + struct mutex hotplug_lock; +@@ -2109,10 +2110,17 @@ static ssize_t mini_led_mode_show(struct device *dev, + struct asus_wmi *asus = dev_get_drvdata(dev); + int result; + +- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE); +- if (result < 0) +- return result; ++ result = asus_wmi_get_devstate_simple(asus, asus->mini_led_dev_id); + ++ // Remap the mode values to match previous generation mini-led including ++ // if errored -19 since some of these bios return a bad result if set to "2" ++ // which is mini-led off ++ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) { ++ if (result >= 0 || result == -19) ++ result = result == 1 ? 2 : result == 0 ? 1 : 0; ++ } else if (result < 0) { ++ return result; ++ } + return sysfs_emit(buf, "%d\n", result); + } + +@@ -2129,10 +2137,15 @@ static ssize_t mini_led_mode_store(struct device *dev, + if (result) + return result; + +- if (mode > 1) ++ if (mode > 1 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE) + return -EINVAL; ++ if (mode > 2 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) ++ return -EINVAL; ++ // Remap the mode values to match previous generation mini-led ++ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) ++ mode = mode == 2 ? 1 : mode == 0 ? 2 : 0; + +- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result); ++ err = asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result); + + if (err) { + pr_warn("Failed to set mini-LED: %d\n", err); +@@ -2150,6 +2163,21 @@ static ssize_t mini_led_mode_store(struct device *dev, + } + static DEVICE_ATTR_RW(mini_led_mode); + ++static ssize_t available_mini_led_mode_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE) ++ return sysfs_emit(buf, "0 1\n"); ++ if (asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) ++ return sysfs_emit(buf, "0 1 2\n"); ++ ++ return sysfs_emit(buf, "0\n"); ++} ++ ++static DEVICE_ATTR_RO(available_mini_led_mode); ++ + /* Quirks *********************************************************************/ + + static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) +@@ -4174,6 +4202,7 @@ static struct attribute *platform_attributes[] = { + &dev_attr_nv_temp_target.attr, + &dev_attr_panel_od.attr, + &dev_attr_mini_led_mode.attr, ++ &dev_attr_available_mini_led_mode.attr, + NULL + }; + +@@ -4496,10 +4525,17 @@ static int asus_wmi_add(struct platform_device *pdev) + asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST); + asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); + asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); +- asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE); + asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) + && dmi_match(DMI_BOARD_NAME, "RC71L"); + ++ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) { ++ asus->mini_led_mode_available = true; ++ asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE; ++ } else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2)) { ++ asus->mini_led_mode_available = true; ++ asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2; ++ } ++ + err = fan_boost_mode_check_present(asus); + if (err) + goto fail_fan_boost_mode; +diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h +index ab1c7deff118..9cadce10ad9a 100644 +--- a/include/linux/platform_data/x86/asus-wmi.h ++++ b/include/linux/platform_data/x86/asus-wmi.h +@@ -71,6 +71,7 @@ + #define ASUS_WMI_DEVID_LID_FLIP 0x00060062 + #define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077 + #define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E ++#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E + + /* Storage */ + #define ASUS_WMI_DEVID_CARDREADER 0x00080013 +-- +2.44.0 + + diff --git a/patches/asuslinux/0002-platform-x86-asus-wmi-add-support-for-Vivobook-GPU-M.patch b/patches/asuslinux/0002-platform-x86-asus-wmi-add-support-for-Vivobook-GPU-M.patch new file mode 100644 index 0000000..dbd8ee9 --- /dev/null +++ b/patches/asuslinux/0002-platform-x86-asus-wmi-add-support-for-Vivobook-GPU-M.patch @@ -0,0 +1,100 @@ +From 06d5a9b83548d99b70764166d723489cc8336b1d Mon Sep 17 00:00:00 2001 +From: "Luke D. Jones" +Date: Sun, 10 Mar 2024 17:10:05 +1300 +Subject: [PATCH 2/5] platform/x86: asus-wmi: add support for Vivobook GPU MUX + +Adjust existing MUX support to select whichever MUX support is available +so that ASUS Vivobook MUX can also be used if detected. + +Signed-off-by: Luke D. Jones +--- + drivers/platform/x86/asus-wmi.c | 18 +++++++++++++----- + include/linux/platform_data/x86/asus-wmi.h | 1 + + 2 files changed, 14 insertions(+), 5 deletions(-) + +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c +index a56152ccfbe7..b9a2fb8007c0 100644 +--- a/drivers/platform/x86/asus-wmi.c ++++ b/drivers/platform/x86/asus-wmi.c +@@ -268,6 +268,7 @@ struct asus_wmi { + bool egpu_connect_available; + bool dgpu_disable_available; + bool gpu_mux_mode_available; ++ u32 gpu_mux_dev; + + /* Tunables provided by ASUS for gaming laptops */ + bool ppt_pl2_sppt_available; +@@ -682,7 +683,7 @@ static ssize_t dgpu_disable_store(struct device *dev, + return -EINVAL; + + if (asus->gpu_mux_mode_available) { +- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); ++ result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); + if (result < 0) + /* An error here may signal greater failure of GPU handling */ + return result; +@@ -748,7 +749,7 @@ static ssize_t egpu_enable_store(struct device *dev, + } + + if (asus->gpu_mux_mode_available) { +- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); ++ result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); + if (result < 0) { + /* An error here may signal greater failure of GPU handling */ + pr_warn("Failed to get gpu mux status: %d\n", result); +@@ -801,7 +802,7 @@ static ssize_t gpu_mux_mode_show(struct device *dev, + struct asus_wmi *asus = dev_get_drvdata(dev); + int result; + +- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); ++ result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); + if (result < 0) + return result; + +@@ -847,7 +848,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, + } + } + +- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_MUX, optimus, &result); ++ err = asus_wmi_set_devstate(asus->gpu_mux_dev, optimus, &result); + if (err) { + dev_err(dev, "Failed to set GPU MUX mode: %d\n", err); + return err; +@@ -4514,7 +4515,6 @@ static int asus_wmi_add(struct platform_device *pdev) + asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); + asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); + asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); +- asus->gpu_mux_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX); + asus->kbd_rgb_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE); + asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); + asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT); +@@ -4536,6 +4536,14 @@ static int asus_wmi_add(struct platform_device *pdev) + asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2; + } + ++ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX)) { ++ asus->gpu_mux_mode_available = true; ++ asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX; ++ } else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) { ++ asus->gpu_mux_mode_available = true; ++ asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO; ++ } ++ + err = fan_boost_mode_check_present(asus); + if (err) + goto fail_fan_boost_mode; +diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h +index 9cadce10ad9a..b48b024dd844 100644 +--- a/include/linux/platform_data/x86/asus-wmi.h ++++ b/include/linux/platform_data/x86/asus-wmi.h +@@ -128,6 +128,7 @@ + + /* gpu mux switch, 0 = dGPU, 1 = Optimus */ + #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 ++#define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 + + /* TUF laptop RGB modes/colours */ + #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 +-- +2.44.0 + diff --git a/patches/asuslinux/0003-platform-x86-asus-wmi-add-support-variant-of-TUF-RGB.patch b/patches/asuslinux/0003-platform-x86-asus-wmi-add-support-variant-of-TUF-RGB.patch new file mode 100644 index 0000000..1fd2ce7 --- /dev/null +++ b/patches/asuslinux/0003-platform-x86-asus-wmi-add-support-variant-of-TUF-RGB.patch @@ -0,0 +1,74 @@ +From 9b038d6db81b457738cf65e43f401ccb8bf505e6 Mon Sep 17 00:00:00 2001 +From: "Luke D. Jones" +Date: Sun, 10 Mar 2024 17:20:02 +1300 +Subject: [PATCH 3/5] platform/x86: asus-wmi: add support variant of TUF RGB + +Adds support for a second TUF RGB wmi call that some versions of the TUF +laptop come with. Also adjusts existing support to select whichever is +available. + +Signed-off-by: Luke D. Jones +--- + drivers/platform/x86/asus-wmi.c | 12 +++++++++++- + include/linux/platform_data/x86/asus-wmi.h | 1 + + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c +index b9a2fb8007c0..e1100726de53 100644 +--- a/drivers/platform/x86/asus-wmi.c ++++ b/drivers/platform/x86/asus-wmi.c +@@ -280,6 +280,7 @@ struct asus_wmi { + bool nv_temp_tgt_available; + + bool kbd_rgb_mode_available; ++ u32 kbd_rgb_dev; + bool kbd_rgb_state_available; + + bool throttle_thermal_policy_available; +@@ -870,6 +871,7 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + u32 cmd, mode, r, g, b, speed; + int err; + +@@ -906,7 +908,7 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, + speed = 0xeb; + } + +- err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, ASUS_WMI_DEVID_TUF_RGB_MODE, ++ err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, asus->kbd_rgb_dev, + cmd | (mode << 8) | (r << 16) | (g << 24), b | (speed << 8), NULL); + if (err) + return err; +@@ -4544,6 +4546,14 @@ static int asus_wmi_add(struct platform_device *pdev) + asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO; + } + ++ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE)) { ++ asus->kbd_rgb_mode_available = true; ++ asus->kbd_rgb_dev = ASUS_WMI_DEVID_TUF_RGB_MODE; ++ } else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE2)) { ++ asus->kbd_rgb_mode_available = true; ++ asus->kbd_rgb_dev = ASUS_WMI_DEVID_TUF_RGB_MODE2; ++ } ++ + err = fan_boost_mode_check_present(asus); + if (err) + goto fail_fan_boost_mode; +diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h +index b48b024dd844..3e9a01467c67 100644 +--- a/include/linux/platform_data/x86/asus-wmi.h ++++ b/include/linux/platform_data/x86/asus-wmi.h +@@ -132,6 +132,7 @@ + + /* TUF laptop RGB modes/colours */ + #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 ++#define ASUS_WMI_DEVID_TUF_RGB_MODE2 0x0010005A + + /* TUF laptop RGB power/state */ + #define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057 +-- +2.44.0 + diff --git a/patches/asuslinux/0004-platform-x86-asus-wmi-support-toggling-POST-sound.patch b/patches/asuslinux/0004-platform-x86-asus-wmi-support-toggling-POST-sound.patch new file mode 100644 index 0000000..2b0f7cf --- /dev/null +++ b/patches/asuslinux/0004-platform-x86-asus-wmi-support-toggling-POST-sound.patch @@ -0,0 +1,139 @@ +From 1c0f375634b3ddbcf479c4ddb81639e397795802 Mon Sep 17 00:00:00 2001 +From: "Luke D. Jones" +Date: Sun, 10 Mar 2024 19:03:11 +1300 +Subject: [PATCH 4/5] platform/x86: asus-wmi: support toggling POST sound + +Add support for toggling the BIOS POST sound on some ASUS laptops. + +Signed-off-by: Luke D. Jones +--- + .../ABI/testing/sysfs-platform-asus-wmi | 7 +++ + drivers/platform/x86/asus-wmi.c | 54 +++++++++++++++++++ + include/linux/platform_data/x86/asus-wmi.h | 3 ++ + 3 files changed, 64 insertions(+) + +diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi +index e32b4f0ae15f..f3c53b7453f0 100644 +--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi ++++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi +@@ -194,3 +194,10 @@ Contact: "Luke Jones" + Description: + Set the target temperature limit of the Nvidia dGPU: + * min=75, max=87 ++ ++What: /sys/devices/platform//boot_sound ++Date: Jun 2023 ++KernelVersion: 6.9 ++Contact: "Luke Jones" ++Description: ++ Set if the BIOS POST sound is played on boot. +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c +index e1100726de53..e4341abb71e0 100644 +--- a/drivers/platform/x86/asus-wmi.c ++++ b/drivers/platform/x86/asus-wmi.c +@@ -297,6 +297,7 @@ struct asus_wmi { + // The RSOC controls the maximum charging percentage. + bool battery_rsoc_available; + ++ bool boot_sound_available; + bool panel_overdrive_available; + bool mini_led_mode_available; + u32 mini_led_dev_id; +@@ -2106,6 +2107,55 @@ static ssize_t panel_od_store(struct device *dev, + } + static DEVICE_ATTR_RW(panel_od); + ++/* Bootup sound ***************************************************************/ ++ ++static ssize_t boot_sound_show(struct device *dev, ++ struct device_attribute *attr, char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ int result; ++ ++ result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_BOOT_SOUND); ++ if (result < 0) ++ return result; ++ ++ return sysfs_emit(buf, "%d\n", result); ++} ++ ++static ssize_t boot_sound_store(struct device *dev, ++ struct device_attribute *attr, ++ const char *buf, size_t count) ++{ ++ int result, err; ++ u32 snd; ++ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ result = kstrtou32(buf, 10, &snd); ++ if (result) ++ return result; ++ ++ if (snd > 1) ++ return -EINVAL; ++ ++ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BOOT_SOUND, snd, &result); ++ ++ if (err) { ++ pr_warn("Failed to set boot sound: %d\n", err); ++ return err; ++ } ++ ++ if (result > 1) { ++ pr_warn("Failed to set panel boot sound (result): 0x%x\n", result); ++ return -EIO; ++ } ++ ++ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "boot_sound"); ++ ++ return count; ++} ++static DEVICE_ATTR_RW(boot_sound); ++ + /* Mini-LED mode **************************************************************/ + static ssize_t mini_led_mode_show(struct device *dev, + struct device_attribute *attr, char *buf) +@@ -4203,6 +4253,7 @@ static struct attribute *platform_attributes[] = { + &dev_attr_ppt_platform_sppt.attr, + &dev_attr_nv_dynamic_boost.attr, + &dev_attr_nv_temp_target.attr, ++ &dev_attr_boot_sound.attr, + &dev_attr_panel_od.attr, + &dev_attr_mini_led_mode.attr, + &dev_attr_available_mini_led_mode.attr, +@@ -4255,6 +4306,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, + ok = asus->nv_dyn_boost_available; + else if (attr == &dev_attr_nv_temp_target.attr) + ok = asus->nv_temp_tgt_available; ++ else if (attr == &dev_attr_boot_sound.attr) ++ ok = asus->boot_sound_available; + else if (attr == &dev_attr_panel_od.attr) + ok = asus->panel_overdrive_available; + else if (attr == &dev_attr_mini_led_mode.attr) +@@ -4526,6 +4579,7 @@ static int asus_wmi_add(struct platform_device *pdev) + asus->ppt_plat_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PLAT_SPPT); + asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST); + asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); ++ asus->boot_sound_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_BOOT_SOUND); + asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); + asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) + && dmi_match(DMI_BOARD_NAME, "RC71L"); +diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h +index 3e9a01467c67..3eb5cd6773ad 100644 +--- a/include/linux/platform_data/x86/asus-wmi.h ++++ b/include/linux/platform_data/x86/asus-wmi.h +@@ -137,6 +137,9 @@ + /* TUF laptop RGB power/state */ + #define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057 + ++/* Bootup sound control */ ++#define ASUS_WMI_DEVID_BOOT_SOUND 0x00130022 ++ + /* DSTS masks */ + #define ASUS_WMI_DSTS_STATUS_BIT 0x00000001 + #define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002 +-- +2.44.0 + diff --git a/patches/asuslinux/0005-platform-x86-asus-wmi-store-a-min-default-for-ppt-op.patch b/patches/asuslinux/0005-platform-x86-asus-wmi-store-a-min-default-for-ppt-op.patch new file mode 100644 index 0000000..54402f0 --- /dev/null +++ b/patches/asuslinux/0005-platform-x86-asus-wmi-store-a-min-default-for-ppt-op.patch @@ -0,0 +1,342 @@ +From 6045f385154a2c0a4aaa692d13bb0fa14bbe1d12 Mon Sep 17 00:00:00 2001 +From: "Luke D. Jones" +Date: Mon, 11 Mar 2024 12:15:46 +1300 +Subject: [PATCH 5/5] platform/x86: asus-wmi: store a min default for ppt + options + +Laptops with any of the ppt or nv tunables default to the minimum setting +on boot so we can safely assume a stored value is correct. + +This patch adds storing of those values in the local struct, and enables +reading of those values back. + +Secondary to the above it renames some internal variables to be more +consistent (which makes code grepping show all related parts) + +Signed-off-by: Luke D. Jones +--- + drivers/platform/x86/asus-wmi.c | 141 +++++++++++++++++++++++++------- + 1 file changed, 111 insertions(+), 30 deletions(-) + +diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c +index e4341abb71e0..482e23b55e1e 100644 +--- a/drivers/platform/x86/asus-wmi.c ++++ b/drivers/platform/x86/asus-wmi.c +@@ -272,12 +272,19 @@ struct asus_wmi { + + /* Tunables provided by ASUS for gaming laptops */ + bool ppt_pl2_sppt_available; ++ u32 ppt_pl2_sppt; + bool ppt_pl1_spl_available; ++ u32 ppt_pl1_spl; + bool ppt_apu_sppt_available; +- bool ppt_plat_sppt_available; ++ u32 ppt_apu_sppt; ++ bool ppt_platform_sppt_available; ++ u32 ppt_platform_sppt; + bool ppt_fppt_available; +- bool nv_dyn_boost_available; +- bool nv_temp_tgt_available; ++ u32 ppt_fppt; ++ bool nv_dynamic_boost_available; ++ u32 nv_dynamic_boost; ++ bool nv_temp_target_available; ++ u32 nv_temp_target; + + bool kbd_rgb_mode_available; + u32 kbd_rgb_dev; +@@ -999,11 +1006,10 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1022,22 +1028,31 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev, + return -EIO; + } + ++ asus->ppt_pl2_sppt = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt"); + + return count; + } +-static DEVICE_ATTR_WO(ppt_pl2_sppt); ++ ++static ssize_t ppt_pl2_sppt_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt); ++} ++static DEVICE_ATTR_RW(ppt_pl2_sppt); + + /* Tunable: PPT, Intel=PL1, AMD=SPL ******************************************/ + static ssize_t ppt_pl1_spl_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1056,22 +1071,30 @@ static ssize_t ppt_pl1_spl_store(struct device *dev, + return -EIO; + } + ++ asus->ppt_pl1_spl = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl1_spl"); + + return count; + } +-static DEVICE_ATTR_WO(ppt_pl1_spl); ++static ssize_t ppt_pl1_spl_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->ppt_pl1_spl); ++} ++static DEVICE_ATTR_RW(ppt_pl1_spl); + + /* Tunable: PPT APU FPPT ******************************************************/ + static ssize_t ppt_fppt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1090,22 +1113,31 @@ static ssize_t ppt_fppt_store(struct device *dev, + return -EIO; + } + ++ asus->ppt_fppt = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_fpu_sppt"); + + return count; + } +-static DEVICE_ATTR_WO(ppt_fppt); ++ ++static ssize_t ppt_fppt_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->ppt_fppt); ++} ++static DEVICE_ATTR_RW(ppt_fppt); + + /* Tunable: PPT APU SPPT *****************************************************/ + static ssize_t ppt_apu_sppt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1124,22 +1156,31 @@ static ssize_t ppt_apu_sppt_store(struct device *dev, + return -EIO; + } + ++ asus->ppt_apu_sppt = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_apu_sppt"); + + return count; + } +-static DEVICE_ATTR_WO(ppt_apu_sppt); ++ ++static ssize_t ppt_apu_sppt_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->ppt_apu_sppt); ++} ++static DEVICE_ATTR_RW(ppt_apu_sppt); + + /* Tunable: PPT platform SPPT ************************************************/ + static ssize_t ppt_platform_sppt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1158,22 +1199,31 @@ static ssize_t ppt_platform_sppt_store(struct device *dev, + return -EIO; + } + ++ asus->ppt_platform_sppt = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_platform_sppt"); + + return count; + } +-static DEVICE_ATTR_WO(ppt_platform_sppt); ++ ++static ssize_t ppt_platform_sppt_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->ppt_platform_sppt); ++} ++static DEVICE_ATTR_RW(ppt_platform_sppt); + + /* Tunable: NVIDIA dynamic boost *********************************************/ + static ssize_t nv_dynamic_boost_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1192,22 +1242,31 @@ static ssize_t nv_dynamic_boost_store(struct device *dev, + return -EIO; + } + ++ asus->nv_dynamic_boost = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_dynamic_boost"); + + return count; + } +-static DEVICE_ATTR_WO(nv_dynamic_boost); ++ ++static ssize_t nv_dynamic_boost_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->nv_dynamic_boost); ++} ++static DEVICE_ATTR_RW(nv_dynamic_boost); + + /* Tunable: NVIDIA temperature target ****************************************/ + static ssize_t nv_temp_target_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) + { ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int result, err; + u32 value; + +- struct asus_wmi *asus = dev_get_drvdata(dev); +- + result = kstrtou32(buf, 10, &value); + if (result) + return result; +@@ -1226,11 +1285,21 @@ static ssize_t nv_temp_target_store(struct device *dev, + return -EIO; + } + ++ asus->nv_temp_target = value; + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_temp_target"); + + return count; + } +-static DEVICE_ATTR_WO(nv_temp_target); ++ ++static ssize_t nv_temp_target_show(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ ++ return sysfs_emit(buf, "%d\n", asus->nv_temp_target); ++} ++static DEVICE_ATTR_RW(nv_temp_target); + + /* Battery ********************************************************************/ + +@@ -4301,11 +4370,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, + else if (attr == &dev_attr_ppt_apu_sppt.attr) + ok = asus->ppt_apu_sppt_available; + else if (attr == &dev_attr_ppt_platform_sppt.attr) +- ok = asus->ppt_plat_sppt_available; ++ ok = asus->ppt_platform_sppt_available; + else if (attr == &dev_attr_nv_dynamic_boost.attr) +- ok = asus->nv_dyn_boost_available; ++ ok = asus->nv_dynamic_boost_available; + else if (attr == &dev_attr_nv_temp_target.attr) +- ok = asus->nv_temp_tgt_available; ++ ok = asus->nv_temp_target_available; + else if (attr == &dev_attr_boot_sound.attr) + ok = asus->boot_sound_available; + else if (attr == &dev_attr_panel_od.attr) +@@ -4566,6 +4635,15 @@ static int asus_wmi_add(struct platform_device *pdev) + if (err) + goto fail_platform; + ++ /* ensure defaults for tunables */ ++ asus->ppt_pl2_sppt = 5; ++ asus->ppt_pl1_spl = 5; ++ asus->ppt_apu_sppt = 5; ++ asus->ppt_platform_sppt = 5; ++ asus->ppt_fppt = 5; ++ asus->nv_dynamic_boost = 5; ++ asus->nv_temp_target = 75; ++ + asus->charge_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CHARGE_MODE); + asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); + asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); +@@ -4576,9 +4654,12 @@ static int asus_wmi_add(struct platform_device *pdev) + asus->ppt_pl1_spl_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL1_SPL); + asus->ppt_fppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_FPPT); + asus->ppt_apu_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_APU_SPPT); +- asus->ppt_plat_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PLAT_SPPT); +- asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST); +- asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); ++ asus->ppt_platform_sppt_available = asus_wmi_dev_is_present(asus, ++ ASUS_WMI_DEVID_PPT_PLAT_SPPT); ++ asus->nv_dynamic_boost_available = asus_wmi_dev_is_present(asus, ++ ASUS_WMI_DEVID_NV_DYN_BOOST); ++ asus->nv_temp_target_available = asus_wmi_dev_is_present(asus, ++ ASUS_WMI_DEVID_NV_THERM_TARGET); + asus->boot_sound_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_BOOT_SOUND); + asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); + asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) +-- +2.44.0 + diff --git a/patches/asuslinux/ROG-ALLY-NCT6775-PLATFORM.patch b/patches/asuslinux/ROG-ALLY-NCT6775-PLATFORM.patch deleted file mode 100644 index 806ad79..0000000 --- a/patches/asuslinux/ROG-ALLY-NCT6775-PLATFORM.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/drivers/hwmon/nct6775-platform.c b/drivers/hwmon/nct6775-platform.c -index 81bf03d..96d875b 100644 ---- a/drivers/hwmon/nct6775-platform.c -+++ b/drivers/hwmon/nct6775-platform.c -@@ -1359,6 +1359,7 @@ static const char * const asus_msi_boards[] = { - "ProArt X670E-CREATOR WIFI", - "ProArt Z690-CREATOR WIFI", - "ProArt Z790-CREATOR WIFI", -+ "RC71L", - "ROG CROSSHAIR X670E EXTREME", - "ROG CROSSHAIR X670E GENE", - "ROG CROSSHAIR X670E HERO", diff --git a/patches/asuslinux/asus-linux.patch b/patches/asuslinux/asus-linux.patch deleted file mode 100644 index a2bcfcc..0000000 --- a/patches/asuslinux/asus-linux.patch +++ /dev/null @@ -1,390 +0,0 @@ -From 76556b655f7b50afe5c58006f44221900e5711a9 Mon Sep 17 00:00:00 2001 -From: "Luke D. Jones" -Date: Wed, 23 Aug 2023 11:05:59 +1200 -Subject: [PATCH v2] ALSA: hda: cs35l41: Support ASUS 2023 laptops with missing - DSD - -Support adding the missing DSD properties required for ASUS ROG 2023 -laptops and other ASUS laptops to properly utilise the cs35l41. - -The currently added laptops are: -- ASUS GS650P, i2c -- ASUS GA402X, i2c -- ASUS GU604V, spi -- ASUS GU603V, spi -- ASUS GV601V, spi -- ASUS GZ301V, spi -- ASUS ROG ALLY, i2c -- ASUS G614J, spi -- ASUS G634J, spi -- ASUS G614JI, spi -- ASUS G713P, i2c -- ASUS H7604JV, spi - -The SPI connected amps may be required to use an external DSD patch -to fix or add the "cs-gpios" property. - -Co-developed-by: Jonathan LoBue -Signed-off-by: Jonathan LoBue -Co-developed-by: Luke D. Jones -Signed-off-by: Luke D. Jones ---- - sound/pci/hda/cs35l41_hda_property.c | 57 ++++++++++++++++++++++++++++ - 1 file changed, 57 insertions(+) - -diff --git a/sound/pci/hda/cs35l41_hda_property.c b/sound/pci/hda/cs35l41_hda_property.c -index c83328971728..de0802859849 100644 ---- a/sound/pci/hda/cs35l41_hda_property.c -+++ b/sound/pci/hda/cs35l41_hda_property.c -@@ -76,6 +76,49 @@ static int hp_vision_acpi_fix(struct cs35l41_hda *cs35l41, struct device *physde - hw_cfg->bst_ind = 1000; - hw_cfg->bst_ipk = 4500; - hw_cfg->bst_cap = 24; -+ -+ hw_cfg->valid = true; -+ -+ return 0; -+} -+ -+/* -+ * The CSC3551 is used in almost the entire ROG laptop range in 2023, this is likely to -+ * also include many non ROG labelled laptops. It is also used with either I2C connection or -+ * SPI connection. The SPI connected versions may be missing a chip select GPIO and require -+ * an DSD table patch. -+ */ -+static int asus_rog_2023_no_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, int id, -+ const char *hid) -+{ -+ struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; -+ int reset_gpio = 0; -+ int spkr_gpio = 2; -+ -+ /* check SPI or I2C address to assign the index */ -+ cs35l41->index = (id == 0 || id == 0x40) ? 0 : 1; -+ cs35l41->channel_index = 0; -+ hw_cfg->spk_pos = cs35l41->index; -+ hw_cfg->bst_type = CS35L41_EXT_BOOST; -+ hw_cfg->gpio1.func = CS35l41_VSPK_SWITCH; -+ hw_cfg->gpio1.valid = true; -+ hw_cfg->gpio2.func = CS35L41_INTERRUPT; -+ hw_cfg->gpio2.valid = true; -+ -+ if (strcmp(cs35l41->acpi_subsystem_id, "10431483") == 0) -+ spkr_gpio = 1; -+ cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, 0, 0, spkr_gpio); -+ -+ if (strcmp(cs35l41->acpi_subsystem_id, "10431473") == 0 -+ || strcmp(cs35l41->acpi_subsystem_id, "10431483") == 0 -+ || strcmp(cs35l41->acpi_subsystem_id, "10431493") == 0 -+ || strcmp(cs35l41->acpi_subsystem_id, "10431CAF") == 0 -+ || strcmp(cs35l41->acpi_subsystem_id, "10431CCF") == 0 -+ || strcmp(cs35l41->acpi_subsystem_id, "10431E02") == 0) { -+ reset_gpio = 1; -+ } -+ cs35l41->reset_gpio = gpiod_get_index(physdev, NULL, reset_gpio, GPIOD_OUT_HIGH); -+ - hw_cfg->valid = true; - - return 0; -@@ -92,6 +135,20 @@ static const struct cs35l41_prop_model cs35l41_prop_model_table[] = { - { "CLSA0100", NULL, lenovo_legion_no_acpi }, - { "CLSA0101", NULL, lenovo_legion_no_acpi }, - { "CSC3551", "103C89C6", hp_vision_acpi_fix }, -+ { "CSC3551", "10431433", asus_rog_2023_no_acpi }, // GS650P i2c -+ { "CSC3551", "10431463", asus_rog_2023_no_acpi }, // GA402X/N i2c, rst=0 -+ { "CSC3551", "10431473", asus_rog_2023_no_acpi }, // GU604V spi, rst=1 -+ { "CSC3551", "10431483", asus_rog_2023_no_acpi }, // GU603V spi, rst=1, spkr=1 -+ { "CSC3551", "10431493", asus_rog_2023_no_acpi }, // GV601V spi, rst=1 -+ { "CSC3551", "10431573", asus_rog_2023_no_acpi }, // GZ301V spi, rst=0 -+ { "CSC3551", "104317F3", asus_rog_2023_no_acpi }, // ROG ALLY i2c, rst=0 -+ { "CSC3551", "10431B93", asus_rog_2023_no_acpi }, // G614J spi, rst=0 -+ { "CSC3551", "10431C9F", asus_rog_2023_no_acpi }, // G614JI spi, rst=0 -+ { "CSC3551", "10431CAF", asus_rog_2023_no_acpi }, // G634J spi, rst=1 -+ { "CSC3551", "10431CCF", asus_rog_2023_no_acpi }, // G814J spi, rst=1 -+ { "CSC3551", "10431D1F", asus_rog_2023_no_acpi }, // G713P i2c, rst=0 -+ { "CSC3551", "10431E02", asus_rog_2023_no_acpi }, // UX3042Z spi, rst=1 -+ { "CSC3551", "10431F1F", asus_rog_2023_no_acpi }, // H7604JV spi, rst=0 - {} - }; - --- -2.41.0 - -From b35a4c957b3f0e5b4c7c73dec4fe3a5b9dbc4873 Mon Sep 17 00:00:00 2001 -From: "Luke D. Jones" -Date: Sun, 30 Apr 2023 10:56:34 +1200 -Subject: [PATCH v6 1/1] platform/x86: asus-wmi: add support for ASUS screenpad - -Add support for the WMI methods used to turn off and adjust the -brightness of the secondary "screenpad" device found on some high-end -ASUS laptops like the GX650P series and others. - -There are some small quirks with this device when considering only the -raw WMI methods: -1. The Off method can only switch the device off -2. Changing the brightness turns the device back on -3. To turn the device back on the brightness must be > 1 -4. When the device is off the brightness can't be changed (so it is - stored by the driver if device is off). -5. Booting with a value of 0 brightness (retained by bios) means the bios - will set a value of >0 <15 -6. When the device is off it is "unplugged" - -asus_wmi sets the minimum brightness as 20 in general use, and 60 for -booting with values <= min. - -The ACPI methods are used in a new backlight device named asus_screenpad. - -Signed-off-by: Luke D. Jones ---- - drivers/platform/x86/asus-wmi.c | 133 +++++++++++++++++++++ - drivers/platform/x86/asus-wmi.h | 1 + - include/linux/platform_data/x86/asus-wmi.h | 4 + - 3 files changed, 138 insertions(+) - -diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index f54178d6f780..0b13be703856 100644 ---- a/drivers/platform/x86/asus-wmi.c -+++ b/drivers/platform/x86/asus-wmi.c -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -127,6 +128,10 @@ module_param(fnlock_default, bool, 0444); - #define NVIDIA_TEMP_MIN 75 - #define NVIDIA_TEMP_MAX 87 - -+#define ASUS_SCREENPAD_BRIGHT_MIN 20 -+#define ASUS_SCREENPAD_BRIGHT_MAX 255 -+#define ASUS_SCREENPAD_BRIGHT_DEFAULT 60 -+ - static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; - - static int throttle_thermal_policy_write(struct asus_wmi *); -@@ -212,6 +217,7 @@ struct asus_wmi { - - struct input_dev *inputdev; - struct backlight_device *backlight_device; -+ struct backlight_device *screenpad_backlight_device; - struct platform_device *platform_device; - - struct led_classdev wlan_led; -@@ -3776,6 +3782,124 @@ static int is_display_toggle(int code) - return 0; - } - -+/* Screenpad backlight *******************************************************/ -+ -+static int read_screenpad_backlight_power(struct asus_wmi *asus) -+{ -+ int ret; -+ -+ ret = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_SCREENPAD_POWER); -+ if (ret < 0) -+ return ret; -+ /* 1 == powered */ -+ return ret ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; -+} -+ -+static int read_screenpad_brightness(struct backlight_device *bd) -+{ -+ struct asus_wmi *asus = bl_get_data(bd); -+ u32 retval; -+ int err; -+ -+ err = read_screenpad_backlight_power(asus); -+ if (err < 0) -+ return err; -+ /* The device brightness can only be read if powered, so return stored */ -+ if (err == FB_BLANK_POWERDOWN) -+ return asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN; -+ -+ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &retval); -+ if (err < 0) -+ return err; -+ -+ return (retval & ASUS_WMI_DSTS_BRIGHTNESS_MASK) - ASUS_SCREENPAD_BRIGHT_MIN; -+} -+ -+static int update_screenpad_bl_status(struct backlight_device *bd) -+{ -+ struct asus_wmi *asus = bl_get_data(bd); -+ int power, err = 0; -+ u32 ctrl_param; -+ -+ power = read_screenpad_backlight_power(asus); -+ if (power < 0) -+ return power; -+ -+ if (bd->props.power != power) { -+ if (power != FB_BLANK_UNBLANK) { -+ /* Only brightness > 0 can power it back on */ -+ ctrl_param = asus->driver->screenpad_brightness - ASUS_SCREENPAD_BRIGHT_MIN; -+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, -+ ctrl_param, NULL); -+ } else { -+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_POWER, 0, NULL); -+ } -+ } else if (power == FB_BLANK_UNBLANK) { -+ /* Only set brightness if powered on or we get invalid/unsync state */ -+ ctrl_param = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN; -+ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_SCREENPAD_LIGHT, ctrl_param, NULL); -+ } -+ -+ /* Ensure brightness is stored to turn back on with */ -+ if (err == 0) -+ asus->driver->screenpad_brightness = bd->props.brightness + ASUS_SCREENPAD_BRIGHT_MIN; -+ -+ return err; -+} -+ -+static const struct backlight_ops asus_screenpad_bl_ops = { -+ .get_brightness = read_screenpad_brightness, -+ .update_status = update_screenpad_bl_status, -+ .options = BL_CORE_SUSPENDRESUME, -+}; -+ -+static int asus_screenpad_init(struct asus_wmi *asus) -+{ -+ struct backlight_device *bd; -+ struct backlight_properties props; -+ int err, power; -+ int brightness = 0; -+ -+ power = read_screenpad_backlight_power(asus); -+ if (power < 0) -+ return power; -+ -+ if (power != FB_BLANK_POWERDOWN) { -+ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT, &brightness); -+ if (err < 0) -+ return err; -+ } -+ /* default to an acceptable min brightness on boot if too low */ -+ if (brightness < ASUS_SCREENPAD_BRIGHT_MIN) -+ brightness = ASUS_SCREENPAD_BRIGHT_DEFAULT; -+ -+ memset(&props, 0, sizeof(struct backlight_properties)); -+ props.type = BACKLIGHT_RAW; /* ensure this bd is last to be picked */ -+ props.max_brightness = ASUS_SCREENPAD_BRIGHT_MAX - ASUS_SCREENPAD_BRIGHT_MIN; -+ bd = backlight_device_register("asus_screenpad", -+ &asus->platform_device->dev, asus, -+ &asus_screenpad_bl_ops, &props); -+ if (IS_ERR(bd)) { -+ pr_err("Could not register backlight device\n"); -+ return PTR_ERR(bd); -+ } -+ -+ asus->screenpad_backlight_device = bd; -+ asus->driver->screenpad_brightness = brightness; -+ bd->props.brightness = brightness; -+ bd->props.power = power; -+ backlight_update_status(bd); -+ -+ return 0; -+} -+ -+static void asus_screenpad_exit(struct asus_wmi *asus) -+{ -+ backlight_device_unregister(asus->screenpad_backlight_device); -+ -+ asus->screenpad_backlight_device = NULL; -+} -+ - /* Fn-lock ********************************************************************/ - - static bool asus_wmi_has_fnlock_key(struct asus_wmi *asus) -@@ -4431,6 +4555,12 @@ static int asus_wmi_add(struct platform_device *pdev) - } else if (asus->driver->quirks->wmi_backlight_set_devstate) - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_BACKLIGHT, 2, NULL); - -+ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_SCREENPAD_LIGHT)) { -+ err = asus_screenpad_init(asus); -+ if (err && err != -ENODEV) -+ goto fail_screenpad; -+ } -+ - if (asus_wmi_has_fnlock_key(asus)) { - asus->fnlock_locked = fnlock_default; - asus_wmi_fnlock_update(asus); -@@ -4454,6 +4584,8 @@ static int asus_wmi_add(struct platform_device *pdev) - asus_wmi_backlight_exit(asus); - fail_backlight: - asus_wmi_rfkill_exit(asus); -+fail_screenpad: -+ asus_screenpad_exit(asus); - fail_rfkill: - asus_wmi_led_exit(asus); - fail_leds: -@@ -4480,6 +4612,7 @@ static int asus_wmi_remove(struct platform_device *device) - asus = platform_get_drvdata(device); - wmi_remove_notify_handler(asus->driver->event_guid); - asus_wmi_backlight_exit(asus); -+ asus_screenpad_exit(asus); - asus_wmi_input_exit(asus); - asus_wmi_led_exit(asus); - asus_wmi_rfkill_exit(asus); -diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h -index a478ebfd34df..5fbdd0eafa02 100644 ---- a/drivers/platform/x86/asus-wmi.h -+++ b/drivers/platform/x86/asus-wmi.h -@@ -57,6 +57,7 @@ struct quirk_entry { - struct asus_wmi_driver { - int brightness; - int panel_power; -+ int screenpad_brightness; - int wlan_ctrl_by_user; - - const char *name; -diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index 16e99a1c37fc..63e630276499 100644 ---- a/include/linux/platform_data/x86/asus-wmi.h -+++ b/include/linux/platform_data/x86/asus-wmi.h -@@ -58,6 +58,10 @@ - #define ASUS_WMI_DEVID_KBD_BACKLIGHT 0x00050021 - #define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */ - #define ASUS_WMI_DEVID_LIGHTBAR 0x00050025 -+/* This can only be used to disable the screen, not re-enable */ -+#define ASUS_WMI_DEVID_SCREENPAD_POWER 0x00050031 -+/* Writing a brightness re-enables the screen if disabled */ -+#define ASUS_WMI_DEVID_SCREENPAD_LIGHT 0x00050032 - #define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018 - #define ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY 0x00120075 - --- -2.41.0 - -From 7760e10674dbb9127450629308c6ee1c35d5fc19 Mon Sep 17 00:00:00 2001 -From: "Luke D. Jones" -Date: Thu, 9 Nov 2023 09:41:13 +1300 -Subject: [PATCH] ALSA: hda/realtek: Add quirk for ASUS ROG G814Jx - -Adds the required quirk to enable the Cirrus amp and correct pins -on the ASUS ROG G814J series which uses an SPI connected Cirrus amp. - -While this works if the related _DSD properties are made available, these -aren't included in the ACPI of these laptops (yet). - -Signed-off-by: Luke D. Jones ---- - sound/pci/hda/patch_realtek.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index 58006c8bcfb9..a690baa202c5 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -9924,6 +9924,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1043, 0x1c9f, "ASUS G614JI", ALC285_FIXUP_ASUS_HEADSET_MIC), - SND_PCI_QUIRK(0x1043, 0x1caf, "ASUS G634JYR/JZR", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), - SND_PCI_QUIRK(0x1043, 0x1ccd, "ASUS X555UB", ALC256_FIXUP_ASUS_MIC), -+ SND_PCI_QUIRK(0x1043, 0x1ccf, "ASUS G814JI", ALC285_FIXUP_ASUS_SPI_REAR_SPEAKERS), - SND_PCI_QUIRK(0x1043, 0x1d1f, "ASUS ROG Strix G17 2023 (G713PV)", ALC287_FIXUP_CS35L41_I2C_2), - SND_PCI_QUIRK(0x1043, 0x1d42, "ASUS Zephyrus G14 2022", ALC289_FIXUP_ASUS_GA401), - SND_PCI_QUIRK(0x1043, 0x1d4e, "ASUS TM420", ALC256_FIXUP_ASUS_HPE), --- -2.41.0 diff --git a/patches/asuslinux/rog-ally-audio-fix.patch b/patches/asuslinux/rog-ally-audio-fix.patch deleted file mode 100644 index 9626c61..0000000 --- a/patches/asuslinux/rog-ally-audio-fix.patch +++ /dev/null @@ -1,64 +0,0 @@ -diff --git a/sound/pci/hda/cd35l41_hda_property.c b/sound/pci/hda/cs35l41_hda_property.c -index 6b704fd..d63617f 100644 ---- a/sound/pci/hda/cs35l41_hda_property.c -+++ b/sound/pci/hda/cs35l41_hda_property.c -@@ -6,7 +6,9 @@ - // - // Author: Stefan Binding - -+#include - #include -+#include - #include - #include "cs35l41_hda_property.h" - -@@ -117,6 +119,40 @@ static int asus_rog_2023_no_acpi(struct cs35l41_hda *cs35l41, struct device *phy - return 0; - } - -+static int asus_rog_2023_ally_fix(struct cs35l41_hda *cs35l41, struct device *physdev, int id, -+ const char *hid) -+{ -+ const char *rog_ally_bios_ver = dmi_get_system_info(DMI_BIOS_VERSION); -+ const char *rog_ally_bios_num = rog_ally_bios_ver + 6; // Dropping the RC71L. part before the number -+ int rog_ally_bios_int; -+ kstrtoint(rog_ally_bios_num, 10, &rog_ally_bios_int); -+ if(rog_ally_bios_int >= 330){ -+ printk(KERN_INFO "DSD properties exist in the %d BIOS. Not applying DSD override...\n", rog_ally_bios_int); -+ return -ENOENT; //Patch not applicable. Exiting... -+ } -+ -+ struct cs35l41_hw_cfg *hw_cfg = &cs35l41->hw_cfg; -+ -+ dev_info(cs35l41->dev, "Adding DSD properties for %s\n", cs35l41->acpi_subsystem_id); -+ -+ cs35l41->index = id == 0x40 ? 0 : 1; -+ cs35l41->channel_index = 0; -+ cs35l41->reset_gpio = gpiod_get_index(physdev, NULL, 0, GPIOD_OUT_HIGH); -+ cs35l41->speaker_id = cs35l41_get_speaker_id(physdev, 0, 0, 2); -+ hw_cfg->spk_pos = cs35l41->index; -+ hw_cfg->gpio1.func = CS35L41_NOT_USED; -+ hw_cfg->gpio1.valid = true; -+ hw_cfg->gpio2.func = CS35L41_INTERRUPT; -+ hw_cfg->gpio2.valid = true; -+ hw_cfg->bst_type = CS35L41_INT_BOOST; -+ hw_cfg->bst_ind = 1000; /* 1,000nH Inductance value */ -+ hw_cfg->bst_ipk = 4500; /* 4,500mA peak current */ -+ hw_cfg->bst_cap = 24; /* 24 microFarad cap value */ -+ hw_cfg->valid = true; -+ -+ return 0; -+} -+ - struct cs35l41_prop_model { - const char *hid; - const char *ssid; -@@ -134,7 +170,7 @@ static const struct cs35l41_prop_model cs35l41_prop_model_table[] = { - { "CSC3551", "10431483", asus_rog_2023_no_acpi }, // GU603V spi, rst=1, spkr=1 - { "CSC3551", "10431493", asus_rog_2023_no_acpi }, // GV601V spi, rst=1 - { "CSC3551", "10431573", asus_rog_2023_no_acpi }, // GZ301V spi, rst=0 -- { "CSC3551", "104317F3", asus_rog_2023_no_acpi }, // ROG ALLY i2c, rst=0 -+ { "CSC3551", "104317F3", asus_rog_2023_ally_fix }, // ASUS ROG ALLY - i2c, rst=0 - { "CSC3551", "10431B93", asus_rog_2023_no_acpi }, // G614J spi, rst=0 - { "CSC3551", "10431C9F", asus_rog_2023_no_acpi }, // G614JI spi, rst=0 - { "CSC3551", "10431CAF", asus_rog_2023_no_acpi }, // G634J spi, rst=1 diff --git a/patches/asuslinux/rog-ally-bmc150.patch b/patches/asuslinux/rog-ally-bmc150.patch deleted file mode 100644 index e83d6e3..0000000 --- a/patches/asuslinux/rog-ally-bmc150.patch +++ /dev/null @@ -1,2672 +0,0 @@ -From 622ea77bfccd751247b1c08c3126d7ab716f0423 Mon Sep 17 00:00:00 2001 -From: Denis -Date: Mon, 25 Sep 2023 03:38:49 +0200 -Subject: [PATCH] This commit adds support to the bmi323 device on top of the - pre-existing bmc150 kernel module. - -Some new devices for example the ROG Ally and the Air Plus identify this chip in the ACPI table as a bmc150 so previously the original module was loaded, -but was erroring out as it cannot handle such device. - -The device I own does not allow me to use the interrupt part of the device as the interrupt pin is not connected (or not advertised to be connected) hence -I avoided including on this commit anything related to IRQ. - -This driver has already been proved to work well enough to be used in the switch emulator "yuzu". - -While designing this module my main focus was not to alter the original driver and not to limit the original author in regard to future mofications, -and I was mostly able to achive this, except: -1) I added a new structure on top of the original one and added a field that is responsible for holding information -on what type of chip the module is currently managing -2) the previous point required the init function of the original driver to write that field in order to be sure no bmi323 code -was executed when the old part of the module is managing the device -3) as the original driver issued an i2c write on some register not really meant to be written in the bmi323 device I have made sure an i2c read to discover -the bmi323 is performed prior to that code: such read SHOULD fail in the older bmc150 IC for two reasons: - - the i2c address is not reported in the memory map of the bmc150 in its datasheet - - the i2c read attempts to get 4 bytes out of a 8-bit device - - the fourth bit (the one that cannot be read from a bmc150 device) is initialized to 0 and bmi323 presence is signaled with a 1 in the LSB - that is the fourth coming out of the device in temporal order ---- - drivers/iio/accel/bmc150-accel-core.c | 2307 ++++++++++++++++++++++++- - drivers/iio/accel/bmc150-accel-i2c.c | 100 +- - drivers/iio/accel/bmc150-accel.h | 94 +- - 3 files changed, 2495 insertions(+), 6 deletions(-) - -diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c -index 110591804b4c..9a2c1732c9ef 100644 ---- a/drivers/iio/accel/bmc150-accel-core.c -+++ b/drivers/iio/accel/bmc150-accel-core.c -@@ -130,6 +130,73 @@ - #define BMC150_ACCEL_REG_FIFO_DATA 0x3F - #define BMC150_ACCEL_FIFO_LENGTH 32 - -+#define BMC150_BMI323_TEMPER_CENTER_VAL 23 -+#define BMC150_BMI323_TEMPER_LSB_PER_KELVIN_VAL 512 -+ -+#define BMC150_BMI323_AUTO_SUSPEND_DELAY_MS 2000 -+ -+#define BMC150_BMI323_CHIP_ID_REG 0x00 -+#define BMC150_BMI323_SOFT_RESET_REG 0x7E -+#define BMC150_BMI323_SOFT_RESET_VAL 0xDEAFU -+#define BMC150_BMI323_DATA_BASE_REG 0x03 -+#define BMC150_BMI323_TEMPERATURE_DATA_REG 0x09 -+#define BMC150_BMI323_FIFO_FILL_LEVEL_REG 0x15 -+#define BMC150_BMI323_FIFO_DATA_REG 0x16 -+#define BMC150_BMI323_ACC_CONF_REG 0x20 -+#define BMC150_BMI323_GYR_CONF_REG 0x21 -+#define BMC150_BMI323_FIFO_CONF_REG 0x36 -+ -+// these are bits [0:3] of ACC_CONF.acc_odr, sample rate in Hz for the accel part of the chip -+#define BMC150_BMI323_ACCEL_ODR_0_78123_VAL 0x0001 -+#define BMC150_BMI323_ACCEL_ODR_1_5625_VAL 0x0002 -+#define BMC150_BMI323_ACCEL_ODR_3_125_VAL 0x0003 -+#define BMC150_BMI323_ACCEL_ODR_6_25_VAL 0x0004 -+#define BMC150_BMI323_ACCEL_ODR_12_5_VAL 0x0005 -+#define BMC150_BMI323_ACCEL_ODR_25_VAL 0x0006 -+#define BMC150_BMI323_ACCEL_ODR_50_VAL 0x0007 -+#define BMC150_BMI323_ACCEL_ODR_100_VAL 0x0008 -+#define BMC150_BMI323_ACCEL_ODR_200_VAL 0x0009 -+#define BMC150_BMI323_ACCEL_ODR_400_VAL 0x000A -+#define BMC150_BMI323_ACCEL_ODR_800_VAL 0x000B -+#define BMC150_BMI323_ACCEL_ODR_1600_VAL 0x000C -+#define BMC150_BMI323_ACCEL_ODR_3200_VAL 0x000D -+#define BMC150_BMI323_ACCEL_ODR_6400_VAL 0x000E -+ -+#define BMC150_BMI323_ACCEL_BW_ODR_2_VAL 0x0000 -+#define BMC150_BMI323_ACCEL_BW_ODR_4_VAL 0x0001 -+ -+// these are bits [4:6] of ACC_CONF.acc_range, full scale resolution -+#define BMC150_BMI323_ACCEL_RANGE_2_VAL 0x0000 // +/-2g, 16.38 LSB/mg -+#define BMC150_BMI323_ACCEL_RANGE_4_VAL 0x0001 // +/-4g, 8.19 LSB/mg -+#define BMC150_BMI323_ACCEL_RANGE_8_VAL 0x0002 // +/-8g, 4.10 LSB/mg -+#define BMC150_BMI323_ACCEL_RANGE_16_VAL 0x0003 // +/-4g, 2.05 LSB/mg -+ -+// these are bits [0:3] of GYR_CONF.gyr_odr, sample rate in Hz for the gyro part of the chip -+#define BMC150_BMI323_GYRO_ODR_0_78123_VAL 0x0001 -+#define BMC150_BMI323_GYRO_ODR_1_5625_VAL 0x0002 -+#define BMC150_BMI323_GYRO_ODR_3_125_VAL 0x0003 -+#define BMC150_BMI323_GYRO_ODR_6_25_VAL 0x0004 -+#define BMC150_BMI323_GYRO_ODR_12_5_VAL 0x0005 -+#define BMC150_BMI323_GYRO_ODR_25_VAL 0x0006 -+#define BMC150_BMI323_GYRO_ODR_50_VAL 0x0007 -+#define BMC150_BMI323_GYRO_ODR_100_VAL 0x0008 -+#define BMC150_BMI323_GYRO_ODR_200_VAL 0x0009 -+#define BMC150_BMI323_GYRO_ODR_400_VAL 0x000A -+#define BMC150_BMI323_GYRO_ODR_800_VAL 0x000B -+#define BMC150_BMI323_GYRO_ODR_1600_VAL 0x000C -+#define BMC150_BMI323_GYRO_ODR_3200_VAL 0x000D -+#define BMC150_BMI323_GYRO_ODR_6400_VAL 0x000E -+ -+#define BMC150_BMI323_GYRO_BW_ODR_2_VAL 0x0000 -+#define BMC150_BMI323_GYRO_BW_ODR_4_VAL 0x0001 -+ -+// these are bits [4:6] of GYR_CONF.gyr_range, full scale resolution -+#define BMC150_BMI323_GYRO_RANGE_125_VAL 0x0000 // +/-125°/s, 262.144 LSB/°/s -+#define BMC150_BMI323_GYRO_RANGE_250_VAL 0x0001 // +/-250°/s, 131.2 LSB/°/s -+#define BMC150_BMI323_GYRO_RANGE_500_VAL 0x0002 // +/-500°/s, 65.6 LSB/°/s -+#define BMC150_BMI323_GYRO_RANGE_1000_VAL 0x0003 // +/-1000°/s, 32.8 LSB/°/s -+#define BMC150_BMI323_GYRO_RANGE_2000_VAL 0x0004 // +/-2000°/s, 16.4 LSB/°/s -+ - enum bmc150_accel_axis { - AXIS_X, - AXIS_Y, -@@ -149,6 +216,654 @@ struct bmc150_scale_info { - u8 reg_range; - }; - -+/* -+ * This enum MUST not be altered as there are parts in the code that -+ * uses an int conversion to get the correct device register to read. -+ */ -+enum bmi323_axis { -+ BMI323_ACCEL_AXIS_X = 0, -+ BMI323_ACCEL_AXIS_Y, -+ BMI323_ACCEL_AXIS_Z, -+ BMI323_GYRO_AXIS_X, -+ BMI323_GYRO_AXIS_Y, -+ BMI323_GYRO_AXIS_Z, -+ BMI323_TEMP, -+ BMI323_AXIS_MAX, -+}; -+ -+static const struct bmi323_scale_accel_info { -+ u8 hw_val; -+ int val; -+ int val2; -+ int ret_type; -+} bmi323_accel_scale_map[] = { -+ { -+ .hw_val = (u16)BMC150_BMI323_ACCEL_RANGE_2_VAL << (u16)4, -+ .val = 0, -+ .val2 = 598, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_ACCEL_RANGE_4_VAL << (u16)4, -+ .val = 0, -+ .val2 = 1196, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_ACCEL_RANGE_8_VAL << (u16)4, -+ .val = 0, -+ .val2 = 2392, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_ACCEL_RANGE_16_VAL << (u16)4, -+ .val = 0, -+ .val2 = 4785, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+}; -+ -+static const struct bmi323_scale_gyro_info { -+ u8 hw_val; -+ int val; -+ int val2; -+ int ret_type; -+} bmi323_gyro_scale_map[] = { -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_125_VAL << (u16)4, -+ .val = 0, -+ .val2 = 66545, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_125_VAL << (u16)4, -+ .val = 0, -+ .val2 = 66, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_250_VAL << (u16)4, -+ .val = 0, -+ .val2 = 133090, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_250_VAL << (u16)4, -+ .val = 0, -+ .val2 = 133, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_500_VAL << (u16)4, -+ .val = 0, -+ .val2 = 266181, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_500_VAL << (u16)4, -+ .val = 0, -+ .val2 = 266, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_1000_VAL << (u16)4, -+ .val = 0, -+ .val2 = 532362, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_1000_VAL << (u16)4, -+ .val = 0, -+ .val2 = 532, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_2000_VAL << (u16)4, -+ .val = 0, -+ .val2 = 1064724, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ // this shouldn't be necessary, but iio seems to have a wrong rounding of this value... -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_2000_VAL << (u16)4, -+ .val = 0, -+ .val2 = 1064, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+ { -+ .hw_val = (u16)BMC150_BMI323_GYRO_RANGE_2000_VAL << (u16)4, -+ .val = 0, -+ .val2 = 1065, -+ .ret_type = IIO_VAL_INT_PLUS_NANO, -+ }, -+}; -+ -+/* -+ * this reflects the frequency map that is following. -+ * For each index i of that map index i*2 and i*2+1 of of this -+ * holds ODR/2 and ODR/4 -+ */ -+static const struct bmi323_3db_freq_cutoff_accel_info { -+ int val; -+ int val2; -+ int ret_type; -+} bmi323_accel_3db_freq_cutoff[] = { -+ { -+ .val = 0, -+ .val2 = 390615, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 195308, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 781300, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 390650, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1, -+ .val2 = 562500, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 78125, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 3, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1, -+ .val2 = 500000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 6, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 3, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 12, -+ .val2 = 500000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 6, -+ .val2 = 250000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 25, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 12, -+ .val2 = 500000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 50, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 25, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 100, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 50, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 200, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 100, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 400, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 200, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 800, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 400, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1600, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 800, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1600, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 800, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 3200, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1600, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+}; -+ -+static const struct bmi323_freq_accel_info { -+ u8 hw_val; -+ int val; -+ int val2; -+ s64 time_ns; -+} bmi323_accel_odr_map[] = { -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_0_78123_VAL, -+ .val = 0, -+ .val2 = 781230, -+ .time_ns = 1280032769, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_1_5625_VAL, -+ .val = 1, -+ .val2 = 562600, -+ .time_ns = 886522247, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_3_125_VAL, -+ .val = 3, -+ .val2 = 125000, -+ .time_ns = 320000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_6_25_VAL, -+ .val = 6, -+ .val2 = 250000, -+ .time_ns = 160000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_12_5_VAL, -+ .val = 12, -+ .val2 = 500000, -+ .time_ns = 80000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_25_VAL, -+ .val = 25, -+ .val2 = 0, -+ .time_ns = 40000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_50_VAL, -+ .val = 50, -+ .val2 = 0, -+ .time_ns = 20000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_100_VAL, -+ .val = 100, -+ .val2 = 0, -+ .time_ns = 10000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_200_VAL, -+ .val = 200, -+ .val2 = 0, -+ .time_ns = 5000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_400_VAL, -+ .val = 400, -+ .val2 = 0, -+ .time_ns = 2500000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_800_VAL, -+ .val = 800, -+ .val2 = 0, -+ .time_ns = 1250000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_1600_VAL, -+ .val = 1600, -+ .val2 = 0, -+ .time_ns = 625000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_3200_VAL, -+ .val = 3200, -+ .val2 = 0, -+ .time_ns = 312500, -+ }, -+ { -+ .hw_val = BMC150_BMI323_ACCEL_ODR_6400_VAL, -+ .val = 6400, -+ .val2 = 0, -+ .time_ns = 156250, -+ }, -+}; -+ -+static const struct bmi323_freq_gyro_info { -+ u8 hw_val; -+ int val; -+ int val2; -+ s64 time_ns; -+} bmi323_gyro_odr_map[] = { -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_0_78123_VAL, -+ .val = 0, -+ .val2 = 781230, -+ .time_ns = 1280032769, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_1_5625_VAL, -+ .val = 1, -+ .val2 = 562600, -+ .time_ns = 886522247, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_3_125_VAL, -+ .val = 3, -+ .val2 = 125000, -+ .time_ns = 320000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_6_25_VAL, -+ .val = 6, -+ .val2 = 250000, -+ .time_ns = 160000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_12_5_VAL, -+ .val = 12, -+ .val2 = 500000, -+ .time_ns = 80000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_25_VAL, -+ .val = 25, -+ .val2 = 0, -+ .time_ns = 40000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_50_VAL, -+ .val = 50, -+ .val2 = 0, -+ .time_ns = 20000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_100_VAL, -+ .val = 100, -+ .val2 = 0, -+ .time_ns = 10000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_200_VAL, -+ .val = 200, -+ .val2 = 0, -+ .time_ns = 5000000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_400_VAL, -+ .val = 400, -+ .val2 = 0, -+ .time_ns = 2500000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_800_VAL, -+ .val = 800, -+ .val2 = 0, -+ .time_ns = 1250000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_1600_VAL, -+ .val = 1600, -+ .val2 = 0, -+ .time_ns = 625000, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_3200_VAL, -+ .val = 3200, -+ .val2 = 0, -+ .time_ns = 312500, -+ }, -+ { -+ .hw_val = BMC150_BMI323_GYRO_ODR_6400_VAL, -+ .val = 6400, -+ .val2 = 0, -+ .time_ns = 156250, -+ }, -+}; -+ -+static const struct bmi323_3db_freq_cutoff_gyro_info { -+ int val; -+ int val2; -+ int ret_type; -+} bmi323_gyro_3db_freq_cutoff[] = { -+ { -+ .val = 0, -+ .val2 = 390615, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 1953075, // TODO: check if this gets reported correctly... -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 781300, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 390650, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1, -+ .val2 = 562500, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 0, -+ .val2 = 78125, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 3, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1, -+ .val2 = 500000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 6, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 3, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 12, -+ .val2 = 500000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 6, -+ .val2 = 250000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 25, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 12, -+ .val2 = 500000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 50, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 25, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 100, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 50, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 200, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 100, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 400, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 200, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 800, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 400, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1600, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 800, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1600, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 800, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 3200, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+ { -+ .val = 1600, -+ .val2 = 000000, -+ .ret_type = IIO_VAL_INT_PLUS_MICRO, -+ }, -+}; -+ -+static const int bmi323_accel_scales[] = { -+ 0, 598, 0, 1196, 0, 2392, 0, 4785, -+}; -+ -+static const int bmi323_gyro_scales[] = { -+ 0, 66545, 0, 133090, 0, 266181, 0, 532362, 0, 1064724, -+}; -+ -+static const int bmi323_sample_freqs[] = { -+ 0, 781230, 1, 562600, 3, 125000, 6, 250000, 12, 500000, -+ 25, 0, 50, 0, 100, 0, 200, 0, 400, 0, -+ 800, 0, 1600, 0, 3200, 0, 6400, 0, -+}; -+ -+static const struct { -+ int val; -+ int val2; // IIO_VAL_INT_PLUS_MICRO -+ u8 bw_bits; -+} bmi323_samp_freq_table[] = { { 15, 620000, 0x08 }, { 31, 260000, 0x09 }, -+ { 62, 500000, 0x0A }, { 125, 0, 0x0B }, -+ { 250, 0, 0x0C }, { 500, 0, 0x0D }, -+ { 1000, 0, 0x0E }, { 2000, 0, 0x0F } }; -+ - struct bmc150_accel_chip_info { - const char *name; - u8 chip_id; -@@ -1113,6 +1828,52 @@ static const struct iio_event_spec bmc150_accel_event = { - .num_event_specs = 1 \ - } - -+#define BMI323_ACCEL_CHANNEL(_axis, bits) \ -+ { \ -+ .type = IIO_ACCEL, .modified = 1, .channel2 = IIO_MOD_##_axis, \ -+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ -+ .info_mask_shared_by_type = \ -+ BIT(IIO_CHAN_INFO_SCALE) | \ -+ BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ -+ BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ -+ .info_mask_shared_by_type_available = \ -+ BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ -+ BIT(IIO_CHAN_INFO_SCALE), \ -+ .scan_index = BMI323_ACCEL_AXIS_##_axis, \ -+ .scan_type = { \ -+ .sign = 's', \ -+ .realbits = (bits), \ -+ .storagebits = 16, \ -+ .shift = 16 - (bits), \ -+ .endianness = IIO_LE, \ -+ }, \ -+ } -+ -+#define BMI323_GYRO_CHANNEL(_axis, bits) \ -+ { \ -+ .type = IIO_ANGL_VEL, .modified = 1, \ -+ .channel2 = IIO_MOD_##_axis, \ -+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ -+ .info_mask_shared_by_type = \ -+ BIT(IIO_CHAN_INFO_SCALE) | \ -+ BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ -+ BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ -+ .info_mask_shared_by_type_available = \ -+ BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ -+ BIT(IIO_CHAN_INFO_SCALE), \ -+ .scan_index = BMI323_GYRO_AXIS_##_axis, \ -+ .scan_type = { \ -+ .sign = 's', \ -+ .realbits = (bits), \ -+ .storagebits = 16, \ -+ .shift = 16 - (bits), \ -+ .endianness = IIO_LE, \ -+ }, \ -+ /*.ext_info = bmi323_accel_ext_info,*/ \ -+ /*.event_spec = &bmi323_accel_event,*/ \ -+ /*.num_event_specs = 1*/ \ -+ } -+ - #define BMC150_ACCEL_CHANNELS(bits) { \ - { \ - .type = IIO_TEMP, \ -@@ -1595,7 +2356,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) - struct device *dev = regmap_get_device(data->regmap); - int ret, i; - unsigned int val; -- -+ - /* - * Reset chip to get it in a known good state. A delay of 1.8ms after - * reset is required according to the data sheets of supported chips. -@@ -1677,6 +2438,11 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, - data = iio_priv(indio_dev); - dev_set_drvdata(dev, indio_dev); - -+ /* -+ * Setting the dev_type here is necessary to avoid having it left uninitialized -+ * and therefore potentially executing bmi323 functions for the original bmc150 model. -+ */ -+ data->dev_type = BMC150; - data->regmap = regmap; - data->type = type; - -@@ -1826,12 +2592,1407 @@ void bmc150_accel_core_remove(struct device *dev) - } - EXPORT_SYMBOL_NS_GPL(bmc150_accel_core_remove, IIO_BMC150); - --#ifdef CONFIG_PM_SLEEP --static int bmc150_accel_suspend(struct device *dev) -+struct device *bmi323_get_managed_device(struct bmi323_private_data *bmi323) -+{ -+ if (bmi323->i2c_client != NULL) -+ return &bmi323->i2c_client->dev; -+ -+ return &bmi323->spi_client->dev; -+} -+ -+static int bmi323_set_power_state(struct bmi323_private_data *bmi323, bool on) -+{ -+#ifdef CONFIG_PM -+ struct device *dev = bmi323_get_managed_device(bmi323); -+ int ret; -+ -+ if (on) -+ ret = pm_runtime_get_sync(dev); -+ else { -+ pm_runtime_mark_last_busy(dev); -+ ret = pm_runtime_put_autosuspend(dev); -+ } -+ -+ if (ret < 0) { -+ dev_err(dev, "bmi323_set_power_state failed with %d\n", on); -+ -+ if (on) -+ pm_runtime_put_noidle(dev); -+ -+ return ret; -+ } -+#endif -+ -+ return 0; -+} -+ -+int bmi323_write_u16(struct bmi323_private_data *bmi323, u8 in_reg, -+ u16 in_value) -+{ -+ s32 ret; -+ -+ if (bmi323->i2c_client != NULL) { -+ ret = i2c_smbus_write_i2c_block_data(bmi323->i2c_client, in_reg, -+ sizeof(in_value), -+ (u8 *)(&in_value)); -+ if (ret != 0) { -+ return -2; -+ } -+ -+ return 0; -+ } else if (bmi323->spi_client != NULL) { -+ /* -+ * To whoever may need this: implementing this should be straightforward: -+ * it's specular to the i2c part. -+ */ -+ -+ return -EINVAL; // TODO: change with 0 once implemented -+ } -+ -+ return -EINVAL; -+} -+EXPORT_SYMBOL_NS_GPL(bmi323_write_u16, IIO_BMC150); -+ -+int bmi323_read_u16(struct bmi323_private_data *bmi323, u8 in_reg, -+ u16 *out_value) -+{ -+ s32 ret; -+ u8 read_bytes[4]; -+ -+ if (bmi323->i2c_client != NULL) { -+ ret = i2c_smbus_read_i2c_block_data(bmi323->i2c_client, in_reg, -+ sizeof(read_bytes), -+ &read_bytes[0]); -+ if (ret != 4) { -+ return ret; -+ } -+ -+ // DUMMY = read_bytes[0] -+ // DUMMY = read_bytes[1] -+ // LSB = read_bytes[2] -+ // MSB = read_bytes[3] -+ u8 *o = (u8 *)out_value; -+ o[0] = read_bytes[2]; -+ o[1] = read_bytes[3]; -+ -+ return 0; -+ } else if (bmi323->spi_client != NULL) { -+ printk(KERN_CRIT -+ "bmi323: SPI interface is not yet implemented.\n"); -+ -+ /* -+ * To whoever may need this: implementing this should be straightforward: -+ * it's specular to the i2c part except that the dummy data is just 1 byte. -+ */ -+ -+ return -EINVAL; // TODO: change with 0 once implemented -+ } -+ -+ return -EINVAL; -+} -+EXPORT_SYMBOL_NS_GPL(bmi323_read_u16, IIO_BMC150); -+ -+int bmi323_chip_check(struct bmi323_private_data *bmi323) -+{ -+ u16 chip_id; -+ int ret; -+ -+ ret = bmi323_read_u16(bmi323, BMC150_BMI323_CHIP_ID_REG, &chip_id); -+ if (ret != 0) { -+ return ret; -+ } -+ -+ if (((chip_id)&0x00FF) != cpu_to_le16((u16)0x0043U)) { -+ dev_err(bmi323->dev, -+ "bmi323_chip_check failed with: %d; chip_id = 0x%04x", -+ ret, chip_id); -+ -+ return -EINVAL; -+ } -+ -+ return 0; -+} -+EXPORT_SYMBOL_NS_GPL(bmi323_chip_check, IIO_BMC150); -+ -+static int bmi323_buffer_preenable(struct iio_dev *indio_dev) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ -+ const int ret = bmi323_set_power_state(&data->bmi323, true); -+ -+ if (ret == 0) { -+ mutex_lock(&data->bmi323.mutex); -+ data->bmi323.fifo_frame_time_diff_ns = -+ (data->bmi323.acc_odr_time_ns >= -+ data->bmi323.gyr_odr_time_ns) ? -+ data->bmi323.acc_odr_time_ns : -+ data->bmi323.gyr_odr_time_ns; -+ mutex_unlock(&data->bmi323.mutex); -+ } -+ -+ return ret; -+} -+ -+static int bmi323_buffer_postenable(struct iio_dev *indio_dev) -+{ -+ //struct bmc150_accel_data *data = iio_priv(indio_dev); -+ -+ /* -+ * This code is a placeholder until I can get a way to test it -+ */ -+ -+ return 0; -+} -+ -+static int bmi323_buffer_predisable(struct iio_dev *indio_dev) -+{ -+ //struct bmc150_accel_data *data = iio_priv(indio_dev); -+ -+ /* -+ * This code is a placeholder until I can get a way to test it -+ */ -+ -+ return 0; -+} -+ -+static int bmi323_buffer_postdisable(struct iio_dev *indio_dev) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ -+ return bmi323_set_power_state(&data->bmi323, true); -+} -+ -+static const struct iio_buffer_setup_ops bmi323_buffer_ops = { -+ .preenable = bmi323_buffer_preenable, -+ .postenable = bmi323_buffer_postenable, -+ .predisable = bmi323_buffer_predisable, -+ .postdisable = bmi323_buffer_postdisable, -+}; -+ -+int bmi323_chip_rst(struct bmi323_private_data *bmi323) -+{ -+ u16 sensor_status = 0x0000, device_status = 0x0000; -+ int ret; -+ -+ ret = bmi323_write_u16(bmi323, BMC150_BMI323_SOFT_RESET_REG, -+ cpu_to_le16((u16)BMC150_BMI323_SOFT_RESET_VAL)); -+ if (ret != 0) { -+ dev_err(bmi323->dev, -+ "bmi323: error while issuing the soft-reset command: %d", -+ ret); -+ return ret; -+ } -+ -+ /* wait the specified amount of time... I agree with the bmc150 module: better safe than sorry. */ -+ msleep(5); -+ -+ // if the device is connected over SPI a dummy read is to be performed once after each reset -+ if (bmi323->spi_client != NULL) { -+ dev_info(bmi323->dev, -+ "issuing the dummy read to switch mode to SPI"); -+ -+ // do not even check the result of that... it's just a dummy read -+ bmi323_chip_check(bmi323); -+ } -+ -+ ret = bmi323_chip_check(bmi323); -+ if (ret != 0) { -+ return ret; -+ } -+ -+ /* now check the correct initialization status as per datasheet */ -+ ret = bmi323_read_u16(bmi323, 0x01, &device_status); -+ if (ret != 0) { -+ return -EINVAL; -+ } -+ -+ if ((device_status & cpu_to_le16((u16)0x00FFU)) != -+ cpu_to_le16((u16)0x0000U)) { -+ dev_err(bmi323->dev, -+ "bmi323: device_status incorrect: %d; device_status = 0x%04x", -+ ret, device_status); -+ -+ /* from the datasheet: power error */ -+ return -EINVAL; -+ } -+ -+ /* from the datasheet: power ok */ -+ ret = bmi323_read_u16(bmi323, 0x02, &sensor_status); -+ if (ret != 0) { -+ return -EINVAL; -+ } -+ -+ if ((sensor_status & cpu_to_le16((u16)0x00FFU)) != -+ cpu_to_le16((u16)0x0001U)) { -+ dev_err(bmi323->dev, -+ "bmi323: sensor_status incorrect: %d; sensor_status = 0x%04x", -+ ret, sensor_status); -+ -+ /* from the datasheet: initialization error */ -+ return -EINVAL; -+ } -+ -+ /* from the datasheet: initialization ok */ -+ return 0; -+} -+EXPORT_SYMBOL_NS_GPL(bmi323_chip_rst, IIO_BMC150); -+ -+static const struct iio_chan_spec bmi323_channels[] = { -+ BMI323_ACCEL_CHANNEL(X, 16), -+ BMI323_ACCEL_CHANNEL(Y, 16), -+ BMI323_ACCEL_CHANNEL(Z, 16), -+ BMI323_GYRO_CHANNEL(X, 16), -+ BMI323_GYRO_CHANNEL(Y, 16), -+ BMI323_GYRO_CHANNEL(Z, 16), -+ { -+ .type = IIO_TEMP, -+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | -+ BIT(IIO_CHAN_INFO_SCALE) | -+ BIT(IIO_CHAN_INFO_OFFSET), -+ .scan_index = BMI323_TEMP, -+ }, -+ IIO_CHAN_SOFT_TIMESTAMP(BMI323_AXIS_MAX), -+}; -+ -+static int bmi323_read_raw(struct iio_dev *indio_dev, -+ struct iio_chan_spec const *chan, int *val, -+ int *val2, long mask) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ int ret = -EINVAL, was_sleep_modified = -1; -+ u16 raw_read = 0x8000; -+ -+ mutex_lock(&data->bmi323.mutex); -+ -+ if ((data->bmi323.flags & BMI323_FLAGS_RESET_FAILED) != 0x00U) { -+ dev_err(data->bmi323.dev, -+ "bmi323 error: device has not being woken up correctly."); -+ mutex_unlock(&data->bmi323.mutex); -+ return -EBUSY; -+ } -+ -+ switch (mask) { -+ case IIO_CHAN_INFO_RAW: { -+ switch (chan->type) { -+ case IIO_TEMP: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_read_raw_error; -+ } -+ -+ was_sleep_modified = -+ bmi323_set_power_state(&data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ goto bmi323_read_raw_error_power; -+ } -+ -+ ret = iio_device_claim_direct_mode(indio_dev); -+ if (ret != 0) { -+ printk(KERN_CRIT -+ "bmc150 bmi323_read_raw IIO_TEMP iio_device_claim_direct_mode returned %d\n", -+ ret); -+ goto bmi323_read_raw_error; -+ } -+ -+ ret = bmi323_read_u16( -+ &data->bmi323, -+ BMC150_BMI323_TEMPERATURE_DATA_REG, &raw_read); -+ iio_device_release_direct_mode(indio_dev); -+ if (ret != 0) { -+ printk(KERN_CRIT -+ "bmc150 bmi323_read_raw IIO_TEMP bmi323_read_u16 returned %d\n", -+ ret); -+ goto bmi323_read_raw_error; -+ } -+ -+ *val = sign_extend32(le16_to_cpu(raw_read), 15); -+ bmi323_set_power_state(&data->bmi323, false); -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT; -+ -+ case IIO_ACCEL: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_read_raw_error; -+ } -+ -+ was_sleep_modified = -+ bmi323_set_power_state(&data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ goto bmi323_read_raw_error_power; -+ } -+ -+ ret = iio_device_claim_direct_mode(indio_dev); -+ if (ret != 0) { -+ printk(KERN_CRIT -+ "bmc150 bmi323_read_raw IIO_ACCEL iio_device_claim_direct_mode returned %d\n", -+ ret); -+ goto bmi323_read_raw_error; -+ } -+ -+ ret = bmi323_read_u16(&data->bmi323, -+ BMC150_BMI323_DATA_BASE_REG + -+ (u8)(chan->scan_index), -+ &raw_read); -+ iio_device_release_direct_mode(indio_dev); -+ if (ret != 0) { -+ printk(KERN_CRIT -+ "bmc150 bmi323_read_raw IIO_ACCEL bmi323_read_u16 returned %d\n", -+ ret); -+ goto bmi323_read_raw_error; -+ } -+ *val = sign_extend32(le16_to_cpu(raw_read), 15); -+ bmi323_set_power_state(&data->bmi323, false); -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT; -+ -+ case IIO_ANGL_VEL: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_read_raw_error; -+ } -+ -+ was_sleep_modified = -+ bmi323_set_power_state(&data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ goto bmi323_read_raw_error_power; -+ } -+ -+ ret = iio_device_claim_direct_mode(indio_dev); -+ if (ret != 0) { -+ printk(KERN_CRIT -+ "bmc150 bmi323_read_raw IIO_ANGL_VEL iio_device_claim_direct_mode returned %d\n", -+ ret); -+ goto bmi323_read_raw_error; -+ } -+ -+ ret = bmi323_read_u16(&data->bmi323, -+ BMC150_BMI323_DATA_BASE_REG + -+ (u8)(chan->scan_index), -+ &raw_read); -+ iio_device_release_direct_mode(indio_dev); -+ if (ret != 0) { -+ printk(KERN_CRIT -+ "bmc150 bmi323_read_raw IIO_ANGL_VEL bmi323_read_u16 returned %d\n", -+ ret); -+ goto bmi323_read_raw_error; -+ } -+ -+ *val = sign_extend32(le16_to_cpu(raw_read), 15); -+ bmi323_set_power_state(&data->bmi323, false); -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT; -+ -+ default: -+ goto bmi323_read_raw_error; -+ } -+ } -+ case IIO_CHAN_INFO_OFFSET: { -+ switch (chan->type) { -+ case IIO_TEMP: -+ *val = BMC150_BMI323_TEMPER_CENTER_VAL; -+ *val2 = 0; -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT; -+ -+ default: -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ } -+ case IIO_CHAN_INFO_SCALE: -+ switch (chan->type) { -+ case IIO_TEMP: { -+ *val = 0; -+ *val2 = BMC150_BMI323_TEMPER_LSB_PER_KELVIN_VAL; -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_FRACTIONAL; -+ } -+ case IIO_ACCEL: { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323.acc_conf_reg_value; -+ for (int s = 0; s < ARRAY_SIZE(bmi323_accel_scale_map); -+ ++s) { -+ if (((le_raw_read[0]) & ((u16)0b01110000U)) == -+ (bmi323_accel_scale_map[s].hw_val)) { -+ *val = bmi323_accel_scale_map[s].val; -+ *val2 = bmi323_accel_scale_map[s].val2; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return bmi323_accel_scale_map[s] -+ .ret_type; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ case IIO_ANGL_VEL: { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323.gyr_conf_reg_value; -+ for (int s = 0; s < ARRAY_SIZE(bmi323_gyro_scale_map); -+ ++s) { -+ if (((le_raw_read[0]) & ((u16)0b01110000U)) == -+ (bmi323_gyro_scale_map[s].hw_val)) { -+ *val = bmi323_gyro_scale_map[s].val; -+ *val2 = bmi323_gyro_scale_map[s].val2; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return bmi323_gyro_scale_map[s].ret_type; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ default: -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: -+ switch (chan->type) { -+ case IIO_ACCEL: { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323.acc_conf_reg_value; -+ for (int s = 0; s < ARRAY_SIZE(bmi323_accel_odr_map); -+ ++s) { -+ if (((le_raw_read[0]) & ((u16)0x0FU)) == -+ (bmi323_accel_odr_map[s].hw_val)) { -+ /* -+ * from tha datasheed: -3dB cut-off frequency can be configured with the bit 7 of GYR_confm, -+ * also called acc_bw that can either be 0 or 1, where 1 means odr/4 and 0 means odr/2 -+ */ -+ int freq_adj_idx = -+ (((le_raw_read[0]) & -+ ((u8)0x80U)) == (u8)0x00U) ? -+ (s * 2) + 0 : -+ (s * 2) + 1; -+ *val = bmi323_accel_3db_freq_cutoff -+ [freq_adj_idx] -+ .val; -+ *val2 = bmi323_accel_3db_freq_cutoff -+ [freq_adj_idx] -+ .val2; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT_PLUS_MICRO; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ case IIO_ANGL_VEL: { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323.gyr_conf_reg_value; -+ for (int s = 0; s < ARRAY_SIZE(bmi323_gyro_odr_map); -+ ++s) { -+ if (((le_raw_read[0]) & ((u16)0x0FU)) == -+ (bmi323_gyro_odr_map[s].hw_val)) { -+ /* -+ * from tha datasheed: -3dB cut-off frequency can be configured with the bit 7 of GYR_confm, -+ * also called acc_bw that can either be 0 or 1, where 1 means odr/4 and 0 means odr/2 -+ */ -+ int freq_adj_idx = -+ (((le_raw_read[0]) & -+ ((u8)0x80U)) == (u8)0x0000U) ? -+ (s * 2) + 0 : -+ (s * 2) + 1; -+ *val = bmi323_gyro_3db_freq_cutoff -+ [freq_adj_idx] -+ .val; -+ *val2 = bmi323_gyro_3db_freq_cutoff -+ [freq_adj_idx] -+ .val2; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return bmi323_gyro_3db_freq_cutoff -+ [freq_adj_idx] -+ .ret_type; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ default: { -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ } -+ case IIO_CHAN_INFO_SAMP_FREQ: -+ switch (chan->type) { -+ case IIO_TEMP: { -+ -+ // while in normal or power mode the temperature sensur has a 50Hz sampling frequency -+ *val = 50; -+ *val2 = 0; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT_PLUS_MICRO; -+ } -+ case IIO_ACCEL: { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323.acc_conf_reg_value; -+ for (int s = 0; s < ARRAY_SIZE(bmi323_accel_odr_map); -+ ++s) { -+ if (((le_raw_read[0]) & ((u16)0x0FU)) == -+ (bmi323_accel_odr_map[s].hw_val)) { -+ *val = bmi323_accel_odr_map[s].val; -+ *val2 = bmi323_accel_odr_map[s].val2; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT_PLUS_MICRO; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ case IIO_ANGL_VEL: { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323.gyr_conf_reg_value; -+ for (int s = 0; s < ARRAY_SIZE(bmi323_gyro_odr_map); -+ ++s) { -+ if (((le_raw_read[0]) & ((u16)0x0FU)) == -+ (bmi323_gyro_odr_map[s].hw_val)) { -+ *val = bmi323_gyro_odr_map[s].val; -+ *val2 = bmi323_gyro_odr_map[s].val2; -+ -+ mutex_unlock(&data->bmi323.mutex); -+ return IIO_VAL_INT_PLUS_MICRO; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ default: -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ default: -+ ret = -EINVAL; -+ goto bmi323_read_raw_error; -+ } -+ -+bmi323_read_raw_error: -+ if (was_sleep_modified == 0) { -+ bmi323_set_power_state(&data->bmi323, false); -+ } -+ -+bmi323_read_raw_error_power: -+ mutex_unlock(&data->bmi323.mutex); -+ return ret; -+} -+ -+static int bmi323_write_raw(struct iio_dev *indio_dev, -+ struct iio_chan_spec const *chan, int val, int val2, -+ long mask) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ int ret = -EINVAL, was_sleep_modified = -1; -+ -+ mutex_lock(&data->bmi323.mutex); -+ -+ if ((data->bmi323.flags & BMI323_FLAGS_RESET_FAILED) != 0x00U) { -+ dev_err(data->bmi323.dev, -+ "bmi323 error: device has not being woken up correctly."); -+ mutex_unlock(&data->bmi323.mutex); -+ return -EBUSY; -+ } -+ -+ switch (mask) { -+ case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: -+ switch (chan->type) { -+ default: { -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ } -+ } -+ case IIO_CHAN_INFO_SAMP_FREQ: -+ switch (chan->type) { -+ case IIO_ACCEL: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_write_raw_error; -+ } -+ -+ for (int s = 0; s < ARRAY_SIZE(bmi323_accel_odr_map); -+ ++s) { -+ if ((bmi323_accel_odr_map[s].val == val) && -+ (bmi323_accel_odr_map[s].val2 == val2)) { -+ const u16 conf_backup = -+ data->bmi323.acc_conf_reg_value; -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323 -+ .acc_conf_reg_value; -+ le_raw_read[0] &= (u8)0b11110000U; -+ le_raw_read[0] |= -+ ((u8)bmi323_gyro_odr_map[s] -+ .hw_val); -+ -+ was_sleep_modified = -+ bmi323_set_power_state( -+ &data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ data->bmi323.acc_conf_reg_value = -+ conf_backup; -+ goto bmi323_write_raw_error_power; -+ } -+ -+ ret = bmi323_write_u16( -+ &data->bmi323, -+ BMC150_BMI323_ACC_CONF_REG, -+ data->bmi323.acc_conf_reg_value); -+ if (ret != 0) { -+ data->bmi323.acc_conf_reg_value = -+ conf_backup; -+ goto bmi323_write_raw_error; -+ } -+ -+ data->bmi323.acc_odr_time_ns = -+ bmi323_accel_odr_map[s].time_ns; -+ bmi323_set_power_state(&data->bmi323, -+ false); -+ mutex_unlock(&data->bmi323.mutex); -+ return 0; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ case IIO_ANGL_VEL: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_write_raw_error; -+ } -+ -+ for (int s = 0; s < ARRAY_SIZE(bmi323_gyro_odr_map); -+ ++s) { -+ if ((bmi323_gyro_odr_map[s].val == val) && -+ (bmi323_gyro_odr_map[s].val2 == val2)) { -+ const u16 conf_backup = -+ data->bmi323.gyr_conf_reg_value; -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323 -+ .gyr_conf_reg_value; -+ le_raw_read[0] &= (u8)0b11110000U; -+ le_raw_read[0] |= -+ ((u8)bmi323_gyro_odr_map[s] -+ .hw_val); -+ -+ was_sleep_modified = -+ bmi323_set_power_state( -+ &data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ data->bmi323.gyr_conf_reg_value = -+ conf_backup; -+ goto bmi323_write_raw_error_power; -+ } -+ -+ ret = bmi323_write_u16( -+ &data->bmi323, -+ BMC150_BMI323_GYR_CONF_REG, -+ data->bmi323.gyr_conf_reg_value); -+ if (ret != 0) { -+ data->bmi323.gyr_conf_reg_value = -+ conf_backup; -+ goto bmi323_write_raw_error; -+ } -+ -+ data->bmi323.gyr_odr_time_ns = -+ bmi323_gyro_odr_map[s].time_ns; -+ bmi323_set_power_state(&data->bmi323, -+ false); -+ mutex_unlock(&data->bmi323.mutex); -+ return 0; -+ } -+ } -+ -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ -+ /* Termometer also ends up here: its sampling frequency depends on the chip configuration and cannot be changed */ -+ default: -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ } -+ -+ break; -+ case IIO_CHAN_INFO_SCALE: -+ switch (chan->type) { -+ case IIO_ACCEL: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_write_raw_error; -+ } -+ -+ for (int s = 0; s < ARRAY_SIZE(bmi323_accel_scale_map); -+ ++s) { -+ if ((bmi323_accel_scale_map[s].val == val) && -+ (bmi323_accel_scale_map[s].val2 == val2)) { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323 -+ .acc_conf_reg_value; -+ le_raw_read[0] &= (u8)0b10001111U; -+ le_raw_read[0] |= -+ ((u8)bmi323_accel_scale_map[s] -+ .hw_val); -+ -+ was_sleep_modified = -+ bmi323_set_power_state( -+ &data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ goto bmi323_write_raw_error_power; -+ } -+ -+ ret = bmi323_write_u16( -+ &data->bmi323, -+ BMC150_BMI323_ACC_CONF_REG, -+ data->bmi323.acc_conf_reg_value); -+ if (ret != 0) { -+ goto bmi323_write_raw_error; -+ } -+ -+ bmi323_set_power_state(&data->bmi323, -+ false); -+ mutex_unlock(&data->bmi323.mutex); -+ return 0; -+ } -+ } -+ -+ dev_warn( -+ data->bmi323.dev, -+ "bmi323 error: accel scale val=%d,val2=%d unavailable: ignoring.", -+ val, val2); -+ -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ case IIO_ANGL_VEL: -+ if (iio_buffer_enabled(indio_dev)) { -+ ret = -EBUSY; -+ goto bmi323_write_raw_error; -+ } -+ -+ for (int s = 0; s < ARRAY_SIZE(bmi323_gyro_scale_map); -+ ++s) { -+ if ((bmi323_gyro_scale_map[s].val == val) && -+ (bmi323_gyro_scale_map[s].val2 == val2)) { -+ u8 *le_raw_read = -+ (u8 *)&data->bmi323 -+ .gyr_conf_reg_value; -+ le_raw_read[0] &= (u8)0b10001111U; -+ le_raw_read[0] |= -+ ((u8)bmi323_gyro_scale_map[s] -+ .hw_val); -+ -+ was_sleep_modified = -+ bmi323_set_power_state( -+ &data->bmi323, true); -+ if (was_sleep_modified != 0) { -+ ret = was_sleep_modified; -+ goto bmi323_write_raw_error_power; -+ } -+ -+ ret = bmi323_write_u16( -+ &data->bmi323, -+ BMC150_BMI323_GYR_CONF_REG, -+ data->bmi323.acc_conf_reg_value); -+ if (ret != 0) { -+ goto bmi323_write_raw_error; -+ } -+ -+ bmi323_set_power_state(&data->bmi323, -+ false); -+ mutex_unlock(&data->bmi323.mutex); -+ return 0; -+ } -+ } -+ -+ dev_warn( -+ data->bmi323.dev, -+ "bmi323 error: gyro scale val=%d,val2=%d unavailable: ignoring.", -+ val, val2); -+ -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ -+ default: -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ } -+ -+ default: -+ ret = -EINVAL; -+ goto bmi323_write_raw_error; -+ } -+ -+bmi323_write_raw_error: -+ if (was_sleep_modified == 0) { -+ bmi323_set_power_state(&data->bmi323, false); -+ } -+ -+bmi323_write_raw_error_power: -+ mutex_unlock(&data->bmi323.mutex); -+ return ret; -+} -+ -+static int bmi323_read_avail(struct iio_dev *indio_dev, -+ struct iio_chan_spec const *chan, const int **vals, -+ int *type, int *length, long mask) -+{ -+ switch (mask) { -+ case IIO_CHAN_INFO_SCALE: -+ switch (chan->type) { -+ case IIO_ACCEL: -+ *type = IIO_VAL_INT_PLUS_MICRO; -+ *vals = bmi323_accel_scales; -+ *length = ARRAY_SIZE(bmi323_accel_scales); -+ return IIO_AVAIL_LIST; -+ case IIO_ANGL_VEL: -+ *type = IIO_VAL_INT_PLUS_NANO; -+ *vals = bmi323_gyro_scales; -+ *length = ARRAY_SIZE(bmi323_gyro_scales); -+ return IIO_AVAIL_LIST; -+ default: -+ return -EINVAL; -+ } -+ case IIO_CHAN_INFO_SAMP_FREQ: -+ *type = IIO_VAL_INT_PLUS_MICRO; -+ *vals = bmi323_sample_freqs; -+ *length = ARRAY_SIZE(bmi323_sample_freqs); -+ return IIO_AVAIL_LIST; -+ default: -+ return -EINVAL; -+ } -+} -+ -+static const struct iio_info bmi323_accel_info = { -+ .read_raw = bmi323_read_raw, -+ .write_raw = bmi323_write_raw, -+ .read_avail = bmi323_read_avail, -+ //.hwfifo_flush_to_buffer = bmi323_fifo_flush, -+}; -+ -+static int bmi323_fifo_flush(struct iio_dev *indio_dev) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ int ret; -+ -+ ret = bmi323_write_u16(&data->bmi323, 0x37, cpu_to_le16(0x01)); -+ -+ return ret; -+} -+ -+static const u16 stub_value = 0x8000; -+ -+#define ADVANCE_AT_REQ_OR_AVAIL(req, avail, dst, dst_offset, src, src_offset) \ -+ if (req) { \ -+ if (gyr_avail) { \ -+ memcpy((void *)(dst + dst_offset), \ -+ (const void *)(src + src_offset), 2); \ -+ src_offset += 2; \ -+ } else { \ -+ memcpy((void *)(dst + dst_offset), \ -+ (const void *)((const u8 *)(&stub_value)), 2); \ -+ } \ -+ dst_offset += 2; \ -+ } else { \ -+ if (avail) { \ -+ src_offset += 2; \ -+ } \ -+ } -+ -+static irqreturn_t iio_bmi323_trigger_h(int irq, void *p) -+{ -+ printk(KERN_WARNING "bmi323 executed iio_bmi323_trigger_h"); -+ -+ struct iio_poll_func *pf = p; -+ struct iio_dev *indio_dev = pf->indio_dev; -+ struct bmc150_accel_data *indio_data = iio_priv(indio_dev); -+ -+ mutex_lock(&indio_data->bmi323.mutex); -+ -+ const bool temp_avail = ((indio_data->bmi323.fifo_conf_reg_value & -+ (cpu_to_le16(0b0000100000000000))) != 0); -+ const bool gyr_avail = ((indio_data->bmi323.fifo_conf_reg_value & -+ (cpu_to_le16(0b0000010000000000))) != 0); -+ const bool acc_avail = ((indio_data->bmi323.fifo_conf_reg_value & -+ (cpu_to_le16(0b0000001000000000))) != 0); -+ const bool time_avail = ((indio_data->bmi323.fifo_conf_reg_value & -+ (cpu_to_le16(0b0000000100000000))) != 0); -+ -+ /* Calculate the number of bytes for a frame */ -+ const u16 frames_aggregate_size_in_words = -+ /* 2 * */ ((temp_avail ? 1 : 0) + (gyr_avail ? 3 : 0) + -+ (acc_avail ? 3 : 0) + (time_avail ? 1 : 0)); -+ -+ u16 available_words = 0; -+ const int available_words_read_res = bmi323_read_u16( -+ &indio_data->bmi323, BMC150_BMI323_FIFO_FILL_LEVEL_REG, -+ &available_words); -+ if (available_words_read_res != 0) { -+ goto bmi323_irq_done; -+ } -+ -+ const u16 available_frame_aggregates = (le16_to_cpu(available_words)) / -+ (frames_aggregate_size_in_words); -+ -+ const s64 current_timestamp_ns = iio_get_time_ns(indio_dev); -+ const s64 fifo_frame_time_ns = -+ indio_data->bmi323.fifo_frame_time_diff_ns; -+ const s64 first_sample_timestamp_ns = -+ current_timestamp_ns - -+ (fifo_frame_time_ns * (s64)(available_frame_aggregates)); -+ -+ /* This can hold one full block */ -+ u8 temp_data[16]; -+ -+ /* This is fifo data as read from the sensor */ -+ u8 fifo_data[32]; -+ -+ /* -+ | CHANNEL | scan_index -+ |============================ -+ | | | -+ | ACCEL_X | 0 | -+ | ACCEL_Y | 1 | -+ | ACCEL_Y | 2 | -+ | GYRO_X | 3 | -+ | GYRO_Y | 4 | -+ | GYRO_Z | 5 | -+ | TEMP | 6 | -+ | TIMESTAMP | ? | -+ */ -+ bool accel_x_requested = false; -+ bool accel_y_requested = false; -+ bool accel_z_requested = false; -+ bool gyro_x_requested = false; -+ bool gyro_y_requested = false; -+ bool gyro_z_requested = false; -+ bool temp_requested = false; -+ -+ int j = 0; -+ for_each_set_bit(j, indio_dev->active_scan_mask, -+ indio_dev->masklength) { -+ switch (j) { -+ case 0: -+ accel_x_requested = true; -+ break; -+ case 1: -+ accel_y_requested = true; -+ break; -+ case 2: -+ accel_z_requested = true; -+ break; -+ case 3: -+ gyro_x_requested = true; -+ break; -+ case 4: -+ gyro_y_requested = true; -+ break; -+ case 5: -+ gyro_z_requested = true; -+ break; -+ case 6: -+ temp_requested = true; -+ break; -+ default: -+ break; -+ } -+ } -+ -+ u16 current_fifo_buffer_offset_bytes = 0; -+ for (u16 f = 0; f < available_frame_aggregates; ++f) { -+ u16 current_sample_buffer_offset = 0; -+ -+ /* Read data from the raw device */ -+ if (indio_data->bmi323.i2c_client != NULL) { -+ const int bytes_to_read = -+ 2 + (2 * frames_aggregate_size_in_words); -+ int read_block_ret = i2c_smbus_read_i2c_block_data( -+ indio_data->bmi323.i2c_client, -+ BMC150_BMI323_FIFO_DATA_REG, bytes_to_read, -+ &fifo_data[0]); -+ if (read_block_ret < bytes_to_read) { -+ dev_warn( -+ &indio_data->bmi323.i2c_client->dev, -+ "bmi323: i2c_smbus_read_i2c_block_data wrong return: expected %d bytes, %d arrived. Doing what is possible with recovered data.\n", -+ bytes_to_read, read_block_ret); -+ -+ /* at this point FIFO buffer must be flushed to avoid interpreting data incorrectly the next trigger */ -+ const int flush_res = -+ bmi323_fifo_flush(indio_dev); -+ if (flush_res != 0) { -+ dev_err(&indio_data->bmi323.i2c_client -+ ->dev, -+ "bmi323: Could not flush FIFO (%d). Following buffer data might be corrupted.\n", -+ flush_res); -+ } -+ -+ goto bmi323_irq_done; -+ } -+ -+ /* Discard 2-bytes dummy data from I2C */ -+ current_fifo_buffer_offset_bytes = 2; -+ } else if (indio_data->bmi323.spi_client != NULL) { -+ printk(KERN_CRIT -+ "bmi323: SPI interface is not yet implemented.\n"); -+ -+ /* -+ * To whoever may need this: implementing this should be straightforward: -+ * it's specular to the i2c part. -+ */ -+ -+ /* Discard 1-byte dummy data from SPI */ -+ current_fifo_buffer_offset_bytes = 1; -+ -+ goto bmi323_irq_done; -+ } -+ -+ ADVANCE_AT_REQ_OR_AVAIL(accel_x_requested, acc_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ ADVANCE_AT_REQ_OR_AVAIL(accel_y_requested, acc_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ ADVANCE_AT_REQ_OR_AVAIL(accel_z_requested, acc_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ ADVANCE_AT_REQ_OR_AVAIL(gyro_x_requested, gyr_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ ADVANCE_AT_REQ_OR_AVAIL(gyro_y_requested, gyr_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ ADVANCE_AT_REQ_OR_AVAIL(gyro_z_requested, gyr_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ ADVANCE_AT_REQ_OR_AVAIL(temp_requested, temp_avail, -+ (u8 *)&temp_data[0], -+ current_sample_buffer_offset, -+ (u8 *)&fifo_data[0], -+ current_fifo_buffer_offset_bytes); -+ -+#ifdef BMC150_BMI232_DEBUG_EN -+ /* The following is code only used for debugging */ -+ u16 timestamp = 0; -+ if (time_avail) { -+ memcpy((u8 *)×tamp, -+ (const u8 -+ *)(&fifo_data -+ [current_fifo_buffer_offset_bytes]), -+ 2); -+ current_fifo_buffer_offset_bytes += 2; -+ } -+ -+ u16 *debg = (u16 *)&temp_data[0]; -+ if (!time_avail) { -+ printk(KERN_WARNING -+ "bmi323 pushing to buffer %d/%d -- accel: %d %d %d gyro: %d %d %d", -+ (int)(f + 1), (int)available_frame_aggregates, -+ (int)(*((s16 *)&debg[0])), -+ (int)(*((s16 *)&debg[1])), -+ (int)(*((s16 *)&debg[2])), -+ (int)(*((s16 *)&debg[3])), -+ (int)(*((s16 *)&debg[4])), -+ (int)(*((s16 *)&debg[5]))); -+ } else { -+ printk(KERN_WARNING -+ "bmi323 pushing to buffer %d/%d -- time: %d accel: %d %d %d gyro: %d %d %d", -+ (int)(f + 1), (int)available_frame_aggregates, -+ (int)timestamp, (int)(*((s16 *)&debg[0])), -+ (int)(*((s16 *)&debg[1])), -+ (int)(*((s16 *)&debg[2])), -+ (int)(*((s16 *)&debg[3])), -+ (int)(*((s16 *)&debg[4])), -+ (int)(*((s16 *)&debg[5]))); -+ } -+#endif -+ -+ iio_push_to_buffers_with_timestamp( -+ indio_dev, &temp_data[0], -+ first_sample_timestamp_ns + -+ (fifo_frame_time_ns * (s64)j)); -+ } -+ -+bmi323_irq_done: -+ mutex_unlock(&indio_data->bmi323.mutex); -+ -+ /* -+ * Tell the core we are done with this trigger and ready for the -+ * next one. -+ */ -+ iio_trigger_notify_done(indio_dev->trig); -+ -+ return IRQ_HANDLED; -+} -+ -+int bmi323_set_trigger_state(struct iio_trigger *trig, bool state) -+{ -+ return 0; -+} -+ -+/* -+// The following is meant to be used in a IRQ-enabled hardware -+static const struct iio_trigger_ops time_trigger_ops = { -+ .set_trigger_state = &bmi323_set_trigger_state, -+ //.reenable = NULL, -+ .validate_device = &iio_trigger_validate_own_device, -+}; -+*/ -+ -+/* -+ * A very basic scan mask: everything can work in conjunction with everything else so no need to worry about -+ * managing conbinations of mutually exclusive data sources... -+ */ -+static const unsigned long bmi323_accel_scan_masks[] = { -+ BIT(BMI323_ACCEL_AXIS_X) | BIT(BMI323_ACCEL_AXIS_Y) | -+ BIT(BMI323_ACCEL_AXIS_Z) | BIT(BMI323_GYRO_AXIS_X) | -+ BIT(BMI323_GYRO_AXIS_Y) | -+ BIT(BMI323_GYRO_AXIS_Z) /*| BIT(BMI323_TEMP)*/, -+ 0 -+}; -+ -+int bmi323_iio_init(struct iio_dev *indio_dev) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ struct irq_data *irq_desc = NULL; -+ -+ if (data->bmi323.i2c_client != NULL) { -+ data->bmi323.dev = &data->bmi323.i2c_client->dev; -+ } else if (data->bmi323.spi_client != NULL) { -+ data->bmi323.dev = &data->bmi323.spi_client->dev; -+ } else { -+ return -ENODEV; -+ } -+ -+ int ret = 0; -+ -+ /* change to 8 for a default 200Hz sampling rate */ -+ const int gyr_odr_conf_idx = 7; -+ const int acc_odr_conf_idx = 7; -+ -+ mutex_init(&data->bmi323.mutex); -+ -+ data->bmi323.acc_odr_time_ns = -+ bmi323_accel_odr_map[acc_odr_conf_idx].time_ns; -+ data->bmi323.gyr_odr_time_ns = -+ bmi323_gyro_odr_map[gyr_odr_conf_idx].time_ns; -+ -+ // FIFO enabled for gyro, accel and temp. Overwrite older samples. -+ data->bmi323.fifo_conf_reg_value = cpu_to_le16((u16)0x0F00U); -+ //data->bmi323.fifo_conf_reg_value = cpu_to_le16((u16)0x0E00U); -+ //data->bmi323.fifo_conf_reg_value = cpu_to_le16((u16)0x0600U); // working -+ -+ // now set the (default) normal mode... -+ // normal mode: 0x4000 -+ // no averaging: 0x0000 -+ data->bmi323.acc_conf_reg_value = cpu_to_le16( -+ 0x4000 | ((u16)BMC150_BMI323_ACCEL_RANGE_2_VAL << (u16)4U) | -+ ((u16)bmi323_accel_odr_map[acc_odr_conf_idx].hw_val)); -+ -+ // now set the (default) normal mode... -+ // normal mode: 0x4000 -+ // no averaging: 0x0000 -+ // filtering to ODR/2: 0x0000 -+ data->bmi323.gyr_conf_reg_value = cpu_to_le16( -+ 0x4000 | ((u16)BMC150_BMI323_GYRO_RANGE_125_VAL << (u16)4U) | -+ ((u16)bmi323_gyro_odr_map[gyr_odr_conf_idx].hw_val)); -+ -+ // the datasheet states that FIFO buffer MUST be enabled before enabling any sensor -+ ret = bmi323_write_u16(&data->bmi323, BMC150_BMI323_FIFO_CONF_REG, -+ data->bmi323.fifo_conf_reg_value); -+ if (ret != 0) { -+ return -1; -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, BMC150_BMI323_ACC_CONF_REG, -+ data->bmi323.acc_conf_reg_value); -+ if (ret != 0) { -+ return -1; -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, BMC150_BMI323_GYR_CONF_REG, -+ data->bmi323.gyr_conf_reg_value); -+ if (ret != 0) { -+ return -2; -+ } -+ -+ indio_dev->channels = bmi323_channels; -+ indio_dev->num_channels = ARRAY_SIZE(bmi323_channels); -+ indio_dev->name = "bmi323"; -+ indio_dev->available_scan_masks = bmi323_accel_scan_masks; -+ indio_dev->modes = INDIO_DIRECT_MODE; -+ indio_dev->info = &bmi323_accel_info; -+ indio_dev->label = "bmi323-accel_base"; -+ -+ if (data->bmi323.irq > 0) { -+ dev_info(data->bmi323.dev, "IRQ pin reported as connected: %d", -+ data->bmi323.irq); -+ -+ irq_desc = irq_get_irq_data(data->bmi323.irq); -+ if (!irq_desc) { -+ dev_err(data->bmi323.dev, -+ "Could not find IRQ %d. ignoring it.\n", -+ data->bmi323.irq); -+ goto bmi323_iio_init_missing_irq_pin; -+ } -+ -+ //data->bmi323.trig[0] = devm_iio_trigger_alloc(data->bmi323.dev, "trig-fifo_full-%s-%d", indio_dev->name, iio_device_id(indio_dev)); -+ //if (data->bmi323.trig[0] == NULL) { -+ // ret = -ENOMEM; -+ // goto bmi323_iio_init_err_trigger_unregister; -+ //} -+ // -+ //data->bmi323.trig[0]->ops = &time_trigger_ops; -+ //iio_trigger_set_drvdata(data->bmi323.trig[0], indio_dev); -+ //ret = devm_iio_trigger_register(data->bmi323.dev, data->bmi323.trig[0]); -+ //if (ret) { -+ // dev_err(data->bmi323.dev, "iio trigger register failed\n"); -+ // goto bmi323_iio_init_err_trigger_unregister; -+ //} -+ -+ /* -+ * register triggers BEFORE buffer setup so that they are cleared -+ * on emergence exit by bmi323_iio_init_err_trigger_unregister. -+ * -+ * This is just a placeholder until I can get my hands on a bmi323 -+ * device that has the IRQ pin actually connected to the CPU. -+ */ -+ -+ /* here resume operation with the module part common to irq and non-irq enabled code. */ -+ goto bmi323_iio_init_common_irq_and_not_irq; -+ } -+ -+bmi323_iio_init_missing_irq_pin: -+ dev_info( -+ data->bmi323.dev, -+ "IRQ pin NOT connected (irq=%d). Will continue normally without triggers.", -+ data->bmi323.irq); -+ -+bmi323_iio_init_common_irq_and_not_irq: -+ -+ /* Once orientation matrix is implemented switch this to iio_triggered_buffer_setup_ext. */ -+ ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, -+ iio_bmi323_trigger_h, -+ &bmi323_buffer_ops); -+ if (ret < 0) { -+ dev_err(data->bmi323.dev, -+ "Failed: iio triggered buffer setup: %d\n", ret); -+ goto bmi323_iio_init_err_trigger_unregister; -+ } -+ -+ ret = pm_runtime_set_active(data->bmi323.dev); -+ if (ret) { -+ dev_err(data->bmi323.dev, -+ "bmi323 unable to initialize runtime PD: pm_runtime_set_active returned %d\n", -+ ret); -+ goto bmi323_iio_init_err_buffer_cleanup; -+ } -+ -+ pm_runtime_enable(data->bmi323.dev); -+ pm_runtime_set_autosuspend_delay(data->bmi323.dev, -+ BMC150_BMI323_AUTO_SUSPEND_DELAY_MS); -+ pm_runtime_use_autosuspend(data->bmi323.dev); -+ -+ ret = iio_device_register(indio_dev); -+ if (ret < 0) { -+ dev_err(data->bmi323.dev, -+ "bmi323 unable to register iio device: %d\n", ret); -+ goto bmi323_iio_init_err_pm_cleanup; -+ } -+ -+ return 0; -+ -+bmi323_iio_init_err_pm_cleanup: -+ pm_runtime_dont_use_autosuspend(data->bmi323.dev); -+ pm_runtime_disable(data->bmi323.dev); -+bmi323_iio_init_err_buffer_cleanup: -+ iio_triggered_buffer_cleanup(indio_dev); -+bmi323_iio_init_err_trigger_unregister: -+ /* -+ * unregister triggers if they have been setup already. -+ * iio_trigger_unregister shall be used in that regard. -+ * -+ * This is just a placeholder until I can get my hands on a bmi323 -+ * device that has the IRQ pin actually connected to the CPU. -+ */ -+ //if (data->bmi323.trig[0] != NULL) { -+ // iio_trigger_unregister(data->bmi323.trig[0]); -+ //} -+ -+ return ret; -+} -+EXPORT_SYMBOL_NS_GPL(bmi323_iio_init, IIO_BMC150); -+ -+void bmi323_iio_deinit(struct iio_dev *indio_dev) -+{ -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ struct device *dev = bmi323_get_managed_device(&data->bmi323); -+ -+ iio_device_unregister(indio_dev); -+ -+ pm_runtime_disable(dev); -+ pm_runtime_set_suspended(dev); -+ pm_runtime_put_noidle(dev); -+ -+ iio_triggered_buffer_cleanup(indio_dev); -+ -+ //iio_device_free(indio_dev); // this isn't done in the bmg160 driver nor in other drivers so I guess I shouldn't do it too -+ -+ mutex_unlock(&data->bmi323.mutex); -+ bmi323_chip_rst(&data->bmi323); -+ mutex_unlock(&data->bmi323.mutex); -+} -+EXPORT_SYMBOL_NS_GPL(bmi323_iio_deinit, IIO_BMC150); -+ -+#ifdef CONFIG_PM_SLEEP -+static int bmc150_accel_suspend(struct device *dev) - { - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct bmc150_accel_data *data = iio_priv(indio_dev); - -+ if (data->dev_type == BMI323) { -+ int ret; -+ -+ //dev_warn(dev, "bmi323 suspending driver..."); -+ -+ // here push the register GYRO & ACCEL configuration and issue a reset so that chip goes to sleep mode (the default one after a reset) -+ mutex_unlock(&data->bmi323.mutex); -+ -+ ret = bmi323_chip_rst(&data->bmi323); -+ mutex_unlock(&data->bmi323.mutex); -+ if (ret != 0) { -+ dev_err(dev, -+ "bmi323 error in suspend on bmi323_chip_rst: %d\n", -+ ret); -+ data->bmi323.flags |= BMI323_FLAGS_RESET_FAILED; -+ return -EAGAIN; -+ } -+ -+ return 0; -+ } -+ - mutex_lock(&data->mutex); - bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); - mutex_unlock(&data->mutex); -@@ -1844,6 +4005,63 @@ static int bmc150_accel_resume(struct device *dev) - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct bmc150_accel_data *data = iio_priv(indio_dev); - -+ if (data->dev_type == BMI323) { -+ int ret; -+ -+ //dev_warn(dev, "bmi323 resuming driver..."); -+ -+ // here pop the register GYRO & ACCEL configuration and issue a reset so that chip goes to sleep mode (the default one after a reset) -+ mutex_lock(&data->bmi323.mutex); -+ -+ // this was done already in runtime_sleep function. -+ if ((data->bmi323.flags & BMI323_FLAGS_RESET_FAILED) != 0x00U) { -+ ret = bmi323_chip_rst(&data->bmi323); -+ if (ret == 0) { -+ data->bmi323.flags &= -+ ~BMI323_FLAGS_RESET_FAILED; -+ } else { -+ goto bmi323_bmc150_accel_resume_terminate; -+ } -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, -+ BMC150_BMI323_FIFO_CONF_REG, -+ data->bmi323.fifo_conf_reg_value); -+ if (ret != 0) { -+ goto bmi323_bmc150_accel_resume_terminate; -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, -+ BMC150_BMI323_GYR_CONF_REG, -+ data->bmi323.gyr_conf_reg_value); -+ if (ret != 0) { -+ goto bmi323_bmc150_accel_resume_terminate; -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, -+ BMC150_BMI323_ACC_CONF_REG, -+ data->bmi323.acc_conf_reg_value); -+ if (ret != 0) { -+ goto bmi323_bmc150_accel_resume_terminate; -+ } -+ -+bmi323_bmc150_accel_resume_terminate: -+ mutex_unlock(&data->bmi323.mutex); -+ if (ret != 0) { -+ return -EAGAIN; -+ } -+ -+ /* -+ * datasheet says "Start-up time": suspend to high performance mode is tipically 30ms, -+ * however when setting this to 32 or even higher the first reading from the gyro (unlike accel part) -+ * is actually the (wrong) default value 0x8000 so it is better to sleep a bit longer -+ * to prevent issues and give time to the sensor to pick up first readings... -+ */ -+ msleep_interruptible(64); -+ -+ return 0; -+ } -+ - mutex_lock(&data->mutex); - bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0); - bmc150_accel_fifo_set_mode(data); -@@ -1863,6 +4081,25 @@ static int bmc150_accel_runtime_suspend(struct device *dev) - struct bmc150_accel_data *data = iio_priv(indio_dev); - int ret; - -+ if (data->dev_type == BMI323) { -+ //dev_warn(dev, "bmi323 suspending runtime..."); -+ -+ /* -+ * Every operation requiring this function have the mutex locked already: -+ * with mutex_lock(&data->bmi323.mutex); -+ */ -+ ret = bmi323_chip_rst(&data->bmi323); -+ if (ret != 0) { -+ dev_err(dev, -+ "bmi323 error in runtime_suspend on bmi323_chip_rst: %d\n", -+ ret); -+ data->bmi323.flags |= BMI323_FLAGS_RESET_FAILED; -+ return -EAGAIN; -+ } -+ -+ return 0; -+ } -+ - ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_SUSPEND, 0); - if (ret < 0) - return -EAGAIN; -@@ -1877,6 +4114,70 @@ static int bmc150_accel_runtime_resume(struct device *dev) - int ret; - int sleep_val; - -+ if (data->dev_type == BMI323) { -+ //dev_warn(dev, "bmi323 resuming runtime..."); -+ -+ /* -+ * Every operation requiring this function have the mutex locked already: -+ * with mutex_lock(&data->bmi323.mutex); -+ */ -+ -+ // recover from a bad state if it was left that way on reuntime_suspend -+ if ((data->bmi323.flags & BMI323_FLAGS_RESET_FAILED) != 0x00U) { -+ ret = bmi323_chip_rst(&data->bmi323); -+ if (ret == 0) { -+ data->bmi323.flags &= -+ ~BMI323_FLAGS_RESET_FAILED; -+ } else { -+ goto bmi323_bmc150_accel_runtime_resume_terminate; -+ } -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, -+ BMC150_BMI323_FIFO_CONF_REG, -+ data->bmi323.fifo_conf_reg_value); -+ if (ret != 0) { -+ dev_err(dev, -+ "bmi323 writing to GYR_CONF register failed"); -+ goto bmi323_bmc150_accel_runtime_resume_terminate; -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, -+ BMC150_BMI323_GYR_CONF_REG, -+ data->bmi323.gyr_conf_reg_value); -+ if (ret != 0) { -+ dev_err(dev, -+ "bmi323 writing to GYR_CONF register failed"); -+ goto bmi323_bmc150_accel_runtime_resume_terminate; -+ } -+ -+ ret = bmi323_write_u16(&data->bmi323, -+ BMC150_BMI323_ACC_CONF_REG, -+ data->bmi323.acc_conf_reg_value); -+ if (ret != 0) { -+ dev_err(dev, -+ "bmi323 writing to ACC_CONF register failed"); -+ goto bmi323_bmc150_accel_runtime_resume_terminate; -+ } -+ -+bmi323_bmc150_accel_runtime_resume_terminate: -+ if (ret != 0) { -+ dev_err(dev, -+ "bmi323 bmc150_accel_runtime_resume -EAGAIN"); -+ return -EAGAIN; -+ } -+ -+ /* -+ * datasheet says "Start-up time": suspend to high performance mode is tipically 30ms, -+ * however when setting this to 32 or even higher the first reading from the gyro (unlike accel part) -+ * is actually the (wrong) default value 0x8000 so it is better to sleep a bit longer -+ * to prevent issues and give time to the sensor to pick up first readings... -+ */ -+ msleep_interruptible(64); -+ -+ return 0; -+ } -+ - ret = bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_NORMAL, 0); - if (ret < 0) - return ret; -diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c -index ee1ba134ad42..0d6ee304b3e7 100644 ---- a/drivers/iio/accel/bmc150-accel-i2c.c -+++ b/drivers/iio/accel/bmc150-accel-i2c.c -@@ -173,15 +173,102 @@ static void bmc150_acpi_dual_accel_remove(struct i2c_client *client) {} - - static int bmc150_accel_probe(struct i2c_client *client) - { -+ int ret; -+ u8 chip_id_first[4] = { 0x00, 0x00, 0x00, 0x00 }; -+ enum bmc150_device_type dev_type = BMC150; - const struct i2c_device_id *id = i2c_client_get_device_id(client); - struct regmap *regmap; - const char *name = NULL; - enum bmc150_type type = BOSCH_UNKNOWN; -+ -+ /* reads 4 bytes (2 dummy + 2 good) from the i2c CHIP_ID device register */ -+ ret = i2c_smbus_read_i2c_block_data(client, 0x00, 4, &chip_id_first[0]); -+ if (ret != 4) { -+ dev_info( -+ &client->dev, -+ "error checking if the bmc150 is in fact a bmi323: i2c_smbus_read_i2c_block_data = %d: reg = 0x%02x.\n\tIt probably is a bmc150 as correctly reported by the ACPI entry.", -+ (int)ret, 0x00); -+ goto bmi150_old_probe; -+ } -+ -+ // at this point we have enough data to know what chip we are handling -+ dev_type = (chip_id_first[2] == 0x43) ? BMI323 : dev_type; -+ -+ if (dev_type == BMI323) { -+ dev_warn( -+ &client->dev, -+ "bmc323: what the ACPI table reported as a bmc150 is in fact a bmc323\n"); -+ -+ struct iio_dev *indio_dev = devm_iio_device_alloc( -+ &client->dev, sizeof(struct bmc150_accel_data)); -+ if (!indio_dev) { -+ dev_err(&client->dev, -+ "bmc323 init process failed: out of memory\n"); -+ -+ return -ENOMEM; -+ } -+ -+ dev_set_drvdata(&client->dev, indio_dev); -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ data->dev_type = dev_type; -+ -+ struct bmi323_private_data *bmi323_data = &data->bmi323; -+ bmi323_data->i2c_client = client; -+ bmi323_data->spi_client = NULL; -+ bmi323_data->irq = client->irq; -+ -+ /* -+ * VDD is the analog and digital domain voltage supply -+ * VDDIO is the digital I/O voltage supply -+ */ -+ bmi323_data->regulators[0].supply = "vdd"; -+ bmi323_data->regulators[1].supply = "vddio"; -+ ret = devm_regulator_bulk_get( -+ &client->dev, ARRAY_SIZE(bmi323_data->regulators), -+ bmi323_data->regulators); -+ if (ret) { -+ return dev_err_probe(&client->dev, ret, -+ "failed to get regulators\n"); -+ } -+ -+ ret = regulator_bulk_enable(ARRAY_SIZE(bmi323_data->regulators), -+ bmi323_data->regulators); -+ if (ret) { -+ iio_device_free(indio_dev); -+ -+ dev_err(&client->dev, -+ "failed to enable regulators: %d\n", ret); -+ return ret; -+ } -+ -+ ret = bmi323_chip_rst(bmi323_data); -+ if (ret != 0) { -+ dev_err(&client->dev, -+ "bmc323: error issuing the chip reset: %d\n", -+ ret); -+ return ret; -+ } -+ -+ dev_info( -+ &client->dev, -+ "bmc323: chip reset success: starting the iio subsystem binding\n"); -+ -+ ret = bmi323_iio_init(indio_dev); -+ if (ret != 0) { -+ return ret; -+ } -+ -+ return 0; -+ } -+ -+bmi150_old_probe: -+ dev_info(&client->dev, -+ "executing the normal procedure for a bmc150..."); -+ - bool block_supported = - i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || - i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_READ_I2C_BLOCK); -- int ret; - - regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf); - if (IS_ERR(regmap)) { -@@ -198,7 +285,7 @@ static int bmc150_accel_probe(struct i2c_client *client) - type, name, block_supported); - if (ret) - return ret; -- -+ - /* - * The !id check avoids recursion when probe() gets called - * for the second client. -@@ -211,6 +298,15 @@ static int bmc150_accel_probe(struct i2c_client *client) - - static void bmc150_accel_remove(struct i2c_client *client) - { -+ struct iio_dev *indio_dev = dev_get_drvdata(&client->dev); -+ struct bmc150_accel_data *data = iio_priv(indio_dev); -+ -+ if (data->dev_type == BMI323) { -+ bmi323_iio_deinit(indio_dev); -+ -+ return; -+ } -+ - bmc150_acpi_dual_accel_remove(client); - - bmc150_accel_core_remove(&client->dev); -diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h -index 7775c5edaeef..65ec208960df 100644 ---- a/drivers/iio/accel/bmc150-accel.h -+++ b/drivers/iio/accel/bmc150-accel.h -@@ -8,6 +8,14 @@ - #include - #include - -+/* -+ * the bmi323 needs raw access to spi and i2c: I cannot use regmap -+ * as this device expects i2c writes to be 2 bytes, -+ * spi reads to be 3 bytes and i2c reads to be 4 bytes. -+ */ -+#include -+#include -+ - struct regmap; - struct i2c_client; - struct bmc150_accel_chip_info; -@@ -34,6 +42,11 @@ struct bmc150_accel_interrupt { - atomic_t users; - }; - -+enum bmc150_device_type { -+ BMC150, -+ BMI323, -+}; -+ - struct bmc150_accel_trigger { - struct bmc150_accel_data *data; - struct iio_trigger *indio_trig; -@@ -55,6 +68,25 @@ enum bmc150_accel_trigger_id { - BMC150_ACCEL_TRIGGERS, - }; - -+#define BMI323_FLAGS_RESET_FAILED 0x00000001U -+ -+struct bmi323_private_data { -+ struct regulator_bulk_data regulators[2]; -+ struct i2c_client *i2c_client; -+ struct spi_device *spi_client; -+ struct device *dev; /* pointer at i2c_client->dev or spi_client->dev */ -+ struct mutex mutex; -+ int irq; -+ u32 flags; -+ u16 acc_conf_reg_value; -+ u16 gyr_conf_reg_value; -+ u16 fifo_conf_reg_value; -+ struct iio_trigger *trig[1]; -+ s64 fifo_frame_time_diff_ns; -+ s64 acc_odr_time_ns; -+ s64 gyr_odr_time_ns; -+}; -+ - struct bmc150_accel_data { - struct regmap *regmap; - struct regulator_bulk_data regulators[2]; -@@ -83,7 +115,67 @@ struct bmc150_accel_data { - void (*resume_callback)(struct device *dev); - struct delayed_work resume_work; - struct iio_mount_matrix orientation; --}; -+ enum bmc150_device_type dev_type; -+ struct bmi323_private_data bmi323; -+ }; -+ -+/** -+ * This function performs a write of a u16 little-endian (regardless of CPU architecture) integer -+ * to a device register. Returns 0 on success or an error code otherwise. -+ * -+ * PRE: in_value holds the data to be sent to the sensor, in little endian format even on big endian -+ * architectures. -+ * -+ * NOTE: bmi323->dev can be NULL (not yet initialized) when this function is called -+ * therefore it is not needed and is not used inside the function -+ * -+ * WARNING: this function does not lock any mutex and synchronization MUST be performed by the caller -+ */ -+int bmi323_write_u16(struct bmi323_private_data *bmi323, u8 in_reg, u16 in_value); -+ -+/** -+ * This function performs a read of "good" values from the bmi323 discarding what -+ * in the datasheet is described as "dummy data": additional useles bytes. -+ * -+ * PRE: bmi323 has been partially initialized: i2c_device and spi_devices MUST be set to either -+ * the correct value or NULL -+ * -+ * NOTE: bmi323->dev can be NULL (not yet initialized) when this function is called -+ * therefore it is not needed and is not used inside the function -+ * -+ * POST: on success out_value is written with data from the sensor, as it came out, so the -+ * content is little-endian even on big endian architectures -+ * -+ * WARNING: this function does not lock any mutex and synchronization MUST be performed by the caller -+ */ -+int bmi323_read_u16(struct bmi323_private_data *bmi323, u8 in_reg, u16* out_value); -+ -+int bmi323_chip_check(struct bmi323_private_data *bmi323); -+ -+/** -+ * Reset the chip in a known state that is ready to accept commands, but is not configured therefore after calling this function -+ * it is required to load a new configuration to start data acquisition. -+ * -+ * PRE: bmi323 has been fully identified and partially initialized -+ * -+ * NOTE: after issuing a reset the the chip will be in what it is called "suspended mode" and the feature angine is -+ * ready to be set. This mode has everything disabled and consumes aroud 15uA. -+ * -+ * When removing the driver or suspend has been requested it's best to reset the chip so that power consumption -+ * will be the lowest possible. -+ */ -+int bmi323_chip_rst(struct bmi323_private_data *bmi323); -+ -+/** -+ * This function MUST be called in probe and is responsible for registering the userspace sysfs. -+ * -+ * The indio_dev MUST have been allocated but not registered. This function will perform userspace registration. -+ * -+ * @param indio_dev the industrual io device already allocated but not yet registered -+ */ -+int bmi323_iio_init(struct iio_dev *indio_dev); -+ -+void bmi323_iio_deinit(struct iio_dev *indio_dev); - - int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, - enum bmc150_type type, const char *name, --- -2.42.0 - diff --git a/patches/asuslinux/v2-0001-platform-x86-asus-wmi-disable-USB0-hub-on-ROG-All.patch b/patches/asuslinux/v2-0001-platform-x86-asus-wmi-disable-USB0-hub-on-ROG-All.patch deleted file mode 100644 index 3c89787..0000000 --- a/patches/asuslinux/v2-0001-platform-x86-asus-wmi-disable-USB0-hub-on-ROG-All.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 0a399a37fbe6f6b2b9062e1c076df28608b628c9 Mon Sep 17 00:00:00 2001 -From: "Luke D. Jones" -Date: Fri, 24 Nov 2023 21:13:11 +1300 -Subject: [PATCH v2] platform/x86: asus-wmi: disable USB0 hub on ROG Ally - before suspend - -ASUS have worked around an issue in XInput where it doesn't support USB -selective suspend, whcih causes suspend issues in Windows. They worked -around this by adjusting the MCU firmware to disable the USB0 hub when -the screen is switched off during the Microsoft DSM suspend path in ACPI. - -The issue we have with this however is one of timing - the call the tells -the MCU to this isn't able to complete before suspend is done so we call -this in a prepare() and add a small msleep() to ensure it is done. This -must be done before the screen is switched off to prevent a variety of -possible races. - -Without this the MCU is unable to initialise itself correctly on resume. - -Signed-off-by: Luke D. Jones ---- - drivers/platform/x86/asus-wmi.c | 40 +++++++++++++++++++++++++++++++++ - 1 file changed, 40 insertions(+) - -diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index 6a79f16233ab..563c9ab31bc7 100644 ---- a/drivers/platform/x86/asus-wmi.c -+++ b/drivers/platform/x86/asus-wmi.c -@@ -16,6 +16,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -132,6 +133,9 @@ module_param(fnlock_default, bool, 0444); - #define ASUS_SCREENPAD_BRIGHT_MAX 255 - #define ASUS_SCREENPAD_BRIGHT_DEFAULT 60 - -+/* Controls the power state of the USB0 hub on ROG Ally which input is on */ -+#define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE" -+ - static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; - - static int throttle_thermal_policy_write(struct asus_wmi *); -@@ -300,6 +304,9 @@ struct asus_wmi { - - bool fnlock_locked; - -+ /* The ROG Ally device requires the USB hub to be disabled before suspend */ -+ bool pre_suspend_ec0_csee_disable; -+ - struct asus_wmi_debug debug; - - struct asus_wmi_driver *driver; -@@ -4488,6 +4495,8 @@ static int asus_wmi_add(struct platform_device *pdev) - asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); - asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); - asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE); -+ asus->pre_suspend_ec0_csee_disable = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) -+ && dmi_match(DMI_BOARD_NAME, "RC71L"); - - err = fan_boost_mode_check_present(asus); - if (err) -@@ -4654,6 +4663,35 @@ static int asus_hotk_resume(struct device *device) - asus_wmi_fnlock_update(asus); - - asus_wmi_tablet_mode_get_state(asus); -+ -+ return 0; -+} -+ -+static int asus_hotk_resume_early(struct device *device) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(device); -+ -+ if (asus->pre_suspend_ec0_csee_disable) { -+ /* sleep required to ensure USB0 is enabled before drivers notice */ -+ if (ACPI_FAILURE(acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, 0xB8))) -+ pr_warn("ASUS ROG Ally failed to set USB hub power on\n"); -+ } -+ -+ return 0; -+} -+ -+static int asus_hotk_prepare(struct device *device) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(device); -+ -+ if (asus->pre_suspend_ec0_csee_disable) { -+ /* sleep required to ensure USB0 is disabled before sleep continues */ -+ if (ACPI_FAILURE(acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, 0xB7))) -+ pr_warn("ASUS ROG Ally failed to set USB hub power off\n"); -+ else -+ msleep(100); -+ } -+ - return 0; - } - -@@ -4701,6 +4739,8 @@ static const struct dev_pm_ops asus_pm_ops = { - .thaw = asus_hotk_thaw, - .restore = asus_hotk_restore, - .resume = asus_hotk_resume, -+ .resume_early = asus_hotk_resume_early, -+ .prepare = asus_hotk_prepare, - }; - - /* Registration ***************************************************************/ --- -2.43.0 - diff --git a/patches/series b/patches/series index 50989b1..be1ab52 100644 --- a/patches/series +++ b/patches/series @@ -11,3 +11,8 @@ nobara/0001-acpi-proc-idle-skip-dummy-wait.patch nobara/0001-add-acpi_call.patch nobara/OpenRGB.patch nobara/amdgpu-si-cik-default.patch +asuslinux/0001-platform-x86-asus-wmi-add-support-for-2024-ROG-Mini-.patch +asuslinux/0002-platform-x86-asus-wmi-add-support-for-Vivobook-GPU-M.patch +asuslinux/0003-platform-x86-asus-wmi-add-support-variant-of-TUF-RGB.patch +asuslinux/0004-platform-x86-asus-wmi-support-toggling-POST-sound.patch +asuslinux/0005-platform-x86-asus-wmi-store-a-min-default-for-ppt-op.patch diff --git a/scripts/build.sh b/scripts/build.sh index c698678..561e065 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,4 +2,4 @@ echo "Pika Kernel - Building" -make -j`nproc` bindeb-pkg LOCALVERSION=-pikaos KDEB_PKGVERSION=$(make kernelversion)-4 +make -j`nproc` bindeb-pkg LOCALVERSION=-pikaos KDEB_PKGVERSION=$(make kernelversion)-100pika1