* sysfs mount_matrix for st_lsm6dsx gyro @ 2023-01-11 12:09 Philippe De Muyter 2023-01-11 17:17 ` Jonathan Cameron 0 siblings, 1 reply; 8+ messages in thread From: Philippe De Muyter @ 2023-01-11 12:09 UTC (permalink / raw) To: lorenzo, linux-iio Hello Lorenzo and list, I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' iio device. Is that normal ? Is a fix available ? Some more info : I have backported drivers/iio/imu/st_lsm6dsx to linux-4.9 in order to drive a ism330dlc imu on a custom board. The chip is correctly detected and two devices are created in /sys/bus/iio/devices/ the first one (where name is 'ism330dlc_gyro') has the following entries : me@proto4:~$ ls /sys/bus/iio/devices/iio\:device1/ buffer in_anglvel_x_raw sampling_frequency current_timestamp_clock in_anglvel_y_raw sampling_frequency_available dev in_anglvel_z_raw scan_elements in_anglvel_scale name subsystem in_anglvel_scale_available power uevent me@proto4:~$ the second one (where name is 'ism330dlc_accel') has those entries : me@proto4:~$ ls /sys/bus/iio/devices/iio\:device2 buffer in_accel_x_raw sampling_frequency current_timestamp_clock in_accel_y_raw sampling_frequency_available dev in_accel_z_raw scan_elements events mount_matrix subsystem in_accel_scale name uevent in_accel_scale_available power me@proto4:~$ The 'mount_matrix' entry is only present in the 'ism330dlc_accel' device but not in the 'ism330dlc_gyro' device. On a similar board, but with mpu9250 imu, I get only one iio:deviceX entry but with two *mount_matrix entries : in_accel_mount_matrix in_anglvel_mount_matrix In both cases, I would have expected only one 'iio:deviceX' entry with only one 'mount_matrix' entry. Best regards Philippe -- Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-11 12:09 sysfs mount_matrix for st_lsm6dsx gyro Philippe De Muyter @ 2023-01-11 17:17 ` Jonathan Cameron 2023-01-12 9:51 ` Lorenzo Bianconi 2023-01-12 10:12 ` Lorenzo Bianconi 0 siblings, 2 replies; 8+ messages in thread From: Jonathan Cameron @ 2023-01-11 17:17 UTC (permalink / raw) To: Philippe De Muyter; +Cc: lorenzo, linux-iio On Wed, 11 Jan 2023 13:09:40 +0100 Philippe De Muyter <phdm@macq.eu> wrote: > Hello Lorenzo and list, > > I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' > iio device. > Is that normal ? > Is a fix available ? Looks like the channel definition for the gyro does not include an appropriate ext_info entry unlike the accelerometer channels which have one with mount_matrix support. From a quick glance looks like a simple fix. Add that entry. > > Some more info : > > I have backported drivers/iio/imu/st_lsm6dsx to linux-4.9 in order > to drive a ism330dlc imu on a custom board. The chip is correctly > detected and two devices are created in /sys/bus/iio/devices/ > > the first one (where name is 'ism330dlc_gyro') has the following entries : > > me@proto4:~$ ls /sys/bus/iio/devices/iio\:device1/ > buffer in_anglvel_x_raw sampling_frequency > current_timestamp_clock in_anglvel_y_raw sampling_frequency_available > dev in_anglvel_z_raw scan_elements > in_anglvel_scale name subsystem > in_anglvel_scale_available power uevent > me@proto4:~$ > > the second one (where name is 'ism330dlc_accel') has those entries : > > me@proto4:~$ ls /sys/bus/iio/devices/iio\:device2 > buffer in_accel_x_raw sampling_frequency > current_timestamp_clock in_accel_y_raw sampling_frequency_available > dev in_accel_z_raw scan_elements > events mount_matrix subsystem > in_accel_scale name uevent > in_accel_scale_available power > me@proto4:~$ > > The 'mount_matrix' entry is only present in the 'ism330dlc_accel' device > but not in the 'ism330dlc_gyro' device. > > On a similar board, but with mpu9250 imu, I get only one iio:deviceX > entry but with two *mount_matrix entries : > > in_accel_mount_matrix > in_anglvel_mount_matrix > > In both cases, I would have expected only one 'iio:deviceX' entry with > only one 'mount_matrix' entry. There are multiple devices because the driver predates the addition of multiple buffer support to IIO and IIRC is capable of producing data at different sampling rates for the accelerometer and the gyros. Hence when it was implemented the only choice was to register multiple devices in order to get the multiple buffers. It's ABI now so we can't fix it in an old driver unfortunately. We'd do this differently today.. The double mount_matrix for the mpu9250 is a little odd and I can't immediately spot why that one is happening. > > Best regards > > Philippe > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-11 17:17 ` Jonathan Cameron @ 2023-01-12 9:51 ` Lorenzo Bianconi 2023-01-12 11:27 ` Philippe De Muyter 2023-01-12 10:12 ` Lorenzo Bianconi 1 sibling, 1 reply; 8+ messages in thread From: Lorenzo Bianconi @ 2023-01-12 9:51 UTC (permalink / raw) To: Jonathan Cameron; +Cc: Philippe De Muyter, linux-iio [-- Attachment #1: Type: text/plain, Size: 3008 bytes --] > On Wed, 11 Jan 2023 13:09:40 +0100 > Philippe De Muyter <phdm@macq.eu> wrote: > > > Hello Lorenzo and list, > > > > I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' > > iio device. > > Is that normal ? > > Is a fix available ? > > Looks like the channel definition for the gyro does not include an > appropriate ext_info entry unlike the accelerometer channels which > have one with mount_matrix support. > > From a quick glance looks like a simple fix. Add that entry. I am not sure if accel and gyro can be mounted with a different orientation. Do you think we should have a per-sensor mount_matrix? Regards, Lorenzo > > > > Some more info : > > > > I have backported drivers/iio/imu/st_lsm6dsx to linux-4.9 in order > > to drive a ism330dlc imu on a custom board. The chip is correctly > > detected and two devices are created in /sys/bus/iio/devices/ > > > > the first one (where name is 'ism330dlc_gyro') has the following entries : > > > > me@proto4:~$ ls /sys/bus/iio/devices/iio\:device1/ > > buffer in_anglvel_x_raw sampling_frequency > > current_timestamp_clock in_anglvel_y_raw sampling_frequency_available > > dev in_anglvel_z_raw scan_elements > > in_anglvel_scale name subsystem > > in_anglvel_scale_available power uevent > > me@proto4:~$ > > > > the second one (where name is 'ism330dlc_accel') has those entries : > > > > me@proto4:~$ ls /sys/bus/iio/devices/iio\:device2 > > buffer in_accel_x_raw sampling_frequency > > current_timestamp_clock in_accel_y_raw sampling_frequency_available > > dev in_accel_z_raw scan_elements > > events mount_matrix subsystem > > in_accel_scale name uevent > > in_accel_scale_available power > > me@proto4:~$ > > > > The 'mount_matrix' entry is only present in the 'ism330dlc_accel' device > > but not in the 'ism330dlc_gyro' device. > > > > On a similar board, but with mpu9250 imu, I get only one iio:deviceX > > entry but with two *mount_matrix entries : > > > > in_accel_mount_matrix > > in_anglvel_mount_matrix > > > > In both cases, I would have expected only one 'iio:deviceX' entry with > > only one 'mount_matrix' entry. > > There are multiple devices because the driver predates the addition > of multiple buffer support to IIO and IIRC is capable of producing data > at different sampling rates for the accelerometer and the gyros. > Hence when it was implemented the only choice was to register multiple > devices in order to get the multiple buffers. It's ABI now so we can't > fix it in an old driver unfortunately. We'd do this differently today.. > > The double mount_matrix for the mpu9250 is a little odd and I can't > immediately spot why that one is happening. > > > > > > Best regards > > > > Philippe > > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-12 9:51 ` Lorenzo Bianconi @ 2023-01-12 11:27 ` Philippe De Muyter 2023-01-12 11:32 ` Lorenzo Bianconi 0 siblings, 1 reply; 8+ messages in thread From: Philippe De Muyter @ 2023-01-12 11:27 UTC (permalink / raw) To: Lorenzo Bianconi; +Cc: Jonathan Cameron, linux-iio Hello Lorenzo, On Thu, Jan 12, 2023 at 10:51:03AM +0100, Lorenzo Bianconi wrote: > Date: Thu, 12 Jan 2023 10:51:03 +0100 > From: Lorenzo Bianconi <lorenzo@kernel.org> > To: Jonathan Cameron <Jonathan.Cameron@huawei.com> > Cc: Philippe De Muyter <phdm@macq.eu>, linux-iio@vger.kernel.org > Subject: Re: sysfs mount_matrix for st_lsm6dsx gyro > > > On Wed, 11 Jan 2023 13:09:40 +0100 > > Philippe De Muyter <phdm@macq.eu> wrote: > > > > > Hello Lorenzo and list, > > > > > > I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' > > > iio device. > > > Is that normal ? > > > Is a fix available ? > > > > Looks like the channel definition for the gyro does not include an > > appropriate ext_info entry unlike the accelerometer channels which > > have one with mount_matrix support. > > > > From a quick glance looks like a simple fix. Add that entry. > > I am not sure if accel and gyro can be mounted with a different orientation. > Do you think we should have a per-sensor mount_matrix? My chip is a 'ism330dlc'. It's one chip containing an accel and a gyro, so the mount_matrix should be the same for the accel and the gyro. Unfortunately the accel and the gyro are presented in /sysfs as two separate devices, and only the accel one has a 'mount_matrix' entry. So a user looking for any gyro will find the gyro entry, but without 'mount_matrix'. I have followed Jonathan's proposal and added this simple patch in the definition of the ST_LSM6DSX_CHANNEL macro : diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index d80ba2e688ed..9d18145d5041 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -96,6 +96,7 @@ enum st_lsm6dsx_hw_id { .storagebits = 16, \ .endianness = IIO_LE, \ }, \ + .ext_info = st_lsm6dsx_accel_ext_info, \ } struct st_lsm6dsx_reg { Another fix would be to create only one chip entry in sysfs, but that's above my knowledge of this driver. Best regards Philippe ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-12 11:27 ` Philippe De Muyter @ 2023-01-12 11:32 ` Lorenzo Bianconi 2023-01-12 15:19 ` Jonathan Cameron 2023-01-13 14:45 ` Philippe De Muyter 0 siblings, 2 replies; 8+ messages in thread From: Lorenzo Bianconi @ 2023-01-12 11:32 UTC (permalink / raw) To: Philippe De Muyter; +Cc: Jonathan Cameron, linux-iio [-- Attachment #1: Type: text/plain, Size: 2543 bytes --] > Hello Lorenzo, > > On Thu, Jan 12, 2023 at 10:51:03AM +0100, Lorenzo Bianconi wrote: > > Date: Thu, 12 Jan 2023 10:51:03 +0100 > > From: Lorenzo Bianconi <lorenzo@kernel.org> > > To: Jonathan Cameron <Jonathan.Cameron@huawei.com> > > Cc: Philippe De Muyter <phdm@macq.eu>, linux-iio@vger.kernel.org > > Subject: Re: sysfs mount_matrix for st_lsm6dsx gyro > > > > > On Wed, 11 Jan 2023 13:09:40 +0100 > > > Philippe De Muyter <phdm@macq.eu> wrote: > > > > > > > Hello Lorenzo and list, > > > > > > > > I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' > > > > iio device. > > > > Is that normal ? > > > > Is a fix available ? > > > > > > Looks like the channel definition for the gyro does not include an > > > appropriate ext_info entry unlike the accelerometer channels which > > > have one with mount_matrix support. > > > > > > From a quick glance looks like a simple fix. Add that entry. > > > > I am not sure if accel and gyro can be mounted with a different orientation. > > Do you think we should have a per-sensor mount_matrix? > > My chip is a 'ism330dlc'. It's one chip containing an accel and a gyro, > so the mount_matrix should be the same for the accel and the gyro. > Unfortunately the accel and the gyro are presented in /sysfs as two > separate devices, and only the accel one has a 'mount_matrix' entry. > So a user looking for any gyro will find the gyro entry, but without > 'mount_matrix'. > > I have followed Jonathan's proposal and added this simple patch in > the definition of the ST_LSM6DSX_CHANNEL macro : > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > index d80ba2e688ed..9d18145d5041 100644 > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > @@ -96,6 +96,7 @@ enum st_lsm6dsx_hw_id { > .storagebits = 16, \ > .endianness = IIO_LE, \ > }, \ > + .ext_info = st_lsm6dsx_accel_ext_info, \ > } I am fine with this approach, probably having a per-sensor mount_matrix is unnecessary. Can you please just rename st_lsm6dsx_accel_ext_info in st_lsm6dsx_ext_info? Regards, Lorenzo > > struct st_lsm6dsx_reg { > > Another fix would be to create only one chip entry in sysfs, but that's > above my knowledge of this driver. > > Best regards > > Philippe [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-12 11:32 ` Lorenzo Bianconi @ 2023-01-12 15:19 ` Jonathan Cameron 2023-01-13 14:45 ` Philippe De Muyter 1 sibling, 0 replies; 8+ messages in thread From: Jonathan Cameron @ 2023-01-12 15:19 UTC (permalink / raw) To: Lorenzo Bianconi; +Cc: Philippe De Muyter, linux-iio On Thu, 12 Jan 2023 12:32:11 +0100 Lorenzo Bianconi <lorenzo@kernel.org> wrote: > > Hello Lorenzo, > > > > On Thu, Jan 12, 2023 at 10:51:03AM +0100, Lorenzo Bianconi wrote: > > > Date: Thu, 12 Jan 2023 10:51:03 +0100 > > > From: Lorenzo Bianconi <lorenzo@kernel.org> > > > To: Jonathan Cameron <Jonathan.Cameron@huawei.com> > > > Cc: Philippe De Muyter <phdm@macq.eu>, linux-iio@vger.kernel.org > > > Subject: Re: sysfs mount_matrix for st_lsm6dsx gyro > > > > > > > On Wed, 11 Jan 2023 13:09:40 +0100 > > > > Philippe De Muyter <phdm@macq.eu> wrote: > > > > > > > > > Hello Lorenzo and list, > > > > > > > > > > I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' > > > > > iio device. > > > > > Is that normal ? > > > > > Is a fix available ? > > > > > > > > Looks like the channel definition for the gyro does not include an > > > > appropriate ext_info entry unlike the accelerometer channels which > > > > have one with mount_matrix support. > > > > > > > > From a quick glance looks like a simple fix. Add that entry. > > > > > > I am not sure if accel and gyro can be mounted with a different orientation. > > > Do you think we should have a per-sensor mount_matrix? > > > > My chip is a 'ism330dlc'. It's one chip containing an accel and a gyro, > > so the mount_matrix should be the same for the accel and the gyro. > > Unfortunately the accel and the gyro are presented in /sysfs as two > > separate devices, and only the accel one has a 'mount_matrix' entry. > > So a user looking for any gyro will find the gyro entry, but without > > 'mount_matrix'. > > > > I have followed Jonathan's proposal and added this simple patch in > > the definition of the ST_LSM6DSX_CHANNEL macro : > > > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > > index d80ba2e688ed..9d18145d5041 100644 > > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > > @@ -96,6 +96,7 @@ enum st_lsm6dsx_hw_id { > > .storagebits = 16, \ > > .endianness = IIO_LE, \ > > }, \ > > + .ext_info = st_lsm6dsx_accel_ext_info, \ > > } > > I am fine with this approach, probably having a per-sensor mount_matrix is > unnecessary. Can you please just rename st_lsm6dsx_accel_ext_info in > st_lsm6dsx_ext_info? > > Regards, > Lorenzo > > > > > struct st_lsm6dsx_reg { > > > > Another fix would be to create only one chip entry in sysfs, but that's > > above my knowledge of this driver. We can't make that change. It would be ABI breakage - userspace code would stop working. Jonathan > > > > Best regards > > > > Philippe > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-12 11:32 ` Lorenzo Bianconi 2023-01-12 15:19 ` Jonathan Cameron @ 2023-01-13 14:45 ` Philippe De Muyter 1 sibling, 0 replies; 8+ messages in thread From: Philippe De Muyter @ 2023-01-13 14:45 UTC (permalink / raw) To: Lorenzo Bianconi; +Cc: Jonathan Cameron, linux-iio On Thu, Jan 12, 2023 at 12:32:11PM +0100, Lorenzo Bianconi wrote: > > I have followed Jonathan's proposal and added this simple patch in > > the definition of the ST_LSM6DSX_CHANNEL macro : > > > > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > > index d80ba2e688ed..9d18145d5041 100644 > > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h > > @@ -96,6 +96,7 @@ enum st_lsm6dsx_hw_id { > > .storagebits = 16, \ > > .endianness = IIO_LE, \ > > }, \ > > + .ext_info = st_lsm6dsx_accel_ext_info, \ > > } > > I am fine with this approach, probably having a per-sensor mount_matrix is > unnecessary. Can you please just rename st_lsm6dsx_accel_ext_info in > st_lsm6dsx_ext_info? > The compilation fails because there is already something different with that same name in drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:715:30: error: conflicting type qualifiers for ‘st_lsm6dsx_ext_info’ static const struct iio_info st_lsm6dsx_ext_info = { ^~~~~~~~~~~~~~~~~~~ In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c:31:0: drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h:498:46: note: previous definition of ‘st_lsm6dsx_ext_info’ was here struct iio_chan_spec_ext_info __maybe_unused st_lsm6dsx_ext_info[] = { Best regards Philippe ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: sysfs mount_matrix for st_lsm6dsx gyro 2023-01-11 17:17 ` Jonathan Cameron 2023-01-12 9:51 ` Lorenzo Bianconi @ 2023-01-12 10:12 ` Lorenzo Bianconi 1 sibling, 0 replies; 8+ messages in thread From: Lorenzo Bianconi @ 2023-01-12 10:12 UTC (permalink / raw) To: Jonathan Cameron; +Cc: Philippe De Muyter, linux-iio [-- Attachment #1: Type: text/plain, Size: 6075 bytes --] > On Wed, 11 Jan 2023 13:09:40 +0100 > Philippe De Muyter <phdm@macq.eu> wrote: > > > Hello Lorenzo and list, > > > > I do not find a "*mount_matrix" entry in sysfs for a 'ism330dlc_gyro' > > iio device. > > Is that normal ? > > Is a fix available ? > > Looks like the channel definition for the gyro does not include an > appropriate ext_info entry unlike the accelerometer channels which > have one with mount_matrix support. > > From a quick glance looks like a simple fix. Add that entry. something like (per-sensor mount_matrix): diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 5b6f195748fc..5e0c184e1055 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -113,6 +113,8 @@ enum st_lsm6dsx_hw_id { .storagebits = 16, \ .endianness = IIO_LE, \ }, \ + .ext_info = st_lsm6dsx_gyro_ext_info, \ + .num_event_specs = 1, \ } struct st_lsm6dsx_reg { @@ -356,6 +358,7 @@ enum st_lsm6dsx_fifo_mode { * @decimator: Sensor decimation factor. * @sip: Number of samples in a given pattern. * @ts_ref: Sensor timestamp reference for hw one. + * @orientation: sensor chip orientation relative to main hardware. * @ext_info: Sensor settings if it is connected to i2c controller */ struct st_lsm6dsx_sensor { @@ -371,6 +374,8 @@ struct st_lsm6dsx_sensor { u8 sip; s64 ts_ref; + struct iio_mount_matrix orientation; + struct { const struct st_lsm6dsx_ext_dev_settings *settings; u32 slv_odr; @@ -398,7 +403,6 @@ struct st_lsm6dsx_sensor { * @enable_event: enabled event bitmask. * @iio_devs: Pointers to acc/gyro iio_dev instances. * @settings: Pointer to the specific sensor settings in use. - * @orientation: sensor chip orientation relative to main hardware. * @scan: Temporary buffers used to align data before iio_push_to_buffers() */ struct st_lsm6dsx_hw { @@ -427,7 +431,6 @@ struct st_lsm6dsx_hw { const struct st_lsm6dsx_settings *settings; - struct iio_mount_matrix orientation; /* Ensure natural alignment of buffer elements */ struct { __le16 channels[3]; @@ -511,9 +514,8 @@ st_lsm6dsx_get_mount_matrix(const struct iio_dev *iio_dev, const struct iio_chan_spec *chan) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); - struct st_lsm6dsx_hw *hw = sensor->hw; - return &hw->orientation; + return &sensor->orientation; } static inline int @@ -533,4 +535,10 @@ struct iio_chan_spec_ext_info __maybe_unused st_lsm6dsx_accel_ext_info[] = { { } }; +static const +struct iio_chan_spec_ext_info __maybe_unused st_lsm6dsx_gyro_ext_info[] = { + IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, st_lsm6dsx_get_mount_matrix), + { } +}; + #endif /* ST_LSM6DSX_H */ diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 3f6060c64f32..15c7184a1895 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2359,6 +2359,9 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, sensor->gain = hw->settings->fs_table[id].fs_avl[0].gain; sensor->watermark = 1; + if (iio_read_mount_matrix(hw->dev, &sensor->orientation)) + return NULL; + switch (id) { case ST_LSM6DSX_ID_ACC: iio_dev->info = &st_lsm6dsx_acc_info; @@ -2676,10 +2679,6 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, return err; } - err = iio_read_mount_matrix(hw->dev, &hw->orientation); - if (err) - return err; - for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { if (!hw->iio_devs[i]) continue; > > > > Some more info : > > > > I have backported drivers/iio/imu/st_lsm6dsx to linux-4.9 in order > > to drive a ism330dlc imu on a custom board. The chip is correctly > > detected and two devices are created in /sys/bus/iio/devices/ > > > > the first one (where name is 'ism330dlc_gyro') has the following entries : > > > > me@proto4:~$ ls /sys/bus/iio/devices/iio\:device1/ > > buffer in_anglvel_x_raw sampling_frequency > > current_timestamp_clock in_anglvel_y_raw sampling_frequency_available > > dev in_anglvel_z_raw scan_elements > > in_anglvel_scale name subsystem > > in_anglvel_scale_available power uevent > > me@proto4:~$ > > > > the second one (where name is 'ism330dlc_accel') has those entries : > > > > me@proto4:~$ ls /sys/bus/iio/devices/iio\:device2 > > buffer in_accel_x_raw sampling_frequency > > current_timestamp_clock in_accel_y_raw sampling_frequency_available > > dev in_accel_z_raw scan_elements > > events mount_matrix subsystem > > in_accel_scale name uevent > > in_accel_scale_available power > > me@proto4:~$ > > > > The 'mount_matrix' entry is only present in the 'ism330dlc_accel' device > > but not in the 'ism330dlc_gyro' device. > > > > On a similar board, but with mpu9250 imu, I get only one iio:deviceX > > entry but with two *mount_matrix entries : > > > > in_accel_mount_matrix > > in_anglvel_mount_matrix > > > > In both cases, I would have expected only one 'iio:deviceX' entry with > > only one 'mount_matrix' entry. > > There are multiple devices because the driver predates the addition > of multiple buffer support to IIO and IIRC is capable of producing data > at different sampling rates for the accelerometer and the gyros. > Hence when it was implemented the only choice was to register multiple > devices in order to get the multiple buffers. It's ABI now so we can't > fix it in an old driver unfortunately. We'd do this differently today.. > > The double mount_matrix for the mpu9250 is a little odd and I can't > immediately spot why that one is happening. > > > > > > Best regards > > > > Philippe > > > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-01-13 14:59 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-01-11 12:09 sysfs mount_matrix for st_lsm6dsx gyro Philippe De Muyter 2023-01-11 17:17 ` Jonathan Cameron 2023-01-12 9:51 ` Lorenzo Bianconi 2023-01-12 11:27 ` Philippe De Muyter 2023-01-12 11:32 ` Lorenzo Bianconi 2023-01-12 15:19 ` Jonathan Cameron 2023-01-13 14:45 ` Philippe De Muyter 2023-01-12 10:12 ` Lorenzo Bianconi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox