From patchwork Sat Apr 8 11:46:17 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: 7919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp837350vqo; Sat, 8 Apr 2023 05:13:26 -0700 (PDT) X-Google-Smtp-Source: AKy350ay2VtpfM/EHVYaPi1kYlYpuGYa2vnJ12BZYwlF+1mR8ORj9d5Zut5Hmio2JPkL3LjMLYrh X-Received: by 2002:a05:6a00:dc:b0:625:c631:8cea with SMTP id e28-20020a056a0000dc00b00625c6318ceamr1741500pfj.15.1680956005763; Sat, 08 Apr 2023 05:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680956005; cv=none; d=google.com; s=arc-20160816; b=gbEWagPXJpGPvUU06HPwHdUyiaL0f3puwItsJ4hVz9w3fr4Ffsqz8FtWgr0O62An5O hhHtrqkNqNQw9QcwIk24P9YMZou0GzaUKyq+UYS967CjGU5skJGkHp/2CnZ+Ee7fBZZt x5tZOj+aJ/SFu2HT9q6CCp0hU/IBfKDGZzQXA3jtHjsiexgrh/brYINJAmOU4tMETFTp wwjniPb7+r+Iq3MHY8NACA+IAR5Rg9j3HexVd2PMx10TP5I2eVCb2g4pQn940Ls4fsSh sVramaQjLEmQeyxacmZOlhrTHnq+JoTfXxvHqNKLIWLq+PCtMnl3nWeSLAO7p/Yj+Nx1 jjag== 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=aj7BJRGxp0A9WS53Fydt2hDFp/YXbSvFyWVqf4RUrfw=; b=Oq/Knhq9JwqcF6RSsO5L9isVuLidyNuCAHmMasA48PEedibGzfvGSMuEFnbBk4BZF5 GmcnHJN9kJTCTU/DzuBOP0BFHuJF+SmTiSSzKCo+UMXH3FEIwKThfN9Xbr6/aoLIhygT 8Nj6NF0QEwwosn976T8zwfdbglVvKMv3GJwYMx8fSoExKPGkG9dNra9hQB4lfliLAaT0 li0Uk+q7evw0d/VQbHIeQFMiIOVbM6nf2MnYhVZ6Tl1XBAzYLUk2f5rNdrotp8y2jcSo Uf9nS7hYbfHeqW4cBd3PPq3yJjuY11IZkJ4vJ1zm/mHwcJR4Copxk5A6TRXH3UMKb22e 8P9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b="gRLb/0FO"; 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 r9-20020aa79629000000b006321a8f0dc4si1732118pfg.234.2023.04.08.05.13.09; Sat, 08 Apr 2023 05:13:25 -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="gRLb/0FO"; 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 S229605AbjDHLqm (ORCPT + 99 others); Sat, 8 Apr 2023 07:46:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230237AbjDHLqk (ORCPT ); Sat, 8 Apr 2023 07:46:40 -0400 Received: from pio-pvt-msa1.bahnhof.se (pio-pvt-msa1.bahnhof.se [79.136.2.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A737BE1A3; Sat, 8 Apr 2023 04:46:38 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 20A6F3F5C5; Sat, 8 Apr 2023 13:46:37 +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: pio-pvt-msa1.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=dalakolonin.se Received: from pio-pvt-msa1.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa1.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xjSKraQ4BQ5q; Sat, 8 Apr 2023 13:46:36 +0200 (CEST) Received: by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id D42DF3F586; Sat, 8 Apr 2023 13:46:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 96BC595F12; Sat, 8 Apr 2023 11:46:35 +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 fu62W0fH1-mH; Sat, 8 Apr 2023 11:46:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 75C3095F0E; Sat, 8 Apr 2023 11:46:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se 75C3095F0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680954394; bh=aj7BJRGxp0A9WS53Fydt2hDFp/YXbSvFyWVqf4RUrfw=; h=From:To:Date:Message-Id:MIME-Version; b=gRLb/0FOvThhlpUVXTa7QLKES++feoRYjrWJuQiSTfUngVlEKn1wrqx1TyIseDDiv pVeR3gaspICQAfTfMLa7sEUSa57QTurjz/K6z5beiQK/iE3YsoXTyN7Nq0Ye+oHgA3 nczqxoJ15HWo61qgelwKAshHab6zM25mlxfJIFr0E9ns3NtJgfY/RQSyPCkjkg0mYD AgjkUiH2XCFt7x5Vkp5r7MEYXwAHPIO9L7UZ5OqEFROyn1Vkr/6p/fFsGETU7EGOg7 friF20P3JAnVviGfx9fuZz6PO1ulNFRl9M/GKxzdK5HiuJfRVKq6qjFbrmbiFv/FqJ pVbYKOnktZlSg== 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 N_4mZzM6CVu9; Sat, 8 Apr 2023 11:46:34 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id 1DE5C95F0B; Sat, 8 Apr 2023 11:46:34 +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 v3 0/7] iio: adc: palmas_gpadc: add iio events Date: Sat, 8 Apr 2023 13:46:17 +0200 Message-Id: <20230408114624.824144-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?1762610124779704876?= This series is based on linux-next/master [1] and [2]. 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 [3]. 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/next/linux-next.git [2] https://lore.kernel.org/linux-iio/20230318163039.56115-1-jic23@kernel.org/ [3] https://github.com/Risca/pyra_vol_mon Patrik Dahlström (7): 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 | 559 +++++++++++++++++++++++++++------ include/linux/mfd/palmas.h | 8 - 2 files changed, 464 insertions(+), 103 deletions(-) base-commit: 8417c8f5007bf4567ccffda850a3157c7d905f67 prerequisite-patch-id: b0418c707db13f514400956596e9ebe91c25bba0