diff options
Diffstat (limited to 'drivers/nvmem/starfive-otp.c')
-rw-r--r-- | drivers/nvmem/starfive-otp.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/nvmem/starfive-otp.c b/drivers/nvmem/starfive-otp.c index f9bf05ca87..47b94b1399 100644 --- a/drivers/nvmem/starfive-otp.c +++ b/drivers/nvmem/starfive-otp.c @@ -1,4 +1,4 @@ -// SPDX_License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2021 StarFive, Inc */ @@ -8,12 +8,12 @@ #include <malloc.h> #include <xfuncs.h> #include <errno.h> -#include <gpiod.h> +#include <linux/gpio/consumer.h> #include <init.h> #include <net.h> #include <io.h> #include <of.h> -#include <regmap.h> +#include <linux/regmap.h> #include <machine_id.h> #include <linux/reset.h> #include <linux/clk.h> @@ -87,7 +87,7 @@ */ struct starfive_otp { - int power_gpio; + struct gpio_desc *power_gpio; struct starfive_otp_regs __iomem *regs; }; @@ -112,7 +112,7 @@ static int starfive_otp_read(void *ctx, unsigned offset, unsigned *val) { struct starfive_otp *priv = ctx; - gpio_set_active(priv->power_gpio, true); + gpiod_set_value(priv->power_gpio, true); mdelay(10); //otp set to read mode @@ -122,7 +122,7 @@ static int starfive_otp_read(void *ctx, unsigned offset, unsigned *val) /* read all requested fuses */ *val = readl(&priv->regs->mem[offset / 4]); - gpio_set_active(priv->power_gpio, false); + gpiod_set_value(priv->power_gpio, false); mdelay(5); return 0; @@ -138,7 +138,7 @@ static struct regmap_bus starfive_otp_regmap_bus = { .reg_write = starfive_otp_write, }; -static int starfive_otp_probe(struct device_d *dev) +static int starfive_otp_probe(struct device *dev) { struct starfive_otp *priv; struct regmap_config config = {}; @@ -162,7 +162,7 @@ static int starfive_otp_probe(struct device_d *dev) if (IS_ERR(iores)) return PTR_ERR(iores); - ret = of_property_read_u32(dev->device_node, "fuse-count", &total_fuses); + ret = of_property_read_u32(dev->of_node, "fuse-count", &total_fuses); if (ret < 0) { dev_err(dev, "missing required fuse-count property\n"); return ret; @@ -172,14 +172,14 @@ static int starfive_otp_probe(struct device_d *dev) config.reg_bits = 32; config.val_bits = 32; config.reg_stride = 4; - config.max_register = total_fuses; + config.max_register = (total_fuses - 1) * config.reg_stride; priv = xzalloc(sizeof(*priv)); priv->regs = IOMEM(iores->start); priv->power_gpio = gpiod_get(dev, "power", GPIOD_OUT_LOW); - if (priv->power_gpio < 0) - return priv->power_gpio; + if (IS_ERR(priv->power_gpio)) + return PTR_ERR(priv->power_gpio); map = regmap_init(dev, &starfive_otp_regmap_bus, priv, &config); if (IS_ERR(map)) @@ -192,8 +192,9 @@ static struct of_device_id starfive_otp_dt_ids[] = { { .compatible = "starfive,fu740-otp" }, { /* sentinel */ } }; +MODULE_DEVICE_TABLE(of, starfive_otp_dt_ids); -static struct driver_d starfive_otp_driver = { +static struct driver starfive_otp_driver = { .name = "starfive_otp", .probe = starfive_otp_probe, .of_compatible = starfive_otp_dt_ids, |