mtd: spi-nor: support vcc-supply regulator
authorPeng Fan <peng.fan@nxp.com>
Mon, 11 Nov 2024 11:19:46 +0000 (13:19 +0200)
committerPratyush Yadav <pratyush@kernel.org>
Fri, 6 Dec 2024 16:08:25 +0000 (16:08 +0000)
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 <peng.fan@nxp.com>
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
[ta: move devm_regulator_get_enable() to spi_nor_probe().]
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Reviewed-by: Pratyush Yadav <pratyush@kernel.org>
Signed-off-by: Pratyush Yadav <pratyush@kernel.org>
Link: https://lore.kernel.org/r/20241111111946.9048-3-tudor.ambarus@linaro.org
drivers/mtd/spi-nor/core.c

index 0b50293fc373460638d73eff66df2e53a14e6716..7ba89ffeaf2d0bcd1fe2cae4e5be4788c87967b4 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/mtd/spi-nor.h>
 #include <linux/mutex.h>
 #include <linux/of_platform.h>
+#include <linux/regulator/consumer.h>
 #include <linux/sched/task_stack.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
@@ -3587,6 +3588,10 @@ static int spi_nor_probe(struct spi_mem *spimem)
        char *flash_name;
        int ret;
 
+       ret = devm_regulator_get_enable(dev, "vcc");
+       if (ret)
+               return ret;
+
        nor = devm_kzalloc(dev, sizeof(*nor), GFP_KERNEL);
        if (!nor)
                return -ENOMEM;