Linux Driver Porting Guide for Lingming Photon ADS6401 dToF Sensor

Linux Driver Porting Guide for Lingming Photon ADS6401 dToF Sensor

Linux_Driver_porting_guide_for_ads6401

1. Download the latest driver release package and compilation toolkit from GitHub

Ads6401_Linux_Driver

2. Hardware and software environment of the reference design

  • Target Platform: Rockchip RK3568 SoC
  • Kernel Version: Linux 5.10.110
  • SDK Package: Linux 5.10 SDK based on RK3568, where<span><rockchip_original></span> contains the original source files from the RK3568 Linux 5.10 SDK, while<span><adaps_modified></span> contains our modified and newly added files

3. List of modified and newly added files

Linux Driver Porting Guide for Lingming Photon ADS6401 dToF Sensor
Modified and newly added files
kernel/arch/arm64/boot/dts/rockchip/rk3568-evb1-ddr4-v10-linux.dts
kernel/arch/arm64/configs/rockchip_linux_defconfig
kernel/drivers/media/i2c/ads6401.c
kernel/drivers/media/i2c/ads6401_flood.c
kernel/drivers/media/i2c/ads6401_spot.c
kernel/drivers/media/i2c/Kconfig
kernel/drivers/media/i2c/Makefile
kernel/drivers/media/platform/rockchip/cif/capture.c
kernel/drivers/media/platform/rockchip/cif/dev.c
kernel/drivers/media/platform/rockchip/cif/dev.h
kernel/include/uapi/linux/adaps_dtof_uapi.h
kernel/include/uapi/linux/adaps_types.h
kernel/include/uapi/linux/rk-camera-module.h

4. Porting Steps

4.1 Code Integration
  1. Copy the files from the<span><adaps_modified></span> directory to the corresponding paths in the SDK:

  • Header files:<span>adaps_types.h</span>, <span>adaps_dtof_uapi.h</span>, <span>rk-camera-module.h</span> → Copy to <span>include/uapi/linux/</span>
  • Driver files:<span>ads6401*.c</span> → Copy to <span>drivers/media/i2c/</span>
  • Modify the I2C driver Makefile (<span>drivers/media/i2c/Makefile</span>), adding the ADS6401 driver compilation entry:

    # Add at the appropriate position
    obj-$(CONFIG_VIDEO_ADS6401)+= ads6401.o
    
  • Modify the I2C driver Kconfig (<span>drivers/media/i2c/Kconfig</span>), adding the ADS6401 driver compilation entry:

    # Add at the appropriate position
    config VIDEO_ADS6401
     tristate "Adaps ADS6401 sensor support"
     depends on I2C && VIDEO_V4L2
     select V4L2_FWNODE
     help
       This is a Video4Linux2 sensor driver for the Adaps Ads6401 camera.
    
       To compile this driver as a module, choose M here: the
       module will be called Ads6401.
    
    config SWIFT_MINI_DEMO_BOX
     bool "rk3568 Linux for ads6401 mini demo box"
     depends on VIDEO_ADS6401
     default n
     help
       Enable this option to support rk3568 Linux for ads6401 mini demo box.
    
    
  • Modify the Linux kernel configuration options file (<span>arch\arm64\configs\rockchip_linux_defconfig</span>), adding some compilation options: (We have multiple similar files in our internal Gerrit repository to support hawk, swift, and different adapter boards)

    # Add at the end of the file
    # adaps modification for swift mini-demo-box on adaps rk3568 SoC mini board
    # CONFIG_DP83720_PHY=y
    CONFIG_USB_CONFIGFS_RNDIS=y
    CONFIG_USB_U_ETHER=y
    CONFIG_USB_F_RNDIS=y
    CONFIG_VIDEO_ADS6401=y
    # The following line is only needed for the Adaps company's miniaturized prototype
    CONFIG_SWIFT_MINI_DEMO_BOX=y
    
  • The ADS6401 supports two major module types (with more detailed subtypes), distinguished in ads6401.c by macro definitions:

    #define SWIFT_MODULE_TYPE               ADS6401_MODULE_SPOT  // ADS6401_MODULE_FLOOD
    
    4.2 Compilation and Deployment
    1. Execute the kernel compilation:

      make ARCH=arm64 rockchip_linux_defconfig
      make ARCH=arm64 -j8
      
    2. Deploy the generated kernel image and driver module (if configured as a module) to the RK3568 development board, and reboot to take effect. The Rockchip SDK has made some Android-like custom modifications to the kernel, supporting adb, and the kernel flashing image file uses boot.img. The SDK’s build script build.sh enhances the lunch menu to select different development board types and also provides automation to convert traditional kernel image files Image to boot.img. Customers should handle this according to the actual platform they are using.

    See details on compiling the Rockchip Linux kernel image and generating boot.img

    4.3 Verification
    • Check driver loading:<span>lsmod | grep ads6401</span> or <span>dmesg | grep DRV_ADS6401</span>
    • Confirm device node:<span>ls /dev/ads6401_misc</span> (Device node for the misc driver in the ADS6401 driver)
    • Confirm if our unique device attributes exist:
      root@rk356x:~# find /sys -name register
      /sys/devices/platform/fe5d0000.i2c/i2c-4/4-005e/register
      
      root@rk356x:~# cat /sys/devices/platform/fe5d0000.i2c/i2c-4/4-005e/info
      Adaps ads6401 dToF sensor driver
      Version:                       3.2.11_LM20250822A
      Build Time:                    Fri Aug 2212:01:10 CST 2025
      I2C Bus Num:                   4
      I2C bus frequency:             1000000Hz
      I2C address for ads6401:       0x5e
      Current TTY:                   pts0
      tdc_delay_major:               0xa
      tdc_delay_minor:               0x8
      
      root@rk356x:~# cat /sys/devices/platform/fe5d0000.i2c/i2c-4/4-005e/config
      Build switch options:
      ---------------------------------------------------------
      MINI_DEMO_BOX:                                     No
      ADS6401_MODULE_TYPE:                               Spot
      ENABLE_BIG_FOV_MODULE:                             No
      SENSOR_XCLK_FROM_SOC:                              Yes
      IGNORE_PROBE_FAILURE:                              Yes
      ...
      NON_CONTINUOUS_MIPI_CLK:                           Yes
      MIPI_DATA_LANE_COUNT:                              2
      MIPI_SPEED:                                        1000 Mbps
      SOC_MIPI_RX_CLOCK_FREQ:                            500 MHz
      EEPROM_CHIP_CAPACITY:                              65536 bytes
      ADAPS_DBG_ONCE:                                    0x400000

    Leave a Comment