Since peripheral manager does not build in the IIO source, ifdef's were
added around the initio functionality for IIO.
IMO this is an ugly fix, but I don't see a better way since the
PERIPHERALMAN architecture is qualified throughout the CMake and source
with ifdef's.
Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit limits which tests run on which ARCH to allow all tests to
pass on CI.
* Qualify the FTDI tests with (FTDI4222 AND USBPLAT)
* Qualify the IO init tests with (DETECTED_ARCH == "MOCK")
* Renamed all unit tests to start with 'test_unit_' to facilitate
grouping with tab completion (or any other type of sorting)
* Updated docker targets with new unit test target name
Signed-off-by: Noel Eck <noel.eck@intel.com>
For all subplaform pins, save the subplatform index as dev->pin and the
actual platform index as dev->phy_pin.
Example:
pin 515 (subplatform pin 3)
dev->pin = 515
dev->phy_pin = 515 - 512 = 3
In this way, methods which get a mraa_gpio_context have a means
to tell whether the pin is on a subplatform or not.
Signed-off-by: Noel Eck <noel.eck@intel.com>
Updates to make the FT4222 platform extender more usable.
Previous implementation opened libft4222.so and loaded symbols as
needed. This implementation removes dynamic loading of libft4222 in
favor of creating a new shared libary which links against libft4222.so.
The dynamic loading is now done in mraa.c. One C method is exposed in
libmraa-platform-ft4222.so for finding/initializing an FT4222:
mraa_platform_t mraa_usb_platform_extender(mraa_board_t* board);
Mraa.c attempts to open this platform library and calls the
mraa_usb_platform_extender method. If an ftdi4222 is connected, the
user gets added IO from the extender. If no FT4222 device is connected,
continue as normal.
* Create a new platform library for the FT4222
* Expose only 1 C method from the library -
mraa_usb_platform_extender
* libmraa-platform-ft4222.so contains CXX code (as well as previous
C code). All *allocs have been removed in favor of global
C++ stl containers.
* Previously, the FT4222 would only initialize correctly if 2 ftdi
devices existed. Now, initialize FT4222 devices based on the
device id.
* Many fixes for various problems with the FT4222
* Added unit test for platform extender (minimal functionality w/o hw)
* Updated to FindFtd4222.cmake module to handle standard arguments
* Removed CMAKE_C_FLAGS addition of -DFTDID2XX and -DFTDI4222 since
these are NOT used anywhere in source.
* Building the FTDI4222 shim requires libft4222.h which requires
ftd2xx.h. Updated CMakeLists.txt to require both when building
the shim.
Signed-off-by: Noel Eck <noel.eck@intel.com>
The chardev feature changed the flow for most GPIO functions but did not take into account existing function hooks correctly.
This fixes the checks and restores subplatform GPIO access.
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
Went a bit too far with the previous commit. Added pointer to pointer
back to mraa_find_uart_bus_pci.
Tested leaks against valgrind and verified dev_path gets set with gdb.
Signed-off-by: Noel Eck <noel.eck@intel.com>
Unfortunately the device_path char* is dynamically allocated
and #defined and const char *'ed depending on how each platform provided the
uart device paths which makes cleaning it up more complicated.
Added a check for the IEI_TANK.
Removed the char** (in favor of a char*) for mraa_find_uart_bus_pci.)
Signed-off-by: Noel Eck <noel.eck@intel.com>
Fixes for assortment of memory leaks. Updated i2c_read/write_internal
methods to get the controller status ONLY when a read/write fails.
Signed-off-by: Noel Eck <noel.eck@intel.com>
* Fixed broken switch statement - missing 'case' in front of labels
* Added default case to switch statement
* Removed unused variable
* Removed unused static functions
* Attempted to fix cases where functions are returning/not returning
data incorrectly.
* Attempted to fix i2c read which was returning an
* uninitialized/unused variable.
Signed-off-by: Noel Eck <noel.eck@intel.com>
If numDevs is not == 2, the previous code would fail. If numDevs > 2
(example 1 ft2xx device connected and 1 ft4222 device in mode 3) then
the code would not initialize the FT4222 and give an error that the mode
must be 0 or 3.
Updated source to find the first index of a ft4222 device. Initialize
it as I2C. If another device of the same id exists, then initialize it
as GPIO.
Added more syslog messages for debugging.
Signed-off-by: Noel Eck <noel.eck@intel.com>
Add support for Hikey960 board from HiSilicon based on their Kirin960 SoC.
Peripherals supported:
1. GPIO
2. UART
3. I2C
For GPIO only Chardev interface has been added since this board only supports
>=4.15 kernel and using legacy sysfs interface is highly discouraged.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
The following APIs are only used for getting the line information from
kernel by opening the gpiochip independently and they fails to close
the file descriptor when done:
1. mraa_get_line_info_by_chip_number()
2. mraa_get_line_info_by_chip_name()
3. mraa_get_line_info_by_chip_label()
This will create issue if these API consumers like mraa_gpio_read_dir(),
mraa_gpio_mode(), mraa_gpio_chardev_dir() gets called in a loop. The
system will run out of file descriptor after some time.
Fix this issue by closing the opened file descriptors before freeing
the cinfo struct.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
Move the chardev enablement inside the platform check.
Some boards might not have the chardev mapping yet.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
The flag used for checking the kernel owned gpio line is GPIOLINE_FLAG_KERNEL.
Hence use that instead of GPIOLINE_FLAG_IS_OUT.
Flag used for checking the open source gpio line is GPIOLINE_FLAG_OPEN_SOURCE.
Hence use that instead of GPIOHANDLE_REQUEST_OPEN_SOURCE, which should be
only used when requesting lines.
Reported-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
As of now both Dragonboard410c and Hikey boards run latest LTS kernel.
Hence, adding chardev support for those.
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: malikabhi05 <abhishek.malik@intel.com>
Fixes for possible NULL pointer dereferencing by C++ header methods.
Updated string methods to return an empty string.
Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit includes a set of small fixes flushed out from the google
unit tests.
* Fixed missing implementations of mraa_get_*_count methods.
* Fix for NULL string
* Fix for MOCK platform C++ define.
* Switched (void) -> () function definitions for consistency.
Signed-off-by: Noel Eck <noel.eck@intel.com>
Added Google Test for unit testing. Currently NOT required by
MRAA CMake.
* Added a test fixture for mraa common C header methods.
* Added a test fixture for mraa common C++ header methods.
Signed-off-by: Noel Eck <noel.eck@intel.com>
Added an additional job to the CI matrix which does a minimal mraa build
(only C) which can run and pass/fail quickly.
Signed-off-by: Noel Eck <noel.eck@intel.com>
Remove some _multiple functions and replace with generic function that
does both. Some general cleanup and will move more interrnal mraa
functions to use the _mraa prefix
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>