* [PATCH v6 1/4] dt-bindings: iio: magnetometer: Add MEMSIC MMC5603 and MMC5633
2026-12-03 16:56 [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Gerard Marull-Paretas
@ 2026-12-03 16:56 ` Gerard Marull-Paretas
2026-12-03 16:56 ` [PATCH v6 2/4] iio: magnetometer: mmc5633: Reference the datasheet for the SET/RESET wait Gerard Marull-Paretas
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Gerard Marull-Paretas @ 2026-12-03 16:56 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, Frank.li, andriy.shevchenko, linux-iio,
devicetree, linux-kernel
The MMC5603NJ and MMC5633NJL are listed in trivial-devices.yaml, which
allows no properties besides the register address and interrupts.
Boards need to describe how the sensor is oriented, and the supply it
runs from, which is often switched on wearables.
Give them a binding of their own, covering both the I2C and I3C
connections of the MMC5633NJL.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
---
.../iio/magnetometer/memsic,mmc5633.yaml | 61 +++++++++++++++++++
.../devicetree/bindings/trivial-devices.yaml | 4 --
2 files changed, 61 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/memsic,mmc5633.yaml
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/memsic,mmc5633.yaml b/Documentation/devicetree/bindings/iio/magnetometer/memsic,mmc5633.yaml
new file mode 100644
index 000000000000..423b8ecbb9e5
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/magnetometer/memsic,mmc5633.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/magnetometer/memsic,mmc5633.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MEMSIC MMC5603 and MMC5633 3-axis magnetic sensors
+
+maintainers:
+ - Gerard Marull-Paretas <gerard@teslabs.com>
+
+description:
+ The MMC5603NJ is connected over I2C, the MMC5633NJL over I2C or I3C.
+
+properties:
+ compatible:
+ enum:
+ - memsic,mmc5603
+ - memsic,mmc5633
+
+ reg:
+ maxItems: 1
+
+ vdd-supply: true
+
+ mount-matrix:
+ description: An optional 3x3 mounting rotation matrix.
+
+required:
+ - compatible
+ - reg
+
+additionalProperties: false
+
+examples:
+ - |
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ magnetometer@30 {
+ compatible = "memsic,mmc5603";
+ reg = <0x30>;
+ vdd-supply = <&vdd_1v8>;
+ mount-matrix = "-1", "0", "0",
+ "0", "1", "0",
+ "0", "0", "-1";
+ };
+ };
+
+ - |
+ i3c {
+ #address-cells = <3>;
+ #size-cells = <0>;
+
+ magnetometer@30,4a20000f000 {
+ compatible = "memsic,mmc5633";
+ reg = <0x30 0x4a2 0xf000>;
+ vdd-supply = <&vdd_1v8>;
+ };
+ };
diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml
index a8b2b9deade4..523c205c0880 100644
--- a/Documentation/devicetree/bindings/trivial-devices.yaml
+++ b/Documentation/devicetree/bindings/trivial-devices.yaml
@@ -261,10 +261,6 @@ properties:
- meas,tsys01
# MEMSIC magnetometer
- memsic,mmc35240
- # MEMSIC 3-axis magnetometer
- - memsic,mmc5603
- # MEMSIC 3-axis magnetometer (Support I3C HDR)
- - memsic,mmc5633
# MEMSIC 3-axis accelerometer
- memsic,mxc4005
# MEMSIC 2-axis 8-bit digital accelerometer
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v6 2/4] iio: magnetometer: mmc5633: Reference the datasheet for the SET/RESET wait
2026-12-03 16:56 [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Gerard Marull-Paretas
2026-12-03 16:56 ` [PATCH v6 1/4] dt-bindings: iio: magnetometer: Add MEMSIC MMC5603 and MMC5633 Gerard Marull-Paretas
@ 2026-12-03 16:56 ` Gerard Marull-Paretas
2026-12-03 16:56 ` [PATCH v6 3/4] iio: magnetometer: mmc5633: Enable the VDD supply Gerard Marull-Paretas
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Gerard Marull-Paretas @ 2026-12-03 16:56 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, Frank.li, andriy.shevchenko, linux-iio,
devicetree, linux-kernel
The 1 ms wait after a SET or RESET is tSR in the Operating Timing Diagram
section of both datasheets. Describe it where it is defined, with the
revision and page of each datasheet, in place of the comment at its use
that pointed at the datasheet without either.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
---
drivers/iio/magnetometer/mmc5633.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/magnetometer/mmc5633.c b/drivers/iio/magnetometer/mmc5633.c
index b651f01e1b5d..8142ba741ddc 100644
--- a/drivers/iio/magnetometer/mmc5633.c
+++ b/drivers/iio/magnetometer/mmc5633.c
@@ -63,6 +63,12 @@
#define MMC5633_CTRL1_BW_MASK GENMASK(1, 0)
+/*
+ * tSR, minimum time between SET or RESET and other operations, per
+ * Operating Timing Diagram section in
+ * - MMC5603NJ datasheet (Rev. B, page 15)
+ * - MMC5633NJL datasheet (Rev. A, page 23)
+ */
#define MMC5633_WAIT_SET_RESET_US (1 * USEC_PER_MSEC)
#define MMC5633_HDR_CTRL0_MEAS_M 0x01
@@ -144,10 +150,6 @@ static int mmc5633_init(struct mmc5633_data *data)
if (ret)
return ret;
- /*
- * Minimum time interval between SET or RESET to other operations is
- * 1ms according to Operating Timing Diagram in datasheet.
- */
fsleep(MMC5633_WAIT_SET_RESET_US);
ret = regmap_write(data->regmap, MMC5633_REG_CTRL0, MMC5633_CTRL0_RESET);
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v6 3/4] iio: magnetometer: mmc5633: Enable the VDD supply
2026-12-03 16:56 [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Gerard Marull-Paretas
2026-12-03 16:56 ` [PATCH v6 1/4] dt-bindings: iio: magnetometer: Add MEMSIC MMC5603 and MMC5633 Gerard Marull-Paretas
2026-12-03 16:56 ` [PATCH v6 2/4] iio: magnetometer: mmc5633: Reference the datasheet for the SET/RESET wait Gerard Marull-Paretas
@ 2026-12-03 16:56 ` Gerard Marull-Paretas
2026-12-03 16:56 ` [PATCH v6 4/4] iio: magnetometer: mmc5633: Add mount matrix support Gerard Marull-Paretas
2026-12-04 23:02 ` [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Jonathan Cameron
4 siblings, 0 replies; 8+ messages in thread
From: Gerard Marull-Paretas @ 2026-12-03 16:56 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, Frank.li, andriy.shevchenko, linux-iio,
devicetree, linux-kernel
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@teslabs.com>
---
drivers/iio/magnetometer/mmc5633.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/drivers/iio/magnetometer/mmc5633.c b/drivers/iio/magnetometer/mmc5633.c
index 8142ba741ddc..08bebc8eb5f6 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>
@@ -70,6 +71,13 @@
* - MMC5633NJL datasheet (Rev. A, page 23)
*/
#define MMC5633_WAIT_SET_RESET_US (1 * USEC_PER_MSEC)
+/*
+ * tOp, time to operate the device after VDD is valid, per
+ * Operating Timing Diagram section in
+ * - MMC5603NJ datasheet (Rev. B, page 15)
+ * - MMC5633NJL datasheet (Rev. A, page 23)
+ */
+#define MMC5633_POWER_ON_US (5 * USEC_PER_MSEC)
#define MMC5633_HDR_CTRL0_MEAS_M 0x01
#define MMC5633_HDR_CTRL0_MEAS_T 0x03
@@ -474,6 +482,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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v6 4/4] iio: magnetometer: mmc5633: Add mount matrix support
2026-12-03 16:56 [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Gerard Marull-Paretas
` (2 preceding siblings ...)
2026-12-03 16:56 ` [PATCH v6 3/4] iio: magnetometer: mmc5633: Enable the VDD supply Gerard Marull-Paretas
@ 2026-12-03 16:56 ` Gerard Marull-Paretas
2026-12-03 17:26 ` Andy Shevchenko
2026-12-04 23:02 ` [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Jonathan Cameron
4 siblings, 1 reply; 8+ messages in thread
From: Gerard Marull-Paretas @ 2026-12-03 16:56 UTC (permalink / raw)
To: jic23, robh, krzk+dt, conor+dt
Cc: dlechner, nuno.sa, andy, Frank.li, andriy.shevchenko, linux-iio,
devicetree, linux-kernel
Read the mount matrix from the firmware and expose it, so that user
space can account for how the sensor is oriented on the board.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
---
drivers/iio/magnetometer/mmc5633.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/iio/magnetometer/mmc5633.c b/drivers/iio/magnetometer/mmc5633.c
index 08bebc8eb5f6..26c99db1a13a 100644
--- a/drivers/iio/magnetometer/mmc5633.c
+++ b/drivers/iio/magnetometer/mmc5633.c
@@ -95,6 +95,7 @@ struct mmc5633_data {
struct regmap *regmap;
struct i3c_device *i3cdev;
struct mutex mutex; /* protect to finish one whole measurement */
+ struct iio_mount_matrix orientation;
};
static int mmc5633_samp_freq[][2] = {
@@ -104,6 +105,20 @@ static int mmc5633_samp_freq[][2] = {
{ 6, 600000 },
};
+static const struct iio_mount_matrix *
+mmc5633_get_mount_matrix(const struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan)
+{
+ struct mmc5633_data *data = iio_priv(indio_dev);
+
+ return &data->orientation;
+}
+
+static const struct iio_chan_spec_ext_info mmc5633_ext_info[] = {
+ IIO_MOUNT_MATRIX(IIO_SHARED_BY_DIR, mmc5633_get_mount_matrix),
+ { }
+};
+
#define MMC5633_CHANNEL(_axis) { \
.type = IIO_MAGN, \
.modified = 1, \
@@ -112,6 +127,7 @@ static int mmc5633_samp_freq[][2] = {
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
BIT(IIO_CHAN_INFO_SCALE), \
+ .ext_info = mmc5633_ext_info, \
}
static const struct iio_chan_spec mmc5633_channels[] = {
@@ -482,6 +498,10 @@ static int mmc5633_common_probe(struct regmap *regmap, char *name,
if (ret)
return ret;
+ ret = iio_read_mount_matrix(dev, &data->orientation);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to read mount matrix\n");
+
ret = devm_regulator_get_enable(dev, "vdd");
if (ret)
return dev_err_probe(dev, ret, "Failed to enable VDD regulator\n");
--
2.45.2
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v6 4/4] iio: magnetometer: mmc5633: Add mount matrix support
2026-12-03 16:56 ` [PATCH v6 4/4] iio: magnetometer: mmc5633: Add mount matrix support Gerard Marull-Paretas
@ 2026-12-03 17:26 ` Andy Shevchenko
2026-12-04 23:02 ` Jonathan Cameron
0 siblings, 1 reply; 8+ messages in thread
From: Andy Shevchenko @ 2026-12-03 17:26 UTC (permalink / raw)
To: Gerard Marull-Paretas
Cc: jic23, robh, krzk+dt, conor+dt, dlechner, nuno.sa, andy,
Frank.li, linux-iio, devicetree, linux-kernel
On Thu, Dec 03, 2026 at 05:56:54PM +0100, Gerard Marull-Paretas wrote:
> Read the mount matrix from the firmware and expose it, so that user
> space can account for how the sensor is oriented on the board.
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
While I reviewed that, the more generic Q still stands. Can we rather use IIO
opaque structure and move majority of this code to the IIO core as a helper for
drivers that want it? Jonathan, what do you think?
(It definitely does not affect this series, which is good as it go.)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v6 4/4] iio: magnetometer: mmc5633: Add mount matrix support
2026-12-03 17:26 ` Andy Shevchenko
@ 2026-12-04 23:02 ` Jonathan Cameron
0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-12-04 23:02 UTC (permalink / raw)
To: Andy Shevchenko, nuno.sa
Cc: Gerard Marull-Paretas, robh, krzk+dt, conor+dt, dlechner, andy,
Frank.li, linux-iio, devicetree, linux-kernel
On Thu, 3 Dec 2026 19:26:02 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Thu, Dec 03, 2026 at 05:56:54PM +0100, Gerard Marull-Paretas wrote:
> > Read the mount matrix from the firmware and expose it, so that user
> > space can account for how the sensor is oriented on the board.
>
> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
>
> While I reviewed that, the more generic Q still stands. Can we rather use IIO
> opaque structure and move majority of this code to the IIO core as a helper for
> drivers that want it? Jonathan, what do you think?
I wasn't keen on doing this in the past because it was relatively rare
for firmware to actually provide this info so we only supported it in a
few drivers. It still only applies to a subset of IIO devices and
the ACPI side of things isn't standard, so those are a bit trickier to deal
with. So I think there is a limit to what can be in the core.
I'd be interested to see a proposal though and see what it ends up
looking like. I guess it would be put the pointer in the iio_opaque
structure and then fill it if a driver requests it. So the bit we save
on is the pointer in the iio_priv() and the helper function used
to find that. Might be worth doing.
We aren't very consistent in how we handle the scope of it either.
Mix of shared_by_all, by_type, by_dir so generating the attribute from
the core is going to be tricky. There are good reasons for some of
those variants, but with hindsight this hasn't been as controlled as
it should have been.
So, maybe?
Jonathan
>
> (It definitely does not affect this series, which is good as it go.)
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix
2026-12-03 16:56 [PATCH v6 0/4] iio: magnetometer: mmc5633: Binding, supply and mount matrix Gerard Marull-Paretas
` (3 preceding siblings ...)
2026-12-03 16:56 ` [PATCH v6 4/4] iio: magnetometer: mmc5633: Add mount matrix support Gerard Marull-Paretas
@ 2026-12-04 23:02 ` Jonathan Cameron
4 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2026-12-04 23:02 UTC (permalink / raw)
To: Gerard Marull-Paretas
Cc: robh, krzk+dt, conor+dt, dlechner, nuno.sa, andy, Frank.li,
andriy.shevchenko, linux-iio, devicetree, linux-kernel
On Thu, 3 Dec 2026 17:56:50 +0100
Gerard Marull-Paretas <gerard@teslabs.com> wrote:
> The MMC5603 and MMC5633 are listed in trivial-devices.yaml, but boards
> need to describe their supply and orientation. Patch 1 gives them a
> binding of their own. These bindings are also used by PebbleOS, which
> is where the need came from.
>
> Patches 2 to 4 add the matching support to the driver. I have no board
> running Linux with these sensors, so they are only compile tested (W=1);
> feel free to take only patch 1 if you prefer.
>
Applied to the testing branch of iio.git.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 8+ messages in thread