デバイスツリーでデバイス名を指定するには?

デバイスツリーでデバイス名を指定するには?

デバイスツリーオーバーレイファイル(dtbo)を使用して、i2c-2ノードのハードウェア参照をデバイスツリーに追加します。このデバイスは加速度計であり、ここで見つけることができる既存のドライバを実装しています。https://elixir.bootlin.com/linux/v4.19.94/source/drivers/iio/accel/mma8452.c

私のデバイスはiio:device0/ devディレクトリに表示されます。

debian@beaglebone:/dev$ ls
accel            log                 spi        tty27  tty53     urandom
apm_bios         loop-control        spidev1.0  tty28  tty54     vcs
autofs           mapper              spidev1.1  tty29  tty55     vcs1
block            mem                 spidev2.0  tty3   tty56     vcs2
btrfs-control    memory_bandwidth    spidev2.1  tty30  tty57     vcs3
bus              mmcblk0             stderr     tty31  tty58     vcs4
char             mmcblk0p1           stdin      tty32  tty59     vcs5
console          mmcblk1             stdout     tty33  tty6      vcs6
cpu_dma_latency  mmcblk1boot0        tty        tty34  tty60     vcsa
cuse             mmcblk1boot1        tty0       tty35  tty61     vcsa1
disk             mmcblk1p1           tty1       tty36  tty62     vcsa2
dri              mmcblk1rpmb         tty10      tty37  tty63     vcsa3
fb0              mqueue              tty11      tty38  tty7      vcsa4
fd               net                 tty12      tty39  tty8      vcsa5
full             network_latency     tty13      tty4   tty9      vcsa6
fuse             network_throughput  tty14      tty40  ttyGS0    vcsu
gpiochip0        null                tty15      tty41  ttyO0     vcsu1
gpiochip1        ppp                 tty16      tty42  ttyO1     vcsu2
gpiochip2        ptmx                tty17      tty43  ttyO2     vcsu3
gpiochip3        pts                 tty18      tty44  ttyO4     vcsu4
hwrng            pwm                 tty19      tty45  ttyO5     vcsu5
i2c-0            random              tty2       tty46  ttyS0     vcsu6
i2c-1            remoteproc          tty20      tty47  ttyS1     vhci
i2c-2            rfkill              tty21      tty48  ttyS2     watchdog
iio:device0      rtc                 tty22      tty49  ttyS4     watchdog0
initctl          rtc0                tty23      tty5   ttyS5     watchdog1
input            shm                 tty24      tty50  ubi_ctrl  zero
ion              snapshot            tty25      tty51  uhid
kmsg             snd                 tty26      tty52  uinput

私のデバイスは以下でも見ることができます。

debian@beaglebone:/sys/class/i2c-dev/i2c-2/subsystem/i2c-2/device/2-001c$ ls
driver       modalias  of_node  subsystem  uevent
iio:device0  name      power    trigger0

ここでは、デバイスの命名に関する特定の情報を表示できます。

debian@beaglebone:/sys/class/i2c-dev/i2c-2/subsystem/i2c-2/device/2-001c/iio:device0$ cat uevent
MAJOR=248
MINOR=0
DEVNAME=iio:device0
DEVTYPE=iio_device
OF_NAME=accelerometer
OF_FULLNAME=/ocp/i2c@4819c000/accelerometer@1C
OF_COMPATIBLE_0=fsl,mma8451
OF_COMPATIBLE_N=1

私の質問は、このデバイスの名前がどこから来たのかということですiio:device0指定しなかったので、ただ基本名だと思います。したがって、私の質問は次のようになります。デバイスツリーで自分のデバイスに名前を割り当てるには?どういうわけかDEVNAMEを変更したいようです。

次のように、dtboファイルにこの名前の理由が見つかりませんでした。

/*
 * MIRA custom cape device tree overlay
 * Supports MMA8451Q Accelerometer  
 */
/dts-v1/;
/plugin/;

#include <dt-bindings/interrupt-controller/irq.h>

/ {
        /*
         * Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
         */
        fragment@0 {
                target-path="/";
                __overlay__ {

                        chosen {
                                overlays {
                                        MIRA_EXTENSIONS = __TIMESTAMP__;
                                };
                        };
                };
        };

        fragment@1 {
                target = <&i2c2>;

                __overlay__ {
                        status = "okay";
                        #address-cells = <1>;
                        #size-cells = <0>;
                        accelerometer@1C {
                                compatible = "fsl,mma8451";
                                reg = <0x1C>;
                                interrupt-parent = <&gpio1>;
                                interrupts = <16 IRQ_TYPE_EDGE_RISING>;
                                interrupt-names = "INT1";
                        };
                };
        };
};

ベストアンサー1

おすすめ記事