summaryrefslogtreecommitdiff
path: root/drivers/soc/apple
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-02-17 11:40:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-17 11:40:04 -0800
commit9b725d5959a1d9bb670ccdb23add45f0eaafefb5 (patch)
treee55a94fe0836bcebb1528d2c5bb8a9360a2b5edc /drivers/soc/apple
parent4e15e819710e3518ec28735a12e0f45b7550290d (diff)
parentdbeea86fecef7cf2b93aded4525d74f6277376ef (diff)
Merge tag 'phy-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy
Pull phy updates from Vinod Koul: "Core: - Add suuport for "rx-polarity" and "tx-polarity" device tree properties and phy common properties to manage this New Support: - Qualcomm Glymur PCIe Gen4 2-lanes PCIe phy, DP and edp phy, USB UNI PHY and SMB2370 eUSB2 repeater. SC8280xp QMP UFS PHY, Kaanapali PCIe phy and QMP PHY, QCS615 QMP USB3+DP PHY and driver support for that. - SpacemiT PCIe/combo PHY and K1 USB2 PHY driver. - HDMI 2.1 FRL configuration support and driver enabling for rockchip samsung-hdptx driver - TI TCAN1046 phy - Renesas RZ/V2H(P) and RZ/V2N usb3 - Mediatek MT8188 hdmi-phy - Google Tensor SoC USB PHY driver - Apple Type-C PHY Updates: - Subsystem conversion for clock round_rate() to determine_rate() - TI USB3 DT schema conversion - Samsung ExynosAutov920 usb3, combo hsphy and ssphy support" * tag 'phy-for-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy: (143 commits) phy: ti: phy-j721e-wiz: convert from divider_round_rate() to divider_determine_rate() dt-bindings: phy: ti,control-phy-otghs: convert to DT schema dt-bindings: phy: ti,phy-usb3: convert to DT schema phy: tegra: xusb: Remove unused powered_on variable phy: renesas: rcar-gen3-usb2: add regulator dependency phy: GOOGLE_USB: add TYPEC dependency phy: enter drivers/phy/Makefile even without CONFIG_GENERIC_PHY phy: renesas: rcar-gen3-usb2: Use mux-state for phyrst management phy: renesas: rcar-gen3-usb2: Add regulator for OTG VBUS control phy: renesas: rcar-gen3-usb2: Use devm_pm_runtime_enable() phy: renesas: rcar-gen3-usb2: Factor out VBUS control logic dt-bindings: phy: renesas,usb2-phy: Document RZ/G3E SoC dt-bindings: phy: renesas,usb2-phy: Document mux-states property dt-bindings: phy: renesas,usb2-phy: Document USB VBUS regulator phy: rockchip: samsung-hdptx: Add HDMI 2.1 FRL support phy: rockchip: samsung-hdptx: Extend rk_hdptx_phy_verify_hdmi_config() helper phy: rockchip: samsung-hdptx: Switch to driver specific HDMI config phy: rockchip: samsung-hdptx: Drop hw_rate driver data phy: rockchip: samsung-hdptx: Compute clk rate from PLL config phy: rockchip: samsung-hdptx: Cleanup *_cmn_init_seq lists ...
Diffstat (limited to 'drivers/soc/apple')
-rw-r--r--drivers/soc/apple/Kconfig4
-rw-r--r--drivers/soc/apple/Makefile3
-rw-r--r--drivers/soc/apple/tunable.c80
3 files changed, 87 insertions, 0 deletions
diff --git a/drivers/soc/apple/Kconfig b/drivers/soc/apple/Kconfig
index ad6736889231..d0ff32182a2b 100644
--- a/drivers/soc/apple/Kconfig
+++ b/drivers/soc/apple/Kconfig
@@ -38,6 +38,10 @@ config APPLE_SART
Say 'y' here if you have an Apple SoC.
+config APPLE_TUNABLE
+ tristate
+ depends on ARCH_APPLE || COMPILE_TEST
+
endmenu
endif
diff --git a/drivers/soc/apple/Makefile b/drivers/soc/apple/Makefile
index 4d9ab8f3037b..0b85ab61aefe 100644
--- a/drivers/soc/apple/Makefile
+++ b/drivers/soc/apple/Makefile
@@ -8,3 +8,6 @@ apple-rtkit-y = rtkit.o rtkit-crashlog.o
obj-$(CONFIG_APPLE_SART) += apple-sart.o
apple-sart-y = sart.o
+
+obj-$(CONFIG_APPLE_TUNABLE) += apple-tunable.o
+apple-tunable-y = tunable.o
diff --git a/drivers/soc/apple/tunable.c b/drivers/soc/apple/tunable.c
new file mode 100644
index 000000000000..659323839171
--- /dev/null
+++ b/drivers/soc/apple/tunable.c
@@ -0,0 +1,80 @@
+// SPDX-License-Identifier: GPL-2.0-only OR MIT
+/*
+ * Apple Silicon hardware tunable support
+ *
+ * Each tunable is a list with each entry containing a offset into the MMIO
+ * region, a mask of bits to be cleared and a set of bits to be set. These
+ * tunables are passed along by the previous boot stages and vary from device
+ * to device such that they cannot be hardcoded in the individual drivers.
+ *
+ * Copyright (C) The Asahi Linux Contributors
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/overflow.h>
+#include <linux/soc/apple/tunable.h>
+
+struct apple_tunable *devm_apple_tunable_parse(struct device *dev,
+ struct device_node *np,
+ const char *name,
+ struct resource *res)
+{
+ struct apple_tunable *tunable;
+ struct property *prop;
+ const __be32 *p;
+ size_t sz;
+ int i;
+
+ if (resource_size(res) < 4)
+ return ERR_PTR(-EINVAL);
+
+ prop = of_find_property(np, name, NULL);
+ if (!prop)
+ return ERR_PTR(-ENOENT);
+
+ if (prop->length % (3 * sizeof(u32)))
+ return ERR_PTR(-EINVAL);
+ sz = prop->length / (3 * sizeof(u32));
+
+ tunable = devm_kzalloc(dev, struct_size(tunable, values, sz), GFP_KERNEL);
+ if (!tunable)
+ return ERR_PTR(-ENOMEM);
+ tunable->sz = sz;
+
+ for (i = 0, p = NULL; i < tunable->sz; ++i) {
+ p = of_prop_next_u32(prop, p, &tunable->values[i].offset);
+ p = of_prop_next_u32(prop, p, &tunable->values[i].mask);
+ p = of_prop_next_u32(prop, p, &tunable->values[i].value);
+
+ /* Sanity checks to catch bugs in our bootloader */
+ if (tunable->values[i].offset % 4)
+ return ERR_PTR(-EINVAL);
+ if (tunable->values[i].offset > (resource_size(res) - 4))
+ return ERR_PTR(-EINVAL);
+ }
+
+ return tunable;
+}
+EXPORT_SYMBOL(devm_apple_tunable_parse);
+
+void apple_tunable_apply(void __iomem *regs, struct apple_tunable *tunable)
+{
+ size_t i;
+
+ for (i = 0; i < tunable->sz; ++i) {
+ u32 val, old_val;
+
+ old_val = readl(regs + tunable->values[i].offset);
+ val = old_val & ~tunable->values[i].mask;
+ val |= tunable->values[i].value;
+ if (val != old_val)
+ writel(val, regs + tunable->values[i].offset);
+ }
+}
+EXPORT_SYMBOL(apple_tunable_apply);
+
+MODULE_LICENSE("Dual MIT/GPL");
+MODULE_AUTHOR("Sven Peter <sven@kernel.org>");
+MODULE_DESCRIPTION("Apple Silicon hardware tunable support");