lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1576686157-11939-1-git-send-email-eugen.hristev@microchip.com>
Date:   Wed, 18 Dec 2019 16:23:57 +0000
From:   <Eugen.Hristev@...rochip.com>
To:     <jic23@...nel.org>, <robh+dt@...nel.org>,
        <alexandre.belloni@...tlin.com>
CC:     <Nicolas.Ferre@...rochip.com>, <linux-iio@...r.kernel.org>,
        <devicetree@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <linux-rtc@...r.kernel.org>,
        <a.zummo@...ertech.it>, <Ludovic.Desroches@...rochip.com>,
        <Eugen.Hristev@...rochip.com>
Subject: [PATCH 00/10] Enhancements to at91-sama5d2_adc and rtc trigger

From: Eugen Hristev <eugen.hristev@...rochip.com>

This series includes support for having the Real Time Clock trigger
capability for the Analog to Digital Converter in sama5d2-based SoCs
(RTC ADC Trigger)

The first patch of the series has been already submitted on the iio mailing list
as
[PATCH] iio: adc: at91-sama5d2_adc: update for other trigger usage
But I also include here for reference since the other commits on the driver
use this as a base commit.

In short, the RTC block can trigger the ADC block to perform a conversion.
To solve this, I created a driver named rtc-adc-trigger that shares the
register map with the RTC. It's done in devicetree as a subnode.
This driver will register a separate trigger inside the iio subsystem.
This trigger can then be associated to the ADC driver (sysfs current_trigger).
However, this is not enough. The ADC has to be aware that it;s being
triggered by the RTC (TRGMOD and TRGSEL). So, this hardware link between
the two IPs has been described as a phandle reference in the ADC node to the
RTC trigger node.
At runtime (trigger selection), the ADC will check if the assigned trigger
is the RTC one given by the phandle link. If so, it will configure
accordingly.
The RTC trigger driver will also register to sysfs two attributes for
selecting the desired trigger frequency.
One attribute is RO : list of possible frequencies.
Another attribute is RW: current set frequency.

To achieve all this, had to make a small patch on the RTC to populate
child nodes platform data to probe them.

Fixed other issues with the adc driver: unfinished conversions on IRQ in
triggered mode, and differential channels missing configurations in
triggered mode.

For exercising this, created DT patches for sama5d2/sama5d2_xplained.

Here is a sample of how it works in sysfs:

 # cat /sys/bus/iio/devices/trigger0/trigger_frequency_hz
 1
 # echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage4_en
 # cat /sys/bus/iio/devices/
 iio:device0/        iio_sysfs_trigger/  trigger0/           trigger1/
 # cat /sys/bus/iio/devices/trigger0/name
 f80480b0.at91_rtc_adc
 # iio_generic_buffer -n fc030000.adc -t f80480b0.at91_rtc_adc -c 5
 iio device number being used is 0
 iio trigger number being used is 0
 /sys/bus/iio/devices/iio:device0 f80480b0.at91_rtc_adc
 3298.388672
 3294.360352
 3291.943359
 3294.360352
 3291.943359


Future work:
In the future the node would have to be enabled for other sama5d2 based
boards as well, and MAINTAINERS to be updated if this driver is accepted.


Eugen Hristev (10):
  iio: adc: at91-sama5d2_adc: update for other trigger usage
  dt-bindings: iio: adc: at91-sama5d2: add rtc-trigger optional property
  dt-bindings: iio: trigger: at91-rtc-trigger: add bindings
  rtc: at91rm9200: use of_platform_populate as return value
  iio: trigger: at91-rtc-trigger: introduce at91 rtc adc trigger driver
  iio: adc: at91-sama5d2_adc: handle unfinished conversions
  iio: adc: at91-sama5d2_adc: fix differential channels in triggered
    mode
  iio: adc: at91-sama5d2_adc: implement RTC triggering
  ARM: dts: at91: sama5d2: add rtc_adc_trigger node
  ARM: dts: at91: sama5d2_xplained: enable rtc_adc_trigger

 .../bindings/iio/adc/at91-sama5d2_adc.txt          |   4 +
 .../bindings/iio/trigger/at91-rtc-trigger.yaml     |  44 +++
 arch/arm/boot/dts/at91-sama5d2_xplained.dts        |   4 +
 arch/arm/boot/dts/sama5d2.dtsi                     |  11 +
 drivers/iio/adc/at91-sama5d2_adc.c                 | 336 ++++++++++++++++-----
 drivers/iio/trigger/Kconfig                        |  10 +
 drivers/iio/trigger/Makefile                       |   1 +
 drivers/iio/trigger/at91-rtc-trigger.c             | 213 +++++++++++++
 drivers/rtc/rtc-at91rm9200.c                       |   2 +-
 9 files changed, 543 insertions(+), 82 deletions(-)
 create mode 040000 Documentation/devicetree/bindings/iio/trigger
 create mode 100644 Documentation/devicetree/bindings/iio/trigger/at91-rtc-trigger.yaml
 create mode 100644 drivers/iio/trigger/at91-rtc-trigger.c

-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ