2 * Copyright (C) 2005, Broadcom Corporation
3 * Copyright (C) 2006, Felix Fietkau <nbd@openwrt.org>
4 * Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
12 #ifndef __BCM47XX_NVRAM_H
13 #define __BCM47XX_NVRAM_H
15 #include <linux/types.h>
16 #include <linux/kernel.h>
21 u32 crc_ver_init
; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
22 u32 config_refresh
; /* 0:15 sdram_config, 16:31 sdram_refresh */
23 u32 config_ncdl
; /* ncdl values for memc */
26 #define NVRAM_HEADER 0x48534C46 /* 'FLSH' */
27 #define NVRAM_VERSION 1
28 #define NVRAM_HEADER_SIZE 20
29 #define NVRAM_SPACE 0x8000
31 #define FLASH_MIN 0x00020000 /* Minimum flash size */
33 #define NVRAM_MAX_VALUE_LEN 255
34 #define NVRAM_MAX_PARAM_LEN 64
37 int bcm47xx_nvram_getenv(const char *name
, char *val
, size_t val_len
);
39 int bcm47xx_nvram_gpio_pin(const char *name
);
41 static inline int bcm47xx_nvram_getenv(const char *name
, char *val
,
47 static inline int bcm47xx_nvram_gpio_pin(const char *name
)
53 static inline void bcm47xx_nvram_parse_macaddr(char *buf
, u8 macaddr
[6])
56 sscanf(buf
, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr
[0],
57 &macaddr
[1], &macaddr
[2], &macaddr
[3], &macaddr
[4],
59 else if (strchr(buf
, '-'))
60 sscanf(buf
, "%hhx-%hhx-%hhx-%hhx-%hhx-%hhx", &macaddr
[0],
61 &macaddr
[1], &macaddr
[2], &macaddr
[3], &macaddr
[4],
64 pr_warn("Can not parse mac address: %s\n", buf
);
66 #endif /* __BCM47XX_NVRAM_H */