Search code examples
linuxdriverdevice-tree

Issue with binding platform driver to the platform device


I want to make work mt7622 soc's ethernet controller and faced with this issue. I've compiled mtk_soc_eth driver as mkt_eth module and I have an entry in mt7622-bananapi-bpi-r64.dts device tree for device, compatible with driver.

During boot this module is loaded into system automatically (I think after mounting rootfs):

[root@nixos:~]# lsmod | grep mtk_eth
mtk_eth                69632  0
dsa_core               98304  1 mtk_eth

And it seems registered as platform driver:

[root@nixos:~]# ls /sys/bus/platform/drivers/mtk_soc_eth
bind  module  uevent  unbind

Also after boot I have an platform device:

[root@nixos:~]# ls /sys/bus/platform/devices/1b100000.ethernet
driver_override
modalias
of_node
power
subsystem
supplier:platform:10006000.power-controller
supplier:platform:10209000.apmixedsys
supplier:platform:10210000.topckgen
supplier:platform:10211000.pinctrl
supplier:platform:1b000000.syscon
supplier:platform:1b128000.sgmiisys
uevent
waiting_for_supplier

However they are not binded for some reason. Moreover, when I try to bind them manually, I get an error:

[root@nixos:~]# echo '1b100000.ethernet' > /sys/bus/platform/drivers/mtk_soc_eth/bind
-bash: echo: write error: Resource temporarily unavailable

How can I understand why ethernet device doesn't bind with driver?


Solution

  • Well, it seems that I figured out where is the problem. It seems that linux kernel have rich debug options) I've enabled dynamic debug to track which happens inside __driver_probe_device https://github.com/torvalds/linux/blob/master/drivers/base/dd.c#L730 function:

    [root@nixos:~]# echo 'file dd.c +p'>/sys/kernel/debug/dynamic_debug/control
    [root@nixos:~]# echo 'file core.c +p'>/sys/kernel/debug/dynamic_debug/control
    

    And then tried to bind device driver and device:

    [root@nixos:~]# echo '1b100000.ethernet' >/sys/bus/platform/drivers/mtk_soc_eth/bind
    -bash: echo: write error: Resource temporarily unavailable
    [root@nixos:~]# dmesg -T | tail
    ...
    [Sat Jan  1 00:03:27 2000] bus: 'platform': __driver_probe_device: matched device 1b100000.ethernet with driver mtk_soc_eth
    [Sat Jan  1 00:03:27 2000] platform 1b100000.ethernet: error -EPROBE_DEFER: supplier 1b000000.syscon not ready
    

    It seems that one of the dependent devices (1b000000.syscon) is not ready (at the same time /sys/bus/platform/devices/1b100000.ethernet/waiting_for_supplier was still 0 for some reason). I need to load clk-mt7622-eth driver as well.