Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751757AbdFSOeB (ORCPT ); Mon, 19 Jun 2017 10:34:01 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:56243 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751196AbdFSOeA (ORCPT ); Mon, 19 Jun 2017 10:34:00 -0400 Date: Mon, 19 Jun 2017 16:33:55 +0200 From: Oleksij Rempel To: Stefan Wahren Cc: Oleksij Rempel , devicetree@vger.kernel.org, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , Maxime Ripard , Rob Herring , Shawn Guo , Srinivas Kandagatla Subject: Re: [PATCH v5 2/3] nvmem: add snvs_lpgpr driver Message-ID: <20170619143355.2qeuetsx2pbvlgng@pengutronix.de> References: <20170609125730.25502-1-o.rempel@pengutronix.de> <20170609125730.25502-3-o.rempel@pengutronix.de> <2b309881-0134-c3f8-2037-b0e106719a64@i2se.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b309881-0134-c3f8-2037-b0e106719a64@i2se.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 16:32:58 up 9 days, 6:43, 33 users, load average: 0.05, 0.06, 0.02 User-Agent: Mutt/1.6.2-neo (2016-06-11) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4289 Lines: 117 Hi Stefan, On Fri, Jun 09, 2017 at 05:01:09PM +0200, Stefan Wahren wrote: > Hi Oleksij, > > please add the NXP guys in CC in order to give them a chance to review. > > Am 09.06.2017 um 14:57 schrieb Oleksij Rempel: > > This is a driver for Low Power General Purpose Register (LPGPR) > > available on i.MX6 SoCs in Secure Non-Volatile Storage (SNVS) > > of this chip. > > > > It is a 32-bit read/write register located in the low power domain. > > Since LPGPR is located in the battery-backed power domain, LPGPR can > > be used by any application for retaining data during an SoC power-down > > mode. > > > > Signed-off-by: Oleksij Rempel > > --- > > drivers/nvmem/Kconfig | 10 ++++ > > drivers/nvmem/Makefile | 2 + > > drivers/nvmem/snvs_lpgpr.c | 138 +++++++++++++++++++++++++++++++++++++++++++++ > > 3 files changed, 150 insertions(+) > > create mode 100644 drivers/nvmem/snvs_lpgpr.c > > > > diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig > > index 101ced4c84be..ea3044c5d6ee 100644 > > --- a/drivers/nvmem/Kconfig > > +++ b/drivers/nvmem/Kconfig > > @@ -144,4 +144,14 @@ config MESON_EFUSE > > This driver can also be built as a module. If so, the module > > will be called nvmem_meson_efuse. > > > > +config NVMEM_SNVS_LPGPR > > + tristate "Support for Low Power General Purpose Register" > > + depends on SOC_IMX6 || COMPILE_TEST > > + help > > + This is a driver for Low Power General Purpose Register (LPGPR) available on > > + i.MX6 SoCs in Secure Non-Volatile Storage (SNVS) of this chip. > > + > > + This driver can also be built as a module. If so, the module > > + will be called nvmem-snvs-lpgpr. > > + > > endif > > diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile > > index 173140658693..4c589184acee 100644 > > --- a/drivers/nvmem/Makefile > > +++ b/drivers/nvmem/Makefile > > @@ -30,3 +30,5 @@ obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o > > nvmem-vf610-ocotp-y := vf610-ocotp.o > > obj-$(CONFIG_MESON_EFUSE) += nvmem_meson_efuse.o > > nvmem_meson_efuse-y := meson-efuse.o > > +obj-$(CONFIG_NVMEM_SNVS_LPGPR) += nvmem_snvs_lpgpr.o > > +nvmem_snvs_lpgpr-y := snvs_lpgpr.o > > diff --git a/drivers/nvmem/snvs_lpgpr.c b/drivers/nvmem/snvs_lpgpr.c > > new file mode 100644 > > index 000000000000..acb3ddc0d990 > > --- /dev/null > > +++ b/drivers/nvmem/snvs_lpgpr.c > > @@ -0,0 +1,138 @@ > > +/* > > + * Copyright (c) 2015 Pengutronix, Steffen Trumtrar > > + * Copyright (c) 2017 Pengutronix, Oleksij Rempel > > + * > > + * This program is free software; you can redistribute it and/or modify > > + * it under the terms of the GNU General Public License version 2 > > + * as published by the Free Software Foundation. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +struct snvs_lpgpr_cfg { > > + int offset; > > +}; > > + > > +struct snvs_lpgpr_priv { > > + struct device_d *dev; > > + struct regmap *regmap; > > + struct nvmem_config cfg; > > + const struct snvs_lpgpr_cfg *dcfg; > > +}; > > + > > +static const struct snvs_lpgpr_cfg snvs_lpgpr_cfg_imx6q = { > > + .offset = 0x68, > > +}; > > + > > +static int snvs_lpgpr_write(void *context, unsigned int offset, void *_val, > > + size_t bytes) > > +{ > > + struct snvs_lpgpr_priv *priv = context; > > + const struct snvs_lpgpr_cfg *dcfg = priv->dcfg; > > + const u32 *val = _val; > > + int i = 0, words = bytes / 4; > > + > > + while (words--) > > + regmap_write(priv->regmap, dcfg->offset + offset + (i++ * 4), > > + *val++); > > according to the reference manual "57.9.14 SNVS_LP General Purpose > Register (SNVS_LPGPR)": > > When GPR_SL or GPR_HL bit is set, the register cannot be programmed. > > I think the driver should handle this error case properly. good point, I'll update it. -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |