Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp81702imm; Thu, 30 Aug 2018 08:48:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbqGKKBigWlZupmoeW68Sd1U7cXJdaZNfEo5jTP96TKO2lbgxI8jTgtN54wmLKcdsIBcy6n X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr10371076pgq.382.1535644114009; Thu, 30 Aug 2018 08:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535644113; cv=none; d=google.com; s=arc-20160816; b=T8eo40rTPGmqfRQHla0Bx/oPEQKBc3c6IT6ZacjhtS8Mz74j/pIlVEo9RO3N47Jlog viAlIoNz44VKHj8NuGccywDp3PvbxqiJitl+5YsY8Xsr50s1C1/3Yrv0HlIj4DHIxgcD thsc/nkvDkYo0fm4YFaMy6CXA8eceyMl65/EM73nv1RCw0Nj21yeTur5u5q/D9W0jbjV HNLIBfONBL3SzzwuBZDmBbJ4Q7Wm3oMGEeUe9qFsyRSrRuRmhRIDgarJ366UAftd6x4o ojf+YKgbNmt9iiBSPJuN7BuiHQMA0k6UvbxE51RP29dkr2Zy9XD5whJlIJT/ZwxqTCc0 bcpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=yEZZzXd7EqL0QVZwjKI2SdtLyI0ltZvJ5hxxkextUgQ=; b=repgjqQlemSAl0LcRNXosLyAvnYi1m2S4JRI0hAbuY5irECjNrxidh44rVYyMVVdfT 1x7fnbdtqWjBm0szim5K+bkRl6I21QeKWdJJPO/vTMtxVknomf999ViA8SbKaT1aTr6z qH8RBpuEO/zpxLC9fiCNhe9yZPWHq0RKjrwMZ6aj02fUqCTEOVJpe87XygRwFMK94/Oz 4gClRPf+B2kDJnvWB/xExxD5FJfassYAyUGxOcUjix4GvXYbsrv7Pf2+rfizPuHx+LQK n8tab7ZneDl4QQCoAKbtoom3weBKSRelaT/wlJ7HaFlZKdlVqddVkPDvRIV5UUgNwZIn i2bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CZtkdVtp; 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=QUARANTINE 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 b38-v6si6771133plb.167.2018.08.30.08.48.19; Thu, 30 Aug 2018 08:48:33 -0700 (PDT) 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=CZtkdVtp; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727294AbeH3Ttb (ORCPT + 99 others); Thu, 30 Aug 2018 15:49:31 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55456 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727683AbeH3Ts1 (ORCPT ); Thu, 30 Aug 2018 15:48:27 -0400 Received: by mail-wm0-f68.google.com with SMTP id f21-v6so2477870wmc.5; Thu, 30 Aug 2018 08:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yEZZzXd7EqL0QVZwjKI2SdtLyI0ltZvJ5hxxkextUgQ=; b=CZtkdVtp06Yg5sR3ngIwd7L3KZq3/8j6SAEeTg0uaSi+JSVl+cDdDJEIvqRX5/PArS wFGgH/7HekLrY8j6dDC+YVVW5BXKbeGLkUGM7jgJa/oyhiENbrtXAv4zrDiW+xJlBkYM vfE18JH3/kUupsg24QSbbZN7uS68p/gXoiKYDqV9Fi2zKK0uGlQsf9Gp6fH9xYbX3f5x mng/6G+VfhJwFyj6xQvbNI1S2dLMIFFWyqQIUgPAdPqZJT3s/22HkVgocnkVB4I6tGpw k4IVea8z5V5+J/XKnrgbx4vnVjNoUtdAFN4HBZr4ymAhoYK170zmK+s8ZuNDiid8xIOV tYVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yEZZzXd7EqL0QVZwjKI2SdtLyI0ltZvJ5hxxkextUgQ=; b=bdlaj52u2Nob73CyuzvSxY19eSLdrHPHzKkaZ0XRrJVDkZYeRyR1IzLhkKza5fVdRM 7nemLc4nAFF4fvo45gva1aK9rnvTGrZmjlEBxzGq0t2LsbDjgjVxOOC8+Okzt+X7dD7/ yrJfESROHc1mRt+GIRWyzaoj4YWjUt6BWoRQodpXXa+is6Y3xmbG8ZTDekGon5vOMqev PFYtyzS5n7jtrq3vtHhpgFzM9QJmuc2tDmWZ7uTmWZJ5ezblqyzP+nR//9Bzfd6rJtqv quaIi1eU+Cn5Dlq+LU/NspsFuaOtAq//FXNzIzYY9kw93G1STqF+uvvlEFQg4hWqTpKv Emyw== X-Gm-Message-State: APzg51AklzTlDY60bZ89n0ZdAzCQB/TEakOkkFjCa4Y98jkGDGbzcbyQ EqoFS2AII/eByAHZo2WpzN4= X-Received: by 2002:a1c:1943:: with SMTP id 64-v6mr2087807wmz.89.1535643940503; Thu, 30 Aug 2018 08:45:40 -0700 (PDT) Received: from debian-hp.wlan.uni-ulm.de (eduroam170-020.wlan.uni-ulm.de. [134.60.170.20]) by smtp.gmail.com with ESMTPSA id j20-v6sm1362759wmh.9.2018.08.30.08.45.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 08:45:40 -0700 (PDT) From: Philipp Rossak To: lee.jones@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com, maxime.ripard@bootlin.com, wens@csie.org, linux@armlinux.org.uk, jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net, eugen.hristev@microchip.com, rdunlap@infradead.org, vilhelm.gray@gmail.com, clabbe.montjoie@gmail.com, quentin.schulz@bootlin.com, geert+renesas@glider.be, lukas@wunner.de, icenowy@aosc.io, arnd@arndb.de, broonie@kernel.org, arnaud.pouliquen@st.com Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH v3 20/30] iio: adc: sun4i-gpadc-iio: rework: device specific suspend & resume Date: Thu, 30 Aug 2018 17:45:08 +0200 Message-Id: <20180830154518.29507-21-embed3d@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180830154518.29507-1-embed3d@gmail.com> References: <20180830154518.29507-1-embed3d@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Different sensors will have different suspend and resume functions. So we are modularize the suspend and resume functions. The resume function configures and initializes the thermal sensor and the suspend function disables the sensors. Signed-off-by: Philipp Rossak --- drivers/iio/adc/sun4i-gpadc-iio.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 2fd73d143815..c7b46c82e3e5 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -76,6 +76,9 @@ struct gpadc_data { static irqreturn_t sun4i_gpadc_data_irq_handler(int irq, void *dev_id); +static int sun4i_ths_resume(struct sun4i_gpadc_iio *info); +static int sun4i_ths_suspend(struct sun4i_gpadc_iio *info); + static const struct gpadc_data sun4i_gpadc_data = { .temp_offset = -1932, .temp_scale = 133, @@ -87,6 +90,8 @@ static const struct gpadc_data sun4i_gpadc_data = { .ths_irq_thread = sun4i_gpadc_data_irq_handler, .support_irq = true, .temp_data_base = SUN4I_GPADC_TEMP_DATA, + .ths_resume = sun4i_ths_resume, + .ths_suspend = sun4i_ths_suspend, .sensor_count = 1, }; @@ -101,6 +106,8 @@ static const struct gpadc_data sun5i_gpadc_data = { .ths_irq_thread = sun4i_gpadc_data_irq_handler, .support_irq = true, .temp_data_base = SUN4I_GPADC_TEMP_DATA, + .ths_resume = sun4i_ths_resume, + .ths_suspend = sun4i_ths_suspend, .sensor_count = 1, }; @@ -115,6 +122,8 @@ static const struct gpadc_data sun6i_gpadc_data = { .ths_irq_thread = sun4i_gpadc_data_irq_handler, .support_irq = true, .temp_data_base = SUN4I_GPADC_TEMP_DATA, + .ths_resume = sun4i_ths_resume, + .ths_suspend = sun4i_ths_suspend, .sensor_count = 1, }; @@ -123,6 +132,8 @@ static const struct gpadc_data sun8i_a33_gpadc_data = { .temp_scale = 162, .tp_mode_en = SUN8I_A33_GPADC_CTRL1_CHOP_TEMP_EN, .temp_data_base = SUN4I_GPADC_TEMP_DATA, + .ths_resume = sun4i_ths_resume, + .ths_suspend = sun4i_ths_suspend, .sensor_count = 1, }; @@ -401,6 +412,11 @@ static irqreturn_t sun4i_gpadc_data_irq_handler(int irq, void *dev_id) static int sun4i_gpadc_runtime_suspend(struct device *dev) { struct sun4i_gpadc_iio *info = iio_priv(dev_get_drvdata(dev)); + return info->data->ths_suspend(info); +} + +static int sun4i_ths_suspend(struct sun4i_gpadc_iio *info) +{ /* Disable the ADC on IP */ regmap_write(info->regmap, SUN4I_GPADC_CTRL1, 0); @@ -415,7 +431,11 @@ static int sun4i_gpadc_runtime_suspend(struct device *dev) static int sun4i_gpadc_runtime_resume(struct device *dev) { struct sun4i_gpadc_iio *info = iio_priv(dev_get_drvdata(dev)); + return info->data->ths_resume(info); +} +static int sun4i_ths_resume(struct sun4i_gpadc_iio *info) +{ /* clkin = 6MHz */ regmap_write(info->regmap, SUN4I_GPADC_CTRL0, SUN4I_GPADC_CTRL0_ADC_CLK_DIVIDER(2) | -- 2.11.0