Message ID | 20220207234212.685316-11-sean.anderson@seco.com |
---|---|
State | Changes Requested |
Delegated to: | Simon Glass |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=Iqaxybpp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Jt2mh659Bz9s09 for <incoming@patchwork.ozlabs.org>; Tue, 8 Feb 2022 10:44:36 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5353583CCA; Tue, 8 Feb 2022 00:43:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="Iqaxybpp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 34E2E83BDE; Tue, 8 Feb 2022 00:42:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::605]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6B93B83C4D for <u-boot@lists.denx.de>; Tue, 8 Feb 2022 00:42:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G9OgYIn42uOmh/o38GrHOWYwwpbJtuUU1iP/qyj7AlDNWlaOSWQxseXtNFz/AdnlhgoWhXeZwBMQ80pr/i2Y8J1bv5IMgUT02FVW6q0CL41QqLL1Dot++EysBI9RqWJO2qwO0SGNedOg7ZdTTR7E1yyVVdscYUNYhxP7R4+68kY9Hb77vYr+tJ9afElvc17PsYKfOnLercqdqhOBXEzsUd7b49eFixADi5VCe2+VVu5cyu89kDbzTlfrZdOmVDWmWsgH259Q27KOkE5ow/uDvHaZQlVibtEIyt6bZ+/Fq1lpruSwKb7de50SBzzJzr1hLAgtW9C+Im4dkSrw6xbtMg== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IjZkP9+Riiu+8fKCAYCzPiMj7yNzCQI18uQKemyrXlk=; b=bH95h8WHieyFjhFWjbJSd6DShkKPSwC61HyBS5o2Amdq4wuTnTPkAFDRKlX25tW78SKJM09x43y+QnohNg/lu2+nBiJ4Lp857xEwklp5c17CqSXqOM1ocDx7MXuZj6X8Efly8GuE1GJZsMcwOaKA7ZKUeLRx50PY1Z8IEE+McwTM0wkW37LKw2WQRE3tfPxZjX7x93ktexX88l+rpvAN8YI/54CTM6PfxP6Nq7MwbcFfhkVvb/dvMvPrASpwVOZAiFuBT1TT5PSBLINtHnTm8LoCOGKV4G1Jt4SYo6Ql0ycHb3SIxVEEult91gLOoEFCEb7CPt1EVj6nl97yev7cYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IjZkP9+Riiu+8fKCAYCzPiMj7yNzCQI18uQKemyrXlk=; b=IqaxybppPqDYXEexh8tZoM9MvuOCh9rs8T5dGGH9IEgHhSTuKzbE4QYWKutkhtbGihZv+wO3J3cbZIe8pMtya6Dl23cLFQGwxLsaL65njskl9Posktx4CfrxTbDX9JjoXJ/2lQ7ZUn4OA6WmVdLLmxXysS2Uw9QtTRLxwICmeUYD5EO0mNfvMHGPJw3wdfTeG1j+wL+WE9+KKzjgtpdKKL7/3z5CjsCwn2/ksxh0gaw5epWRNkZ6E21VbmU5biW64NqNTs/tjZOhIOnrsUrAr3PW9DgUatcBqoaHqlA1Dbophj1Rd4w0+5fUEQ4/YmnHtQnssEml7CGtA+iF76z+eQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by AM9PR03MB7377.eurprd03.prod.outlook.com (2603:10a6:20b:26a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.19; Mon, 7 Feb 2022 23:42:37 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::ed45:f086:5e82:fccd]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::ed45:f086:5e82:fccd%4]) with mapi id 15.20.4951.018; Mon, 7 Feb 2022 23:42:37 +0000 From: Sean Anderson <sean.anderson@seco.com> To: u-boot@lists.denx.de, Simon Glass <sjg@chromium.org> Cc: Ramon Fried <rfried.dev@gmail.com>, Joe Hershberger <joe.hershberger@ni.com>, Tom Rini <trini@konsulko.com>, Heinrich Schuchardt <xypron.glpk@gmx.de>, Mario Six <mario.six@gdsys.cc>, Sean Anderson <sean.anderson@seco.com> Subject: [PATCH 10/14] misc: Implement nvmem interface Date: Mon, 7 Feb 2022 18:42:08 -0500 Message-Id: <20220207234212.685316-11-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220207234212.685316-1-sean.anderson@seco.com> References: <20220207234212.685316-1-sean.anderson@seco.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN2PR13CA0024.namprd13.prod.outlook.com (2603:10b6:208:160::37) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ab5c5f3-c7af-4a92-d1f6-08d9ea938596 X-MS-TrafficTypeDiagnostic: AM9PR03MB7377:EE_ X-Microsoft-Antispam-PRVS: <AM9PR03MB7377CA15C37B740B6B664E88962C9@AM9PR03MB7377.eurprd03.prod.outlook.com> X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IT/oJrE+kzkQSx8hvz5+1HG9atDE/6uvYGgIrNUgvDs9k00cJgcyh+ArS4UgioIVX5HS+xDidAUwYm2cI1l+0ySh1zWI/ABFb9vUOs1tgeQDdDqEDXfGh3oFWaFIyDuWDl9AA6nc8by9DSfIbJmEusmheOEzx6hWCpAC4RTwkr3cRYKQK5eY6eZfpd4Zs70fFu2tweVEV1Z/eI7lwXTtSrFWCbs16tVrX+CBsYYlqncpQ5dAuNutJaRdMmSu6BmMxa72LtVoXNpECUabCjX9oAA0uaSgbyeq91wCVeOa2mMB3SKRUqaHO7xb0BYf8UQZZhkWnFzSejDzEih8xpkOw3aHPBfxG09tIFvNiaLvghueeu5UkKtTGLuVQNdMoDUbO1pGqdAaXpslAN1oauQVVGIkbghhUWOi1V9icsYUgwkYBlSw0AuUDvP+O8izBD31zCyEc6HT8hZ6JrVlFjPWQ5Oi+/ZQNDOjntM+NLexPUkH5Z8lRe8ZPDTBmi/TDSDJaNUEKjP6M+PBVCKyvy5DndNUOE/VCPVNIOIs8J13DpwGh1SKg7PRDNwRTgot2aLAYwU7JPmMMbwUI7wi0Agp/+WaAPSeuUleXA4lhXdRvgZdhVufdPozHJVp5zPwlNoOg+Ulq/Z2wVPbjXHXUKpgg0pffgtyi9Lol1m+qXjHxACH2gR8rW3XmSPkjbRJcsHsJa+ELoFgs3ku9PRM2q6zGg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(8676002)(66476007)(66556008)(4326008)(66946007)(52116002)(36756003)(2906002)(6666004)(6506007)(8936002)(86362001)(44832011)(5660300002)(186003)(1076003)(26005)(6512007)(107886003)(38350700002)(508600001)(38100700002)(316002)(54906003)(6916009)(6486002)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: okiV0lFYb2hhlsqvmxIqReHytbOskCIeLIT+nAeGYfNF6hssnVueNnc14p6yrqgWy2clGvDYD5+qIPSrEGiU34c1rzfavjIFXg97by3yYWmItfRwKgKNYq9mie+8FLNR+S+3b0jxPHoMsFEEdWoHyP9HOAtJjTJq39FmqgSv3fPDX2lNsAs+3IEkHhKitZpYEKbbLt2skD2A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rUkDmVE7kmSDhr7KXm2V2sc4uVEv58V8whMCt0BhFzEMw8MC2O9MrCIwoEciWzlT6KiowSYH86w66UdE8NJjJuKO4MLuUfcPLRMYmJcgtAh34h6jA7fqdzA5tg3r7kj4j6L3ZoyDSqB/QiVRniMl+XPm+JPHQCc4gI6NCviIGL5Zt2sfCbtrDRONpXp3XcootRxeEBjQYlhskcvH8IaLiNfK0bJpTnzCDTbP2purH13UgyHSM+SuVY435bEjVrjKbg55sEPpgwEIClSOYpMhvWdJD/30A2BEjT+UWsAtOAcvEwQAf7Pft1fobsiUw12H5naylYzofuXAKLl5gAlm+dMNlhHxFuUk4ZoNiSPKLWd+GecveyCB7iDCM= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ab5c5f3-c7af-4a92-d1f6-08d9ea938596 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2022 23:42:37.3231 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0IvOeYfo1j1VfKUyFi0XEpv1mff11s0TKb+fRIw1fSus5jOiOXz44Xl3O0A+3vv3L7KOLDsb7Jm3xi3xWMnbIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB7377 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean |
Series |
Add support for NVMEM API
|
expand
|
diff --git a/drivers/misc/misc-uclass.c b/drivers/misc/misc-uclass.c index cfe9d562fa..6bbc78c38a 100644 --- a/drivers/misc/misc-uclass.c +++ b/drivers/misc/misc-uclass.c @@ -9,6 +9,7 @@ #include <dm.h> #include <errno.h> #include <misc.h> +#include <nvmem.h> /* * Implement a miscellaneous uclass for those do not fit other more @@ -74,3 +75,33 @@ UCLASS_DRIVER(misc) = { .post_bind = dm_scan_fdt_dev, #endif }; + +static int misc_nvmem_read(struct udevice *dev, unsigned int offset, void *buf, + size_t size) +{ + int ret = misc_read(dev, offset, buf, size); + + if (ret < 0) + return ret; + if (ret != size) + return -EIO; + return 0; +} + +static int misc_nvmem_write(struct udevice *dev, unsigned int offset, + const void *buf, size_t size) +{ + int ret = misc_write(dev, offset, buf, size); + + if (ret < 0) + return ret; + if (ret != size) + return -EIO; + return 0; +} + +NVMEM_INTERFACE(misc) = { + .id = UCLASS_MISC, + .read = misc_nvmem_read, + .write = misc_nvmem_write, +};
This adds nvmem support for misc devices. Short reads/writes are not allowed, so we need to translate the return code a bit. This breaks the API slightly, because the original buffer shouldn't be touched if we fail while writing. If this becomes an issue, we can add a bounce buffer here. Signed-off-by: Sean Anderson <sean.anderson@seco.com> --- drivers/misc/misc-uclass.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)