From patchwork Sat Apr 8 11:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Patrik_Dahlstr=C3=B6m?= X-Patchwork-Id: 7920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp838092vqo; Sat, 8 Apr 2023 05:14:57 -0700 (PDT) X-Google-Smtp-Source: AKy350bGUfn61ackZDCl1EVwu38bn6c3J7u3At4BTauQxqvZ81TCodhbAfOcYgzKpKBwyVvddpAo X-Received: by 2002:a17:903:703:b0:19e:e172:2a40 with SMTP id kk3-20020a170903070300b0019ee1722a40mr5128100plb.65.1680956096954; Sat, 08 Apr 2023 05:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680956096; cv=none; d=google.com; s=arc-20160816; b=tKhv82UsdVlNFWeHha8kzGEZ5F6xY/VYPs9k2kGu+ioZ5T7sQSdC836hwpVBDe7at5 ya1YvS17jVk9MjkeqbB8wapcxFv3CanXSdb8n/RflWmotBvVUjYn1rUthAjLnIGuxihj 0YKgMm0ap702iQladkE8Q2HrYTwr0kqfem0MCta/ZwWU0M+tCdU/mc7de2+n+tFuSO0N WmCI+pEWq7e/zfmFfDFhyCbOYufIaZkByl6V8/t1M+D83NgLMTuiVmFPOZqTYTbWORZ+ 6wbyZwzrQb+8sLaTaULR5aRUYDE6MbwZreO1toyHojTn0MIscNSFLvnjC+8AEoybJtsp oflQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=WvTeccIHvOWSU0nrd5eJOb8g88ka9+Tj40GkwzFrkTk=; b=CBUfx/Tw42tP7YVM2q+0RJxQbhsjd7cwEQnseqazaftakGVAWDq4qLXCM0xtnl0H7j +z3L41i6Iajxibdxfi8JPf0xhK0Gn6FB9CCgKFhDPZOdEQLrJYHBAD4VxHhOkRsWnegI tEqE3wl2206b7u/OE50/OP34o+zJHPxNVbKWcdVVxlRjT3mlDowBD7eKFe5LPH2PT7uV rbisRdLR7T+74Y9ZDIn/U9yqhhP6RjDRZTc3cFEJncjHuSQq7UhAgZcrPA+yAreG8PiA Hod60wS45rYiJ0NQmbPk+oRwQ4L49ll6m4po801gDId6zl+hodE9eZLyFzSfzxvzil5J 01RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=Nef9P7qZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dalakolonin.se Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a170902789100b001a5145cf5d5si3591153pll.167.2023.04.08.05.14.44; Sat, 08 Apr 2023 05:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=Nef9P7qZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=dalakolonin.se Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbjDHLtI (ORCPT + 99 others); Sat, 8 Apr 2023 07:49:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229708AbjDHLtH (ORCPT ); Sat, 8 Apr 2023 07:49:07 -0400 Received: from ste-pvt-msa1.bahnhof.se (ste-pvt-msa1.bahnhof.se [213.80.101.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37819E04A; Sat, 8 Apr 2023 04:48:59 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 039A93FB25; Sat, 8 Apr 2023 13:48:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.1 X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Authentication-Results: ste-pvt-msa1.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=dalakolonin.se Received: from ste-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (ste-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZL6G4xavLotB; Sat, 8 Apr 2023 13:48:56 +0200 (CEST) Received: by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id A7F7F3F303; Sat, 8 Apr 2023 13:48:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 80E5D95F96; Sat, 8 Apr 2023 11:48:56 +0000 (UTC) Received: from zimbra.dalakolonin.se ([127.0.0.1]) by localhost (zimbra.dalakolonin.se [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id QbP9npGt_QIF; Sat, 8 Apr 2023 11:48:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 8EE9C95F92; Sat, 8 Apr 2023 11:48:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se 8EE9C95F92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680954534; bh=WvTeccIHvOWSU0nrd5eJOb8g88ka9+Tj40GkwzFrkTk=; h=From:To:Date:Message-Id:MIME-Version; b=Nef9P7qZwki5JyRB5lj3kf3Rx1g7V9lGIrBFHnQUEh4o1tXQYPleajRgu+c/KrB4m lVYpOmpecDOKEOxBVch4QpbP4MvyhMzqjpMgdFI02tHfZ+6v9jI/6CZ+u2rk1gU13N j9CFCI/Kl/mkCfkOoq+DFefPG/o6wk0M2zWovoiuhfwmOnR7a2hjRU1BHwpklRo3Cs cVklM8jG4ZtCXDpau+hnvzSV/wLER+c8ACHojY3AhMlnHC9R0rb0VvMMiCVmkoVrcC KnWyFoaqF9SxmsbWLN7swIQK6BaW+WXfoKq4tckFjKF0ukfi1kc9kQw/MAzcbhz5Ry 4fSrixHxCIPfQ== X-Virus-Scanned: amavisd-new at dalakolonin.se Received: from zimbra.dalakolonin.se ([127.0.0.1]) by localhost (zimbra.dalakolonin.se [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id NHaeZjFvjMA2; Sat, 8 Apr 2023 11:48:54 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id E7D2F95F8F; Sat, 8 Apr 2023 11:48:53 +0000 (UTC) From: =?utf-8?q?Patrik_Dahlstr=C3=B6m?= To: linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, letux-kernel@openphoenux.org, kernel@pyra-handheld.com, pgoudagunta@nvidia.com, hns@goldelico.com, jic23@kernel.org, lars@metafoo.de, linux-omap@vger.kernel.org, =?utf-8?q?Pa?= =?utf-8?q?trik_Dahlstr=C3=B6m?= Subject: [PATCH v4 0/9] iio: adc: palmas_gpadc: add iio events Date: Sat, 8 Apr 2023 13:48:16 +0200 Message-Id: <20230408114825.824505-1-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762608788346673655?= X-GMAIL-MSGID: =?utf-8?q?1762610220208658691?= This series is based on iio/togreg [1] and includes one patch ("fix NULL dereference on rmmod") which is already in linux-next and another patch from Jonathan Cameron ("Take probe fully device managed") to make the rest of the patches apply cleanly to iio/togreg. The palmas gpadc block has support for monitoring up to 2 ADC channels and issue an interrupt if they reach past a set threshold. This can be configured statically with device tree today, but it only gets enabled when reaching sleep mode. Also, it doesn't look like anyone is using it. Instead of this one special case, change the code so userspace can configure the ADC channels to their own needs through the iio events subsystem. The high and low threshold values can be set for every channel, but only 2 thresholds can be enabled at a time. Trying to enable more than 2 thresholds will result in an error. The configured thresholds will wake up the system from sleep mode if wakeup is enabled in /sys/devices/.../power/wakeup. The old platform data was removed. Thresholds, events, and wakeup were tested on omap5-uevm board. It wakes up from sleep mode when wakeup is enabled and a threshold is passed. A userspace tool for monitoring events and adjusting thresholds can be found at [2]. For more background and the use case for these patches, see [3]. V3 -> V4: * Reabased to iio/togreg and included required patches. * Avoid initializing variables unnecessarily. * Minor cosmetic fixes to comments. V2 -> V3: * Rebased to linux-next. * Avoid reconfiguring events on error and when old == new value. V1 -> V2: * Begin by removing adc_wakeupX_data instead of doing it last. * Split changes in smaller patches [1] git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git [2] https://github.com/Risca/pyra_vol_mon [3] https://pyra-handheld.com/boards/threads/improve-volume-wheel-daemon-bounty.99430/post-1711410 Jonathan Cameron (1): iio: adc: palmas: Take probe fully device managed. Patrik Dahlström (8): iio: adc: palmas_gpadc: fix NULL dereference on rmmod iio: adc: palmas: remove adc_wakeupX_data iio: adc: palmas: replace "wakeup" with "event" iio: adc: palmas: use iio_event_direction for threshold polarity iio: adc: palmas: move eventX_enable into palmas_adc_event iio: adc: palmas: always reset events on unload iio: adc: palmas: add support for iio threshold events iio: adc: palmas: don't alter event config on suspend/resume drivers/iio/adc/palmas_gpadc.c | 616 +++++++++++++++++++++++++-------- include/linux/mfd/palmas.h | 8 - 2 files changed, 478 insertions(+), 146 deletions(-) base-commit: f73df43e957a6fc705a9bd6d143585bdf1b13365