From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01C09C31E40 for ; Tue, 6 Aug 2019 10:08:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C7E3620B1F for ; Tue, 6 Aug 2019 10:08:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="NKnmBKqp"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Q9Vdg1/J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7E3620B1F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g2gZAbSIGiRRiVpaIZdxF4JrewUlIXbqL9B0BuFSyJs=; b=NKnmBKqp3RqpwSU5LV6iBI0i8 NETkTRwqWOeQsUJdoIQsKIpkVnUgfyVagqi5ATHxoy9MHlRy2GtHDKJGd8Mx4fcG/Vfcqwzj2InCj dY2WL8PKbRE0ieHvQIiZ5MFMbro4Wc0ueQIeHNxztOb9dgGjmNOZE7hCpUsCDyO2s+kXS88Lw6H9x B4Ky2LzsY3/QKSDc+8DYrRBwsH8Nb5g9Gx2OrdujMYhWw6b6sjvlF88ZorJ4gYAyHamD3Xeirtqhb IDknCKDCABkTl8i2ZESdWiZJYLrnAyZZggU0Tb2xXFXnxeatlQ1iH7TRduxikC5WsYP5dlE1v0kXH X4KBwIaSQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1huwOK-0000gi-Kg; Tue, 06 Aug 2019 10:08:28 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1huwLk-000736-RQ for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2019 10:05:50 +0000 Received: by mail-wr1-x443.google.com with SMTP id g17so87269741wrr.5 for ; Tue, 06 Aug 2019 03:05:48 -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=tD7GBCktkRgBqSQK/rnS2OSCtvZ6JKSYqsfzwb/RV0U=; b=Q9Vdg1/Jnn+2hpisJUNHKj55kXITbJizFqEZLvdMMifAbvLijjhKdZQzcOk6rg6biF vj2QpQFdH18o+gwKuevO6r0gIsS+yxD62YTeaRc/3nHak9+XXS1CA5ALumdCYdxy22EK UnvoqcHTjoGd7ZXmggbXcwgHvjuQ9V8xkXxudLD4ziqrVEedqBF4Z+i3JAFIiCfOiUkn RKpt80kpVNZmecHICto/0TMEM2PcMWsI0x8kBIqoNwwbuDDBceiVzQfzbqpGuiDPnCwr 18MmYTojJ43cey8QcAc66hgdhGIwx0wa0onmlR8fQDlAtTWosIOiwAhVfisoIEgm/FMk dgMA== 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=tD7GBCktkRgBqSQK/rnS2OSCtvZ6JKSYqsfzwb/RV0U=; b=HYLrNKNOLZ12UA5dqHCaraH8x+PZ4Rryc33Kb8c/OkKOuUJeNw0/vxFtR4ufeVjfkG CdTISdw9uONUAtVOykDTWTKpc+ZrGrXKL680UGRQjlkpHbKTlWmjEztC5WHtOX3WatRs XTO7k9T8wdEj86iTsmRXrg8mV1Jt4W9GZ0ac7FdjDE28b/lc3/7sE2f4wRNfsQO/7LgO TGHCDXB7XYXSutPD+aiLoGsjA0dUP0zafX/EQR+wlnLCY7nbAI+MZ5UlkjYKxcI8tTur wA1nRRb3h+Kr9p/yh+RyMYTq5CRvX+HGwcDxubIFIYU69YcTzHttuoMICcn/XjM9zca8 j8rg== X-Gm-Message-State: APjAAAXSD2iPaGfXQStSKng5rhFFXu/jVLWYr6oa8QCDiVnIxgkR98+K gQrWvpBWwTVrqmZzHIa2bctYtg== X-Google-Smtp-Source: APXvYqzpWHfNm5EbCjNGJ6Vw8NSHmw5758vwwbCj5bXSgXTRGDeyMkz1GMDHlz7qeloNb+yN0JqX6Q== X-Received: by 2002:a5d:6949:: with SMTP id r9mr3611414wrw.73.1565085947506; Tue, 06 Aug 2019 03:05:47 -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 i24sm3303100wrc.45.2019.08.06.03.05.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 03:05:47 -0700 (PDT) Subject: Re: [PATCH 0/2] nvmem: imx-ocotp: allow reads with arbitrary size and offset To: Jose Diaz de Grenu References: <1563895963-19526-1-git-send-email-Jose.DiazdeGrenu@digi.com> From: Srinivas Kandagatla Message-ID: <771a6f0a-3cc2-da20-2439-9a91dd2bf9d2@linaro.org> Date: Tue, 6 Aug 2019 11:05:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1563895963-19526-1-git-send-email-Jose.DiazdeGrenu@digi.com> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190806_030548_969210_C1418364 X-CRM114-Status: GOOD ( 22.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, linux-kernel@vger.kernel.org, linux-imx@nxp.com, kernel@pengutronix.de, festevam@gmail.com, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 23/07/2019 16:32, Jose Diaz de Grenu wrote: > Currently the imx-ocotp driver does only allow reading complete OTP words > correcty aligned. > > Usually OTP memory is limited, so the fields are stored using as few bits as > possible. This means that a given value rarely uses 32 bits and happens to be > aligned. > > Even though the NVMEM API offers a way to define offset and size of each cell > (at bit level) this is not currently usable iwth the imx-ocotp driver, which > forces consumers to read complete words and then hardcode the necessary > shifting and masking in the driver code. > > As an example take the nvmem consumer imx_thermal.c, which reads nvmem cells > as uint32_t words: > > ret = nvmem_cell_read_u32(&pdev->dev, "calib", &val); > if (ret) > return ret; > > ret = imx_init_calib(pdev, val); > if (ret) > return ret; > > ret = nvmem_cell_read_u32(&pdev->dev, "temp_grade", &val); > if (ret) > return ret; > imx_init_temp_grade(pdev, val); > > but needs to later adjust the values in code: > > // Inside imx_init_calib() > data->c1 = (ocotp_ana1 >> 9) & 0x1ff; > > // Inside imx_init_temp_grade() > switch ((ocotp_mem0 >> 6) & 0x3) { > > This patch adjusts the driver so that reads can be requested using any size > and offset. Then, for example the nvmem cell "calib" could use the 'bits' > property to specify size and offset in bits, removing the need to mask and > shift in the driver code. > > This is specially useful when several drivers use the same nvmem cell and when > the specific size and offset of a OTP value depends on a hardware version. > > Jose Diaz de Grenu (2): > nvmem: imx-ocotp: use constant for write restriction > nvmem: imx-ocotp: allow reads with arbitrary size and offset > > drivers/nvmem/imx-ocotp.c | 34 ++++++++++++++++------------------ > 1 file changed, 16 insertions(+), 18 deletions(-) Anyone form IMX can test this patchset before I push this out? Thanks, srini > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel