iio: imu: inv_mpu6050: client enumeration
Subsystems (2)
PATCH v3 1/1 iio: imu: inv_mpu6050: client enumeration
Last comment from Jonathan was
"
This all looks fine to me, though ideally I'd like some input from others, more familiar with the dmi stuff etc and from Wolfram / others wrt to the approach.
"
So anybody have a better suggestion, I am still open to take them. Otherwise please consider as a merge candidate.
v3
Add CONFIG_ACPI protection to avoid compiler warning.
v2
Add CONFIG_ACPI to call creation of mux clients, instead of relying on ACPI_HANDLE not present for non ACPI platforms
It is possible that there is no secondary address, this is not an error.
v1
This is an option if auto detect is not desired.
Here using ACPI magic, by parsing both standard and vendor ACPI data.
v0
Using autodetect feature.
Using HWMON class as other places in the system for mux and client sensor drivers.
Srinivas Pandruvada (1):
iio: imu: inv_mpu6050: Create mux clients for ACPI
drivers/iio/imu/inv_mpu6050/Makefile | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 211 +++++++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 + 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
Signature · 1 line
1.9.3
PATCH v3 1/1 iio: imu: inv_mpu6050: Create mux clients for ACPI
This is a follow up patches after adding i2c mux adapter for bypass mode. Potentially many different types of sensor can be attached to INVMPU6XXX device, which can be connected to main cpu i2c bus in bypass mode.
Why do we need this?
The system ACPI table entry will consist of only one device for INV6XXX, assuming that this driver will handle all connected sensors. That is not true for the Linux driver. There are bunch of IIO drivers for each sensors, hence we created a mux on this device. So to load these additional drivers, we need to create i2c devices for them in this driver using this mux adapter.
There are multiple options:
1. Use the auto detect feature, this needs a new i2c class for the adapter as the existing HWMON class is not acceptable. Also the autodetect has overhead of executing detect method for each matching class of adapters.
This is a simple implementation. This option was previously submitted with not a happy feedback.
2. Option is use ACPI magic and parse the configuration data. What we need to create a i2c device at a minimum is address and a name. Address can be obtained for secondary device in more or less in a standard way from using _CRS element. But there is no name. To get name we need to process proprietary vendor data. Not having name is not fun, as you have to create device using the device name of INVN6XXXX, respecting driver duplicate name space restriction. Also each client driver needs to have this name in the id table. Since multiple driver can be loaded, the driver should be able to detect its presence and gracefully exit for the other client driver to take it over.
So we use two step process:
- Use DMI to id platform and parse propritery data. This is not uncommon for many x86 platform specific driver. We will get both name and address. The change created necessary infrastructure to add more properitery vendor data parsing.
- If DMI match fails, then create device on INV6XXX-client (we can't create with same name as INV6XXX as it will cause duplicate name and driver model will reject.) With this each client sensor driver which needs to get attached via INV6XXXX, need this name in the id table and detect the physical presence of sensor in probe and exit if not found.
--- drivers/iio/imu/inv_mpu6050/Makefile | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 211 +++++++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 + 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
drivers/iio/imu/inv_mpu6050/Makefile +1 -1
@@ -3,4 +3,4 @@ # obj-$(CONFIG_INV_MPU6050_IIO) += inv-mpu6050.o -inv-mpu6050-objs := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o +inv-mpu6050-objs := inv_mpu_core.o inv_mpu_ring.o inv_mpu_trigger.o inv_mpu_acpi.o
drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c new file +211 -0
211 lines not on this page · raw message
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +7 -0
@@ -825,8 +825,14 @@ static int inv_mpu_probe(struct i2c_client *client, goto out_unreg_device; } + result =inv_mpu_acpi_create_mux_client (st); +if (result) + goto out_del_mux; +return 0 ; +out_del_mux: +i2c_del_mux_adapter (st->mux_adapter); out_unreg_device:iio_device_unregister (indio_dev); out_remove_trigger:
@@ -841,6 +847,7 @@ static int inv_mpu_remove(struct i2c_client *client)struct iio_dev *indio_dev =i2c_get_clientdata (client);struct inv_mpu6050_state *st =iio_priv (indio_dev); +inv_mpu_acpi_delete_mux_client (st);i2c_del_mux_adapter (st->mux_adapter);iio_device_unregister (indio_dev);inv_mpu6050_remove_trigger (st);
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +3 -0
@@ -121,6 +121,7 @@ struct inv_mpu6050_state {spinlock_t time_stamp_lock;struct i2c_client *client;struct i2c_adapter *mux_adapter; +struct i2c_client *mux_client;unsigned int powerup_count;struct inv_mpu6050_platform_data plat_data; DECLARE_KFIFO(timestamps, long long, TIMESTAMP_FIFO_SIZE);
@@ -251,3 +252,5 @@ int inv_reset_fifo(struct iio_dev *indio_dev);int inv_mpu6050_switch_engine (struct inv_mpu6050_state *st,bool en,u32 mask);int inv_mpu6050_write_reg (struct inv_mpu6050_state *st,int reg,u8 val);int inv_mpu6050_set_power_itg (struct inv_mpu6050_state *st,bool power_on); +int inv_mpu_acpi_create_mux_client (struct inv_mpu6050_state *st); +void inv_mpu_acpi_delete_mux_client (struct inv_mpu6050_state *st);
Signature · 1 line
1.9.3
Jonathan Cameron
maintainerQuoted 6 lines · Srinivas Pandruvada
Last comment from Jonathan was
"
This all looks fine to me, though ideally I'd like some input from others, more familiar with the dmi stuff etc and from Wolfram / others wrt to the approach.
"
Given timing, (just missed likely merge this cycle) we now have a reasonable amount of time. So lets leave this a little while yet...
Quoted 32 lines
So anybody have a better suggestion, I am still open to take them. Otherwise please consider as a merge candidate.
v3
AddCONFIG_ACPIprotection to avoid compiler warning.v2
AddCONFIG_ACPIto call creation of mux clients, instead of relying onACPI_HANDLEnot present for non ACPI platforms
It is possible that there is no secondary address, this is not an error.v1
This is an option if auto detect is not desired.
Here using ACPI magic, by parsing both standard and vendor ACPI data.v0
Using autodetect feature.
Using HWMON class as other places in the system for mux and client sensor drivers.Srinivas Pandruvada (1):
iio: imu:inv_mpu6050: Create mux clients for ACPIdrivers/iio/imu/inv_mpu6050/Makefile | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 211 +++++++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 + 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c
Jonathan Cameron
maintainerQuoted 9 lines · Jonathan Cameron
Quoted 6 lines · Srinivas Pandruvada
Last comment from Jonathan was
"
This all looks fine to me, though ideally I'd like some input from others, more familiar with the dmi stuff etc and from Wolfram / others wrt to the approach.
"Given timing, (just missed likely merge this cycle) we now have a reasonable amount of time. So lets leave this a little while yet...
I no one else has any comments on this than I'm going to take it pretty soon as is.
Jonathan
Quoted 38 lines
Quoted 25 lines
So anybody have a better suggestion, I am still open to take them. Otherwise please consider as a merge candidate.
v3
AddCONFIG_ACPIprotection to avoid compiler warning.v2
AddCONFIG_ACPIto call creation of mux clients, instead of relying onACPI_HANDLEnot present for non ACPI platforms
It is possible that there is no secondary address, this is not an error.v1
This is an option if auto detect is not desired.
Here using ACPI magic, by parsing both standard and vendor ACPI data.v0
Using autodetect feature.
Using HWMON class as other places in the system for mux and client sensor drivers.Srinivas Pandruvada (1):
iio: imu:inv_mpu6050: Create mux clients for ACPIQuoted 7 lines
drivers/iio/imu/inv_mpu6050/Makefile | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 211 +++++++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 + 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jonathan Cameron
maintainerQuoted 8 lines · Jonathan Cameron
Quoted 7 lines · Jonathan Cameron
Quoted 6 lines · Srinivas Pandruvada
Last comment from Jonathan was
"
This all looks fine to me, though ideally I'd like some input from others, more familiar with the dmi stuff etc and from Wolfram / others wrt to the approach.
"
Quoted 6 lines
Quoted 2 lines
Given timing, (just missed likely merge this cycle) we now have a reasonable amount of time. So lets leave this a little while yet...
I no one else has any comments on this than I'm going to take it pretty soon as is.
Jonathan
Applied to the togreg branch of iio.git. Will be pushed out as testing for the autobuilders to play sometime soonish.
(travelling until Friday)
Jonathan
Quoted 44 lines
Quoted 33 lines
Quoted 25 lines
So anybody have a better suggestion, I am still open to take them. Otherwise please consider as a merge candidate.
v3
AddCONFIG_ACPIprotection to avoid compiler warning.v2
AddCONFIG_ACPIto call creation of mux clients, instead of relying onACPI_HANDLEnot present for non ACPI platforms
It is possible that there is no secondary address, this is not an error.v1
This is an option if auto detect is not desired.
Here using ACPI magic, by parsing both standard and vendor ACPI data.v0
Using autodetect feature.
Using HWMON class as other places in the system for mux and client sensor drivers.Srinivas Pandruvada (1):
iio: imu:inv_mpu6050: Create mux clients for ACPIQuoted 7 lines
drivers/iio/imu/inv_mpu6050/Makefile | 2 +- drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.c | 211 +++++++++++++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 + drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 + 4 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/imu/inv_mpu6050/inv_mpu_acpi.cQuoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html