Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8101551ybn; Tue, 1 Oct 2019 03:16:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5lFKXWwoONJbxbUWdOEPXUpmLwReX2CJ1ArnnMBM3g4jiDSB3mr7prgo3oeE5cB/UKg8p X-Received: by 2002:a50:e616:: with SMTP id y22mr24462105edm.253.1569924972620; Tue, 01 Oct 2019 03:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569924972; cv=none; d=google.com; s=arc-20160816; b=FhaOQoU67hX6G+muQ26GrzDyk+ok3KCilvfIQo+P1j90HbL9PJ4xjpac1WwKgvq+nN MjsCak5PSWniv+Q+7CWNb1ipi3ml3uUBqouiLjhXS+FCxUOARaS1IAKeC8gT3SVaYDeX 1DYZ1k2sGUw+HIbhVGw5ybI28oqZrI1ruovkJGuaxnYoS511NWhge+RT6ZagkoBMD/RH L9im478Sl3QejU1uRfudyB3O/cXpisHlF5OUpBg8S5/KuITRZUyhlEYxugBJ7w0auAtK etK2+B/wDOeLV5uTKYKzI1CfnzQIxQ3VGhqoCp6MGHVFx7ZrH3bdmUvJXXHGpC8Mf/JO rCFA== 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; bh=TqnRymZHVB3nETq43Yyx3kDj0Su1WqRmQVreGP9eeAM=; b=uik4e1rcZvz4tTC6T0kQrXT0HZfiB8n19SKEWC5sKdAdRjs+9LCadfW2HPwXYsstcx rHT4As9W7QgH5wFt64etzHdgieXFPTZ4LL/RrI4fRQVrnOCc0mWBjymO0Z36Zz9IGfH3 FQqjFFfMphEHDY+JLXJ6yQrriX31wxr1WvLsRh4QUtMRtmusYZ599KLGOtnoGWZJQgGc mRmO5+vWj109EwtsX5hyVjN9dcX5Myh8/7voHWqDedW8R5JbiSX/5axivq98Ab36di9W HTVqBot2qZD3TpEUwBdctK+o67Z1CXxkI00t2twX0ZX41mwIjffluaz+vFpcOYPf3N6Q 5UBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SCWeuwoj; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v53si9318826edc.378.2019.10.01.03.15.47; Tue, 01 Oct 2019 03:16:12 -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=@linaro.org header.s=google header.b=SCWeuwoj; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730173AbfJAKO4 (ORCPT + 99 others); Tue, 1 Oct 2019 06:14:56 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36944 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728579AbfJAKOz (ORCPT ); Tue, 1 Oct 2019 06:14:55 -0400 Received: by mail-wr1-f68.google.com with SMTP id i1so14773171wro.4 for ; Tue, 01 Oct 2019 03:14:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TqnRymZHVB3nETq43Yyx3kDj0Su1WqRmQVreGP9eeAM=; b=SCWeuwojpC5yiuVk+b45PdbihMNriak/36ZsCE0jmeSduzCjq/s51e80vXGAJkh3DO qOHqQtqPLCXcoR4SCjvUPn8599enHuL8DaInPPRnMJAbE2OX+R0at2cRImMnVa8lvkz6 jJLXpTtZ+/tu1Jrrb9ZyWKHK4a5AWtizXLSU8Lo7W8GJOifGv04j8JitEpzXburg3asJ H8BysylFgjcP+/1rpYynNTj+oSnqnD5KCDSpcibbNkz+BvguDi/xyTPScY0gm2itHv4+ Z/d/4nB2wk4CLERLmyyDDWuXNXMBDhYOSOJug9IVfhrxKJoEn+AqHdio2hy9ClO0BK1b p40w== 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=TqnRymZHVB3nETq43Yyx3kDj0Su1WqRmQVreGP9eeAM=; b=m8aevu/Oeustdc6M5yWh2vXGQsGOyQdPmLO9cpDX2QWLde8U1H3/JfnS1YCH/w1qvH xYGv6MID4ImbiuH+gYpKjvzuDjQYczOg2yS3ihV/Io9BJV/8qBuM/BXkae1rtwYqMfB+ dH0+qkdRw+VdmS5fhk392yXfs4RyEUgk1RQ8sgHzFqybepWGKg69yUsaUEOjPOVKbaSR GqegHSrS5WJpRMsww6HWB2EoPa0yeurAKFAwJFnH5N9qptEssU2pjmx9IwZ8cDKwsI5X X6PRXPCQCO2kNeiSw50oj09CJQ1Lnkt/XlDm+tR1uR8s/fy+rj7mUqov1YfYSV428bJD 2snQ== X-Gm-Message-State: APjAAAVRrLgg0xsAb6KeN5V5t3TmsUe367F7t7YOiuUG+KbCrA/sSQB/ 7q+Mmq3PutjXbSO2pAR5JJuOnA473CE= X-Received: by 2002:a05:6000:162e:: with SMTP id v14mr17736905wrb.112.1569924892368; Tue, 01 Oct 2019 03:14:52 -0700 (PDT) Received: from [192.168.86.34] (cpc89974-aztw32-2-0-cust43.18-1.cable.virginm.net. [86.30.250.44]) by smtp.googlemail.com with ESMTPSA id t13sm33081133wra.70.2019.10.01.03.14.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Oct 2019 03:14:51 -0700 (PDT) Subject: Re: [PATCH V2 1/2] nvmem: imx: scu: support hole region check To: Peng Fan , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" Cc: "kernel@pengutronix.de" , "festevam@gmail.com" , dl-linux-imx , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Aisheng Dong References: <1569550913-10176-1-git-send-email-peng.fan@nxp.com> From: Srinivas Kandagatla Message-ID: <48bc66d5-684a-cfdb-67dd-722dbf80edbf@linaro.org> Date: Tue, 1 Oct 2019 11:14:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1569550913-10176-1-git-send-email-peng.fan@nxp.com> Content-Type: text/plain; charset=utf-8; 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 27/09/2019 03:23, Peng Fan wrote: > From: Peng Fan > > Introduce HOLE/ECC_REGION flag and in_hole helper to ease the check > of hole region. The ECC_REGION is also introduced here which is > preparing for programming support. ECC_REGION could only be programmed > once, so need take care. > > Signed-off-by: Peng Fan > --- > > V2: > Rebased on latest linux-next > > drivers/nvmem/imx-ocotp-scu.c | 47 ++++++++++++++++++++++++++++++++++++++----- > 1 file changed, 42 insertions(+), 5 deletions(-) thanks, applied both. --srini > > diff --git a/drivers/nvmem/imx-ocotp-scu.c b/drivers/nvmem/imx-ocotp-scu.c > index 61a17f943f47..030e27ba4dfb 100644 > --- a/drivers/nvmem/imx-ocotp-scu.c > +++ b/drivers/nvmem/imx-ocotp-scu.c > @@ -19,9 +19,20 @@ enum ocotp_devtype { > IMX8QM, > }; > > +#define ECC_REGION BIT(0) > +#define HOLE_REGION BIT(1) > + > +struct ocotp_region { > + u32 start; > + u32 end; > + u32 flag; > +}; > + > struct ocotp_devtype_data { > int devtype; > int nregs; > + u32 num_region; > + struct ocotp_region region[]; > }; > > struct ocotp_priv { > @@ -38,13 +49,41 @@ struct imx_sc_msg_misc_fuse_read { > static struct ocotp_devtype_data imx8qxp_data = { > .devtype = IMX8QXP, > .nregs = 800, > + .num_region = 3, > + .region = { > + {0x10, 0x10f, ECC_REGION}, > + {0x110, 0x21F, HOLE_REGION}, > + {0x220, 0x31F, ECC_REGION}, > + }, > }; > > static struct ocotp_devtype_data imx8qm_data = { > .devtype = IMX8QM, > .nregs = 800, > + .num_region = 2, > + .region = { > + {0x10, 0x10f, ECC_REGION}, > + {0x1a0, 0x1ff, ECC_REGION}, > + }, > }; > > +static bool in_hole(void *context, u32 index) > +{ > + struct ocotp_priv *priv = context; > + const struct ocotp_devtype_data *data = priv->data; > + int i; > + > + for (i = 0; i < data->num_region; i++) { > + if (data->region[i].flag & HOLE_REGION) { > + if ((index >= data->region[i].start) && > + (index <= data->region[i].end)) > + return true; > + } > + } > + > + return false; > +} > + > static int imx_sc_misc_otp_fuse_read(struct imx_sc_ipc *ipc, u32 word, > u32 *val) > { > @@ -91,11 +130,9 @@ static int imx_scu_ocotp_read(void *context, unsigned int offset, > buf = p; > > for (i = index; i < (index + count); i++) { > - if (priv->data->devtype == IMX8QXP) { > - if ((i > 271) && (i < 544)) { > - *buf++ = 0; > - continue; > - } > + if (in_hole(context, i)) { > + *buf++ = 0; > + continue; > } > > ret = imx_sc_misc_otp_fuse_read(priv->nvmem_ipc, i, buf); >