2

I'm writing a multi-function kernel driver module, based on http://lxr.free-electrons.com/source/drivers/mfd/wm8350-i2c.c?v=4.4 and http://lxr.free-electrons.com/source/drivers/mfd/wm8350-core.c?v=4.4

I am confused as to how/when/why the wm8350_i2c_probe() function is called.

The i2c_add_driver() call registers a struct i2c_driver with the i2c subsystem and that struct includes a .probe pointer to the wm8350_i2c_probe() function.

I have made my own analogues of these modules. The xxx_i2c_init() is called on insmod but the i2c subsystem does not call the xxx_i2c_probe() function.

There is something I do not understand here. Why doesn't the i2c subsystem call the wm8350_i2c_probe() function via the registered .probe?

fadedbee
  • 42,671
  • 44
  • 178
  • 308
  • 1
    What resource provider do you use? Device tree, ACPI, platform data (board files)? – Sam Protsenko Oct 17 '16 at 14:03
  • @SamProtsenko I think that the wm8350 uses data from board files. Are http://lxr.free-electrons.com/source/arch/arm/mach-imx/mach-mx31ads.c?v=4.4#L495 and http://lxr.free-electrons.com/source/arch/arm/mach-s3c64xx/mach-smdk6410.c?v=4.4#L492 board files? – fadedbee Oct 17 '16 at 15:09
  • Yes, those are board files. Which exactly kernel and platform/board you use? – Sam Protsenko Oct 17 '16 at 16:16
  • The function is called by device driver core. Perhaps you may start from *drivers/base/dd.c*. – 0andriy Oct 18 '16 at 19:56
  • @SamProtsenko Kernel 4.4 and It's a custom ARM board that I'm bringing up (only four in the world, so far). I think I need to write a board file for this board to declare the bus number and address of the i2c chip. (I haven't done any kernel work in 10+ years so I'm very rusty.) – fadedbee Oct 19 '16 at 08:02
  • 2
    @chrisdew In kernel 4.4 you expected to create Device Tree (`.dts`) instead of board files for ARM boards. Look at `arch/arm/boot/dts/`. Compiled Device Tree (`.dtb`) is being read by bootloader (U-Boot) to RAM, modified slightly, and passed to kernel via `r2` register . In your driver you should use corresponding `of_*` functions to obtain properties for your device from Device Tree. – Sam Protsenko Oct 19 '16 at 11:50
  • 1
    @chrisdew Take a look here: ["Device Tree for Dummies"](http://free-electrons.com/pub/conferences/2013/elce/petazzoni-device-tree-dummies/petazzoni-device-tree-dummies.pdf) and here: ["Porting Linux on an ARM board"](http://free-electrons.com/pub/conferences/2015/captronic/captronic-porting-linux-on-arm.pdf) for starters. – Sam Protsenko Oct 19 '16 at 11:51

0 Answers0