From patchwork Thu Sep 23 11:01:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 514529 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp292700jao; Thu, 23 Sep 2021 04:02:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2t6tk8yAJlXh513WgJyKubAbjQu8D0FPjfL8UrlRarC0PGo5ltvC7CzFw78aGInRJc46t X-Received: by 2002:a05:6e02:1caf:: with SMTP id x15mr3375871ill.150.1632394915159; Thu, 23 Sep 2021 04:01:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632394915; cv=pass; d=google.com; s=arc-20160816; b=brcAEXMQB3/MwnB+/2HKYKrBpB2nMQ8NIa/MImkCHvK9CIe+2/kn+h/5qmub/v0ntq OpyfRkSXDk7g7EMVoeBZlGLJve7RtvzTert8oCpD2HFBqMLe4wElentObwje+0K48iym ZZWPZrKtVFCrEqZlFUDfLiMYyHYr0gVRnHW0exFNI1tkUFkgtjjW6EHT5+PnDekkyidA pTbDD2UyMLVxGYssOy9mLaeo0H8LlIy8zJ8NB2bVvATQymrvYoYTkLDe79FLqzulCCEA r3GF3+CFCYN68nmZjXnGCnX69uUx06ugFvzeiW205+zlnPq3DnbXw0jKS6sOR5DR6U/a hKAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=gGed3XtF7ZstaxT41kwc7HAW9psN9+JQ6PZrwDGc6iY=; b=I7p2S9tcBb7uFDUWi66TV2lselr3fkfYYC05OGtrGCryUw/Tdd/hO1ahMX8QwvJTY4 ZHmMFhrQzrK9buwn+Efs9Xz+8VSR+nA0a/xMAhdcckTDMx5ExTj9FM8srchP2Ug9u3al Qk7o71gwg+pQYDsKUZV82yKX4x+1pCIPI9FZQTfVfftQAGpKLWOi1ZVjqWqwWDelK9Zl tfa5BlRwTOUiAdBVsgDoDskErBl6EXWc4e66dTKEJ0t9mm0VzV8jxsfLMunqyUdlqH/P w1mrh/ASksqvTD2JWPwjqW2DyTJcC+r1rlD0Ce0BhSgMk5n9vyREl4n7qCQBf8afF/uh Xq7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ByBTTA3B; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si5376242ion.66.2021.09.23.04.01.37; Thu, 23 Sep 2021 04:01:55 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ByBTTA3B; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240500AbhIWLCm (ORCPT + 7 others); Thu, 23 Sep 2021 07:02:42 -0400 Received: from mail-eopbgr40058.outbound.protection.outlook.com ([40.107.4.58]:22754 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240442AbhIWLCm (ORCPT ); Thu, 23 Sep 2021 07:02:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jWE+JjQVb09kTM5gSZMZ+HnoyW4eTpJPOji5yCaH5IFJzyFpJJPoxwUnciYabB2amcbjs3VQP9Mr6hQuawGDTpFIHrrgnZiqoXVVBIvbgglaMyHhpLGFK7QTZtB4cwHjB7Jj2tCsePHc3TAcFy408ucYmXxZVaUq4mYsAkO7/3RimLSDGciZ/WkB4Yuc3DWpCpF/LzR0J8Tj6pzTdjENHg1DD23TaH7RqKZTi1pa0JJmBXMrC7/s89yP3EoEoBX2PFnwle84dhsDSgWFJKKSFoCRUHpdcDDsvfGKvkC7LfEcohqhViuiLM7AlvdTRjzXfRbLC/X9Pska4CYqaBEOCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gGed3XtF7ZstaxT41kwc7HAW9psN9+JQ6PZrwDGc6iY=; b=FDq42Vn0QGm+S5gz0/DGikrucJA2g1pshAn1VZLtUvzqTpk0Rzd5XNa+HUbR7TqvRkadDYIElKHGL7x5lghGo5rJqTujXE2gbfkcH8RaeiE6WSD6wpjVcCu7yKN3ZI317Xibal/lbD3z+YrP6zX11OolvUJ1fklXbUsWoCWCn1s8eEF31jBd57cSwcaMFEJgf21Q42crgumEIPo6wL7XydGb1ecTQNRxYe9dVH+21ExLhBVfCjCjEJTnCLbDHQE3HPuoEEYn1CXEcVfo0ryhNaWwQ9tHcNzbNINXRwtWtoNrTu/0hJvpU9V21g/XPhSeEF0oT99dIua6RD56QBQjIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gGed3XtF7ZstaxT41kwc7HAW9psN9+JQ6PZrwDGc6iY=; b=ByBTTA3BqtfIyURDtrxuX4RuOzurvwDMZyYcJdNSXKksJGffpM+rCVoPQlG/c39H5EzOBUe0TIayC3St9aPv8qamN43Ua7r4pvNfe6VynllHXSaVa9Ltls3FCEURtXngPoY+RHGkIltz0O9BP01fDz8Y9jQ9GlEnmaljc+A3XYE= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DBBPR04MB7836.eurprd04.prod.outlook.com (2603:10a6:10:1f3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 11:01:09 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f%9]) with mapi id 15.20.4544.013; Thu, 23 Sep 2021 11:01:09 +0000 From: Joakim Zhang To: srinivas.kandagatla@linaro.org, robh+dt@kernel.org, shawnguo@kernel.org, a.fatoum@pengutronix.de Cc: kernel@pengutronix.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V2 1/6] dt-bindings: nvmem: add cell-type to nvmem cells Date: Thu, 23 Sep 2021 19:01:04 +0800 Message-Id: <20210923110109.29785-2-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923110109.29785-1-qiangqing.zhang@nxp.com> References: <20210923110109.29785-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 11:01:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e95733f4-6fa8-48cd-348a-08d97e8172b8 X-MS-TrafficTypeDiagnostic: DBBPR04MB7836: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JVeOhoSwioHPOls42JdCt3QJFny7oYYyeahr2Mvpg4vjTTgRMDMqaL8+ILe8r7scZ1G9l/tZg0gMLyfCr5XYOfQmkEKxEfktWKUaweJdIMkXduTE37WohZ/Y4tl8M7BJOs5baDEXR4lmwc/M8EgrquH0bwZPmBdvpMXaNidxBb4Xp90XMvGMQjMqrxHHEC2w281vk4clSAF8L27MU6UEiEiMTeLRFIyG30IU3kFaxHCQbp+QUoyogGHzwlQFjKOMeBwBcYPgiPl7hu+o7QycvkNNZagikiSWovL952lO9M/dKR2cEmWmSJS1Gy+hdvmMZhpAEcgGgdC6S7TFviWPzpxgumW0tEFdBqVc3h6ZxlvsT1qfKoRzQuvBnSvqFiZc+FAMUjKgOTi6UTjLOiWR8oXxgEz7lDtD0GIU55QMqtrwnHEAHmiipTPTUyzPjSiUtQcO0FCEjVWjqq6o4dSh1AJpkMaPLbE1XdN2cYQHjG2ZwI50AejQbdmm1n7zg5O9sintroE14PZTjYP7Il/1U5g9cEM+wptIJn0OBNHZ9sXZzp1KbXdXqaanO/8Ro2g4ROv/3lEkgi5v1tfEF3+xwrnCzBnjMUCvN0qzt1Wjoq+bOXXVrtfGoPW97pyu1T+CvvExGnm2Erv42GaHYnedoM2JyoibseHCnXfhaEAG09K0xDovLtOOSUrFzI+MoqmKF2bvqSnYsgn7AjvSE8yQPw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(1076003)(36756003)(8936002)(86362001)(186003)(66946007)(2906002)(6512007)(38100700002)(38350700002)(26005)(8676002)(66476007)(6506007)(5660300002)(66556008)(508600001)(2616005)(316002)(83380400001)(956004)(4326008)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hUQIQWm6Oy2hxG1lHAq9oHBLKaHwfTjXACbENvbW8goddZ8m5NJ6C1qX2gbJbjZiXitgmCyugpP0Lqk1bpsR+QO9HGcdq+UqVEBWtDmJKf9kHM6DTeubBY4M3MCByb9iNHCg2s69jG//i/RSWLEw+Ek4k1uJyYJLbc52HntFbYOTEr8CnPnD93PIC+Ukg4YAvRaxeSUZjWq83aS6K0SZ/VTGdFUTPwhmjzimXb5saPz1WMZC6jxML2J/NlaGg+LyU99Vu3e76Mfj0nNTHtwxzJRY7UV/BQHcUO9dihqcP1Sp+LToL78RCNg5ykhTWE3nSAD1VGiXQ0/6AT0b4UpCOPRluApc8Rjm8UJiC89a+jRepUbfqWAIBvqJ9f70zFTHzk0NMNynXeSXdwDffvHMlnwTVqqVcmFDWDxg8EfsJB8GE/rVuPOBIWU3VmLuzhmDid/NnIzmgRnGAfrv8M7BXhQy4ZyJvXAK/J/q1h5m1YgRhMcSBD3YnXe+hsMQAthLluQfeen13kvClAZYcChWUOdWzy7WU9/X6qRPgis+uaQ9otSgJLq4RwqUCxxgTe0tAkT8THlCv1P3H2f795S+x0Ts1e+OoAChsJl/EOneo2617sqYCot0FZ3IoxiFriFxyReYC2866yFjzw1S2U8VHvHi3jITWOnd5FzMlGxzfqje9ETW/Dmsaw8FpAJwzeYszHBqG2jOYrp/f+1LjWnTEZxlP/s2UoB63+8XnWlXG/ysO0/UD7bF3iTLeOs/I30ZemjUAHlmLS3gYM6TspIrY/eT/U3mr9J7K7oHIa6VGwrvZcx8L1cEVFZARCwRY9XC8NFVDvCoRKLFLvuISctFHYRP/FddFgBrTRH5Cqirfc05K5nNpUcfxSKbD7EhuMK8YoyuYtufBpl+h9IMSuJ4GvKcXkT0y38GJdaglOrMk5oUnP6ltDCi1iAWM/Er/jeJY2r62SncI6yCiXaJWKbMtuv9WG0ZlKC0GoSOMpfcoPQ0cL+I+RIUrxhopytLe8F1ngttDqcFHOhI/tbgrN4ymzyrtLDbnx5zFeeRlwgE2mTmK/A7yn9LHaL3GQ6LJpbKoyInqslsFkHPTlsFFTLRimw1i0i+j22hGt83ink3s7xygI0l6oe0Ap4QbY8Kxcf52Tf/ljGxly3ZXR1acxALtDvOUDH5AkMSRE5XuV4MZ1Anpe/2Heg/KQvON3i45ytHTh104TWTAeRmjtvoFljMeeAzKsiH54ok0Ygve0qEjnK8YHmxbsvIOM8wftbWrWoho1UZNMQHSt+ZWtEyIejHQlN3SzZhpw3KiMEmO8+2zvS8ASw4hHE3uYF2l9SxqdUy X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e95733f4-6fa8-48cd-348a-08d97e8172b8 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 11:01:09.1784 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gFIuvgOJ24y/D/1Q+MT8eD7q1b09ty8sx9I3sI4iOywTjqSrXx2p8OXul4b48Y74VxR94ReHxCkecwZoL//XHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7836 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla Some of the nvmem providers encode data for certain type of nvmem cell, example mac-address is stored in ascii or with delimiter or in reverse order. This is much specific to vendor, so having a cell-type would allow nvmem provider drivers to post-process this before using it. Signed-off-by: Srinivas Kandagatla Signed-off-by: Joakim Zhang --- Documentation/devicetree/bindings/nvmem/nvmem.yaml | 11 +++++++++++ include/dt-bindings/nvmem/nvmem.h | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 include/dt-bindings/nvmem/nvmem.h -- 2.17.1 diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index b8dc3d2b6e92..8cf6c7e72b0a 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -60,6 +60,11 @@ patternProperties: - minimum: 1 description: Size in bit within the address range specified by reg. + cell-type: + $ref: /schemas/types.yaml#/definitions/uint32 + maxItems: 1 + description: + Type of nvmem, Use defines in dt-bindings/nvmem/nvmem.h. required: - reg @@ -69,6 +74,7 @@ additionalProperties: true examples: - | #include + #include qfprom: eeprom@700000 { #address-cells = <1>; @@ -98,6 +104,11 @@ examples: reg = <0xc 0x1>; bits = <2 3>; }; + + mac_addr: mac-addr@90{ + reg = <0x90 0x6>; + cell-type = ; + }; }; ... diff --git a/include/dt-bindings/nvmem/nvmem.h b/include/dt-bindings/nvmem/nvmem.h new file mode 100644 index 000000000000..eed0478f6bfd --- /dev/null +++ b/include/dt-bindings/nvmem/nvmem.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_NVMMEM_H +#define __DT_NVMMEM_H + +#define NVMEM_CELL_TYPE_UNKNOWN 0 +#define NVMEM_CELL_TYPE_MAC_ADDRESS 1 + +#endif /* __DT_NVMMEM_H */ From patchwork Thu Sep 23 11:01:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 514530 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp292756jao; Thu, 23 Sep 2021 04:02:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNvvLSLyNPFhFn7HXyfP5ds5ZfYDz4ov8M4448cwxEA9D+GW/WTT8J/SpDcWWcVFKSzKfs X-Received: by 2002:a6b:7214:: with SMTP id n20mr3327653ioc.194.1632394930856; Thu, 23 Sep 2021 04:02:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632394930; cv=pass; d=google.com; s=arc-20160816; b=TsyEHUvyxex+JBEORA+wo5hSPPdfnIRvA4Au5JMKhyZbrqMBhf/f7DMlFJBFObXEz8 yoDNBZS3VFy6x/9X4UTP0e7tUhpWq2cl2h+uxEIuFRYEsRmdFvY2N9Ubkt5uZCX903Hb p7KYeKkPL7JIsSM2fEC/q+zMCWp+d6EOnoA/SUpPvGjsT6H+Ea2rt5i4DXCfFh4flS3Y cMEBfmG6XHilwlhdxQ7VSJ6NPy7kBw/inDBOkgbjLhDKq4X968kVvOeG+MhUbkoG4Ooh EZ/oAxNhULU4Y/7vgIzTPxBKGBJgMOSXHN27+4zggN6oor1T7ScavpYgC0O62/1sd3RY WA6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ueuWPSIKuJFJwaGclxCSNB6T64FLl3aDoSY+8oR2i94=; b=eoNt/J4gK1gA5OhzfvCbRdl66j/jP3y7b95njV/wSrcxEbOCeXqstBs5CYJpCHRFUf NVssAg6wgMDRrcfAPftRvi8MWZBtuwbkawl2NWOJJrqiW/PvCs+2SvKjq4R9HEYONMXj IVhghBJSD1Eyk3ms2nKGrKMhRwqCfgvqx/l08w7VW9u3OGJAS6geNEqVOlkLBza+41O4 pNZBLHt1j4FyletG7Euph3a1ToLyDuNRcqpcmPZwWXRFS7gQdPo51h9PgOasW0OMMgfv Iqqb2c0ucgvA6lBQCPstO0wrxrWSuUwmvXzpk2yj258ChYdzxm0fXehcfvT9jbUf/BCf yyDw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Qk60MOwu; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si5376242ion.66.2021.09.23.04.01.56; Thu, 23 Sep 2021 04:02:10 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=Qk60MOwu; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240533AbhIWLCv (ORCPT + 7 others); Thu, 23 Sep 2021 07:02:51 -0400 Received: from mail-eopbgr40073.outbound.protection.outlook.com ([40.107.4.73]:54915 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240442AbhIWLCp (ORCPT ); Thu, 23 Sep 2021 07:02:45 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkpBt5dEHqPJ18Lf86/C4fo9ttCf70Lg7d1TlhFJTcL4QfctYA8I7PaGmsOgc8J8zxXpYTiZVISx4bofkV/mxeHxEP7makEUhWzqTkUVNFPeb0Kkl5gpRj8SeFQOMwhyc5GIZ5f0rPTplBqQz11Y45F+HWWKQ/M1MkhplAa2BNXsSoStIffA6yye3rxb6WWWKtBVP5TvUCoXvNius5l/mCEeBYolJ8Vls79ldPvIWh/lrHnG2FSeLE8tMw4njmeWPdqOKByZzoLAXr42/G4UlNajluVbHWC+KM3RpZBzk/zeueZ6TlxYFrOf9B83FPj0Eo596KizIgflixq768AYJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ueuWPSIKuJFJwaGclxCSNB6T64FLl3aDoSY+8oR2i94=; b=ZUioluyMCq7mBcAGDA7rH+yhA6Ya6FkGditA/pgxmyBBfQNCATcr+Wc1RT1L5wT+J9QhP+zNuW/QYsKmiIhKcL2AwIzHBhAJLS3+uQYGV46qo9fyAy0GND8vLodyUGr17bLfRPYrFMhSqQTeZCWYjDJMYO4oIklKRMZg29/xy5+bzZbQfx02DfNnIgcTaqEfF48/aal62nazduU1EmxlKPcgIUaeYlmeRqGeLId3XI1sF2sFHZnHbbU8nPTex9Yp+j5deDuZWa7b9ZQTMOIyDGCbL/tfOy0flRlGttPu0rlPgAutMmKVR3hdfMgl/X3cNIK6MxUz0FfkB7fhWlOYzw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ueuWPSIKuJFJwaGclxCSNB6T64FLl3aDoSY+8oR2i94=; b=Qk60MOwu081bhEsNDyTIDMiafCUHBg1C1nI1RwNjM6eYlnwkuMxzVG6e8VQgwP+rMWKzFgjnbSU1177XaVCtlIx3YHAcp5/BccnPuOHfMWpPLk+aH1tsAScTpntp/V6MPyGNTwqtl/kSktwKt9QsxEfxpjbNcZ9l25OR+02O+Gk= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DBBPR04MB7836.eurprd04.prod.outlook.com (2603:10a6:10:1f3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 11:01:12 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f%9]) with mapi id 15.20.4544.013; Thu, 23 Sep 2021 11:01:12 +0000 From: Joakim Zhang To: srinivas.kandagatla@linaro.org, robh+dt@kernel.org, shawnguo@kernel.org, a.fatoum@pengutronix.de Cc: kernel@pengutronix.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V2 2/6] nvmem: core: parse nvmem cell-type from device tree Date: Thu, 23 Sep 2021 19:01:05 +0800 Message-Id: <20210923110109.29785-3-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923110109.29785-1-qiangqing.zhang@nxp.com> References: <20210923110109.29785-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 11:01:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c42168d9-3eb7-41b5-751d-08d97e817477 X-MS-TrafficTypeDiagnostic: DBBPR04MB7836: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:113; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8IgAL2v1YjYfPjQq0WsHu1HNURvroXdRCb4wUhsg/SMWuI9q60vZmTinxs0jFuJXLIe48cu9J2sNOuNmGtGzjQ2mIVe5bPGaPcAoEzML7QYahmkZXX9qoOaq1ZM470hlv7KK7WIdzvX6LgMuHpI9nmSHP8wkziAiY8w4lkZTWUWBjYppbQ0goevLRuEBIoChWYUolG2fGV4ANcnS+RVf3q7RIlT1IP31aNOZtsX/Ym8DoUlBKqVs2WdtmTVDi6Za293oYurJcrTQUa3fQgkPDNcmxLG7LT0c9PUxPRq5wamRIruIX3JvCZglfwYx9VkYuyscAB4aDQt+kRgnEKs/Acgy+nu8W/PPfANGQKAtLvrDBqEgzVZa2+BPzfSL2LBZLa0geSxH2k+ULKADimGE2sWxhUEleX8v21LMyDpm2AU9KOPSLb0glHBdDS5/dLxPf4JRQiFTxIjUGoNm8EUo9LDeecvhW/4Tx4BkKodg8YwMizESpq3qOFSiPtQILTO9yPAAY1OOznO3joHd5+1A4CfSNo9Z+eKPKTcWEjKh6/3axAfpRt8bIn8SdQ0b33W7LxXKRfTXg4b5rKPcdg9eHLMjcLzpAF2TeaycNSVAYvn1M3O7vEbjS1DRS8yne8/jxE0JGY2YM/RifQcaZLneOkrdwqnJlHKfk2vlhY33YJDeklTuN4FQm69Qnrazelx24PuDfitKUW+57TzHDzoHtA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(1076003)(36756003)(8936002)(86362001)(186003)(66946007)(2906002)(6512007)(38100700002)(38350700002)(4744005)(26005)(8676002)(66476007)(6666004)(6506007)(5660300002)(66556008)(508600001)(2616005)(316002)(956004)(4326008)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ihjtFCgvVgiezLG8BuiCqSbt79kwhCIAYTl4GSZ6S8IMuWy1oKWVMn9er2R95dzSgUrB3Q/Iz6/IZxdQePBkyP3+gwGpFHf3tIEXKgqIzH97IPHszC752y8oGedynYETYyJoVpwG5soq+O5hfxFREApfkExXOc1CMc6JsZgjayUN5jOQQD2j19gHL/aeE3HNN3xDDI7asMKg0lvZ8xOzh066HzGCslDcwHEaptw6DYYZZmWsoFUZyZeOgCAm/SMAanoNlgi7I11LcrkGPDhUf9Jm6jN9yMvn7fKkOOo25COB5XIfLsNDfnkK+TGhZw5vzxND9K5Mkd6NrCaQCY31x2wzsW325jcP7cdxk2y+x0vXjkPZ7SWNzY3cmQ6EtuKzU3FU2wBhyF+S9slNAQp9PBZGZMKGkP0TzZFgjwW2lRtBx8AxQaOmof2mvnVOCnjRa8N94+JUBum7iiYuyTqSxfO7GPxiUqeTIZQikTu8ME3NUVcgEOlHqYkFxamhpXtcuQTTOZ7ubj8p4LaGhOj9cxRjntCJQxNHLpxwfFds0wRbSnIC0WUZD9gqYfzpwIEFrgfslXZQu8vkagCSWfvKQe1ZyJBJCRL539A5/Wx/EQEwZt4sUolTY33h5isDDNoi5NURXy5VjZ4EBujBGq+Y5Eg5+D8o7/TLiADlYmintgSSGg3vusCc/UockyTpBlvivwJbaF/uRM4nFiEQec5qY5T7HN5tLFDS8uVjjF3Jecb4ADbsU/FJ92dxedf5n26NiAMCdLWURjJuV2jF621b4Eg/LbBynXBuT0/z65IPL4jQ7OzeQOtbNkbckjNN4oE9HRpBzRLBwfhFQDo4g9vrqBAk8O4gBFvTZRhbaGZ2NdIncIAmZBsVWjKTv0i3r9yuK2ekDdtuGpvda8RbI/HZpzEKFnwfdCEW2q7jCt01v//fSUm3BV+oJ8Opo3MnUR9EDrvXP5V/T/8CmSBMXXKDEiSVUyfh0IVmFXjPfXeJVKrXxy2C14cZpQ+KeDbzKknjcOVSVKUkGQ/CkQyx3GSUt44fzH5ER8DGy1gNTEO3b31yvoNkj8JauNYNJ7Z6+iP9RdXnQrffqxJqT99wfXj3mVRtAE841GIdn76BORwTy6sIGL4m8jBEf1KAxgkQY2HX2vyEmDZAeXLXWL8BM1o9+mkOE6g2WjpCHoqjvZo5ilX21xDyRN4pi5+adZAsH3KfVnlkouOulQGHuqy2lAVYcVJa0mEYS5QseIw9dMvROfu4I14x/6l28EYD9RlC+p4jMCIFqgzatRDcaOCAIg2+n39xDteitBQvkDXs+x4H4aU6AKy7TmsuNdpB168wNDeh X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c42168d9-3eb7-41b5-751d-08d97e817477 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 11:01:12.2748 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9mSn8qqRTTGA5w7zaWfjedjZO/ta5l3TYJeVNSEp/5nYKS+AglLLX5JJIJyKyR8ZGUx/vFc2Grj7UorHHI+Eew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7836 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla get nvmem cell-type from device tree Reviewed-by: Ahmad Fatoum Signed-off-by: Srinivas Kandagatla Signed-off-by: Joakim Zhang --- drivers/nvmem/core.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 3d87fadaa160..23c08dbaf45e 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -52,6 +52,7 @@ struct nvmem_cell { int bytes; int bit_offset; int nbits; + u32 type; struct device_node *np; struct nvmem_device *nvmem; struct list_head node; @@ -726,6 +727,8 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) return -EINVAL; } + of_property_read_u32(child, "cell-type", &cell->type); + cell->np = of_node_get(child); nvmem_cell_add(cell); } From patchwork Thu Sep 23 11:01:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 514531 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp293185jao; Thu, 23 Sep 2021 04:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbw58qf4EheobPygpTRMn7bhGKTBv8wWXk7dkEBmio5IYYGygAIhLG8PI5R2fEmvWoRR2O X-Received: by 2002:a05:6e02:d8f:: with SMTP id i15mr3201933ilj.62.1632394953043; Thu, 23 Sep 2021 04:02:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632394953; cv=pass; d=google.com; s=arc-20160816; b=UA5tezfg9uemPc6xDknnuuT9w9wwZsfmcLi17U4ZU6Mn8HIQrhngXAm+cNT2eVQucF fwUldTXHUUYWMUgJKUzSUMMhiOxvJfCTEvOBEHmlNRTvHPaG4GUb4gBh+6Ln3HQosT0r j47ZrYsHzhIeZTdAJ3PyWI+Wi0oDqS/r7DBEKGkIlczuJj9qGvvMLuVb+lHy+D9J8eRA tI8xrIMLyERz/IjjWXwzzYQjth+ZNe68C993cr6OmQKwAb42EEoFtpSwBmLkO7ZQdlHO 7hkecquBoIjLGOULTzQSyd93WpVvVBi9N6UvWXAh+Tgs3oWtHkoMBzrAjsJRSWjmOEl6 6oEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XkNim5Upv15BilG6gSXnmwwW9jSE+qvZPNitUH82U5I=; b=Eo3z+yDH/kxSjEpohI4VJW7bhEdpSuVIBeOpZzW4k0FqHVF4Hesq073NPRiFThiOK6 xbtUtoH34+oczxSZctCt+1zI2V10Gj0QSuXvIQie0Hr72fgDvsNVv+5ClMkqEVQC+Bw+ TMnITeockhg0OtZ08v2LnlwWSD5x9Sd1u3Vx39SoZtwCiVYriAluqzftQSSaENvqcVWk tqEmzDGHzZ9Obn12oPvsrPCePeRC/Ez+z1cyya+hBS0SHFQZMHix5a03SeSWw7siIGDM d4oq3NfaAw6SN8Jh0CHpJKu07dqr/EplR+kEm1oGYxLyJH/XEy4wvZPhGZOdX7hQxfTR FM7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=L4QZBmVk; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si5376242ion.66.2021.09.23.04.02.11; Thu, 23 Sep 2021 04:02:33 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=L4QZBmVk; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240546AbhIWLCy (ORCPT + 7 others); Thu, 23 Sep 2021 07:02:54 -0400 Received: from mail-eopbgr40073.outbound.protection.outlook.com ([40.107.4.73]:54915 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240529AbhIWLCw (ORCPT ); Thu, 23 Sep 2021 07:02:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S3XGUbl0w6nRg97NNDnko+pSFJqjJFfNEURAP4c9WFqji1+kfnKf9apU6Z6WFS/FgldPT2a6AqucCm6KnVgH3GNf14B5X/6d3Y08Svp3R+YtwQ/Q3Fmh/nmOkIoJAKg7jmR0WcrXpAbmJS5uf5eEsfa1S42I+A9yQ4pKB2MHZARDafTmnET2SzaHEVRnU4uZ5GhBzAqYRwcN+VyivkGu5SCREJwcSSTkvl+Dnjdlrt1IE9m/2nfiIR4KwnFegt1IjVnEb4/X5IWQovyJ/9ZxC2mgpP5OKUdQAxMAU+jGAV5JoM4Ryfh+JWt2NZqR4Q3WhIIelNEsK1LNtgZXEHg42g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=XkNim5Upv15BilG6gSXnmwwW9jSE+qvZPNitUH82U5I=; b=gL20nIKXAL7LD8rcVucgHTfLrO4L8Cgr3Ky6dIDrjE9u7bGln28KJgZsXvyUVCrkq73Lcwz3pTPJWC33CCzIMYQ7Aag2CSiFk9v0vcn4aDGB47OkmXZlQ4T+HKlb6pTNkApFxTbQY0x3i+63Zs6oG7+AdMJoBtu71fEqCq0hskjQfkoZd8esAaLQl95qOKMSdoHAl+BmUj3GNyi4cH9vf3hKzBvYqR91a8EFU0Uge35IOxJTZYR50nae8gByffQs2Uh28yc/SEotk3uBepsaGNh24A5aLgWBGUaEeEPfrrkioDdirvh1jgEuNg0Ge8WA96HJK2Rc8IFhI4v78XZTDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XkNim5Upv15BilG6gSXnmwwW9jSE+qvZPNitUH82U5I=; b=L4QZBmVkXFvJXPukdejsM+Ktvaape0wsS5VmBE+3ZpSsOChCKK81jTzhaunMd+yKfVDo/qYELNzamrPY1h18nFSMsBsj4lXmFxcM0H+z+DZaJ5rLOkNiJlgqlsnDIW3ryV9/H/iKshEW/RhOfvFJSBV5H0A+e/UbU72nZMTnv3Q= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DBBPR04MB7836.eurprd04.prod.outlook.com (2603:10a6:10:1f3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 11:01:15 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f%9]) with mapi id 15.20.4544.013; Thu, 23 Sep 2021 11:01:15 +0000 From: Joakim Zhang To: srinivas.kandagatla@linaro.org, robh+dt@kernel.org, shawnguo@kernel.org, a.fatoum@pengutronix.de Cc: kernel@pengutronix.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V2 3/6] nvmem: core: add nvmem cell post processing callback Date: Thu, 23 Sep 2021 19:01:06 +0800 Message-Id: <20210923110109.29785-4-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923110109.29785-1-qiangqing.zhang@nxp.com> References: <20210923110109.29785-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 11:01:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5e60a49c-6d25-4f0e-68b4-08d97e81764e X-MS-TrafficTypeDiagnostic: DBBPR04MB7836: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2ilupEI6iChT0D4t+qCxESwUmQbKEUs/JgzC1O3IzFcJHXBSxUkrNKHj++CEN+6UNavBemSDaZxes6DX5jMLFJt1UjEP9SZQyuXkwbktZyM4E19GkUxEVhI52CpHSquZwvi6y4lV/B8NixRgY0oTYTIA2H4Er0P9RZsTojgLeQ2crCVlmM5kbctwBZh0iNCINYWC93laFvxeD+I5kQjOfekNBhCVrdK9xyfiPg/eZwivr5psPtPSBUMKsgqUgv1rvAj8Fk6w6kE/IH1w+Vfqnxaoz/Md2dDNMC6onQAIuT/0w3OInRvRe/ZzkBS3qkfzF8XYMEs6C7ikmAQstZtkY/uBEj3k2EpLkh6CoF4SFmv1F5O+WzQuKiyifzYByD4evHvVxlssXIRYj6fG7jIFkWxffqaWJ35z9+rjtfYmX3RW+uSnd0N7Ozbn7E/LwqFZlR/4bFtTu1KLY6ekfZN2yiLIReOZDtcAaNnw81XW8/bq2aibiw8PO/CPFT5SKxyNxlTy049jcvgepR5+v0P4bYCpfZT96y5oT5y5UERei7ti9G/1mGy4wffgtpFybzSQe1rXwyFOmVePNqfCjkmRmDi5u3y1bkXObDa62X5rntR1W/mPo3i2ez/6Oy5yqvImG5jZ/d7bAGSws10Lv4NSHv1qntzPa3QU7HRDg8eBHtjlmM/CjhJqYy6u/PN6mVw9XRxaZuUO+qKO3yWOLGgRHg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(1076003)(36756003)(8936002)(86362001)(186003)(66946007)(2906002)(6512007)(38100700002)(38350700002)(26005)(8676002)(66476007)(6666004)(6506007)(5660300002)(66556008)(508600001)(2616005)(316002)(83380400001)(956004)(4326008)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qDlUGJroz/yRlhbg81+A8WePwXOlqsxp2PvyesB45g3Cjc/3X7G5/x8MSxbA/T9uBOS64JocTfNiRcrPVDJ2MJtbpbPKw+xs4V4Yuydjl89Us0UPViCdYPO5/x+q9WKfU373H+HRITm4OUHdzf5PBYpc6G+YH1OPEQPExf8BXEyTPUj+KhG0HYUyl356Lc5FGweoKwlQYjRai+a+TDB9zXMcrlEfkCv1meiPR5djXwvzPHLn61CmJdj9vOkpnhYuW9ThK2luRDQY03OfVDR4avoD2WnW9eCZyuTOxyNLnBRO5oF7/DJZDmo46B6FOLs46zzndTF/9zlCjhiz7vo4exdM+qg/a1uCs3eoGMUIqBpiy/9BnTkUyI+pKvNUKqcWc1NN5ETXvxh78ZVM4USFgi46XN7nB+89Ms9ZhTWadbtXW4zsTesp7OANA3mxTuvezkD2CvJqWS3qbp727f0jzSol3Gsphp5c397/vO2fPK+42eJ6zVDJAYWSh2PlJ/w0PXJmJkYZ28gPnp075vWbquZa4PJyNe2hG/JxMVQRRcuDtOc2VKGJ20kwMUBH+6jD0x9v5cUhQqyiqqpwWXvTPMCQYMc+1pR5U1HJWIZphTEW4I4tIbJ8R/wMb4BeezRkYoBMcTzCiMC5OLGC/SSvwAe93HGMMMfQOF0AvyYBH2bAYhYrD74Yy3md9pdQoIkN+BNdL7e+KNq/YdKl2b0Xxv+R0/QwYOxYfTLiKhy4DzJG6ZF05ZqQNrrG6Kx1LZ9TK1Mf9IL6sN/rfySz+3MTnVZjdMcieVp4MmmjH2i9M6ThYb76UkAMhSaZTMO0Sdce1YbpABeqHjs1IXMggrq0eSkDnl8oYL8ekQUzWZX+OxNeC11fH85TORjYQnCmdVoi4pTfHkZngo1ruN39LcPtZdsFigEJFblv57c5mF3LVz+L2HUsYaC0OXwFdv9G5vq06budI49L7O1DNw9JRJIhFwiPaHsDKd5I8n1xunfpycQkTl3Aue/9TuhQtGQiEmIFHA3cLBNHJA1izC5Fs3YhjPpOyBHJaZrSaKnIxtq3wArx9lGuLXKcb50tRVFiTF2ze6CBw+K11wEUH3qktpIeQf1uySWx3k6t9FqbBD8XORm5J9PnUx0VB/xEuGozjPFGvOeQn3W6orX41Fr5lMI33wwkMTubyEPjVL43p0zfR06G3kBtdyMAOzc5TGSMq8HV1iKk7fzpidyWD3s74iSdkbprh8bVUP+JPGl0BbLUB248LrukQLL6aJcUtEyUsqYB75R1qt/0KVeHDOjblHiUh6ZvUuUOLpSGc8YyuN9QDfSmRVy56RdvmCYgLCHRJ9ZN X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5e60a49c-6d25-4f0e-68b4-08d97e81764e X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 11:01:15.2218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nllJNar/ApKDLezkzxjXD8Cb2qI3GRFdgolxxyf34pzZtVy3fhvEL6+r1ABcdkl8YnAZE6UQ1toqt5oKx7Tcyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7836 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla Some NVMEM providers have certain nvmem cells encoded, which requires post processing before actually using it. For example mac-address is stored in either in ascii or delimited or reverse-order. Having a post-process callback hook to provider drivers would enable them to do this vendor specific post processing before nvmem consumers see it. Signed-off-by: Srinivas Kandagatla Signed-off-by: Joakim Zhang --- drivers/nvmem/core.c | 9 +++++++++ include/linux/nvmem-provider.h | 5 +++++ 2 files changed, 14 insertions(+) -- 2.17.1 diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 23c08dbaf45e..4f81a3adf081 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -38,6 +38,7 @@ struct nvmem_device { unsigned int nkeepout; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; + nvmem_cell_post_process_t cell_post_process; struct gpio_desc *wp_gpio; void *priv; }; @@ -797,6 +798,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) nvmem->type = config->type; nvmem->reg_read = config->reg_read; nvmem->reg_write = config->reg_write; + nvmem->cell_post_process = config->cell_post_process; nvmem->keepout = config->keepout; nvmem->nkeepout = config->nkeepout; if (config->of_node) @@ -1404,6 +1406,13 @@ static int __nvmem_cell_read(struct nvmem_device *nvmem, if (cell->bit_offset || cell->nbits) nvmem_shift_read_buffer_in_place(cell, buf); + if (nvmem->cell_post_process) { + rc = nvmem->cell_post_process(nvmem->priv, cell->type, + cell->offset, buf, cell->bytes); + if (rc) + return rc; + } + if (len) *len = cell->bytes; diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index 104505e9028f..be555bdaf189 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -19,6 +19,9 @@ typedef int (*nvmem_reg_read_t)(void *priv, unsigned int offset, void *val, size_t bytes); typedef int (*nvmem_reg_write_t)(void *priv, unsigned int offset, void *val, size_t bytes); +/* used for vendor specific post processing of cell data */ +typedef int (*nvmem_cell_post_process_t)(void *priv, int type, unsigned int offset, + void *buf, size_t bytes); enum nvmem_type { NVMEM_TYPE_UNKNOWN = 0, @@ -62,6 +65,7 @@ struct nvmem_keepout { * @no_of_node: Device should not use the parent's of_node even if it's !NULL. * @reg_read: Callback to read data. * @reg_write: Callback to write data. + * @cell_post_process: Callback for vendor specific post processing of cell data * @size: Device size. * @word_size: Minimum read/write access granularity. * @stride: Minimum read/write access stride. @@ -92,6 +96,7 @@ struct nvmem_config { bool no_of_node; nvmem_reg_read_t reg_read; nvmem_reg_write_t reg_write; + nvmem_cell_post_process_t cell_post_process; int size; int word_size; int stride; From patchwork Thu Sep 23 11:01:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Zhang X-Patchwork-Id: 514532 Delivered-To: patch@linaro.org Received: by 2002:a02:c816:0:0:0:0:0 with SMTP id p22csp293267jao; Thu, 23 Sep 2021 04:02:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiIfT2CuywR61yzyjz1tSFbsfTBIuNWTW1HoQJqGN+yl4Jk/PXqcepdFPOM2/VYvjcsJKq X-Received: by 2002:a05:6602:2c05:: with SMTP id w5mr3357233iov.160.1632394957647; Thu, 23 Sep 2021 04:02:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1632394957; cv=pass; d=google.com; s=arc-20160816; b=k3LGDFJZXn1ekAlcaHmIy7lb0JiS8cL2kThUoO2mCDq8N1W9+suu4VMbD/LQNMwoyF ptADBljAhuc8fOJwjUlIPIDWRFo8AH1gCLCB6iB9tJpW4oGLFOAp5CwxTHhce8ht/i59 NSr66DP/xi8uMzRVXr0P9TQpUE8SkagVajlxxokW2gCk7PEc43tfeoEFv1/ZO5HwFVcj rBEgVVjxvBBB/RTkIi/g3xG6fWjpfbI8+hyHpY5kaETfbt3KOSUVpHu9HDxI+v+cGm9L buq7KSL1uZmRAx1l7+e+M4xjRJd3VVJx9l11d/uJn8XQaXOGxy8qzwyzQKrRSCKhK2yp cy7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=L1w6mJgNPv25TAFp33iSL9NrM/o/1JNb8Gl5JeEagkw=; b=PWO8H6xNY5WHrt42ABN11hwa0vG04/tJy3UpJtNSuYAyl0+DeGuGCg+gN1EP0zVrPd 1C0/ueURoV2p2YgJHdD0okLwSTWi8MdLysrVjsCDH35spybVSvXaRs4XzOh8l8Dp5HdG OnhuBKkIe0pq+tVPACWOrh1gYGg32EnXArQrZP2UwqB7hFNlxDkm0/T9ij+nfAhlYW+y xs3KcMiRG+s5D80mPsTioDSTesGgoQ9lMgffQSm2stLcJtLPriEnMJSI8hsqYu87Pslz zQZGkKE7vCa/Fe7HIWgZJpSBBxQPHk71y0sH8AvViKLxJSmUB4dpm0uamEfGBN98RYrS NFng== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KtBrh4pk; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si5376242ion.66.2021.09.23.04.02.33; Thu, 23 Sep 2021 04:02:37 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=KtBrh4pk; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240528AbhIWLC5 (ORCPT + 7 others); Thu, 23 Sep 2021 07:02:57 -0400 Received: from mail-eopbgr40073.outbound.protection.outlook.com ([40.107.4.73]:54915 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240542AbhIWLCz (ORCPT ); Thu, 23 Sep 2021 07:02:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZvE3eJMfBH0lGHaOtpFYX9ReMJ7WmL5QwTVX+66Q5s5/YCeBxiwDACJqKvEWfT1FcF9Iv+tPJ8/8CuvKZsThRM+gMzgjAXm/XnK+kVb8kjHMxWAORc8Pnd0BG7FtOztEHaiWELKikuzCPlIr7jt0deIRWa7lToJC+6gYe0jnJKHOcldgAXfOz9PlUVW0CoMxC0uJZrFCFDCyD+cCNs7/ldIIP/C0RX8w1a2AJFYg7Z51rjiDWMpVKv2pQ357XOorUMlPb0EDPjukErcUygRxkJgljMI19fhgHbq4Ud1xi8T5LYumkxWXb8CcIwowscvyBV0tkOrO/GEfNrbGyyqg7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=L1w6mJgNPv25TAFp33iSL9NrM/o/1JNb8Gl5JeEagkw=; b=RrUwboU6CCsDdkd/AI+3rxob6ax9JknUB+4/AtXof4somDKRLBbrQqirBvuhqmMzpDZNgBj8WCXicxY7NclYTsosPQbVdvaAk6eLLpiMdQ7u6yZuF9Nawzk2vnYrO9Vm+oTvJYZzTXF7mYAp8pes1WTvwPmPJIR/Xz5BXaW7tD1Dv1kx7eHmdKT4JAPg2NASJWAbTbdsmg67lheFqQHB6pJdcRS21WSL3YxIB2Dtci9l/jQ8DVjzwiNtyp9L4kbny6FPoP+BZQsjsi0VpT4IGnITdU6aGDJx13WxW1dIQTQLEkrUmRtHVsTd1Kpw/lvcOLutHlvu6J//sCn7Ckkwrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L1w6mJgNPv25TAFp33iSL9NrM/o/1JNb8Gl5JeEagkw=; b=KtBrh4pkPeasTvSrsR5xo2EA3kD5oceTROxWwIDnovLJWEBsl8sHQHL3jmj6nilQtCz+Zmt/xrkEmOt9BssbbcmZCZ5292/b9oPhmCk94KetaN9owgHI8An6fUK5VfCSEy38eAmY/b1kBSroJJVL3Hf2l8w+Tf/EEEnbdJVesM8= Authentication-Results: linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=nxp.com; Received: from DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) by DBBPR04MB7836.eurprd04.prod.outlook.com (2603:10a6:10:1f3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.14; Thu, 23 Sep 2021 11:01:18 +0000 Received: from DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f]) by DB8PR04MB6795.eurprd04.prod.outlook.com ([fe80::5d5a:30b0:2bc2:312f%9]) with mapi id 15.20.4544.013; Thu, 23 Sep 2021 11:01:18 +0000 From: Joakim Zhang To: srinivas.kandagatla@linaro.org, robh+dt@kernel.org, shawnguo@kernel.org, a.fatoum@pengutronix.de Cc: kernel@pengutronix.de, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH V2 4/6] nvmem: imx-ocotp: add support for post porcessing. Date: Thu, 23 Sep 2021 19:01:07 +0800 Message-Id: <20210923110109.29785-5-qiangqing.zhang@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210923110109.29785-1-qiangqing.zhang@nxp.com> References: <20210923110109.29785-1-qiangqing.zhang@nxp.com> X-ClientProxiedBy: SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) To DB8PR04MB6795.eurprd04.prod.outlook.com (2603:10a6:10:fa::15) MIME-Version: 1.0 Received: from localhost.localdomain (119.31.174.71) by SG2PR02CA0004.apcprd02.prod.outlook.com (2603:1096:3:17::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 11:01:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2e33622e-7d1e-4eb4-8f29-08d97e817809 X-MS-TrafficTypeDiagnostic: DBBPR04MB7836: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2089; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WQTbRbZ8QbtbpygYm39Bhoha1PL+Uc99CiERrvi2QxW8kddiEwH98Q915r5ccboDPRcQVOwPxKu/Iq05btOgtnQzi2CAnrNLvsMXegROxD3FD7Q7g1nAZpNjitRf12O0rah6yzkMoaG1tJo84NmXugtIBsY1u3Is8l2Q49xB7xlwHy1jD/faFqPRiipeSFr8bbmL60S+uiSHPj9NIkEzpEyk9Poz00neD7PBr04sYhqiZ3R8qk1KYo8QCMbcfwVFIycoYiqnpAf5q16lGSWQifE9H6wPf2vgg0r9h76FRPsqEeI+DR5CycIp/amkQTn1urC96ZAlgJ+fcsES+31fr4RCXqzoo+cGVSsduSF9yHBolfNFItm1EavC3led7G65Ivz+MVtMysUw4ksjqlhnke/fwAHi5C7lwhGJoN7GSok5/HodAzBiFDAQpY2gKHgyE34k4h4Re8JQzSwQGxm2FQ+aNJBdyekBqzslG+f1jV48ow/1evBAD5Rf25DXjm8DiikiRABYEg14EwbBlojfUOnsjmy20lLa8fjvfX7fvgdGOU/RHvvEAylwsyqfwIHJbz45QQwIhD3BkC0Kn+9OjGuUO6eZaHmb8WMZqg4u/SXcKQyYnWJ7fAkqQYYessYIKycsPtvMNeTUnGsBXWYrJopceO0yAvMIn/UivOFewUYGkwx8glZMxf6dwYTqzyzPaQ/O6LLtor6ksgcYVNqeeA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB8PR04MB6795.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6486002)(1076003)(36756003)(8936002)(86362001)(186003)(66946007)(2906002)(6512007)(38100700002)(38350700002)(26005)(8676002)(66476007)(6666004)(6506007)(5660300002)(66556008)(508600001)(2616005)(316002)(83380400001)(956004)(4326008)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pKGMlwbB56+ovzDULwVxy46RegO1UStX1l8onOfy35TWHxq4lhpfx7b3fXh4PwBwwTAufdyOQjSnvja+aBMVKr+Byj3K2RlJX4SbYasvlw2GDZcoSwSisAGFl+EBHx+1xRD4lr9vKqeF0BJIUwvWwk/wibl+yly5A4MrRVkELdMNS2VMQ83b5aO1vQDHZLgeEaQZUzT38X7l1TnHRHXDPyYuwttNGl+/Ms3ji+K+r6EJJnVteV9CsL6tF31KS9rzaaqJOayfCMyBJp3y+PjuydZQuAAUudJCe4bDfcEPdZ+Hbut66GtbU8dqnHd5Qj2pPNFXhiNx/Q9dC6ebRMHEKsZi0XtabUoWJHE710ArALPJnl6PXJfhGUGYGBVejIrtchO6MYKEZnYDmmVruz3I++QYtDac9YFcHNu/36LanYort2Dv7rg58/+e3xeFaVL41Fk3bghaZB5gmrM7w9L3SKbnewPlpVoCsXL/mO+/zqNwxaPLMhT09p/Oemz8s8/qyvI7AwAGKVWaPunLx0Ci4l6Abf7nZFzmwV8XVlxda3CTp6n/JS4m2SaHnd4vml5tpSCD6n4QMXw2M6l4D1M7vSe4QD5oH+91MifVVck3IWecSJD6p2UkjbBI1TkKeLLKVeSak5NvbzHsJ+hWRGgrOIP//xFpPZT4rPrrBup0/PDOsEY200ARUaMvEHSn3v2HLW9OFY8xtXmpSKnO6gL0bFcmqtBROzIn+bN3SVjdoU/juc/I6m5dVcNmJMkDu9Q2VIz8dh5ATicAg6oOFLrxKFBKmNVCn2zzu1NXMBZRw5/ZxCg2hvirEn7ubdAdmmgMe/2RdAYDbdLZNwK5liwrw7F7GR0ohkOD8DZWnsi/+S2CKwJWj4e/2cKl7mqrFcrL06EzfHniyssQEA9hbI4SLNOus9ujYeUJcXXv/AyBxspHmuyH5jH5Z4W/mO4/855FldgFuygF+tjL9JS/tetYsnKjtoIWrWu6edOs0eAFJdCOnKOoi3bFeCaUzVypXx4a0fdg8GKt/nAHe2lpCGiUAHp2o5yDC+LowHm1ewuMY62nl1mEGTF4weezzSAFYMe5qCdyH3KC0bpQn2fCddVOd8k62tsIIfqGk252Fy8mXnNRIxra0ZKVL7QMwkBE8bZX+JAdj5dzKGWEWN9p4fzWjrIQwWKxllhyMLe3yB+lRI5LLVMPpaitw34lxdFm41sX7zoy76Ek8gGY/oHbu1syrppjzsf1hBxFlxf/HGBATmgswW+i8ZFZCepQq/eaqqAAHRBYJ3hGJW4md0LMy/zhPpIOF30FNjIymRJib0aRtTDB5UJKRvH7Ri5kD0cN344q X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e33622e-7d1e-4eb4-8f29-08d97e817809 X-MS-Exchange-CrossTenant-AuthSource: DB8PR04MB6795.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 11:01:18.1191 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TbJUumlH96t/+bcApd0CLDgAgCA8T22Zs9w1k09OWmULPBfErxzRklX2rw2AMpg5EBiUn1biWFCM3Aj93C9Lww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7836 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Srinivas Kandagatla Add .cell_post_process callback for imx-ocotp to deal with MAC address, since MAC address need to be reversed byte for some i.MX SoCs. Signed-off-by: Srinivas Kandagatla Signed-off-by: Joakim Zhang --- drivers/nvmem/imx-ocotp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.17.1 diff --git a/drivers/nvmem/imx-ocotp.c b/drivers/nvmem/imx-ocotp.c index 08f41328cc71..0b5a092ebcd2 100644 --- a/drivers/nvmem/imx-ocotp.c +++ b/drivers/nvmem/imx-ocotp.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,7 @@ struct ocotp_params { unsigned int bank_address_words; void (*set_timing)(struct ocotp_priv *priv); struct ocotp_ctrl_reg ctrl; + bool reverse_mac_address; }; static int imx_ocotp_wait_for_busy(struct ocotp_priv *priv, u32 flags) @@ -221,6 +223,29 @@ static int imx_ocotp_read(void *context, unsigned int offset, return ret; } +static int imx_ocotp_cell_pp(void *context, int type, unsigned int offset, + void *data, size_t bytes) +{ + struct ocotp_priv *priv = context; + + /* Deal with some post processing of nvmem cell data */ + switch (type) { + case NVMEM_CELL_TYPE_MAC_ADDRESS: + if (priv->params->reverse_mac_address) { + u8 *buf = data; + int i; + + for (i = 0; i < bytes/2; i++) + swap(buf[i], buf[bytes - i - 1]); + } + break; + default: + break; + } + + return 0; +} + static void imx_ocotp_set_imx6_timing(struct ocotp_priv *priv) { unsigned long clk_rate; @@ -468,6 +493,7 @@ static struct nvmem_config imx_ocotp_nvmem_config = { .stride = 1, .reg_read = imx_ocotp_read, .reg_write = imx_ocotp_write, + .cell_post_process = imx_ocotp_cell_pp, }; static const struct ocotp_params imx6q_params = { @@ -530,6 +556,7 @@ static const struct ocotp_params imx8mq_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_DEFAULT, + .reverse_mac_address = true, }; static const struct ocotp_params imx8mm_params = { @@ -537,6 +564,7 @@ static const struct ocotp_params imx8mm_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_DEFAULT, + .reverse_mac_address = true, }; static const struct ocotp_params imx8mn_params = { @@ -544,6 +572,7 @@ static const struct ocotp_params imx8mn_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_DEFAULT, + .reverse_mac_address = true, }; static const struct ocotp_params imx8mp_params = { @@ -551,6 +580,7 @@ static const struct ocotp_params imx8mp_params = { .bank_address_words = 0, .set_timing = imx_ocotp_set_imx6_timing, .ctrl = IMX_OCOTP_BM_CTRL_8MP, + .reverse_mac_address = true, }; static const struct of_device_id imx_ocotp_dt_ids[] = {