From patchwork Wed Dec 18 16:23:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 11301333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0BCD17EF for ; Wed, 18 Dec 2019 16:26:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F62A227BF for ; Wed, 18 Dec 2019 16:26:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eWz0Sju7"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="qjM3J37K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F62A227BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=MSHUyzajtQ6qgNZVbdX/kRWgRhoxhsObzLxlrTdDofc=; b=eWz0Sju7J+9xWF G3Xg+4PA9Qy6hrg8J6IJOP9m+fI68AKHnb9HFot9O433OzCbred8qiKB7HGyrnRJuUsU20fprVBlv /fFe1yZhwd91V5QhovLtjvxhFIuOy04pPq0snmwliEKc1j12glbPcFz40lo2reN7BpSzTKPEjkp13 crmL6UL4EYGWvXLA81lyGj8G2sxh1ogboEFqLKejzk1ueetiJ/Y7lWlmrBISN6CF9hLP1CbIWmVkK ykCi5B2OkmXCbq7O5mZU+u1UA5p932AxgnitYap9W2VNqn7MlPrPI4Uirwub1xzX9LJmvdCk7HjAK qzBlTDFVIot4ekD1meHQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ihcA0-0001Nk-9A; Wed, 18 Dec 2019 16:26:52 +0000 Received: from esa5.microchip.iphmx.com ([216.71.150.166]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ihc7O-0006iJ-3v for linux-arm-kernel@lists.infradead.org; Wed, 18 Dec 2019 16:24:12 +0000 Received-SPF: Pass (esa5.microchip.iphmx.com: domain of Eugen.Hristev@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Eugen.Hristev@microchip.com"; x-sender="Eugen.Hristev@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com -exists:%{i}.spf.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa5.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa5.microchip.iphmx.com; envelope-from="Eugen.Hristev@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa5.microchip.iphmx.com; spf=Pass smtp.mailfrom=Eugen.Hristev@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dkim=pass (signature verified) header.i=@microchiptechnology.onmicrosoft.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: Pj4dhcNBKEnadabKBkLJr6CQTYxW7OjkSOB1cANzjHJsAmlKJ9Qpl88AoCoae1+piF1VYbw+0X Y4Sf+mm81IdiJyAHK2PhBPQ0N2hZCX2Rs2t1EMtI8k6PWA/IaqcD79ries6v8Knu6eSdMvybm1 2+4EXdqc+hZpEqWqnXByMR3PGDoC+L5LrCpcHTes2cVQO4jmEcCMEhOwIvv/YYHa1mss21kxsC i7NEYtCwznZo11l6rUF5kJjCQCg1LExMY64ewX5wuoAZniwqFAvalTMZ5YAAa5djiUW6xvr5px xB0= X-IronPort-AV: E=Sophos;i="5.69,330,1571727600"; d="scan'208";a="59426779" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 18 Dec 2019 09:24:01 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 18 Dec 2019 09:23:58 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 18 Dec 2019 09:23:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RP/A+6l5W3Si9Lm4L+KmNhsrAiSJXA+PT0Z8jcibzEp4djtcW5QrovElkDbX6V9GM3VCHbxWnmHgAk1HKMevCNKB6rH31L/S57KIYtEAG6IbGKh1mytEXEe/NBn1jEJ1HvsSbg3WifV/2UPR2ewn+M+WLOkUJFA4OTgw3ao5lNm/ZMkKoodJ70Y01SUvPjmbQXOuwM1in1PKdZExyjmJiA44vlol1P9bTHt6uAeDnP6N6jTDDfNeShgpYJEo4S3eGwSJ4i2y14JP26sxDC0X1OH9DWloFZS6RPJ/PHIfeUlf3NJiPabjkkL/+J6wIl28kJ5tw62C69pPffB7IVZ78g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nkbxb1EvYc7ZEC/RY7x0LhCxXUt8pumOzfafB8ahW5s=; b=dGc1194ZqhltYd2KaGUyBmQDF0XeAV/R8A78XHcVWes0zFS69Si1ZEBD7qMke5cMHyyMdhF29y23DJM/x8bClqwchvhYzgYB4rwESiLW60UmSGOkPutQkj8CC/+Sli3HqQz+b+ERL00z50jHVRMR6i1BVveD08AzzAFBwZyElc6fGXG61e1vloxHszNvy9zoCK2QwBpxkJ5bnrQR0yyD3gaCAL6PDpamRdTKamuSfihXpDTiSEafmkQjlakbLdtUhmJi6yY/6KoyE0DZZTNujEL5AEJodNhCw6nnBYVB4GouuCbTIMl4ubDiAjUtr30KTt8xksqPW665J4ePhud8TQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microchip.com; dmarc=pass action=none header.from=microchip.com; dkim=pass header.d=microchip.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector2-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nkbxb1EvYc7ZEC/RY7x0LhCxXUt8pumOzfafB8ahW5s=; b=qjM3J37Kkb62vMVODHhSHORGb1h9sckkp+O/puCV4dOd7WO6/ISJrO5QB+kPiI5aVyjhQPuktrW1R5bhIir8CKFfA15RExTFlG2WuI2BP36Qy0XgtVlLGKDVTMMnErgyrf8f2ARfQKiImkMN/07BOmEsJr8V6IvESGhDzsVmJAs= Received: from DM5PR11MB1242.namprd11.prod.outlook.com (10.168.108.8) by DM5PR11MB1913.namprd11.prod.outlook.com (10.175.87.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Wed, 18 Dec 2019 16:23:58 +0000 Received: from DM5PR11MB1242.namprd11.prod.outlook.com ([fe80::9039:e0e8:9032:20c1]) by DM5PR11MB1242.namprd11.prod.outlook.com ([fe80::9039:e0e8:9032:20c1%12]) with mapi id 15.20.2559.012; Wed, 18 Dec 2019 16:23:58 +0000 From: To: , , Subject: [PATCH 00/10] Enhancements to at91-sama5d2_adc and rtc trigger Thread-Topic: [PATCH 00/10] Enhancements to at91-sama5d2_adc and rtc trigger Thread-Index: AQHVtb+MrR5owibMB0+1LePacD8d5g== Date: Wed, 18 Dec 2019 16:23:57 +0000 Message-ID: <1576686157-11939-1-git-send-email-eugen.hristev@microchip.com> Accept-Language: en-US, ro-RO Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.7.4 x-originating-ip: [94.177.32.156] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 80a705b2-8144-4f9d-da0c-08d783d6af27 x-ms-traffictypediagnostic: DM5PR11MB1913: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 0255DF69B9 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(346002)(376002)(136003)(396003)(199004)(189003)(2616005)(66556008)(316002)(107886003)(8676002)(71200400001)(8936002)(66476007)(26005)(6506007)(2906002)(64756008)(66446008)(66946007)(81156014)(76116006)(81166006)(5660300002)(478600001)(36756003)(54906003)(186003)(4326008)(86362001)(6512007)(110136005)(91956017)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR11MB1913; H:DM5PR11MB1242.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: kMd3B5gmnN3fqJ49NdX1qCNxxpFCfRvTH3vsBDAA/WJ5z1sPhFvaE3/tCGahu8HSlHRvkchL0BU7x8YeqVNSsGBGd3+U6b63590fTylC5TYLlI/jEsU0GWZ6IbISKy8R115RX3Mb1d8bJn742UD6BlB14vqS1rutCrA8i/O8Wj+T0rUkuMKVfXAbYDCCzsQTc0T+eGBdspDlta0sKoE4hkBJb7rvWXK8OvVM/jzM0Gm8SLWr4WmAlXI0wpRJMc1sElDpgh8oUuvB1z5MQqm0jBEISCgTLSChI2oAJZSUn0do6esVxWrx0F/9WKXc3OmPyJeuZBDyFL1NXY1sE5G4nVvkmw7Y3wcx6e8kkXXpvETL4C13MThm4TMQwEeCE7R9aOoA70XELPtaqI4SuykZ/ZsZ4S5qA5euXUoHsB9ZTfhFZdhdzxvAgCpxAYu46g1M MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 80a705b2-8144-4f9d-da0c-08d783d6af27 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2019 16:23:57.9030 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: lxzwzGRzhd5qNdDoHeVBwY42NsFXqV+qYWTyiux1yXFaof4+LjpdIqkE+/SbGLLECTcfTW7rk1XzoufHgkHvDQB5GnpPGwWpN1jVjPbaTFw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB1913 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191218_082410_222391_2BC2A7AB X-CRM114-Status: GOOD ( 13.95 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [216.71.150.166 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, a.zummo@towertech.it, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Ludovic.Desroches@microchip.com, Eugen.Hristev@microchip.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Eugen Hristev 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