From 9e89cecc554c56f1841d9b966d4c1c485bd3592a Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Mon, 12 Oct 2026 17:19:54 -0400 Subject: [PATCH 1/7] clk: samsung: exynos-clkout: add the GS101 and GS201 pads GS101 and GS201 have two clock output pads, CLKOUT0 and CLKOUT1, each with its own PMU register (PAD_CTRL_CLKOUT0/1 at 0x3e80/0x3e84): bit 0 drives the clock onto the pad and bits 13:8 select its source, 0 being the TCXO. Google's downstream kernel uses CLKOUT1 as the reference clock of the NFC controller (google-modules/nfc st21nfc.c sets bit 0 while the device is open; soc/gs cal-if clkout_gs201.c selects the TCXO). The PMU on these SoCs only accepts writes through the secure monitor, so the pads cannot use the existing MMIO mux and gate. Register one gate per pad that goes through the PMU's regmap instead, parented to mux input 0 ("clkout0", the TCXO), and expose them as clocks 0 and 1 of the PMU node. The pads may feed devices that Linux doesn't describe, so they are marked CLK_IGNORE_UNUSED and left as the bootloader left them until a consumer enables them. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Derek Ross --- drivers/clk/samsung/clk-exynos-clkout.c | 161 ++++++++++++++++++++++-- 1 file changed, 149 insertions(+), 12 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c index 5f64d93b2f..73f9fa56cd 100644 --- a/drivers/clk/samsung/clk-exynos-clkout.c +++ b/drivers/clk/samsung/clk-exynos-clkout.c @@ -11,11 +11,13 @@ #include #include #include +#include #include #include #include #include #include +#include #define DRV_NAME "exynos-clkout" @@ -28,6 +30,25 @@ #define EXYNOS4_CLKOUT_MUX_MASK 0xf #define EXYNOS5_CLKOUT_MUX_MASK 0x1f +/* + * GS101 and GS201 have one PAD_CTRL_CLKOUTn register per output pad in the + * PMU, written through the PMU regmap (the PMU is secured on these SoCs). + * Bit 0 drives the clock onto the pad, bits 13:8 select the source; source 0 + * is the TCXO. + */ +#define GS101_CLKOUT_NR_CLKS 2 +#define GS101_PAD_CTRL_CLKOUT(n) (0x3e80 + 4 * (n)) +#define GS101_CLKOUT_SEL_MASK GENMASK(13, 8) +#define GS101_CLKOUT_EN BIT(0) + +struct exynos_clkout_pad { + struct clk_hw hw; + struct regmap *regmap; + unsigned int reg; +}; + +#define to_exynos_clkout_pad(_hw) container_of(_hw, struct exynos_clkout_pad, hw) + struct exynos_clkout { struct clk_gate gate; struct clk_mux mux; @@ -35,11 +56,13 @@ struct exynos_clkout { void __iomem *reg; struct device_node *np; u32 pmu_debug_save; + struct exynos_clkout_pad pads[GS101_CLKOUT_NR_CLKS]; struct clk_hw_onecell_data data; }; struct exynos_clkout_variant { u32 mux_mask; + bool pad_ctrl; }; static const struct exynos_clkout_variant exynos_clkout_exynos4 = { @@ -50,8 +73,18 @@ static const struct exynos_clkout_variant exynos_clkout_exynos5 = { .mux_mask = EXYNOS5_CLKOUT_MUX_MASK, }; +static const struct exynos_clkout_variant exynos_clkout_gs101 = { + .pad_ctrl = true, +}; + static const struct of_device_id exynos_clkout_ids[] = { { + .compatible = "google,gs101-pmu", + .data = &exynos_clkout_gs101, + }, { + .compatible = "google,gs201-pmu", + .data = &exynos_clkout_gs101, + }, { .compatible = "samsung,exynos3250-pmu", .data = &exynos_clkout_exynos4, }, { @@ -82,9 +115,9 @@ static const struct of_device_id exynos_clkout_ids[] = { * Device will be instantiated as child of PMU device without its own * device node. Therefore match compatibles against parent. */ -static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask) +static int exynos_clkout_match_parent_dev(struct device *dev, + const struct exynos_clkout_variant **variant) { - const struct exynos_clkout_variant *variant; const struct of_device_id *match; if (!dev->parent) { @@ -102,31 +135,122 @@ static int exynos_clkout_match_parent_dev(struct device *dev, u32 *mux_mask) dev_err(dev, "cannot match parent device\n"); return -EINVAL; } - variant = match->data; - - *mux_mask = variant->mux_mask; + *variant = match->data; return 0; } +static int exynos_clkout_pad_enable(struct clk_hw *hw) +{ + struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); + + /* Select the TCXO and drive it onto the pad. */ + return regmap_update_bits(pad->regmap, pad->reg, + GS101_CLKOUT_SEL_MASK | GS101_CLKOUT_EN, + GS101_CLKOUT_EN); +} + +static void exynos_clkout_pad_disable(struct clk_hw *hw) +{ + struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); + + regmap_clear_bits(pad->regmap, pad->reg, GS101_CLKOUT_EN); +} + +static int exynos_clkout_pad_is_enabled(struct clk_hw *hw) +{ + struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); + unsigned int val; + + if (regmap_read(pad->regmap, pad->reg, &val)) + return 0; + + return !!(val & GS101_CLKOUT_EN); +} + +static const struct clk_ops exynos_clkout_pad_ops = { + .enable = exynos_clkout_pad_enable, + .disable = exynos_clkout_pad_disable, + .is_enabled = exynos_clkout_pad_is_enabled, +}; + +/* + * GS101/GS201: one gate per pad, parented to mux input 0 (the TCXO, named + * "clkout0" in the PMU node). The pads may be in use by devices that Linux + * does not describe, so leave them as the bootloader left them until a + * consumer asks for them. + */ +static int exynos_clkout_pad_probe(struct platform_device *pdev, + struct exynos_clkout *clkout) +{ + struct device *dev = &pdev->dev; + struct clk_init_data init = {}; + const char *parent_name; + struct regmap *regmap; + struct clk *parent; + int ret, i; + + regmap = syscon_node_to_regmap(clkout->np); + if (IS_ERR(regmap)) + return dev_err_probe(dev, PTR_ERR(regmap), + "failed to get PMU regmap\n"); + + parent = of_clk_get_by_name(clkout->np, "clkout0"); + if (IS_ERR(parent)) + return dev_err_probe(dev, PTR_ERR(parent), + "failed to get TCXO clock\n"); + parent_name = __clk_get_name(parent); + + clkout->data.num = GS101_CLKOUT_NR_CLKS; + for (i = 0; i < GS101_CLKOUT_NR_CLKS; i++) { + struct exynos_clkout_pad *pad = &clkout->pads[i]; + char name[] = "pmu-clkoutX"; + + snprintf(name, sizeof(name), "pmu-clkout%d", i); + init.name = name; + init.ops = &exynos_clkout_pad_ops; + init.parent_names = &parent_name; + init.num_parents = 1; + init.flags = CLK_IGNORE_UNUSED; + + pad->regmap = regmap; + pad->reg = GS101_PAD_CTRL_CLKOUT(i); + pad->hw.init = &init; + + ret = devm_clk_hw_register(dev, &pad->hw); + if (ret) { + clk_put(parent); + return dev_err_probe(dev, ret, + "failed to register %s\n", name); + } + clkout->data.hws[i] = &pad->hw; + } + clk_put(parent); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, + &clkout->data); +} + static int exynos_clkout_probe(struct platform_device *pdev) { const char *parent_names[EXYNOS_CLKOUT_PARENTS]; + const struct exynos_clkout_variant *variant; struct clk *parents[EXYNOS_CLKOUT_PARENTS]; struct exynos_clkout *clkout; int parent_count, ret, i; - u32 mux_mask; + + ret = exynos_clkout_match_parent_dev(&pdev->dev, &variant); + if (ret) + return ret; clkout = devm_kzalloc(&pdev->dev, - struct_size(clkout, data.hws, EXYNOS_CLKOUT_NR_CLKS), + struct_size(clkout, data.hws, + variant->pad_ctrl ? GS101_CLKOUT_NR_CLKS : + EXYNOS_CLKOUT_NR_CLKS), GFP_KERNEL); if (!clkout) return -ENOMEM; - ret = exynos_clkout_match_parent_dev(&pdev->dev, &mux_mask); - if (ret) - return ret; - clkout->np = pdev->dev.of_node; if (!clkout->np) { /* @@ -138,6 +262,9 @@ static int exynos_clkout_probe(struct platform_device *pdev) platform_set_drvdata(pdev, clkout); + if (variant->pad_ctrl) + return exynos_clkout_pad_probe(pdev, clkout); + spin_lock_init(&clkout->slock); parent_count = 0; @@ -170,7 +297,7 @@ static int exynos_clkout_probe(struct platform_device *pdev) clkout->gate.lock = &clkout->slock; clkout->mux.reg = clkout->reg + EXYNOS_PMU_DEBUG_REG; - clkout->mux.mask = mux_mask; + clkout->mux.mask = variant->mux_mask; clkout->mux.shift = EXYNOS_CLKOUT_MUX_SHIFT; clkout->mux.lock = &clkout->slock; @@ -209,6 +336,10 @@ static void exynos_clkout_remove(struct platform_device *pdev) { struct exynos_clkout *clkout = platform_get_drvdata(pdev); + /* The GS101 pads are managed by devres. */ + if (!clkout->reg) + return; + of_clk_del_provider(clkout->np); clk_hw_unregister(clkout->data.hws[0]); iounmap(clkout->reg); @@ -218,6 +349,9 @@ static int __maybe_unused exynos_clkout_suspend(struct device *dev) { struct exynos_clkout *clkout = dev_get_drvdata(dev); + if (!clkout->reg) + return 0; + clkout->pmu_debug_save = readl(clkout->reg + EXYNOS_PMU_DEBUG_REG); return 0; @@ -227,6 +361,9 @@ static int __maybe_unused exynos_clkout_resume(struct device *dev) { struct exynos_clkout *clkout = dev_get_drvdata(dev); + if (!clkout->reg) + return 0; + writel(clkout->pmu_debug_save, clkout->reg + EXYNOS_PMU_DEBUG_REG); return 0; From 018411b032a3c25c6c40a2e06c7e7f5d2d7b075a Mon Sep 17 00:00:00 2001 From: Derek Ross Date: Mon, 12 Oct 2026 19:29:46 -0400 Subject: [PATCH 2/7] clk: samsung: exynos-clkout: let bring-up pick the GS101 pad polarity Google's sources disagree on PAD_CTRL_CLKOUTn bit 0: st21nfc.c sets it while the NFC device is open, the cal-if clkout code clears it to enable the clock. Add a writable parameter, gs101_pad_en_active_low, read at every enable, disable and is_enabled, so both can be tried in one boot, and pr_debug() the register after each change (a regmap read). Bring-up only: drop the parameter once a board settles the polarity. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Derek Ross --- drivers/clk/samsung/clk-exynos-clkout.c | 37 +++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c index 73f9fa56cd..5239033b43 100644 --- a/drivers/clk/samsung/clk-exynos-clkout.c +++ b/drivers/clk/samsung/clk-exynos-clkout.c @@ -49,6 +49,27 @@ struct exynos_clkout_pad { #define to_exynos_clkout_pad(_hw) container_of(_hw, struct exynos_clkout_pad, hw) +/* + * Google's sources disagree on bit 0: the NFC driver sets it to run the + * clock, the clock framework code clears it. Until a board proves one, + * let bring-up pick at run time. + */ +static bool gs101_pad_en_active_low; +module_param(gs101_pad_en_active_low, bool, 0644); +MODULE_PARM_DESC(gs101_pad_en_active_low, + "GS101/GS201 CLKOUT pads run with bit 0 clear (default: set)"); + +static void exynos_clkout_pad_trace(struct exynos_clkout_pad *pad, + const char *what) +{ + unsigned int val = 0; + int ret; + + ret = regmap_read(pad->regmap, pad->reg, &val); + pr_debug("%s: %s, PAD_CTRL 0x%x = 0x%08x (%d)\n", + clk_hw_get_name(&pad->hw), what, pad->reg, val, ret); +} + struct exynos_clkout { struct clk_gate gate; struct clk_mux mux; @@ -143,18 +164,24 @@ static int exynos_clkout_match_parent_dev(struct device *dev, static int exynos_clkout_pad_enable(struct clk_hw *hw) { struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); + int ret; /* Select the TCXO and drive it onto the pad. */ - return regmap_update_bits(pad->regmap, pad->reg, - GS101_CLKOUT_SEL_MASK | GS101_CLKOUT_EN, - GS101_CLKOUT_EN); + ret = regmap_update_bits(pad->regmap, pad->reg, + GS101_CLKOUT_SEL_MASK | GS101_CLKOUT_EN, + gs101_pad_en_active_low ? 0 : GS101_CLKOUT_EN); + exynos_clkout_pad_trace(pad, "enable"); + + return ret; } static void exynos_clkout_pad_disable(struct clk_hw *hw) { struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); - regmap_clear_bits(pad->regmap, pad->reg, GS101_CLKOUT_EN); + regmap_update_bits(pad->regmap, pad->reg, GS101_CLKOUT_EN, + gs101_pad_en_active_low ? GS101_CLKOUT_EN : 0); + exynos_clkout_pad_trace(pad, "disable"); } static int exynos_clkout_pad_is_enabled(struct clk_hw *hw) @@ -165,7 +192,7 @@ static int exynos_clkout_pad_is_enabled(struct clk_hw *hw) if (regmap_read(pad->regmap, pad->reg, &val)) return 0; - return !!(val & GS101_CLKOUT_EN); + return !!(val & GS101_CLKOUT_EN) != gs101_pad_en_active_low; } static const struct clk_ops exynos_clkout_pad_ops = { From bb6cf7006cca65ff97d23ecf879d4c3ecc8cee9e Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:30:48 -0643 Subject: [PATCH 3/7] dt-bindings: soc: samsung: exynos-pmu: describe Tensor G4's PMU clock The Tensor G4 PMU (google,zumapro-pmu) gates the NFC controller's reference clock pad, which clk-exynos-clkout provides like the Exynos CLKOUT clocks. Say what #clock-cells numbers there: clock 0 is that pad. Only the Pixel 9a's devicetree is known to use it, so this names Tensor G4 rather than google,zuma-pmu in general. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml b/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml index 2f273e9e5a..9cec4a1375 100644 --- a/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml +++ b/Documentation/devicetree/bindings/soc/samsung/exynos-pmu.yaml @@ -63,6 +63,10 @@ properties: '#clock-cells': const: 1 + description: + On the Exynos SoCs, one clock per CLKOUT mux input. On the Tensor G4 + PMU (google,zumapro-pmu), clock 0 is the NFC controller's reference + clock pad. clock-names: description: From 67529a00bad43895ce022e62ddd6be27b2254ad7 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:30:49 -0643 Subject: [PATCH 4/7] soc: samsung: exynos-pmu: zuma: allow the NFC clock pad register Tensor G4's NFC controller takes its reference clock from a PMU pad, PAD_CTRL 0x3e84, which clk-exynos-clkout drives through this regmap. zuma's access tables admit only the registers in use, so add that one. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/soc/samsung/gs101-pmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/soc/samsung/gs101-pmu.c b/drivers/soc/samsung/gs101-pmu.c index e357744d4a..9ee77754d0 100644 --- a/drivers/soc/samsung/gs101-pmu.c +++ b/drivers/soc/samsung/gs101-pmu.c @@ -342,6 +342,7 @@ const struct exynos_pmu_data gs101_pmu_data = { #define ZUMA_CLUSTER1_NONCPU_OUT 0x1520 #define ZUMA_CLUSTER1_NONCPU_INT_EN 0x1544 #define ZUMA_HSI0_STATUS 0x2a84 +#define ZUMA_PAD_CTRL_NFC_CLK 0x3e84 #define ZUMA_PHY_CTRL_UFS 0x3ec0 static const struct regmap_range zuma_pmu_registers[] = { @@ -360,6 +361,8 @@ static const struct regmap_range zuma_pmu_registers[] = { regmap_reg_range(ZUMA_PHY_CTRL_UFS, ZUMA_PHY_CTRL_UFS), /* a hint TF-A reads, not a status register: see zuma_pmu_regmap_init() */ regmap_reg_range(ZUMA_PMU_INFORM0, ZUMA_PMU_INFORM0), + /* Tensor G4's NFC reference clock pad, a clock of clk-exynos-clkout */ + regmap_reg_range(ZUMA_PAD_CTRL_NFC_CLK, ZUMA_PAD_CTRL_NFC_CLK), }; static const struct regmap_range zuma_pmu_ro_registers[] = { From b642e6cf06b9e13e6fedfbcd72b01202e55a1393 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:30:49 -0643 Subject: [PATCH 5/7] clk: samsung: exynos-clkout: add Tensor G4's NFC clock pad The Pixel 9a's NFC controller (an ST54L) asks the SoC for its reference clock on a clock request line, which the PMU follows only once EXTPAD_EN, bit 16 of PMU register 0x3e84, is set; Google's st21nfc driver sets it from its devicetree (pmu_clk_pad = <0x3e84>, st,extpad_control_en). Without it the controller does not ACK its I2C address. Provide that bit as clock 0 of the google,zumapro-pmu node, beside the GS101 and GS201 pads. The pads' register, enable bit and source field move from constants into per-variant descriptors, since this pad has a different register and bit and no source field we know of; the GS101 pads keep their bring-up polarity parameter, which does not apply here. A PMU node that names no clkout0 gets its pads as root clocks, since this register's source is not described. The register and bit were proven on the Pixel 9a with an earlier provider inside the PMU driver (7.3.0-rc6-omamobile-tegu-s2mpg15-m1, the NFC node's clocks = <&pmu_system_controller 0>): nxp-nci's probe enabled the clock and the controller answered CORE_RESET and polled, with nothing else touching the pad. This driver's version has only been compiled so far. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/clk/samsung/clk-exynos-clkout.c | 142 ++++++++++++++++++------ 1 file changed, 107 insertions(+), 35 deletions(-) diff --git a/drivers/clk/samsung/clk-exynos-clkout.c b/drivers/clk/samsung/clk-exynos-clkout.c index 5239033b43..cd3d09151a 100644 --- a/drivers/clk/samsung/clk-exynos-clkout.c +++ b/drivers/clk/samsung/clk-exynos-clkout.c @@ -36,15 +36,35 @@ * Bit 0 drives the clock onto the pad, bits 13:8 select the source; source 0 * is the TCXO. */ -#define GS101_CLKOUT_NR_CLKS 2 #define GS101_PAD_CTRL_CLKOUT(n) (0x3e80 + 4 * (n)) #define GS101_CLKOUT_SEL_MASK GENMASK(13, 8) #define GS101_CLKOUT_EN BIT(0) +/* + * Tensor G4 (zumapro) feeds the NFC controller's reference clock from a PMU + * pad as well. With EXTPAD_EN set the PMU follows the controller's clock + * request line and drives the clock onto the pad, which is how Google's + * st21nfc driver runs it (pmu_clk_pad = <0x3e84>, st,extpad_control_en); + * without it the Pixel 9a's ST54L does not ACK its I2C address. Nothing + * else about this register is known, so its source field is left alone. + */ +#define ZUMAPRO_PAD_CTRL_NFC_CLK 0x3e84 +#define ZUMAPRO_CLKOUT_EXTPAD_EN BIT(16) + +#define EXYNOS_CLKOUT_MAX_PADS 2 + +/* A pad's register, the bit that puts the clock on it and the source field. */ +struct exynos_clkout_pad_desc { + unsigned int reg; + u32 en; + u32 sel_mask; +}; + struct exynos_clkout_pad { struct clk_hw hw; struct regmap *regmap; - unsigned int reg; + const struct exynos_clkout_pad_desc *desc; + bool en_bringup; }; #define to_exynos_clkout_pad(_hw) container_of(_hw, struct exynos_clkout_pad, hw) @@ -65,9 +85,15 @@ static void exynos_clkout_pad_trace(struct exynos_clkout_pad *pad, unsigned int val = 0; int ret; - ret = regmap_read(pad->regmap, pad->reg, &val); + ret = regmap_read(pad->regmap, pad->desc->reg, &val); pr_debug("%s: %s, PAD_CTRL 0x%x = 0x%08x (%d)\n", - clk_hw_get_name(&pad->hw), what, pad->reg, val, ret); + clk_hw_get_name(&pad->hw), what, pad->desc->reg, val, ret); +} + +/* Only the GS101 pads' bit 0 is still being settled by bring-up. */ +static bool exynos_clkout_pad_active_low(struct exynos_clkout_pad *pad) +{ + return pad->en_bringup && gs101_pad_en_active_low; } struct exynos_clkout { @@ -77,13 +103,15 @@ struct exynos_clkout { void __iomem *reg; struct device_node *np; u32 pmu_debug_save; - struct exynos_clkout_pad pads[GS101_CLKOUT_NR_CLKS]; + struct exynos_clkout_pad pads[EXYNOS_CLKOUT_MAX_PADS]; struct clk_hw_onecell_data data; }; struct exynos_clkout_variant { u32 mux_mask; - bool pad_ctrl; + const struct exynos_clkout_pad_desc *pads; + unsigned int nr_pads; + bool pad_en_bringup; }; static const struct exynos_clkout_variant exynos_clkout_exynos4 = { @@ -94,8 +122,38 @@ static const struct exynos_clkout_variant exynos_clkout_exynos5 = { .mux_mask = EXYNOS5_CLKOUT_MUX_MASK, }; +static const struct exynos_clkout_pad_desc exynos_clkout_gs101_pads[] = { + { + .reg = GS101_PAD_CTRL_CLKOUT(0), + .en = GS101_CLKOUT_EN, + .sel_mask = GS101_CLKOUT_SEL_MASK, + }, { + .reg = GS101_PAD_CTRL_CLKOUT(1), + .en = GS101_CLKOUT_EN, + .sel_mask = GS101_CLKOUT_SEL_MASK, + }, +}; + +static_assert(ARRAY_SIZE(exynos_clkout_gs101_pads) <= EXYNOS_CLKOUT_MAX_PADS); + static const struct exynos_clkout_variant exynos_clkout_gs101 = { - .pad_ctrl = true, + .pads = exynos_clkout_gs101_pads, + .nr_pads = ARRAY_SIZE(exynos_clkout_gs101_pads), + .pad_en_bringup = true, +}; + +static const struct exynos_clkout_pad_desc exynos_clkout_zumapro_pads[] = { + { + .reg = ZUMAPRO_PAD_CTRL_NFC_CLK, + .en = ZUMAPRO_CLKOUT_EXTPAD_EN, + }, +}; + +static_assert(ARRAY_SIZE(exynos_clkout_zumapro_pads) <= EXYNOS_CLKOUT_MAX_PADS); + +static const struct exynos_clkout_variant exynos_clkout_zumapro = { + .pads = exynos_clkout_zumapro_pads, + .nr_pads = ARRAY_SIZE(exynos_clkout_zumapro_pads), }; static const struct of_device_id exynos_clkout_ids[] = { @@ -105,6 +163,9 @@ static const struct of_device_id exynos_clkout_ids[] = { }, { .compatible = "google,gs201-pmu", .data = &exynos_clkout_gs101, + }, { + .compatible = "google,zumapro-pmu", + .data = &exynos_clkout_zumapro, }, { .compatible = "samsung,exynos3250-pmu", .data = &exynos_clkout_exynos4, @@ -164,12 +225,13 @@ static int exynos_clkout_match_parent_dev(struct device *dev, static int exynos_clkout_pad_enable(struct clk_hw *hw) { struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); + const struct exynos_clkout_pad_desc *desc = pad->desc; int ret; - /* Select the TCXO and drive it onto the pad. */ - ret = regmap_update_bits(pad->regmap, pad->reg, - GS101_CLKOUT_SEL_MASK | GS101_CLKOUT_EN, - gs101_pad_en_active_low ? 0 : GS101_CLKOUT_EN); + /* Select the TCXO (where the pad has a source field) and drive it. */ + ret = regmap_update_bits(pad->regmap, desc->reg, + desc->sel_mask | desc->en, + exynos_clkout_pad_active_low(pad) ? 0 : desc->en); exynos_clkout_pad_trace(pad, "enable"); return ret; @@ -179,8 +241,8 @@ static void exynos_clkout_pad_disable(struct clk_hw *hw) { struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); - regmap_update_bits(pad->regmap, pad->reg, GS101_CLKOUT_EN, - gs101_pad_en_active_low ? GS101_CLKOUT_EN : 0); + regmap_update_bits(pad->regmap, pad->desc->reg, pad->desc->en, + exynos_clkout_pad_active_low(pad) ? pad->desc->en : 0); exynos_clkout_pad_trace(pad, "disable"); } @@ -189,10 +251,10 @@ static int exynos_clkout_pad_is_enabled(struct clk_hw *hw) struct exynos_clkout_pad *pad = to_exynos_clkout_pad(hw); unsigned int val; - if (regmap_read(pad->regmap, pad->reg, &val)) + if (regmap_read(pad->regmap, pad->desc->reg, &val)) return 0; - return !!(val & GS101_CLKOUT_EN) != gs101_pad_en_active_low; + return !!(val & pad->desc->en) != exynos_clkout_pad_active_low(pad); } static const struct clk_ops exynos_clkout_pad_ops = { @@ -202,17 +264,19 @@ static const struct clk_ops exynos_clkout_pad_ops = { }; /* - * GS101/GS201: one gate per pad, parented to mux input 0 (the TCXO, named - * "clkout0" in the PMU node). The pads may be in use by devices that Linux - * does not describe, so leave them as the bootloader left them until a - * consumer asks for them. + * GS101/GS201 and Tensor G4: one gate per pad, parented to mux input 0 (the + * TCXO, named "clkout0" in the PMU node) where the PMU node names it; a pad + * whose source the node does not describe is a root clock. The pads may be + * in use by devices that Linux does not describe, so leave them as the + * bootloader left them until a consumer asks for them. */ static int exynos_clkout_pad_probe(struct platform_device *pdev, - struct exynos_clkout *clkout) + struct exynos_clkout *clkout, + const struct exynos_clkout_variant *variant) { struct device *dev = &pdev->dev; struct clk_init_data init = {}; - const char *parent_name; + const char *parent_name = NULL; struct regmap *regmap; struct clk *parent; int ret, i; @@ -222,26 +286,35 @@ static int exynos_clkout_pad_probe(struct platform_device *pdev, return dev_err_probe(dev, PTR_ERR(regmap), "failed to get PMU regmap\n"); - parent = of_clk_get_by_name(clkout->np, "clkout0"); - if (IS_ERR(parent)) - return dev_err_probe(dev, PTR_ERR(parent), - "failed to get TCXO clock\n"); - parent_name = __clk_get_name(parent); + /* + * Only a PMU node that names "clkout0" has a parent: without + * clock-names at all of_clk_get_by_name() returns -EINVAL, not + * -ENOENT, so look for the name first. + */ + parent = NULL; + if (of_property_match_string(clkout->np, "clock-names", "clkout0") >= 0) { + parent = of_clk_get_by_name(clkout->np, "clkout0"); + if (IS_ERR(parent)) + return dev_err_probe(dev, PTR_ERR(parent), + "failed to get TCXO clock\n"); + parent_name = __clk_get_name(parent); + } - clkout->data.num = GS101_CLKOUT_NR_CLKS; - for (i = 0; i < GS101_CLKOUT_NR_CLKS; i++) { + clkout->data.num = variant->nr_pads; + for (i = 0; i < variant->nr_pads; i++) { struct exynos_clkout_pad *pad = &clkout->pads[i]; char name[] = "pmu-clkoutX"; snprintf(name, sizeof(name), "pmu-clkout%d", i); init.name = name; init.ops = &exynos_clkout_pad_ops; - init.parent_names = &parent_name; - init.num_parents = 1; + init.parent_names = parent ? &parent_name : NULL; + init.num_parents = parent ? 1 : 0; init.flags = CLK_IGNORE_UNUSED; pad->regmap = regmap; - pad->reg = GS101_PAD_CTRL_CLKOUT(i); + pad->desc = &variant->pads[i]; + pad->en_bringup = variant->pad_en_bringup; pad->hw.init = &init; ret = devm_clk_hw_register(dev, &pad->hw); @@ -272,8 +345,7 @@ static int exynos_clkout_probe(struct platform_device *pdev) clkout = devm_kzalloc(&pdev->dev, struct_size(clkout, data.hws, - variant->pad_ctrl ? GS101_CLKOUT_NR_CLKS : - EXYNOS_CLKOUT_NR_CLKS), + variant->nr_pads ?: EXYNOS_CLKOUT_NR_CLKS), GFP_KERNEL); if (!clkout) return -ENOMEM; @@ -289,8 +361,8 @@ static int exynos_clkout_probe(struct platform_device *pdev) platform_set_drvdata(pdev, clkout); - if (variant->pad_ctrl) - return exynos_clkout_pad_probe(pdev, clkout); + if (variant->nr_pads) + return exynos_clkout_pad_probe(pdev, clkout, variant); spin_lock_init(&clkout->slock); From 6445b209bf2a157eedc91a21709d89dffdd1ca6e Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:09:59 -0647 Subject: [PATCH 6/7] dt-bindings: net: nfc: nxp,nci: Allow a reference clock Some boards gate the controller's reference clock, or the SoC pad it comes from, in a clock provider: the Pixel 9a's ST54L takes its clock from a pad the PMU enables. Allow one clock. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml b/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml index fbf2b14f69..a1d4603a57 100644 --- a/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml +++ b/Documentation/devicetree/bindings/net/nfc/nxp,nci.yaml @@ -26,6 +26,11 @@ properties: - st,st54l - const: nxp,nxp-nci-i2c + clocks: + maxItems: 1 + description: The controller's reference clock, or the SoC clock pad + that feeds it on the controller's request + enable-gpios: description: Output GPIO pin used for enabling/disabling the controller From a6de6287f0078c920b4008eea0cb0ceabfc5238c Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:09:59 -0647 Subject: [PATCH 7/7] nfc: nxp-nci: i2c: Enable an optional reference clock Take an optional clock and keep it enabled while the device is bound, for boards whose controller clock (or the pad it comes from) is gated: the Pixel 9a's ST54L needs the PMU's NFC clock pad. Tested on the Pixel 9a: the clock is enabled at probe and the controller answers and polls. Signed-off-by: W4HO <87742609+W4HO-ham@users.noreply.github.com> --- drivers/nfc/nxp-nci/i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c index 92ce096e9b..6d81a97784 100644 --- a/drivers/nfc/nxp-nci/i2c.c +++ b/drivers/nfc/nxp-nci/i2c.c @@ -13,6 +13,7 @@ */ #include +#include #include #include #include @@ -277,6 +278,7 @@ static int nxp_nci_i2c_probe(struct i2c_client *client) struct device *dev = &client->dev; struct nxp_nci_i2c_phy *phy; unsigned long irqflags; + struct clk *clk; int r; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { @@ -308,6 +310,11 @@ static int nxp_nci_i2c_probe(struct i2c_client *client) return PTR_ERR(phy->gpiod_fw); } + /* a reference clock (or its pad's enable) the controller asks for */ + clk = devm_clk_get_optional_enabled(dev, NULL); + if (IS_ERR(clk)) + return dev_err_probe(dev, PTR_ERR(clk), "Failed to get the clock\n"); + r = nxp_nci_probe(phy, &client->dev, &i2c_phy_ops, NXP_NCI_I2C_MAX_PAYLOAD, &phy->ndev); if (r < 0)