Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,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
Expand Down
20 changes: 20 additions & 0 deletions arch/arm64/boot/dts/apple/s5l8960x-mini3.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <pmu 'GPIc' 0 0x79fb 0x49fb>, 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>;
};
};
25 changes: 24 additions & 1 deletion drivers/iio/imu/apple-oscar.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,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 struct oscar_variant *variant;
const char *fw_name;

Expand Down Expand Up @@ -836,6 +838,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;
Expand Down Expand Up @@ -977,6 +982,18 @@ static int oscar_boot(struct oscar *o, const u8 *image, size_t size)
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;
Expand Down Expand Up @@ -1146,6 +1163,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");
Expand Down
26 changes: 26 additions & 0 deletions drivers/regulator/apple-pmic-touch-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <pmu 'GPIc'
* 0 0x79fb 0x49fb>. 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,
Expand Down Expand Up @@ -392,6 +414,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,
Expand Down
Loading