From patchwork Tue Oct 29 10:22:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13854651 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 4A3A5D2AB1C for ; Tue, 29 Oct 2024 10:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=iku2aazVoaifn2qwZ8do62mCbu6cZo7YQepKnixIbc4=; b=FHol3VeCNn7ePylNpFRvJFlIiz kSB9RNyF3g3y2MscHOXSBDxnseLpAAuXtaENHTScyXwFtZSgeuyUch82zW8PVAj0cmuayxWokTQh2 p1ZQWFBVyog8qG0X0dcdCEL+w1mxFGw99iXCFl1kNU+1yJmfRKxTMNUb447mYABB0un0mji1jz6lx i7SdfmZhXk/nVhJiFYWNZRuICYjyp1hi7ExGkyQXjBHu9D3IDmemlxQILoS8SV/zRXLKhvR7Z2FcD HTaGA9ht78weOxpActbVhqHm6vD32Ks/VfPy2eUTDMD7Bk02q6NZKT4gvgNnMdFZA26W8H958eaUI Hv+0mwLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5jab-0000000E3bD-26XS; Tue, 29 Oct 2024 10:36:41 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5jN5-0000000E11C-3Bd7 for linux-arm-kernel@lists.infradead.org; Tue, 29 Oct 2024 10:22:45 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43161c0068bso50422705e9.1 for ; Tue, 29 Oct 2024 03:22:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730197362; x=1730802162; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iku2aazVoaifn2qwZ8do62mCbu6cZo7YQepKnixIbc4=; b=mK2QsuJd1oMgViBNvhGnYwEjbD6WESnkZFvQ2vXgItWYJGkIepipRuoYEhY45epAZJ VoomZu8bsdZOKh6Lk3auHykLML7KBCKRHOzAx5t7gzVOkcQNY5u41R52lBmvnJ2tEOcG pM6nW3Mr6/8K0lFyX1WxRhi8OF8uTs/3ppwJBs7ZGSmGGxpbVFu4/f+5TpWyFVInR6jE qNqCVxLYeZwRIe5SzVV8dbQ7bT10XbCqs3zMm3FLGsVD8SjeFqvd3XlJwYYvRyX9BZXt T3mnMw7pM6mRhGlHPnvbnffuJP9iqvQHKm5k/0NO5TEj3eGnC20JFNjKb54bnAZyEjfq B34w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730197362; x=1730802162; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iku2aazVoaifn2qwZ8do62mCbu6cZo7YQepKnixIbc4=; b=ZGNICIvs5r+d8FXd0YlMcBBCX4nogu05t5kTOVgmtLodYmfoVud4FRxlDX/5jeUCy2 GUZ4Qz4UmRFosXg+ZRJ10qGNEjD1zP4VprmAr27S+1yMjsEkIyZIa8slXM3ee/alZAea MaH4Lf0Bd42pjE3LyaKVbRsmYORRPAG/PyhDG8NDFp9eBz2bJ7BsdSmNfk0lYFKoq8yp Xgpxb5Lo1t4dTeQUBnbkU+jJCKNCGPIR0fVF1dQ2jkPPVxaFuiZF98eAGISNbC1MH85a vi27LpS2XFibIEkiApjkUuk15TTfA2Y++6EX4YlbOVARy9GVo7PXRjo9ib02XQ94Ni7W DUjA== X-Forwarded-Encrypted: i=1; AJvYcCWR5W8sxzpPnoCMh7OC9wmRNapmK9vpt4Gh8oP0csYhLvhd5Ke83NIMKs8dYbSgV0gOtQZtSuBKfFHiCk1SDf7W@lists.infradead.org X-Gm-Message-State: AOJu0YyIEQUot2z2pQgw3iNMHNMgGD4+C7mXhXUlj3d59xZIBLpS8VR8 Ph1qnJWPUXdXhcXa9Aamit58sY702ay9opAMfT3Hz7sdJ+eJTpdWVE9/+cx7XcY= X-Google-Smtp-Source: AGHT+IFJA0rf9yL1/4hL0/WSC0JKP3mxHD/OdeY53wfOUkq+NYJEyeFtfI5Od5uPy5TfvM1U2qN/+g== X-Received: by 2002:adf:e38c:0:b0:37d:47e2:5e30 with SMTP id ffacd0b85a97d-380611e715dmr8476087f8f.42.1730197362162; Tue, 29 Oct 2024 03:22:42 -0700 (PDT) Received: from tudordana.roam.corp.google.com ([79.115.63.43]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b47a86sm12084498f8f.53.2024.10.29.03.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 03:22:41 -0700 (PDT) From: Tudor Ambarus To: peng.fan@oss.nxp.com, m.felsch@pengutronix.de Cc: pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Peng Fan , Tudor Ambarus Subject: [RESEND PATCH v4 1/2] dt-bindings: mtd: jedec,spi-nor: add optional vcc-supply Date: Tue, 29 Oct 2024 10:22:37 +0000 Message-ID: <20241029102238.44673-1-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241029_032243_843107_8122B224 X-CRM114-Status: UNSURE ( 9.17 ) X-CRM114-Notice: Please train this message. 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 From: Peng Fan Introduce optional vcc-supply property, SPI NOR flashes needs power supply to work properly. The power supply maybe software controlable per board design. Acked-by: Rob Herring (Arm) Signed-off-by: Peng Fan Signed-off-by: Tudor Ambarus --- v4: no changes Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml index 6e3afb42926e..335f8204aa1e 100644 --- a/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml +++ b/Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml @@ -96,6 +96,10 @@ properties: If "broken-flash-reset" is present then having this property does not make any difference. + vcc-supply: + description: + Supply for the SPI NOR power. + spi-cpol: true spi-cpha: true From patchwork Tue Oct 29 10:22:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tudor Ambarus X-Patchwork-Id: 13854654 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 36DFDD2AB1C for ; Tue, 29 Oct 2024 10:38: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gevxWDiw1Joa8obRCekHXlX/q8pa3Bd8D6cgQBHwmVE=; b=2fdyGgGiBCzuBVFWYi01d1aD74 MW9CC7JlrvV6NFG44uYfsQZy9tVPEyvmQlET810wePVunuTNPiZIo52J0Z7OqY9YWfpEl8LE9mfmT 0aMQXHngNOf2X3zgZ0N76pGccY3vx7lqVgGyWoha0K8QU2/t13VpsbEOJANaJrQshH4DUy15Gj7ns Uq5r9NLA9y6u4hTJyrSm2ZHuDW9QjqP9GKVrChcDYw6zXTfF3qVtYig2XwO/fIj7baVCNxXZPl4VZ I7xGsabNfqMxlXptEJNJ6cyz81AqIaG88wnHZTmAMre33rloS7Nnsb8xYrXc8Dx/K2Pkhxb6s2xtP JCRhf6+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t5jcD-0000000E3ts-3QSr; Tue, 29 Oct 2024 10:38:21 +0000 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t5jN7-0000000E11j-40vB for linux-arm-kernel@lists.infradead.org; Tue, 29 Oct 2024 10:22:47 +0000 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2fb51f39394so52023391fa.2 for ; Tue, 29 Oct 2024 03:22:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730197364; x=1730802164; darn=lists.infradead.org; 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=gevxWDiw1Joa8obRCekHXlX/q8pa3Bd8D6cgQBHwmVE=; b=cSpKe4NJlxVe1bo9V7eMKwm+qGksa7Agb0GA7BDoWXXRE0c8DpI6tiqmanyQzu8mQL a0FbDki1iXA+Q5+KR/OG+ZGf/WLPADLpTT/1T6s/p4S1PRuaB5KuPt1myBHJnGvrZ6Eb IJMkiMmwTQhyVvHHK4LF0ffdmofwFq+mPUM+qMtT1+n81So2+nXoIjrXxfjmhcF3nrP6 aUxOq5b+KfzK+Vn4S7+fRi7xK1DKq6ktUlfaiw0vmfejOXxik9vMffK8zZNTqSKPGhBv 3GLI+UA4eMb76eEtvEHl1nZNnTMb3VXBvbMwNmAOvHMvku8QIczjSnCTOSdX0OSV0lUM r/0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730197364; x=1730802164; 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=gevxWDiw1Joa8obRCekHXlX/q8pa3Bd8D6cgQBHwmVE=; b=fCeeeSyIHoXS1TpJwEktsuzRc8TsxBXfl+9EZJ0Tt1g/HKMh1uT6QyCiUY5Xf/vViF Fo7dwW025QwUf69O8Y9qTzuhAAYb3neW/pVwrYAe/QTh6dEUAvoGCI+hH1tll3kWMqOQ HI/lN5k+eI/okH1r2S8fttc0xbujU2GLRJvt5bLeah0Sz1SLPV6yZ39ktLuWhtC0gPtq SQXXqus+UDqVGJla+bksqXUzb1wqlyOF3Jt0Z0ET0oj8RF8H87atgtCnKr4X35wPFuBW awVhZgadHpdd6dKeSzIzQnh05+FMTnirUuJRYjqeoG0emUhrxVq0oJ69G0aGrzI/bRgk h4eg== X-Forwarded-Encrypted: i=1; AJvYcCWrZwH6sqbwSKpN47THgrTHrGmV/SVBaQC1FTA3u4F+PYhuLGZ7dNL9PnyBYnfz8JqQaYjhKarEpuvslsDJtSUc@lists.infradead.org X-Gm-Message-State: AOJu0YwQO5UAgwA7x24CGaH8q8xZI1sRPy/l37ikh6g89dOUza9HY+k3 +0sfAvVRGAIxVHjIfLVizLUMwX8W7igHW0r1Tq96Bm8XHItlPch+2S/uJ6c+vFc= X-Google-Smtp-Source: AGHT+IFpXeHjBYJ4bh6c/28VpHHP35QvCnNGUuPqWzvC/md0zxhyDDRH72iKNBCLUTiNRx10pm7VKw== X-Received: by 2002:a05:651c:551:b0:2fa:e658:27a1 with SMTP id 38308e7fff4ca-2fcbdf68ff0mr50076231fa.5.1730197363921; Tue, 29 Oct 2024 03:22:43 -0700 (PDT) Received: from tudordana.roam.corp.google.com ([79.115.63.43]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b47a86sm12084498f8f.53.2024.10.29.03.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 03:22:43 -0700 (PDT) From: Tudor Ambarus To: peng.fan@oss.nxp.com, m.felsch@pengutronix.de Cc: pratyush@kernel.org, mwalle@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Peng Fan , Tudor Ambarus Subject: [RESEND PATCH v4 2/2] mtd: spi-nor: support vcc-supply regulator Date: Tue, 29 Oct 2024 10:22:38 +0000 Message-ID: <20241029102238.44673-2-tudor.ambarus@linaro.org> X-Mailer: git-send-email 2.47.0.163.g1226f6d8fa-goog In-Reply-To: <20241029102238.44673-1-tudor.ambarus@linaro.org> References: <20241029102238.44673-1-tudor.ambarus@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241029_032246_025371_EB871C34 X-CRM114-Status: GOOD ( 14.54 ) 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 From: Peng Fan SPI NOR flashes needs power supply to work properly. The power supply maybe software controllable per board design. So add the support for an vcc-supply regulator. Signed-off-by: Peng Fan Reviewed-by: Marco Felsch [ta: move devm_regulator_get_enable() to spi_nor_probe(). Add local dev variable to avoid dereferences.] Signed-off-by: Tudor Ambarus Reviewed-by: Pratyush Yadav --- v4: - move devm_regulator_get_enable() to spi_nor_probe(). - add local dev variable to avoid dereferences. drivers/mtd/spi-nor/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index b6f374ded390..29441f2bab5d 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -3576,7 +3577,8 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor) static int spi_nor_probe(struct spi_mem *spimem) { struct spi_device *spi = spimem->spi; - struct flash_platform_data *data = dev_get_platdata(&spi->dev); + struct device *dev = &spi->dev; + struct flash_platform_data *data = dev_get_platdata(dev); struct spi_nor *nor; /* * Enable all caps by default. The core will mask them after @@ -3586,12 +3588,16 @@ static int spi_nor_probe(struct spi_mem *spimem) char *flash_name; int ret; - nor = devm_kzalloc(&spi->dev, sizeof(*nor), GFP_KERNEL); + ret = devm_regulator_get_enable(dev, "vcc"); + if (ret) + return ret; + + nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL); if (!nor) return -ENOMEM; nor->spimem = spimem; - nor->dev = &spi->dev; + nor->dev = dev; spi_nor_set_flash_node(nor, spi->dev.of_node); spi_mem_set_drvdata(spimem, nor);