0

I would like to use the apds9960 (light/gesture sensor) on rp0 - utilizing the kernel iio driver, which is already available, but there is no dt overlay yet. I guess I need to:

  • write the dts file
  • compile it to dtb
  • add to overlays
  • specify dtoverlay in config.txt
  • find the device in /sys/bus/iio/devices

Is someone able to do/help with the first point or two?

0

OK. There are current findings:

  • The DTS might look like this (i2c-apds9960.dts):

    /dts-v1/;
    /plugin/;
    
    / {
        compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
    
        fragment@0 {
            target = <&i2c_arm>;
            __overlay__ {
                #address-cells = <1>;
                #size-cells = <0>;
                status = "okay";
    
                apds9960: apds9960@39 {
                    compatible = "avago,apds9960";
                    reg = <0x39>;
                    interrupt-parent = <&gpio>;
                    interrupts = <4 2>;
                    #gpio-cells = <2>;
                };
            };
        };
    
        __overrides__ {
            int_pin = <&apds9960>,"interrupts:0";
            addr = <&apds9960>,"reg:0";
        };
    };
    
  • Compilation to DTB (one of possible methods):

    git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git
    cd dtc
    make
    ./dtc i2c-apds9960.dts > i2c-apds9960.dtbo
    cp i2c-apds9960.dts /mnt/pi-zero/boot/overlays
    
  • Update of the config.txt:

    dtoverlay=i2c-apds9960
    dtparam=int_pin=4 # For the case the pin needs to be different than in DTC
    
  • Locate the device:

    # cat /sys/bus/iio/devices/iio\:device0/name
    apds9960
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.