Sample Header Ad - 728x90

How to name a device in the device tree?

2 votes
0 answers
796 views
I have used a device tree overlay file (dtbo) to add a hardware reference over the i2c-2 node to my device tree. This device is an accelerometer that implements an existing driver that can be found here: https://elixir.bootlin.com/linux/v4.19.94/source/drivers/iio/accel/mma8452.c My device appears as iio:device0 in the /dev directory:
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
My device can also be viewed in:
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
Here you can see the specifics of the device naming:
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
**My question is, where does this device get its name as iio:device0?** I assume this is simply a default name as I haven't specified one. **My question therefore becomes: How do I specify a name for my device in the device tree? It seems I would like to change the DEVNAME somehow.** I do not see any reason for this name in my dtbo file, which can be seen below:
/*
 * MIRA custom cape device tree overlay
 * Supports MMA8451Q Accelerometer  
 */
/dts-v1/;
/plugin/;

#include 

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

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

        fragment@1 {
                target = ;

                __overlay__ {
                        status = "okay";
                        #address-cells = ;
                        #size-cells = ;
                        accelerometer@1C {
                                compatible = "fsl,mma8451";
                                reg = ;
                                interrupt-parent = ;
                                interrupts = ;
                                interrupt-names = "INT1";
                        };
                };
        };
};
Asked by Dillon McCardell (83 rep)
Dec 14, 2022, 12:03 AM
Last activity: Dec 31, 2022, 07:58 PM