+++ /dev/null
-From 32cd0e7c2ba83070ef63507abb061bc2d6193bd7 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 9 Jun 2021 13:40:18 -0500
-Subject: ACPI: Add quirks for AMD Renoir/Lucienne CPUs to force the D3 hint
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit 6485fc18faa01e8845b1e5bb55118e633f84d1f2 ]
-
-AMD systems from Renoir and Lucienne require that the NVME controller
-is put into D3 over a Modern Standby / suspend-to-idle
-cycle. This is "typically" accomplished using the `StorageD3Enable`
-property in the _DSD, but this property was introduced after many
-of these systems launched and most OEM systems don't have it in
-their BIOS.
-
-On AMD Renoir without these drives going into D3 over suspend-to-idle
-the resume will fail with the NVME controller being reset and a trace
-like this in the kernel logs:
-```
-[ 83.556118] nvme nvme0: I/O 161 QID 2 timeout, aborting
-[ 83.556178] nvme nvme0: I/O 162 QID 2 timeout, aborting
-[ 83.556187] nvme nvme0: I/O 163 QID 2 timeout, aborting
-[ 83.556196] nvme nvme0: I/O 164 QID 2 timeout, aborting
-[ 95.332114] nvme nvme0: I/O 25 QID 0 timeout, reset controller
-[ 95.332843] nvme nvme0: Abort status: 0x371
-[ 95.332852] nvme nvme0: Abort status: 0x371
-[ 95.332856] nvme nvme0: Abort status: 0x371
-[ 95.332859] nvme nvme0: Abort status: 0x371
-[ 95.332909] PM: dpm_run_callback(): pci_pm_resume+0x0/0xe0 returns -16
-[ 95.332936] nvme 0000:03:00.0: PM: failed to resume async: error -16
-```
-
-The Microsoft documentation for StorageD3Enable mentioned that Windows has
-a hardcoded allowlist for D3 support, which was used for these platforms.
-Introduce quirks to hardcode them for Linux as well.
-
-As this property is now "standardized", OEM systems using AMD Cezanne and
-newer APU's have adopted this property, and quirks like this should not be
-necessary.
-
-CC: Shyam-sundar S-k <Shyam-sundar.S-k@amd.com>
-CC: Alexander Deucher <Alexander.Deucher@amd.com>
-CC: Prike Liang <prike.liang@amd.com>
-Link: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/power-management-for-storage-hardware-devices-intro
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Tested-by: Julian Sikorski <belegdol@gmail.com>
-Signed-off-by: Christoph Hellwig <hch@lst.de>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/device_pm.c | 3 +++
- drivers/acpi/internal.h | 9 +++++++++
- drivers/acpi/x86/utils.c | 25 +++++++++++++++++++++++++
- 3 files changed, 37 insertions(+)
-
-diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
-index fcb10697ed7bb..c672e1d0c4fdf 100644
---- a/drivers/acpi/device_pm.c
-+++ b/drivers/acpi/device_pm.c
-@@ -1351,6 +1351,9 @@ bool acpi_storage_d3(struct device *dev)
- struct acpi_device *adev = ACPI_COMPANION(dev);
- u8 val;
-
-+ if (force_storage_d3())
-+ return true;
-+
- if (!adev)
- return false;
- if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
-diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
-index 62b6b36f3a37c..c58b910946fdb 100644
---- a/drivers/acpi/internal.h
-+++ b/drivers/acpi/internal.h
-@@ -236,6 +236,15 @@ static inline int suspend_nvs_save(void) { return 0; }
- static inline void suspend_nvs_restore(void) {}
- #endif
-
-+#ifdef CONFIG_X86
-+bool force_storage_d3(void);
-+#else
-+static inline bool force_storage_d3(void)
-+{
-+ return false;
-+}
-+#endif
-+
- /*--------------------------------------------------------------------------
- Device properties
- -------------------------------------------------------------------------- */
-diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
-index 697a6b12d6b96..70a5eba7afc6f 100644
---- a/drivers/acpi/x86/utils.c
-+++ b/drivers/acpi/x86/utils.c
-@@ -135,3 +135,28 @@ bool acpi_device_always_present(struct acpi_device *adev)
-
- return ret;
- }
-+
-+/*
-+ * AMD systems from Renoir and Lucienne *require* that the NVME controller
-+ * is put into D3 over a Modern Standby / suspend-to-idle cycle.
-+ *
-+ * This is "typically" accomplished using the `StorageD3Enable`
-+ * property in the _DSD that is checked via the `acpi_storage_d3` function
-+ * but this property was introduced after many of these systems launched
-+ * and most OEM systems don't have it in their BIOS.
-+ *
-+ * The Microsoft documentation for StorageD3Enable mentioned that Windows has
-+ * a hardcoded allowlist for D3 support, which was used for these platforms.
-+ *
-+ * This allows quirking on Linux in a similar fashion.
-+ */
-+static const struct x86_cpu_id storage_d3_cpu_ids[] = {
-+ X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */
-+ X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */
-+ {}
-+};
-+
-+bool force_storage_d3(void)
-+{
-+ return x86_match_cpu(storage_d3_cpu_ids);
-+}
---
-2.43.0
-
+++ /dev/null
-From 3511a4f82bbe3ef6b365350afc0dfd821f0c6970 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 9 Jun 2021 13:40:17 -0500
-Subject: ACPI: Check StorageD3Enable _DSD property in ACPI code
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit 2744d7a0733503931b71c00d156119ced002f22c ]
-
-Although first implemented for NVME, this check may be usable by
-other drivers as well. Microsoft's specification explicitly mentions
-that is may be usable by SATA and AHCI devices. Google also indicates
-that they have used this with SDHCI in a downstream kernel tree that
-a user can plug a storage device into.
-
-Link: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/power-management-for-storage-hardware-devices-intro
-Suggested-by: Keith Busch <kbusch@kernel.org>
-CC: Shyam-sundar S-k <Shyam-sundar.S-k@amd.com>
-CC: Alexander Deucher <Alexander.Deucher@amd.com>
-CC: Rafael J. Wysocki <rjw@rjwysocki.net>
-CC: Prike Liang <prike.liang@amd.com>
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Signed-off-by: Christoph Hellwig <hch@lst.de>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/device_pm.c | 29 +++++++++++++++++++++++++++++
- drivers/nvme/host/pci.c | 28 +---------------------------
- include/linux/acpi.h | 5 +++++
- 3 files changed, 35 insertions(+), 27 deletions(-)
-
-diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
-index 72e6fad39a5e1..fcb10697ed7bb 100644
---- a/drivers/acpi/device_pm.c
-+++ b/drivers/acpi/device_pm.c
-@@ -1331,4 +1331,33 @@ int acpi_dev_pm_attach(struct device *dev, bool power_on)
- return 1;
- }
- EXPORT_SYMBOL_GPL(acpi_dev_pm_attach);
-+
-+/**
-+ * acpi_storage_d3 - Check if D3 should be used in the suspend path
-+ * @dev: Device to check
-+ *
-+ * Return %true if the platform firmware wants @dev to be programmed
-+ * into D3hot or D3cold (if supported) in the suspend path, or %false
-+ * when there is no specific preference. On some platforms, if this
-+ * hint is ignored, @dev may remain unresponsive after suspending the
-+ * platform as a whole.
-+ *
-+ * Although the property has storage in the name it actually is
-+ * applied to the PCIe slot and plugging in a non-storage device the
-+ * same platform restrictions will likely apply.
-+ */
-+bool acpi_storage_d3(struct device *dev)
-+{
-+ struct acpi_device *adev = ACPI_COMPANION(dev);
-+ u8 val;
-+
-+ if (!adev)
-+ return false;
-+ if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
-+ &val))
-+ return false;
-+ return val == 1;
-+}
-+EXPORT_SYMBOL_GPL(acpi_storage_d3);
-+
- #endif /* CONFIG_PM */
-diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
-index 58aad5e03d045..145db8bf3acc5 100644
---- a/drivers/nvme/host/pci.c
-+++ b/drivers/nvme/host/pci.c
-@@ -2829,32 +2829,6 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)
- return 0;
- }
-
--#ifdef CONFIG_ACPI
--static bool nvme_acpi_storage_d3(struct pci_dev *dev)
--{
-- struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
-- u8 val;
--
-- /*
-- * Look for _DSD property specifying that the storage device on the port
-- * must use D3 to support deep platform power savings during
-- * suspend-to-idle.
-- */
--
-- if (!adev)
-- return false;
-- if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
-- &val))
-- return false;
-- return val == 1;
--}
--#else
--static inline bool nvme_acpi_storage_d3(struct pci_dev *dev)
--{
-- return false;
--}
--#endif /* CONFIG_ACPI */
--
- static void nvme_async_probe(void *data, async_cookie_t cookie)
- {
- struct nvme_dev *dev = data;
-@@ -2902,7 +2876,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-
- quirks |= check_vendor_combination_bug(pdev);
-
-- if (!noacpi && nvme_acpi_storage_d3(pdev)) {
-+ if (!noacpi && acpi_storage_d3(&pdev->dev)) {
- /*
- * Some systems use a bios work around to ask for D3 on
- * platforms that support kernel managed suspend.
-diff --git a/include/linux/acpi.h b/include/linux/acpi.h
-index 65a6b75b55c32..af1ccf307e4ec 100644
---- a/include/linux/acpi.h
-+++ b/include/linux/acpi.h
-@@ -945,6 +945,7 @@ int acpi_dev_resume(struct device *dev);
- int acpi_subsys_runtime_suspend(struct device *dev);
- int acpi_subsys_runtime_resume(struct device *dev);
- int acpi_dev_pm_attach(struct device *dev, bool power_on);
-+bool acpi_storage_d3(struct device *dev);
- #else
- static inline int acpi_dev_runtime_suspend(struct device *dev) { return 0; }
- static inline int acpi_dev_runtime_resume(struct device *dev) { return 0; }
-@@ -954,6 +955,10 @@ static inline int acpi_dev_pm_attach(struct device *dev, bool power_on)
- {
- return 0;
- }
-+static inline bool acpi_storage_d3(struct device *dev)
-+{
-+ return false;
-+}
- #endif
-
- #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP)
---
-2.43.0
-
+++ /dev/null
-From 5625673f5fe2588680f82b34216d5156e7180de5 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 1 Oct 2019 17:27:22 +0300
-Subject: ACPI / utils: Introduce acpi_dev_hid_uid_match() helper
-
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-
-[ Upstream commit 35009c807488ccd5a01cbf102033695e52794b68 ]
-
-There are users outside of ACPI realm which reimplementing the comparator
-function to check if the given device matches to given HID and UID.
-
-For better utilization, introduce a helper for everyone to use.
-
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: a92a73b1d924 ("mmc: sdhci-acpi: Sort DMI quirks alphabetically")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/utils.c | 25 +++++++++++++++++++++++++
- include/acpi/acpi_bus.h | 2 ++
- include/linux/acpi.h | 8 ++++++++
- 3 files changed, 35 insertions(+)
-
-diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
-index e3974a8f8fd41..2deba6c2cd99f 100644
---- a/drivers/acpi/utils.c
-+++ b/drivers/acpi/utils.c
-@@ -694,6 +694,31 @@ bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs)
- }
- EXPORT_SYMBOL(acpi_check_dsm);
-
-+/**
-+ * acpi_dev_hid_uid_match - Match device by supplied HID and UID
-+ * @adev: ACPI device to match.
-+ * @hid2: Hardware ID of the device.
-+ * @uid2: Unique ID of the device, pass NULL to not check _UID.
-+ *
-+ * Matches HID and UID in @adev with given @hid2 and @uid2.
-+ * Returns true if matches.
-+ */
-+bool acpi_dev_hid_uid_match(struct acpi_device *adev,
-+ const char *hid2, const char *uid2)
-+{
-+ const char *hid1 = acpi_device_hid(adev);
-+ const char *uid1 = acpi_device_uid(adev);
-+
-+ if (strcmp(hid1, hid2))
-+ return false;
-+
-+ if (!uid2)
-+ return true;
-+
-+ return uid1 && !strcmp(uid1, uid2);
-+}
-+EXPORT_SYMBOL(acpi_dev_hid_uid_match);
-+
- /**
- * acpi_dev_found - Detect presence of a given ACPI device in the namespace.
- * @hid: Hardware ID of the device.
-diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
-index 1e5ae3b01eb2b..5de47e7a5d37b 100644
---- a/include/acpi/acpi_bus.h
-+++ b/include/acpi/acpi_bus.h
-@@ -676,6 +676,8 @@ static inline bool acpi_device_can_poweroff(struct acpi_device *adev)
- adev->power.states[ACPI_STATE_D3_HOT].flags.explicit_set);
- }
-
-+bool acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2);
-+
- struct acpi_device *
- acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv);
-
-diff --git a/include/linux/acpi.h b/include/linux/acpi.h
-index c708fd8315652..65a6b75b55c32 100644
---- a/include/linux/acpi.h
-+++ b/include/linux/acpi.h
-@@ -687,6 +687,14 @@ static inline bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
- return false;
- }
-
-+struct acpi_device;
-+
-+static inline bool
-+acpi_dev_hid_uid_match(struct acpi_device *adev, const char *hid2, const char *uid2)
-+{
-+ return false;
-+}
-+
- static inline struct acpi_device *
- acpi_dev_get_first_match_dev(const char *hid, const char *uid, s64 hrv)
- {
---
-2.43.0
-
+++ /dev/null
-From 4515a5ad58f9950ae264ddd30a86849a484b1d8d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 15 Sep 2022 13:23:14 -0500
-Subject: ACPI: x86: Add a quirk for Dell Inspiron 14 2-in-1 for
- StorageD3Enable
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit 018d6711c26e4bd26e20a819fcc7f8ab902608f3 ]
-
-Dell Inspiron 14 2-in-1 has two ACPI nodes under GPP1 both with _ADR of
-0, both without _HID. It's ambiguous which the kernel should take, but
-it seems to take "DEV0". Unfortunately "DEV0" is missing the device
-property `StorageD3Enable` which is present on "NVME".
-
-To avoid this causing problems for suspend, add a quirk for this system
-to behave like `StorageD3Enable` property was found.
-
-Link: https://bugzilla.kernel.org/show_bug.cgi?id=216440
-Reported-and-tested-by: Luya Tshimbalanga <luya@fedoraproject.org>
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/x86/utils.c | 19 ++++++++++++++++++-
- 1 file changed, 18 insertions(+), 1 deletion(-)
-
-diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
-index 70a5eba7afc6f..0bf27e66ed0e3 100644
---- a/drivers/acpi/x86/utils.c
-+++ b/drivers/acpi/x86/utils.c
-@@ -156,7 +156,24 @@ static const struct x86_cpu_id storage_d3_cpu_ids[] = {
- {}
- };
-
-+static const struct dmi_system_id force_storage_d3_dmi[] = {
-+ {
-+ /*
-+ * _ADR is ambiguous between GPP1.DEV0 and GPP1.NVME
-+ * but .NVME is needed to get StorageD3Enable node
-+ * https://bugzilla.kernel.org/show_bug.cgi?id=216440
-+ */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 14 7425 2-in-1"),
-+ }
-+ },
-+ {}
-+};
-+
- bool force_storage_d3(void)
- {
-- return x86_match_cpu(storage_d3_cpu_ids);
-+ const struct dmi_system_id *dmi_id = dmi_first_match(force_storage_d3_dmi);
-+
-+ return dmi_id || x86_match_cpu(storage_d3_cpu_ids);
- }
---
-2.43.0
-
+++ /dev/null
-From 859f8af79ee0213426f15c3ef5fc4c66fafd67f4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 14 Oct 2022 07:11:36 -0500
-Subject: ACPI: x86: Add another system to quirk list for forcing
- StorageD3Enable
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit 2124becad797245d49252d2d733aee0322233d7e ]
-
-commit 018d6711c26e4 ("ACPI: x86: Add a quirk for Dell Inspiron 14 2-in-1
-for StorageD3Enable") introduced a quirk to allow a system with ambiguous
-use of _ADR 0 to force StorageD3Enable.
-
-Julius Brockmann reports that Inspiron 16 5625 suffers that same symptoms.
-Add this other system to the list as well.
-
-Link: https://bugzilla.kernel.org/show_bug.cgi?id=216440
-Reported-and-tested-by: Julius Brockmann <mail@juliusbrockmann.com>
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/x86/utils.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
-index 0bf27e66ed0e3..f83fff9024611 100644
---- a/drivers/acpi/x86/utils.c
-+++ b/drivers/acpi/x86/utils.c
-@@ -168,6 +168,12 @@ static const struct dmi_system_id force_storage_d3_dmi[] = {
- DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 14 7425 2-in-1"),
- }
- },
-+ {
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 16 5625"),
-+ }
-+ },
- {}
- };
-
---
-2.43.0
-
+++ /dev/null
-From 5ab21e8046f0dbbca2fc0a99cca32237f7bf02dc Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 9 May 2024 13:45:02 -0500
-Subject: ACPI: x86: Force StorageD3Enable on more products
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit e79a10652bbd320649da705ca1ea0c04351af403 ]
-
-A Rembrandt-based HP thin client is reported to have problems where
-the NVME disk isn't present after resume from s2idle.
-
-This is because the NVME disk wasn't put into D3 at suspend, and
-that happened because the StorageD3Enable _DSD was missing in the BIOS.
-
-As AMD's architecture requires that the NVME is in D3 for s2idle, adjust
-the criteria for force_storage_d3 to match *all* Zen SoCs when the FADT
-advertises low power idle support.
-
-This will ensure that any future products with this BIOS deficiency don't
-need to be added to the allow list of overrides.
-
-Cc: All applicable <stable@vger.kernel.org>
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Acked-by: Hans de Goede <hdegoede@redhat.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/x86/utils.c | 24 ++++++++++--------------
- 1 file changed, 10 insertions(+), 14 deletions(-)
-
-diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
-index 353b3bb017f55..759baec32257e 100644
---- a/drivers/acpi/x86/utils.c
-+++ b/drivers/acpi/x86/utils.c
-@@ -137,16 +137,16 @@ bool acpi_device_always_present(struct acpi_device *adev)
- }
-
- /*
-- * AMD systems from Renoir and Lucienne *require* that the NVME controller
-+ * AMD systems from Renoir onwards *require* that the NVME controller
- * is put into D3 over a Modern Standby / suspend-to-idle cycle.
- *
- * This is "typically" accomplished using the `StorageD3Enable`
- * property in the _DSD that is checked via the `acpi_storage_d3` function
-- * but this property was introduced after many of these systems launched
-- * and most OEM systems don't have it in their BIOS.
-+ * but some OEM systems still don't have it in their BIOS.
- *
- * The Microsoft documentation for StorageD3Enable mentioned that Windows has
-- * a hardcoded allowlist for D3 support, which was used for these platforms.
-+ * a hardcoded allowlist for D3 support as well as a registry key to override
-+ * the BIOS, which has been used for these cases.
- *
- * This allows quirking on Linux in a similar fashion.
- *
-@@ -159,17 +159,13 @@ bool acpi_device_always_present(struct acpi_device *adev)
- * https://bugzilla.kernel.org/show_bug.cgi?id=216773
- * https://bugzilla.kernel.org/show_bug.cgi?id=217003
- * 2) On at least one HP system StorageD3Enable is missing on the second NVME
-- disk in the system.
-+ * disk in the system.
-+ * 3) On at least one HP Rembrandt system StorageD3Enable is missing on the only
-+ * NVME device.
- */
--static const struct x86_cpu_id storage_d3_cpu_ids[] = {
-- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 24, NULL), /* Picasso */
-- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */
-- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */
-- X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 80, NULL), /* Cezanne */
-- {}
--};
--
- bool force_storage_d3(void)
- {
-- return x86_match_cpu(storage_d3_cpu_ids);
-+ if (!cpu_feature_enabled(X86_FEATURE_ZEN))
-+ return false;
-+ return acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0;
- }
---
-2.43.0
-
+++ /dev/null
-From bcc7b6a947bd28fa57419a4942516a632e775e91 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 28 Feb 2023 16:11:28 -0600
-Subject: ACPI: x86: utils: Add Cezanne to the list for forcing StorageD3Enable
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit e2a56364485e7789e7b8f342637c7f3a219f7ede ]
-
-commit 018d6711c26e4 ("ACPI: x86: Add a quirk for Dell Inspiron 14 2-in-1
-for StorageD3Enable") introduced a quirk to allow a system with ambiguous
-use of _ADR 0 to force StorageD3Enable.
-
-It was reported that several more Dell systems suffered the same symptoms.
-As the list is continuing to grow but these are all Cezanne systems,
-instead add Cezanne to the CPU list to apply the StorageD3Enable property
-and remove the whole list.
-
-It was also reported that an HP system only has StorageD3Enable on the ACPI
-device for the first NVME disk, not the second.
-
-Link: https://bugzilla.kernel.org/show_bug.cgi?id=217003
-Link: https://bugzilla.kernel.org/show_bug.cgi?id=216773
-Reported-by: David Alvarez Lombardi <dqalombardi@proton.me>
-Reported-by: dbilios@stdio.gr
-Reported-and-tested-by: Elvis Angelaccio <elvis.angelaccio@kde.org>
-Tested-by: victor.bonnelle@proton.me
-Tested-by: hurricanepootis@protonmail.com
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/x86/utils.c | 37 +++++++++++++------------------------
- 1 file changed, 13 insertions(+), 24 deletions(-)
-
-diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
-index f83fff9024611..b8510bbc4bd6c 100644
---- a/drivers/acpi/x86/utils.c
-+++ b/drivers/acpi/x86/utils.c
-@@ -149,37 +149,26 @@ bool acpi_device_always_present(struct acpi_device *adev)
- * a hardcoded allowlist for D3 support, which was used for these platforms.
- *
- * This allows quirking on Linux in a similar fashion.
-+ *
-+ * Cezanne systems shouldn't *normally* need this as the BIOS includes
-+ * StorageD3Enable. But for two reasons we have added it.
-+ * 1) The BIOS on a number of Dell systems have ambiguity
-+ * between the same value used for _ADR on ACPI nodes GPP1.DEV0 and GPP1.NVME.
-+ * GPP1.NVME is needed to get StorageD3Enable node set properly.
-+ * https://bugzilla.kernel.org/show_bug.cgi?id=216440
-+ * https://bugzilla.kernel.org/show_bug.cgi?id=216773
-+ * https://bugzilla.kernel.org/show_bug.cgi?id=217003
-+ * 2) On at least one HP system StorageD3Enable is missing on the second NVME
-+ disk in the system.
- */
- static const struct x86_cpu_id storage_d3_cpu_ids[] = {
- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */
- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */
-- {}
--};
--
--static const struct dmi_system_id force_storage_d3_dmi[] = {
-- {
-- /*
-- * _ADR is ambiguous between GPP1.DEV0 and GPP1.NVME
-- * but .NVME is needed to get StorageD3Enable node
-- * https://bugzilla.kernel.org/show_bug.cgi?id=216440
-- */
-- .matches = {
-- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-- DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 14 7425 2-in-1"),
-- }
-- },
-- {
-- .matches = {
-- DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-- DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 16 5625"),
-- }
-- },
-+ X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 80, NULL), /* Cezanne */
- {}
- };
-
- bool force_storage_d3(void)
- {
-- const struct dmi_system_id *dmi_id = dmi_first_match(force_storage_d3_dmi);
--
-- return dmi_id || x86_match_cpu(storage_d3_cpu_ids);
-+ return x86_match_cpu(storage_d3_cpu_ids);
- }
---
-2.43.0
-
+++ /dev/null
-From 82d4a0126a64cd71b7a4cd9a1a0c29051f4d28ef Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 31 Mar 2023 11:08:42 -0500
-Subject: ACPI: x86: utils: Add Picasso to the list for forcing StorageD3Enable
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit 10b6b4a8ac6120ec36555fd286eed577f7632e3b ]
-
-Picasso was the first APU that introduced s2idle support from AMD,
-and it was predating before vendors started to use `StorageD3Enable`
-in their firmware.
-
-Windows doesn't have problems with this hardware and NVME so it was
-likely on the list of hardcoded CPUs to use this behavior in Windows.
-
-Add it to the list for Linux to avoid NVME resume issues.
-
-Reported-by: Stuart Axon <stuaxo2@yahoo.com>
-Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2449
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/x86/utils.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
-index b8510bbc4bd6c..353b3bb017f55 100644
---- a/drivers/acpi/x86/utils.c
-+++ b/drivers/acpi/x86/utils.c
-@@ -162,6 +162,7 @@ bool acpi_device_always_present(struct acpi_device *adev)
- disk in the system.
- */
- static const struct x86_cpu_id storage_d3_cpu_ids[] = {
-+ X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 24, NULL), /* Picasso */
- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 96, NULL), /* Renoir */
- X86_MATCH_VENDOR_FAM_MODEL(AMD, 23, 104, NULL), /* Lucienne */
- X86_MATCH_VENDOR_FAM_MODEL(AMD, 25, 80, NULL), /* Cezanne */
---
-2.43.0
-
+++ /dev/null
-From 73d6beeafd5dccfbe0e8915b9aebeeb76dd1fa99 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 8 Nov 2019 09:39:30 -0600
-Subject: arm64: dts: agilex: add NAND IP to base dts
-
-From: Dinh Nguyen <dinguyen@kernel.org>
-
-[ Upstream commit 68441353538b77dbe7cd94b48d0c3677fb451be0 ]
-
-Add NAND entry to base DTSI.
-
-Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
-Stable-dep-of: 5d915e584d84 ("af_unix: Use skb_queue_len_lockless() in sk_diag_show_rqlen().")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm64/boot/dts/intel/socfpga_agilex.dtsi | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
-
-diff --git a/arch/arm64/boot/dts/intel/socfpga_agilex.dtsi b/arch/arm64/boot/dts/intel/socfpga_agilex.dtsi
-index 19f17bb29e4bd..414f84aff902f 100644
---- a/arch/arm64/boot/dts/intel/socfpga_agilex.dtsi
-+++ b/arch/arm64/boot/dts/intel/socfpga_agilex.dtsi
-@@ -229,6 +229,18 @@ mmc: dwmmc0@ff808000 {
- status = "disabled";
- };
-
-+ nand: nand@ffb90000 {
-+ #address-cells = <1>;
-+ #size-cells = <0>;
-+ compatible = "altr,socfpga-denali-nand";
-+ reg = <0xffb90000 0x10000>,
-+ <0xffb80000 0x1000>;
-+ reg-names = "nand_data", "denali_reg";
-+ interrupts = <0 97 4>;
-+ resets = <&rst NAND_RESET>, <&rst NAND_OCP_RESET>;
-+ status = "disabled";
-+ };
-+
- ocram: sram@ffe00000 {
- compatible = "mmio-sram";
- reg = <0xffe00000 0x40000>;
---
-2.43.0
-
+++ /dev/null
-From c140c3bd62861ac1b796f37deabbc405e9112b17 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 4 Dec 2019 16:50:57 -0800
-Subject: bitops: introduce the for_each_set_clump8 macro
-
-From: William Breathitt Gray <vilhelm.gray@gmail.com>
-
-[ Upstream commit 169c474fb22d8a5e909e172f177b957546d0519d ]
-
-Pach series "Introduce the for_each_set_clump8 macro", v18.
-
-While adding GPIO get_multiple/set_multiple callback support for various
-drivers, I noticed a pattern of looping manifesting that would be useful
-standardized as a macro.
-
-This patchset introduces the for_each_set_clump8 macro and utilizes it
-in several GPIO drivers. The for_each_set_clump macro8 facilitates a
-for-loop syntax that iterates over a memory region entire groups of set
-bits at a time.
-
-For example, suppose you would like to iterate over a 32-bit integer 8
-bits at a time, skipping over 8-bit groups with no set bit, where
-XXXXXXXX represents the current 8-bit group:
-
- Example: 10111110 00000000 11111111 00110011
- First loop: 10111110 00000000 11111111 XXXXXXXX
- Second loop: 10111110 00000000 XXXXXXXX 00110011
- Third loop: XXXXXXXX 00000000 11111111 00110011
-
-Each iteration of the loop returns the next 8-bit group that has at
-least one set bit.
-
-The for_each_set_clump8 macro has four parameters:
-
- * start: set to the bit offset of the current clump
- * clump: set to the current clump value
- * bits: bitmap to search within
- * size: bitmap size in number of bits
-
-In this version of the patchset, the for_each_set_clump macro has been
-reimplemented and simplified based on the suggestions provided by Rasmus
-Villemoes and Andy Shevchenko in the version 4 submission.
-
-In particular, the function of the for_each_set_clump macro has been
-restricted to handle only 8-bit clumps; the drivers that use the
-for_each_set_clump macro only handle 8-bit ports so a generic
-for_each_set_clump implementation is not necessary. Thus, a solution
-for large clumps (i.e. those larger than the width of a bitmap word)
-can be postponed until a driver appears that actually requires such a
-generic for_each_set_clump implementation.
-
-For what it's worth, a semi-generic for_each_set_clump (i.e. for clumps
-smaller than the width of a bitmap word) can be implemented by simply
-replacing the hardcoded '8' and '0xFF' instances with respective
-variables. I have not yet had a need for such an implementation, and
-since it falls short of a true generic for_each_set_clump function, I
-have decided to forgo such an implementation for now.
-
-In addition, the bitmap_get_value8 and bitmap_set_value8 functions are
-introduced to get and set 8-bit values respectively. Their use is based
-on the behavior suggested in the patchset version 4 review.
-
-This patch (of 14):
-
-This macro iterates for each 8-bit group of bits (clump) with set bits,
-within a bitmap memory region. For each iteration, "start" is set to
-the bit offset of the found clump, while the respective clump value is
-stored to the location pointed by "clump". Additionally, the
-bitmap_get_value8 and bitmap_set_value8 functions are introduced to
-respectively get and set an 8-bit value in a bitmap memory region.
-
-[gustavo@embeddedor.com: fix potential sign-extension overflow]
- Link: http://lkml.kernel.org/r/20191015184657.GA26541@embeddedor
-[akpm@linux-foundation.org: s/ULL/UL/, per Joe]
-[vilhelm.gray@gmail.com: add for_each_set_clump8 documentation]
- Link: http://lkml.kernel.org/r/20191016161825.301082-1-vilhelm.gray@gmail.com
-Link: http://lkml.kernel.org/r/893c3b4f03266c9496137cc98ac2b1bd27f92c73.1570641097.git.vilhelm.gray@gmail.com
-Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com>
-Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
-Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
-Suggested-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
-Suggested-by: Lukas Wunner <lukas@wunner.de>
-Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Cc: Arnd Bergmann <arnd@arndb.de>
-Cc: Linus Walleij <linus.walleij@linaro.org>
-Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
-Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
-Cc: Geert Uytterhoeven <geert@linux-m68k.org>
-Cc: Phil Reid <preid@electromag.com.au>
-Cc: Geert Uytterhoeven <geert+renesas@glider.be>
-Cc: Mathias Duckeck <m.duckeck@kunbus.de>
-Cc: Morten Hein Tiljeset <morten.tiljeset@prevas.dk>
-Cc: Sean Nyekjaer <sean.nyekjaer@prevas.dk>
-Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-Stable-dep-of: 9d6a811b522b ("gpio: tqmx86: introduce shadow register for GPIO output value")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/asm-generic/bitops/find.h | 17 +++++++++++++++
- include/linux/bitmap.h | 35 +++++++++++++++++++++++++++++++
- include/linux/bitops.h | 12 +++++++++++
- lib/find_bit.c | 14 +++++++++++++
- 4 files changed, 78 insertions(+)
-
-diff --git a/include/asm-generic/bitops/find.h b/include/asm-generic/bitops/find.h
-index 8a1ee10014def..9fdf21302fdf3 100644
---- a/include/asm-generic/bitops/find.h
-+++ b/include/asm-generic/bitops/find.h
-@@ -80,4 +80,21 @@ extern unsigned long find_first_zero_bit(const unsigned long *addr,
-
- #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
-
-+/**
-+ * find_next_clump8 - find next 8-bit clump with set bits in a memory region
-+ * @clump: location to store copy of found clump
-+ * @addr: address to base the search on
-+ * @size: bitmap size in number of bits
-+ * @offset: bit offset at which to start searching
-+ *
-+ * Returns the bit offset for the next set clump; the found clump value is
-+ * copied to the location pointed by @clump. If no bits are set, returns @size.
-+ */
-+extern unsigned long find_next_clump8(unsigned long *clump,
-+ const unsigned long *addr,
-+ unsigned long size, unsigned long offset);
-+
-+#define find_first_clump8(clump, bits, size) \
-+ find_next_clump8((clump), (bits), (size), 0)
-+
- #endif /*_ASM_GENERIC_BITOPS_FIND_H_ */
-diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
-index 29fc933df3bf0..9f046609e8090 100644
---- a/include/linux/bitmap.h
-+++ b/include/linux/bitmap.h
-@@ -66,6 +66,8 @@
- * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
- * bitmap_from_arr32(dst, buf, nbits) Copy nbits from u32[] buf to dst
- * bitmap_to_arr32(buf, src, nbits) Copy nbits from buf to u32[] dst
-+ * bitmap_get_value8(map, start) Get 8bit value from map at start
-+ * bitmap_set_value8(map, value, start) Set 8bit value to map at start
- *
- * Note, bitmap_zero() and bitmap_fill() operate over the region of
- * unsigned longs, that is, bits behind bitmap till the unsigned long
-@@ -489,6 +491,39 @@ static inline void bitmap_from_u64(unsigned long *dst, u64 mask)
- dst[1] = mask >> 32;
- }
-
-+/**
-+ * bitmap_get_value8 - get an 8-bit value within a memory region
-+ * @map: address to the bitmap memory region
-+ * @start: bit offset of the 8-bit value; must be a multiple of 8
-+ *
-+ * Returns the 8-bit value located at the @start bit offset within the @src
-+ * memory region.
-+ */
-+static inline unsigned long bitmap_get_value8(const unsigned long *map,
-+ unsigned long start)
-+{
-+ const size_t index = BIT_WORD(start);
-+ const unsigned long offset = start % BITS_PER_LONG;
-+
-+ return (map[index] >> offset) & 0xFF;
-+}
-+
-+/**
-+ * bitmap_set_value8 - set an 8-bit value within a memory region
-+ * @map: address to the bitmap memory region
-+ * @value: the 8-bit value; values wider than 8 bits may clobber bitmap
-+ * @start: bit offset of the 8-bit value; must be a multiple of 8
-+ */
-+static inline void bitmap_set_value8(unsigned long *map, unsigned long value,
-+ unsigned long start)
-+{
-+ const size_t index = BIT_WORD(start);
-+ const unsigned long offset = start % BITS_PER_LONG;
-+
-+ map[index] &= ~(0xFFUL << offset);
-+ map[index] |= value << offset;
-+}
-+
- #endif /* __ASSEMBLY__ */
-
- #endif /* __LINUX_BITMAP_H */
-diff --git a/include/linux/bitops.h b/include/linux/bitops.h
-index e9e74af163fab..5e51d28b33f8d 100644
---- a/include/linux/bitops.h
-+++ b/include/linux/bitops.h
-@@ -48,6 +48,18 @@ extern unsigned long __sw_hweight64(__u64 w);
- (bit) < (size); \
- (bit) = find_next_zero_bit((addr), (size), (bit) + 1))
-
-+/**
-+ * for_each_set_clump8 - iterate over bitmap for each 8-bit clump with set bits
-+ * @start: bit offset to start search and to store the current iteration offset
-+ * @clump: location to store copy of current 8-bit clump
-+ * @bits: bitmap address to base the search on
-+ * @size: bitmap size in number of bits
-+ */
-+#define for_each_set_clump8(start, clump, bits, size) \
-+ for ((start) = find_first_clump8(&(clump), (bits), (size)); \
-+ (start) < (size); \
-+ (start) = find_next_clump8(&(clump), (bits), (size), (start) + 8))
-+
- static inline int get_bitmask_order(unsigned int count)
- {
- int order;
-diff --git a/lib/find_bit.c b/lib/find_bit.c
-index 4e68490fa7035..06e503c339f37 100644
---- a/lib/find_bit.c
-+++ b/lib/find_bit.c
-@@ -202,3 +202,17 @@ EXPORT_SYMBOL(find_next_bit_le);
- #endif
-
- #endif /* __BIG_ENDIAN */
-+
-+unsigned long find_next_clump8(unsigned long *clump, const unsigned long *addr,
-+ unsigned long size, unsigned long offset)
-+{
-+ offset = find_next_bit(addr, size, offset);
-+ if (offset == size)
-+ return size;
-+
-+ offset = round_down(offset, 8);
-+ *clump = bitmap_get_value8(addr, offset);
-+
-+ return offset;
-+}
-+EXPORT_SYMBOL(find_next_clump8);
---
-2.43.0
-
+++ /dev/null
-From 8af05fe961081463b9e1511e25a9b2074925f9b3 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 16 Sep 2020 13:40:41 -0700
-Subject: drivers core: Reindent a couple uses around sysfs_emit
-
-From: Joe Perches <joe@perches.com>
-
-[ Upstream commit 27275d301813d1f3b1b2fe5576d4afd690df6b99 ]
-
-Just a couple of whitespace realignment to open parenthesis for
-multi-line statements.
-
-Signed-off-by: Joe Perches <joe@perches.com>
-Link: https://lore.kernel.org/r/33224191421dbb56015eded428edfddcba997d63.1600285923.git.joe@perches.com
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-Stable-dep-of: 55c421b36448 ("mmc: davinci: Don't strip remove function when driver is builtin")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/base/node.c | 4 ++--
- drivers/base/power/sysfs.c | 2 +-
- 2 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/drivers/base/node.c b/drivers/base/node.c
-index 666eb55c0774e..c78d190fef376 100644
---- a/drivers/base/node.c
-+++ b/drivers/base/node.c
-@@ -384,9 +384,9 @@ static ssize_t node_read_meminfo(struct device *dev,
- nid, K(i.freeram),
- nid, K(i.totalram - i.freeram),
- nid, K(node_page_state(pgdat, NR_ACTIVE_ANON) +
-- node_page_state(pgdat, NR_ACTIVE_FILE)),
-+ node_page_state(pgdat, NR_ACTIVE_FILE)),
- nid, K(node_page_state(pgdat, NR_INACTIVE_ANON) +
-- node_page_state(pgdat, NR_INACTIVE_FILE)),
-+ node_page_state(pgdat, NR_INACTIVE_FILE)),
- nid, K(node_page_state(pgdat, NR_ACTIVE_ANON)),
- nid, K(node_page_state(pgdat, NR_INACTIVE_ANON)),
- nid, K(node_page_state(pgdat, NR_ACTIVE_FILE)),
-diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
-index 2786962e08107..4ac032a1fa228 100644
---- a/drivers/base/power/sysfs.c
-+++ b/drivers/base/power/sysfs.c
-@@ -101,7 +101,7 @@ static ssize_t control_show(struct device *dev, struct device_attribute *attr,
- char *buf)
- {
- return sysfs_emit(buf, "%s\n",
-- dev->power.runtime_auto ? ctrl_auto : ctrl_on);
-+ dev->power.runtime_auto ? ctrl_auto : ctrl_on);
- }
-
- static ssize_t control_store(struct device * dev, struct device_attribute *attr,
---
-2.43.0
-
+++ /dev/null
-From f691d0cbdf9b9b179ffef64a78ada25c3e42d2ff Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 24 Mar 2020 14:32:11 +0200
-Subject: i2c: core: Provide generic definitions for bus frequencies
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-
-[ Upstream commit e6282fc6f889debe4d6eb6332dc6e49739faa5cb ]
-
-There are few maximum bus frequencies being used in the I²C core code.
-Provide generic definitions for bus frequencies and use them in the core.
-
-The drivers may use predefined constants where it is appropriate.
-Some of them are already using these under slightly different names.
-We will convert them later to use newly introduced defines.
-
-Note, the name of modes are chosen to follow well established naming
-scheme [1].
-
-These definitions will also help to avoid typos in the numbers that
-may lead to subtle errors.
-
-[1]: https://en.wikipedia.org/wiki/I%C2%B2C#Differences_between_modes
-
-Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-Stable-dep-of: cbf3fb5b29e9 ("i2c: designware: Fix the functionality flags of the slave-only interface")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/i2c/i2c-core-acpi.c | 2 +-
- drivers/i2c/i2c-core-base.c | 8 ++++----
- include/linux/i2c.h | 8 ++++++++
- 3 files changed, 13 insertions(+), 5 deletions(-)
-
-diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
-index fe466ee4c49bf..17640e2230b61 100644
---- a/drivers/i2c/i2c-core-acpi.c
-+++ b/drivers/i2c/i2c-core-acpi.c
-@@ -328,7 +328,7 @@ static acpi_status i2c_acpi_lookup_speed(acpi_handle handle, u32 level,
- lookup->min_speed = lookup->speed;
-
- if (acpi_match_device_ids(adev, i2c_acpi_force_400khz_device_ids) == 0)
-- lookup->force_speed = 400000;
-+ lookup->force_speed = I2C_MAX_FAST_MODE_FREQ;
-
- return AE_OK;
- }
-diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
-index cf9ad03bb34de..4972cc0f9f9ac 100644
---- a/drivers/i2c/i2c-core-base.c
-+++ b/drivers/i2c/i2c-core-base.c
-@@ -1650,13 +1650,13 @@ void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_de
-
- ret = device_property_read_u32(dev, "clock-frequency", &t->bus_freq_hz);
- if (ret && use_defaults)
-- t->bus_freq_hz = 100000;
-+ t->bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ;
-
- ret = device_property_read_u32(dev, "i2c-scl-rising-time-ns", &t->scl_rise_ns);
- if (ret && use_defaults) {
-- if (t->bus_freq_hz <= 100000)
-+ if (t->bus_freq_hz <= I2C_MAX_STANDARD_MODE_FREQ)
- t->scl_rise_ns = 1000;
-- else if (t->bus_freq_hz <= 400000)
-+ else if (t->bus_freq_hz <= I2C_MAX_FAST_MODE_FREQ)
- t->scl_rise_ns = 300;
- else
- t->scl_rise_ns = 120;
-@@ -1664,7 +1664,7 @@ void i2c_parse_fw_timings(struct device *dev, struct i2c_timings *t, bool use_de
-
- ret = device_property_read_u32(dev, "i2c-scl-falling-time-ns", &t->scl_fall_ns);
- if (ret && use_defaults) {
-- if (t->bus_freq_hz <= 400000)
-+ if (t->bus_freq_hz <= I2C_MAX_FAST_MODE_FREQ)
- t->scl_fall_ns = 300;
- else
- t->scl_fall_ns = 120;
-diff --git a/include/linux/i2c.h b/include/linux/i2c.h
-index af2b799d7a665..3d0008c41bed8 100644
---- a/include/linux/i2c.h
-+++ b/include/linux/i2c.h
-@@ -39,6 +39,14 @@ enum i2c_slave_event;
- typedef int (*i2c_slave_cb_t)(struct i2c_client *client,
- enum i2c_slave_event event, u8 *val);
-
-+/* I2C Frequency Modes */
-+#define I2C_MAX_STANDARD_MODE_FREQ 100000
-+#define I2C_MAX_FAST_MODE_FREQ 400000
-+#define I2C_MAX_FAST_MODE_PLUS_FREQ 1000000
-+#define I2C_MAX_TURBO_MODE_FREQ 1400000
-+#define I2C_MAX_HIGH_SPEED_MODE_FREQ 3400000
-+#define I2C_MAX_ULTRA_FAST_MODE_FREQ 5000000
-+
- struct module;
- struct property_entry;
-
---
-2.43.0
-
+++ /dev/null
-From d566760563316f41fe836ccce70069d512958423 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 6 Mar 2020 16:19:54 +0300
-Subject: i2c: designware: Detect the FIFO size in the common code
-
-From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
-
-[ Upstream commit 1f1a714658307a1a5ec65b0a23d87a87da64c86f ]
-
-The problem with detecting the FIFO depth in the platform driver
-is that in order to implement this we have to access the controller
-IC_COMP_PARAM_1 register. Currently it's done before the
-i2c_dw_set_reg_access() method execution, which is errors prone since
-the method determines the registers endianness and access mode and we
-can't use dw_readl/dw_writel accessors before this information is
-retrieved. We also can't move the i2c_dw_set_reg_access() function
-invocation to after the master/slave probe functions call (when endianness
-and access mode are determined), since the FIFO depth information is used
-by them for initializations. So in order to fix the problem we have no
-choice but to move the FIFO size detection methods to the common code and
-call it at the probe stage.
-
-Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
-Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
-Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
-Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-Stable-dep-of: cbf3fb5b29e9 ("i2c: designware: Fix the functionality flags of the slave-only interface")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/i2c/busses/i2c-designware-common.c | 22 +++++++++++++++++++
- drivers/i2c/busses/i2c-designware-core.h | 1 +
- drivers/i2c/busses/i2c-designware-master.c | 2 ++
- drivers/i2c/busses/i2c-designware-platdrv.c | 24 ---------------------
- drivers/i2c/busses/i2c-designware-slave.c | 2 ++
- 5 files changed, 27 insertions(+), 24 deletions(-)
-
-diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
-index c9036675bd779..2abfed2b3e875 100644
---- a/drivers/i2c/busses/i2c-designware-common.c
-+++ b/drivers/i2c/busses/i2c-designware-common.c
-@@ -341,6 +341,28 @@ int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev)
- return -EIO;
- }
-
-+void i2c_dw_set_fifo_size(struct dw_i2c_dev *dev)
-+{
-+ u32 param, tx_fifo_depth, rx_fifo_depth;
-+
-+ /*
-+ * Try to detect the FIFO depth if not set by interface driver,
-+ * the depth could be from 2 to 256 from HW spec.
-+ */
-+ param = dw_readl(dev, DW_IC_COMP_PARAM_1);
-+ tx_fifo_depth = ((param >> 16) & 0xff) + 1;
-+ rx_fifo_depth = ((param >> 8) & 0xff) + 1;
-+ if (!dev->tx_fifo_depth) {
-+ dev->tx_fifo_depth = tx_fifo_depth;
-+ dev->rx_fifo_depth = rx_fifo_depth;
-+ } else if (tx_fifo_depth >= 2) {
-+ dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth,
-+ tx_fifo_depth);
-+ dev->rx_fifo_depth = min_t(u32, dev->rx_fifo_depth,
-+ rx_fifo_depth);
-+ }
-+}
-+
- u32 i2c_dw_func(struct i2c_adapter *adap)
- {
- struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
-diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
-index 67edbbde1070a..3fbc9f22fcf1c 100644
---- a/drivers/i2c/busses/i2c-designware-core.h
-+++ b/drivers/i2c/busses/i2c-designware-core.h
-@@ -297,6 +297,7 @@ int i2c_dw_acquire_lock(struct dw_i2c_dev *dev);
- void i2c_dw_release_lock(struct dw_i2c_dev *dev);
- int i2c_dw_wait_bus_not_busy(struct dw_i2c_dev *dev);
- int i2c_dw_handle_tx_abort(struct dw_i2c_dev *dev);
-+void i2c_dw_set_fifo_size(struct dw_i2c_dev *dev);
- u32 i2c_dw_func(struct i2c_adapter *adap);
- void i2c_dw_disable(struct dw_i2c_dev *dev);
- void i2c_dw_disable_int(struct dw_i2c_dev *dev);
-diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
-index e8b328242256e..05da900cf3759 100644
---- a/drivers/i2c/busses/i2c-designware-master.c
-+++ b/drivers/i2c/busses/i2c-designware-master.c
-@@ -698,6 +698,8 @@ int i2c_dw_probe(struct dw_i2c_dev *dev)
- if (ret)
- return ret;
-
-+ i2c_dw_set_fifo_size(dev);
-+
- ret = dev->init(dev);
- if (ret)
- return ret;
-diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
-index 75313c80f132f..3a094ce343f43 100644
---- a/drivers/i2c/busses/i2c-designware-platdrv.c
-+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
-@@ -218,28 +218,6 @@ static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
- dev->mode = DW_IC_SLAVE;
- }
-
--static void dw_i2c_set_fifo_size(struct dw_i2c_dev *dev)
--{
-- u32 param, tx_fifo_depth, rx_fifo_depth;
--
-- /*
-- * Try to detect the FIFO depth if not set by interface driver,
-- * the depth could be from 2 to 256 from HW spec.
-- */
-- param = i2c_dw_read_comp_param(dev);
-- tx_fifo_depth = ((param >> 16) & 0xff) + 1;
-- rx_fifo_depth = ((param >> 8) & 0xff) + 1;
-- if (!dev->tx_fifo_depth) {
-- dev->tx_fifo_depth = tx_fifo_depth;
-- dev->rx_fifo_depth = rx_fifo_depth;
-- } else if (tx_fifo_depth >= 2) {
-- dev->tx_fifo_depth = min_t(u32, dev->tx_fifo_depth,
-- tx_fifo_depth);
-- dev->rx_fifo_depth = min_t(u32, dev->rx_fifo_depth,
-- rx_fifo_depth);
-- }
--}
--
- static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
- {
- pm_runtime_disable(dev->dev);
-@@ -370,8 +348,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
- div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000);
- }
-
-- dw_i2c_set_fifo_size(dev);
--
- adap = &dev->adapter;
- adap->owner = THIS_MODULE;
- adap->class = I2C_CLASS_DEPRECATED;
-diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
-index f5f001738df5e..0fc3aa31d46aa 100644
---- a/drivers/i2c/busses/i2c-designware-slave.c
-+++ b/drivers/i2c/busses/i2c-designware-slave.c
-@@ -260,6 +260,8 @@ int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
- if (ret)
- return ret;
-
-+ i2c_dw_set_fifo_size(dev);
-+
- ret = dev->init(dev);
- if (ret)
- return ret;
---
-2.43.0
-
+++ /dev/null
-From 7d20a99f7db1c4a8974b44e67fc93119400238f9 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 6 Mar 2020 16:19:56 +0300
-Subject: i2c: designware: Discard i2c_dw_read_comp_param() function
-
-From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
-
-[ Upstream commit d816f216c36445d1f9180b32ac30a3094317d6bb ]
-
-There is no code left in the kernel which would be using the function.
-So just remove it.
-
-Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
-Signed-off-by: Alexey Malahov <Alexey.Malahov@baikalelectronics.ru>
-Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
-Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-Stable-dep-of: cbf3fb5b29e9 ("i2c: designware: Fix the functionality flags of the slave-only interface")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/i2c/busses/i2c-designware-common.c | 6 ------
- drivers/i2c/busses/i2c-designware-core.h | 1 -
- 2 files changed, 7 deletions(-)
-
-diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
-index 2abfed2b3e875..8ebe2ca13c8f6 100644
---- a/drivers/i2c/busses/i2c-designware-common.c
-+++ b/drivers/i2c/busses/i2c-designware-common.c
-@@ -385,11 +385,5 @@ void i2c_dw_disable_int(struct dw_i2c_dev *dev)
- dw_writel(dev, 0, DW_IC_INTR_MASK);
- }
-
--u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev)
--{
-- return dw_readl(dev, DW_IC_COMP_PARAM_1);
--}
--EXPORT_SYMBOL_GPL(i2c_dw_read_comp_param);
--
- MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter core");
- MODULE_LICENSE("GPL");
-diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
-index 3fbc9f22fcf1c..b220ad64c38d7 100644
---- a/drivers/i2c/busses/i2c-designware-core.h
-+++ b/drivers/i2c/busses/i2c-designware-core.h
-@@ -314,7 +314,6 @@ static inline void __i2c_dw_disable_nowait(struct dw_i2c_dev *dev)
-
- void __i2c_dw_disable(struct dw_i2c_dev *dev);
-
--extern u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev);
- extern int i2c_dw_probe(struct dw_i2c_dev *dev);
- #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_SLAVE)
- extern int i2c_dw_probe_slave(struct dw_i2c_dev *dev);
---
-2.43.0
-
+++ /dev/null
-From 231b0a8a10455d45900268361d468e59e23475c4 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 31 May 2024 11:17:48 +0200
-Subject: i2c: designware: Fix the functionality flags of the slave-only
- interface
-
-From: Jean Delvare <jdelvare@suse.de>
-
-[ Upstream commit cbf3fb5b29e99e3689d63a88c3cddbffa1b8de99 ]
-
-When an I2C adapter acts only as a slave, it should not claim to
-support I2C master capabilities.
-
-Fixes: 5b6d721b266a ("i2c: designware: enable SLAVE in platform module")
-Signed-off-by: Jean Delvare <jdelvare@suse.de>
-Cc: Luis Oliveira <lolivei@synopsys.com>
-Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
-Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
-Cc: Jan Dabros <jsd@semihalf.com>
-Cc: Andi Shyti <andi.shyti@kernel.org>
-Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
-Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
-Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/i2c/busses/i2c-designware-slave.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
-index 52a0f118917e1..4ef8e9d7e545b 100644
---- a/drivers/i2c/busses/i2c-designware-slave.c
-+++ b/drivers/i2c/busses/i2c-designware-slave.c
-@@ -243,7 +243,7 @@ static const struct i2c_algorithm i2c_dw_algo = {
-
- void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
- {
-- dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY;
-+ dev->functionality = I2C_FUNC_SLAVE;
-
- dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
- DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED;
---
-2.43.0
-
+++ /dev/null
-From 41c964e72952bac10934f86768c4cce98101b147 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sat, 25 Apr 2020 16:44:45 +0300
-Subject: i2c: designware: Move configuration routines to respective modules
-
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-
-[ Upstream commit 3ebe40ed1c39016eeae947acc9fd57d6b10d43b2 ]
-
-Move configuration routines to respective modules, i.e. master and slave.
-
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Signed-off-by: Wolfram Sang <wsa@kernel.org>
-Stable-dep-of: cbf3fb5b29e9 ("i2c: designware: Fix the functionality flags of the slave-only interface")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/i2c/busses/i2c-designware-core.h | 12 +++++++
- drivers/i2c/busses/i2c-designware-master.c | 24 +++++++++++++
- drivers/i2c/busses/i2c-designware-platdrv.c | 38 +--------------------
- drivers/i2c/busses/i2c-designware-slave.c | 11 ++++++
- 4 files changed, 48 insertions(+), 37 deletions(-)
-
-diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
-index b220ad64c38d7..b2f894f685233 100644
---- a/drivers/i2c/busses/i2c-designware-core.h
-+++ b/drivers/i2c/busses/i2c-designware-core.h
-@@ -314,13 +314,25 @@ static inline void __i2c_dw_disable_nowait(struct dw_i2c_dev *dev)
-
- void __i2c_dw_disable(struct dw_i2c_dev *dev);
-
-+extern void i2c_dw_configure_master(struct dw_i2c_dev *dev);
- extern int i2c_dw_probe(struct dw_i2c_dev *dev);
-+
- #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_SLAVE)
-+extern void i2c_dw_configure_slave(struct dw_i2c_dev *dev);
- extern int i2c_dw_probe_slave(struct dw_i2c_dev *dev);
- #else
-+static inline void i2c_dw_configure_slave(struct dw_i2c_dev *dev) { }
- static inline int i2c_dw_probe_slave(struct dw_i2c_dev *dev) { return -EINVAL; }
- #endif
-
-+static inline void i2c_dw_configure(struct dw_i2c_dev *dev)
-+{
-+ if (i2c_detect_slave_mode(dev->dev))
-+ i2c_dw_configure_slave(dev);
-+ else
-+ i2c_dw_configure_master(dev);
-+}
-+
- #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_BAYTRAIL)
- extern int i2c_dw_probe_lock_support(struct dw_i2c_dev *dev);
- #else
-diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
-index 05da900cf3759..9a52ad00c4db5 100644
---- a/drivers/i2c/busses/i2c-designware-master.c
-+++ b/drivers/i2c/busses/i2c-designware-master.c
-@@ -632,6 +632,30 @@ static irqreturn_t i2c_dw_isr(int this_irq, void *dev_id)
- return IRQ_HANDLED;
- }
-
-+void i2c_dw_configure_master(struct dw_i2c_dev *dev)
-+{
-+ struct i2c_timings *t = &dev->timings;
-+
-+ dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY;
-+
-+ dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
-+ DW_IC_CON_RESTART_EN;
-+
-+ dev->mode = DW_IC_MASTER;
-+
-+ switch (t->bus_freq_hz) {
-+ case I2C_MAX_STANDARD_MODE_FREQ:
-+ dev->master_cfg |= DW_IC_CON_SPEED_STD;
-+ break;
-+ case I2C_MAX_HIGH_SPEED_MODE_FREQ:
-+ dev->master_cfg |= DW_IC_CON_SPEED_HIGH;
-+ break;
-+ default:
-+ dev->master_cfg |= DW_IC_CON_SPEED_FAST;
-+ }
-+}
-+EXPORT_SYMBOL_GPL(i2c_dw_configure_master);
-+
- static void i2c_dw_prepare_recovery(struct i2c_adapter *adap)
- {
- struct dw_i2c_dev *dev = i2c_get_adapdata(adap);
-diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
-index 50a9e29df9152..a4f0e94833aa2 100644
---- a/drivers/i2c/busses/i2c-designware-platdrv.c
-+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
-@@ -185,39 +185,6 @@ static inline int dw_i2c_of_configure(struct platform_device *pdev)
- }
- #endif
-
--static void i2c_dw_configure_master(struct dw_i2c_dev *dev)
--{
-- struct i2c_timings *t = &dev->timings;
--
-- dev->functionality = I2C_FUNC_10BIT_ADDR | DW_IC_DEFAULT_FUNCTIONALITY;
--
-- dev->master_cfg = DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
-- DW_IC_CON_RESTART_EN;
--
-- dev->mode = DW_IC_MASTER;
--
-- switch (t->bus_freq_hz) {
-- case I2C_MAX_STANDARD_MODE_FREQ:
-- dev->master_cfg |= DW_IC_CON_SPEED_STD;
-- break;
-- case I2C_MAX_HIGH_SPEED_MODE_FREQ:
-- dev->master_cfg |= DW_IC_CON_SPEED_HIGH;
-- break;
-- default:
-- dev->master_cfg |= DW_IC_CON_SPEED_FAST;
-- }
--}
--
--static void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
--{
-- dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY;
--
-- dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
-- DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED;
--
-- dev->mode = DW_IC_SLAVE;
--}
--
- static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
- {
- pm_runtime_disable(dev->dev);
-@@ -322,10 +289,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
- if (ret)
- goto exit_reset;
-
-- if (i2c_detect_slave_mode(&pdev->dev))
-- i2c_dw_configure_slave(dev);
-- else
-- i2c_dw_configure_master(dev);
-+ i2c_dw_configure(dev);
-
- /* Optional interface clock */
- dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk");
-diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c
-index 0fc3aa31d46aa..52a0f118917e1 100644
---- a/drivers/i2c/busses/i2c-designware-slave.c
-+++ b/drivers/i2c/busses/i2c-designware-slave.c
-@@ -241,6 +241,17 @@ static const struct i2c_algorithm i2c_dw_algo = {
- .unreg_slave = i2c_dw_unreg_slave,
- };
-
-+void i2c_dw_configure_slave(struct dw_i2c_dev *dev)
-+{
-+ dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY;
-+
-+ dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL |
-+ DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED;
-+
-+ dev->mode = DW_IC_SLAVE;
-+}
-+EXPORT_SYMBOL_GPL(i2c_dw_configure_slave);
-+
- int i2c_dw_probe_slave(struct dw_i2c_dev *dev)
- {
- struct i2c_adapter *adap = &dev->adapter;
---
-2.43.0
-
+++ /dev/null
-From 2b5a3c53e82a21b67aa5ae5a837043fc795b125e Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 24 Mar 2020 14:32:16 +0200
-Subject: i2c: drivers: Use generic definitions for bus frequencies
-
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-
-[ Upstream commit 90224e6468e15d5eb22a10ae1849cf8ca2e7360a ]
-
-Since we have generic definitions for bus frequencies, let's use them.
-
-Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
-Acked-by: Robert Richter <rrichter@marvell.com>
-Reviewed-by: Thor Thayer <thor.thayer@linux.intel.com>
-Acked-by: Elie Morisse <syniurge@gmail.com>
-Acked-by: Nehal Shah <nehal-bakulchandra.shah@amd.com>
-Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
-Acked-by: Scott Branden <scott.branden@broadcom.com>
-Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
-Acked-by: Baruch Siach <baruch@tkos.co.il>
-Reviewed-by: Guenter Roeck <linux@roeck-us.net>
-Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
-Acked-by: Vladimir Zapolskiy <vz@mleia.com>
-Acked-by: Gregory CLEMENT <gregory.clement@bootlin.com>
-Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
-Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
-Reviewed-by: Chris Brandt <chris.brandt@renesas.com>
-Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
-Reviewed-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
-Acked-by: Patrice Chotard <patrice.chotard@st.com>
-Acked-by: Ard Biesheuvel <ardb@kernel.org>
-Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
-Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-Stable-dep-of: cbf3fb5b29e9 ("i2c: designware: Fix the functionality flags of the slave-only interface")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/i2c/busses/i2c-altera.c | 6 ++--
- drivers/i2c/busses/i2c-amd-mp2-plat.c | 27 +++++++++------
- drivers/i2c/busses/i2c-aspeed.c | 2 +-
- drivers/i2c/busses/i2c-axxia.c | 4 +--
- drivers/i2c/busses/i2c-bcm-iproc.c | 14 ++++----
- drivers/i2c/busses/i2c-bcm-kona.c | 8 ++---
- drivers/i2c/busses/i2c-bcm2835.c | 2 +-
- drivers/i2c/busses/i2c-cadence.c | 7 ++--
- drivers/i2c/busses/i2c-designware-platdrv.c | 37 ++++++++++++---------
- drivers/i2c/busses/i2c-digicolor.c | 3 +-
- drivers/i2c/busses/i2c-diolan-u2c.c | 12 +++----
- drivers/i2c/busses/i2c-efm32.c | 2 +-
- drivers/i2c/busses/i2c-exynos5.c | 18 ++++------
- drivers/i2c/busses/i2c-hix5hd2.c | 10 +++---
- drivers/i2c/busses/i2c-img-scb.c | 4 +--
- drivers/i2c/busses/i2c-imx-lpi2c.c | 16 +++------
- drivers/i2c/busses/i2c-imx.c | 5 +--
- drivers/i2c/busses/i2c-lpc2k.c | 6 ++--
- drivers/i2c/busses/i2c-mt65xx.c | 21 +++++-------
- drivers/i2c/busses/i2c-mt7621.c | 2 +-
- drivers/i2c/busses/i2c-mv64xxx.c | 6 ++--
- drivers/i2c/busses/i2c-mxs.c | 4 +--
- drivers/i2c/busses/i2c-nomadik.c | 8 ++---
- drivers/i2c/busses/i2c-omap.c | 2 +-
- drivers/i2c/busses/i2c-owl.c | 9 ++---
- drivers/i2c/busses/i2c-qup.c | 11 ++----
- drivers/i2c/busses/i2c-riic.c | 6 ++--
- drivers/i2c/busses/i2c-rk3x.c | 12 +++----
- drivers/i2c/busses/i2c-s3c2410.c | 4 +--
- drivers/i2c/busses/i2c-sh_mobile.c | 9 ++---
- drivers/i2c/busses/i2c-sirf.c | 3 +-
- drivers/i2c/busses/i2c-sprd.c | 9 ++---
- drivers/i2c/busses/i2c-st.c | 6 ++--
- drivers/i2c/busses/i2c-stm32f4.c | 10 +++---
- drivers/i2c/busses/i2c-stu300.c | 6 ++--
- drivers/i2c/busses/i2c-sun6i-p2wi.c | 2 +-
- drivers/i2c/busses/i2c-synquacer.c | 6 ++--
- drivers/i2c/busses/i2c-tegra.c | 18 ++++------
- drivers/i2c/busses/i2c-thunderx-pcidrv.c | 2 +-
- drivers/i2c/busses/i2c-uniphier-f.c | 6 ++--
- drivers/i2c/busses/i2c-uniphier.c | 7 ++--
- drivers/i2c/busses/i2c-wmt.c | 2 +-
- drivers/i2c/busses/i2c-xlp9xx.c | 8 ++---
- drivers/i2c/busses/i2c-xlr.c | 2 +-
- 44 files changed, 165 insertions(+), 199 deletions(-)
-
-diff --git a/drivers/i2c/busses/i2c-altera.c b/drivers/i2c/busses/i2c-altera.c
-index a600424313701..16ddc26c00e65 100644
---- a/drivers/i2c/busses/i2c-altera.c
-+++ b/drivers/i2c/busses/i2c-altera.c
-@@ -149,7 +149,7 @@ static void altr_i2c_init(struct altr_i2c_dev *idev)
- (ALTR_I2C_THRESHOLD << ALTR_I2C_CTRL_TCT_SHFT);
- u32 t_high, t_low;
-
-- if (idev->bus_clk_rate <= 100000) {
-+ if (idev->bus_clk_rate <= I2C_MAX_STANDARD_MODE_FREQ) {
- tmp &= ~ALTR_I2C_CTRL_BSPEED;
- /* Standard mode SCL 50/50 */
- t_high = divisor * 1 / 2;
-@@ -430,10 +430,10 @@ static int altr_i2c_probe(struct platform_device *pdev)
- &idev->bus_clk_rate);
- if (ret) {
- dev_err(&pdev->dev, "Default to 100kHz\n");
-- idev->bus_clk_rate = 100000; /* default clock rate */
-+ idev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; /* default clock rate */
- }
-
-- if (idev->bus_clk_rate > 400000) {
-+ if (idev->bus_clk_rate > I2C_MAX_FAST_MODE_FREQ) {
- dev_err(&pdev->dev, "invalid clock-frequency %d\n",
- idev->bus_clk_rate);
- return -EINVAL;
-diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c
-index f5b3f00c6559f..17df9e8845b67 100644
---- a/drivers/i2c/busses/i2c-amd-mp2-plat.c
-+++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c
-@@ -201,32 +201,37 @@ static int i2c_amd_resume(struct amd_i2c_common *i2c_common)
- }
- #endif
-
-+static const u32 supported_speeds[] = {
-+ I2C_MAX_HIGH_SPEED_MODE_FREQ,
-+ I2C_MAX_TURBO_MODE_FREQ,
-+ I2C_MAX_FAST_MODE_PLUS_FREQ,
-+ I2C_MAX_FAST_MODE_FREQ,
-+ I2C_MAX_STANDARD_MODE_FREQ,
-+};
-+
- static enum speed_enum i2c_amd_get_bus_speed(struct platform_device *pdev)
- {
- u32 acpi_speed;
- int i;
-- static const u32 supported_speeds[] = {
-- 0, 100000, 400000, 1000000, 1400000, 3400000
-- };
-
- acpi_speed = i2c_acpi_find_bus_speed(&pdev->dev);
- /* round down to the lowest standard speed */
-- for (i = 1; i < ARRAY_SIZE(supported_speeds); i++) {
-- if (acpi_speed < supported_speeds[i])
-+ for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
-+ if (acpi_speed >= supported_speeds[i])
- break;
- }
-- acpi_speed = supported_speeds[i - 1];
-+ acpi_speed = i < ARRAY_SIZE(supported_speeds) ? supported_speeds[i] : 0;
-
- switch (acpi_speed) {
-- case 100000:
-+ case I2C_MAX_STANDARD_MODE_FREQ:
- return speed100k;
-- case 400000:
-+ case I2C_MAX_FAST_MODE_FREQ:
- return speed400k;
-- case 1000000:
-+ case I2C_MAX_FAST_MODE_PLUS_FREQ:
- return speed1000k;
-- case 1400000:
-+ case I2C_MAX_TURBO_MODE_FREQ:
- return speed1400k;
-- case 3400000:
-+ case I2C_MAX_HIGH_SPEED_MODE_FREQ:
- return speed3400k;
- default:
- return speed400k;
-diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
-index 3f0b072a4cc84..1c0ec6924aa1d 100644
---- a/drivers/i2c/busses/i2c-aspeed.c
-+++ b/drivers/i2c/busses/i2c-aspeed.c
-@@ -1018,7 +1018,7 @@ static int aspeed_i2c_probe_bus(struct platform_device *pdev)
- if (ret < 0) {
- dev_err(&pdev->dev,
- "Could not read bus-frequency property\n");
-- bus->bus_frequency = 100000;
-+ bus->bus_frequency = I2C_MAX_STANDARD_MODE_FREQ;
- }
-
- match = of_match_node(aspeed_i2c_bus_of_table, pdev->dev.of_node);
-diff --git a/drivers/i2c/busses/i2c-axxia.c b/drivers/i2c/busses/i2c-axxia.c
-index 0214daa913ff1..be3681d08a8da 100644
---- a/drivers/i2c/busses/i2c-axxia.c
-+++ b/drivers/i2c/busses/i2c-axxia.c
-@@ -199,7 +199,7 @@ static int axxia_i2c_init(struct axxia_i2c_dev *idev)
- /* Enable Master Mode */
- writel(0x1, idev->base + GLOBAL_CONTROL);
-
-- if (idev->bus_clk_rate <= 100000) {
-+ if (idev->bus_clk_rate <= I2C_MAX_STANDARD_MODE_FREQ) {
- /* Standard mode SCL 50/50, tSU:DAT = 250 ns */
- t_high = divisor * 1 / 2;
- t_low = divisor * 1 / 2;
-@@ -765,7 +765,7 @@ static int axxia_i2c_probe(struct platform_device *pdev)
-
- of_property_read_u32(np, "clock-frequency", &idev->bus_clk_rate);
- if (idev->bus_clk_rate == 0)
-- idev->bus_clk_rate = 100000; /* default clock rate */
-+ idev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; /* default clock rate */
-
- ret = clk_prepare_enable(idev->i2c_clk);
- if (ret) {
-diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c
-index cae34c55ae08b..d66df7f9cf3a0 100644
---- a/drivers/i2c/busses/i2c-bcm-iproc.c
-+++ b/drivers/i2c/busses/i2c-bcm-iproc.c
-@@ -952,25 +952,25 @@ static int bcm_iproc_i2c_cfg_speed(struct bcm_iproc_i2c_dev *iproc_i2c)
- if (ret < 0) {
- dev_info(iproc_i2c->device,
- "unable to interpret clock-frequency DT property\n");
-- bus_speed = 100000;
-+ bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
- }
-
-- if (bus_speed < 100000) {
-+ if (bus_speed < I2C_MAX_STANDARD_MODE_FREQ) {
- dev_err(iproc_i2c->device, "%d Hz bus speed not supported\n",
- bus_speed);
- dev_err(iproc_i2c->device,
- "valid speeds are 100khz and 400khz\n");
- return -EINVAL;
-- } else if (bus_speed < 400000) {
-- bus_speed = 100000;
-+ } else if (bus_speed < I2C_MAX_FAST_MODE_FREQ) {
-+ bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
- } else {
-- bus_speed = 400000;
-+ bus_speed = I2C_MAX_FAST_MODE_FREQ;
- }
-
- iproc_i2c->bus_speed = bus_speed;
- val = iproc_i2c_rd_reg(iproc_i2c, TIM_CFG_OFFSET);
- val &= ~BIT(TIM_CFG_MODE_400_SHIFT);
-- val |= (bus_speed == 400000) << TIM_CFG_MODE_400_SHIFT;
-+ val |= (bus_speed == I2C_MAX_FAST_MODE_FREQ) << TIM_CFG_MODE_400_SHIFT;
- iproc_i2c_wr_reg(iproc_i2c, TIM_CFG_OFFSET, val);
-
- dev_info(iproc_i2c->device, "bus set to %u Hz\n", bus_speed);
-@@ -1123,7 +1123,7 @@ static int bcm_iproc_i2c_resume(struct device *dev)
- /* configure to the desired bus speed */
- val = iproc_i2c_rd_reg(iproc_i2c, TIM_CFG_OFFSET);
- val &= ~BIT(TIM_CFG_MODE_400_SHIFT);
-- val |= (iproc_i2c->bus_speed == 400000) << TIM_CFG_MODE_400_SHIFT;
-+ val |= (iproc_i2c->bus_speed == I2C_MAX_FAST_MODE_FREQ) << TIM_CFG_MODE_400_SHIFT;
- iproc_i2c_wr_reg(iproc_i2c, TIM_CFG_OFFSET, val);
-
- bcm_iproc_i2c_enable_disable(iproc_i2c, true);
-diff --git a/drivers/i2c/busses/i2c-bcm-kona.c b/drivers/i2c/busses/i2c-bcm-kona.c
-index 4e489a9d16fb3..572aebbb254e7 100644
---- a/drivers/i2c/busses/i2c-bcm-kona.c
-+++ b/drivers/i2c/busses/i2c-bcm-kona.c
-@@ -722,16 +722,16 @@ static int bcm_kona_i2c_assign_bus_speed(struct bcm_kona_i2c_dev *dev)
- }
-
- switch (bus_speed) {
-- case 100000:
-+ case I2C_MAX_STANDARD_MODE_FREQ:
- dev->std_cfg = &std_cfg_table[BCM_SPD_100K];
- break;
-- case 400000:
-+ case I2C_MAX_FAST_MODE_FREQ:
- dev->std_cfg = &std_cfg_table[BCM_SPD_400K];
- break;
-- case 1000000:
-+ case I2C_MAX_FAST_MODE_PLUS_FREQ:
- dev->std_cfg = &std_cfg_table[BCM_SPD_1MHZ];
- break;
-- case 3400000:
-+ case I2C_MAX_HIGH_SPEED_MODE_FREQ:
- /* Send mastercode at 100k */
- dev->std_cfg = &std_cfg_table[BCM_SPD_100K];
- dev->hs_cfg = &hs_cfg_table[BCM_SPD_3P4MHZ];
-diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c
-index c265fe4621621..1e23838fb4375 100644
---- a/drivers/i2c/busses/i2c-bcm2835.c
-+++ b/drivers/i2c/busses/i2c-bcm2835.c
-@@ -444,7 +444,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
- if (ret < 0) {
- dev_warn(&pdev->dev,
- "Could not read clock-frequency property\n");
-- bus_clk_rate = 100000;
-+ bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ;
- }
-
- ret = clk_set_rate_exclusive(i2c_dev->bus_clk, bus_clk_rate);
-diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
-index 72699fdd5d113..a8d84b968da6f 100644
---- a/drivers/i2c/busses/i2c-cadence.c
-+++ b/drivers/i2c/busses/i2c-cadence.c
-@@ -104,9 +104,6 @@
-
- #define DRIVER_NAME "cdns-i2c"
-
--#define CDNS_I2C_SPEED_MAX 400000
--#define CDNS_I2C_SPEED_DEFAULT 100000
--
- #define CDNS_I2C_DIVA_MAX 4
- #define CDNS_I2C_DIVB_MAX 64
-
-@@ -934,8 +931,8 @@ static int cdns_i2c_probe(struct platform_device *pdev)
-
- ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &id->i2c_clk);
-- if (ret || (id->i2c_clk > CDNS_I2C_SPEED_MAX))
-- id->i2c_clk = CDNS_I2C_SPEED_DEFAULT;
-+ if (ret || (id->i2c_clk > I2C_MAX_FAST_MODE_FREQ))
-+ id->i2c_clk = I2C_MAX_STANDARD_MODE_FREQ;
-
- cdns_i2c_writereg(CDNS_I2C_CR_ACK_EN | CDNS_I2C_CR_NEA | CDNS_I2C_CR_MS,
- CDNS_I2C_CR_OFFSET);
-diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
-index 3a094ce343f43..50a9e29df9152 100644
---- a/drivers/i2c/busses/i2c-designware-platdrv.c
-+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
-@@ -99,16 +99,16 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev)
- dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, &fs_ht);
-
- switch (t->bus_freq_hz) {
-- case 100000:
-+ case I2C_MAX_STANDARD_MODE_FREQ:
- dev->sda_hold_time = ss_ht;
- break;
-- case 1000000:
-+ case I2C_MAX_FAST_MODE_PLUS_FREQ:
- dev->sda_hold_time = fp_ht;
- break;
-- case 3400000:
-+ case I2C_MAX_HIGH_SPEED_MODE_FREQ:
- dev->sda_hold_time = hs_ht;
- break;
-- case 400000:
-+ case I2C_MAX_FAST_MODE_FREQ:
- default:
- dev->sda_hold_time = fs_ht;
- break;
-@@ -197,10 +197,10 @@ static void i2c_dw_configure_master(struct dw_i2c_dev *dev)
- dev->mode = DW_IC_MASTER;
-
- switch (t->bus_freq_hz) {
-- case 100000:
-+ case I2C_MAX_STANDARD_MODE_FREQ:
- dev->master_cfg |= DW_IC_CON_SPEED_STD;
- break;
-- case 3400000:
-+ case I2C_MAX_HIGH_SPEED_MODE_FREQ:
- dev->master_cfg |= DW_IC_CON_SPEED_HIGH;
- break;
- default:
-@@ -226,6 +226,13 @@ static void dw_i2c_plat_pm_cleanup(struct dw_i2c_dev *dev)
- pm_runtime_put_noidle(dev->dev);
- }
-
-+static const u32 supported_speeds[] = {
-+ I2C_MAX_HIGH_SPEED_MODE_FREQ,
-+ I2C_MAX_FAST_MODE_PLUS_FREQ,
-+ I2C_MAX_FAST_MODE_FREQ,
-+ I2C_MAX_STANDARD_MODE_FREQ,
-+};
-+
- static int dw_i2c_plat_probe(struct platform_device *pdev)
- {
- struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
-@@ -235,9 +242,6 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
- u32 acpi_speed;
- struct resource *mem;
- int i, irq, ret;
-- static const int supported_speeds[] = {
-- 0, 100000, 400000, 1000000, 3400000
-- };
-
- irq = platform_get_irq(pdev, 0);
- if (irq < 0)
-@@ -273,11 +277,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
- * Some DSTDs use a non standard speed, round down to the lowest
- * standard speed.
- */
-- for (i = 1; i < ARRAY_SIZE(supported_speeds); i++) {
-- if (acpi_speed < supported_speeds[i])
-+ for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
-+ if (acpi_speed >= supported_speeds[i])
- break;
- }
-- acpi_speed = supported_speeds[i - 1];
-+ acpi_speed = i < ARRAY_SIZE(supported_speeds) ? supported_speeds[i] : 0;
-
- /*
- * Find bus speed from the "clock-frequency" device property, ACPI
-@@ -288,7 +292,7 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
- else if (acpi_speed || t->bus_freq_hz)
- t->bus_freq_hz = max(t->bus_freq_hz, acpi_speed);
- else
-- t->bus_freq_hz = 400000;
-+ t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
-
- dev->flags |= (uintptr_t)device_get_match_data(&pdev->dev);
-
-@@ -302,8 +306,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
- * Only standard mode at 100kHz, fast mode at 400kHz,
- * fast mode plus at 1MHz and high speed mode at 3.4MHz are supported.
- */
-- if (t->bus_freq_hz != 100000 && t->bus_freq_hz != 400000 &&
-- t->bus_freq_hz != 1000000 && t->bus_freq_hz != 3400000) {
-+ for (i = 0; i < ARRAY_SIZE(supported_speeds); i++) {
-+ if (t->bus_freq_hz == supported_speeds[i])
-+ break;
-+ }
-+ if (i == ARRAY_SIZE(supported_speeds)) {
- dev_err(&pdev->dev,
- "%d Hz is unsupported, only 100kHz, 400kHz, 1MHz and 3.4MHz are supported\n",
- t->bus_freq_hz);
-diff --git a/drivers/i2c/busses/i2c-digicolor.c b/drivers/i2c/busses/i2c-digicolor.c
-index 3adf72540db13..056a5c4f0833c 100644
---- a/drivers/i2c/busses/i2c-digicolor.c
-+++ b/drivers/i2c/busses/i2c-digicolor.c
-@@ -18,7 +18,6 @@
- #include <linux/of.h>
- #include <linux/platform_device.h>
-
--#define DEFAULT_FREQ 100000
- #define TIMEOUT_MS 100
-
- #define II_CONTROL 0x0
-@@ -300,7 +299,7 @@ static int dc_i2c_probe(struct platform_device *pdev)
-
- if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &i2c->frequency))
-- i2c->frequency = DEFAULT_FREQ;
-+ i2c->frequency = I2C_MAX_STANDARD_MODE_FREQ;
-
- i2c->dev = &pdev->dev;
- platform_set_drvdata(pdev, i2c);
-diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
-index 382f105e0fe3b..b48b7888936fe 100644
---- a/drivers/i2c/busses/i2c-diolan-u2c.c
-+++ b/drivers/i2c/busses/i2c-diolan-u2c.c
-@@ -64,8 +64,6 @@
- #define U2C_I2C_SPEED_2KHZ 242 /* 2 kHz, minimum speed */
- #define U2C_I2C_SPEED(f) ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1)
-
--#define U2C_I2C_FREQ_FAST 400000
--#define U2C_I2C_FREQ_STD 100000
- #define U2C_I2C_FREQ(s) (1000000 / (2 * (s - 1) + 10))
-
- #define DIOLAN_USB_TIMEOUT 100 /* in ms */
-@@ -87,7 +85,7 @@ struct i2c_diolan_u2c {
- int ocount; /* Number of enqueued messages */
- };
-
--static uint frequency = U2C_I2C_FREQ_STD; /* I2C clock frequency in Hz */
-+static uint frequency = I2C_MAX_STANDARD_MODE_FREQ; /* I2C clock frequency in Hz */
-
- module_param(frequency, uint, S_IRUGO | S_IWUSR);
- MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
-@@ -299,12 +297,12 @@ static int diolan_init(struct i2c_diolan_u2c *dev)
- {
- int speed, ret;
-
-- if (frequency >= 200000) {
-+ if (frequency >= 2 * I2C_MAX_STANDARD_MODE_FREQ) {
- speed = U2C_I2C_SPEED_FAST;
-- frequency = U2C_I2C_FREQ_FAST;
-- } else if (frequency >= 100000 || frequency == 0) {
-+ frequency = I2C_MAX_FAST_MODE_FREQ;
-+ } else if (frequency >= I2C_MAX_STANDARD_MODE_FREQ || frequency == 0) {
- speed = U2C_I2C_SPEED_STD;
-- frequency = U2C_I2C_FREQ_STD;
-+ frequency = I2C_MAX_STANDARD_MODE_FREQ;
- } else {
- speed = U2C_I2C_SPEED(frequency);
- if (speed > U2C_I2C_SPEED_2KHZ)
-diff --git a/drivers/i2c/busses/i2c-efm32.c b/drivers/i2c/busses/i2c-efm32.c
-index a8c6323e7f44c..18cca8f56da87 100644
---- a/drivers/i2c/busses/i2c-efm32.c
-+++ b/drivers/i2c/busses/i2c-efm32.c
-@@ -388,7 +388,7 @@ static int efm32_i2c_probe(struct platform_device *pdev)
- if (!ret) {
- dev_dbg(&pdev->dev, "using frequency %u\n", frequency);
- } else {
-- frequency = 100000;
-+ frequency = I2C_MAX_STANDARD_MODE_FREQ;
- dev_info(&pdev->dev, "defaulting to 100 kHz\n");
- }
- ddata->frequency = frequency;
-diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
-index e7514c16b756c..527030953ba13 100644
---- a/drivers/i2c/busses/i2c-exynos5.c
-+++ b/drivers/i2c/busses/i2c-exynos5.c
-@@ -164,13 +164,6 @@
- #define HSI2C_MASTER_ID(x) ((x & 0xff) << 24)
- #define MASTER_ID(x) ((x & 0x7) + 0x08)
-
--/*
-- * Controller operating frequency, timing values for operation
-- * are calculated against this frequency
-- */
--#define HSI2C_HS_TX_CLOCK 1000000
--#define HSI2C_FS_TX_CLOCK 100000
--
- #define EXYNOS5_I2C_TIMEOUT (msecs_to_jiffies(100))
-
- enum i2c_type_exynos {
-@@ -264,6 +257,9 @@ static void exynos5_i2c_clr_pend_irq(struct exynos5_i2c *i2c)
- * exynos5_i2c_set_timing: updates the registers with appropriate
- * timing values calculated
- *
-+ * Timing values for operation are calculated against either 100kHz
-+ * or 1MHz controller operating frequency.
-+ *
- * Returns 0 on success, -EINVAL if the cycle length cannot
- * be calculated.
- */
-@@ -281,7 +277,7 @@ static int exynos5_i2c_set_timing(struct exynos5_i2c *i2c, bool hs_timings)
- unsigned int t_ftl_cycle;
- unsigned int clkin = clk_get_rate(i2c->clk);
- unsigned int op_clk = hs_timings ? i2c->op_clock :
-- (i2c->op_clock >= HSI2C_HS_TX_CLOCK) ? HSI2C_FS_TX_CLOCK :
-+ (i2c->op_clock >= I2C_MAX_FAST_MODE_PLUS_FREQ) ? I2C_MAX_STANDARD_MODE_FREQ :
- i2c->op_clock;
- int div, clk_cycle, temp;
-
-@@ -353,7 +349,7 @@ static int exynos5_hsi2c_clock_setup(struct exynos5_i2c *i2c)
- /* always set Fast Speed timings */
- int ret = exynos5_i2c_set_timing(i2c, false);
-
-- if (ret < 0 || i2c->op_clock < HSI2C_HS_TX_CLOCK)
-+ if (ret < 0 || i2c->op_clock < I2C_MAX_FAST_MODE_PLUS_FREQ)
- return ret;
-
- return exynos5_i2c_set_timing(i2c, true);
-@@ -376,7 +372,7 @@ static void exynos5_i2c_init(struct exynos5_i2c *i2c)
- i2c->regs + HSI2C_CTL);
- writel(HSI2C_TRAILING_COUNT, i2c->regs + HSI2C_TRAILIG_CTL);
-
-- if (i2c->op_clock >= HSI2C_HS_TX_CLOCK) {
-+ if (i2c->op_clock >= I2C_MAX_FAST_MODE_PLUS_FREQ) {
- writel(HSI2C_MASTER_ID(MASTER_ID(i2c->adap.nr)),
- i2c->regs + HSI2C_ADDR);
- i2c_conf |= HSI2C_HS_MODE;
-@@ -748,7 +744,7 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
- return -ENOMEM;
-
- if (of_property_read_u32(np, "clock-frequency", &i2c->op_clock))
-- i2c->op_clock = HSI2C_FS_TX_CLOCK;
-+ i2c->op_clock = I2C_MAX_STANDARD_MODE_FREQ;
-
- strlcpy(i2c->adap.name, "exynos5-i2c", sizeof(i2c->adap.name));
- i2c->adap.owner = THIS_MODULE;
-diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
-index 224f830f77f9b..6610304b6dc61 100644
---- a/drivers/i2c/busses/i2c-hix5hd2.c
-+++ b/drivers/i2c/busses/i2c-hix5hd2.c
-@@ -68,8 +68,6 @@
- #define I2C_ARBITRATE_INTR BIT(1)
- #define I2C_OVER_INTR BIT(0)
-
--#define HIX5I2C_MAX_FREQ 400000 /* 400k */
--
- enum hix5hd2_i2c_state {
- HIX5I2C_STAT_RW_ERR = -1,
- HIX5I2C_STAT_INIT,
-@@ -400,12 +398,12 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
-
- if (of_property_read_u32(np, "clock-frequency", &freq)) {
- /* use 100k as default value */
-- priv->freq = 100000;
-+ priv->freq = I2C_MAX_STANDARD_MODE_FREQ;
- } else {
-- if (freq > HIX5I2C_MAX_FREQ) {
-- priv->freq = HIX5I2C_MAX_FREQ;
-+ if (freq > I2C_MAX_FAST_MODE_FREQ) {
-+ priv->freq = I2C_MAX_FAST_MODE_FREQ;
- dev_warn(priv->dev, "use max freq %d instead\n",
-- HIX5I2C_MAX_FREQ);
-+ I2C_MAX_FAST_MODE_FREQ);
- } else {
- priv->freq = freq;
- }
-diff --git a/drivers/i2c/busses/i2c-img-scb.c b/drivers/i2c/busses/i2c-img-scb.c
-index a1f8a9a91213a..cac941e377f30 100644
---- a/drivers/i2c/busses/i2c-img-scb.c
-+++ b/drivers/i2c/busses/i2c-img-scb.c
-@@ -304,7 +304,7 @@ static struct img_i2c_timings timings[] = {
- /* Standard mode */
- {
- .name = "standard",
-- .max_bitrate = 100000,
-+ .max_bitrate = I2C_MAX_STANDARD_MODE_FREQ,
- .tckh = 4000,
- .tckl = 4700,
- .tsdh = 4700,
-@@ -316,7 +316,7 @@ static struct img_i2c_timings timings[] = {
- /* Fast mode */
- {
- .name = "fast",
-- .max_bitrate = 400000,
-+ .max_bitrate = I2C_MAX_FAST_MODE_FREQ,
- .tckh = 600,
- .tckl = 1300,
- .tsdh = 600,
-diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
-index 89faef6f013b4..890cf04552c1e 100644
---- a/drivers/i2c/busses/i2c-imx-lpi2c.c
-+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
-@@ -75,12 +75,6 @@
- #define I2C_CLK_RATIO 2
- #define CHUNK_DATA 256
-
--#define LPI2C_DEFAULT_RATE 100000
--#define STARDARD_MAX_BITRATE 400000
--#define FAST_MAX_BITRATE 1000000
--#define FAST_PLUS_MAX_BITRATE 3400000
--#define HIGHSPEED_MAX_BITRATE 5000000
--
- #define I2C_PM_TIMEOUT 10 /* ms */
-
- enum lpi2c_imx_mode {
-@@ -152,13 +146,13 @@ static void lpi2c_imx_set_mode(struct lpi2c_imx_struct *lpi2c_imx)
- unsigned int bitrate = lpi2c_imx->bitrate;
- enum lpi2c_imx_mode mode;
-
-- if (bitrate < STARDARD_MAX_BITRATE)
-+ if (bitrate < I2C_MAX_FAST_MODE_FREQ)
- mode = STANDARD;
-- else if (bitrate < FAST_MAX_BITRATE)
-+ else if (bitrate < I2C_MAX_FAST_MODE_PLUS_FREQ)
- mode = FAST;
-- else if (bitrate < FAST_PLUS_MAX_BITRATE)
-+ else if (bitrate < I2C_MAX_HIGH_SPEED_MODE_FREQ)
- mode = FAST_PLUS;
-- else if (bitrate < HIGHSPEED_MAX_BITRATE)
-+ else if (bitrate < I2C_MAX_ULTRA_FAST_MODE_FREQ)
- mode = HS;
- else
- mode = ULTRA_FAST;
-@@ -584,7 +578,7 @@ static int lpi2c_imx_probe(struct platform_device *pdev)
- ret = of_property_read_u32(pdev->dev.of_node,
- "clock-frequency", &lpi2c_imx->bitrate);
- if (ret)
-- lpi2c_imx->bitrate = LPI2C_DEFAULT_RATE;
-+ lpi2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ;
-
- ret = devm_request_irq(&pdev->dev, irq, lpi2c_imx_isr, 0,
- pdev->name, lpi2c_imx);
-diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
-index 9d3f42fd63522..64aa886e05fa0 100644
---- a/drivers/i2c/busses/i2c-imx.c
-+++ b/drivers/i2c/busses/i2c-imx.c
-@@ -49,9 +49,6 @@
- /* This will be the driver name the kernel reports */
- #define DRIVER_NAME "imx-i2c"
-
--/* Default value */
--#define IMX_I2C_BIT_RATE 100000 /* 100kHz */
--
- /*
- * Enable DMA if transfer byte size is bigger than this threshold.
- * As the hardware request, it must bigger than 4 bytes.\
-@@ -1167,7 +1164,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
- }
-
- /* Set up clock divider */
-- i2c_imx->bitrate = IMX_I2C_BIT_RATE;
-+ i2c_imx->bitrate = I2C_MAX_STANDARD_MODE_FREQ;
- ret = of_property_read_u32(pdev->dev.of_node,
- "clock-frequency", &i2c_imx->bitrate);
- if (ret < 0 && pdata && pdata->bitrate)
-diff --git a/drivers/i2c/busses/i2c-lpc2k.c b/drivers/i2c/busses/i2c-lpc2k.c
-index deea18b14add5..13b0c12e2dbaf 100644
---- a/drivers/i2c/busses/i2c-lpc2k.c
-+++ b/drivers/i2c/busses/i2c-lpc2k.c
-@@ -396,7 +396,7 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
- ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &bus_clk_rate);
- if (ret)
-- bus_clk_rate = 100000; /* 100 kHz default clock rate */
-+ bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ;
-
- clkrate = clk_get_rate(i2c->clk);
- if (clkrate == 0) {
-@@ -407,9 +407,9 @@ static int i2c_lpc2k_probe(struct platform_device *pdev)
-
- /* Setup I2C dividers to generate clock with proper duty cycle */
- clkrate = clkrate / bus_clk_rate;
-- if (bus_clk_rate <= 100000)
-+ if (bus_clk_rate <= I2C_MAX_STANDARD_MODE_FREQ)
- scl_high = (clkrate * I2C_STD_MODE_DUTY) / 100;
-- else if (bus_clk_rate <= 400000)
-+ else if (bus_clk_rate <= I2C_MAX_FAST_MODE_FREQ)
- scl_high = (clkrate * I2C_FAST_MODE_DUTY) / 100;
- else
- scl_high = (clkrate * I2C_FAST_MODE_PLUS_DUTY) / 100;
-diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
-index 5587e7c549c4f..6ff2137c9a0be 100644
---- a/drivers/i2c/busses/i2c-mt65xx.c
-+++ b/drivers/i2c/busses/i2c-mt65xx.c
-@@ -56,9 +56,6 @@
- #define I2C_DMA_4G_MODE 0x0001
-
- #define I2C_DEFAULT_CLK_DIV 5
--#define I2C_DEFAULT_SPEED 100000 /* hz */
--#define MAX_FS_MODE_SPEED 400000
--#define MAX_HS_MODE_SPEED 3400000
- #define MAX_SAMPLE_CNT_DIV 8
- #define MAX_STEP_CNT_DIV 64
- #define MAX_HS_STEP_CNT_DIV 8
-@@ -450,10 +447,10 @@ static int mtk_i2c_calculate_speed(struct mtk_i2c *i2c, unsigned int clk_src,
- unsigned int best_mul;
- unsigned int cnt_mul;
-
-- if (target_speed > MAX_HS_MODE_SPEED)
-- target_speed = MAX_HS_MODE_SPEED;
-+ if (target_speed > I2C_MAX_FAST_MODE_PLUS_FREQ)
-+ target_speed = I2C_MAX_FAST_MODE_PLUS_FREQ;
-
-- if (target_speed > MAX_FS_MODE_SPEED)
-+ if (target_speed > I2C_MAX_FAST_MODE_FREQ)
- max_step_cnt = MAX_HS_STEP_CNT_DIV;
- else
- max_step_cnt = MAX_STEP_CNT_DIV;
-@@ -514,9 +511,9 @@ static int mtk_i2c_set_speed(struct mtk_i2c *i2c, unsigned int parent_clk)
- clk_src = parent_clk / i2c->clk_src_div;
- target_speed = i2c->speed_hz;
-
-- if (target_speed > MAX_FS_MODE_SPEED) {
-+ if (target_speed > I2C_MAX_FAST_MODE_FREQ) {
- /* Set master code speed register */
-- ret = mtk_i2c_calculate_speed(i2c, clk_src, MAX_FS_MODE_SPEED,
-+ ret = mtk_i2c_calculate_speed(i2c, clk_src, I2C_MAX_FAST_MODE_FREQ,
- &l_step_cnt, &l_sample_cnt);
- if (ret < 0)
- return ret;
-@@ -581,7 +578,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
-
- control_reg = mtk_i2c_readw(i2c, OFFSET_CONTROL) &
- ~(I2C_CONTROL_DIR_CHANGE | I2C_CONTROL_RS);
-- if ((i2c->speed_hz > MAX_FS_MODE_SPEED) || (left_num >= 1))
-+ if ((i2c->speed_hz > I2C_MAX_FAST_MODE_FREQ) || (left_num >= 1))
- control_reg |= I2C_CONTROL_RS;
-
- if (i2c->op == I2C_MASTER_WRRD)
-@@ -590,7 +587,7 @@ static int mtk_i2c_do_transfer(struct mtk_i2c *i2c, struct i2c_msg *msgs,
- mtk_i2c_writew(i2c, control_reg, OFFSET_CONTROL);
-
- /* set start condition */
-- if (i2c->speed_hz <= I2C_DEFAULT_SPEED)
-+ if (i2c->speed_hz <= I2C_MAX_STANDARD_MODE_FREQ)
- mtk_i2c_writew(i2c, I2C_ST_START_CON, OFFSET_EXT_CONF);
- else
- mtk_i2c_writew(i2c, I2C_FS_START_CON, OFFSET_EXT_CONF);
-@@ -798,7 +795,7 @@ static int mtk_i2c_transfer(struct i2c_adapter *adap,
- }
- }
-
-- if (i2c->auto_restart && num >= 2 && i2c->speed_hz > MAX_FS_MODE_SPEED)
-+ if (i2c->auto_restart && num >= 2 && i2c->speed_hz > I2C_MAX_FAST_MODE_FREQ)
- /* ignore the first restart irq after the master code,
- * otherwise the first transfer will be discarded.
- */
-@@ -893,7 +890,7 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c)
-
- ret = of_property_read_u32(np, "clock-frequency", &i2c->speed_hz);
- if (ret < 0)
-- i2c->speed_hz = I2C_DEFAULT_SPEED;
-+ i2c->speed_hz = I2C_MAX_STANDARD_MODE_FREQ;
-
- ret = of_property_read_u32(np, "clock-div", &i2c->clk_src_div);
- if (ret < 0)
-diff --git a/drivers/i2c/busses/i2c-mt7621.c b/drivers/i2c/busses/i2c-mt7621.c
-index 65e72101b393b..901f0fb04fee4 100644
---- a/drivers/i2c/busses/i2c-mt7621.c
-+++ b/drivers/i2c/busses/i2c-mt7621.c
-@@ -300,7 +300,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
-
- if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &i2c->bus_freq))
-- i2c->bus_freq = 100000;
-+ i2c->bus_freq = I2C_MAX_STANDARD_MODE_FREQ;
-
- if (i2c->bus_freq == 0) {
- dev_warn(i2c->dev, "clock-frequency 0 not supported\n");
-diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
-index a5a95ea5b81a7..e65c51e508db7 100644
---- a/drivers/i2c/busses/i2c-mv64xxx.c
-+++ b/drivers/i2c/busses/i2c-mv64xxx.c
-@@ -810,7 +810,7 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
- tclk = clk_get_rate(drv_data->clk);
-
- if (of_property_read_u32(np, "clock-frequency", &bus_freq))
-- bus_freq = 100000; /* 100kHz by default */
-+ bus_freq = I2C_MAX_STANDARD_MODE_FREQ; /* 100kHz by default */
-
- if (of_device_is_compatible(np, "allwinner,sun4i-a10-i2c") ||
- of_device_is_compatible(np, "allwinner,sun6i-a31-i2c"))
-@@ -846,14 +846,14 @@ mv64xxx_of_config(struct mv64xxx_i2c_data *drv_data,
- if (of_device_is_compatible(np, "marvell,mv78230-i2c")) {
- drv_data->offload_enabled = true;
- /* The delay is only needed in standard mode (100kHz) */
-- if (bus_freq <= 100000)
-+ if (bus_freq <= I2C_MAX_STANDARD_MODE_FREQ)
- drv_data->errata_delay = true;
- }
-
- if (of_device_is_compatible(np, "marvell,mv78230-a0-i2c")) {
- drv_data->offload_enabled = false;
- /* The delay is only needed in standard mode (100kHz) */
-- if (bus_freq <= 100000)
-+ if (bus_freq <= I2C_MAX_STANDARD_MODE_FREQ)
- drv_data->errata_delay = true;
- }
-
-diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
-index 081a1169ecea3..9473abb52e730 100644
---- a/drivers/i2c/busses/i2c-mxs.c
-+++ b/drivers/i2c/busses/i2c-mxs.c
-@@ -735,7 +735,7 @@ static void mxs_i2c_derive_timing(struct mxs_i2c_dev *i2c, uint32_t speed)
- * This is compensated for by subtracting the respective constants
- * from the values written to the timing registers.
- */
-- if (speed > 100000) {
-+ if (speed > I2C_MAX_STANDARD_MODE_FREQ) {
- /* fast mode */
- low_count = DIV_ROUND_CLOSEST(divider * 13, (13 + 6));
- high_count = DIV_ROUND_CLOSEST(divider * 6, (13 + 6));
-@@ -773,7 +773,7 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c)
- ret = of_property_read_u32(node, "clock-frequency", &speed);
- if (ret) {
- dev_warn(dev, "No I2C speed selected, using 100kHz\n");
-- speed = 100000;
-+ speed = I2C_MAX_STANDARD_MODE_FREQ;
- }
-
- mxs_i2c_derive_timing(i2c, speed);
-diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
-index 01a7d72e55111..e1e8d4ef9aa72 100644
---- a/drivers/i2c/busses/i2c-nomadik.c
-+++ b/drivers/i2c/busses/i2c-nomadik.c
-@@ -396,7 +396,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
- * 2 whereas it is 3 for fast and fastplus mode of
- * operation. TODO - high speed support.
- */
-- div = (dev->clk_freq > 100000) ? 3 : 2;
-+ div = (dev->clk_freq > I2C_MAX_STANDARD_MODE_FREQ) ? 3 : 2;
-
- /*
- * generate the mask for baud rate counters. The controller
-@@ -420,7 +420,7 @@ static void setup_i2c_controller(struct nmk_i2c_dev *dev)
- if (dev->sm > I2C_FREQ_MODE_FAST) {
- dev_err(&dev->adev->dev,
- "do not support this mode defaulting to std. mode\n");
-- brcr2 = i2c_clk/(100000 * 2) & 0xffff;
-+ brcr2 = i2c_clk / (I2C_MAX_STANDARD_MODE_FREQ * 2) & 0xffff;
- writel((brcr1 | brcr2), dev->virtbase + I2C_BRCR);
- writel(I2C_FREQ_MODE_STANDARD << 4,
- dev->virtbase + I2C_CR);
-@@ -949,10 +949,10 @@ static void nmk_i2c_of_probe(struct device_node *np,
- {
- /* Default to 100 kHz if no frequency is given in the node */
- if (of_property_read_u32(np, "clock-frequency", &nmk->clk_freq))
-- nmk->clk_freq = 100000;
-+ nmk->clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
-
- /* This driver only supports 'standard' and 'fast' modes of operation. */
-- if (nmk->clk_freq <= 100000)
-+ if (nmk->clk_freq <= I2C_MAX_STANDARD_MODE_FREQ)
- nmk->sm = I2C_FREQ_MODE_STANDARD;
- else
- nmk->sm = I2C_FREQ_MODE_FAST;
-diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
-index a788f2e706779..435652646842f 100644
---- a/drivers/i2c/busses/i2c-omap.c
-+++ b/drivers/i2c/busses/i2c-omap.c
-@@ -1382,7 +1382,7 @@ omap_i2c_probe(struct platform_device *pdev)
-
- match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev);
- if (match) {
-- u32 freq = 100000; /* default to 100000 Hz */
-+ u32 freq = I2C_MAX_STANDARD_MODE_FREQ;
-
- pdata = match->data;
- omap->flags = pdata->flags;
-diff --git a/drivers/i2c/busses/i2c-owl.c b/drivers/i2c/busses/i2c-owl.c
-index a567fd2b295e1..03631f34c0637 100644
---- a/drivers/i2c/busses/i2c-owl.c
-+++ b/drivers/i2c/busses/i2c-owl.c
-@@ -87,9 +87,6 @@
-
- #define OWL_I2C_MAX_RETRIES 50
-
--#define OWL_I2C_DEF_SPEED_HZ 100000
--#define OWL_I2C_MAX_SPEED_HZ 400000
--
- struct owl_i2c_dev {
- struct i2c_adapter adap;
- struct i2c_msg *msg;
-@@ -425,11 +422,11 @@ static int owl_i2c_probe(struct platform_device *pdev)
-
- if (of_property_read_u32(dev->of_node, "clock-frequency",
- &i2c_dev->bus_freq))
-- i2c_dev->bus_freq = OWL_I2C_DEF_SPEED_HZ;
-+ i2c_dev->bus_freq = I2C_MAX_STANDARD_MODE_FREQ;
-
- /* We support only frequencies of 100k and 400k for now */
-- if (i2c_dev->bus_freq != OWL_I2C_DEF_SPEED_HZ &&
-- i2c_dev->bus_freq != OWL_I2C_MAX_SPEED_HZ) {
-+ if (i2c_dev->bus_freq != I2C_MAX_STANDARD_MODE_FREQ &&
-+ i2c_dev->bus_freq != I2C_MAX_FAST_MODE_FREQ) {
- dev_err(dev, "invalid clock-frequency %d\n", i2c_dev->bus_freq);
- return -EINVAL;
- }
-diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
-index 3417f7dffa943..f2e8206e02e2a 100644
---- a/drivers/i2c/busses/i2c-qup.c
-+++ b/drivers/i2c/busses/i2c-qup.c
-@@ -136,13 +136,8 @@
- */
- #define TOUT_MIN 2
-
--/* I2C Frequency Modes */
--#define I2C_STANDARD_FREQ 100000
--#define I2C_FAST_MODE_FREQ 400000
--#define I2C_FAST_MODE_PLUS_FREQ 1000000
--
- /* Default values. Use these if FW query fails */
--#define DEFAULT_CLK_FREQ I2C_STANDARD_FREQ
-+#define DEFAULT_CLK_FREQ I2C_MAX_STANDARD_MODE_FREQ
- #define DEFAULT_SRC_CLK 20000000
-
- /*
-@@ -1757,7 +1752,7 @@ static int qup_i2c_probe(struct platform_device *pdev)
-
- nodma:
- /* We support frequencies up to FAST Mode Plus (1MHz) */
-- if (!clk_freq || clk_freq > I2C_FAST_MODE_PLUS_FREQ) {
-+ if (!clk_freq || clk_freq > I2C_MAX_FAST_MODE_PLUS_FREQ) {
- dev_err(qup->dev, "clock frequency not supported %d\n",
- clk_freq);
- return -EINVAL;
-@@ -1862,7 +1857,7 @@ static int qup_i2c_probe(struct platform_device *pdev)
- qup->in_fifo_sz = qup->in_blk_sz * (2 << size);
-
- hs_div = 3;
-- if (clk_freq <= I2C_STANDARD_FREQ) {
-+ if (clk_freq <= I2C_MAX_STANDARD_MODE_FREQ) {
- fs_div = ((src_clk_freq / clk_freq) / 2) - 3;
- qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff);
- } else {
-diff --git a/drivers/i2c/busses/i2c-riic.c b/drivers/i2c/busses/i2c-riic.c
-index 800414886f6b5..4eccc0f69861f 100644
---- a/drivers/i2c/busses/i2c-riic.c
-+++ b/drivers/i2c/busses/i2c-riic.c
-@@ -287,10 +287,10 @@ static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
-
- pm_runtime_get_sync(riic->adapter.dev.parent);
-
-- if (t->bus_freq_hz > 400000) {
-+ if (t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) {
- dev_err(&riic->adapter.dev,
-- "unsupported bus speed (%dHz). 400000 max\n",
-- t->bus_freq_hz);
-+ "unsupported bus speed (%dHz). %d max\n",
-+ t->bus_freq_hz, I2C_MAX_FAST_MODE_FREQ);
- ret = -EINVAL;
- goto out;
- }
-diff --git a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
-index 74dd378446c13..2b2071717535f 100644
---- a/drivers/i2c/busses/i2c-rk3x.c
-+++ b/drivers/i2c/busses/i2c-rk3x.c
-@@ -541,9 +541,9 @@ static irqreturn_t rk3x_i2c_irq(int irqno, void *dev_id)
- */
- static const struct i2c_spec_values *rk3x_i2c_get_spec(unsigned int speed)
- {
-- if (speed <= 100000)
-+ if (speed <= I2C_MAX_STANDARD_MODE_FREQ)
- return &standard_mode_spec;
-- else if (speed <= 400000)
-+ else if (speed <= I2C_MAX_FAST_MODE_FREQ)
- return &fast_mode_spec;
- else
- return &fast_mode_plus_spec;
-@@ -579,8 +579,8 @@ static int rk3x_i2c_v0_calc_timings(unsigned long clk_rate,
- int ret = 0;
-
- /* Only support standard-mode and fast-mode */
-- if (WARN_ON(t->bus_freq_hz > 400000))
-- t->bus_freq_hz = 400000;
-+ if (WARN_ON(t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ))
-+ t->bus_freq_hz = I2C_MAX_FAST_MODE_FREQ;
-
- /* prevent scl_rate_khz from becoming 0 */
- if (WARN_ON(t->bus_freq_hz < 1000))
-@@ -758,8 +758,8 @@ static int rk3x_i2c_v1_calc_timings(unsigned long clk_rate,
- int ret = 0;
-
- /* Support standard-mode, fast-mode and fast-mode plus */
-- if (WARN_ON(t->bus_freq_hz > 1000000))
-- t->bus_freq_hz = 1000000;
-+ if (WARN_ON(t->bus_freq_hz > I2C_MAX_FAST_MODE_PLUS_FREQ))
-+ t->bus_freq_hz = I2C_MAX_FAST_MODE_PLUS_FREQ;
-
- /* prevent scl_rate_khz from becoming 0 */
- if (WARN_ON(t->bus_freq_hz < 1000))
-diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
-index 7402f71dd24d5..c1cc86b5c569e 100644
---- a/drivers/i2c/busses/i2c-s3c2410.c
-+++ b/drivers/i2c/busses/i2c-s3c2410.c
-@@ -840,11 +840,11 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, unsigned int *got)
- int freq;
-
- i2c->clkrate = clkin;
-- clkin /= 1000; /* clkin now in KHz */
-+ clkin /= 1000; /* clkin now in KHz */
-
- dev_dbg(i2c->dev, "pdata desired frequency %lu\n", pdata->frequency);
-
-- target_frequency = pdata->frequency ? pdata->frequency : 100000;
-+ target_frequency = pdata->frequency ?: I2C_MAX_STANDARD_MODE_FREQ;
-
- target_frequency /= 1000; /* Target frequency now in KHz */
-
-diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
-index 0dc2494f1a37b..36801457f1f3b 100644
---- a/drivers/i2c/busses/i2c-sh_mobile.c
-+++ b/drivers/i2c/busses/i2c-sh_mobile.c
-@@ -146,9 +146,6 @@ struct sh_mobile_dt_config {
-
- #define IIC_FLAG_HAS_ICIC67 (1 << 0)
-
--#define STANDARD_MODE 100000
--#define FAST_MODE 400000
--
- /* Register offsets */
- #define ICDR 0x00
- #define ICCR 0x04
-@@ -271,11 +268,11 @@ static int sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
-
- i2c_clk_khz = clk_get_rate(pd->clk) / 1000 / pd->clks_per_count;
-
-- if (pd->bus_speed == STANDARD_MODE) {
-+ if (pd->bus_speed == I2C_MAX_STANDARD_MODE_FREQ) {
- tLOW = 47; /* tLOW = 4.7 us */
- tHIGH = 40; /* tHD;STA = tHIGH = 4.0 us */
- tf = 3; /* tf = 0.3 us */
-- } else if (pd->bus_speed == FAST_MODE) {
-+ } else if (pd->bus_speed == I2C_MAX_FAST_MODE_FREQ) {
- tLOW = 13; /* tLOW = 1.3 us */
- tHIGH = 6; /* tHD;STA = tHIGH = 0.6 us */
- tf = 3; /* tf = 0.3 us */
-@@ -897,7 +894,7 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
- return PTR_ERR(pd->reg);
-
- ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
-- pd->bus_speed = (ret || !bus_speed) ? STANDARD_MODE : bus_speed;
-+ pd->bus_speed = (ret || !bus_speed) ? I2C_MAX_STANDARD_MODE_FREQ : bus_speed;
- pd->clks_per_count = 1;
-
- /* Newer variants come with two new bits in ICIC */
-diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
-index fb7a046b3226b..a459e00c6851f 100644
---- a/drivers/i2c/busses/i2c-sirf.c
-+++ b/drivers/i2c/busses/i2c-sirf.c
-@@ -62,7 +62,6 @@
- #define SIRFSOC_I2C_STOP BIT(6)
- #define SIRFSOC_I2C_START BIT(7)
-
--#define SIRFSOC_I2C_DEFAULT_SPEED 100000
- #define SIRFSOC_I2C_ERR_NOACK 1
- #define SIRFSOC_I2C_ERR_TIMEOUT 2
-
-@@ -353,7 +352,7 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
- err = of_property_read_u32(pdev->dev.of_node,
- "clock-frequency", &bitrate);
- if (err < 0)
-- bitrate = SIRFSOC_I2C_DEFAULT_SPEED;
-+ bitrate = I2C_MAX_STANDARD_MODE_FREQ;
-
- /*
- * Due to some hardware design issues, we need to tune the formula.
-diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
-index ef0dc06a3778e..a69fb07fe6edb 100644
---- a/drivers/i2c/busses/i2c-sprd.c
-+++ b/drivers/i2c/busses/i2c-sprd.c
-@@ -343,9 +343,9 @@ static void sprd_i2c_set_clk(struct sprd_i2c *i2c_dev, u32 freq)
- writel(div1, i2c_dev->base + ADDR_DVD1);
-
- /* Start hold timing = hold time(us) * source clock */
-- if (freq == 400000)
-+ if (freq == I2C_MAX_FAST_MODE_FREQ)
- writel((6 * apb_clk) / 10000000, i2c_dev->base + ADDR_STA0_DVD);
-- else if (freq == 100000)
-+ else if (freq == I2C_MAX_STANDARD_MODE_FREQ)
- writel((4 * apb_clk) / 1000000, i2c_dev->base + ADDR_STA0_DVD);
- }
-
-@@ -508,7 +508,7 @@ static int sprd_i2c_probe(struct platform_device *pdev)
- snprintf(i2c_dev->adap.name, sizeof(i2c_dev->adap.name),
- "%s", "sprd-i2c");
-
-- i2c_dev->bus_freq = 100000;
-+ i2c_dev->bus_freq = I2C_MAX_STANDARD_MODE_FREQ;
- i2c_dev->adap.owner = THIS_MODULE;
- i2c_dev->dev = dev;
- i2c_dev->adap.retries = 3;
-@@ -522,7 +522,8 @@ static int sprd_i2c_probe(struct platform_device *pdev)
- i2c_dev->bus_freq = prop;
-
- /* We only support 100k and 400k now, otherwise will return error. */
-- if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000)
-+ if (i2c_dev->bus_freq != I2C_MAX_STANDARD_MODE_FREQ &&
-+ i2c_dev->bus_freq != I2C_MAX_FAST_MODE_FREQ)
- return -EINVAL;
-
- ret = sprd_i2c_clk_init(i2c_dev);
-diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
-index f7f7b5b64720e..faa81a95551fe 100644
---- a/drivers/i2c/busses/i2c-st.c
-+++ b/drivers/i2c/busses/i2c-st.c
-@@ -213,7 +213,7 @@ static inline void st_i2c_clr_bits(void __iomem *reg, u32 mask)
- */
- static struct st_i2c_timings i2c_timings[] = {
- [I2C_MODE_STANDARD] = {
-- .rate = 100000,
-+ .rate = I2C_MAX_STANDARD_MODE_FREQ,
- .rep_start_hold = 4400,
- .rep_start_setup = 5170,
- .start_hold = 4400,
-@@ -222,7 +222,7 @@ static struct st_i2c_timings i2c_timings[] = {
- .bus_free_time = 5170,
- },
- [I2C_MODE_FAST] = {
-- .rate = 400000,
-+ .rate = I2C_MAX_FAST_MODE_FREQ,
- .rep_start_hold = 660,
- .rep_start_setup = 660,
- .start_hold = 660,
-@@ -836,7 +836,7 @@ static int st_i2c_probe(struct platform_device *pdev)
-
- i2c_dev->mode = I2C_MODE_STANDARD;
- ret = of_property_read_u32(np, "clock-frequency", &clk_rate);
-- if ((!ret) && (clk_rate == 400000))
-+ if (!ret && (clk_rate == I2C_MAX_FAST_MODE_FREQ))
- i2c_dev->mode = I2C_MODE_FAST;
-
- i2c_dev->dev = &pdev->dev;
-diff --git a/drivers/i2c/busses/i2c-stm32f4.c b/drivers/i2c/busses/i2c-stm32f4.c
-index ba600d77a3f88..d6a69dfcac3f6 100644
---- a/drivers/i2c/busses/i2c-stm32f4.c
-+++ b/drivers/i2c/busses/i2c-stm32f4.c
-@@ -232,10 +232,10 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)
- * In standard mode:
- * t_scl_high = t_scl_low = CCR * I2C parent clk period
- * So to reach 100 kHz, we have:
-- * CCR = I2C parent rate / 100 kHz >> 1
-+ * CCR = I2C parent rate / (100 kHz * 2)
- *
- * For example with parent rate = 2 MHz:
-- * CCR = 2000000 / (100000 << 1) = 10
-+ * CCR = 2000000 / (100000 * 2) = 10
- * t_scl_high = t_scl_low = 10 * (1 / 2000000) = 5000 ns
- * t_scl_high + t_scl_low = 10000 ns so 100 kHz is reached
- *
-@@ -243,7 +243,7 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)
- * parent rate is not higher than 46 MHz . As a result val
- * is at most 8 bits wide and so fits into the CCR bits [11:0].
- */
-- val = i2c_dev->parent_rate / (100000 << 1);
-+ val = i2c_dev->parent_rate / (I2C_MAX_STANDARD_MODE_FREQ * 2);
- } else {
- /*
- * In fast mode, we compute CCR with duty = 0 as with low
-@@ -263,7 +263,7 @@ static void stm32f4_i2c_set_speed_mode(struct stm32f4_i2c_dev *i2c_dev)
- * parent rate is not higher than 46 MHz . As a result val
- * is at most 6 bits wide and so fits into the CCR bits [11:0].
- */
-- val = DIV_ROUND_UP(i2c_dev->parent_rate, 400000 * 3);
-+ val = DIV_ROUND_UP(i2c_dev->parent_rate, I2C_MAX_FAST_MODE_FREQ * 3);
-
- /* Select Fast mode */
- ccr |= STM32F4_I2C_CCR_FS;
-@@ -807,7 +807,7 @@ static int stm32f4_i2c_probe(struct platform_device *pdev)
-
- i2c_dev->speed = STM32_I2C_SPEED_STANDARD;
- ret = of_property_read_u32(np, "clock-frequency", &clk_rate);
-- if (!ret && clk_rate >= 400000)
-+ if (!ret && clk_rate >= I2C_MAX_FAST_MODE_FREQ)
- i2c_dev->speed = STM32_I2C_SPEED_FAST;
-
- i2c_dev->dev = &pdev->dev;
-diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
-index 8c3e2d409d63f..1c285095adeaa 100644
---- a/drivers/i2c/busses/i2c-stu300.c
-+++ b/drivers/i2c/busses/i2c-stu300.c
-@@ -132,7 +132,7 @@ enum stu300_error {
- #define NUM_ADDR_RESEND_ATTEMPTS 12
-
- /* I2C clock speed, in Hz 0-400kHz*/
--static unsigned int scl_frequency = 100000;
-+static unsigned int scl_frequency = I2C_MAX_STANDARD_MODE_FREQ;
- module_param(scl_frequency, uint, 0644);
-
- /**
-@@ -497,7 +497,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)
- dev_dbg(&dev->pdev->dev, "Clock rate %lu Hz, I2C bus speed %d Hz "
- "virtbase %p\n", clkrate, dev->speed, dev->virtbase);
-
-- if (dev->speed > 100000)
-+ if (dev->speed > I2C_MAX_STANDARD_MODE_FREQ)
- /* Fast Mode I2C */
- val = ((clkrate/dev->speed) - 9)/3 + 1;
- else
-@@ -518,7 +518,7 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)
- return -EINVAL;
- }
-
-- if (dev->speed > 100000) {
-+ if (dev->speed > I2C_MAX_STANDARD_MODE_FREQ) {
- /* CC6..CC0 */
- stu300_wr8((val & I2C_CCR_CC_MASK) | I2C_CCR_FMSM,
- dev->virtbase + I2C_CCR);
-diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
-index 540c33f4e3500..62231c89dcb16 100644
---- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
-+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
-@@ -186,7 +186,7 @@ static int p2wi_probe(struct platform_device *pdev)
- struct device_node *np = dev->of_node;
- struct device_node *childnp;
- unsigned long parent_clk_freq;
-- u32 clk_freq = 100000;
-+ u32 clk_freq = I2C_MAX_STANDARD_MODE_FREQ;
- struct resource *r;
- struct p2wi *p2wi;
- u32 slave_addr;
-diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
-index 39762f0611b18..179495e496821 100644
---- a/drivers/i2c/busses/i2c-synquacer.c
-+++ b/drivers/i2c/busses/i2c-synquacer.c
-@@ -67,10 +67,10 @@
-
- /* STANDARD MODE frequency */
- #define SYNQUACER_I2C_CLK_MASTER_STD(rate) \
-- DIV_ROUND_UP(DIV_ROUND_UP((rate), 100000) - 2, 2)
-+ DIV_ROUND_UP(DIV_ROUND_UP((rate), I2C_MAX_STANDARD_MODE_FREQ) - 2, 2)
- /* FAST MODE frequency */
- #define SYNQUACER_I2C_CLK_MASTER_FAST(rate) \
-- DIV_ROUND_UP((DIV_ROUND_UP((rate), 400000) - 2) * 2, 3)
-+ DIV_ROUND_UP((DIV_ROUND_UP((rate), I2C_MAX_FAST_MODE_FREQ) - 2) * 2, 3)
-
- /* (clkrate <= 18000000) */
- /* calculate the value of CS bits in CCR register on standard mode */
-@@ -602,7 +602,7 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
- i2c->adapter.nr = pdev->id;
- init_completion(&i2c->completion);
-
-- if (bus_speed < 400000)
-+ if (bus_speed < I2C_MAX_FAST_MODE_FREQ)
- i2c->speed_khz = SYNQUACER_I2C_SPEED_SM;
- else
- i2c->speed_khz = SYNQUACER_I2C_SPEED_FM;
-diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
-index db94e96aed77e..f52822156269f 100644
---- a/drivers/i2c/busses/i2c-tegra.c
-+++ b/drivers/i2c/busses/i2c-tegra.c
-@@ -122,10 +122,6 @@
- #define I2C_THIGH_SHIFT 8
- #define I2C_INTERFACE_TIMING_1 0x98
-
--#define I2C_STANDARD_MODE 100000
--#define I2C_FAST_MODE 400000
--#define I2C_FAST_PLUS_MODE 1000000
--
- /* Packet header size in bytes */
- #define I2C_PACKET_HEADER_SIZE 12
-
-@@ -731,8 +727,8 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev, bool clk_reinit)
- I2C_CLK_DIVISOR_STD_FAST_MODE_SHIFT;
- i2c_writel(i2c_dev, clk_divisor, I2C_CLK_DIVISOR);
-
-- if (i2c_dev->bus_clk_rate > I2C_STANDARD_MODE &&
-- i2c_dev->bus_clk_rate <= I2C_FAST_PLUS_MODE) {
-+ if (i2c_dev->bus_clk_rate > I2C_MAX_STANDARD_MODE_FREQ &&
-+ i2c_dev->bus_clk_rate <= I2C_MAX_FAST_MODE_PLUS_FREQ) {
- tlow = i2c_dev->hw->tlow_fast_fastplus_mode;
- thigh = i2c_dev->hw->thigh_fast_fastplus_mode;
- tsu_thd = i2c_dev->hw->setup_hold_time_fast_fast_plus_mode;
-@@ -1291,7 +1287,7 @@ static void tegra_i2c_parse_dt(struct tegra_i2c_dev *i2c_dev)
- ret = of_property_read_u32(np, "clock-frequency",
- &i2c_dev->bus_clk_rate);
- if (ret)
-- i2c_dev->bus_clk_rate = 100000; /* default clock rate */
-+ i2c_dev->bus_clk_rate = I2C_MAX_STANDARD_MODE_FREQ; /* default clock rate */
-
- multi_mode = of_property_read_bool(np, "multi-master");
- i2c_dev->is_multimaster_mode = multi_mode;
-@@ -1589,12 +1585,12 @@ static int tegra_i2c_probe(struct platform_device *pdev)
- }
- }
-
-- if (i2c_dev->bus_clk_rate > I2C_FAST_MODE &&
-- i2c_dev->bus_clk_rate <= I2C_FAST_PLUS_MODE)
-+ if (i2c_dev->bus_clk_rate > I2C_MAX_FAST_MODE_FREQ &&
-+ i2c_dev->bus_clk_rate <= I2C_MAX_FAST_MODE_PLUS_FREQ)
- i2c_dev->clk_divisor_non_hs_mode =
- i2c_dev->hw->clk_divisor_fast_plus_mode;
-- else if (i2c_dev->bus_clk_rate > I2C_STANDARD_MODE &&
-- i2c_dev->bus_clk_rate <= I2C_FAST_MODE)
-+ else if (i2c_dev->bus_clk_rate > I2C_MAX_STANDARD_MODE_FREQ &&
-+ i2c_dev->bus_clk_rate <= I2C_MAX_FAST_MODE_FREQ)
- i2c_dev->clk_divisor_non_hs_mode =
- i2c_dev->hw->clk_divisor_fast_mode;
- else
-diff --git a/drivers/i2c/busses/i2c-thunderx-pcidrv.c b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
-index 107aeb8b54da4..21ba3018c11a3 100644
---- a/drivers/i2c/busses/i2c-thunderx-pcidrv.c
-+++ b/drivers/i2c/busses/i2c-thunderx-pcidrv.c
-@@ -178,7 +178,7 @@ static int thunder_i2c_probe_pci(struct pci_dev *pdev,
- thunder_i2c_clock_enable(dev, i2c);
- ret = device_property_read_u32(dev, "clock-frequency", &i2c->twsi_freq);
- if (ret)
-- i2c->twsi_freq = 100000;
-+ i2c->twsi_freq = I2C_MAX_STANDARD_MODE_FREQ;
-
- init_waitqueue_head(&i2c->queue);
-
-diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
-index 4241aac79e7ef..2b258d54d68cf 100644
---- a/drivers/i2c/busses/i2c-uniphier-f.c
-+++ b/drivers/i2c/busses/i2c-uniphier-f.c
-@@ -73,8 +73,6 @@
- #define UNIPHIER_FI2C_BYTE_WISE BIT(3)
- #define UNIPHIER_FI2C_DEFER_STOP_COMP BIT(4)
-
--#define UNIPHIER_FI2C_DEFAULT_SPEED 100000
--#define UNIPHIER_FI2C_MAX_SPEED 400000
- #define UNIPHIER_FI2C_FIFO_SIZE 8
-
- struct uniphier_fi2c_priv {
-@@ -537,9 +535,9 @@ static int uniphier_fi2c_probe(struct platform_device *pdev)
- }
-
- if (of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed))
-- bus_speed = UNIPHIER_FI2C_DEFAULT_SPEED;
-+ bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
-
-- if (!bus_speed || bus_speed > UNIPHIER_FI2C_MAX_SPEED) {
-+ if (!bus_speed || bus_speed > I2C_MAX_FAST_MODE_FREQ) {
- dev_err(dev, "invalid clock-frequency %d\n", bus_speed);
- return -EINVAL;
- }
-diff --git a/drivers/i2c/busses/i2c-uniphier.c b/drivers/i2c/busses/i2c-uniphier.c
-index 0270090c03603..668b1fa2b0ef4 100644
---- a/drivers/i2c/busses/i2c-uniphier.c
-+++ b/drivers/i2c/busses/i2c-uniphier.c
-@@ -35,9 +35,6 @@
- #define UNIPHIER_I2C_NOISE 0x1c /* noise filter control */
- #define UNIPHIER_I2C_SETUP 0x20 /* setup time control */
-
--#define UNIPHIER_I2C_DEFAULT_SPEED 100000
--#define UNIPHIER_I2C_MAX_SPEED 400000
--
- struct uniphier_i2c_priv {
- struct completion comp;
- struct i2c_adapter adap;
-@@ -333,9 +330,9 @@ static int uniphier_i2c_probe(struct platform_device *pdev)
- }
-
- if (of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed))
-- bus_speed = UNIPHIER_I2C_DEFAULT_SPEED;
-+ bus_speed = I2C_MAX_STANDARD_MODE_FREQ;
-
-- if (!bus_speed || bus_speed > UNIPHIER_I2C_MAX_SPEED) {
-+ if (!bus_speed || bus_speed > I2C_MAX_FAST_MODE_FREQ) {
- dev_err(dev, "invalid clock-frequency %d\n", bus_speed);
- return -EINVAL;
- }
-diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c
-index 524017f7034e8..88f5aafdce5b4 100644
---- a/drivers/i2c/busses/i2c-wmt.c
-+++ b/drivers/i2c/busses/i2c-wmt.c
-@@ -399,7 +399,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
-
- i2c_dev->mode = I2C_MODE_STANDARD;
- err = of_property_read_u32(np, "clock-frequency", &clk_rate);
-- if ((!err) && (clk_rate == 400000))
-+ if (!err && (clk_rate == I2C_MAX_FAST_MODE_FREQ))
- i2c_dev->mode = I2C_MODE_FAST;
-
- i2c_dev->dev = &pdev->dev;
-diff --git a/drivers/i2c/busses/i2c-xlp9xx.c b/drivers/i2c/busses/i2c-xlp9xx.c
-index 8a873975cf125..f678f8d9abd67 100644
---- a/drivers/i2c/busses/i2c-xlp9xx.c
-+++ b/drivers/i2c/busses/i2c-xlp9xx.c
-@@ -71,8 +71,6 @@
- #define XLP9XX_I2C_SLAVEADDR_ADDR_SHIFT 1
-
- #define XLP9XX_I2C_IP_CLK_FREQ 133000000UL
--#define XLP9XX_I2C_DEFAULT_FREQ 100000
--#define XLP9XX_I2C_HIGH_FREQ 400000
- #define XLP9XX_I2C_FIFO_SIZE 0x80U
- #define XLP9XX_I2C_TIMEOUT_MS 1000
- #define XLP9XX_I2C_BUSY_TIMEOUT 50
-@@ -476,12 +474,12 @@ static int xlp9xx_i2c_get_frequency(struct platform_device *pdev,
-
- err = device_property_read_u32(&pdev->dev, "clock-frequency", &freq);
- if (err) {
-- freq = XLP9XX_I2C_DEFAULT_FREQ;
-+ freq = I2C_MAX_STANDARD_MODE_FREQ;
- dev_dbg(&pdev->dev, "using default frequency %u\n", freq);
-- } else if (freq == 0 || freq > XLP9XX_I2C_HIGH_FREQ) {
-+ } else if (freq == 0 || freq > I2C_MAX_FAST_MODE_FREQ) {
- dev_warn(&pdev->dev, "invalid frequency %u, using default\n",
- freq);
-- freq = XLP9XX_I2C_DEFAULT_FREQ;
-+ freq = I2C_MAX_STANDARD_MODE_FREQ;
- }
- priv->clk_hz = freq;
-
-diff --git a/drivers/i2c/busses/i2c-xlr.c b/drivers/i2c/busses/i2c-xlr.c
-index dda6cb848405b..adc15e7eac8cf 100644
---- a/drivers/i2c/busses/i2c-xlr.c
-+++ b/drivers/i2c/busses/i2c-xlr.c
-@@ -404,7 +404,7 @@ static int xlr_i2c_probe(struct platform_device *pdev)
-
- if (of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &busfreq))
-- busfreq = 100000;
-+ busfreq = I2C_MAX_STANDARD_MODE_FREQ;
-
- clk = devm_clk_get(&pdev->dev, NULL);
- if (!IS_ERR(clk)) {
---
-2.43.0
-
+++ /dev/null
-From dd8d9169375a725cadd5e3635342a6e2d483cf4c Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 3 Jun 2020 15:56:53 -0700
-Subject: mm: memblock: replace dereferences of memblock_region.nid with API
- calls
-
-From: Mike Rapoport <rppt@linux.ibm.com>
-
-[ Upstream commit d622abf74f3d81365e41c3bfdbbda50ecd99ba3d ]
-
-Patch series "mm: rework free_area_init*() funcitons".
-
-After the discussion [1] about removal of CONFIG_NODES_SPAN_OTHER_NODES
-and CONFIG_HAVE_MEMBLOCK_NODE_MAP options, I took it a bit further and
-updated the node/zone initialization.
-
-Since all architectures have memblock, it is possible to use only the
-newer version of free_area_init_node() that calculates the zone and node
-boundaries based on memblock node mapping and architectural limits on
-possible zone PFNs.
-
-The architectures that still determined zone and hole sizes can be
-switched to the generic code and the old code that took those zone and
-hole sizes can be simply removed.
-
-And, since it all started from the removal of
-CONFIG_NODES_SPAN_OTHER_NODES, the memmap_init() is now updated to iterate
-over memblocks and so it does not need to perform early_pfn_to_nid() query
-for every PFN.
-
-[1] https://lore.kernel.org/lkml/1585420282-25630-1-git-send-email-Hoan@os.amperecomputing.com
-
-This patch (of 21):
-
-There are several places in the code that directly dereference
-memblock_region.nid despite this field being defined only when
-CONFIG_HAVE_MEMBLOCK_NODE_MAP=y.
-
-Replace these with calls to memblock_get_region_nid() to improve code
-robustness and to avoid possible breakage when
-CONFIG_HAVE_MEMBLOCK_NODE_MAP will be removed.
-
-Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
-Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-Tested-by: Hoan Tran <hoan@os.amperecomputing.com> [arm64]
-Reviewed-by: Baoquan He <bhe@redhat.com>
-Cc: Brian Cain <bcain@codeaurora.org>
-Cc: Catalin Marinas <catalin.marinas@arm.com>
-Cc: "David S. Miller" <davem@davemloft.net>
-Cc: Geert Uytterhoeven <geert@linux-m68k.org>
-Cc: Greentime Hu <green.hu@gmail.com>
-Cc: Greg Ungerer <gerg@linux-m68k.org>
-Cc: Guan Xuetao <gxt@pku.edu.cn>
-Cc: Guo Ren <guoren@kernel.org>
-Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
-Cc: Helge Deller <deller@gmx.de>
-Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
-Cc: Jonathan Corbet <corbet@lwn.net>
-Cc: Ley Foon Tan <ley.foon.tan@intel.com>
-Cc: Mark Salter <msalter@redhat.com>
-Cc: Matt Turner <mattst88@gmail.com>
-Cc: Max Filippov <jcmvbkbc@gmail.com>
-Cc: Michael Ellerman <mpe@ellerman.id.au>
-Cc: Michal Hocko <mhocko@kernel.org>
-Cc: Michal Simek <monstr@monstr.eu>
-Cc: Mike Rapoport <rppt@kernel.org>
-Cc: Nick Hu <nickhu@andestech.com>
-Cc: Paul Walmsley <paul.walmsley@sifive.com>
-Cc: Richard Weinberger <richard@nod.at>
-Cc: Rich Felker <dalias@libc.org>
-Cc: Russell King <linux@armlinux.org.uk>
-Cc: Stafford Horne <shorne@gmail.com>
-Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
-Cc: Tony Luck <tony.luck@intel.com>
-Cc: Vineet Gupta <vgupta@synopsys.com>
-Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
-Link: http://lkml.kernel.org/r/20200412194859.12663-1-rppt@kernel.org
-Link: http://lkml.kernel.org/r/20200412194859.12663-2-rppt@kernel.org
-Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-Stable-dep-of: 3ac36aa73073 ("x86/mm/numa: Use NUMA_NO_NODE when calling memblock_set_node()")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/arm64/mm/numa.c | 9 ++++++---
- arch/x86/mm/numa.c | 6 ++++--
- mm/memblock.c | 8 +++++---
- mm/page_alloc.c | 4 ++--
- 4 files changed, 17 insertions(+), 10 deletions(-)
-
-diff --git a/arch/arm64/mm/numa.c b/arch/arm64/mm/numa.c
-index 53ebb4babf3a7..58c83c2b8748f 100644
---- a/arch/arm64/mm/numa.c
-+++ b/arch/arm64/mm/numa.c
-@@ -354,13 +354,16 @@ static int __init numa_register_nodes(void)
- struct memblock_region *mblk;
-
- /* Check that valid nid is set to memblks */
-- for_each_memblock(memory, mblk)
-- if (mblk->nid == NUMA_NO_NODE || mblk->nid >= MAX_NUMNODES) {
-+ for_each_memblock(memory, mblk) {
-+ int mblk_nid = memblock_get_region_node(mblk);
-+
-+ if (mblk_nid == NUMA_NO_NODE || mblk_nid >= MAX_NUMNODES) {
- pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n",
-- mblk->nid, mblk->base,
-+ mblk_nid, mblk->base,
- mblk->base + mblk->size - 1);
- return -EINVAL;
- }
-+ }
-
- /* Finally register nodes. */
- for_each_node_mask(nid, numa_nodes_parsed) {
-diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
-index 7316dca7e846a..bd52ce954d59a 100644
---- a/arch/x86/mm/numa.c
-+++ b/arch/x86/mm/numa.c
-@@ -502,8 +502,10 @@ static void __init numa_clear_kernel_node_hotplug(void)
- * reserve specific pages for Sandy Bridge graphics. ]
- */
- for_each_memblock(reserved, mb_region) {
-- if (mb_region->nid != MAX_NUMNODES)
-- node_set(mb_region->nid, reserved_nodemask);
-+ int nid = memblock_get_region_node(mb_region);
-+
-+ if (nid != MAX_NUMNODES)
-+ node_set(nid, reserved_nodemask);
- }
-
- /*
-diff --git a/mm/memblock.c b/mm/memblock.c
-index a75cc65f03307..d2d85d4d16b74 100644
---- a/mm/memblock.c
-+++ b/mm/memblock.c
-@@ -1170,13 +1170,15 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid,
- {
- struct memblock_type *type = &memblock.memory;
- struct memblock_region *r;
-+ int r_nid;
-
- while (++*idx < type->cnt) {
- r = &type->regions[*idx];
-+ r_nid = memblock_get_region_node(r);
-
- if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size))
- continue;
-- if (nid == MAX_NUMNODES || nid == r->nid)
-+ if (nid == MAX_NUMNODES || nid == r_nid)
- break;
- }
- if (*idx >= type->cnt) {
-@@ -1189,7 +1191,7 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid,
- if (out_end_pfn)
- *out_end_pfn = PFN_DOWN(r->base + r->size);
- if (out_nid)
-- *out_nid = r->nid;
-+ *out_nid = r_nid;
- }
-
- /**
-@@ -1730,7 +1732,7 @@ int __init_memblock memblock_search_pfn_nid(unsigned long pfn,
- *start_pfn = PFN_DOWN(type->regions[mid].base);
- *end_pfn = PFN_DOWN(type->regions[mid].base + type->regions[mid].size);
-
-- return type->regions[mid].nid;
-+ return memblock_get_region_node(&type->regions[mid]);
- }
- #endif
-
-diff --git a/mm/page_alloc.c b/mm/page_alloc.c
-index 0ad582945f54d..4a649111178cc 100644
---- a/mm/page_alloc.c
-+++ b/mm/page_alloc.c
-@@ -7214,7 +7214,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
- if (!memblock_is_hotpluggable(r))
- continue;
-
-- nid = r->nid;
-+ nid = memblock_get_region_node(r);
-
- usable_startpfn = PFN_DOWN(r->base);
- zone_movable_pfn[nid] = zone_movable_pfn[nid] ?
-@@ -7235,7 +7235,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)
- if (memblock_is_mirror(r))
- continue;
-
-- nid = r->nid;
-+ nid = memblock_get_region_node(r);
-
- usable_startpfn = memblock_region_memory_base_pfn(r);
-
---
-2.43.0
-
+++ /dev/null
-From 1f27f96028207a35cd36882848e003df737a40bc Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 24 Mar 2024 12:40:17 +0100
-Subject: mmc: davinci: Don't strip remove function when driver is builtin
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-
-[ Upstream commit 55c421b364482b61c4c45313a535e61ed5ae4ea3 ]
-
-Using __exit for the remove function results in the remove callback being
-discarded with CONFIG_MMC_DAVINCI=y. When such a device gets unbound (e.g.
-using sysfs or hotplug), the driver is just removed without the cleanup
-being performed. This results in resource leaks. Fix it by compiling in the
-remove callback unconditionally.
-
-This also fixes a W=1 modpost warning:
-
-WARNING: modpost: drivers/mmc/host/davinci_mmc: section mismatch in
-reference: davinci_mmcsd_driver+0x10 (section: .data) ->
-davinci_mmcsd_remove (section: .exit.text)
-
-Fixes: b4cff4549b7a ("DaVinci: MMC: MMC/SD controller driver for DaVinci family")
-Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-Cc: stable@vger.kernel.org
-Link: https://lore.kernel.org/r/20240324114017.231936-2-u.kleine-koenig@pengutronix.de
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/davinci_mmc.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
-index 2ae2af3bb7161..118ab9edf0d7c 100644
---- a/drivers/mmc/host/davinci_mmc.c
-+++ b/drivers/mmc/host/davinci_mmc.c
-@@ -1348,7 +1348,7 @@ static int davinci_mmcsd_probe(struct platform_device *pdev)
- return ret;
- }
-
--static void __exit davinci_mmcsd_remove(struct platform_device *pdev)
-+static void davinci_mmcsd_remove(struct platform_device *pdev)
- {
- struct mmc_davinci_host *host = platform_get_drvdata(pdev);
-
-@@ -1402,7 +1402,7 @@ static struct platform_driver davinci_mmcsd_driver = {
- .of_match_table = davinci_mmc_dt_ids,
- },
- .probe = davinci_mmcsd_probe,
-- .remove_new = __exit_p(davinci_mmcsd_remove),
-+ .remove_new = davinci_mmcsd_remove,
- .id_table = davinci_mmc_devtype,
- };
-
---
-2.43.0
-
+++ /dev/null
-From 8d4fca32af8f3242867a86add35a1a1951d82733 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 27 Jul 2023 14:59:56 +0800
-Subject: mmc: davinci_mmc: Convert to platform remove callback returning void
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-From: Yangtao Li <frank.li@vivo.com>
-
-[ Upstream commit bc1711e8332da03648d8fe1950189237e66313af ]
-
-The .remove() callback for a platform driver returns an int which makes
-many driver authors wrongly assume it's possible to do error handling by
-returning an error code. However the value returned is (mostly) ignored
-and this typically results in resource leaks. To improve here there is a
-quest to make the remove callback return void. In the first step of this
-quest all drivers are converted to .remove_new() which already returns
-void.
-
-Trivially convert this driver from always returning zero in the remove
-callback to the void returning variant.
-
-Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
-Signed-off-by: Yangtao Li <frank.li@vivo.com>
-Link: https://lore.kernel.org/r/20230727070051.17778-7-frank.li@vivo.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Stable-dep-of: 55c421b36448 ("mmc: davinci: Don't strip remove function when driver is builtin")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/davinci_mmc.c | 6 ++----
- 1 file changed, 2 insertions(+), 4 deletions(-)
-
-diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c
-index ade7c022a33c0..2ae2af3bb7161 100644
---- a/drivers/mmc/host/davinci_mmc.c
-+++ b/drivers/mmc/host/davinci_mmc.c
-@@ -1348,7 +1348,7 @@ static int davinci_mmcsd_probe(struct platform_device *pdev)
- return ret;
- }
-
--static int __exit davinci_mmcsd_remove(struct platform_device *pdev)
-+static void __exit davinci_mmcsd_remove(struct platform_device *pdev)
- {
- struct mmc_davinci_host *host = platform_get_drvdata(pdev);
-
-@@ -1357,8 +1357,6 @@ static int __exit davinci_mmcsd_remove(struct platform_device *pdev)
- davinci_release_dma_channels(host);
- clk_disable_unprepare(host->clk);
- mmc_free_host(host->mmc);
--
-- return 0;
- }
-
- #ifdef CONFIG_PM
-@@ -1404,7 +1402,7 @@ static struct platform_driver davinci_mmcsd_driver = {
- .of_match_table = davinci_mmc_dt_ids,
- },
- .probe = davinci_mmcsd_probe,
-- .remove = __exit_p(davinci_mmcsd_remove),
-+ .remove_new = __exit_p(davinci_mmcsd_remove),
- .id_table = davinci_mmc_devtype,
- };
-
---
-2.43.0
-
+++ /dev/null
-From 3fbee38b67a3931a32bfc02e73cfb0e3258e2d27 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 16 Mar 2020 19:47:53 +0100
-Subject: mmc: sdhci-acpi: Disable write protect detection on Acer Aspire
- Switch 10 (SW5-012)
-
-From: Hans de Goede <hdegoede@redhat.com>
-
-[ Upstream commit 3397b251ea02003f47f0b1667f3fe30bb4f9ce90 ]
-
-On the Acer Aspire Switch 10 (SW5-012) microSD slot always reports the card
-being write-protected even though microSD cards do not have a write-protect
-switch at all.
-
-Add a new DMI_QUIRK_SD_NO_WRITE_PROTECT quirk which when set sets
-the MMC_CAP2_NO_WRITE_PROTECT flag on the controller for the external SD
-slot; and add a DMI quirk table entry which selects this quirk for the
-Acer SW5-012.
-
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Cc: stable@vger.kernel.org
-Link: https://lore.kernel.org/r/20200316184753.393458-2-hdegoede@redhat.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Stable-dep-of: a92a73b1d924 ("mmc: sdhci-acpi: Sort DMI quirks alphabetically")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci-acpi.c | 16 ++++++++++++++++
- 1 file changed, 16 insertions(+)
-
-diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
-index 6a402367b1499..31049a9b1d582 100644
---- a/drivers/mmc/host/sdhci-acpi.c
-+++ b/drivers/mmc/host/sdhci-acpi.c
-@@ -80,6 +80,7 @@ struct sdhci_acpi_host {
-
- enum {
- DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP = BIT(0),
-+ DMI_QUIRK_SD_NO_WRITE_PROTECT = BIT(1),
- };
-
- static inline void *sdhci_acpi_priv(struct sdhci_acpi_host *c)
-@@ -774,6 +775,18 @@ static const struct dmi_system_id sdhci_acpi_quirks[] = {
- },
- .driver_data = (void *)DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP,
- },
-+ {
-+ /*
-+ * The Acer Aspire Switch 10 (SW5-012) microSD slot always
-+ * reports the card being write-protected even though microSD
-+ * cards do not have a write-protect switch at all.
-+ */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
-+ },
-+ .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
-+ },
- {} /* Terminating entry */
- };
-
-@@ -898,6 +911,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
-
- if (quirks & DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP)
- c->reset_signal_volt_on_suspend = true;
-+
-+ if (quirks & DMI_QUIRK_SD_NO_WRITE_PROTECT)
-+ host->mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
- }
-
- err = sdhci_setup_host(host);
---
-2.43.0
-
+++ /dev/null
-From e084998de943b8af59f83c158e8935390d2bcdfa Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 3 May 2021 11:21:57 +0200
-Subject: mmc: sdhci-acpi: Disable write protect detection on Toshiba Encore 2
- WT8-B
-
-From: Hans de Goede <hdegoede@redhat.com>
-
-[ Upstream commit 94ee6782e045645abd9180ab9369b01293d862bd ]
-
-On the Toshiba Encore 2 WT8-B the microSD slot always reports the card
-being write-protected even though microSD cards do not have a write-protect
-switch at all.
-
-Add a new DMI_QUIRK_SD_NO_WRITE_PROTECT quirk entry to sdhci-acpi.c's
-DMI quirk table for this.
-
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Link: https://lore.kernel.org/r/20210503092157.5689-1-hdegoede@redhat.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Cc: stable@vger.kernel.org
-Stable-dep-of: a92a73b1d924 ("mmc: sdhci-acpi: Sort DMI quirks alphabetically")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci-acpi.c | 11 +++++++++++
- 1 file changed, 11 insertions(+)
-
-diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
-index 31049a9b1d582..ba4c00fc62600 100644
---- a/drivers/mmc/host/sdhci-acpi.c
-+++ b/drivers/mmc/host/sdhci-acpi.c
-@@ -787,6 +787,17 @@ static const struct dmi_system_id sdhci_acpi_quirks[] = {
- },
- .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
- },
-+ {
-+ /*
-+ * The Toshiba WT8-B's microSD slot always reports the card being
-+ * write-protected.
-+ */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "TOSHIBA ENCORE 2 WT8-B"),
-+ },
-+ .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
-+ },
- {} /* Terminating entry */
- };
-
---
-2.43.0
-
+++ /dev/null
-From 3cb15cba5c525cb9740b25ce3481390c386ae9f2 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 10 Apr 2024 21:16:38 +0200
-Subject: mmc: sdhci-acpi: Disable write protect detection on Toshiba WT10-A
-
-From: Hans de Goede <hdegoede@redhat.com>
-
-[ Upstream commit ef3eab75e17191e5665f52e64e85bc29d5705a7b ]
-
-On the Toshiba WT10-A the microSD slot always reports the card being
-write-protected, just like on the Toshiba WT8-B.
-
-Add a DMI quirk to work around this.
-
-Reviewed-by: Andy Shevchenko <andy@kernel.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Cc: stable@vger.kernel.org
-Link: https://lore.kernel.org/r/20240410191639.526324-6-hdegoede@redhat.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci-acpi.c | 11 +++++++++++
- 1 file changed, 11 insertions(+)
-
-diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
-index b4192e00c333e..d3a7d38eb2a96 100644
---- a/drivers/mmc/host/sdhci-acpi.c
-+++ b/drivers/mmc/host/sdhci-acpi.c
-@@ -799,6 +799,17 @@ static const struct dmi_system_id sdhci_acpi_quirks[] = {
- },
- .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
- },
-+ {
-+ /*
-+ * The Toshiba WT10-A's microSD slot always reports the card being
-+ * write-protected.
-+ */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "TOSHIBA WT10-A"),
-+ },
-+ .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
-+ },
- {} /* Terminating entry */
- };
-
---
-2.43.0
-
+++ /dev/null
-From 4f5b54d40d617b8297eea7e3ab6e0b5b5824b766 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 10 Apr 2024 21:16:36 +0200
-Subject: mmc: sdhci-acpi: Sort DMI quirks alphabetically
-
-From: Hans de Goede <hdegoede@redhat.com>
-
-[ Upstream commit a92a73b1d9249d155412d8ac237142fa716803ea ]
-
-Sort the DMI quirks alphabetically.
-
-Reviewed-by: Andy Shevchenko <andy@kernel.org>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Cc: stable@vger.kernel.org
-Link: https://lore.kernel.org/r/20240410191639.526324-4-hdegoede@redhat.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci-acpi.c | 25 +++++++++++++------------
- 1 file changed, 13 insertions(+), 12 deletions(-)
-
-diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
-index ba4c00fc62600..b4192e00c333e 100644
---- a/drivers/mmc/host/sdhci-acpi.c
-+++ b/drivers/mmc/host/sdhci-acpi.c
-@@ -760,7 +760,20 @@ static const struct acpi_device_id sdhci_acpi_ids[] = {
- };
- MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
-
-+/* Please keep this list sorted alphabetically */
- static const struct dmi_system_id sdhci_acpi_quirks[] = {
-+ {
-+ /*
-+ * The Acer Aspire Switch 10 (SW5-012) microSD slot always
-+ * reports the card being write-protected even though microSD
-+ * cards do not have a write-protect switch at all.
-+ */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-+ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
-+ },
-+ .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
-+ },
- {
- /*
- * The Lenovo Miix 320-10ICR has a bug in the _PS0 method of
-@@ -775,18 +788,6 @@ static const struct dmi_system_id sdhci_acpi_quirks[] = {
- },
- .driver_data = (void *)DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP,
- },
-- {
-- /*
-- * The Acer Aspire Switch 10 (SW5-012) microSD slot always
-- * reports the card being write-protected even though microSD
-- * cards do not have a write-protect switch at all.
-- */
-- .matches = {
-- DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
-- DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
-- },
-- .driver_data = (void *)DMI_QUIRK_SD_NO_WRITE_PROTECT,
-- },
- {
- /*
- * The Toshiba WT8-B's microSD slot always reports the card being
---
-2.43.0
-
+++ /dev/null
-From f42b28c2b0945d814bb4cb62eebf807d0c32f976 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 16 Mar 2020 19:47:52 +0100
-Subject: mmc: sdhci-acpi: Switch signal voltage back to 3.3V on suspend on
- external microSD on Lenovo Miix 320
-
-From: Hans de Goede <hdegoede@redhat.com>
-
-[ Upstream commit 84d49b3d08a1d33690cc159036f381c31c27c17b ]
-
-Based on a sample of 7 DSDTs from Cherry Trail devices using an AXP288
-PMIC depending on the design one of 2 possible LDOs on the PMIC is used
-for the MMC signalling voltage, either DLDO3 or GPIO1LDO (GPIO1 pin in
-low noise LDO mode).
-
-The Lenovo Miix 320-10ICR uses GPIO1LDO in the SHC1 ACPI device's DSM
-methods to set 3.3 or 1.8 signalling voltage and this appears to work
-as advertised, so presumably the device is actually using GPIO1LDO for
-the external microSD signalling voltage.
-
-But this device has a bug in the _PS0 method of the SHC1 ACPI device,
-the DSM remembers the last set signalling voltage and the _PS0 restores
-this after a (runtime) suspend-resume cycle, but it "restores" the voltage
-on DLDO3 instead of setting it on GPIO1LDO as the DSM method does. DLDO3
-is used for the LCD and setting it to 1.8V causes the LCD to go black.
-
-This commit works around this issue by calling the Intel DSM to reset the
-signal voltage to 3.3V after the host has been runtime suspended.
-This will make the _PS0 method reprogram the DLDO3 voltage to 3.3V, which
-leaves it at its original setting fixing the LCD going black.
-
-This commit adds and uses a DMI quirk mechanism to only trigger this
-workaround on the Lenovo Miix 320 while leaving the behavior of the
-driver unchanged on other devices.
-
-BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=111294
-BugLink: https://gitlab.freedesktop.org/drm/intel/issues/355
-Reported-by: russianneuromancer <russianneuromancer@ya.ru>
-Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Cc: stable@vger.kernel.org
-Link: https://lore.kernel.org/r/20200316184753.393458-1-hdegoede@redhat.com
-Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-Stable-dep-of: a92a73b1d924 ("mmc: sdhci-acpi: Sort DMI quirks alphabetically")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci-acpi.c | 68 +++++++++++++++++++++++++++++++++--
- 1 file changed, 66 insertions(+), 2 deletions(-)
-
-diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
-index a8d9a6037fe56..6a402367b1499 100644
---- a/drivers/mmc/host/sdhci-acpi.c
-+++ b/drivers/mmc/host/sdhci-acpi.c
-@@ -23,6 +23,7 @@
- #include <linux/pm.h>
- #include <linux/pm_runtime.h>
- #include <linux/delay.h>
-+#include <linux/dmi.h>
-
- #include <linux/mmc/host.h>
- #include <linux/mmc/pm.h>
-@@ -72,9 +73,15 @@ struct sdhci_acpi_host {
- const struct sdhci_acpi_slot *slot;
- struct platform_device *pdev;
- bool use_runtime_pm;
-+ bool is_intel;
-+ bool reset_signal_volt_on_suspend;
- unsigned long private[0] ____cacheline_aligned;
- };
-
-+enum {
-+ DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP = BIT(0),
-+};
-+
- static inline void *sdhci_acpi_priv(struct sdhci_acpi_host *c)
- {
- return (void *)c->private;
-@@ -391,6 +398,8 @@ static int intel_probe_slot(struct platform_device *pdev, struct acpi_device *ad
- host->mmc_host_ops.start_signal_voltage_switch =
- intel_start_signal_voltage_switch;
-
-+ c->is_intel = true;
-+
- return 0;
- }
-
-@@ -750,6 +759,24 @@ static const struct acpi_device_id sdhci_acpi_ids[] = {
- };
- MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
-
-+static const struct dmi_system_id sdhci_acpi_quirks[] = {
-+ {
-+ /*
-+ * The Lenovo Miix 320-10ICR has a bug in the _PS0 method of
-+ * the SHC1 ACPI device, this bug causes it to reprogram the
-+ * wrong LDO (DLDO3) to 1.8V if 1.8V modes are used and the
-+ * card is (runtime) suspended + resumed. DLDO3 is used for
-+ * the LCD and setting it to 1.8V causes the LCD to go black.
-+ */
-+ .matches = {
-+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-+ DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
-+ },
-+ .driver_data = (void *)DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP,
-+ },
-+ {} /* Terminating entry */
-+};
-+
- static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(struct acpi_device *adev)
- {
- const struct sdhci_acpi_uid_slot *u;
-@@ -766,17 +793,23 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
- struct device *dev = &pdev->dev;
- const struct sdhci_acpi_slot *slot;
- struct acpi_device *device, *child;
-+ const struct dmi_system_id *id;
- struct sdhci_acpi_host *c;
- struct sdhci_host *host;
- struct resource *iomem;
- resource_size_t len;
- size_t priv_size;
-+ int quirks = 0;
- int err;
-
- device = ACPI_COMPANION(dev);
- if (!device)
- return -ENODEV;
-
-+ id = dmi_first_match(sdhci_acpi_quirks);
-+ if (id)
-+ quirks = (long)id->driver_data;
-+
- slot = sdhci_acpi_get_slot(device);
-
- /* Power on the SDHCI controller and its children */
-@@ -862,6 +895,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
- dev_warn(dev, "failed to setup card detect gpio\n");
- c->use_runtime_pm = false;
- }
-+
-+ if (quirks & DMI_QUIRK_RESET_SD_SIGNAL_VOLT_ON_SUSP)
-+ c->reset_signal_volt_on_suspend = true;
- }
-
- err = sdhci_setup_host(host);
-@@ -926,17 +962,39 @@ static int sdhci_acpi_remove(struct platform_device *pdev)
- return 0;
- }
-
-+static void __maybe_unused sdhci_acpi_reset_signal_voltage_if_needed(
-+ struct device *dev)
-+{
-+ struct sdhci_acpi_host *c = dev_get_drvdata(dev);
-+ struct sdhci_host *host = c->host;
-+
-+ if (c->is_intel && c->reset_signal_volt_on_suspend &&
-+ host->mmc->ios.signal_voltage != MMC_SIGNAL_VOLTAGE_330) {
-+ struct intel_host *intel_host = sdhci_acpi_priv(c);
-+ unsigned int fn = INTEL_DSM_V33_SWITCH;
-+ u32 result = 0;
-+
-+ intel_dsm(intel_host, dev, fn, &result);
-+ }
-+}
-+
- #ifdef CONFIG_PM_SLEEP
-
- static int sdhci_acpi_suspend(struct device *dev)
- {
- struct sdhci_acpi_host *c = dev_get_drvdata(dev);
- struct sdhci_host *host = c->host;
-+ int ret;
-
- if (host->tuning_mode != SDHCI_TUNING_MODE_3)
- mmc_retune_needed(host->mmc);
-
-- return sdhci_suspend_host(host);
-+ ret = sdhci_suspend_host(host);
-+ if (ret)
-+ return ret;
-+
-+ sdhci_acpi_reset_signal_voltage_if_needed(dev);
-+ return 0;
- }
-
- static int sdhci_acpi_resume(struct device *dev)
-@@ -956,11 +1014,17 @@ static int sdhci_acpi_runtime_suspend(struct device *dev)
- {
- struct sdhci_acpi_host *c = dev_get_drvdata(dev);
- struct sdhci_host *host = c->host;
-+ int ret;
-
- if (host->tuning_mode != SDHCI_TUNING_MODE_3)
- mmc_retune_needed(host->mmc);
-
-- return sdhci_runtime_suspend_host(host);
-+ ret = sdhci_runtime_suspend_host(host);
-+ if (ret)
-+ return ret;
-+
-+ sdhci_acpi_reset_signal_voltage_if_needed(dev);
-+ return 0;
- }
-
- static int sdhci_acpi_runtime_resume(struct device *dev)
---
-2.43.0
-
+++ /dev/null
-From 30ab76be9799a03b0943addb5db5775905b33235 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Tue, 1 Oct 2019 17:27:24 +0300
-Subject: mmc: sdhci-acpi: Switch to use acpi_dev_hid_uid_match()
-
-From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-
-[ Upstream commit 4f3cde3a24ce874973ee21269da16024c77a159c ]
-
-Since we have a generic helper, drop custom implementation in the driver.
-
-Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
-Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
-Acked-by: Adrian Hunter <adrian.hunter@intel.com>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Stable-dep-of: a92a73b1d924 ("mmc: sdhci-acpi: Sort DMI quirks alphabetically")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/mmc/host/sdhci-acpi.c | 49 ++++++++++++-----------------------
- 1 file changed, 16 insertions(+), 33 deletions(-)
-
-diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
-index a02f3538d5611..a8d9a6037fe56 100644
---- a/drivers/mmc/host/sdhci-acpi.c
-+++ b/drivers/mmc/host/sdhci-acpi.c
-@@ -61,7 +61,7 @@ struct sdhci_acpi_slot {
- mmc_pm_flag_t pm_caps;
- unsigned int flags;
- size_t priv_size;
-- int (*probe_slot)(struct platform_device *, const char *, const char *);
-+ int (*probe_slot)(struct platform_device *, struct acpi_device *);
- int (*remove_slot)(struct platform_device *);
- int (*free_slot)(struct platform_device *pdev);
- int (*setup_host)(struct platform_device *pdev);
-@@ -325,12 +325,10 @@ static bool sdhci_acpi_cht_pci_wifi(unsigned int vendor, unsigned int device,
- * wifi card in the expected slot with an ACPI companion node, is used to
- * indicate that acpi_device_fix_up_power() should be avoided.
- */
--static inline bool sdhci_acpi_no_fixup_child_power(const char *hid,
-- const char *uid)
-+static inline bool sdhci_acpi_no_fixup_child_power(struct acpi_device *adev)
- {
- return sdhci_acpi_cht() &&
-- !strcmp(hid, "80860F14") &&
-- !strcmp(uid, "2") &&
-+ acpi_dev_hid_uid_match(adev, "80860F14", "2") &&
- sdhci_acpi_cht_pci_wifi(0x14e4, 0x43ec, 0, 28);
- }
-
-@@ -345,8 +343,7 @@ static inline bool sdhci_acpi_byt_defer(struct device *dev)
- return false;
- }
-
--static inline bool sdhci_acpi_no_fixup_child_power(const char *hid,
-- const char *uid)
-+static inline bool sdhci_acpi_no_fixup_child_power(struct acpi_device *adev)
- {
- return false;
- }
-@@ -375,19 +372,18 @@ static int bxt_get_cd(struct mmc_host *mmc)
- return ret;
- }
-
--static int intel_probe_slot(struct platform_device *pdev, const char *hid,
-- const char *uid)
-+static int intel_probe_slot(struct platform_device *pdev, struct acpi_device *adev)
- {
- struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
- struct intel_host *intel_host = sdhci_acpi_priv(c);
- struct sdhci_host *host = c->host;
-
-- if (hid && uid && !strcmp(hid, "80860F14") && !strcmp(uid, "1") &&
-+ if (acpi_dev_hid_uid_match(adev, "80860F14", "1") &&
- sdhci_readl(host, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
- sdhci_readl(host, SDHCI_CAPABILITIES_1) == 0x00000807)
- host->timeout_clk = 1000; /* 1000 kHz i.e. 1 MHz */
-
-- if (hid && !strcmp(hid, "80865ACA"))
-+ if (acpi_dev_hid_uid_match(adev, "80865ACA", NULL))
- host->mmc_host_ops.get_cd = bxt_get_cd;
-
- intel_dsm_init(intel_host, &pdev->dev, host->mmc);
-@@ -473,8 +469,7 @@ static irqreturn_t sdhci_acpi_qcom_handler(int irq, void *ptr)
- return IRQ_HANDLED;
- }
-
--static int qcom_probe_slot(struct platform_device *pdev, const char *hid,
-- const char *uid)
-+static int qcom_probe_slot(struct platform_device *pdev, struct acpi_device *adev)
- {
- struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
- struct sdhci_host *host = c->host;
-@@ -482,7 +477,7 @@ static int qcom_probe_slot(struct platform_device *pdev, const char *hid,
-
- *irq = -EINVAL;
-
-- if (strcmp(hid, "QCOM8051"))
-+ if (!acpi_dev_hid_uid_match(adev, "QCOM8051", NULL))
- return 0;
-
- *irq = platform_get_irq(pdev, 1);
-@@ -501,14 +496,12 @@ static int qcom_free_slot(struct platform_device *pdev)
- struct sdhci_host *host = c->host;
- struct acpi_device *adev;
- int *irq = sdhci_acpi_priv(c);
-- const char *hid;
-
- adev = ACPI_COMPANION(dev);
- if (!adev)
- return -ENODEV;
-
-- hid = acpi_device_hid(adev);
-- if (strcmp(hid, "QCOM8051"))
-+ if (!acpi_dev_hid_uid_match(adev, "QCOM8051", NULL))
- return 0;
-
- if (*irq < 0)
-@@ -645,7 +638,7 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_amd = {
- };
-
- static int sdhci_acpi_emmc_amd_probe_slot(struct platform_device *pdev,
-- const char *hid, const char *uid)
-+ struct acpi_device *adev)
- {
- struct sdhci_acpi_host *c = platform_get_drvdata(pdev);
- struct sdhci_host *host = c->host;
-@@ -757,17 +750,12 @@ static const struct acpi_device_id sdhci_acpi_ids[] = {
- };
- MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids);
-
--static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid,
-- const char *uid)
-+static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(struct acpi_device *adev)
- {
- const struct sdhci_acpi_uid_slot *u;
-
- for (u = sdhci_acpi_uids; u->hid; u++) {
-- if (strcmp(u->hid, hid))
-- continue;
-- if (!u->uid)
-- return u->slot;
-- if (uid && !strcmp(u->uid, uid))
-+ if (acpi_dev_hid_uid_match(adev, u->hid, u->uid))
- return u->slot;
- }
- return NULL;
-@@ -783,22 +771,17 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
- struct resource *iomem;
- resource_size_t len;
- size_t priv_size;
-- const char *hid;
-- const char *uid;
- int err;
-
- device = ACPI_COMPANION(dev);
- if (!device)
- return -ENODEV;
-
-- hid = acpi_device_hid(device);
-- uid = acpi_device_uid(device);
--
-- slot = sdhci_acpi_get_slot(hid, uid);
-+ slot = sdhci_acpi_get_slot(device);
-
- /* Power on the SDHCI controller and its children */
- acpi_device_fix_up_power(device);
-- if (!sdhci_acpi_no_fixup_child_power(hid, uid)) {
-+ if (!sdhci_acpi_no_fixup_child_power(device)) {
- list_for_each_entry(child, &device->children, node)
- if (child->status.present && child->status.enabled)
- acpi_device_fix_up_power(child);
-@@ -848,7 +831,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev)
-
- if (c->slot) {
- if (c->slot->probe_slot) {
-- err = c->slot->probe_slot(pdev, hid, uid);
-+ err = c->slot->probe_slot(pdev, device);
- if (err)
- goto err_free;
- }
---
-2.43.0
-
+++ /dev/null
-From 5f13dd13b2a5ed39870c4cc4697ba619dca0fb22 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 28 Sep 2020 00:28:11 -0700
-Subject: nl80211: extend support to config spatial reuse parameter set
-
-From: Rajkumar Manoharan <rmanohar@codeaurora.org>
-
-[ Upstream commit f5bec330e3010450daeb5cb6a94a4a7c54afa306 ]
-
-Allow the user to configure below Spatial Reuse Parameter Set element.
- * Non-SRG OBSS PD Max Offset
- * SRG BSS Color Bitmap
- * SRG Partial BSSID Bitmap
-
-Signed-off-by: Rajkumar Manoharan <rmanohar@codeaurora.org>
-Link: https://lore.kernel.org/r/1601278091-20313-2-git-send-email-rmanohar@codeaurora.org
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-Stable-dep-of: a26d8dc5227f ("wifi: mac80211: correctly parse Spatial Reuse Parameter Set element")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- include/linux/ieee80211.h | 7 +++++--
- include/net/cfg80211.h | 10 ++++++++++
- include/uapi/linux/nl80211.h | 11 +++++++++++
- net/wireless/nl80211.c | 25 +++++++++++++++++++++++++
- 4 files changed, 51 insertions(+), 2 deletions(-)
-
-diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
-index 624d2643bfbaa..3b0459e88ab73 100644
---- a/include/linux/ieee80211.h
-+++ b/include/linux/ieee80211.h
-@@ -2095,8 +2095,11 @@ ieee80211_he_oper_size(const u8 *he_oper_ie)
- }
-
- /* HE Spatial Reuse defines */
--#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT 0x4
--#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT 0x8
-+#define IEEE80211_HE_SPR_PSR_DISALLOWED BIT(0)
-+#define IEEE80211_HE_SPR_NON_SRG_OBSS_PD_SR_DISALLOWED BIT(1)
-+#define IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT BIT(2)
-+#define IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT BIT(3)
-+#define IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED BIT(4)
-
- /*
- * ieee80211_he_spr_size - calculate 802.11ax HE Spatial Reuse IE size
-diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
-index 2dfa3331604e4..cba78dfe8a3db 100644
---- a/include/net/cfg80211.h
-+++ b/include/net/cfg80211.h
-@@ -250,13 +250,23 @@ struct ieee80211_rate {
- * struct ieee80211_he_obss_pd - AP settings for spatial reuse
- *
- * @enable: is the feature enabled.
-+ * @sr_ctrl: The SR Control field of SRP element.
-+ * @non_srg_max_offset: non-SRG maximum tx power offset
- * @min_offset: minimal tx power offset an associated station shall use
- * @max_offset: maximum tx power offset an associated station shall use
-+ * @bss_color_bitmap: bitmap that indicates the BSS color values used by
-+ * members of the SRG
-+ * @partial_bssid_bitmap: bitmap that indicates the partial BSSID values
-+ * used by members of the SRG
- */
- struct ieee80211_he_obss_pd {
- bool enable;
-+ u8 sr_ctrl;
-+ u8 non_srg_max_offset;
- u8 min_offset;
- u8 max_offset;
-+ u8 bss_color_bitmap[8];
-+ u8 partial_bssid_bitmap[8];
- };
-
- /**
-diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
-index beee59c831a73..4a95edbfc6e43 100644
---- a/include/uapi/linux/nl80211.h
-+++ b/include/uapi/linux/nl80211.h
-@@ -6533,6 +6533,13 @@ enum nl80211_peer_measurement_ftm_resp {
- *
- * @NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET: the OBSS PD minimum tx power offset.
- * @NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET: the OBSS PD maximum tx power offset.
-+ * @NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET: the non-SRG OBSS PD maximum
-+ * tx power offset.
-+ * @NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP: bitmap that indicates the BSS color
-+ * values used by members of the SRG.
-+ * @NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP: bitmap that indicates the partial
-+ * BSSID values used by members of the SRG.
-+ * @NL80211_HE_OBSS_PD_ATTR_SR_CTRL: The SR Control field of SRP element.
- *
- * @__NL80211_HE_OBSS_PD_ATTR_LAST: Internal
- * @NL80211_HE_OBSS_PD_ATTR_MAX: highest OBSS PD attribute.
-@@ -6542,6 +6549,10 @@ enum nl80211_obss_pd_attributes {
-
- NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET,
- NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET,
-+ NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET,
-+ NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP,
-+ NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP,
-+ NL80211_HE_OBSS_PD_ATTR_SR_CTRL,
-
- /* keep last */
- __NL80211_HE_OBSS_PD_ATTR_LAST,
-diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
-index 0d15dd68565cb..7e0079aa4e6c4 100644
---- a/net/wireless/nl80211.c
-+++ b/net/wireless/nl80211.c
-@@ -319,6 +319,13 @@ he_obss_pd_policy[NL80211_HE_OBSS_PD_ATTR_MAX + 1] = {
- NLA_POLICY_RANGE(NLA_U8, 1, 20),
- [NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET] =
- NLA_POLICY_RANGE(NLA_U8, 1, 20),
-+ [NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET] =
-+ NLA_POLICY_RANGE(NLA_U8, 1, 20),
-+ [NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP] =
-+ NLA_POLICY_EXACT_LEN(8),
-+ [NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP] =
-+ NLA_POLICY_EXACT_LEN(8),
-+ [NL80211_HE_OBSS_PD_ATTR_SR_CTRL] = { .type = NLA_U8 },
- };
-
- const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
-@@ -4505,16 +4512,34 @@ static int nl80211_parse_he_obss_pd(struct nlattr *attrs,
- if (err)
- return err;
-
-+ if (!tb[NL80211_HE_OBSS_PD_ATTR_SR_CTRL])
-+ return -EINVAL;
-+
-+ he_obss_pd->sr_ctrl = nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_SR_CTRL]);
-+
- if (tb[NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET])
- he_obss_pd->min_offset =
- nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET]);
- if (tb[NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET])
- he_obss_pd->max_offset =
- nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET]);
-+ if (tb[NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET])
-+ he_obss_pd->non_srg_max_offset =
-+ nla_get_u8(tb[NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET]);
-
- if (he_obss_pd->min_offset > he_obss_pd->max_offset)
- return -EINVAL;
-
-+ if (tb[NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP])
-+ memcpy(he_obss_pd->bss_color_bitmap,
-+ nla_data(tb[NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP]),
-+ sizeof(he_obss_pd->bss_color_bitmap));
-+
-+ if (tb[NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP])
-+ memcpy(he_obss_pd->partial_bssid_bitmap,
-+ nla_data(tb[NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP]),
-+ sizeof(he_obss_pd->partial_bssid_bitmap));
-+
- he_obss_pd->enable = true;
-
- return 0;
---
-2.43.0
-
+++ /dev/null
-From 6d757e8f7b67bc8abe6313bfa8a59cee44697ea7 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 9 Jul 2020 11:43:33 -0700
-Subject: nvme-pci: add support for ACPI StorageD3Enable property
-
-From: David E. Box <david.e.box@linux.intel.com>
-
-[ Upstream commit df4f9bc4fb9cb338b1c21cf99c6e905d3b78e91d ]
-
-This patch implements a solution for a BIOS hack used on some currently
-shipping Intel systems to change driver power management policy for PCIe
-NVMe drives. Some newer Intel platforms, like some Comet Lake systems,
-require that PCIe devices use D3 when doing suspend-to-idle in order to
-allow the platform to realize maximum power savings. This is particularly
-needed to support ATX power supply shutdown on desktop systems. In order to
-ensure this happens for root ports with storage devices, Microsoft
-apparently created this ACPI _DSD property as a way to influence their
-driver policy. To my knowledge this property has not been discussed with
-the NVME specification body.
-
-Though the solution is not ideal, it addresses a problem that also affects
-Linux since the NVMe driver's default policy of using NVMe APST during
-suspend-to-idle prevents the PCI root port from going to D3 and leads to
-higher power consumption for these platforms. The power consumption
-difference may be negligible on laptop systems, but many watts on desktop
-systems when the ATX power supply is blocked from powering down.
-
-The patch creates a new nvme_acpi_storage_d3 function to check for the
-StorageD3Enable property during probe and enables D3 as a quirk if set. It
-also provides a 'noacpi' module parameter to allow skipping the quirk if
-needed.
-
-Tested with:
- - PM961 NVMe SED Samsung 512GB
- - INTEL SSDPEKKF512G8
-
-Link: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/power-management-for-storage-hardware-devices-intro
-Signed-off-by: David E. Box <david.e.box@linux.intel.com>
-Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Signed-off-by: Christoph Hellwig <hch@lst.de>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/acpi/property.c | 3 ++
- drivers/nvme/host/pci.c | 63 +++++++++++++++++++++++++++++++++++++++++
- 2 files changed, 66 insertions(+)
-
-diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
-index 5906e247b9fa1..11274df95289b 100644
---- a/drivers/acpi/property.c
-+++ b/drivers/acpi/property.c
-@@ -45,6 +45,9 @@ static const guid_t prp_guids[] = {
- /* Thunderbolt GUID for WAKE_SUPPORTED: 6c501103-c189-4296-ba72-9bf5a26ebe5d */
- GUID_INIT(0x6c501103, 0xc189, 0x4296,
- 0xba, 0x72, 0x9b, 0xf5, 0xa2, 0x6e, 0xbe, 0x5d),
-+ /* Storage device needs D3 GUID: 5025030f-842f-4ab4-a561-99a5189762d0 */
-+ GUID_INIT(0x5025030f, 0x842f, 0x4ab4,
-+ 0xa5, 0x61, 0x99, 0xa5, 0x18, 0x97, 0x62, 0xd0),
- };
-
- /* ACPI _DSD data subnodes GUID: dbb8e3e6-5886-4ba6-8795-1319f52a966b */
-diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
-index 486e44d20b430..db81403a4286c 100644
---- a/drivers/nvme/host/pci.c
-+++ b/drivers/nvme/host/pci.c
-@@ -4,6 +4,7 @@
- * Copyright (c) 2011-2014, Intel Corporation.
- */
-
-+#include <linux/acpi.h>
- #include <linux/aer.h>
- #include <linux/async.h>
- #include <linux/blkdev.h>
-@@ -78,6 +79,10 @@ static unsigned int poll_queues;
- module_param(poll_queues, uint, 0644);
- MODULE_PARM_DESC(poll_queues, "Number of queues to use for polled IO.");
-
-+static bool noacpi;
-+module_param(noacpi, bool, 0444);
-+MODULE_PARM_DESC(noacpi, "disable acpi bios quirks");
-+
- struct nvme_dev;
- struct nvme_queue;
-
-@@ -2824,6 +2829,54 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)
- return 0;
- }
-
-+#ifdef CONFIG_ACPI
-+static bool nvme_acpi_storage_d3(struct pci_dev *dev)
-+{
-+ struct acpi_device *adev;
-+ struct pci_dev *root;
-+ acpi_handle handle;
-+ acpi_status status;
-+ u8 val;
-+
-+ /*
-+ * Look for _DSD property specifying that the storage device on the port
-+ * must use D3 to support deep platform power savings during
-+ * suspend-to-idle.
-+ */
-+ root = pcie_find_root_port(dev);
-+ if (!root)
-+ return false;
-+
-+ adev = ACPI_COMPANION(&root->dev);
-+ if (!adev)
-+ return false;
-+
-+ /*
-+ * The property is defined in the PXSX device for South complex ports
-+ * and in the PEGP device for North complex ports.
-+ */
-+ status = acpi_get_handle(adev->handle, "PXSX", &handle);
-+ if (ACPI_FAILURE(status)) {
-+ status = acpi_get_handle(adev->handle, "PEGP", &handle);
-+ if (ACPI_FAILURE(status))
-+ return false;
-+ }
-+
-+ if (acpi_bus_get_device(handle, &adev))
-+ return false;
-+
-+ if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
-+ &val))
-+ return false;
-+ return val == 1;
-+}
-+#else
-+static inline bool nvme_acpi_storage_d3(struct pci_dev *dev)
-+{
-+ return false;
-+}
-+#endif /* CONFIG_ACPI */
-+
- static void nvme_async_probe(void *data, async_cookie_t cookie)
- {
- struct nvme_dev *dev = data;
-@@ -2871,6 +2924,16 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-
- quirks |= check_vendor_combination_bug(pdev);
-
-+ if (!noacpi && nvme_acpi_storage_d3(pdev)) {
-+ /*
-+ * Some systems use a bios work around to ask for D3 on
-+ * platforms that support kernel managed suspend.
-+ */
-+ dev_info(&pdev->dev,
-+ "platform quirk: setting simple suspend\n");
-+ quirks |= NVME_QUIRK_SIMPLE_SUSPEND;
-+ }
-+
- /*
- * Double check that our mempool alloc size will cover the biggest
- * command we support.
---
-2.43.0
-
+++ /dev/null
-From d488eb35bf24e2acbcb0c4da033107b1309a958a Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Fri, 28 May 2021 11:02:34 -0500
-Subject: nvme-pci: look for StorageD3Enable on companion ACPI device instead
-
-From: Mario Limonciello <mario.limonciello@amd.com>
-
-[ Upstream commit e21e0243e7b0f1c2a21d21f4d115f7b37175772a ]
-
-The documentation around the StorageD3Enable property hints that it
-should be made on the PCI device. This is where newer AMD systems set
-the property and it's required for S0i3 support.
-
-So rather than look for nodes of the root port only present on Intel
-systems, switch to the companion ACPI device for all systems.
-David Box from Intel indicated this should work on Intel as well.
-
-Link: https://lore.kernel.org/linux-nvme/YK6gmAWqaRmvpJXb@google.com/T/#m900552229fa455867ee29c33b854845fce80ba70
-Link: https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/power-management-for-storage-hardware-devices-intro
-Fixes: df4f9bc4fb9c ("nvme-pci: add support for ACPI StorageD3Enable property")
-Suggested-by: Liang Prike <Prike.Liang@amd.com>
-Acked-by: Raul E Rangel <rrangel@chromium.org>
-Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
-Reviewed-by: David E. Box <david.e.box@linux.intel.com>
-Signed-off-by: Christoph Hellwig <hch@lst.de>
-Stable-dep-of: e79a10652bbd ("ACPI: x86: Force StorageD3Enable on more products")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- drivers/nvme/host/pci.c | 24 +-----------------------
- 1 file changed, 1 insertion(+), 23 deletions(-)
-
-diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
-index db81403a4286c..58aad5e03d045 100644
---- a/drivers/nvme/host/pci.c
-+++ b/drivers/nvme/host/pci.c
-@@ -2832,10 +2832,7 @@ static unsigned long check_vendor_combination_bug(struct pci_dev *pdev)
- #ifdef CONFIG_ACPI
- static bool nvme_acpi_storage_d3(struct pci_dev *dev)
- {
-- struct acpi_device *adev;
-- struct pci_dev *root;
-- acpi_handle handle;
-- acpi_status status;
-+ struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
- u8 val;
-
- /*
-@@ -2843,28 +2840,9 @@ static bool nvme_acpi_storage_d3(struct pci_dev *dev)
- * must use D3 to support deep platform power savings during
- * suspend-to-idle.
- */
-- root = pcie_find_root_port(dev);
-- if (!root)
-- return false;
-
-- adev = ACPI_COMPANION(&root->dev);
- if (!adev)
- return false;
--
-- /*
-- * The property is defined in the PXSX device for South complex ports
-- * and in the PEGP device for North complex ports.
-- */
-- status = acpi_get_handle(adev->handle, "PXSX", &handle);
-- if (ACPI_FAILURE(status)) {
-- status = acpi_get_handle(adev->handle, "PEGP", &handle);
-- if (ACPI_FAILURE(status))
-- return false;
-- }
--
-- if (acpi_bus_get_device(handle, &adev))
-- return false;
--
- if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
- &val))
- return false;
---
-2.43.0
-
wifi-iwlwifi-mvm-revert-gen2-tx-a-mpdu-size-to-64.patch
wifi-iwlwifi-dbg_ini-move-iwl_dbg_tlv_free-outside-o.patch
wifi-iwlwifi-mvm-don-t-read-past-the-mfuart-notifcat.patch
-nl80211-extend-support-to-config-spatial-reuse-param.patch
-wifi-mac80211-correctly-parse-spatial-reuse-paramete.patch
ipv6-sr-block-bh-in-seg6_output_core-and-seg6_input_.patch
net-sched-sch_multiq-fix-possible-oob-write-in-multi.patch
vxlan-fix-regression-when-dropping-packets-due-to-in.patch
af_unix-annotate-data-races-around-sk-sk_state-in-un.patch-4923
af_unix-annotate-data-race-of-net-unx.sysctl_max_dgr.patch
af_unix-use-unix_recvq_full_lockless-in-unix_stream_.patch
-arm64-dts-agilex-add-nand-ip-to-base-dts.patch
af_unix-use-skb_queue_len_lockless-in-sk_diag_show_r.patch
af_unix-annotate-data-race-of-sk-sk_shutdown-in-sk_d.patch
ipv6-fix-possible-race-in-__fib6_drop_pcpu_from.patch
drm-amd-display-handle-y-carry-over-in-vcp-x.y-calcu.patch
serial-sc16is7xx-replace-hardcoded-divisor-value-wit.patch
serial-sc16is7xx-fix-bug-in-sc16is7xx_set_baud-when-.patch
-drivers-core-reindent-a-couple-uses-around-sysfs_emi.patch
-mmc-davinci_mmc-convert-to-platform-remove-callback-.patch
-mmc-davinci-don-t-strip-remove-function-when-driver-.patch
selftests-mm-compaction_test-fix-incorrect-write-of-.patch
selftests-mm-conform-test-to-tap-format-output.patch
selftests-mm-log-a-consistent-test-name-for-check_co.patch
input-try-trimming-too-long-modalias-strings.patch
sunrpc-return-proper-error-from-gss_wrap_req_priv.patch
gpio-tqmx86-fix-typo-in-kconfig-label.patch
-bitops-introduce-the-for_each_set_clump8-macro.patch
hid-core-remove-unnecessary-warn_on-in-implement.patch
iommu-amd-use-4k-page-for-completion-wait-write-back.patch
iommu-amd-introduce-pci-segment-structure.patch
greybus-fix-use-after-free-bug-in-gb_interface_release-due-to-race-condition.patch
usb-storage-alauda-check-whether-the-media-is-initia.patch
i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch
-i2c-designware-detect-the-fifo-size-in-the-common-co.patch
-i2c-designware-discard-i2c_dw_read_comp_param-functi.patch
-i2c-core-provide-generic-definitions-for-bus-frequen.patch
-i2c-drivers-use-generic-definitions-for-bus-frequenc.patch
-i2c-designware-move-configuration-routines-to-respec.patch
-i2c-designware-fix-the-functionality-flags-of-the-sl.patch
rcutorture-fix-rcu_torture_one_read-pipe_count-overf.patch
selftests-bpf-prevent-client-connect-before-server-b.patch
batman-adv-bypass-empty-buckets-in-batadv_purge_orig.patch
arm-dts-samsung-smdkv310-fix-keypad-no-autorepeat.patch
arm-dts-samsung-exynos4412-origen-fix-keypad-no-auto.patch
arm-dts-samsung-smdk4412-fix-keypad-no-autorepeat.patch
-acpi-utils-introduce-acpi_dev_hid_uid_match-helper.patch
-mmc-sdhci-acpi-switch-to-use-acpi_dev_hid_uid_match.patch
-mmc-sdhci-acpi-switch-signal-voltage-back-to-3.3v-on.patch
-mmc-sdhci-acpi-disable-write-protect-detection-on-ac.patch
-mmc-sdhci-acpi-disable-write-protect-detection-on-to.patch
-mmc-sdhci-acpi-sort-dmi-quirks-alphabetically.patch
-mmc-sdhci-acpi-disable-write-protect-detection-on-to.patch-21681
arm64-dts-qcom-qcs404-fix-bluetooth-device-address.patch
s390-cpacf-make-use-of-invalid-opcode-produce-a-link.patch
tracing-add-module_description-to-preemptirq_delay_t.patch
iio-dac-ad5592r-base-replace-indio_dev-mlock-with-ow.patch
iio-dac-ad5592r-un-indent-code-block-for-scale-read.patch
iio-dac-ad5592r-fix-temperature-channel-scaling-valu.patch
-mm-memblock-replace-dereferences-of-memblock_region..patch
-x86-mm-numa-use-numa_no_node-when-calling-memblock_s.patch
-nvme-pci-add-support-for-acpi-storaged3enable-proper.patch
-nvme-pci-look-for-storaged3enable-on-companion-acpi-.patch
-acpi-check-storaged3enable-_dsd-property-in-acpi-cod.patch
-acpi-add-quirks-for-amd-renoir-lucienne-cpus-to-forc.patch
-acpi-x86-add-a-quirk-for-dell-inspiron-14-2-in-1-for.patch
-acpi-x86-add-another-system-to-quirk-list-for-forcin.patch
-acpi-x86-utils-add-cezanne-to-the-list-for-forcing-s.patch
-acpi-x86-utils-add-picasso-to-the-list-for-forcing-s.patch
-acpi-x86-force-storaged3enable-on-more-products.patch
pinctrl-fix-deadlock-in-create_pinctrl-when-handling.patch
pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio2-b-.patch
pinctrl-rockchip-fix-pinmux-bits-for-rk3328-gpio3-b-.patch
+++ /dev/null
-From d703a332b120f4e5908abfbebee77a405aa7f8c1 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Thu, 16 May 2024 10:18:54 +0800
-Subject: wifi: mac80211: correctly parse Spatial Reuse Parameter Set element
-
-From: Lingbo Kong <quic_lingbok@quicinc.com>
-
-[ Upstream commit a26d8dc5227f449a54518a8b40733a54c6600a8b ]
-
-Currently, the way of parsing Spatial Reuse Parameter Set element is
-incorrect and some members of struct ieee80211_he_obss_pd are not assigned.
-
-To address this issue, it must be parsed in the order of the elements of
-Spatial Reuse Parameter Set defined in the IEEE Std 802.11ax specification.
-
-The diagram of the Spatial Reuse Parameter Set element (IEEE Std 802.11ax
--2021-9.4.2.252).
-
--------------------------------------------------------------------------
-| | | | |Non-SRG| SRG | SRG | SRG | SRG |
-|Element|Length| Element | SR |OBSS PD|OBSS PD|OBSS PD| BSS |Partial|
-| ID | | ID |Control| Max | Min | Max |Color | BSSID |
-| | |Extension| | Offset| Offset|Offset |Bitmap|Bitmap |
--------------------------------------------------------------------------
-
-Fixes: 1ced169cc1c2 ("mac80211: allow setting spatial reuse parameters from bss_conf")
-Signed-off-by: Lingbo Kong <quic_lingbok@quicinc.com>
-Link: https://msgid.link/20240516021854.5682-3-quic_lingbok@quicinc.com
-Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- net/mac80211/he.c | 10 ++++++++--
- 1 file changed, 8 insertions(+), 2 deletions(-)
-
-diff --git a/net/mac80211/he.c b/net/mac80211/he.c
-index 736da0035135a..398cf8a7ebd91 100644
---- a/net/mac80211/he.c
-+++ b/net/mac80211/he.c
-@@ -78,15 +78,21 @@ ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif,
-
- if (!he_spr_ie_elem)
- return;
-+
-+ he_obss_pd->sr_ctrl = he_spr_ie_elem->he_sr_control;
- data = he_spr_ie_elem->optional;
-
- if (he_spr_ie_elem->he_sr_control &
- IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)
-- data++;
-+ he_obss_pd->non_srg_max_offset = *data++;
-+
- if (he_spr_ie_elem->he_sr_control &
- IEEE80211_HE_SPR_SRG_INFORMATION_PRESENT) {
-- he_obss_pd->max_offset = *data++;
- he_obss_pd->min_offset = *data++;
-+ he_obss_pd->max_offset = *data++;
-+ memcpy(he_obss_pd->bss_color_bitmap, data, 8);
-+ data += 8;
-+ memcpy(he_obss_pd->partial_bssid_bitmap, data, 8);
- he_obss_pd->enable = true;
- }
- }
---
-2.43.0
-
+++ /dev/null
-From c301d88e8887294170e6809c9d9410a3e4a95c16 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 29 May 2024 09:42:05 +0200
-Subject: x86/mm/numa: Use NUMA_NO_NODE when calling memblock_set_node()
-
-From: Jan Beulich <jbeulich@suse.com>
-
-[ Upstream commit 3ac36aa7307363b7247ccb6f6a804e11496b2b36 ]
-
-memblock_set_node() warns about using MAX_NUMNODES, see
-
- e0eec24e2e19 ("memblock: make memblock_set_node() also warn about use of MAX_NUMNODES")
-
-for details.
-
-Reported-by: Narasimhan V <Narasimhan.V@amd.com>
-Signed-off-by: Jan Beulich <jbeulich@suse.com>
-Cc: stable@vger.kernel.org
-[bp: commit message]
-Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
-Reviewed-by: Mike Rapoport (IBM) <rppt@kernel.org>
-Tested-by: Paul E. McKenney <paulmck@kernel.org>
-Link: https://lore.kernel.org/r/20240603141005.23261-1-bp@kernel.org
-Link: https://lore.kernel.org/r/abadb736-a239-49e4-ab42-ace7acdd4278@suse.com
-Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/mm/numa.c | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
-index bd52ce954d59a..badfa96aac320 100644
---- a/arch/x86/mm/numa.c
-+++ b/arch/x86/mm/numa.c
-@@ -504,7 +504,7 @@ static void __init numa_clear_kernel_node_hotplug(void)
- for_each_memblock(reserved, mb_region) {
- int nid = memblock_get_region_node(mb_region);
-
-- if (nid != MAX_NUMNODES)
-+ if (nid != NUMA_NO_NODE)
- node_set(nid, reserved_nodemask);
- }
-
-@@ -624,9 +624,9 @@ static int __init numa_init(int (*init_func)(void))
- nodes_clear(node_online_map);
- memset(&numa_meminfo, 0, sizeof(numa_meminfo));
- WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory,
-- MAX_NUMNODES));
-+ NUMA_NO_NODE));
- WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.reserved,
-- MAX_NUMNODES));
-+ NUMA_NO_NODE));
- /* In case that parsing SRAT failed. */
- WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX));
- numa_reset_distance();
---
-2.43.0
-