Skip to content

Defined APIs

Zubeen Tolani edited this page Aug 23, 2016 · 3 revisions

The project is under development and new features/APIs will be added soon. As of now, following APIs are exported by the parallel_interface module :

APIs to be used by the platform driver :

int pi_core_register_devices(struct pi_bus_host *pibushost)

 pi_core_register_devices	  The function to register all the child devices.

 @pibushost     The pi_bus_host device whose child device needs to be
                registered.

 The function allocates a pi_device object, associates it with the given
 device_node and sets the given parent as its parent device. The function
 then returns the 0 if all the child devices are registered successfully,
 and 0 otherwise.

| Definition | Declaration |


struct pi_bus_host *pi_core_register_host(struct device *dev)

pi_core_register_host       Function that will serve as the 'release'
                            member function for all the pi_bus_host
                            devices.

@dev		The device element of the platform device that was detected by
    		by the platform-bus driver.

The function allocates a pi_bus_host object and initializes it with required
data. It further registers the device. The function returns a pointer to the
pi_bus_host object if successfully registered. It returns NULL otherwise.

TODO: Add support to add more than one host device if more than one
compatible device tree nodes are present.

| Definition | Declaration |


int pi_core_unregister_host (struct pi_bus_host *pibushost)

pi_core_unregister_host     Function to unregister the pi-host device.

@pibushost    The pi_bus_host device that needs to be unregistered.

The function iterates over all the child device of the given pi_bus_host
device, unregisters each of them. It further unregisters the pibushost
pibushost device.
The function returns 0 if all of the child device and the host device are
successfully unregistered, otherwise returns the error code.

| Definition | Declaration |


APIs to be used by the device driver :

int __pi_register_driver (char *name, struct module *owner, struct pi_driver *pidrv)

__pi_register_driver        Function to register a device driver for a
                            device that would be on pi bus.
     
@name	Char string name of the driver.
@owner	The owner module.
@pidrv	The pi-bus specific device-driver structure.

The function allocates a pi_bus_host object and initializes it with required
data. It further registers the device. The function returns a pointer to the
pi_bus_host object if successfully registered. It returns NULL otherwise.

| Definition | Declaration |


#####define pi_register_driver(__drv) __pi_register_driver (KBUILD_MODNAME ,THIS_MODULE, __drv)

 pi_register_driver    Helper macro to register the device driver onto the
                       pi-bus. The macro should only be called when there is
                       something else to be done in the driver __init
                       function. In simpler cases, the macro module_pi_driver
                       can be used.
              
 @__drv       The pi_driver associated with the device driver.

| Definition |


#define module_pi_driver(__pi_driver) module_driver(__pi_driver, pi_register_driver, pi_unregister_driver

module_pi_driver    Helper macro for drivers that don't do anything special
                    in module init/exit. This eliminates a lot of
                    boilerplate. Each module may only use this macro once,
                    and calling it replaces module_init() and
                    module_exit().
  
@__pi_driver        the pi-bus specific device driver structure of
                    pi_driver type.

| Definition |


static inline void pi_unregister_driver (struct pi_driver *pidrv)

  pi_unregister_driver              Function that can be used to unregister an
                                    already registered device driver.
      
  @pidrv       The pi_driver structure associated with the device driver.

| Definition |