From patchwork Wed Apr 5 21:22:27 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: 79954 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp629122rwc; Wed, 5 Apr 2023 14:27:31 -0700 (PDT) X-Google-Smtp-Source: AKy350Ys8Nfi3iMs7L6Wsajr3gqUd+vmqbj7HJB0a+JqmJPR5vVoQH4x3rC29GC9sKlBJWoCU3U0 X-Received: by 2002:a05:6402:14d7:b0:4fc:6a39:d2f2 with SMTP id f23-20020a05640214d700b004fc6a39d2f2mr3652607edx.18.1680730050540; Wed, 05 Apr 2023 14:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730050; cv=none; d=google.com; s=arc-20160816; b=e3WVZBKc22fZPTasS0TmHcSq4+TSQJJue8bWxYxctPWkhYZOBfTRoJKmF3eFlrNuOi vge1NFQGT4Nsgy6EtNsOyMO4AZgHaUrW8fqjW0+IiFtojLBtYEH8yOw/AKBDOGsr+Bce xfF7vnhAT3CGz615bgxTBI17r7f6hVsg8bhVLA6+JGxVoe2jhdwnTjUHXHfz88DURqXq hBVSRaPGEbhKebzlYi6I7ivWALjQzpJWzokBPHJ1sJUtr4ZQf9XNeZds1dVLsqVxcnrM 2p6MFPwBQcvWOFXSgBzrjhxvOfOSFQVkujO6hoEFYMhV0hJB3E0lubWwRjbQzYEvgODF fj6w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=QpAkz8NzyhCd80cX7C/EMbSMfNw/jsM+n+BufT6T6ZU=; b=q4O0vq26s07l4JDiQnzd6P72GQa1z/2aAuy1d/hcvKfYoOvP09hErpEoC1Q2ut1dul rGwJY4QjWSeTVNkuM6WvPJOWlZXEOwPLz3PTT5ZX0bmQdCbJas9uk3b1ui8KB9Kvr4wg Z5ztoKAg1kqYK5PLCCa0zkDreNakQfHQh/7tcpuRn5gj4IzCnu7hDkwZkbrxZSBWYYK0 W8PkedxFPwBXbeRyzuku4krK+BHU2+3IHT1UmRFa9pO2dUqtsotgiAAPUf0Qu34q8RkX 4MgzUN214lcjI1UfbOZA88EuO/YomlG2Vm6glylbYYuH38mzuNJEuCItCJSB5qFY1uSL zw5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=jgWeIePR; 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 p25-20020a056402045900b004fefeece418si10829670edw.284.2023.04.05.14.27.07; Wed, 05 Apr 2023 14:27:30 -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=jgWeIePR; 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 S234103AbjDEVW5 (ORCPT + 99 others); Wed, 5 Apr 2023 17:22:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjDEVW4 (ORCPT ); Wed, 5 Apr 2023 17:22:56 -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 89C5F659F; Wed, 5 Apr 2023 14:22:54 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id A01A93F586; Wed, 5 Apr 2023 23:22:52 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 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 tmvn3NSw37ur; Wed, 5 Apr 2023 23:22:51 +0200 (CEST) Received: by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 9CF373F2DD; Wed, 5 Apr 2023 23:22:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 2C4D594DD1; Wed, 5 Apr 2023 21:22:51 +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 AxWYc146xV64; Wed, 5 Apr 2023 21:22:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 62B4394DCB; Wed, 5 Apr 2023 21:22:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se 62B4394DCB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729768; bh=QpAkz8NzyhCd80cX7C/EMbSMfNw/jsM+n+BufT6T6ZU=; h=From:To:Date:Message-Id:MIME-Version; b=jgWeIePR+F31mf6PsgTwYe1TFFtCnPNBbUyzHlwVCTjx6PSdBV6na5YhqmqJ5VDoa MLa7A0pxYOSgdT0+bPdXlHZ4KjvL9Jr69jo780On1IOdObuXABRPf8r1jyLPexiYpw Vh+jMg82f757l+Z0wZhbpQwL86JWike+LDnx41GjgxI/56VyczzJebUUV/35EbXsw/ 30tBIEZdKTAJKDmYmaR3AnIwqIh0Y7NQoDONF7nREhkX0/Onnqy6yvtZn/AC+tuLW5 tO2pRQeLdNZIb+rbDMJkIjoiucDG+Q1/iWrYE9BrAtUi9j0TDijySADELfi9vYrRcI s3rYPgkZtrG0A== 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 3lQsBSGNDPZ6; Wed, 5 Apr 2023 21:22:47 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id 7361294DC5; Wed, 5 Apr 2023 21:22:47 +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 1/7] iio: adc: palmas: remove adc_wakeupX_data Date: Wed, 5 Apr 2023 23:22:27 +0200 Message-Id: <20230405212233.4167986-2-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373193039628472?= X-GMAIL-MSGID: =?utf-8?q?1762373193039628472?= It does not seem to be used by anyone and later patches in this series are made simpler by first removing this. There is now a lot of dead code that cannot be reached, until later patches revive it. Arguably, this is preferred over removing the code only to add it again. Signed-off-by: Patrik Dahlström --- drivers/iio/adc/palmas_gpadc.c | 50 ++++------------------------------ include/linux/mfd/palmas.h | 8 ------ 2 files changed, 6 insertions(+), 52 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 2921186458e0..03af6cd73ec8 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -76,6 +76,12 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = { PALMAS_ADC_INFO(IN15, 0, 0, 0, 0, INVALID, INVALID, true), }; +struct palmas_adc_wakeup_property { + int adc_channel_number; + int adc_high_threshold; + int adc_low_threshold; +}; + /* * struct palmas_gpadc - the palmas_gpadc structure * @ch0_current: channel 0 current source setting @@ -493,11 +499,6 @@ static int palmas_gpadc_get_adc_dt_data(struct platform_device *pdev, return 0; } -static void palmas_disable_wakeup(void *dev) -{ - device_wakeup_disable(dev); -} - static int palmas_gpadc_probe(struct platform_device *pdev) { struct palmas_gpadc *adc; @@ -548,36 +549,6 @@ static int palmas_gpadc_probe(struct platform_device *pdev) return dev_err_probe(adc->dev, ret, "request irq %d failed\n", adc->irq); - if (gpadc_pdata->adc_wakeup1_data) { - memcpy(&adc->wakeup1_data, gpadc_pdata->adc_wakeup1_data, - sizeof(adc->wakeup1_data)); - adc->wakeup1_enable = true; - adc->irq_auto_0 = platform_get_irq(pdev, 1); - ret = devm_request_threaded_irq(&pdev->dev, adc->irq_auto_0, - NULL, palmas_gpadc_irq_auto, - IRQF_ONESHOT, - "palmas-adc-auto-0", adc); - if (ret < 0) - return dev_err_probe(adc->dev, ret, - "request auto0 irq %d failed\n", - adc->irq_auto_0); - } - - if (gpadc_pdata->adc_wakeup2_data) { - memcpy(&adc->wakeup2_data, gpadc_pdata->adc_wakeup2_data, - sizeof(adc->wakeup2_data)); - adc->wakeup2_enable = true; - adc->irq_auto_1 = platform_get_irq(pdev, 2); - ret = devm_request_threaded_irq(&pdev->dev, adc->irq_auto_1, - NULL, palmas_gpadc_irq_auto, - IRQF_ONESHOT, - "palmas-adc-auto-1", adc); - if (ret < 0) - return dev_err_probe(adc->dev, ret, - "request auto1 irq %d failed\n", - adc->irq_auto_1); - } - /* set the current source 0 (value 0/5/15/20 uA => 0..3) */ if (gpadc_pdata->ch0_current <= 1) adc->ch0_current = PALMAS_ADC_CH0_CURRENT_SRC_0; @@ -617,15 +588,6 @@ static int palmas_gpadc_probe(struct platform_device *pdev) palmas_gpadc_calibrate(adc, i); } - if (adc->wakeup1_enable || adc->wakeup2_enable) { - device_wakeup_enable(&pdev->dev); - ret = devm_add_action_or_reset(&pdev->dev, - palmas_disable_wakeup, - &pdev->dev); - if (ret) - return ret; - } - return 0; } diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h index 117d02708439..eda1ffd99c1a 100644 --- a/include/linux/mfd/palmas.h +++ b/include/linux/mfd/palmas.h @@ -128,12 +128,6 @@ struct palmas_pmic_driver_data { struct regulator_config config); }; -struct palmas_adc_wakeup_property { - int adc_channel_number; - int adc_high_threshold; - int adc_low_threshold; -}; - struct palmas_gpadc_platform_data { /* Channel 3 current source is only enabled during conversion */ int ch3_current; /* 0: off; 1: 10uA; 2: 400uA; 3: 800 uA */ @@ -152,8 +146,6 @@ struct palmas_gpadc_platform_data { int start_polarity; int auto_conversion_period_ms; - struct palmas_adc_wakeup_property *adc_wakeup1_data; - struct palmas_adc_wakeup_property *adc_wakeup2_data; }; struct palmas_reg_init { From patchwork Wed Apr 5 21:22:28 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: 79959 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp630272rwc; Wed, 5 Apr 2023 14:30:17 -0700 (PDT) X-Google-Smtp-Source: AKy350YyWTNNcqgCByG4oFlUZraZdC1uJc8HIzDyjsWokMgJ/0jKrvCFsxE5Beg+FodH+e4nFmnl X-Received: by 2002:a17:906:3b04:b0:931:d277:78a4 with SMTP id g4-20020a1709063b0400b00931d27778a4mr4683491ejf.30.1680730217414; Wed, 05 Apr 2023 14:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730217; cv=none; d=google.com; s=arc-20160816; b=Zck3xnYi3mb1QO7UBXOYpkUR1t++RZL5hJy0N1kHgwJmW8IPxddvqjuLG0IBLux6wK yTGALljSn6MIJV8J8zX+EIxc/jWsx5ftwfj+xHycYAnYmOq0ufjn58Kwv9z6onitdPmM tckr59scqNFnD9uMtBHFzXY3xYQZQaPvovCi/MlwOywgIhIbJfXT2IXf6YNFuUGQVFZU e00to5h7aPg0xFb1y4z6dWn81xXWaq0Mp+B9hGlEERW8FQ1nUvTjmrZK5IjzWmYxRpZL QwrkorqCwNkNWticPTayhJfaO8NjIiffiQmXBnd4VsHdJgCJPMLqr3dm6dgLaPAQAjaa Elmw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=WEa42btgt5YoGy4wRFO15STm/DxrasoQ4xEIrCOV4as=; b=tXTUkpkVQEkxjDlf5t0TNKG1x1PpTuSqPI4gcwScG8cYJ3UPUTVZgKDVQWDepxVUvg EMwydmUGUPR91sx9Xqh1xkKcY15ISO+AFtVQ+g8HJ8wYcED4sZ+rkB6dka0VKgGLSIy3 xJZmFhgCJriptbjvqtdvhf1xaNxuaa+sXWJqJfE7+zmw+FH53VOItDOs6sesZeCzfIVN T5Kh9xBxp3tswWpmftLlh0KxpuuUa2AfzS/28MYxAk/9hVdPVQIfS3sY+EEf+6zuHxw4 aFLPSI17tJJvPqiqg2ckAHozCS3Yux7zv+pz2NH0xnRi33+cqbhZLvSeOaZviBTKSe69 FSmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b="jcL/+c1u"; 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 ss15-20020a170907038f00b009301df0b15asi9616080ejb.62.2023.04.05.14.29.53; Wed, 05 Apr 2023 14:30:17 -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="jcL/+c1u"; 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 S233470AbjDEVXq (ORCPT + 99 others); Wed, 5 Apr 2023 17:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232876AbjDEVXb (ORCPT ); Wed, 5 Apr 2023 17:23:31 -0400 Received: from pio-pvt-msa3.bahnhof.se (pio-pvt-msa3.bahnhof.se [79.136.2.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 018A211D; Wed, 5 Apr 2023 14:23:18 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id AE8783F8A3; Wed, 5 Apr 2023 23:23:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Authentication-Results: pio-pvt-msa3.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=dalakolonin.se Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O0BBc1TQFAsG; Wed, 5 Apr 2023 23:23:16 +0200 (CEST) Received: by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id A11AC3F7F6; Wed, 5 Apr 2023 23:23:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 7D4F294E16; Wed, 5 Apr 2023 21:23:15 +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 X-BWrBWRI1uS; Wed, 5 Apr 2023 21:22:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 79E9294DD4; Wed, 5 Apr 2023 21:22:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se 79E9294DD4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729771; bh=WEa42btgt5YoGy4wRFO15STm/DxrasoQ4xEIrCOV4as=; h=From:To:Date:Message-Id:MIME-Version; b=jcL/+c1up0GWwUPaFBdcGhSDeWRBe65UcZ8RltysdL7W0It0+txIHC8mQtsCG1yRk CVb9rsNWDjxSrwyEbqRNbLlUxCrrfcvyJsBlxqXafsar4tYnJTzyABeGQkQ05LNH2U MpzmNlYkQ8/yTO+YywHs7sZ/wES3BzFvaWV0WPwVbaIbs1J70jF813CRM4+Fd1fMzU k6t9oZdfBZXQFGr1DDGsuTqp22IVqprOARfo9hbbl86nPoVncf+G+axTcE3exSUT0Z uIL/sVClmiIbaNG7GIihKBFhrcVGqcTsqmc90Wg38aXWoATGIvSIhbuXOXelKEusDT 4L5G0GJk0JG+w== 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 Dl_JdPTUq3Db; Wed, 5 Apr 2023 21:22:51 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id 0491494DCF; Wed, 5 Apr 2023 21:22:50 +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 2/7] iio: adc: palmas: replace "wakeup" with "event" Date: Wed, 5 Apr 2023 23:22:28 +0200 Message-Id: <20230405212233.4167986-3-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373368305935349?= X-GMAIL-MSGID: =?utf-8?q?1762373368305935349?= 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 is currently used to wake up the system from sleep, but the functionality is more generic than that. As such, change the naming of functions and variables to refer to it as events instead, except during suspend and resume where wakeup still make sense. Signed-off-by: Patrik Dahlström --- drivers/iio/adc/palmas_gpadc.c | 50 +++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 03af6cd73ec8..55fdf59ef711 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -76,7 +76,7 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = { PALMAS_ADC_INFO(IN15, 0, 0, 0, 0, INVALID, INVALID, true), }; -struct palmas_adc_wakeup_property { +struct palmas_adc_event { int adc_channel_number; int adc_high_threshold; int adc_low_threshold; @@ -117,10 +117,10 @@ struct palmas_gpadc { int irq_auto_1; struct palmas_gpadc_info *adc_info; struct completion conv_completion; - struct palmas_adc_wakeup_property wakeup1_data; - struct palmas_adc_wakeup_property wakeup2_data; - bool wakeup1_enable; - bool wakeup2_enable; + struct palmas_adc_event event0; + struct palmas_adc_event event1; + bool event0_enable; + bool event1_enable; int auto_conversion_period; struct mutex lock; }; @@ -591,7 +591,7 @@ static int palmas_gpadc_probe(struct platform_device *pdev) return 0; } -static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc) +static int palmas_adc_configure_events(struct palmas_gpadc *adc) { int adc_period, conv; int i; @@ -617,16 +617,16 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc) } conv = 0; - if (adc->wakeup1_enable) { + if (adc->event0_enable) { int polarity; - ch0 = adc->wakeup1_data.adc_channel_number; + ch0 = adc->event0.adc_channel_number; conv |= PALMAS_GPADC_AUTO_CTRL_AUTO_CONV0_EN; - if (adc->wakeup1_data.adc_high_threshold > 0) { - thres = adc->wakeup1_data.adc_high_threshold; + if (adc->event0.adc_high_threshold > 0) { + thres = adc->event0.adc_high_threshold; polarity = 0; } else { - thres = adc->wakeup1_data.adc_low_threshold; + thres = adc->event0.adc_low_threshold; polarity = PALMAS_GPADC_THRES_CONV0_MSB_THRES_CONV0_POL; } @@ -648,16 +648,16 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc) } } - if (adc->wakeup2_enable) { + if (adc->event1_enable) { int polarity; - ch1 = adc->wakeup2_data.adc_channel_number; + ch1 = adc->event1.adc_channel_number; conv |= PALMAS_GPADC_AUTO_CTRL_AUTO_CONV1_EN; - if (adc->wakeup2_data.adc_high_threshold > 0) { - thres = adc->wakeup2_data.adc_high_threshold; + if (adc->event1.adc_high_threshold > 0) { + thres = adc->event1.adc_high_threshold; polarity = 0; } else { - thres = adc->wakeup2_data.adc_low_threshold; + thres = adc->event1.adc_low_threshold; polarity = PALMAS_GPADC_THRES_CONV1_MSB_THRES_CONV1_POL; } @@ -696,7 +696,7 @@ static int palmas_adc_wakeup_configure(struct palmas_gpadc *adc) return ret; } -static int palmas_adc_wakeup_reset(struct palmas_gpadc *adc) +static int palmas_adc_reset_events(struct palmas_gpadc *adc) { int ret; @@ -718,20 +718,20 @@ static int palmas_gpadc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct palmas_gpadc *adc = iio_priv(indio_dev); - int wakeup = adc->wakeup1_enable || adc->wakeup2_enable; + int wakeup = adc->event0_enable || adc->event1_enable; int ret; if (!device_may_wakeup(dev) || !wakeup) return 0; - ret = palmas_adc_wakeup_configure(adc); + ret = palmas_adc_configure_events(adc); if (ret < 0) return ret; - if (adc->wakeup1_enable) + if (adc->event0_enable) enable_irq_wake(adc->irq_auto_0); - if (adc->wakeup2_enable) + if (adc->event1_enable) enable_irq_wake(adc->irq_auto_1); return 0; @@ -741,20 +741,20 @@ static int palmas_gpadc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct palmas_gpadc *adc = iio_priv(indio_dev); - int wakeup = adc->wakeup1_enable || adc->wakeup2_enable; + int wakeup = adc->event0_enable || adc->event1_enable; int ret; if (!device_may_wakeup(dev) || !wakeup) return 0; - ret = palmas_adc_wakeup_reset(adc); + ret = palmas_adc_reset_events(adc); if (ret < 0) return ret; - if (adc->wakeup1_enable) + if (adc->event0_enable) disable_irq_wake(adc->irq_auto_0); - if (adc->wakeup2_enable) + if (adc->event1_enable) disable_irq_wake(adc->irq_auto_1); return 0; From patchwork Wed Apr 5 21:22:29 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: 79955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp629277rwc; Wed, 5 Apr 2023 14:27:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ZdRfUPa2h0eGjpP+t6SQ/+IgotqRPMaGKwec2G2D15DIpsQrv9chTNtqN4lofe6AIk+TPs X-Received: by 2002:a17:906:a3c1:b0:8b2:8876:6a3c with SMTP id ca1-20020a170906a3c100b008b288766a3cmr4214573ejb.29.1680730078917; Wed, 05 Apr 2023 14:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730078; cv=none; d=google.com; s=arc-20160816; b=nxZzUpYsBLvEJcgGDhnSBn4q84ewgBZ72uVCUdvNgZhpy9PExnGmn1mAF/gcYwtqpl EtTFwxZu0H6hpLNjUMnxDJZYAhw/qj1T+kMcRKcQ7Gka+IYElo2j1NHrdQqAJ7tMcCcu 3qbJPRn/tmCPhgfNi67gaAc6QEzomBjvRqJJ9HEHyOiDDY5bj5Jha6UOIJJJ89jkhZBX w7PXhxXLUH0bQYBlN+bw+Myxc3dyZrcwhGjW/cw13WkkSDgTsbwgRaeklwOLXjR2FMAL kFgAghv+EujPY0zZUXx0JfjrnibFy5GeBUisEHUwKdb7PGHGK2GUFwjwEVvQljdE/kRJ Omcw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=8oCsKoWj+OT4dqdz4wKUl0ESprUGM0ZozVBAf1AeyA0=; b=IAhkOttYXSnduz6n9/2wZ0CcusLnp31oP/8BNjZTuPE4tubbt/YmQm2gdI91ZeY2oy fnjk8G+GmBceDnNzCb5kKsKQKkGABHOEeOk/K38kX9hYTeD6oGTvjwy0LZVJiP6OdWE1 qPh/xeIh5OAlomr4p3S3gm3MAnxAdBvYzPZ7Nke8y+jRZ4IYc9znJDpAub8OoAGZN2oY pEnIdHkrt1IpLE5HClcEhOFaCOt2qxGaybeqOCZBRemteJRXnTjMpJ8qVu46KJEeh3gQ alkQRLlVH+s8tpon5eXcC2gbHFYNlMc+empO8tkHjFNBc1t2ikYrleqwE8UvBrM8U/An 6h5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=pq5LjY4s; 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 q20-20020a170906145400b008ce4075b9e3si473269ejc.725.2023.04.05.14.27.34; Wed, 05 Apr 2023 14:27:58 -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=pq5LjY4s; 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 S229693AbjDEVXY (ORCPT + 99 others); Wed, 5 Apr 2023 17:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234251AbjDEVXS (ORCPT ); Wed, 5 Apr 2023 17:23:18 -0400 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8D1E61BF; Wed, 5 Apr 2023 14:23:09 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 3AD023F4DA; Wed, 5 Apr 2023 23:23:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 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-msa2.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=dalakolonin.se Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id t_WA2Mg8pMkx; Wed, 5 Apr 2023 23:23:06 +0200 (CEST) Received: by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 7FA1B3F3A9; Wed, 5 Apr 2023 23:23:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id D88F094DFA; Wed, 5 Apr 2023 21:23:05 +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 B7jsiih08e8c; Wed, 5 Apr 2023 21:22:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id CEA1694DD9; Wed, 5 Apr 2023 21:22:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se CEA1694DD9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729774; bh=8oCsKoWj+OT4dqdz4wKUl0ESprUGM0ZozVBAf1AeyA0=; h=From:To:Date:Message-Id:MIME-Version; b=pq5LjY4swcA7YwZoss5qZBn7Fk1BvLJhUJIuWLkUq5nm3e2Igysq6O8u1JGxWl8B7 kiBoE6wPmAiRbGO+c3Y/2+2xyNuht2Zi6siVsMMczPUPLrQJ9CZreWGJ8BV0/MnVfA p+sDlXcrEFImDUeu9htb3XfZCm7p1NewTd9BflLVy/ZKpx7TGAVo35iLxr23U5h3Pr x4i6ZiYwmYS8jVAOJpitJx7HQnx6LlZJetTiaTT1AJCRB9wmflCHo5oBLbftDENzfQ 8Z6aS1Ucd7TbDiV4c+G2yiihihHquGNn+KvLMbYV6Q/5+HcBkjQRBZkqg6jD50rCmn F88yrunmXTnzw== 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 Uv4ko-kqoacb; Wed, 5 Apr 2023 21:22:54 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id BD65F94DD6; Wed, 5 Apr 2023 21:22: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 v3 3/7] iio: adc: palmas: use iio_event_direction for threshold polarity Date: Wed, 5 Apr 2023 23:22:29 +0200 Message-Id: <20230405212233.4167986-4-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373223046325533?= X-GMAIL-MSGID: =?utf-8?q?1762373223046325533?= Instead of having high_threshold > 0 as an indicator for upper threshold event and lower threshold event otherwise, use enum iio_event_direction instead. This is hopefully less ambiguous. Signed-off-by: Patrik Dahlström --- drivers/iio/adc/palmas_gpadc.c | 36 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 55fdf59ef711..205a7628b235 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -77,9 +77,9 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = { }; struct palmas_adc_event { - int adc_channel_number; - int adc_high_threshold; - int adc_low_threshold; + int channel; + int raw_thresh; + enum iio_event_direction direction; }; /* @@ -618,16 +618,21 @@ static int palmas_adc_configure_events(struct palmas_gpadc *adc) conv = 0; if (adc->event0_enable) { + struct palmas_adc_event *ev = &adc->event0; int polarity; - ch0 = adc->event0.adc_channel_number; + ch0 = ev->channel; + thres = ev->raw_thresh; conv |= PALMAS_GPADC_AUTO_CTRL_AUTO_CONV0_EN; - if (adc->event0.adc_high_threshold > 0) { - thres = adc->event0.adc_high_threshold; + switch (ev->direction) { + case IIO_EV_DIR_RISING: polarity = 0; - } else { - thres = adc->event0.adc_low_threshold; + break; + case IIO_EV_DIR_FALLING: polarity = PALMAS_GPADC_THRES_CONV0_MSB_THRES_CONV0_POL; + break; + default: + return -EINVAL; } ret = palmas_write(adc->palmas, PALMAS_GPADC_BASE, @@ -649,16 +654,21 @@ static int palmas_adc_configure_events(struct palmas_gpadc *adc) } if (adc->event1_enable) { + struct palmas_adc_event *ev = &adc->event1; int polarity; - ch1 = adc->event1.adc_channel_number; + ch1 = ev->channel; + thres = ev->raw_thresh; conv |= PALMAS_GPADC_AUTO_CTRL_AUTO_CONV1_EN; - if (adc->event1.adc_high_threshold > 0) { - thres = adc->event1.adc_high_threshold; + switch (ev->direction) { + case IIO_EV_DIR_RISING: polarity = 0; - } else { - thres = adc->event1.adc_low_threshold; + break; + case IIO_EV_DIR_FALLING: polarity = PALMAS_GPADC_THRES_CONV1_MSB_THRES_CONV1_POL; + break; + default: + return -EINVAL; } ret = palmas_write(adc->palmas, PALMAS_GPADC_BASE, From patchwork Wed Apr 5 21:22:30 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: 79958 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp630219rwc; Wed, 5 Apr 2023 14:30:13 -0700 (PDT) X-Google-Smtp-Source: AKy350aPRDDBBN3T4rd99scuUYvvFl2+TzqyCSyJE3IOElfAsgyIhPCSqtfa0qw93qq0vINgS3DQ X-Received: by 2002:a17:906:5e53:b0:946:bd15:b13f with SMTP id b19-20020a1709065e5300b00946bd15b13fmr3846029eju.44.1680730212821; Wed, 05 Apr 2023 14:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730212; cv=none; d=google.com; s=arc-20160816; b=cb3VSTYE7IGVAiyh2rbxZD0pRKAAgdujn6bw3vloC3c670fDepYQQSGRqeOYiDSInB mx9GX1BFHmkmOEmRcFyQM7t8pUFNtNbKd44pXgXiyUokb/qwDnHiRA3NR5b3t5o+fbSP hz6P6TdsaNxDnfS6fs4hSAyIYfZewVCp1w3zob4XNWxQmMS/62PDggrsKwPkAZkiY7Vj 0YrnXrXVYPjbme/92DydLuVy5GfilgpPzjF1ADmSSu6P1M+FIk6Ues7nuhV0f71y/VOf tr5SQHUai/LZ+QO/kRs9IqsNJyNJQaq9pXwFAqydh3dQlrL+SFbXRPcXjIIhuz6luEWe faJQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=TmuWTPcVR6kjhWZxrkfB1qR/xKdRysUauxZUpzZtF7k=; b=OilhboKef/Py/+XJOkfkhKzc9ZgDTTZzLsfcHVKoVkPbG1J0K4lk+CkXcJsFoIgBJ/ yzJpk0IRPEzTMacDWAgNVbAUkcvzHZ+7ZA1Iyygy+I3XnWNT4a55/Om3Q00vp2dTltkm kIMgxf8xF5t9vbBvSKFGuO8kZ2NWR/2/5N8Cl/O5MX78IE6eK+3/W88olx4r2wM6QLyf fiNRIt4cx8jOVsWLl5eb9B4BgQQoWqPwCnjHvcf7T3d26ArKa5ztxKFJv00vGHXMODR4 Vu0wUkqBpC9WHIWT4Wgp8wSxRZlWQng8qMet+Iy2cJYxtFALi/HIrohx3t2ZG0hewzWE gMEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=PSPEYxqe; 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 d21-20020a17090694d500b0092cdece0c4csi12753757ejy.201.2023.04.05.14.29.46; Wed, 05 Apr 2023 14:30:12 -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=PSPEYxqe; 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 S234297AbjDEVXf (ORCPT + 99 others); Wed, 5 Apr 2023 17:23:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbjDEVX3 (ORCPT ); Wed, 5 Apr 2023 17:23:29 -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 13DD97DA4; Wed, 5 Apr 2023 14:23:14 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 62BBF3FA21; Wed, 5 Apr 2023 23:23:13 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 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 IcLgFRpfqez1; Wed, 5 Apr 2023 23:23:12 +0200 (CEST) Received: by pio-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 6B7123F870; Wed, 5 Apr 2023 23:23:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id F3D0B94E01; Wed, 5 Apr 2023 21:23:08 +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 mHGQsfKd3kNV; Wed, 5 Apr 2023 21:23:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id DA7C694DE1; Wed, 5 Apr 2023 21:22:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se DA7C694DE1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729778; bh=TmuWTPcVR6kjhWZxrkfB1qR/xKdRysUauxZUpzZtF7k=; h=From:To:Date:Message-Id:MIME-Version; b=PSPEYxqePHdQP9cLR80UV50OIXfmQU2Chwoq5lbcziAM7e0A6IUs6LMYPldLAlChF C66rMH+yhRkh8tAOrjUdei9uEiAcmvl2V2pZXYa4qISknTCpxVDUPundcTVvDyDoQK OntzqsIIseATFk4XoXWnamZTN3OLWYbLmM0WNOSdY7FoqHyPGJiwRRGICK/MaE0tkb DRPMSU2Lm/F/HLBMoOPJR481qN1ZPiz1c/FO67YdMEhN9c+RXm77TA0CA6Fa0sjdMt NoMD+oqyZHHOez1DZNx2bQd0U9ssHJU8TdBebbVWVIpGMoP1mZMNYtRn92m6cXcucG +Cga0AS/RsH+A== 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 FO5mvdtNXwa9; Wed, 5 Apr 2023 21:22:57 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id C1D6A94DDA; Wed, 5 Apr 2023 21:22:56 +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 4/7] iio: adc: palmas: move eventX_enable into palmas_adc_event Date: Wed, 5 Apr 2023 23:22:30 +0200 Message-Id: <20230405212233.4167986-5-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373363639515308?= X-GMAIL-MSGID: =?utf-8?q?1762373363639515308?= It just makes more sense to have all information regarding adc events in one place. Signed-off-by: Patrik Dahlström --- drivers/iio/adc/palmas_gpadc.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 205a7628b235..8c6ea4a3cd2e 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -77,6 +77,7 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = { }; struct palmas_adc_event { + bool enabled; int channel; int raw_thresh; enum iio_event_direction direction; @@ -119,8 +120,6 @@ struct palmas_gpadc { struct completion conv_completion; struct palmas_adc_event event0; struct palmas_adc_event event1; - bool event0_enable; - bool event1_enable; int auto_conversion_period; struct mutex lock; }; @@ -617,7 +616,7 @@ static int palmas_adc_configure_events(struct palmas_gpadc *adc) } conv = 0; - if (adc->event0_enable) { + if (adc->event0.enabled) { struct palmas_adc_event *ev = &adc->event0; int polarity; @@ -653,7 +652,7 @@ static int palmas_adc_configure_events(struct palmas_gpadc *adc) } } - if (adc->event1_enable) { + if (adc->event1.enabled) { struct palmas_adc_event *ev = &adc->event1; int polarity; @@ -728,7 +727,7 @@ static int palmas_gpadc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct palmas_gpadc *adc = iio_priv(indio_dev); - int wakeup = adc->event0_enable || adc->event1_enable; + int wakeup = adc->event0.enabled || adc->event1.enabled; int ret; if (!device_may_wakeup(dev) || !wakeup) @@ -738,10 +737,10 @@ static int palmas_gpadc_suspend(struct device *dev) if (ret < 0) return ret; - if (adc->event0_enable) + if (adc->event0.enabled) enable_irq_wake(adc->irq_auto_0); - if (adc->event1_enable) + if (adc->event1.enabled) enable_irq_wake(adc->irq_auto_1); return 0; @@ -751,7 +750,7 @@ static int palmas_gpadc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct palmas_gpadc *adc = iio_priv(indio_dev); - int wakeup = adc->event0_enable || adc->event1_enable; + int wakeup = adc->event0.enabled || adc->event1.enabled; int ret; if (!device_may_wakeup(dev) || !wakeup) @@ -761,10 +760,10 @@ static int palmas_gpadc_resume(struct device *dev) if (ret < 0) return ret; - if (adc->event0_enable) + if (adc->event0.enabled) disable_irq_wake(adc->irq_auto_0); - if (adc->event1_enable) + if (adc->event1.enabled) disable_irq_wake(adc->irq_auto_1); return 0; From patchwork Wed Apr 5 21:22:31 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: 79956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp629570rwc; Wed, 5 Apr 2023 14:28:40 -0700 (PDT) X-Google-Smtp-Source: AKy350br9mwp5nDAlU28aYjtha8fdnZhpv5XY/XEdviIEqWoD0egTnmGVNG2hXg8yYMkiANFiIn+ X-Received: by 2002:a05:6402:152:b0:4fd:1cf1:b7b0 with SMTP id s18-20020a056402015200b004fd1cf1b7b0mr2689624edu.7.1680730120742; Wed, 05 Apr 2023 14:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730120; cv=none; d=google.com; s=arc-20160816; b=xsLnI3z8lx/uxOobvkhz0VjhzbcxRJzjGaI1SFRJ5JJquvKAiUWQodnUjWfGgHrpTM i/kgGqAEXw3GqgfK/DMuxoX4do5biRfs6B9IquXBnxV82cgvG3MJBswcpgK25cgCg4SO QBrkba+Czk8awB/68w/ZCIpgzXF/MfKdJNMfEzMBpzbh3G90SG3NbqlROvJeRPP7LAbs X1hXEAKEDTxV7jGeiDzlytGEZRpaRmtAXH06rfNRoCvHT9UHDYn1mEySVLxUXKO1uGBj EG1qkGraPrxI/W/wOCqATvYxHDlJ01+gF8pY9SxCgh48rezuISQxddXModrx2dhBncMR m34w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=46bAIQhprw5uAV/CIe/YRgQOYjSd553x4RWwfAtfJJI=; b=NQjIBLU2QSmyiC0Tt34He3M1ZIY1pwP2tqBe//NRKtn7STJ9bmO7eZ08M9dZ0tEztY frKELNLBUep8ALoB9h+qOCE1rnKN2DC/AvV6pgm93ZKbrfTKKwap7X3dJYI98Px/InOJ pKe6LJ8DF/7Pm9JbrWChOyQ9wP4viW6Se0/2Yvp5vEP1OB0zO2goBNX5O9d0t5IW3VVd NECF3CcOModHUzi+jo1oezlNqKUOiZLOFf69r+t8aWSgcJzhjTTw82IvQM0SJioAi7rO D2ROL7DdQKRfgVqsOJEuiY5K+LKWURx/dkyhXmVWpCFDVC7I7v4meZVnqIlkxOthN/3D cx0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=W1n9mCzI; 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 w2-20020aa7d282000000b005024aa3e836si3459edq.394.2023.04.05.14.27.59; Wed, 05 Apr 2023 14:28:40 -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=W1n9mCzI; 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 S234598AbjDEVXu (ORCPT + 99 others); Wed, 5 Apr 2023 17:23:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234539AbjDEVXh (ORCPT ); Wed, 5 Apr 2023 17:23:37 -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 F3A9FCA; Wed, 5 Apr 2023 14:23:23 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTP id 10D443F716; Wed, 5 Apr 2023 23:23:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 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 7qB-PXVyeJ_f; Wed, 5 Apr 2023 23:23:21 +0200 (CEST) Received: by ste-pvt-msa1.bahnhof.se (Postfix) with ESMTPA id 3C6893F56D; Wed, 5 Apr 2023 23:23:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 923D194E2A; Wed, 5 Apr 2023 21:23:18 +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 BhJ80WM7Jc-I; Wed, 5 Apr 2023 21:23:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 9F22094DEF; Wed, 5 Apr 2023 21:23:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se 9F22094DEF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729782; bh=46bAIQhprw5uAV/CIe/YRgQOYjSd553x4RWwfAtfJJI=; h=From:To:Date:Message-Id:MIME-Version; b=W1n9mCzIB0IzFCnyUDHPyVLdpqLfBFKhQ2kIloBOSjzwKePoRZQ0IPQD/hhh9BORf sOpeVYT8OEwF9KQSs/xAbaPUvhGF9phAoHLVJaQvVhtNjGU2gPYxcrOEKjn/+AGzm2 sm+YDhX9umMgPm+YEh0YoARv8S76jNPiYlez1opD/kW7s32NiUxodTnQV0GEaN+j6o XGhfQQwyqn3rLTKNwDXbnA/brz++EhSMKKNY+WzH1P5jQLQ7SxtO/y/d7fRDMJxrAh 1SXHT2fuVPDzxCsh/xlFS/iCpW0om3YhVT73nv9a1PGceeLneg3f4JPXh5EaKQUvAw nyLlsWDWUoxiA== 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 aZw-piB1XN1t; Wed, 5 Apr 2023 21:23:02 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id 750DA94DE6; Wed, 5 Apr 2023 21:22:59 +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 5/7] iio: adc: palmas: always reset events on unload Date: Wed, 5 Apr 2023 23:22:31 +0200 Message-Id: <20230405212233.4167986-6-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373267231436759?= X-GMAIL-MSGID: =?utf-8?q?1762373267231436759?= This prevents leaving the adc in freerunning mode when removing the driver. Signed-off-by: Patrik Dahlström --- drivers/iio/adc/palmas_gpadc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 8c6ea4a3cd2e..da4908608a27 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -498,6 +498,13 @@ static int palmas_gpadc_get_adc_dt_data(struct platform_device *pdev, return 0; } +static void palmas_gpadc_reset(void *data) +{ + struct palmas_gpadc *adc = data; + if (adc->event0.enabled || adc->event1.enabled) + palmas_adc_reset_events(adc); +} + static int palmas_gpadc_probe(struct platform_device *pdev) { struct palmas_gpadc *adc; @@ -587,6 +594,10 @@ static int palmas_gpadc_probe(struct platform_device *pdev) palmas_gpadc_calibrate(adc, i); } + ret = devm_add_action(&pdev->dev, palmas_gpadc_reset, adc); + if (ret) + return ret; + return 0; } From patchwork Wed Apr 5 21:22:32 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: 79960 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp630710rwc; Wed, 5 Apr 2023 14:31:02 -0700 (PDT) X-Google-Smtp-Source: AKy350anfARYN928ELIyssl1VDucmiJ4PqZ1hfY2Oy6TBwzRCPqwZwch+rnjgjMRzxF+9Ie5NdFC X-Received: by 2002:a05:6402:148d:b0:501:e26e:502b with SMTP id e13-20020a056402148d00b00501e26e502bmr3101605edv.29.1680730262113; Wed, 05 Apr 2023 14:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730262; cv=none; d=google.com; s=arc-20160816; b=B9uxtHrvzClsbuD+AAkAw4al4s6ELJnoaNYS3u6SeMDDG2NGega167cPN4/dF0Dn8I XBV125jzKftKV6zbj7D/D61Zpp5NUchDErYB4OotDwgLk8O3mij7JA5mPK7NxyZnUs0C vw/vkJ+7HkZovNtY11MYaHFv0XrXmsBWcmrgQB8UDfNdSpEKsvASyxyw2LlWo0Iea0QY TAtVg2KQqGArZOlZ8/3xL9ckEGggp8HdrJ4lWN/9YCFFpcE1FCf8yxmqUYoSMO+VcXRz Fx0n+Xx8ZwwwwQVX+njsfyRGp+twTT7lLXdu333ORUhgcIia1SeGdBfRzzGyKe0lyO+C ekTw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=lEv74jZ+S8eRkgYN46D3PbWKWh/LCi0bknKpQNhJJv0=; b=vL7PeIwNF501olt6hMiv8IVu5A4q6lYS8T/uNX3U7GM4cDYv7YMLmmckZ9evtFtWcA 7lmepdE2kBbFaWPDKLzu9uc17oNLiT5CdrPoFLRNC6nR0YPivj8b9kNbafczEuOjIIbY MXeCXiSzNidZdU6m2LrsGUlCWuPy+A+dpWRDtvK7G7NaY0mmEplX/VqTRtnPqcQbgYi3 c9lRIkoVInMVR0lbKOMo7jjXAubk6WiGc9GEN9XwYGwTF2ewgqej8v/3vBcTUqrpCMpS Jcs154mUd5oEMLOOFWmBMaMa5+GR9eRwXo+B37/GBXW23ALLdXygUcttyOcdR7txpFO+ JXHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=RXFGOwQn; 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 c24-20020aa7df18000000b004acb32d3a1bsi2004852edy.362.2023.04.05.14.30.36; Wed, 05 Apr 2023 14:31:02 -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=RXFGOwQn; 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 S234222AbjDEVYA (ORCPT + 99 others); Wed, 5 Apr 2023 17:24:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234587AbjDEVXp (ORCPT ); Wed, 5 Apr 2023 17:23:45 -0400 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 164E22D77; Wed, 5 Apr 2023 14:23:29 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 4EC803F4DA; Wed, 5 Apr 2023 23:23:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 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-msa2.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=dalakolonin.se Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pqB1PhBrPj3a; Wed, 5 Apr 2023 23:23:27 +0200 (CEST) Received: by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 3B5973F3A9; Wed, 5 Apr 2023 23:23:27 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 8682394E40; Wed, 5 Apr 2023 21:23:26 +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 HRn71PbF9QzW; Wed, 5 Apr 2023 21:23:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id F201B94DFF; Wed, 5 Apr 2023 21:23:07 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se F201B94DFF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729789; bh=lEv74jZ+S8eRkgYN46D3PbWKWh/LCi0bknKpQNhJJv0=; h=From:To:Date:Message-Id:MIME-Version; b=RXFGOwQnV3jBtUBvYbg76XipgvTFvSiRHjA7AZ99uhAwIaOj2yyuC0X6oZEu6cCNA ygWWHMOcg4DaEIZH2ZSYqB4CNYgSu6s9QZWtqpsavSEEMxC4sGe0XjoAKwbsmLDHDy M/8Fnxpeoomof74Ka54oFrK7cwetV42zl1GMqk5rYusqpKhSOZO7XprxFS9o0+R+tw YggguDopvtjO9UFAIgwRYGidS1UlWipH1y0mPigzyEiYJLnLta5VvYxtYwXpv6Sl33 jI+MTX3PoJlWHu/UUI7uTz2aRkYW8PPN8c9d/enCnbeN+OuoBvkfqeioYO0WPuo1Lb eieHl8XmQ1bAw== 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 pppVvG94BhTX; Wed, 5 Apr 2023 21:23:06 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id DEF1594DF7; Wed, 5 Apr 2023 21:23:04 +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 6/7] iio: adc: palmas: add support for iio threshold events Date: Wed, 5 Apr 2023 23:22:32 +0200 Message-Id: <20230405212233.4167986-7-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373415493782611?= X-GMAIL-MSGID: =?utf-8?q?1762373415493782611?= 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 change hooks into the IIO events system and exposes to userspace the ability to configure these threshold values for each channel, but only allow up to 2 such thresholds to be enabled at any given time. Trying to enable a third channel will result in an error. Userspace is expected to input calibrated, as opposed to raw, values as threshold. However, it is not enough to do the opposite of what is done when converting the other way around. To account for tolerances in the ADC, the calculated raw threshold should be adjusted based on the ADC specifications for the device. These specifications include the integral nonlinearity (INL), offset, and gain error. To adjust the high threshold, use the following equation: (calibrated value + INL) * Gain error + offset = maximum value [1] Likewise, use the following equation for the low threshold: (calibrated value - INL) * Gain error - offset = minimum value The gain error is a combination of gain error, as listed in the datasheet, and gain error drift due to temperature and supply. The exact values for these specifications vary between palmas devices. This patch sets the values found in TWL6035, TWL6037 datasheet. [1] TI Application Report, SLIA087A, Guide to Using the GPADC in TPS65903x, TPS65917-Q1, TPS65919-Q1, and TPS65916 Devices. Signed-off-by: Patrik Dahlström --- V2 -> V3: avoid reconfiguring channels on error and when old == new. drivers/iio/adc/palmas_gpadc.c | 447 +++++++++++++++++++++++++++++++-- 1 file changed, 423 insertions(+), 24 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index da4908608a27..2e0755e9e3a4 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -79,10 +80,14 @@ static struct palmas_gpadc_info palmas_gpadc_info[] = { struct palmas_adc_event { bool enabled; int channel; - int raw_thresh; enum iio_event_direction direction; }; +struct palmas_gpadc_thresholds { + int high; + int low; +}; + /* * struct palmas_gpadc - the palmas_gpadc structure * @ch0_current: channel 0 current source setting @@ -120,10 +125,31 @@ struct palmas_gpadc { struct completion conv_completion; struct palmas_adc_event event0; struct palmas_adc_event event1; + struct palmas_gpadc_thresholds thresholds[PALMAS_ADC_CH_MAX]; int auto_conversion_period; struct mutex lock; }; +static struct palmas_adc_event *palmas_gpadc_get_event(struct palmas_gpadc *adc, + int adc_chan, + enum iio_event_direction dir) +{ + if (adc_chan == adc->event0.channel && dir == adc->event0.direction) + return &adc->event0; + + if (adc_chan == adc->event1.channel && dir == adc->event1.direction) + return &adc->event1; + + return NULL; +} + +static bool palmas_gpadc_channel_is_freerunning(struct palmas_gpadc *adc, + int adc_chan) +{ + return palmas_gpadc_get_event(adc, adc_chan, IIO_EV_DIR_RISING) || + palmas_gpadc_get_event(adc, adc_chan, IIO_EV_DIR_FALLING); +} + /* * GPADC lock issue in AUTO mode. * Impact: In AUTO mode, GPADC conversion can be locked after disabling AUTO @@ -193,11 +219,24 @@ static irqreturn_t palmas_gpadc_irq(int irq, void *data) static irqreturn_t palmas_gpadc_irq_auto(int irq, void *data) { - struct palmas_gpadc *adc = data; + struct iio_dev *indio_dev = data; + struct palmas_gpadc *adc = iio_priv(indio_dev); + struct palmas_adc_event *ev; dev_dbg(adc->dev, "Threshold interrupt %d occurs\n", irq); palmas_disable_auto_conversion(adc); + ev = (irq == adc->irq_auto_0) ? &adc->event0 : &adc->event1; + if (ev->channel != -1) { + enum iio_event_direction dir; + u64 code; + + dir = ev->direction; + code = IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, ev->channel, + IIO_EV_TYPE_THRESH, dir); + iio_push_event(indio_dev, code, iio_get_time_ns(indio_dev)); + } + return IRQ_HANDLED; } @@ -285,6 +324,9 @@ static int palmas_gpadc_read_prepare(struct palmas_gpadc *adc, int adc_chan) { int ret; + if (palmas_gpadc_channel_is_freerunning(adc, adc_chan)) + return 0; /* ADC already running */ + ret = palmas_gpadc_enable(adc, adc_chan, true); if (ret < 0) return ret; @@ -344,28 +386,43 @@ static int palmas_gpadc_start_conversion(struct palmas_gpadc *adc, int adc_chan) unsigned int val; int ret; - init_completion(&adc->conv_completion); - ret = palmas_update_bits(adc->palmas, PALMAS_GPADC_BASE, - PALMAS_GPADC_SW_SELECT, - PALMAS_GPADC_SW_SELECT_SW_START_CONV0, - PALMAS_GPADC_SW_SELECT_SW_START_CONV0); - if (ret < 0) { - dev_err(adc->dev, "SELECT_SW_START write failed: %d\n", ret); - return ret; - } + if (palmas_gpadc_channel_is_freerunning(adc, adc_chan)) { + int event = (adc_chan == adc->event0.channel) ? 0 : 1; + unsigned int reg = (event == 0) ? + PALMAS_GPADC_AUTO_CONV0_LSB : + PALMAS_GPADC_AUTO_CONV1_LSB; - ret = wait_for_completion_timeout(&adc->conv_completion, - PALMAS_ADC_CONVERSION_TIMEOUT); - if (ret == 0) { - dev_err(adc->dev, "conversion not completed\n"); - return -ETIMEDOUT; - } + ret = palmas_bulk_read(adc->palmas, PALMAS_GPADC_BASE, + reg, &val, 2); + if (ret < 0) { + dev_err(adc->dev, "AUTO_CONV%x_LSB read failed: %d\n", + event, ret); + return ret; + } + } else { + init_completion(&adc->conv_completion); + ret = palmas_update_bits(adc->palmas, PALMAS_GPADC_BASE, + PALMAS_GPADC_SW_SELECT, + PALMAS_GPADC_SW_SELECT_SW_START_CONV0, + PALMAS_GPADC_SW_SELECT_SW_START_CONV0); + if (ret < 0) { + dev_err(adc->dev, "SELECT_SW_START write failed: %d\n", ret); + return ret; + } - ret = palmas_bulk_read(adc->palmas, PALMAS_GPADC_BASE, - PALMAS_GPADC_SW_CONV0_LSB, &val, 2); - if (ret < 0) { - dev_err(adc->dev, "SW_CONV0_LSB read failed: %d\n", ret); - return ret; + ret = wait_for_completion_timeout(&adc->conv_completion, + PALMAS_ADC_CONVERSION_TIMEOUT); + if (ret == 0) { + dev_err(adc->dev, "conversion not completed\n"); + return -ETIMEDOUT; + } + + ret = palmas_bulk_read(adc->palmas, PALMAS_GPADC_BASE, + PALMAS_GPADC_SW_CONV0_LSB, &val, 2); + if (ret < 0) { + dev_err(adc->dev, "SW_CONV0_LSB read failed: %d\n", ret); + return ret; + } } ret = val & 0xFFF; @@ -391,6 +448,98 @@ static int palmas_gpadc_get_calibrated_code(struct palmas_gpadc *adc, return val; } +/** + * The high and low threshold values are calculated based on the advice given + * in TI Application Report SLIA087A, "Guide to Using the GPADC in PS65903x, + * TPS65917-Q1, TPS65919-Q1, and TPS65916 Devices". This document recommend + * taking ADC tolerances into account and is based on the device integral non- + * linearity (INL), offset error and gain error: + * + * raw high threshold = (ideal threshold + INL) * gain error + offset error + * + * The gain error include both gain error, as specified in the datasheet, and + * the gain error drift. These paramenters vary depending on device and whether + * the the channel is calibrated (trimmed) or not. + */ +static int palmas_gpadc_threshold_with_tolerance(int val, const int INL, + const int gain_error, + const int offset_error) +{ + val = ((val + INL) * (1000 + gain_error)) / 1000 + offset_error; + + return clamp(val, 0, 0xFFF); +} + +/** + * The values below are taken from the datasheet of TWL6035, TWL6037. + * todo: get max INL, gain error, and offset error from OF. + */ +static int palmas_gpadc_get_high_threshold_raw(struct palmas_gpadc *adc, + struct palmas_adc_event *ev) +{ + const int adc_chan = ev->channel; + int val = adc->thresholds[adc_chan].high; + /* integral nonlinearity, measured in LSB */ + const int max_INL = 2; + /* measured in LSB */ + int max_offset_error; + /* 0.2% when calibrated */ + int max_gain_error = 2; + + val = (val * 1000) / adc->adc_info[adc_chan].gain; + + if (adc->adc_info[adc_chan].is_uncalibrated) { + /* 2% worse */ + max_gain_error += 20; + max_offset_error = 36; + } else { + val = (val * adc->adc_info[adc_chan].gain_error + + adc->adc_info[adc_chan].offset) / + 1000; + max_offset_error = 2; + } + + return palmas_gpadc_threshold_with_tolerance(val, + max_INL, + max_gain_error, + max_offset_error); +} + +/** + * The values below are taken from the datasheet of TWL6035, TWL6037. + * todo: get min INL, gain error, and offset error from OF. + */ +static int palmas_gpadc_get_low_threshold_raw(struct palmas_gpadc *adc, + struct palmas_adc_event *ev) +{ + const int adc_chan = ev->channel; + int val = adc->thresholds[adc_chan].low; + /* integral nonlinearity, measured in LSB */ + const int min_INL = -2; + /* measured in LSB */ + int min_offset_error; + /* -0.6% when calibrated */ + int min_gain_error = -6; + + val = (val * 1000) / adc->adc_info[adc_chan].gain; + + if (adc->adc_info[adc_chan].is_uncalibrated) { + /* 2% worse */ + min_gain_error -= 20; + min_offset_error = -36; + } else { + val = (val * adc->adc_info[adc_chan].gain_error - + adc->adc_info[adc_chan].offset) / + 1000; + min_offset_error = -2; + } + + return palmas_gpadc_threshold_with_tolerance(val, + min_INL, + min_gain_error, + min_offset_error); +} + static int palmas_gpadc_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long mask) { @@ -437,8 +586,221 @@ static int palmas_gpadc_read_raw(struct iio_dev *indio_dev, return ret; } +static int palmas_gpadc_read_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir) +{ + struct palmas_gpadc *adc = iio_priv(indio_dev); + int adc_chan = chan->channel; + int ret = 0; + + if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) + return -EINVAL; + + mutex_lock(&adc->lock); + + if (palmas_gpadc_get_event(adc, adc_chan, dir)) { + ret = 1; + } + + mutex_unlock(&adc->lock); + + return ret; +} + +static int palmas_adc_configure_events(struct palmas_gpadc *adc); +static int palmas_adc_reset_events(struct palmas_gpadc *adc); + +static int palmas_gpadc_reconfigure_event_channels(struct palmas_gpadc *adc) +{ + return (adc->event0.enabled || adc->event1.enabled) ? + palmas_adc_configure_events(adc) : + palmas_adc_reset_events(adc); +} + +static int palmas_gpadc_enable_event_config(struct palmas_gpadc *adc, + const struct iio_chan_spec *chan, + enum iio_event_direction dir) +{ + struct palmas_adc_event *ev; + int adc_chan = chan->channel; + + if (palmas_gpadc_get_event(adc, adc_chan, dir)) + /* already enabled */ + return 0; + + if (adc->event0.channel == -1) { + ev = &adc->event0; + } else if (adc->event1.channel == -1) { + /* event0 has to be the lowest channel */ + if (adc_chan < adc->event0.channel) { + adc->event1 = adc->event0; + ev = &adc->event0; + } else { + ev = &adc->event1; + } + } else { /* both AUTO channels already in use */ + dev_warn(adc->dev, "event0 - %d, event1 - %d\n", + adc->event0.channel, adc->event1.channel); + return -EBUSY; + } + + ev->enabled = true; + ev->channel = adc_chan; + ev->direction = dir; + + return palmas_gpadc_reconfigure_event_channels(adc); +} + +static int palmas_gpadc_disable_event_config(struct palmas_gpadc *adc, + const struct iio_chan_spec *chan, + enum iio_event_direction dir) +{ + int adc_chan = chan->channel; + struct palmas_adc_event *ev = palmas_gpadc_get_event(adc, adc_chan, dir); + + if (!ev) + return 0; + + if (ev == &adc->event0) { + adc->event0 = adc->event1; + ev = &adc->event1; + } + + ev->enabled = false; + ev->channel = -1; + ev->direction = IIO_EV_DIR_NONE; + + return palmas_gpadc_reconfigure_event_channels(adc); +} + +static int palmas_gpadc_write_event_config(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + int state) +{ + struct palmas_gpadc *adc = iio_priv(indio_dev); + int adc_chan = chan->channel; + int ret = 0; + + if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) + return -EINVAL; + + mutex_lock(&adc->lock); + + if (state) + ret = palmas_gpadc_enable_event_config(adc, chan, dir); + else + ret = palmas_gpadc_disable_event_config(adc, chan, dir); + + mutex_unlock(&adc->lock); + + return ret; +} + +static int palmas_gpadc_read_event_value(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int *val, int *val2) +{ + struct palmas_gpadc *adc = iio_priv(indio_dev); + int adc_chan = chan->channel; + int ret = 0; + + if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) + return -EINVAL; + + mutex_lock(&adc->lock); + + switch (info) { + case IIO_EV_INFO_VALUE: + *val = (dir == IIO_EV_DIR_RISING) ? + adc->thresholds[adc_chan].high : + adc->thresholds[adc_chan].low; + ret = IIO_VAL_INT; + break; + default: + ret = -EINVAL; + break; + } + + mutex_unlock(&adc->lock); + + return ret; +} + +static int palmas_gpadc_write_event_value(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, + int val, int val2) +{ + struct palmas_gpadc *adc = iio_priv(indio_dev); + int adc_chan = chan->channel; + int old; + int ret = 0; + + if (adc_chan > PALMAS_ADC_CH_MAX || type != IIO_EV_TYPE_THRESH) + return -EINVAL; + + mutex_lock(&adc->lock); + switch (info) { + case IIO_EV_INFO_VALUE: + if (val < 0 || val > 0xFFF) { + ret = -EINVAL; + break; + } + if (dir == IIO_EV_DIR_RISING) { + old = adc->thresholds[adc_chan].high; + adc->thresholds[adc_chan].high = val; + } + else { + old = adc->thresholds[adc_chan].low; + adc->thresholds[adc_chan].low = val; + } + break; + default: + ret = -EINVAL; + break; + } + + if (ret) + goto out_unlock; + + if (val != old && palmas_gpadc_get_event(adc, adc_chan, dir)) + ret = palmas_gpadc_reconfigure_event_channels(adc); + +out_unlock: + mutex_unlock(&adc->lock); + + return ret; +} + static const struct iio_info palmas_gpadc_iio_info = { .read_raw = palmas_gpadc_read_raw, + .read_event_config = palmas_gpadc_read_event_config, + .write_event_config = palmas_gpadc_write_event_config, + .read_event_value = palmas_gpadc_read_event_value, + .write_event_value = palmas_gpadc_write_event_value, +}; + +static const struct iio_event_spec palmas_gpadc_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE) | + BIT(IIO_EV_INFO_ENABLE), + }, }; #define PALMAS_ADC_CHAN_IIO(chan, _type, chan_info) \ @@ -449,6 +811,8 @@ static const struct iio_info palmas_gpadc_iio_info = { BIT(chan_info), \ .indexed = 1, \ .channel = PALMAS_ADC_CH_##chan, \ + .event_spec = palmas_gpadc_events, \ + .num_event_specs = ARRAY_SIZE(palmas_gpadc_events) \ } static const struct iio_chan_spec palmas_gpadc_iio_channel[] = { @@ -555,6 +919,39 @@ static int palmas_gpadc_probe(struct platform_device *pdev) return dev_err_probe(adc->dev, ret, "request irq %d failed\n", adc->irq); + adc->irq_auto_0 = platform_get_irq(pdev, 1); + if (adc->irq_auto_0 < 0) + return dev_err_probe(adc->dev, adc->irq_auto_0, + "get auto0 irq failed\n"); + + ret = devm_request_threaded_irq(&pdev->dev, adc->irq_auto_0, NULL, + palmas_gpadc_irq_auto, IRQF_ONESHOT, + "palmas-adc-auto-0", indio_dev); + if (ret < 0) + return dev_err_probe(adc->dev, ret, + "request auto0 irq %d failed\n", + adc->irq_auto_0); + + adc->irq_auto_1 = platform_get_irq(pdev, 2); + if (adc->irq_auto_1 < 0) + return dev_err_probe(adc->dev, adc->irq_auto_1, + "get auto1 irq failed\n"); + + ret = devm_request_threaded_irq(&pdev->dev, adc->irq_auto_1, NULL, + palmas_gpadc_irq_auto, IRQF_ONESHOT, + "palmas-adc-auto-1", indio_dev); + if (ret < 0) + return dev_err_probe(adc->dev, ret, + "request auto1 irq %d failed\n", + adc->irq_auto_1); + + adc->event0.enabled = false; + adc->event0.channel = -1; + adc->event0.direction = IIO_EV_DIR_NONE; + adc->event1.enabled = false; + adc->event1.channel = -1; + adc->event1.direction = IIO_EV_DIR_NONE; + /* set the current source 0 (value 0/5/15/20 uA => 0..3) */ if (gpadc_pdata->ch0_current <= 1) adc->ch0_current = PALMAS_ADC_CH0_CURRENT_SRC_0; @@ -632,13 +1029,14 @@ static int palmas_adc_configure_events(struct palmas_gpadc *adc) int polarity; ch0 = ev->channel; - thres = ev->raw_thresh; conv |= PALMAS_GPADC_AUTO_CTRL_AUTO_CONV0_EN; switch (ev->direction) { case IIO_EV_DIR_RISING: + thres = palmas_gpadc_get_high_threshold_raw(adc, ev); polarity = 0; break; case IIO_EV_DIR_FALLING: + thres = palmas_gpadc_get_low_threshold_raw(adc, ev); polarity = PALMAS_GPADC_THRES_CONV0_MSB_THRES_CONV0_POL; break; default: @@ -668,13 +1066,14 @@ static int palmas_adc_configure_events(struct palmas_gpadc *adc) int polarity; ch1 = ev->channel; - thres = ev->raw_thresh; conv |= PALMAS_GPADC_AUTO_CTRL_AUTO_CONV1_EN; switch (ev->direction) { case IIO_EV_DIR_RISING: + thres = palmas_gpadc_get_high_threshold_raw(adc, ev); polarity = 0; break; case IIO_EV_DIR_FALLING: + thres = palmas_gpadc_get_low_threshold_raw(adc, ev); polarity = PALMAS_GPADC_THRES_CONV1_MSB_THRES_CONV1_POL; break; default: From patchwork Wed Apr 5 21:22:33 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: 79957 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3d4a:b0:114:e959:cc0c with SMTP id b10csp629930rwc; Wed, 5 Apr 2023 14:29:31 -0700 (PDT) X-Google-Smtp-Source: AKy350Z1xjCiv+Wgad4vOBOZauvKtRcnieIBJA0/uSBuNec2+H/xIopkFu/3JxGDNVgoPNtD4yQw X-Received: by 2002:aa7:c64c:0:b0:502:100c:53a with SMTP id z12-20020aa7c64c000000b00502100c053amr3151483edr.41.1680730171397; Wed, 05 Apr 2023 14:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680730171; cv=none; d=google.com; s=arc-20160816; b=JzepImvhN38Zo200iBhrD0myoM6EmsTIHmQieQrNHAWrACSPFZidEjOLiZVAJNaWjG IxmbNJ6Vp5r6DrIo8IePsydgDkha+STC0fZHjFvYp80tdqbgLmnyLzpQGqqtPnLvLo6K wcUCyjRbl1/kjhZmwWmuAGxwVEVysm0aLZW4H2QjUQ/c00SvxpcAAQpPP3r3cKMgEI4Q YOFgpdBIvpVEDSef3mBZbiMPSSfScua4t2zmxS+zhkuF97WLQUnJ1tyCR3W08OEktXbs WsmH39phrQDDUSH1QdhGFkbW6C6jgLzgP46FDkkhKg8sWMpwBB3TY1KKpu0YENEXXoOo oOBg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=tdhqZ0SVQrHBM7Ty7175uvKzDgdZmch0EnHFXXlVQ9Y=; b=JtTxSFC/Uk+gRrxGwuhmxSjs4edRPEqqmgPQKB5kdXC7/QBR2u5XtTA/QC+Pzckcws 22Cf6rTpP4z2QBce0V+KErUgGSCtOFywntzvUB/1cOi4eSqPUhEeSsxk1nxqjk+MgHZI 0xgNxtXaAQhby0hDkMmMXgoXcJRJUalmysYomqC4QKp28oF7obJYkU0K0K5o8JrIlf6/ voxHDycp+Enmb6alUjdIwbgkVYpZdQYZXHcXEma+R+lrVpBAjQ4mx4fjKnaZKDsG/CEF xnwQ5fr5C9SVir7MiDuNrJy6reDm7O2Tmpc2Yv8pY70kW7ApsQi0H0JCHW6ySXRcAHEM CnUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dalakolonin.se header.s=D374B428-D0A7-11ED-A657-75977B426508 header.b=BKU6KxXw; 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 p25-20020a056402045900b004fefeece418si10829670edw.284.2023.04.05.14.29.07; Wed, 05 Apr 2023 14:29:31 -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=BKU6KxXw; 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 S233745AbjDEVYG (ORCPT + 99 others); Wed, 5 Apr 2023 17:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232680AbjDEVXs (ORCPT ); Wed, 5 Apr 2023 17:23:48 -0400 Received: from ste-pvt-msa2.bahnhof.se (ste-pvt-msa2.bahnhof.se [213.80.101.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50930729F; Wed, 5 Apr 2023 14:23:33 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 5359E4111E; Wed, 5 Apr 2023 23:23:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Score: -2.099 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-ftg-msa2.bahnhof.se (amavisd-new); dkim=pass (2048-bit key) header.d=dalakolonin.se Received: from ste-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (ste-ftg-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cLEjAgfxlFdL; Wed, 5 Apr 2023 23:23:30 +0200 (CEST) Received: by ste-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id 90C05410A1; Wed, 5 Apr 2023 23:23:30 +0200 (CEST) Authentication-Results: ste-pvt-msa2.bahnhof.se; dkim=pass (2048-bit key; unprotected) header.d=dalakolonin.se header.i=@dalakolonin.se header.b="BKU6KxXw"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 5413094E54; Wed, 5 Apr 2023 21:23:29 +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 Eo1i7dPfeaZD; Wed, 5 Apr 2023 21:23:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTP id 7942C94E10; Wed, 5 Apr 2023 21:23:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra.dalakolonin.se 7942C94E10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalakolonin.se; s=D374B428-D0A7-11ED-A657-75977B426508; t=1680729792; bh=tdhqZ0SVQrHBM7Ty7175uvKzDgdZmch0EnHFXXlVQ9Y=; h=From:To:Date:Message-Id:MIME-Version; b=BKU6KxXw0q3BYRECa/VLJ1Qmqwt+nhDQzLXW90g1ooUpPlyzmn0clAgEe770Mlo93 jtbmHgxFdwsJZBAUqhyNZFNulp0hcadwwWh/2gbMzN44iQU3PbWz6H8r+p0D7MOmbY KEIe0LrEfxrxWclWuGfoSSviQHRc37P1Qv0eb08yakFgRpQnVYVMA9cNjl3u0PGnhh phuGOkooSxFHzkOeBH9MOg/Zi8J5++wGFgy1ywboxJiXP6iIzCXQtZCyKVJyJlQsAI LiW1+yYriH7avPLH6c1MTmZBEb/7toDlZwOWAj3kPjRgqXxJNxChg3iae0w6a8P0TY 5w1Vw6ko3+fyw== 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 9C4YbUzBMhgc; Wed, 5 Apr 2023 21:23:12 +0000 (UTC) Received: from rack-server-1.dalakolonin.se (unknown [172.17.0.1]) by zimbra.dalakolonin.se (Postfix) with ESMTPSA id F225094E00; Wed, 5 Apr 2023 21:23:08 +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 7/7] iio: adc: palmas: don't alter event config on suspend/resume Date: Wed, 5 Apr 2023 23:22:33 +0200 Message-Id: <20230405212233.4167986-8-risca@dalakolonin.se> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405212233.4167986-1-risca@dalakolonin.se> References: <20230405212233.4167986-1-risca@dalakolonin.se> 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?1762373320000053417?= X-GMAIL-MSGID: =?utf-8?q?1762373320000053417?= The event config is controlled through the IIO events subsystem and device wakeup is controlled by /sys/devices/.../power/wakeup. Let's keep those two knobs independent. Signed-off-by: Patrik Dahlström --- drivers/iio/adc/palmas_gpadc.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/iio/adc/palmas_gpadc.c b/drivers/iio/adc/palmas_gpadc.c index 2e0755e9e3a4..ba3cc0e68197 100644 --- a/drivers/iio/adc/palmas_gpadc.c +++ b/drivers/iio/adc/palmas_gpadc.c @@ -1137,16 +1137,10 @@ static int palmas_gpadc_suspend(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct palmas_gpadc *adc = iio_priv(indio_dev); - int wakeup = adc->event0.enabled || adc->event1.enabled; - int ret; - if (!device_may_wakeup(dev) || !wakeup) + if (!device_may_wakeup(dev)) return 0; - ret = palmas_adc_configure_events(adc); - if (ret < 0) - return ret; - if (adc->event0.enabled) enable_irq_wake(adc->irq_auto_0); @@ -1160,16 +1154,10 @@ static int palmas_gpadc_resume(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct palmas_gpadc *adc = iio_priv(indio_dev); - int wakeup = adc->event0.enabled || adc->event1.enabled; - int ret; - if (!device_may_wakeup(dev) || !wakeup) + if (!device_may_wakeup(dev)) return 0; - ret = palmas_adc_reset_events(adc); - if (ret < 0) - return ret; - if (adc->event0.enabled) disable_irq_wake(adc->irq_auto_0);