From patchwork Fri Apr 22 14:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 12823604 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 A42EDC433EF for ; Fri, 22 Apr 2022 14:56:31 +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=dU/cNX4Q9Uk74Prfcba+D+fexR5QldfRLeBTkQ4vwZ8=; b=HBvif0ATdrn50n i1BMGSz/7tLrali81KSRzgdWdDv/TOdLLPZUr+eutTIP4uq9KaCCIyOo5miWc7Foowm4kf4/Wps9a DtnJOxZXzBQHsR9vzMQEdlITjF8DtICF6jHlPhr53U9H7XI8SyPDQW+LPJxKPVVkAEFvajJkdF+1x DkOjHFUhuT8fdo7VjAWEEfc5kfSNESD/pcuOZxltnXINByUCv/j446wW17s1TenQ1Ienny6jWRvLO CYfrfWpWuJB9Jt6qtD3MJoCey/63yAJFi6yPlF76BbZG5BWy50M/OPnhrmuz+w4eRAPz37P3FTK+X 4dslv+sKLlpD+VQVAzgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhugj-000vWD-3k; Fri, 22 Apr 2022 14:55:14 +0000 Received: from mail-db8eur05on20613.outbound.protection.outlook.com ([2a01:111:f400:7e1a::613] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhudu-000uQj-LR for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 14:52:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aBv/hLbKBxSptfYF7B8wPdw0rE5z3tX4/iJo2bIyBya5p+xIctgkI1pt8rMHZoQhDgi56a56WEyFQUXFBJ2SIoRCZmmImPu9D2LH1pUTXDd3Tx62q2Vsamp276j45nytk0lMZBSfSgrJSHxd2h4jLCYbHl7bglhD5Vo7z1TfomCCa5/euELXcCV1ZJmg3h4ZZn1pKOSt4GrWVra3RKorl/aZ7MhTqw+7S1LnOSyoyPrGKZmuTQv3gilrCFg8tD6e+T6r2EwQUdyVA495h4SfMGW9hydCGTQG8Jxku1ghc2wln1HaOkMcb6GfbwshL9GzTN7Nf/ogyaqY7l36ZgWL/A== 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=BY+KrddlITclcy05ISnuSBCRR8YXMVd48hcCHAj4NKI=; b=Rhxu9ttSqCdDxPm5aQlYFty0XVHEc10FccRMyOvMu9lNIpORFtNK/lZh9qiEgfRHmdXBI82pO4ntz4gMGEJZxEga1T5xz167IObw24UuqqyoAp+l7C2F0SDIP39dtbDEUr1uD0A2evtUZpdil3zQXNpAxfEiIbsmdTN5XE+mQpubtFQfFwsOVihONutk3YU9XEhmfscvVZl9VVo4p+QookJtzcmTzy+zqXwrGKJi0pfk9B5ywedeIOuLGVaNXkUVeydwsIZndX8v/XLH5heLC8JUJlmEfdu+e8c30MUwoTFdDu0vHRGmA0HuoRXSg9cC8wMlMBiNJdmNZsZ4yoUHiw== 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=BY+KrddlITclcy05ISnuSBCRR8YXMVd48hcCHAj4NKI=; b=lqOMtYkckob8sbhyk7SCaOEjicQguW2UhrXgZ/D2U/PBKcjZQMr0sH5WOJNCt0NPhvEtqdwh/xgQLe4K4NnmxIv8J8H9gYN1jV9NXnHJvUAk3CA0VuBsMlJk0juItDYyjvm4E9PEKryeW6wW3WpCUlLmg2RoOcCaJLgyoLEZIiCyeZsv+w/rxxPrmQUKC1NYjAyF61Si6e8ks8PyvsAIb+krJHCmCcCqYD+pd9/sGGlxcQXKbgm3R3+NPxCmM9UGHkB1b9xmUZ9eNC8b0WuHEZJ8pSTuXwHQjP+RXqrbacY/+e46loxZjT3VOU3CH+/F7V8b/DMp11jXnBei2aC67w== 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 VE1PR03MB5213.eurprd03.prod.outlook.com (2603:10a6:802:ad::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Fri, 22 Apr 2022 14:52:11 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::714d:2b6:a995:51bd]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::714d:2b6:a995:51bd%4]) with mapi id 15.20.5186.015; Fri, 22 Apr 2022 14:52:11 +0000 From: Sean Anderson To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Cc: Andrew Lunn , Rob Herring , Shawn Guo , linux-kernel@vger.kernel.org, Srinivas Kandagatla , Krzysztof Kozlowski , Li Yang , Michael Walle , Sean Anderson Subject: [PATCH v2 8/9] nvmem: sfp: Use regmap Date: Fri, 22 Apr 2022 10:51:46 -0400 Message-Id: <20220422145147.2210587-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220422145147.2210587-1-sean.anderson@seco.com> References: <20220422145147.2210587-1-sean.anderson@seco.com> X-ClientProxiedBy: BL1PR13CA0065.namprd13.prod.outlook.com (2603:10b6:208:2b8::10) 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: 51b3def5-9feb-4e03-016f-08da246fae8e X-MS-TrafficTypeDiagnostic: VE1PR03MB5213: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: jU60NtDlx3JAJMmT5NTiIq24KJRqBGNj5rFOE81SzXCtl1vq7W/am+oxKay2ZKOP+CAVCpM2G1ryOEe830Z1xgS82mlBwOT0Z6k9UEtHuo3SXt49x+Lr5KZrNb9bWFO9aH5fSmYSbiGTKNxiqCeI+cpHMiiYsAyzxGqDUtQKf/jpT0vpSwrwC5QlRMt7/u3l3D7LxxI4c3fvkiDOwArCNg9RLByAQH0N9MvDqAcI9vQozcUtdTg2jsqlmko/xTUN++QdcOufiYmWBYYY6YeCXFS+qKzjne6ghlxDacNf8LWsOX1t4nKwKQYRCqanXaofTob1cO3IXV0My4J+DOJSHn76FpEXO2gti9OtnY6XW+Zztyjobdw+mpYM4qbN0GkAwZR1iJ42VSXSCMpsTOs6WmT9MY87c5WIc1+iiYmhEQ3y0LU0uaNfxuyMRmzj4GPB+p2ZBsr7eUL4WoGlWVGF+NO1luqSnETaMr8X6138rSG+YPk9OlMc5/iDvM6WvHoqE+SYEU2n4JMXd+Rkg/4zf2nD/LKdNxSXCund0AGLu69m7mRm5cB6qrKTfwqREU3lcDDmSQTDXdlE8eGvbnDhyRUy6nXMZCYMhwYqZVEZmBNxjag5Kus8LWoOMkq7NlGhFjFOjhQKwd62fs46nhYzeOeMEnX2quMPPtZ65kNS3q6Jm4kLL+JyG2/PtY61g+DtMO/5n1haRi7lA2/LTtlO9g== 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)(316002)(5660300002)(186003)(7416002)(44832011)(508600001)(86362001)(52116002)(2906002)(6506007)(8936002)(107886003)(2616005)(6486002)(6666004)(83380400001)(36756003)(6512007)(54906003)(26005)(4326008)(38100700002)(38350700002)(66946007)(8676002)(1076003)(66556008)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rnzRGXSrelwaj7Um4Sx469+RQisGfuabEU1hC0ArzPolzg7B6vw5G7hHRt6z16sIKCEABb9k8DJOIj7OZOLEqP06KMdU/U2QeO+hFimRoB/9cqqg3RMYYEl6kuFuFbvND60Nd024XgN7Zn9H/arh9U9Ptc/ZpjBnJdhg8A77f6V7CrHX2KxWh9BiYaj+PwWpHDz+ZhVlwOVyjPF9X5ML5dMEALjzvEEA5i7I25IwBMVrldRun/CqYgIUePgukr6nL/bLHiARznwXxsO7n2cnsKMybkWW2Y4yA+PYEkGy5Pp3ZavwBM31NZHG/J4jZj5ylPLuUOIkD0Iht+2Z6V5RIomADva/eOI96OxKjXjzqKbJk9mf7mwg+/5L1Lh+nmmDB6qROccRj9tbesxvt4y2+V3860bFktus6x76DDyVf/wFmlDkfJnrG6NDVcZKs6KbgFwevQRoFGC7PK1W1jHY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Wa1Zll7xC3d2R/GPez0PLRaqyIQw1NkWZkafDffyRDGrGRMvwOnUcgzRRYqenZniVVSGfzruqme23wlJtFMAvb8vArdS3NJwu5cpMMzbqYeSFmDwSE4thv5bObARE5e504MMuv3m85LDmBGhDPYbm6jI2z0DxNAH4y2Zt/mcCPxiAnQde/4LHLabqPyACMXpHhIiSbOqHFxw1lU= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 51b3def5-9feb-4e03-016f-08da246fae8e X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 14:52:11.6108 (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: 0YqTdBehaY5c3aSNUCNYv1PD0wTLbd+CGAF1/h7VKe4L9BfH/TToZb/1tQZMu+eU3xnQ5eoTORRM4c9IsJVXkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR03MB5213 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220422_075218_863770_0423C32E X-CRM114-Status: GOOD ( 18.41 ) 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 --- 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[] = {