Received: by 10.223.176.5 with SMTP id f5csp812000wra; Fri, 2 Feb 2018 06:33:07 -0800 (PST) X-Google-Smtp-Source: AH8x225Q5QPQ1TR/fdLjEYg9af9vU0yDEWuPJgIsTEfAF14r6XN7MvagIhmCc6IR4z9Kc61k9Msh X-Received: by 10.98.163.79 with SMTP id s76mr40843757pfe.67.1517581987324; Fri, 02 Feb 2018 06:33:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517581987; cv=none; d=google.com; s=arc-20160816; b=ieniNgnXMRumkh3i/zTCez0NlChs7360R9XfWmAshBqQoM0lpM6LqY4FJ21x3Cz2C5 PZqJ4RRGIlm4CMeV4DiuQiRoVVfLfQNQU4NKqGnFDRBuHhlQupDtYG2E3Z8YBjcfE7Jx bsoGjcaf6iR+5Gqz6csLOICvgKxhHiXs4cQe+kNP6T1AvFr/CUDWN163DBDrcwGO1+5J g/dEXGK9NsekBKheq1l5yzEbGEcmjl1BIKnKVxjYsJBM7KduUW6TBpGEL4QhsMxP7j9/ Mbzezzp55Ww3sG/MffrUjTTTC2NNhk9It1hYyLPbQeqliqlmEyTu/eD1xSgzaP2U33+g vClw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=glTIJqEVbOYufJwYIvWTzunk886+XcGov19zZyBZOrI=; b=FNmuIgmCQUum6UdXA8Yf2kQH6J1WPOVF/EuqOH9HgPdniVpX54Gx9LmK4NiuiGMbUh Qn+t2f4sj06E/g9QxuXqJq3eTBwz+QQxEQyu0/EQqtesF3g5uiEnbTiyysmUEP/iUsOW No1XaFUmiuYPujjaDETRbxypBe3O1xWHybtyuPbCfsYr6NJUVBXWmM3nGgp45PvDAxvT G4o8KyqfGkR0EtC0eA2NlsslIyJvk3FmNxtWhOmY3025AQanwY21qLsNyLrkzygUhnN6 /G3c0h3QMxGNtKqSHz8oZGNXH1iyesEgXwonuDm8EP/LygHkYr/DjBffkYO5rB7IUF0O 6ovw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JOqIXJuR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e83si1889710pfk.254.2018.02.02.06.32.52; Fri, 02 Feb 2018 06:33:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JOqIXJuR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752193AbeBBOao (ORCPT + 99 others); Fri, 2 Feb 2018 09:30:44 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35518 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbeBBOai (ORCPT ); Fri, 2 Feb 2018 09:30:38 -0500 Received: by mail-wm0-f67.google.com with SMTP id r78so12812616wme.0; Fri, 02 Feb 2018 06:30:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=glTIJqEVbOYufJwYIvWTzunk886+XcGov19zZyBZOrI=; b=JOqIXJuRCZNxRsYxDI+WAJfz0sbz84w3pPeKP3jJZCVnOYNyjSF/gIOD5YBeHAV9Z5 boDYEEC5HTl45FpIhwRxBibX3JEmM187ADEtcQ13GRh/XPp7WJLV/4ILtLagaqQ4UbGb SzfD9X6HA5Bf4QWWIqvt7eGxhGqGebL8elc4PCt6LZYsEUrHGYXrisRiR2vrr5B9ewHb 5Bp1z5eM3sgDpRrITjAJ4FC1+OcYKjDswmM8Po4lqG5FZfEON/2Mieu4IvaIHxeoxmtt CtrJelQ3OEmtK0gUF3my43LhtVe7CSUo9flTRIeFN2XC1ueN9qZQQDl16wlh7gASUyqQ fzsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=glTIJqEVbOYufJwYIvWTzunk886+XcGov19zZyBZOrI=; b=BUBNF43hPDFT23u65aLkiZ2vJLvjNKNnJAGdEJh0bygrDNA9X1UN1oDh/XLuCKpjVi uvR0ilqIzrVRupcWfeP9r7P2wHwbZnJHnukOeDbUuOXuz9avMHETu7O94nm6dn5ImOUR VOLJ6ok/A8Ozme9f+Nr9VnRRXEsa0DmVQ+SBVFQBux8JRnlGuHtUoMfA/gibccd0M5ZP QJTHZ48gsMwS04aVmcvObr2fTggLXyrkCUoKxL6SIK8Nrdb/rF53nIDt180bHh+Obx0o BTMPR/UR+hB69+xJx5fiOMvTGU+sCtjQlENz7ATkyiMMX0TZC2JjxSAucq7SwyizkR8F LzXg== X-Gm-Message-State: AKwxytc51neI4n4Tndupe82DiSv6GpidiiQk9e0sgW8D/8e1OjKRK/Hx Bod38k0pV9pGg7QfrtX84qo= X-Received: by 10.80.152.65 with SMTP id h1mr66258125edb.227.1517581836846; Fri, 02 Feb 2018 06:30:36 -0800 (PST) Received: from [134.60.183.180] (eduroam183-180.wlan.uni-ulm.de. [134.60.183.180]) by smtp.gmail.com with ESMTPSA id h1sm2102775edb.95.2018.02.02.06.30.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Feb 2018 06:30:35 -0800 (PST) Subject: Re: [PATCH v2 08/16] iio: adc: sun4i-gpadc-iio: rework: add interrupt support To: Quentin Schulz Cc: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@free-electrons.com, wens@csie.org, linux@armlinux.org.uk, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, davem@davemloft.net, hans.verkuil@cisco.com, mchehab@kernel.org, rask@formelder.dk, clabbe.montjoie@gmail.com, sean@mess.org, krzk@kernel.org, icenowy@aosc.io, edu.molinas@gmail.com, singhalsimran0@gmail.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com References: <20180128232919.12639-1-embed3d@gmail.com> <20180128232919.12639-9-embed3d@gmail.com> <20180131190718.ustqzwdxzw7mqe52@qschulz> From: Philipp Rossak Message-ID: <8a3ff924-9752-e9dc-d70e-609436505b1a@gmail.com> Date: Fri, 2 Feb 2018 15:30:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180131190718.ustqzwdxzw7mqe52@qschulz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31.01.2018 20:07, Quentin Schulz wrote: > Hi Philipp, > > On Mon, Jan 29, 2018 at 12:29:11AM +0100, Philipp Rossak wrote: >> This patch rewors the driver to support interrupts for the thermal part >> of the sensor. >> >> This is only available for the newer sensor (currently H3 and A83T). >> The interrupt will be trigerd on data available and triggers the update >> for the thermal sensors. All newer sensors have different amount of >> sensors and different interrupts for each device the reset of the >> interrupts need to be done different >> >> For the newer sensors is the autosuspend disabled. >> >> Signed-off-by: Philipp Rossak >> Acked-by: Jonathan Cameron >> --- >> drivers/iio/adc/sun4i-gpadc-iio.c | 60 +++++++++++++++++++++++++++++++++++---- >> include/linux/mfd/sun4i-gpadc.h | 2 ++ >> 2 files changed, 56 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c >> index 74eeb5cd5218..b7b5451226b0 100644 >> --- a/drivers/iio/adc/sun4i-gpadc-iio.c >> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c >> @@ -71,11 +71,14 @@ struct gpadc_data { >> unsigned int temp_data[MAX_SENSOR_COUNT]; >> int (*sample_start)(struct sun4i_gpadc_iio *info); >> int (*sample_end)(struct sun4i_gpadc_iio *info); >> + u32 irq_clear_map; >> + u32 irq_control_map; > > I would say to use a regmap_irq_chip for controlling IRQs. > Sounds good for me! I will rework that in the next version. >> bool has_bus_clk; >> bool has_bus_rst; >> bool has_mod_clk; >> int sensor_count; >> bool supports_nvmem; >> + bool support_irq; >> }; >> >> static const struct gpadc_data sun4i_gpadc_data = { >> @@ -90,6 +93,7 @@ static const struct gpadc_data sun4i_gpadc_data = { >> .sample_end = sun4i_gpadc_sample_end, >> .sensor_count = 1, >> .supports_nvmem = false, >> + .support_irq = false, > > False is the default, no need to set support_irq. > > [...] > >> struct sun4i_gpadc_iio { >> @@ -332,6 +339,11 @@ static int sun4i_gpadc_temp_read(struct iio_dev *indio_dev, int *val, >> return 0; >> } >> >> + if (info->data->support_irq) { >> + regmap_read(info->regmap, info->data->temp_data[sensor], val); >> + return 0; >> + } >> + > > Maybe you could define a new thermal_zone_of_device_ops for these new > thermal sensors? That way, you don't even need the boolean support_irq. > Sounds good for me! I will rework that in the next version. >> return sun4i_gpadc_read(indio_dev, 0, val, info->temp_data_irq); >> } >> >> @@ -429,6 +441,17 @@ static irqreturn_t sun4i_gpadc_fifo_data_irq_handler(int irq, void *dev_id) >> return IRQ_HANDLED; >> } >> >> +static irqreturn_t sunxi_irq_thread(int irq, void *data) > > I think we're trying to avoid sunxi mentions but rather using the name > of the first IP (in term of product release, not support) using this > function. > >> +{ >> + struct sun4i_gpadc_iio *info = data; >> + >> + regmap_write(info->regmap, SUN8I_H3_THS_STAT, info->data->irq_clear_map); >> + > > Will be handled by regmap_irq_chip. > [...] >> - info->no_irq = true; >> + if (info->data->support_irq) { >> + /* only the new versions of ths support right now irqs */ >> + irq = platform_get_irq(pdev, 0); >> + if (irq < 0) { >> + dev_err(&pdev->dev, "failed to get IRQ: %d\n", irq); >> + return irq; >> + } >> + >> + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, >> + sunxi_irq_thread, IRQF_ONESHOT, >> + dev_name(&pdev->dev), info); >> + if (ret) >> + return ret; >> + >> + } else >> + info->no_irq = true; >> + > > That's a bit funny to have two booleans named no_irq and support_irq :) > I know this looks very funny. I thought this would be better to keep, to _not_ break anything. Since I will rework the whole driver and integrate the mfd part I hope I can remove both. >> indio_dev->num_channels = ARRAY_SIZE(sun8i_a33_gpadc_channels); >> indio_dev->channels = sun8i_a33_gpadc_channels; >> >> @@ -789,11 +829,13 @@ static int sun4i_gpadc_probe(struct platform_device *pdev) >> if (ret) >> return ret; >> >> - pm_runtime_set_autosuspend_delay(&pdev->dev, >> - SUN4I_GPADC_AUTOSUSPEND_DELAY); >> - pm_runtime_use_autosuspend(&pdev->dev); >> - pm_runtime_set_suspended(&pdev->dev); >> - pm_runtime_enable(&pdev->dev); >> + if (!info->data->support_irq) { >> + pm_runtime_set_autosuspend_delay(&pdev->dev, >> + SUN4I_GPADC_AUTOSUSPEND_DELAY); >> + pm_runtime_use_autosuspend(&pdev->dev); >> + pm_runtime_set_suspended(&pdev->dev); >> + pm_runtime_enable(&pdev->dev); >> + } > > Why would you not want your IP to do runtime PM? I will enable this again, in the next version! I had some issues with this, thus I disabled this, but I know now what I did wrong! Thanks, Philipp