On 2022-10-17 23:19, Peter Bergin wrote:
Hi,
on my system I have a cs42448 chip connected on a i2c bus to a i.Mx8mp. The chip is connected on i2c-2 with address 0x48 and I can detect it and read registers with help of i2c-tools. Running kernel v6.0 and having problem as the device and driver is not connected in my system. The probe function (cs42xx8_i2c_probe) is never called during initialization. The module is loaded in the kernel.
Here is a snippet from the dtb file:
codec: cs42xx8@48 { compatible = "cirrus,cs42448"; reg = <0x48>; reset-gpios = <&gpio4 9 GPIO_ACTIVE_LOW>; #sound-dai-cells = <0>; clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIOMIX_SAI3_MCLK1>; clock-names = "mclk"; VA-supply = <®_audio_pwr_5v0>; VD-supply = <®_audio_pwr_3v3>; VLS-supply = <®_audio_pwr_3v3>; VLC-supply = <®_audio_pwr_3v3>; };
Tried to dig in to the code and understand why the device and the driver is not connected with each other. I assumed that they should be connected through device-tree.
In sound/soc/codec/snd-soc-cs42xx8-i2c.mod.c:
MODULE_ALIAS("i2c:cs42448"); MODULE_ALIAS("i2c:cs42888");
So there are no alias to of: in that file.
Do I have the wrong assumption about connecting the device with the driver through the device-tree? Something wrong in my dts snippet above? Great if someone could help out with some ideas around this.
My problem is solved and I can connect device and driver with this patch:
diff --git a/sound/soc/codecs/cs42xx8-i2c.c b/sound/soc/codecs/cs42xx8-i2c.c index cb06a06d48b0..6e8ee28d01f8 100644 --- a/sound/soc/codecs/cs42xx8-i2c.c +++ b/sound/soc/codecs/cs42xx8-i2c.c @@ -37,6 +37,13 @@ static int cs42xx8_i2c_remove(struct i2c_client *i2c) return 0; }
+const struct of_device_id cs42xx8_of_match[] = { + { .compatible = "cirrus,cs42448", .data = &cs42448_data, }, + { .compatible = "cirrus,cs42888", .data = &cs42888_data, }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, cs42xx8_of_match); + static struct i2c_device_id cs42xx8_i2c_id[] = { {"cs42448", (kernel_ulong_t)&cs42448_data}, {"cs42888", (kernel_ulong_t)&cs42888_data},
That information is already present and copied from sound/soc/codecs/cs42xx8.c. Is this a suitable solution to the problem? Something that can be applied upstream?
Thanks, /Peter