bcm53xx: add support for the PCIe controller
[oweals/openwrt.git] / target / linux / bcm53xx / patches-3.14 / 111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
1 From 60a413ed5bc7917f1612df441240f458163b10c1 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 3 May 2014 22:54:59 +0200
4 Subject: [PATCH 03/15] bcm47xx-nvram: add new nvram driver with dt support
5
6 This adds a new nvrm driver which uses device tree to provide nvram
7 access to other drivers. You have to specify the memory ranges where
8 the flash chip is mapped and this driver will search there for some
9 nvram and parse it. Other drivers can use this driver to access the
10 device nvram. The nvram is used to store board configurations like the
11 mac address and also for configuration values in the vendor firmware.
12 ---
13  arch/mips/bcm47xx/board.c             |  36 +++---
14  arch/mips/bcm47xx/nvram.c             |   7 +-
15  arch/mips/bcm47xx/setup.c             |   4 +-
16  arch/mips/bcm47xx/sprom.c             |   4 +-
17  arch/mips/bcm47xx/time.c              |   2 +-
18  drivers/misc/Kconfig                  |   5 +
19  drivers/misc/Makefile                 |   1 +
20  drivers/misc/bcm47xx-nvram.c          | 211 ++++++++++++++++++++++++++++++++++
21  drivers/net/ethernet/broadcom/b44.c   |   2 +-
22  drivers/net/ethernet/broadcom/bgmac.c |   4 +-
23  drivers/ssb/driver_chipcommon_pmu.c   |   2 +-
24  include/linux/bcm47xx_nvram.h         |  16 ++-
25  12 files changed, 259 insertions(+), 35 deletions(-)
26  create mode 100644 drivers/misc/bcm47xx-nvram.c
27
28 --- a/arch/mips/bcm47xx/board.c
29 +++ b/arch/mips/bcm47xx/board.c
30 @@ -196,50 +196,50 @@ static __init const struct bcm47xx_board
31         const struct bcm47xx_board_type_list2 *e2;
32         const struct bcm47xx_board_type_list3 *e3;
33  
34 -       if (bcm47xx_nvram_getenv("model_name", buf1, sizeof(buf1)) >= 0) {
35 +       if (bcm47xx_nvram_getenv(NULL, "model_name", buf1, sizeof(buf1)) >= 0) {
36                 for (e1 = bcm47xx_board_list_model_name; e1->value1; e1++) {
37                         if (!strcmp(buf1, e1->value1))
38                                 return &e1->board;
39                 }
40         }
41  
42 -       if (bcm47xx_nvram_getenv("model_no", buf1, sizeof(buf1)) >= 0) {
43 +       if (bcm47xx_nvram_getenv(NULL, "model_no", buf1, sizeof(buf1)) >= 0) {
44                 for (e1 = bcm47xx_board_list_model_no; e1->value1; e1++) {
45                         if (strstarts(buf1, e1->value1))
46                                 return &e1->board;
47                 }
48         }
49  
50 -       if (bcm47xx_nvram_getenv("machine_name", buf1, sizeof(buf1)) >= 0) {
51 +       if (bcm47xx_nvram_getenv(NULL, "machine_name", buf1, sizeof(buf1)) >= 0) {
52                 for (e1 = bcm47xx_board_list_machine_name; e1->value1; e1++) {
53                         if (strstarts(buf1, e1->value1))
54                                 return &e1->board;
55                 }
56         }
57  
58 -       if (bcm47xx_nvram_getenv("hardware_version", buf1, sizeof(buf1)) >= 0) {
59 +       if (bcm47xx_nvram_getenv(NULL, "hardware_version", buf1, sizeof(buf1)) >= 0) {
60                 for (e1 = bcm47xx_board_list_hardware_version; e1->value1; e1++) {
61                         if (strstarts(buf1, e1->value1))
62                                 return &e1->board;
63                 }
64         }
65  
66 -       if (bcm47xx_nvram_getenv("productid", buf1, sizeof(buf1)) >= 0) {
67 +       if (bcm47xx_nvram_getenv(NULL, "productid", buf1, sizeof(buf1)) >= 0) {
68                 for (e1 = bcm47xx_board_list_productid; e1->value1; e1++) {
69                         if (!strcmp(buf1, e1->value1))
70                                 return &e1->board;
71                 }
72         }
73  
74 -       if (bcm47xx_nvram_getenv("ModelId", buf1, sizeof(buf1)) >= 0) {
75 +       if (bcm47xx_nvram_getenv(NULL, "ModelId", buf1, sizeof(buf1)) >= 0) {
76                 for (e1 = bcm47xx_board_list_ModelId; e1->value1; e1++) {
77                         if (!strcmp(buf1, e1->value1))
78                                 return &e1->board;
79                 }
80         }
81  
82 -       if (bcm47xx_nvram_getenv("melco_id", buf1, sizeof(buf1)) >= 0 ||
83 -           bcm47xx_nvram_getenv("buf1falo_id", buf1, sizeof(buf1)) >= 0) {
84 +       if (bcm47xx_nvram_getenv(NULL, "melco_id", buf1, sizeof(buf1)) >= 0 ||
85 +           bcm47xx_nvram_getenv(NULL, "buf1falo_id", buf1, sizeof(buf1)) >= 0) {
86                 /* buffalo hardware, check id for specific hardware matches */
87                 for (e1 = bcm47xx_board_list_melco_id; e1->value1; e1++) {
88                         if (!strcmp(buf1, e1->value1))
89 @@ -247,8 +247,8 @@ static __init const struct bcm47xx_board
90                 }
91         }
92  
93 -       if (bcm47xx_nvram_getenv("boot_hw_model", buf1, sizeof(buf1)) >= 0 &&
94 -           bcm47xx_nvram_getenv("boot_hw_ver", buf2, sizeof(buf2)) >= 0) {
95 +       if (bcm47xx_nvram_getenv(NULL, "boot_hw_model", buf1, sizeof(buf1)) >= 0 &&
96 +           bcm47xx_nvram_getenv(NULL, "boot_hw_ver", buf2, sizeof(buf2)) >= 0) {
97                 for (e2 = bcm47xx_board_list_boot_hw; e2->value1; e2++) {
98                         if (!strcmp(buf1, e2->value1) &&
99                             !strcmp(buf2, e2->value2))
100 @@ -256,16 +256,16 @@ static __init const struct bcm47xx_board
101                 }
102         }
103  
104 -       if (bcm47xx_nvram_getenv("board_id", buf1, sizeof(buf1)) >= 0) {
105 +       if (bcm47xx_nvram_getenv(NULL, "board_id", buf1, sizeof(buf1)) >= 0) {
106                 for (e1 = bcm47xx_board_list_board_id; e1->value1; e1++) {
107                         if (!strcmp(buf1, e1->value1))
108                                 return &e1->board;
109                 }
110         }
111  
112 -       if (bcm47xx_nvram_getenv("boardtype", buf1, sizeof(buf1)) >= 0 &&
113 -           bcm47xx_nvram_getenv("boardnum", buf2, sizeof(buf2)) >= 0 &&
114 -           bcm47xx_nvram_getenv("boardrev", buf3, sizeof(buf3)) >= 0) {
115 +       if (bcm47xx_nvram_getenv(NULL, "boardtype", buf1, sizeof(buf1)) >= 0 &&
116 +           bcm47xx_nvram_getenv(NULL, "boardnum", buf2, sizeof(buf2)) >= 0 &&
117 +           bcm47xx_nvram_getenv(NULL, "boardrev", buf3, sizeof(buf3)) >= 0) {
118                 for (e3 = bcm47xx_board_list_board; e3->value1; e3++) {
119                         if (!strcmp(buf1, e3->value1) &&
120                             !strcmp(buf2, e3->value2) &&
121 @@ -286,7 +286,7 @@ void __init bcm47xx_board_detect(void)
122                 return;
123  
124         /* check if the nvram is available */
125 -       err = bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf));
126 +       err = bcm47xx_nvram_getenv(NULL, "boardtype", buf, sizeof(buf));
127  
128         /* init of nvram failed, probably too early now */
129         if (err == -ENXIO) {
130 --- a/arch/mips/bcm47xx/nvram.c
131 +++ b/arch/mips/bcm47xx/nvram.c
132 @@ -158,7 +158,8 @@ static int nvram_init(void)
133         return -ENXIO;
134  }
135  
136 -int bcm47xx_nvram_getenv(char *name, char *val, size_t val_len)
137 +int bcm47xx_nvram_getenv(const struct device *dev, const char *name, char *val,
138 +                        size_t val_len)
139  {
140         char *var, *value, *end, *eq;
141         int err;
142 @@ -190,7 +191,7 @@ int bcm47xx_nvram_getenv(char *name, cha
143  }
144  EXPORT_SYMBOL(bcm47xx_nvram_getenv);
145  
146 -int bcm47xx_nvram_gpio_pin(const char *name)
147 +int bcm47xx_nvram_gpio_pin(const struct device *dev, const char *name)
148  {
149         int i, err;
150         char nvram_var[10];
151 @@ -200,7 +201,7 @@ int bcm47xx_nvram_gpio_pin(const char *n
152                 err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
153                 if (err <= 0)
154                         continue;
155 -               err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
156 +               err = bcm47xx_nvram_getenv(dev, nvram_var, buf, sizeof(buf));
157                 if (err <= 0)
158                         continue;
159                 if (!strcmp(name, buf))
160 --- a/arch/mips/bcm47xx/setup.c
161 +++ b/arch/mips/bcm47xx/setup.c
162 @@ -123,7 +123,7 @@ static int bcm47xx_get_invariants(struct
163         memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
164         bcm47xx_fill_sprom(&iv->sprom, NULL, false);
165  
166 -       if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
167 +       if (bcm47xx_nvram_getenv(NULL, "cardbus", buf, sizeof(buf)) >= 0)
168                 iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
169  
170         return 0;
171 @@ -146,7 +146,7 @@ static void __init bcm47xx_register_ssb(
172                 panic("Failed to initialize SSB bus (err %d)", err);
173  
174         mcore = &bcm47xx_bus.ssb.mipscore;
175 -       if (bcm47xx_nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
176 +       if (bcm47xx_nvram_getenv(NULL, "kernel_args", buf, sizeof(buf)) >= 0) {
177                 if (strstr(buf, "console=ttyS1")) {
178                         struct ssb_serial_port port;
179  
180 --- a/arch/mips/bcm47xx/sprom.c
181 +++ b/arch/mips/bcm47xx/sprom.c
182 @@ -50,10 +50,10 @@ static int get_nvram_var(const char *pre
183  
184         create_key(prefix, postfix, name, key, sizeof(key));
185  
186 -       err = bcm47xx_nvram_getenv(key, buf, len);
187 +       err = bcm47xx_nvram_getenv(NULL, key, buf, len);
188         if (fallback && err == -ENOENT && prefix) {
189                 create_key(NULL, postfix, name, key, sizeof(key));
190 -               err = bcm47xx_nvram_getenv(key, buf, len);
191 +               err = bcm47xx_nvram_getenv(NULL, key, buf, len);
192         }
193         return err;
194  }
195 --- a/arch/mips/bcm47xx/time.c
196 +++ b/arch/mips/bcm47xx/time.c
197 @@ -61,7 +61,7 @@ void __init plat_time_init(void)
198         }
199  
200         if (chip_id == 0x5354) {
201 -               len = bcm47xx_nvram_getenv("clkfreq", buf, sizeof(buf));
202 +               len = bcm47xx_nvram_getenv(NULL, "clkfreq", buf, sizeof(buf));
203                 if (len >= 0 && !strncmp(buf, "200", 4))
204                         hz = 100000000;
205         }
206 --- a/drivers/misc/Kconfig
207 +++ b/drivers/misc/Kconfig
208 @@ -515,6 +515,11 @@ config SRAM
209           the genalloc API. It is supposed to be used for small on-chip SRAM
210           areas found on many SoCs.
211  
212 +config BCM47XX_NVRAM
213 +       tristate "BCM47XX nvram driver"
214 +       help
215 +               This adds support for the brcm47xx nvram driver.
216 +
217  source "drivers/misc/c2port/Kconfig"
218  source "drivers/misc/eeprom/Kconfig"
219  source "drivers/misc/cb710/Kconfig"
220 --- a/drivers/misc/Makefile
221 +++ b/drivers/misc/Makefile
222 @@ -54,3 +54,4 @@ obj-$(CONFIG_LATTICE_ECP3_CONFIG)     += lat
223  obj-$(CONFIG_SRAM)             += sram.o
224  obj-y                          += mic/
225  obj-$(CONFIG_GENWQE)           += genwqe/
226 +obj-$(CONFIG_BCM47XX_NVRAM)    += bcm47xx-nvram.o
227 --- /dev/null
228 +++ b/drivers/misc/bcm47xx-nvram.c
229 @@ -0,0 +1,211 @@
230 +/*
231 + * BCM947xx nvram variable access
232 + *
233 + * Copyright (C) 2005 Broadcom Corporation
234 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
235 + * Copyright (C) 2010-2014 Hauke Mehrtens <hauke@hauke-m.de>
236 + *
237 + * This program is free software; you can redistribute it and/or modify it
238 + * under  the terms of the GNU General  Public License as published by the
239 + * Free Software Foundation;  either version 2 of the  License, or (at your
240 + * option) any later version.
241 + */
242 +
243 +#include <linux/types.h>
244 +#include <linux/module.h>
245 +#include <linux/kernel.h>
246 +#include <linux/string.h>
247 +#include <linux/of_address.h>
248 +#include <linux/device.h>
249 +#include <linux/platform_device.h>
250 +#include <linux/io.h>
251 +#include <linux/bcm47xx_nvram.h>
252 +
253 +struct bcm47xx_nvram {
254 +       size_t nvram_len;
255 +       char *nvram_buf;
256 +};
257 +
258 +static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
259 +
260 +static u32 find_nvram_size(void __iomem *end)
261 +{
262 +       struct nvram_header *header;
263 +       int i;
264 +
265 +       for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
266 +               header = (struct nvram_header *)(end - nvram_sizes[i]);
267 +               if (header->magic == NVRAM_HEADER)
268 +                       return nvram_sizes[i];
269 +       }
270 +
271 +       return 0;
272 +}
273 +
274 +/* Probe for NVRAM header */
275 +static int nvram_find_and_copy(struct device *dev, void __iomem *base,
276 +                              size_t len, char **nvram_buf,
277 +                              size_t *nvram_len)
278 +{
279 +       struct nvram_header *header;
280 +       int i;
281 +       u32 off;
282 +       u32 *src, *dst;
283 +       u32 size;
284 +
285 +       /* TODO: when nvram is on nand flash check for bad blocks first. */
286 +       off = FLASH_MIN;
287 +       while (off <= len) {
288 +               /* Windowed flash access */
289 +               size = find_nvram_size(base + off);
290 +               if (size) {
291 +                       header = (struct nvram_header *)(base + off - size);
292 +                       goto found;
293 +               }
294 +               off <<= 1;
295 +       }
296 +
297 +       /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
298 +       header = (struct nvram_header *)(base + 4096);
299 +       if (header->magic == NVRAM_HEADER) {
300 +               size = NVRAM_SPACE;
301 +               goto found;
302 +       }
303 +
304 +       header = (struct nvram_header *)(base + 1024);
305 +       if (header->magic == NVRAM_HEADER) {
306 +               size = NVRAM_SPACE;
307 +               goto found;
308 +       }
309 +
310 +       *nvram_buf = NULL;
311 +       *nvram_len = 0;
312 +       pr_err("no nvram found\n");
313 +       return -ENXIO;
314 +
315 +found:
316 +       if (header->len > size)
317 +               pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
318 +       *nvram_len = min_t(u32, header->len, size);
319 +
320 +       *nvram_buf = devm_kzalloc(dev, *nvram_len, GFP_KERNEL);
321 +       if (!*nvram_buf)
322 +               return -ENOMEM;
323 +
324 +       src = (u32 *) header;
325 +       dst = (u32 *) *nvram_buf;
326 +       for (i = 0; i < sizeof(struct nvram_header); i += 4)
327 +               *dst++ = *src++;
328 +       for (; i < *nvram_len; i += 4)
329 +               *dst++ = le32_to_cpu(*src++);
330 +
331 +       return 0;
332 +}
333 +
334 +int bcm47xx_nvram_getenv(const struct device *dev, const char *name, char *val, size_t val_len)
335 +{
336 +       char *var, *value, *end, *eq;
337 +       struct bcm47xx_nvram *nvram;
338 +
339 +       if (!dev)
340 +               return -ENODEV;
341 +
342 +       nvram = dev_get_drvdata(dev);
343 +
344 +       if (!name || !nvram || !nvram->nvram_len)
345 +               return -EINVAL;
346 +
347 +       /* Look for name=value and return value */
348 +       var = nvram->nvram_buf + sizeof(struct nvram_header);
349 +       end = nvram->nvram_buf + nvram->nvram_len - 2;
350 +       end[0] = end[1] = '\0';
351 +       for (; *var; var = value + strlen(value) + 1) {
352 +               eq = strchr(var, '=');
353 +               if (!eq)
354 +                       break;
355 +               value = eq + 1;
356 +               if ((eq - var) == strlen(name) &&
357 +                       strncmp(var, name, (eq - var)) == 0) {
358 +                       return snprintf(val, val_len, "%s", value);
359 +               }
360 +       }
361 +       return -ENOENT;
362 +}
363 +EXPORT_SYMBOL(bcm47xx_nvram_getenv);
364 +
365 +int bcm47xx_nvram_gpio_pin(const struct device *dev, const char *name)
366 +{
367 +       int i, err;
368 +       char nvram_var[10];
369 +       char buf[30];
370 +
371 +       if (!dev)
372 +               return -ENODEV;
373 +
374 +       for (i = 0; i < 32; i++) {
375 +               err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
376 +               if (err <= 0)
377 +                       continue;
378 +               err = bcm47xx_nvram_getenv(dev, nvram_var, buf, sizeof(buf));
379 +               if (err <= 0)
380 +                       continue;
381 +               if (!strcmp(name, buf))
382 +                       return i;
383 +       }
384 +       return -ENOENT;
385 +}
386 +EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
387 +
388 +static int bcm47xx_nvram_probe(struct platform_device *pdev)
389 +{
390 +       struct device *dev = &pdev->dev;
391 +       struct device_node *np = dev->of_node;
392 +       struct bcm47xx_nvram *nvram;
393 +       int err;
394 +       struct resource flash_mem;
395 +       void __iomem *mmio;
396 +
397 +       /* Alloc */
398 +       nvram = devm_kzalloc(dev, sizeof(*nvram), GFP_KERNEL);
399 +       if (!nvram)
400 +               return -ENOMEM;
401 +
402 +       err = of_address_to_resource(np, 0, &flash_mem);
403 +       if (err)
404 +               return err;
405 +
406 +       mmio = ioremap_nocache(flash_mem.start, resource_size(&flash_mem));
407 +       if (!mmio)
408 +               return -ENOMEM;
409 +
410 +       err = nvram_find_and_copy(dev, mmio, resource_size(&flash_mem), &nvram->nvram_buf, &nvram->nvram_len);
411 +       if (err)
412 +               goto err_unmap_mmio;
413 +
414 +       platform_set_drvdata(pdev, nvram);
415 +
416 +err_unmap_mmio:
417 +       iounmap(mmio);
418 +       return err;
419 +}
420 +
421 +static const struct of_device_id bcm47xx_nvram_of_match_table[] = {
422 +       { .compatible = "brcm,bcm47xx-nvram", },
423 +       {},
424 +};
425 +MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
426 +
427 +static struct platform_driver bcm47xx_nvram_driver = {
428 +       .driver = {
429 +               .owner = THIS_MODULE,
430 +               .name = "bcm47xx-nvram",
431 +               .of_match_table = bcm47xx_nvram_of_match_table,
432 +               /* driver unloading/unbinding currently not supported */
433 +               .suppress_bind_attrs = true,
434 +       },
435 +       .probe = bcm47xx_nvram_probe,
436 +};
437 +module_platform_driver(bcm47xx_nvram_driver);
438 +
439 +MODULE_AUTHOR("Hauke Mehrtens <hauke@hauke-m.de>");
440 +MODULE_LICENSE("GPLv2");
441 --- a/drivers/net/ethernet/broadcom/b44.c
442 +++ b/drivers/net/ethernet/broadcom/b44.c
443 @@ -411,7 +411,7 @@ static void b44_wap54g10_workaround(stru
444          * see https://dev.openwrt.org/ticket/146
445          * check and reset bit "isolate"
446          */
447 -       if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) < 0)
448 +       if (bcm47xx_nvram_getenv(NULL, "boardnum", buf, sizeof(buf)) < 0)
449                 return;
450         if (simple_strtoul(buf, NULL, 0) == 2) {
451                 err = __b44_readphy(bp, 0, MII_BMCR, &val);
452 --- a/drivers/net/ethernet/broadcom/bgmac.c
453 +++ b/drivers/net/ethernet/broadcom/bgmac.c
454 @@ -974,7 +974,7 @@ static void bgmac_chip_reset(struct bgma
455                              BGMAC_CHIPCTL_1_IF_TYPE_MII;
456                 char buf[4];
457  
458 -               if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
459 +               if (bcm47xx_nvram_getenv(NULL, "et_swtype", buf, sizeof(buf)) > 0) {
460                         if (kstrtou8(buf, 0, &et_swtype))
461                                 bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
462                                           buf);
463 @@ -1534,7 +1534,7 @@ static int bgmac_probe(struct bcma_devic
464         }
465  
466         bgmac->int_mask = BGMAC_IS_ERRMASK | BGMAC_IS_RX | BGMAC_IS_TX_MASK;
467 -       if (bcm47xx_nvram_getenv("et0_no_txint", NULL, 0) == 0)
468 +       if (bcm47xx_nvram_getenv(NULL, "et0_no_txint", NULL, 0) == 0)
469                 bgmac->int_mask &= ~BGMAC_IS_TX_MASK;
470  
471         /* TODO: reset the external phy. Specs are needed */
472 --- a/drivers/ssb/driver_chipcommon_pmu.c
473 +++ b/drivers/ssb/driver_chipcommon_pmu.c
474 @@ -319,7 +319,7 @@ static void ssb_pmu_pll_init(struct ssb_
475  
476         if (bus->bustype == SSB_BUSTYPE_SSB) {
477                 char buf[20];
478 -               if (bcm47xx_nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
479 +               if (bcm47xx_nvram_getenv(NULL, "xtalfreq", buf, sizeof(buf)) >= 0)
480                         crystalfreq = simple_strtoul(buf, NULL, 0);
481         }
482  
483 --- a/include/linux/bcm47xx_nvram.h
484 +++ b/include/linux/bcm47xx_nvram.h
485 @@ -15,6 +15,8 @@
486  #include <linux/types.h>
487  #include <linux/kernel.h>
488  
489 +struct device;
490 +
491  struct nvram_header {
492         u32 magic;
493         u32 len;
494 @@ -33,17 +35,21 @@ struct nvram_header {
495  #define NVRAM_MAX_VALUE_LEN 255
496  #define NVRAM_MAX_PARAM_LEN 64
497  
498 -#ifdef CONFIG_BCM47XX
499 -int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
500 +#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM47XX_NVRAM)
501 +int bcm47xx_nvram_getenv(const struct device *dev, const char *name, char *val,
502 +                        size_t val_len);
503  
504 -int bcm47xx_nvram_gpio_pin(const char *name);
505 +int bcm47xx_nvram_gpio_pin(const struct device *dev, const char *name);
506  #else
507 -static inline int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
508 +static inline int bcm47xx_nvram_getenv(const struct device *dev,
509 +                                      const char *name, char *val,
510 +                                      size_t val_len)
511  {
512         return -ENXIO;
513  }
514  
515 -static inline int bcm47xx_nvram_gpio_pin(const char *name)
516 +static inline int bcm47xx_nvram_gpio_pin(const struct device *dev,
517 +                                        const char *name)
518  {
519         return -ENXIO;
520  }