Implementing NXP Hardware in Device Tree

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Implementing NXP Hardware in Device Tree

跳至解决方案
1,381 次查看
DillonM
Contributor II

I currently attempting to implement the mma8452 driver for my mma8451Q accelerometer by adding it to the the Linux Device Tree. 

Currently I am taking the route of creating a device tree overlay file (dtbo) that contains the addition to the device tree describing the accelerometer. It loads properly at boot and correctly pulls in the designated mma8452 driver. The driver however returns the following error in my dmesg log on boot:

 

[ 23.2352] mma8452: probe of 0-001c failed with error -121

 

Does anyone know what this means or how to fix it? Perhaps an overlay is not the correct way to do this and instead I should create a dtsi file or modify the source dts file? I can access the accelerometer from the console using the i2c-tools package at the SA0 address 0x1C. 

The driver supplied by NXP can be found here mma8452.c Driver 

My dtbo file can be seen below:

 

/*
 * 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 = <&i2c0>;

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

 

 The target = <&i2c0> was chosen simply because it was an i2c node in another dtsi file. No other reason. May be wrong.

标签 (1)
标记 (3)
0 项奖励
回复
1 解答
1,362 次查看
DillonM
Contributor II

The solution was to target the correct i2c bus the Accelerometer was connected to. This ended up being i2c2, not i2c0. This solved my issue. 

在原帖中查看解决方案

0 项奖励
回复
2 回复数
1,363 次查看
DillonM
Contributor II

The solution was to target the correct i2c bus the Accelerometer was connected to. This ended up being i2c2, not i2c0. This solved my issue. 

0 项奖励
回复
957 次查看
rockerr
Contributor II

Did you use the Yocto Project for your distribution? If so, could you explain how exactly did you manage to add your device tree to the linux-imx kernel source?

0 项奖励
回复