From patchwork Thu Apr 28 18:17:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12831095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 53515C433EF for ; Thu, 28 Apr 2022 18:21:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MD91+jSsr7waqKmFyxMDAkJqn8snzPbLj1CWeu9abn8=; b=zqc6ErgXXLVy+q vJsJD6PxD4zZ0BpjNkvqzhIfw2iXGNFdof4zkqtXpsl9J6y/e9WpGjubVLI79sR6tt37izpQV1f/+ ArzGk7Iq1I4mgTJATp2SQpnsn9FgE3nFzSY7Qg1jITFHE/pXDjbEK/zIJCklAyRpU2Et48lu3wmZK Aq4+VVFD/qQfrA1pLk3G19Hy8MUlvCu4NwzHwGM6+6PkD3imVCDId22aXLHQLj8I98yknRWll1NP1 IZl5e7Kpdmzk0gNDRDzWhzyerbkkp7CFXRiWyz52VDvspxdKE7Ig6QKptSTrQxamxrJWIYRlsTBoy T6M51LUeieNbH7pSLB1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk8kR-0088N4-JA; Thu, 28 Apr 2022 18:20:16 +0000 Received: from mail-am6eur05on20629.outbound.protection.outlook.com ([2a01:111:f400:7e1b::629] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nk8hp-0087LK-Ov for linux-arm-kernel@lists.infradead.org; Thu, 28 Apr 2022 18:17:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O9isLFzkl2t20A8LUMzo9BncFZDE4OiyKtF8j8FBbNmg1TYrCpziEmV9VIjPrYGfdz3VuiQHLaVh25Tsf5TEqCHYZuwCcYy0ZdeVbKm+q6P1mva4D1h+Mhh+G7363dd0JMTJFyyxDmcxfY9GmWE8UXTgKnIiXK8s/pKLY3XaHFP24MWXTJmJa01+9YPiSp8WE/5PggqgvHM4vSUh88X0nQIUkwyqj8Lea2mM89f+R/y2w1keXiXCgqP1ylEeMI7XdKXIfHDU5s2o6jSjAcwCzRJKxdS14HZRmepJTZ8wQbfvuSoTbdzNV8rSPm5pqbt7DozNhv6KtaP2KEls+Lg7ZA== 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=m3ohv2uuhuUknQyZb3MQy4p0AuXKGDiBPO+j5olRxSc=; b=MCrDfYm55BrtTGfyB3n2mMYgQY/iG683csWlyOjrMnFflzX31G7O44h/R1YXIoau0d3fynp9APJKbVSnuBTItURWGIqz8ZGMHC3tk9FjWH5E/FGAiTbRyPu5qSrc8gsYnwa7tJV0mB+7PWetKqe96M7RYOhlLiNqCD/c+Wye6yAM5yZ885R8Xwwduhf4ceywR29nt9OXdxHRpM1MdUgY/noEQcj5VWomqDdl21yXkOU6jivgkn+zm6n3nZSPpYO30p3N1P5YTv3mLz5xRfARyaUCfkuifLZ8N2CI0hNLzW6PReWpVkni9FuE1CyANuzsb520FhN7UXkJnmN8CuZDsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; 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=m3ohv2uuhuUknQyZb3MQy4p0AuXKGDiBPO+j5olRxSc=; b=gfNj56EG6QpPecgcE4IF/j7o/9PM98wQDYWIWvWMQ6+XloMqF3QcgJ5Y3RLjga9gvQfvZ2ux6odUwOIIATps55uLRHkEmlOd9b6X8IDX6D5N7o0FDZ5zGS6Oz3SB22E0zAnBTYUHCo4GRSYO2XRTdVT6JmRXIqqfESl0D3vS8iaX5xuq7i2EmZ/rVQ1xJG0TOH6BSDhZLi+rNhNir5jPz5duhvPuVKb/hEfEeh5Brz4wxQ5g4ngj6I2yfgZBMgiIGmjdX951GQlT/jxvk87l67ssGhiEpDpXv4pchRMsC2ZJ9otNHeQVUrNbDB3N2H2bcNgzMnTNn9hMOF9GAUc3tw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by AS8PR03MB6775.eurprd03.prod.outlook.com (2603:10a6:20b:29d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.14; Thu, 28 Apr 2022 18:17:27 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.013; Thu, 28 Apr 2022 18:17:27 +0000 From: Sean Anderson To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Cc: Li Yang , linux-kernel@vger.kernel.org, Srinivas Kandagatla , Rob Herring , Shawn Guo , Krzysztof Kozlowski , Michael Walle , Andrew Lunn , Sean Anderson Subject: [PATCH v3 8/9] nvmem: sfp: Use regmap Date: Thu, 28 Apr 2022 14:17:02 -0400 Message-Id: <20220428181703.2194171-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220428181703.2194171-1-sean.anderson@seco.com> References: <20220428181703.2194171-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0117.namprd13.prod.outlook.com (2603:10b6:208:2b9::32) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e5f8ee82-f958-44e1-7607-08da29435a17 X-MS-TrafficTypeDiagnostic: AS8PR03MB6775:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x2SX8g1Oip1pPYUejqc5IRIollbcYbHOjo9ithZkp8fpLcL/6yijjCsOHQ74xaa1WeKeMEEIYY36OyuqYpy9n2TXQ5Wb90WEzbKl+fSng9MaX75A0mvT7Gkbk6dJ8fd24srh9D89RsLRT65f8BQVhCfe3xUt1PPZe2NQuHp9JgR7JExPP688NJ8Hhu1dY/qD85Zdk2ZeUXfncY1haaaZ3usBoshP8yNQHzDrkZwjqofdyEDiU2SkQO9XBc/6mwcjdeZ5FJPhZzGfCTpu8tgUKvKWz9KNoApRDgDOO161ZujLNnHNK0HpwjlvupQI3PeDkahRzEFtJF+G+0nKPeKFizPenfEOOzdPSScClFkN/O+EMhsQDJ9SpFObZnvm9cYaQeby2FmURvoh+kbAbfSN3HfnnWUXm35b2oi3+Jwpg4KK6BJfUJuoeyGg1vJcuruHRUhtbV6/opWooNrAGCvcgs0+WieAIbRoxSkcRbU7M5PDpXKv5RknMY3HSqFf5y1gUpz86gGtQ+ufILJhophKu1hquCU/wRLQL4HZ/qtkNkjp1TzFV2Nv4P8DtCoRlyj4w6T2lYgfdIHmx31NRobnv730sT7oipfN5tz5L2GTjmvn054LI7aymR8yx/4aI8NLaNjAoS7WG7x1hdkIRanl4CsnTlgxRDC1GkVA4un+foVCK7cGVALplaVP1cx/iyBzJiI+Ko0dB6uiacSxPMUkQg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(5660300002)(8936002)(6486002)(86362001)(6666004)(2906002)(44832011)(1076003)(38350700002)(508600001)(7416002)(83380400001)(38100700002)(316002)(66946007)(186003)(66476007)(8676002)(66556008)(4326008)(36756003)(6506007)(54906003)(2616005)(107886003)(6512007)(26005)(52116002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RKeHc8vtkbUx4xd4JuvyugXWJ9W66stfgiOOl0PkHh+40WG2dPEq5j3jHSZ7arqcjq4ZsxNPXEw5P9dMe12kEeNGUhZT9e6zLkflJITkmuGDeLucrlxDrr+YAOsfY23iBF5FZHNXgbMQ0+o+mutX2DDgiGldefSGd5kWbSg5o3ItM1KybPktF2e7CXGtsfGAGCibEhC/7U1jQ1x2Z1XvNLQdYSppxEWZ4lUs604e6xdFyc9USe5Bb1W8TztwmIgy0GQUbDAkFQtrQL2ELxqPphbe26LWKvTmIDzOCwaPyfc38dX5Vb2bC8ePgfQhZpc4FFloSTq7VtW2Rhmy5iz2s7E+6cQYIkbERrY9KPYATvj3HG2a+YasQ2PGhCnRXRKcAj+Qtb50UyDukm+PP25chjsY9eRkht0GYfxiRHNrayLJGPIg2VJyJv+cBkYvP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M17FyuF883Ku0qXwSKb7YbIxC7DQPwCfWSj3R40FJfEhJ11vphGO5xQO7r/HuiRMTvMTndc25Q5P1QGe1K2CwkUOMZfnl+dRXGyhOSH6e2NCkgLLfL2IGhN0Groqrh6RW4l0IxuAhCeI6/8/aQWS3nbaQqTWXZn2fDV3LER5XAmIDZ81cOmHNLk32aVpuXIxBA7ZOxQgQ6A3/hMlOLS6KC8dyl0c41QRWnrtdPeCZr+cpoH3k1E9ToUKXyLDQboA= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e5f8ee82-f958-44e1-7607-08da29435a17 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2022 18:17:27.8631 (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: gcfw/Od+QwNefXlEEFgcat3yuDncRSbjHsyazeGOzQJdYO391RjmSXbJAsyi34fTQKRVCNiExkFsizTMOKHHkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB6775 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220428_111733_833912_651DC7A9 X-CRM114-Status: GOOD ( 17.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This converts the SFP driver to use regmap. This will allow easily supporting devices with different endians. We disallow byte-level access, as regmap_bulk_read doesn't support it (and it's unclear what the correct result would be when we have an endianness difference). Signed-off-by: Sean Anderson --- (no changes since v2) Changes in v2: - New drivers/nvmem/Kconfig | 1 + drivers/nvmem/layerscape-sfp.c | 30 ++++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 555aa77a574d..403ed5257592 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -304,6 +304,7 @@ config NVMEM_LAYERSCAPE_SFP tristate "Layerscape SFP (Security Fuse Processor) support" depends on ARCH_LAYERSCAPE || COMPILE_TEST depends on HAS_IOMEM + select REGMAP_MMIO help This driver provides support to read the eFuses on Freescale Layerscape SoC's. For example, the vendor provides a per part diff --git a/drivers/nvmem/layerscape-sfp.c b/drivers/nvmem/layerscape-sfp.c index e591c1511e33..59083f048921 100644 --- a/drivers/nvmem/layerscape-sfp.c +++ b/drivers/nvmem/layerscape-sfp.c @@ -13,15 +13,17 @@ #include #include #include +#include #define LAYERSCAPE_SFP_OTP_OFFSET 0x0200 struct layerscape_sfp_priv { - void __iomem *base; + struct regmap *regmap; }; struct layerscape_sfp_data { int size; + enum regmap_endian endian; }; static int layerscape_sfp_read(void *context, unsigned int offset, void *val, @@ -29,15 +31,16 @@ static int layerscape_sfp_read(void *context, unsigned int offset, void *val, { struct layerscape_sfp_priv *priv = context; - memcpy_fromio(val, priv->base + LAYERSCAPE_SFP_OTP_OFFSET + offset, - bytes); - - return 0; + return regmap_bulk_read(priv->regmap, + LAYERSCAPE_SFP_OTP_OFFSET + offset, val, + bytes / 4); } static struct nvmem_config layerscape_sfp_nvmem_config = { .name = "fsl-sfp", .reg_read = layerscape_sfp_read, + .word_size = 4, + .stride = 4, }; static int layerscape_sfp_probe(struct platform_device *pdev) @@ -45,16 +48,26 @@ static int layerscape_sfp_probe(struct platform_device *pdev) const struct layerscape_sfp_data *data; struct layerscape_sfp_priv *priv; struct nvmem_device *nvmem; + struct regmap_config config = { 0 }; + void __iomem *base; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; - priv->base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); data = device_get_match_data(&pdev->dev); + config.reg_bits = 32; + config.reg_stride = 4; + config.val_bits = 32; + config.val_format_endian = data->endian; + config.max_register = LAYERSCAPE_SFP_OTP_OFFSET + data->size - 4; + priv->regmap = devm_regmap_init_mmio(&pdev->dev, base, &config); + if (IS_ERR(priv->regmap)) + return PTR_ERR(priv->regmap); layerscape_sfp_nvmem_config.size = data->size; layerscape_sfp_nvmem_config.dev = &pdev->dev; @@ -67,6 +80,7 @@ static int layerscape_sfp_probe(struct platform_device *pdev) static const struct layerscape_sfp_data ls1028a_data = { .size = 0x88, + .endian = REGMAP_ENDIAN_LITTLE, }; static const struct of_device_id layerscape_sfp_dt_ids[] = {