From 5b115837394e7a408638c0d46cde1b689d03832f Mon Sep 17 00:00:00 2001 From: Scott Murray Date: Wed, 21 Oct 2020 18:04:18 -0400 Subject: Rework for AGL UCB integration Changes include: - The provided kernel patches have been reworked to not modify the salvator-x(s) devicetree source, but to introduce new files for the reference hardware instead. There is some possibility that the reference hardware devicetree could be based off the the salvator-x with some work and perhaps splitting of the salvator-x source, but for now the aim is to avoid breaking the salvator-x(s) with the reference hardware changes. - The modifications to the r8a7795 pinctrl driver have been replaced with a splitting of the USB interface OVC pins into their own pin groups, which has previously been done for other older Renesas hardware. This allows booting the reference hardware off of the same kernel as other H3 boards, at the expense of minor devicetree modifications for them (e.g. h3ulcb). There is likely some more work required if this needs to be upstreamed, as the ulcb.dtsi changes would mean that the pinctrl drivers for M3 would also need the new pin groups. - All changes for the ST asm330lhh driver addtion have been moved to that patch to the kernel. - A machine conf file has been added for "agl-refhw-h3", and the firmware documentation updated to document how to set up a build of the firmware using it. This is required due to the firmware options from this layer's arm-trusted-firmware bbappend not being compatible with other H3 boards (eMMC versus Hyperflash boot). A definition of the COMPATIBLE_MACHINE variable has been added to that bbappend to make sure that attempting to use it with another H3 machine will trigger an error. In AGL, the bbappend will need to be masked out with BBMASK for now. - The top-level README file has been updated to reflect the expected integration in AGL. Bug-AGL: SPEC-3658 Signed-off-by: Scott Murray --- .../linux/files/0002-add-st_asm330lhh-driver.patch | 2112 ++++++++++++++++++++ 1 file changed, 2112 insertions(+) create mode 100644 meta-agl-refhw-gen3/recipes-kernel/linux/files/0002-add-st_asm330lhh-driver.patch (limited to 'meta-agl-refhw-gen3/recipes-kernel/linux/files/0002-add-st_asm330lhh-driver.patch') diff --git a/meta-agl-refhw-gen3/recipes-kernel/linux/files/0002-add-st_asm330lhh-driver.patch b/meta-agl-refhw-gen3/recipes-kernel/linux/files/0002-add-st_asm330lhh-driver.patch new file mode 100644 index 0000000..c779b39 --- /dev/null +++ b/meta-agl-refhw-gen3/recipes-kernel/linux/files/0002-add-st_asm330lhh-driver.patch @@ -0,0 +1,2112 @@ +--- + drivers/iio/imu/st_asm330lhh/Kconfig | 22 + + drivers/iio/imu/st_asm330lhh/Makefile | 5 + + drivers/iio/imu/st_asm330lhh/README.md | 201 +++++ + drivers/iio/imu/st_asm330lhh/st_asm330lhh.h | 247 ++++++ + drivers/iio/imu/st_asm330lhh/st_asm330lhh_buffer.c | 540 ++++++++++++++ + drivers/iio/imu/st_asm330lhh/st_asm330lhh_core.c | 824 +++++++++++++++++++++ + drivers/iio/imu/st_asm330lhh/st_asm330lhh_i2c.c | 94 +++ + drivers/iio/imu/st_asm330lhh/st_asm330lhh_spi.c | 109 +++ + 8 files changed, 2042 insertions(+) + create mode 100644 drivers/iio/imu/st_asm330lhh/Kconfig + create mode 100644 drivers/iio/imu/st_asm330lhh/Makefile + create mode 100644 drivers/iio/imu/st_asm330lhh/README.md + create mode 100644 drivers/iio/imu/st_asm330lhh/st_asm330lhh.h + create mode 100644 drivers/iio/imu/st_asm330lhh/st_asm330lhh_buffer.c + create mode 100644 drivers/iio/imu/st_asm330lhh/st_asm330lhh_core.c + create mode 100644 drivers/iio/imu/st_asm330lhh/st_asm330lhh_i2c.c + create mode 100644 drivers/iio/imu/st_asm330lhh/st_asm330lhh_spi.c + +diff --git a/drivers/iio/imu/st_asm330lhh/Kconfig b/drivers/iio/imu/st_asm330lhh/Kconfig +new file mode 100644 +index 0000000..0e8920e +--- /dev/null ++++ b/drivers/iio/imu/st_asm330lhh/Kconfig +@@ -0,0 +1,22 @@ ++config IIO_ST_ASM330LHH ++ tristate "STMicroelectronics ASM330LHH sensor" ++ depends on (I2C || SPI) ++ select IIO_BUFFER ++ select IIO_KFIFO_BUF ++ select IIO_ST_ASM330LHH_I2C if (I2C) ++ select IIO_ST_ASM330LHH_SPI if (SPI_MASTER) ++ help ++ Say yes here to build support for STMicroelectronics ASM330LHH imu ++ sensor. ++ ++ To compile this driver as a module, choose M here: the module ++ will be called st_asm330lhh. ++ ++config IIO_ST_ASM330LHH_I2C ++ tristate ++ depends on IIO_ST_ASM330LHH ++ ++config IIO_ST_ASM330LHH_SPI ++ tristate ++ depends on IIO_ST_ASM330LHH ++ +diff --git a/drivers/iio/imu/st_asm330lhh/Makefile b/drivers/iio/imu/st_asm330lhh/Makefile +new file mode 100644 +index 0000000..7af80de +--- /dev/null ++++ b/drivers/iio/imu/st_asm330lhh/Makefile +@@ -0,0 +1,5 @@ ++st_asm330lhh-y := st_asm330lhh_core.o st_asm330lhh_buffer.o ++ ++obj-$(CONFIG_IIO_ST_ASM330LHH) += st_asm330lhh.o ++obj-$(CONFIG_IIO_ST_ASM330LHH_I2C) += st_asm330lhh_i2c.o ++obj-$(CONFIG_IIO_ST_ASM330LHH_SPI) += st_asm330lhh_spi.o +diff --git a/drivers/iio/imu/st_asm330lhh/README.md b/drivers/iio/imu/st_asm330lhh/README.md +new file mode 100644 +index 0000000..d471530 +--- /dev/null ++++ b/drivers/iio/imu/st_asm330lhh/README.md +@@ -0,0 +1,201 @@ ++Index ++======= ++ * Introduction ++ * Driver Integration details ++ * Android SensorHAL integration ++ * Linux SensorHAL integration ++ * More information ++ * Copyright ++ ++ ++Introduction ++============== ++This repository contains asm330lhh IMU STMicroelectronics MEMS sensor linux driver support for kernel version 4.14. ++ ++Data collected by asm330lhh STM sensor are pushed to userland through the kernel buffers of Linux IIO framework. User space applications can get sensor events by reading the related IIO devices created in the /dev directory (*/dev/iio{x}*). Please see [IIO][1] for more information. ++ ++Asm330lhh IMU STM MEMS sensor support *I2C/SPI* digital interface. Please refer to [I2C][2] and [SPI][3] for detailed documentation. ++ ++The STM Hardware Abstraction Layer (*HAL*) defines a standard interface for STM sensors allowing Android to be agnostic about low level driver implementation. The HAL library is packaged into modules (.so) file and loaded by the Android or Linux system at the appropriate time. For more information see [AOSP HAL Interface](https://source.android.com/devices/sensors/hal-interface.html) ++ ++STM Sensor HAL is leaning on [Linux IIO framework](https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/iio) to gather data from sensor device drivers and to forward samples to the Android Framework ++ ++Driver Integration details ++===================== ++ ++In order to explain how to integrate Asm330lhh IMU STM sensor into the kernel, please consider the following example ++ ++### Source code integration ++ ++> * Copy driver source code into your linux kernel target directory (e.g. *drivers/iio/imu*) ++> * Edit related Kconfig (e.g. *drivers/iio/imu/Kconfig*) adding *ASM330LHH* support: ++ ++> source "drivers/iio/imu/st_asm330lhh/Kconfig" ++ ++> * Edit related Makefile (e.g. *drivers/iio/imu/Makefile*) adding the following line: ++ ++> obj-y += st_asm330lhh/ ++ ++### Device Tree configuration ++ ++> To enable driver probing, add the asm330lhh node to the platform device tree as described below. ++ ++> **Required properties:** ++ ++> *- compatible*: "st,asm330lhh" ++ ++> *- reg*: the I2C address or SPI chip select the device will respond to ++ ++> *- interrupt-parent*: phandle to the parent interrupt controller as documented in [interrupts][4] ++ ++> *- interrupts*: interrupt mapping for IRQ as documented in [interrupts][4] ++> ++>**Recommended properties for SPI bus usage:** ++ ++> *- spi-max-frequency*: maximum SPI bus frequency as documented in [SPI][3] ++> ++> **Optional properties:** ++ ++> *- st,drdy-int-pin*: MEMS sensor interrupt line to use (default 1) ++ ++> I2C example (based on Raspberry PI 3): ++ ++> &i2c0 { ++> status = "ok"; ++> #address-cells = <0x1>; ++> #size-cells = <0x0>; ++> asm330lhh@6b { ++> compatible = "st,asm330lhh"; ++> reg = <0x6b>; ++> interrupt-parent = <&gpio>; ++> interrupts = <26 IRQ_TYPE_EDGE_RISING>; ++> }; ++ ++> SPI example (based on Raspberry PI 3): ++ ++> &spi0 { ++> status = "ok"; ++> #address-cells = <0x1>; ++> #size-cells = <0x0>; ++> asm330lhh@0 { ++> spi-max-frequency = <500000>; ++> compatible = "st,asm330lhh"; ++> reg = <0>; ++> interrupt-parent = <&gpio>; ++> interrupts = <26 IRQ_TYPE_EDGE_RISING>; ++> }; ++ ++### Kernel configuration ++ ++Configure kernel with *make menuconfig* (alternatively use *make xconfig* or *make qconfig*) ++ ++> Device Drivers ---> ++> Industrial I/O support ---> ++> Inertial measurement units ---> ++> STMicroelectronics ASM330LHH sensor ---> ++ ++ ++Android SensorHAL integration ++============== ++ ++STM Sensor HAL is written in *C++* language using object-oriented design. For each hw sensor there is a custom class file (*Accelerometer.cpp*, *Gyroscope.cpp*) which extends the common base class (*SensorBase.cpp*). ++ ++Copy the HAL source code into */hardware/STMicroelectronics/SensorHAL_IIO* folder. During building process Android will include automatically the SensorHAL Android.mk. ++In */device///device.mk* add package build information: ++ ++ PRODUCT_PACKAGES += sensors.{TARGET_BOARD_PLATFORM} ++ ++ Note: device.mk can not read $(TARGET_BOARD_PLATFORM) variable, read and replace the value from your BoardConfig.mk (e.g. PRODUCT_PACKAGES += sensors.msm8974 for Nexus 5) ++ ++To compile the SensorHAL_IIO just build AOSP source code from *$TOP* folder ++ ++ $ cd ++ $ source build/envsetup.sh ++ $ lunch