From patchwork Wed Feb 1 06:47:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 51187 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp228825dyf; Tue, 31 Jan 2023 22:55:33 -0800 (PST) X-Google-Smtp-Source: AK7set9TiqG7stILhwcAsS86HyG6k2jBqUd8uN08wYoFv1sa6/27v4ZC+TMtjAx39xaFLbHFzXev X-Received: by 2002:a17:902:f28a:b0:196:6577:5a8e with SMTP id k10-20020a170902f28a00b0019665775a8emr1361492plc.39.1675234533614; Tue, 31 Jan 2023 22:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675234533; cv=none; d=google.com; s=arc-20160816; b=MbsJHLwwvZ//A1yeyXxFbxK4aI/CJGvn09Lsy8wASWStbI66d3Lf+Zw0VNHWikni7P ukoCIsUZcHp2WYEAIxwWqnZZh1lwt7EHPo0241Qb2Z6/Seax3hax9cBSbw57FUj5doQ5 H8ah+6gcMZYIGgIScSggQHztmc+8L8djbX6qUDWNX1p1X8/A4uYcMJJmJh65PGs94KiK wXKRRSudrx53Dt6+48DYbkGaZTOk4oa2z9YHr8dDwII+6XtHvUo6IDoou1VRaC1jkt5X QtngYmWXyAJPgY5j6SisR5tyjpMOPn7FVoMvulOSlnrDztcIa2193bRn30C67Ff9GGfF 345w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rkN86TIGDYJR+4nG2fHZ23r9O15jnUv5Y7OgjldbOWg=; b=KGaB98MXPvq3Uqn0JB4ChZrQ+qRQ+slPlf2lUr5nmqY4nSIK0PcShAnsCLB+TNd+06 jZu3i6930sU3di4kpYv1NdyT4vdqc4wHoHHvAj5btf4YpwU3L1SGZOWQS6C9MVqELdKV U5z7VNlItTEGsrN+D+EOV3/CudfPtcIicLK6G6FIM+8cLPlWFfsBeUd6qXP3pm6klA40 gWo2bD7nwnoXveh8s5mkWZe/SiMR8w80RPPbnquz64zSIgRuJ9RBQgC8vXGXihk70TwP TA82ksJPQxl1V+hJQ20A4obUsVKtIJ8qlvbcePrZN65ICCEeq/YJLkYQ2g/nqXFGObmf 0s7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XQIBijkI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x12-20020a1709028ecc00b00194dd9cb062si16738677plo.396.2023.01.31.22.55.21; Tue, 31 Jan 2023 22:55:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XQIBijkI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231478AbjBAGwk (ORCPT + 99 others); Wed, 1 Feb 2023 01:52:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231292AbjBAGwc (ORCPT ); Wed, 1 Feb 2023 01:52:32 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56836A26A; Tue, 31 Jan 2023 22:52:30 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id qw12so32546003ejc.2; Tue, 31 Jan 2023 22:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rkN86TIGDYJR+4nG2fHZ23r9O15jnUv5Y7OgjldbOWg=; b=XQIBijkI8+OKqPlP1sL19SlqXbWw60maYM9giAx3GHyaI8sTJzjRmp2DolRMnASr0y KN+uzR6MaFeH/IuHZUnl3SEco9dEAigoohMzr0+VR8jnKTbFs1fCxFNC7IK019wWt8OY QlzYoAHwljH2DooyMDx5L6kYW21Py4D8vjJ6cfSynz3h51BrFBttejiOKfgd1GgTw0dZ nvzLHSsmvPeJHRhlskiqcv2KfYB/dmNUWPK4L88y9+WMg/F2dS1qJkXnsz7aGsFYHnUn JUswLiy7imzInpudmE6IkD6zZJt8FYlpLUtjMa3u4G3B8tWtvyaAACqDkuz6q4JX0ttc zRsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rkN86TIGDYJR+4nG2fHZ23r9O15jnUv5Y7OgjldbOWg=; b=zrJt6ujNMV6nijKiz28w1N+sKoNkFLrzL/eAi2g2RV4Gjr6vIhZUDyl4QeMAuctw9f e7WtHAq69n4e5fNxAakftobnjbrmig2GWhJlE5A7/FWmUS94WXSjqttLKMkDeRpWjqlm bKSQmI0ypfWeW5BVGioG3nawQ0ApYyiqQa+odlOvM7SNMcZQVljWENmQlUZcbyOi+Kb7 UJyGCMabPVzyXPhOnoyMsg/P8GVend3P+Or2pTJaORoowNG+GAW+3tlhZEr9XmOB2uhv LG/oA/HUMU0IFxkmYTapSfakQE10daiRxg830IuBq3+H2/ionVXcxSNChj1TDEVEI9zZ tQGQ== X-Gm-Message-State: AO0yUKVwMJt3CgyvZjdV7V59/2qG1IHBrr7tA/j/UcHHeca2761ubg2T Msy8xFGLtPIUNKQuZAIh68UMtB29dwY= X-Received: by 2002:a17:906:b7d7:b0:88d:fe1:1aca with SMTP id fy23-20020a170906b7d700b0088d0fe11acamr1102961ejb.34.1675234348849; Tue, 31 Jan 2023 22:52:28 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id 1-20020a170906218100b008720c458bd4sm9509608eju.3.2023.01.31.22.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 22:52:28 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski Cc: Matthias Brugger , Kunihiko Hayashi , Masami Hiramatsu , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 1/4] dt-bindings: nvmem: mmio: new binding for MMIO accessible NVMEM devices Date: Wed, 1 Feb 2023 07:47:14 +0100 Message-Id: <20230201064717.18410-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201064717.18410-1-zajec5@gmail.com> References: <20230201064717.18410-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756610726582511302?= X-GMAIL-MSGID: =?utf-8?q?1756610726582511302?= From: Rafał Miłecki With the NVMEM layouts binding in place we should now use: 1. NVMEM device access bindings 2. NVMEM content description bindings This binding allows describing NVMEM devices that can be MMIO accessed. Signed-off-by: Rafał Miłecki --- .../devicetree/bindings/nvmem/mmio.yaml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/mmio.yaml diff --git a/Documentation/devicetree/bindings/nvmem/mmio.yaml b/Documentation/devicetree/bindings/nvmem/mmio.yaml new file mode 100644 index 000000000000..27e3f6142769 --- /dev/null +++ b/Documentation/devicetree/bindings/nvmem/mmio.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/mmio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MMIO access based NVMEM + +description: | + This binding describes simple NVMEM devices that can be accessed by using MMIO + (memory-mapped I/O access). + + It's a generic solution for providing NVMEM content access. The way of + handling actual content may be device specific and can be described using a + proper layout. + +maintainers: + - Rafał Miłecki + +allOf: + - $ref: nvmem.yaml# + +properties: + compatible: + const: mmio-nvmem + + reg: + maxItems: 1 + + reg-io-width: + description: | + The size (in bytes) of the IO accesses that should be performed + on the device. + enum: [1, 2, 4, 8] + +required: + - reg + +unevaluatedProperties: false + +examples: + - | + nvmem@10000 { + compatible = "mmio-nvmem"; + reg = <0x10000000 0x10000>; + }; From patchwork Wed Feb 1 06:47:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 51186 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp228799dyf; Tue, 31 Jan 2023 22:55:29 -0800 (PST) X-Google-Smtp-Source: AK7set8q0bDLWi+qUizzPDFiQyBenR6GbDkSL2RHb0QKDUFoskDzkLIXUHlv8Ke4hsG/Niill1e1 X-Received: by 2002:a17:902:dad1:b0:196:38f4:78df with SMTP id q17-20020a170902dad100b0019638f478dfmr16754572plx.39.1675234528917; Tue, 31 Jan 2023 22:55:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675234528; cv=none; d=google.com; s=arc-20160816; b=C7dH0swRE6uYklTc79KPJdDwRWVVNRGnG7fApDLNR7e3ixNC+8L9EHgukk85eCuZ2C js7g6Hm9sk9hxLhTzayYzIIPZKWL9Z2u5FPksn/pV3Iuv62XmjFtvr75X0US76zwCLUY I2YY48Ohw+UU4RQlWJG+kQagmMeokqppBmLPB/7DtRHvxHY1Yebs1IUiVk06FcdW9tPi vaedS5A5h7sPmdRwMrK/zZ+PUMcatmp3X8QLNDZ1cKbFnPSqdMB+Jykrvvj7+kiWczTq XZRmjg2xCGqyWqtFrENK9hbdBVPFNetk2tX71iE7oqMfLGpK3LPNy9hx54/DQPiMuqwa sOWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LPyU19+VhmMuIMMpSU5GySmAIP6oqfiCTnK5b5e8Lus=; b=Z6KfPabdFoY2X8T+sC/a/334l2LWLYJ9dzXx3AxSvH6gixjcCqHJZepFZPyYigDc/8 dkBhc9T3FGv4hIVgICF2DYNaE2vprqrcAuKifKy1e/ZdFhdeXf7UrAuEWc+s3D7BhMk7 Y2VnUVLmeWAvQ1VAi1datUSvKgu7NZqqGEaml4aKgT6BCtRA95cpGp/9eFcLtP7ZdkvU kkhr8FnQaLy4Ta1OwqUCA48kTCHNUyw67jQiMUKrxzEzvp1z+s209d7r/61SzHRcACuc /xn/iL+adCc2tIQ/D9TR/D0fsf0qEx8/i4gfje2rKrJf5LbjqESDebuuyjFl/ciMfxta 6Y7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WrbOhXAP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a170902db0c00b001965640b069si14022003plx.594.2023.01.31.22.55.16; Tue, 31 Jan 2023 22:55:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WrbOhXAP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231441AbjBAGwp (ORCPT + 99 others); Wed, 1 Feb 2023 01:52:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbjBAGwe (ORCPT ); Wed, 1 Feb 2023 01:52:34 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 225069740; Tue, 31 Jan 2023 22:52:33 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id qw12so32546222ejc.2; Tue, 31 Jan 2023 22:52:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LPyU19+VhmMuIMMpSU5GySmAIP6oqfiCTnK5b5e8Lus=; b=WrbOhXAP/9dmBsWhH17HvQ/1RmrjVeZyRRbdY5B8ueOrb3gEhdOqTxM7CW4PMPYFL4 TfCfQoI9GAnc2vHMfMEMPctNOI+K95B9YLclNRWNuuTXcKzKWmoLgIucD5Ri2dRB9+Rm QLv/KzB8rnUvez0ZHoG4nZrJ85jQDhii7gbbkQKCmrmEKC4KDkfntN51xX569+x5XVeb dFpPQPuZ6oaAADR43HGvkfC2TBXTPPPMjpzuxkmHkQI9fkG2WBMeiFoFY8mWgPOubeq/ Dz6XsYizMF8UQYUJihKY5arEzzl4iYYd4W6XzB6rUSmkhwPwjD5UKxN8KKLZxC+7L1v9 Ohug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LPyU19+VhmMuIMMpSU5GySmAIP6oqfiCTnK5b5e8Lus=; b=AiKbHyMlDb58NdhA+ElbaltreNx2XylkShr9ukdTYtWaQhrEO360y+wcAR0Qek0qqB riB+aiL/0D7WPsJt5JOM8cOYTCUSRAYPOoAFtRhpWkzU5ZfBquQ/jjEjViEZryzbTTNH 9fT29rANC0/SmxslgVOTRG0otMb9X/tKhjCzVkLn4yAxlA132CQi8o73BtiMSJFsP+I3 bVY5l9xCPIPGZCXD3NkLTDfSCpW73rl65wwfPT0cn+46n0Dg1UuShxwA3i3gusHFbbQi 7A2cq8ip1yaWoHgi9AnHqOrmx7JOw8THEzXMSlZGLPO8gsf4e9Bxn29iTASK7ZA0OniV FZYg== X-Gm-Message-State: AO0yUKWbc46c2tM6y4w+nxsNQBbxDM5y0YQu9kc7BhB4KLZWfgx81bUl 55RKVZ03FjSI8zyxVniCB+s= X-Received: by 2002:a17:907:7244:b0:886:323c:dc39 with SMTP id ds4-20020a170907724400b00886323cdc39mr562016ejc.55.1675234351419; Tue, 31 Jan 2023 22:52:31 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id 1-20020a170906218100b008720c458bd4sm9509608eju.3.2023.01.31.22.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 22:52:30 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski Cc: Matthias Brugger , Kunihiko Hayashi , Masami Hiramatsu , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 2/4] nvmem: add generic driver for devices with MMIO access Date: Wed, 1 Feb 2023 07:47:15 +0100 Message-Id: <20230201064717.18410-3-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201064717.18410-1-zajec5@gmail.com> References: <20230201064717.18410-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756610721462762463?= X-GMAIL-MSGID: =?utf-8?q?1756610721462762463?= From: Rafał Miłecki With nvmem layouts in place we should now work on plain content access NVMEM drivers (e.g. MMIO one). Actual NVMEM content handling should go to layout drivers. Signed-off-by: Rafał Miłecki --- drivers/nvmem/Kconfig | 10 ++++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/mmio.c | 80 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 drivers/nvmem/mmio.c diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 789729ff7e50..9eb5e93f0455 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -170,6 +170,16 @@ config NVMEM_MICROCHIP_OTPC This driver enable the OTP controller available on Microchip SAMA7G5 SoCs. It controls the access to the OTP memory connected to it. +config NVMEM_MMIO + tristate "MMIO access based NVMEM support" + depends on HAS_IOMEM + help + This driver provides support for NVMEM devices that can be accessed + using MMIO. + + This driver can also be built as a module. If so, the module + will be called nvmem-mmio. + config NVMEM_MTK_EFUSE tristate "Mediatek SoCs EFUSE support" depends on ARCH_MEDIATEK || COMPILE_TEST diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 442f9a4876a5..2f2bed7cdf24 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -36,6 +36,8 @@ obj-$(CONFIG_NVMEM_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o nvmem_meson_mx_efuse-y := meson-mx-efuse.o obj-$(CONFIG_NVMEM_MICROCHIP_OTPC) += nvmem-microchip-otpc.o nvmem-microchip-otpc-y := microchip-otpc.o +obj-$(CONFIG_NVMEM_MMIO) += nvmem-mmio.o +nvmem-mmio-y := mmio.o obj-$(CONFIG_NVMEM_MTK_EFUSE) += nvmem_mtk-efuse.o nvmem_mtk-efuse-y := mtk-efuse.o obj-$(CONFIG_NVMEM_MXS_OCOTP) += nvmem-mxs-ocotp.o diff --git a/drivers/nvmem/mmio.c b/drivers/nvmem/mmio.c new file mode 100644 index 000000000000..19c8880dc675 --- /dev/null +++ b/drivers/nvmem/mmio.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2023 Rafał Miłecki + */ + +#include +#include +#include +#include +#include +#include +#include + +struct mmio_nvmem { + void __iomem *base; +}; + +static int mmio_nvmem_read(void *context, unsigned int offset, void *val, size_t bytes) +{ + struct mmio_nvmem *priv = context; + + memcpy_fromio(val, priv->base, bytes); + + return 0; +} + +static int mmio_nvmem_probe(struct platform_device *pdev) +{ + struct nvmem_config config = { + .name = "mmio-nvmem", + .read_only = true, + .reg_read = mmio_nvmem_read, + }; + struct device *dev = &pdev->dev; + struct mmio_nvmem *priv; + struct resource *res; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); + if (IS_ERR(priv->base)) + return PTR_ERR(priv->base); + + config.dev = dev; + config.size = resource_size(res); + config.word_size = sizeof(u8); + config.stride = sizeof(u8); + config.priv = priv; + + if (!device_property_present(dev, "read-only")) + dev_warn(dev, "Writing is not supported yet"); + + return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config)); +} + +static const struct of_device_id mmio_nvmem_of_match_table[] = { + { .compatible = "mmio-nvmem", }, + {}, +}; + +static struct platform_driver mmio_nvmem_driver = { + .probe = mmio_nvmem_probe, + .driver = { + .name = "mmio_nvmem", + .of_match_table = mmio_nvmem_of_match_table, + }, +}; + +static int __init mmio_nvmem_init(void) +{ + return platform_driver_register(&mmio_nvmem_driver); +} + +subsys_initcall_sync(mmio_nvmem_init); + +MODULE_AUTHOR("Rafał Miłecki"); +MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(of, mmio_nvmem_of_match_table); From patchwork Wed Feb 1 06:47:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 51188 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp229058dyf; Tue, 31 Jan 2023 22:56:15 -0800 (PST) X-Google-Smtp-Source: AK7set8ZnwaJezLX0/py96Ly1TLfL8X5wUFooIOaWWdMr12U7ta5tn/Y3PGOf4noethyRp2v8Htx X-Received: by 2002:a17:90b:17c4:b0:22c:719b:3c5 with SMTP id me4-20020a17090b17c400b0022c719b03c5mr1241330pjb.5.1675234575148; Tue, 31 Jan 2023 22:56:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675234575; cv=none; d=google.com; s=arc-20160816; b=jOK5q9NykjHga/IEoGTxoimsnaZ3M+joGN2oQ3gijztqoD78LLcAu/IV+394G7yWRG e3j9n1QaebGJg10vsh/CUrNmA743tXf3Adi8k1fc+pCp3DX3EJWDTF9HPEvFXmIvEnqw 3DkKa5UxGrQnpWA/nqhYyUtOP/YF2xIuRn6dIctKWxnh27guEGbkDjORFSpQJXFQsXmX 2qe7fjaopLKevPCdVX3niou09AGXd8NFyQePuPIO0FgCGwYeXq9pjj9cbrQNghck6vSc dkrchHqq9GzuV1jcwu7Z0M8jsAR7hECTHEAXiYYhAD/jSbWw1MuyK2C0BqwK4GBX+1dS obLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ivmgC6/sjsLjgnwubV4IXo9QoAIf+yIcsu15miGgEqc=; b=epBo6Cg6R+s2jhjS2PPdeiltDAawAmC899wQnMdpeiD8wxKVa/XwI9z2dtfb03JB2V V+nZlQowqQJKV8tutorVDZvIzldEMrujE5YLtoomKtmoFmJec0YUTH8Z8Rr22bK9u/qK fqIozqD4Fm5HTQ1DBG8D372zoo5avtqEpWrMSrcgwubaoxou8on2ONrOfswkv4idFS9Z cCpy0GVBbN5XmS2xqX5eRDnaORRNSsZ0j5hPSCeEUZq2DddNDM9baBHocqdLjoWSRazs WqtZmDcyDaY31bnIoV7qptlC9lFxBy2qf/QQzuQ7XVojiORcL/QeKHWlKeqAFj4EXjEI g3yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="mBvY7kC/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gg24-20020a17090b0a1800b0022915c0c7e2si918498pjb.64.2023.01.31.22.56.03; Tue, 31 Jan 2023 22:56:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="mBvY7kC/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231482AbjBAGwu (ORCPT + 99 others); Wed, 1 Feb 2023 01:52:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbjBAGwg (ORCPT ); Wed, 1 Feb 2023 01:52:36 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4485BF749; Tue, 31 Jan 2023 22:52:35 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id bk15so48419941ejb.9; Tue, 31 Jan 2023 22:52:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ivmgC6/sjsLjgnwubV4IXo9QoAIf+yIcsu15miGgEqc=; b=mBvY7kC/f82hBqQON7oWzx9mBX2znC0pmZY4xaPua/eYyTm/W03yT8pcEJ7O5FDAv6 FTCg2jzUmS7NRAPjqyoF4bCfjAvcM0khTtDT8EJiBMD2s3A2WpLOI9TLpHkqnYJqQWOL g9NptaqyvHLrOy+uXxII81OLBPCsUS38obEox4KOCZ7J0u2MM4d9Zwrm4soLUpgLeQfx L8pveJ8fhOADpiNNB7SIZw0M3IGO4g39okWTdPipmzt8zYU2r5bblVziQl4rpcvPEk+o WSqZEgIfjRKyaZBhCX7ZWGngBriuHUnCG0ITlwR7jsbBpf2EN2tERQ0DwImVc8CJ/6X4 jiYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ivmgC6/sjsLjgnwubV4IXo9QoAIf+yIcsu15miGgEqc=; b=csHkiv7cLP8mQ8tEHvBSU26mmsBlhfbyAzUuQ7qlw1pGeKLKlZlQQMbdiFJaEiu2ur 80Z2VTs1Z77NnWRHTkxUb4F0ggnPv9/yo+88C8DzVLEbpnl3AeQi1CJJ01y9cR+5b10f X4wH2Z9xCHjbD6xfJB18BDgR5iylB+vsOOodAYhe1kkX1SClkLNavcpcstasRMdrVKo1 NYhS7Q6s7pyn5CBXBR/suD1jmsEMi1NssMyfS0e08kn3id/nfoKu7WtcnLf/BgljKZ// nUcqS8YFIQ+VoCNe6WxIazmDI3WCA+Tr+6s1p3Ml4aVYHdifqKcSxd5mJJYP/k21z95X BmXA== X-Gm-Message-State: AO0yUKW71Guw8w91x0GKqpdgnfFcngKv9Pw+n2e9fwZ+8LzaU3bzHDzR e2mnoN/Ae6DYs0neLeXRjYQ= X-Received: by 2002:a17:906:8395:b0:878:6f1d:e5d4 with SMTP id p21-20020a170906839500b008786f1de5d4mr1263932ejx.70.1675234353793; Tue, 31 Jan 2023 22:52:33 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id 1-20020a170906218100b008720c458bd4sm9509608eju.3.2023.01.31.22.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 22:52:33 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski Cc: Matthias Brugger , Kunihiko Hayashi , Masami Hiramatsu , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 3/4] nvmem: mtk-efuse: replace driver with a generic MMIO one Date: Wed, 1 Feb 2023 07:47:16 +0100 Message-Id: <20230201064717.18410-4-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201064717.18410-1-zajec5@gmail.com> References: <20230201064717.18410-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756610769640118762?= X-GMAIL-MSGID: =?utf-8?q?1756610769640118762?= From: Rafał Miłecki Mediatek EFUSE uses a simple MMIO that can be handled with a generic driver. Replace this driver to avoid code duplication. Keep Kconfig symbol for a release or two to help with "make oldconfig". Signed-off-by: Rafał Miłecki --- drivers/nvmem/Kconfig | 7 ++- drivers/nvmem/Makefile | 2 - drivers/nvmem/mmio.c | 3 ++ drivers/nvmem/mtk-efuse.c | 97 --------------------------------------- 4 files changed, 6 insertions(+), 103 deletions(-) delete mode 100644 drivers/nvmem/mtk-efuse.c diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 9eb5e93f0455..4d652c7382a6 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -184,12 +184,11 @@ config NVMEM_MTK_EFUSE tristate "Mediatek SoCs EFUSE support" depends on ARCH_MEDIATEK || COMPILE_TEST depends on HAS_IOMEM + select NVMEM_MMIO help - This is a driver to access hardware related data like sensor - calibration, HDMI impedance etc. + This driver has been replaced by a generic MMIO implementation. - This driver can also be built as a module. If so, the module - will be called efuse-mtk. + Update your config as this symbol will be dropped in the next release. config NVMEM_MXS_OCOTP tristate "Freescale MXS On-Chip OTP Memory Support" diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 2f2bed7cdf24..7a8e29ea408e 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -38,8 +38,6 @@ obj-$(CONFIG_NVMEM_MICROCHIP_OTPC) += nvmem-microchip-otpc.o nvmem-microchip-otpc-y := microchip-otpc.o obj-$(CONFIG_NVMEM_MMIO) += nvmem-mmio.o nvmem-mmio-y := mmio.o -obj-$(CONFIG_NVMEM_MTK_EFUSE) += nvmem_mtk-efuse.o -nvmem_mtk-efuse-y := mtk-efuse.o obj-$(CONFIG_NVMEM_MXS_OCOTP) += nvmem-mxs-ocotp.o nvmem-mxs-ocotp-y := mxs-ocotp.o obj-$(CONFIG_NVMEM_NINTENDO_OTP) += nvmem-nintendo-otp.o diff --git a/drivers/nvmem/mmio.c b/drivers/nvmem/mmio.c index 19c8880dc675..253ade72e0c3 100644 --- a/drivers/nvmem/mmio.c +++ b/drivers/nvmem/mmio.c @@ -57,6 +57,9 @@ static int mmio_nvmem_probe(struct platform_device *pdev) static const struct of_device_id mmio_nvmem_of_match_table[] = { { .compatible = "mmio-nvmem", }, + /* Custom bindings that were introduced before the mmio one */ + { .compatible = "mediatek,mt8173-efuse", }, + { .compatible = "mediatek,efuse", }, {}, }; diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c deleted file mode 100644 index a08e0aedd21c..000000000000 --- a/drivers/nvmem/mtk-efuse.c +++ /dev/null @@ -1,97 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2015 MediaTek Inc. - * Author: Andrew-CT Chen - */ - -#include -#include -#include -#include -#include -#include - -struct mtk_efuse_priv { - void __iomem *base; -}; - -static int mtk_reg_read(void *context, - unsigned int reg, void *_val, size_t bytes) -{ - struct mtk_efuse_priv *priv = context; - void __iomem *addr = priv->base + reg; - u8 *val = _val; - int i; - - for (i = 0; i < bytes; i++, val++) - *val = readb(addr + i); - - return 0; -} - -static int mtk_efuse_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct resource *res; - struct nvmem_device *nvmem; - struct nvmem_config econfig = {}; - struct mtk_efuse_priv *priv; - - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); - - econfig.stride = 1; - econfig.word_size = 1; - econfig.reg_read = mtk_reg_read; - econfig.size = resource_size(res); - econfig.priv = priv; - econfig.dev = dev; - nvmem = devm_nvmem_register(dev, &econfig); - - return PTR_ERR_OR_ZERO(nvmem); -} - -static const struct of_device_id mtk_efuse_of_match[] = { - { .compatible = "mediatek,mt8173-efuse",}, - { .compatible = "mediatek,efuse",}, - {/* sentinel */}, -}; -MODULE_DEVICE_TABLE(of, mtk_efuse_of_match); - -static struct platform_driver mtk_efuse_driver = { - .probe = mtk_efuse_probe, - .driver = { - .name = "mediatek,efuse", - .of_match_table = mtk_efuse_of_match, - }, -}; - -static int __init mtk_efuse_init(void) -{ - int ret; - - ret = platform_driver_register(&mtk_efuse_driver); - if (ret) { - pr_err("Failed to register efuse driver\n"); - return ret; - } - - return 0; -} - -static void __exit mtk_efuse_exit(void) -{ - return platform_driver_unregister(&mtk_efuse_driver); -} - -subsys_initcall(mtk_efuse_init); -module_exit(mtk_efuse_exit); - -MODULE_AUTHOR("Andrew-CT Chen "); -MODULE_DESCRIPTION("Mediatek EFUSE driver"); -MODULE_LICENSE("GPL v2"); From patchwork Wed Feb 1 06:47:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 51189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2388:b0:96:219d:e725 with SMTP id i8csp229610dyf; Tue, 31 Jan 2023 22:57:46 -0800 (PST) X-Google-Smtp-Source: AK7set899VN9Rnz5OsCnVUUpGZfpp10yrFqnFcdi5f23hMQE+8kouX0uMQYJSojnymVd/I9ul/E2 X-Received: by 2002:a05:6a00:2150:b0:593:98cb:e6f6 with SMTP id o16-20020a056a00215000b0059398cbe6f6mr1316450pfk.9.1675234665934; Tue, 31 Jan 2023 22:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675234665; cv=none; d=google.com; s=arc-20160816; b=gsUIcw2U2mD22IeynoPr2yLLnc48gMlbRtCXIY4PaEDB9hILLH+P+eZE0xU/c3fY7h 3DvVSmlouD98feWBf4zMypvxQ/FuSOHmTjjTAGqoy6yiosvQ6hzkO5jf7ncMN30orK63 K0Cxgd9YQYx5DoHHhL9rlQlusiAs1qcE1147jtibRlbAOKGz3eMquV34nho7WIqpI07q KwfsI/tdNxxuO81fLqZR5FYIhS600d+V+n9RFQ1eW+Eqz/AMIZYcRvFO2CeBnkWciHLM PH/FYxP6PPqQBqYO0P/O/Qyq/Df+7L2tFXHr+VfhqmswhYpl34N0Q4JSBTtmYD/vQk7k AdKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3fPObB622ZHAsw7bG4ZtmD1WDgZDX6KJYI3QC9H/s34=; b=Stx3nndjwrvMKHAre5jYmaaZ+R0dSvnMa0dNaq4EGz0n2gskwL0mRk6Z7SVFxP+GIz ILJwvUSt5EtPdh9q9TSVEdN8fKaSxgRwB2a0OGtOjlmXQtRnALYjHLCyNiqLPlzCmbfK TbuWPmVeRx3IYtawG8T9yh4vi0uZ2XvBS4MHR/dWe7ghXw+pNYNiZJW+Gr56u9v/sbnG ZCvi/EXMR/n0DtvlsIn3fg8BbA8DbDZoYLP5Za2hYYAqbsOuGjfqtTH9YL55t/KmVp3q /zx2mcBMzkOwbGvH00KspNLRepPcgLeKGaAoM7BpW3FVER2NDYYlOjctzljdOvgijjP8 X+HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ljP+fzcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g17-20020aa796b1000000b0058db4725798si18767191pfk.160.2023.01.31.22.57.33; Tue, 31 Jan 2023 22:57:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ljP+fzcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231486AbjBAGww (ORCPT + 99 others); Wed, 1 Feb 2023 01:52:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231359AbjBAGwi (ORCPT ); Wed, 1 Feb 2023 01:52:38 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A4DDA274; Tue, 31 Jan 2023 22:52:37 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id bk15so48420136ejb.9; Tue, 31 Jan 2023 22:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3fPObB622ZHAsw7bG4ZtmD1WDgZDX6KJYI3QC9H/s34=; b=ljP+fzclIJjlHMmWQaVJkSQr2M+/sTDBmC+RbHmj5xcO8zNyuRjC8NiPadP5CH96UW hwstXaExliDwmXvG1q/3NxIPr7E+9PQRx9y/kd0XAoZiMRNDf63pdddE1YvA+jj0pEaR qsTyR8XSWJELU4ZcN2936SYxGUbKHcq8gl+mj0yvFtNQD0PW6Jti18z/hGicmmlcdNdM 77B9IlMXefaRaJSkGlyMHK4J41FUZX+ggKo+nU9VziXYgfXWlkxN2h0llCnQndKl36vV sT47hAfA9Q+cNGgDxchrI1Pz1bK2pG6isyveGc04kdPYWNfuGjsGRrvz+RKF7s2g4iQ0 NzTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3fPObB622ZHAsw7bG4ZtmD1WDgZDX6KJYI3QC9H/s34=; b=ge5REmIvnQeRS4JQ9/sM4MLugD/5d5ax7LokELoQ6LGLugs/rM6zDoXLxv/QcFZycC 6lJTPHgLZqe45gSbmiqdm1wM/gRjtmbB6PE8PnzvFt7NJPIL6QtMQJ7VZV1iIR4s1P6q 4XwKMSD+AayyVX247PQkgssiKlp/ivWuHxELg6LhH3ttzqyqWKFZRXbLEh/l/+6zUAWA HrovNJ7KRw7HE6+534Y6LPELdS9OHCjC8A2WTrUMLyj/+5XgfC1NiIhdIKLwdNEG0IW2 qBBVKzp+iuB8D6c1+gz1t3wBvuufpcPy78xMdj02m0LbLFI+bopSDcYfUCQDAUc+h0AA RGuw== X-Gm-Message-State: AO0yUKWkvhBkDajaq3C34GIBht94Unjw7d1NNUyJd30uZYP8xDL4CSSF ZMShB4BDapakYYNYYMJL1Xo= X-Received: by 2002:a17:907:9909:b0:887:9a7f:4326 with SMTP id ka9-20020a170907990900b008879a7f4326mr1108784ejc.8.1675234356056; Tue, 31 Jan 2023 22:52:36 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id 1-20020a170906218100b008720c458bd4sm9509608eju.3.2023.01.31.22.52.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 22:52:35 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski Cc: Matthias Brugger , Kunihiko Hayashi , Masami Hiramatsu , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 4/4] nvmem: uniphier-efuse: replace driver with a generic MMIO one Date: Wed, 1 Feb 2023 07:47:17 +0100 Message-Id: <20230201064717.18410-5-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201064717.18410-1-zajec5@gmail.com> References: <20230201064717.18410-1-zajec5@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756610864923161682?= X-GMAIL-MSGID: =?utf-8?q?1756610864923161682?= From: Rafał Miłecki UniPhier eFuse uses a simple MMIO that can be handled with a generic driver. Replace this driver to avoid code duplication. Keep Kconfig symbol for a release or two to help with "make oldconfig". Signed-off-by: Rafał Miłecki --- drivers/nvmem/Kconfig | 7 ++- drivers/nvmem/Makefile | 2 - drivers/nvmem/mmio.c | 1 + drivers/nvmem/uniphier-efuse.c | 78 ---------------------------------- 4 files changed, 4 insertions(+), 84 deletions(-) delete mode 100644 drivers/nvmem/uniphier-efuse.c diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index 4d652c7382a6..d65950da39b0 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig @@ -359,12 +359,11 @@ config NVMEM_UNIPHIER_EFUSE tristate "UniPhier SoCs eFuse support" depends on ARCH_UNIPHIER || COMPILE_TEST depends on HAS_IOMEM + select NVMEM_MMIO help - This is a simple driver to dump specified values of UniPhier SoC - from eFuse. + This driver has been replaced by a generic MMIO implementation. - This driver can also be built as a module. If so, the module - will be called nvmem-uniphier-efuse. + Update your config as this symbol will be dropped in the next release. config NVMEM_VF610_OCOTP tristate "VF610 SoC OCOTP support" diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 7a8e29ea408e..70dd1154c832 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -67,8 +67,6 @@ obj-$(CONFIG_NVMEM_SUNPLUS_OCOTP) += nvmem_sunplus_ocotp.o nvmem_sunplus_ocotp-y := sunplus-ocotp.o obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o nvmem_sunxi_sid-y := sunxi_sid.o -obj-$(CONFIG_NVMEM_UNIPHIER_EFUSE) += nvmem-uniphier-efuse.o -nvmem-uniphier-efuse-y := uniphier-efuse.o obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o nvmem-vf610-ocotp-y := vf610-ocotp.o obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynqmp_nvmem.o diff --git a/drivers/nvmem/mmio.c b/drivers/nvmem/mmio.c index 253ade72e0c3..f44ff2a56c56 100644 --- a/drivers/nvmem/mmio.c +++ b/drivers/nvmem/mmio.c @@ -60,6 +60,7 @@ static const struct of_device_id mmio_nvmem_of_match_table[] = { /* Custom bindings that were introduced before the mmio one */ { .compatible = "mediatek,mt8173-efuse", }, { .compatible = "mediatek,efuse", }, + { .compatible = "socionext,uniphier-efuse", }, {}, }; diff --git a/drivers/nvmem/uniphier-efuse.c b/drivers/nvmem/uniphier-efuse.c deleted file mode 100644 index aca910b3b6f8..000000000000 --- a/drivers/nvmem/uniphier-efuse.c +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * UniPhier eFuse driver - * - * Copyright (C) 2017 Socionext Inc. - */ - -#include -#include -#include -#include -#include -#include - -struct uniphier_efuse_priv { - void __iomem *base; -}; - -static int uniphier_reg_read(void *context, - unsigned int reg, void *_val, size_t bytes) -{ - struct uniphier_efuse_priv *priv = context; - u8 *val = _val; - int offs; - - for (offs = 0; offs < bytes; offs += sizeof(u8)) - *val++ = readb(priv->base + reg + offs); - - return 0; -} - -static int uniphier_efuse_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct resource *res; - struct nvmem_device *nvmem; - struct nvmem_config econfig = {}; - struct uniphier_efuse_priv *priv; - - priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - priv->base = devm_ioremap_resource(dev, res); - if (IS_ERR(priv->base)) - return PTR_ERR(priv->base); - - econfig.stride = 1; - econfig.word_size = 1; - econfig.read_only = true; - econfig.reg_read = uniphier_reg_read; - econfig.size = resource_size(res); - econfig.priv = priv; - econfig.dev = dev; - nvmem = devm_nvmem_register(dev, &econfig); - - return PTR_ERR_OR_ZERO(nvmem); -} - -static const struct of_device_id uniphier_efuse_of_match[] = { - { .compatible = "socionext,uniphier-efuse",}, - {/* sentinel */}, -}; -MODULE_DEVICE_TABLE(of, uniphier_efuse_of_match); - -static struct platform_driver uniphier_efuse_driver = { - .probe = uniphier_efuse_probe, - .driver = { - .name = "uniphier-efuse", - .of_match_table = uniphier_efuse_of_match, - }, -}; -module_platform_driver(uniphier_efuse_driver); - -MODULE_AUTHOR("Keiji Hayashibara "); -MODULE_DESCRIPTION("UniPhier eFuse driver"); -MODULE_LICENSE("GPL v2");