Camera Power Load Switch Driver#

NVIDIA DRIVE® AGX Orin/Thor Devkit uses ADI Maxim MAX20087 power load switch to control power for camera modules. The reference driver for MAX20087 is here:

drive-linux/samples/nvmedia/nvsipl/devblk/devices/MAX20087

If a different power load switch is used on your device, create a new power load switch driver using the following steps.

Creating a Directory for Custom Driver#

Creating a new power load switch driver inside this directory:

drive-linux/samples/nvmedia/nvsipl/devblk/devices

Creating the Hardware Control for Power Load Switch#

The implementation of hardware control is similar to camera device drivers. Implement the following functions for driver to operate properly:

  • A DevBlkCDIDeviceDriver structure, which describes the functionality of the power load switch driver. All sensor-related callback function pointers can be skipped since they are not used for this driver.

  • A function to return the DeviceBlkCDIDeviceDriver structure. The glue logic calls this function to access to the driver.

  • DriverCreate() and DriverDestroy() functions to create and tear down the power load switch driver.

  • Any support functions used by the glue logic.

The sample Max20087 hardware control code is here:

drive-linux/samples/nvmedia/nvsipl/devblk/devices/MAX20087/cdi_max20087.c

Creating the Glue Logic for Power Load Switch#

Create a new class that inherits from the CNvMCampwr interface class.

Class CNvMMyPowerLoadSwitch final: public CNvMCampwr
{
    …
}

The glue logic is embodied in implementations of the pure virtual methods in the abstract base class. The following interfaces must be implemented:

  • SetConfig(): Called by the camera module glue logic to set the configuration of the power load switch based on the parameters.

  • isSupported(): Checks to see if a power load switch is supported.

  • CheckPresence(): Checks for the presence of the power load switch.

  • GetDeviceHandle(): Retrieves the CDI device handle for the power load switch.

  • CreatePowerDevice(): Called by the camera module glue logic to create a new CDI device object for the power load switch.

  • InitPowerDevice(): Called by the camera module glue logic to initialize the power load switch object.

  • PowerControlSetUnitPower(): Called by the camera module glue logic Power Control API to turn the power on or off to the camera devices.

The power load switch glue logic can also override the following virtual methods:

  • ReadRegister(): Read registers from power load switch.

  • WriteRegister():Write to power load switch registers.

  • MaskRestoreInterrupt(): Mask or restore the error masks for interrupts.

The sample Max20087 glue logic code is here:

drive-linux/samples/nvmedia/nvsipl/devblk/devices/MAX20087/CNvMMax20087.cpp

The power load switch device object is created in camera module glue logic, usually after serializer and sensor device objects are created. The sample code is here:

drive-linux/samples/nvmedia/nvsipl/devblk/cameramodule/MAX96712cameramodule/CNvMMax96712CameraModule.cpp

Building the New Power Load Switch Driver#

The power load switch driver can be built as part of the camera device driver file, or it can be built as a separate driver file and linked with the camera device driver, depending on how the power load switch is used in the system.

The sample MAX20087 power load switch driver is built into a separate driver file, found here:

drive-linux/samples/nvmedia/nvsipl/devblk/devices/MAX20087Driver

Note

This MAX20087 sample uses an optional factory/sync adapter technique to limit the power load switch driver to one instance per SIPL device block instead of one instance per camera module.