Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp80835imm; Thu, 30 Aug 2018 08:47:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZxrWNwJ9MHdQzgezJs2ZNKGjIvEacMX/BGmr9vOibcPycO9djwgxPPInMSOtBCGQBBf6Hk X-Received: by 2002:a17:902:bb0c:: with SMTP id l12-v6mr10793893pls.5.1535644038765; Thu, 30 Aug 2018 08:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535644038; cv=none; d=google.com; s=arc-20160816; b=soAks5TNk/gg2UIMtrUn28OOhMYpM/XgoQCwXg2NjWiC49aeZL8m6d0rMKIxf/JpR1 dz3z4oSZyipe0fcGkXD9keAvzrS5t+j6KPh5hAPDiDQ0hR4tUz7icxoVbUR7rhW7kkwr smgnxQeC7cqbH47FJZCMDbrPchqKfFEkj7Gi+lQcQ3qHY8LYqlDboB7rITO7RrRd7DIt GaSB3nB2bcpAm8z501+g6dWs3DqFEcUqQq/XTt/PCHZBp+9MmaSRAvV1MgocXVNSod6C pZyi84leKMV5E+mvYL+If6vURlzYgjRiGlIUvLLQD/O2Q2t5yPY126S/VZZnerTGKiI+ 7Bkg== 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=pQqP9NLkOkVzk7D1LMI8Y+J0UMHbo42I8dLSpZuhXRc=; b=znUoV7MUmLxoH7aIsc29LoLCCfocMIngbNkupdkTyBL8SeD2BLrW7dsFsYnQAvH6YL /f0/qLbsTz1m0ixHmQ3tPbj6gJVjCu6WOOvnPgy1sfEFh3GMA4UJQslXNqfC56Ex6F/+ CqdMUAnVr9kFkJh/KLQJg+Gt8pa/COE2dhaZh06sIZx6vIYJXJ/2eOa/oxasf1mBXAPd 8axhQIJkGdG1HC3fkR+hPIVCMUQk01D4/CvKH+3e0g8mRLaaXa8e8tuYCuVGgKcfwnwq CxxeZHA9EuB48Wdy1WLwMqsyXZJ5vKZBqXrb3mt8k5QcNnWjfbvVrUCiq3XG/F1ydwu4 yORQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ifjRSj4l; 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 q3-v6si7137869plb.102.2018.08.30.08.47.04; Thu, 30 Aug 2018 08:47:18 -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=ifjRSj4l; 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 S1727806AbeH3Ts2 (ORCPT + 99 others); Thu, 30 Aug 2018 15:48:28 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:37215 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727703AbeH3Ts0 (ORCPT ); Thu, 30 Aug 2018 15:48:26 -0400 Received: by mail-wr1-f65.google.com with SMTP id u12-v6so8499652wrr.4; Thu, 30 Aug 2018 08:45:40 -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=pQqP9NLkOkVzk7D1LMI8Y+J0UMHbo42I8dLSpZuhXRc=; b=ifjRSj4labF3yu/ZzTuSbrT/tXp0Y94XnTmFsd7hGvpHksuOTJFkstfQyLwsdSeuhg 2cQOsLTCbSQ/peuCBn+Scy3WOGD6UqaEAOfoOFyy6ImZdzy0LMrgYMDLGIZKkcZ426J2 fytPVBhEHAqXxCS9LJdkT7br17YVBn8152BzGmYR7hbvRwVS0KMevexNN3I3XIFUSiKa QgmXIUaFF9bqwtBDZ80VEBYG9mmhI6CLG+A2QdbWAmIM+vVoTZpiGLwvy5HsQavSNFIH CTHaCqDSkjNf6oBEX367tVx3X/lizfdCeNa7ftNg8Aa2J/WAfRJjgvkqJJtJOky876zo fRAg== 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=pQqP9NLkOkVzk7D1LMI8Y+J0UMHbo42I8dLSpZuhXRc=; b=Kd7uFW52UtkYNM9kACVpvyS1uUZIaVSAUH2CjU/SEA+FIhphZQ3kVxWZjOD6NovAAS kX//eyZX6Mx905BsDlj6yj3cfkekGMhSqQ12FIzQTE4ek7SBbQVJ7Y2JYrZzDYpPaV/8 qz2+BOdK4iRi5mJVtYPdkV/FeyCNj2Cw10tsbLrJ5i3sqV+sZvsmiITwmVzVEsfXRJNo D0zpVszDxLb9aEJXK3ApZTydzscYI2BOrU3LsMChKY6wllb95RY1k6Tqv9lMLw3X/2wL gOpP3npvMosvPpmPcmf0b219gCioU4G9Sk6LKzhY0Y3kvtE1HsCukTKTHKPDYZ5/XHrf IkIA== X-Gm-Message-State: APzg51CVC5PVDn8mKnwnrqkjrmmAm5JlOd91fID1Vh/voZS0+ldy/Xzw /rNqzceVvlWCtiGZSGrDPJ8= X-Received: by 2002:adf:bb41:: with SMTP id x1-v6mr7702826wrg.24.1535643939495; Thu, 30 Aug 2018 08:45:39 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 08:45:38 -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 19/30] iio: adc: sun4i-gpadc-iio: rework: support nvmem calibration data Date: Thu, 30 Aug 2018 17:45:07 +0200 Message-Id: <20180830154518.29507-20-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 This patch reworks the driver to support nvmem calibration cells. The driver checks if the nvmem calibration is supported and reads out the nvmem. Signed-off-by: Philipp Rossak --- drivers/iio/adc/sun4i-gpadc-iio.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 18ab72e52d78..2fd73d143815 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,7 @@ struct gpadc_data { bool has_mod_clk; u32 temp_data_base; int sensor_count; + bool supports_nvmem; }; static irqreturn_t sun4i_gpadc_data_irq_handler(int irq, void *dev_id); @@ -146,6 +148,7 @@ struct sun4i_gpadc_iio { struct clk *bus_clk; struct clk *mod_clk; struct reset_control *reset; + u32 calibration_data[2]; }; static const struct iio_chan_spec sun4i_gpadc_channels[] = { @@ -484,6 +487,9 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, struct resource *mem; void __iomem *base; int ret; + struct nvmem_cell *cell; + ssize_t cell_size; + u32 *cell_data; info->data = of_device_get_match_data(&pdev->dev); if (!info->data) @@ -494,6 +500,24 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, if (IS_ERR(base)) return PTR_ERR(base); + if (info->data->supports_nvmem) { + + cell = nvmem_cell_get(&pdev->dev, "calibration"); + if (IS_ERR(cell)) { + if (PTR_ERR(cell) == -EPROBE_DEFER) + return PTR_ERR(cell); + } else { + cell_data = (u32 *)nvmem_cell_read(cell, &cell_size); + if (cell_size != 8) + dev_err(&pdev->dev, + "Calibration data has wrong size\n"); + else { + info->calibration_data[0] = cell_data[0]; + info->calibration_data[1] = cell_data[1]; + } + } + } + if (info->data->has_bus_clk) info->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "bus", base, &sun4i_gpadc_regmap_config); -- 2.11.0