[PATCH v2 2/3] iio: magnetometer: mmc5633: Enable the VDD supply

From: Gerard Marull-Paretas

Date: Sun Nov 22 2026 - 14:08:54 EST


Boards may switch the supply of the sensor, so get and enable it before
initialising the chip, and wait the 5 ms both parts need after VDD is
valid before they can be operated.

Signed-off-by: Gerard Marull-Paretas <gerard@xxxxxxxxxxx>
---
drivers/iio/magnetometer/mmc5633.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/iio/magnetometer/mmc5633.c b/drivers/iio/magnetometer/mmc5633.c
index b651f01e1b5d..79015c7984de 100644
--- a/drivers/iio/magnetometer/mmc5633.c
+++ b/drivers/iio/magnetometer/mmc5633.c
@@ -27,6 +27,7 @@
#include <linux/mutex.h>
#include <linux/pm.h>
#include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
#include <linux/time.h>
#include <linux/types.h>
#include <linux/unaligned.h>
@@ -64,6 +65,7 @@
#define MMC5633_CTRL1_BW_MASK GENMASK(1, 0)

#define MMC5633_WAIT_SET_RESET_US (1 * USEC_PER_MSEC)
+#define MMC5633_POWER_ON_US (5 * USEC_PER_MSEC)

#define MMC5633_HDR_CTRL0_MEAS_M 0x01
#define MMC5633_HDR_CTRL0_MEAS_T 0x03
@@ -472,6 +474,12 @@ static int mmc5633_common_probe(struct regmap *regmap, char *name,
if (ret)
return ret;

+ ret = devm_regulator_get_enable(dev, "vdd");
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to enable VDD regulator\n");
+
+ fsleep(MMC5633_POWER_ON_US);
+
indio_dev->info = &mmc5633_info;
indio_dev->name = name;
indio_dev->channels = mmc5633_channels;
--
2.45.2