From 53ecdbb2ce3c7442fc2efc0c6a34c1a5da929dbc Mon Sep 17 00:00:00 2001 From: en3r0 Date: Wed, 2 Dec 2026 15:41:42 -0500 Subject: [PATCH] iio: apple-oscar: switch on the PMIC 32 kHz clock on the iPad mini 3 The M7 firmware checks its 32 kHz clock at start and halts with "PMU 32kclk is not working" when it is off, so the M7 never answers and every accelerometer, gyroscope and compass read times out. Apple's device tree gives the iPad mini 3 (J85M) an oscar1_clock function, , and not the iPad mini 2. iOS 12.5.8's 'GPIc' applies mask 0xfb, value 0x49 (on) or 0x79 (off) to a PMIC register chosen by index 0. That mapping was not found in iOS; register 0x400 was inferred from a register dump (0x400 = 0x79, 0x401 = 0x49) and confirmed on hardware. Add a D2089 clock-output switch as a regulator, like the other M7 switches, and an optional clk32-supply on the M7 that the driver enables before the core supply and disables after it. Describe it in the mini 3 device tree. A clock provider would be the usual form for a PMIC clock output. Tested on one iPad mini 3 (J85M) in a RAM boot: oscar-clk32 registered and enabled, the M7 reported its firmware (AppleOscar1-41.200.1) and the accelerometer read about 1 g flat, with no module option. Not tested on the J86M or J87M, which share the device tree file, or the iPad mini 2. Assisted-by: LLM Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: en3r0 --- .../iio/imu/apple,s5l8960x-oscar.yaml | 5 ++++ .../regulator/apple,pmic-touch-regulator.yaml | 1 + arch/arm64/boot/dts/apple/s5l8960x-mini3.dtsi | 20 ++++++++++++++ drivers/iio/imu/apple-oscar.c | 25 +++++++++++++++++- .../regulator/apple-pmic-touch-regulator.c | 26 +++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/imu/apple,s5l8960x-oscar.yaml b/Documentation/devicetree/bindings/iio/imu/apple,s5l8960x-oscar.yaml index f2006b2993e444..6527dd4e33d67b 100644 --- a/Documentation/devicetree/bindings/iio/imu/apple,s5l8960x-oscar.yaml +++ b/Documentation/devicetree/bindings/iio/imu/apple,s5l8960x-oscar.yaml @@ -30,6 +30,11 @@ properties: sensors-supply: description: Sensor supply (Apple's sensor_power). + clk32-supply: + description: + PMIC 32 kHz clock output the M7 runs from, where the PMIC does not have + it on already (Apple's oscar1_clock, on the iPad mini 3). + reset-gpios: maxItems: 1 diff --git a/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml b/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml index 69f0c5c6c560bc..fb3146151e5928 100644 --- a/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/apple,pmic-touch-regulator.yaml @@ -27,6 +27,7 @@ properties: - apple,antigua-touch-core-regulator - apple,august-touch-analog-regulator - apple,chestnut-touch-hv-regulator + - apple,d2089-oscar-clk32-regulator - apple,d2089-oscar-core-regulator - apple,d2089-oscar-io-regulator - apple,d2089-oscar-sensors-regulator diff --git a/arch/arm64/boot/dts/apple/s5l8960x-mini3.dtsi b/arch/arm64/boot/dts/apple/s5l8960x-mini3.dtsi index 4e397b3d7d7ad3..e23723c3a2bf9f 100644 --- a/arch/arm64/boot/dts/apple/s5l8960x-mini3.dtsi +++ b/arch/arm64/boot/dts/apple/s5l8960x-mini3.dtsi @@ -12,3 +12,23 @@ * to no differentiation between these 2 for now. */ #include "s5l8960x-mini2.dtsi" + +/* + * Apple's device tree gives the mini 3's M7 (not the mini 2's) a clock + * function, oscar1_clock = , which iOS applies to + * the PMIC's first 32 kHz clock output register (0x400, 0x79 off, 0x49 on) + * before it boots the M7. This PMIC leaves it off; the M7 firmware halts with + * "PMU 32kclk is not working" until it is on. + */ +&{/soc/i2c@20a110000/pmic@3c} { + oscar_clk32: regulator-oscar-clk32 { + compatible = "apple,d2089-oscar-clk32-regulator"; + regulator-name = "oscar-clk32"; + }; +}; + +&serial4 { + motion-coprocessor { + clk32-supply = <&oscar_clk32>; + }; +}; diff --git a/drivers/iio/imu/apple-oscar.c b/drivers/iio/imu/apple-oscar.c index 181ecf58d27e65..662886c7a71dbf 100644 --- a/drivers/iio/imu/apple-oscar.c +++ b/drivers/iio/imu/apple-oscar.c @@ -112,8 +112,10 @@ struct oscar { struct serdev_device *serdev; struct device *dev; struct regulator *core, *io, *sensors; + /* PMIC 32 kHz clock output, on boards whose PMIC leaves it off */ + struct regulator *clk32; struct gpio_desc *reset; - bool core_on, io_on, sensors_on; + bool core_on, io_on, sensors_on, clk32_on; const char *fw_name; spinlock_t lock; /* rx state, samples */ @@ -634,6 +636,9 @@ static void oscar_power_off(struct oscar *o) regulator_disable(o->io); if (o->core_on) regulator_disable(o->core); + if (o->clk32_on) + regulator_disable(o->clk32); + o->clk32_on = false; o->sensors_on = false; o->io_on = false; o->core_on = false; @@ -659,6 +664,18 @@ static int oscar_boot(struct oscar *o, const struct firmware *fw) memset(o->line, 0, sizeof(o->line)); spin_unlock_irqrestore(&o->lock, flags); + /* + * The M7 firmware checks its 32 kHz clock at start and halts with + * "PMU 32kclk is not working" without it. Where the PMIC leaves that + * output off (the iPad mini 3), it has to be on before the M7 boots; + * the order against the supplies is not known from iOS, and untested. + */ + if (o->clk32) { + ret = regulator_enable(o->clk32); + if (ret) + goto fail; + o->clk32_on = true; + } ret = regulator_enable(o->core); if (ret) goto fail; @@ -800,6 +817,12 @@ static int oscar_probe(struct serdev_device *serdev) o->sensors = devm_regulator_get(dev, "sensors"); if (IS_ERR(o->sensors)) return dev_err_probe(dev, PTR_ERR(o->sensors), "sensors supply\n"); + o->clk32 = devm_regulator_get_optional(dev, "clk32"); + if (IS_ERR(o->clk32)) { + if (PTR_ERR(o->clk32) != -ENODEV) + return dev_err_probe(dev, PTR_ERR(o->clk32), "clk32 supply\n"); + o->clk32 = NULL; + } o->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(o->reset)) return dev_err_probe(dev, PTR_ERR(o->reset), "reset GPIO\n"); diff --git a/drivers/regulator/apple-pmic-touch-regulator.c b/drivers/regulator/apple-pmic-touch-regulator.c index 9676a7cbefdf5d..3d9ce60be9a8b2 100644 --- a/drivers/regulator/apple-pmic-touch-regulator.c +++ b/drivers/regulator/apple-pmic-touch-regulator.c @@ -96,6 +96,28 @@ static const struct regulator_desc apple_d2089_oscar_io = { .disable_val = 0, }; +/* + * The 32 kHz clock output the M7 runs from on the iPad mini 3: Apple's device + * tree gives that board (not the mini 2) function-oscar1_clock = . iOS 12.5.8's 'GPIc' function applies (mask 0xfb, value + * 0x49 on or 0x79 off) to a PMIC register that its index 0 selects. That + * index-to-register mapping was not found in iOS; register 0x400 (0x79 at + * boot, next to 0x401 at 0x49) was inferred from a register dump and + * confirmed on an iPad mini 3: with it at 0x49 the M7 boots, without it the + * firmware halts with "PMU 32kclk is not working". A clock provider would be + * the usual form for a PMIC clock output; this follows the other M7 switches. + */ +static const struct regulator_desc apple_d2089_oscar_clk32 = { + .name = "d2089-oscar-clk32", + .ops = &apple_pmic_touch_regulator_ops, + .type = REGULATOR_VOLTAGE, + .owner = THIS_MODULE, + .enable_reg = 0x400, + .enable_mask = 0xfb, + .enable_val = 0x49, + .disable_val = 0x79, +}; + static const struct regulator_desc apple_d2089_oscar_sensors = { .name = "d2089-oscar-sensors", .ops = &apple_pmic_touch_regulator_ops, @@ -325,6 +347,10 @@ static const struct of_device_id apple_pmic_touch_regulator_of_match[] = { .compatible = "apple,d2089-touch-core-regulator", .data = &apple_d2089_touch_core, }, + { + .compatible = "apple,d2089-oscar-clk32-regulator", + .data = &apple_d2089_oscar_clk32, + }, { .compatible = "apple,d2089-oscar-core-regulator", .data = &apple_d2089_oscar_core,