Merge Official Source
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
commit
73eac7e437
2
Makefile
2
Makefile
@ -14,7 +14,7 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir
|
||||
|
||||
world:
|
||||
|
||||
DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep '/usr' -m 1)
|
||||
DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -e '/usr' -e '/nix/store' -m 1)
|
||||
|
||||
export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
|
||||
export PATH:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host/bin),$(TOPDIR)/staging_dir/host/bin):$(PATH)
|
||||
|
||||
@ -26,6 +26,14 @@ menu "Global build settings"
|
||||
directory containing machine readable list of built profiles
|
||||
and resulting images.
|
||||
|
||||
config JSON_CYCLONEDX_SBOM
|
||||
bool "Create CycloneDX SBOM JSON"
|
||||
default BUILDBOT
|
||||
help
|
||||
Create a JSON files *.bom.cdx.json in the build
|
||||
directory containing Software Bill Of Materials in CycloneDX
|
||||
format.
|
||||
|
||||
config ALL_NONSHARED
|
||||
bool "Select all target specific packages by default"
|
||||
select ALL_KMODS
|
||||
|
||||
@ -277,6 +277,11 @@ endef
|
||||
define Image/Manifest
|
||||
$(call opkg,$(TARGET_DIR_ORIG)) list-installed > \
|
||||
$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest
|
||||
$(if $(CONFIG_JSON_CYCLONEDX_SBOM), \
|
||||
$(SCRIPT_DIR)/package-metadata.pl imgcyclonedxsbom \
|
||||
$(TMP_DIR)/.packageinfo \
|
||||
$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).manifest > \
|
||||
$(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED)).bom.cdx.json)
|
||||
endef
|
||||
|
||||
define Image/gzip-ext4-padded-squashfs
|
||||
|
||||
@ -36,6 +36,8 @@ $(if $(USERID),Require-User: $(USERID)
|
||||
)Source: $(PKG_SOURCE)
|
||||
$(if $(LICENSE),License: $(LICENSE)
|
||||
)$(if $(LICENSE_FILES),LicenseFiles: $(LICENSE_FILES)
|
||||
)$(if $(PKG_CPE_ID),CPE-ID: $(PKG_CPE_ID)
|
||||
)$(if $(ABI_VERSION),ABI-Version: $(ABI_VERSION)
|
||||
)Type: $(if $(Package/$(1)/targets),$(Package/$(1)/targets),$(if $(PKG_TARGETS),$(PKG_TARGETS),ipkg))
|
||||
$(if $(KCONFIG),Kernel-Config: $(KCONFIG)
|
||||
)$(if $(BUILDONLY),Build-Only: $(BUILDONLY)
|
||||
|
||||
@ -106,6 +106,14 @@ ifdef CONFIG_SIGNED_PACKAGES
|
||||
$(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
|
||||
); done
|
||||
endif
|
||||
ifdef CONFIG_JSON_CYCLONEDX_SBOM
|
||||
@echo Creating CycloneDX package SBOMs...
|
||||
@for d in $(PACKAGE_SUBDIRS); do ( \
|
||||
[ -d $$d ] && \
|
||||
cd $$d || continue; \
|
||||
$(SCRIPT_DIR)/package-metadata.pl pkgcyclonedxsbom Packages.manifest > Packages.bom.cdx.json || true; \
|
||||
); done
|
||||
endif
|
||||
|
||||
$(curdir)/flags-install:= -j1
|
||||
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
From 41f225dae30ea6ddcff10f120a9e732f994d3a07 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Nicol=C3=B2=20Veronese?= <nicveronese@gmail.com>
|
||||
Date: Tue, 3 Oct 2023 23:46:52 +0200
|
||||
Subject: [PATCH] spi: mtk_spim: prevent global pll clock override
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
With commit 793e6230118032a099ec42a1ea67f434721edcc0
|
||||
a new system to calculate the SPI clocks has been added.
|
||||
|
||||
Unfortunately, the do_div macro overrides the global
|
||||
priv->pll_clk_rate field. This will cause to have a reduced
|
||||
clock rate on each subsequent SPI call.
|
||||
|
||||
Signed-off-by: Valerio 'ftp21' Mancini <ftp21@ftp21.eu>
|
||||
Signed-off-by: Nicolò Veronese <nicveronese@gmail.com>
|
||||
---
|
||||
drivers/spi/mtk_spim.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/spi/mtk_spim.c
|
||||
+++ b/drivers/spi/mtk_spim.c
|
||||
@@ -409,7 +409,7 @@ static int mtk_spim_transfer_wait(struct
|
||||
{
|
||||
struct udevice *bus = dev_get_parent(slave->dev);
|
||||
struct mtk_spim_priv *priv = dev_get_priv(bus);
|
||||
- u32 sck_l, sck_h, clk_count, reg;
|
||||
+ u32 pll_clk, sck_l, sck_h, clk_count, reg;
|
||||
ulong us = 1;
|
||||
int ret = 0;
|
||||
|
||||
@@ -418,11 +418,12 @@ static int mtk_spim_transfer_wait(struct
|
||||
else
|
||||
clk_count = op->data.nbytes;
|
||||
|
||||
+ pll_clk = priv->pll_clk_rate;
|
||||
sck_l = readl(priv->base + SPI_CFG2_REG) >> SPI_CFG2_SCK_LOW_OFFSET;
|
||||
sck_h = readl(priv->base + SPI_CFG2_REG) & SPI_CFG2_SCK_HIGH_MASK;
|
||||
- do_div(priv->pll_clk_rate, sck_l + sck_h + 2);
|
||||
+ do_div(pll_clk, sck_l + sck_h + 2);
|
||||
|
||||
- us = CLK_TO_US(priv->pll_clk_rate, clk_count * 8);
|
||||
+ us = CLK_TO_US(pll_clk, clk_count * 8);
|
||||
us += 1000 * 1000; /* 1s tolerance */
|
||||
|
||||
if (us > UINT_MAX)
|
||||
@ -9,9 +9,9 @@ PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/firewall4.git
|
||||
PKG_SOURCE_DATE:=2023-03-23
|
||||
PKG_SOURCE_VERSION:=04a06bd70b9808b14444cae81a2faba4708ee231
|
||||
PKG_MIRROR_HASH:=37c34facb733c50d0fdbfa238765a23e667e4daaae9728aaccbaba87a2a07bb9
|
||||
PKG_SOURCE_DATE:=2023-09-01
|
||||
PKG_SOURCE_VERSION:=598d9fbb5179667aa0c525040eaa41bc7f2dc015
|
||||
PKG_MIRROR_HASH:=038b5b5611425e3c0fcc3ef4a0aea37296733300766d787909a689d16d4f39b4
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_LICENSE:=ISC
|
||||
|
||||
|
||||
@ -0,0 +1,62 @@
|
||||
From: David Bauer <mail@david-bauer.net>
|
||||
To: hostap@lists.infradead.org
|
||||
Cc: =?utf-8?q?=C3=89tienne_Morice?= <neon.emorice@mail.com>
|
||||
Subject: [PATCH] nl80211: add extra-ies only if allowed by driver
|
||||
Date: Sun, 30 Jan 2022 20:22:00 +0100
|
||||
Message-Id: <20220130192200.10883-1-mail@david-bauer.net>
|
||||
List-Id: <hostap.lists.infradead.org>
|
||||
|
||||
Upgrading wpa_supplicant from 2.9 to 2.10 breaks broadcom-wl
|
||||
based adapters. The reason for it is hostapd tries to install additional
|
||||
IEs for scanning while the driver does not support this.
|
||||
|
||||
The kernel indicates the maximum number of bytes for additional scan IEs
|
||||
using the NL80211_ATTR_MAX_SCAN_IE_LEN attribute. Save this value and
|
||||
only add additional scan IEs in case the driver can accommodate these
|
||||
additional IEs.
|
||||
|
||||
Reported-by: Étienne Morice <neon.emorice@mail.com>
|
||||
Tested-by: Étienne Morice <neon.emorice@mail.com>
|
||||
Signed-off-by: David Bauer <mail@david-bauer.net>
|
||||
---
|
||||
src/drivers/driver.h | 3 +++
|
||||
src/drivers/driver_nl80211_capa.c | 4 ++++
|
||||
src/drivers/driver_nl80211_scan.c | 2 +-
|
||||
3 files changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/src/drivers/driver.h
|
||||
+++ b/src/drivers/driver.h
|
||||
@@ -2283,6 +2283,9 @@ struct wpa_driver_capa {
|
||||
/** Maximum number of iterations in a single scan plan */
|
||||
u32 max_sched_scan_plan_iterations;
|
||||
|
||||
+ /** Maximum number of extra IE bytes for scans */
|
||||
+ u16 max_scan_ie_len;
|
||||
+
|
||||
/** Whether sched_scan (offloaded scanning) is supported */
|
||||
int sched_scan_supported;
|
||||
|
||||
--- a/src/drivers/driver_nl80211_capa.c
|
||||
+++ b/src/drivers/driver_nl80211_capa.c
|
||||
@@ -949,6 +949,10 @@ static int wiphy_info_handler(struct nl_
|
||||
nla_get_u32(tb[NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS]);
|
||||
}
|
||||
|
||||
+ if (tb[NL80211_ATTR_MAX_SCAN_IE_LEN])
|
||||
+ capa->max_scan_ie_len =
|
||||
+ nla_get_u16(tb[NL80211_ATTR_MAX_SCAN_IE_LEN]);
|
||||
+
|
||||
if (tb[NL80211_ATTR_MAX_MATCH_SETS])
|
||||
capa->max_match_sets =
|
||||
nla_get_u8(tb[NL80211_ATTR_MAX_MATCH_SETS]);
|
||||
--- a/src/drivers/driver_nl80211_scan.c
|
||||
+++ b/src/drivers/driver_nl80211_scan.c
|
||||
@@ -222,7 +222,7 @@ nl80211_scan_common(struct i802_bss *bss
|
||||
wpa_printf(MSG_DEBUG, "nl80211: Passive scan requested");
|
||||
}
|
||||
|
||||
- if (params->extra_ies) {
|
||||
+ if (params->extra_ies && drv->capa.max_scan_ie_len >= params->extra_ies_len) {
|
||||
wpa_hexdump(MSG_MSGDUMP, "nl80211: Scan extra IEs",
|
||||
params->extra_ies, params->extra_ies_len);
|
||||
if (nla_put(msg, NL80211_ATTR_IE, params->extra_ies_len,
|
||||
@ -12,9 +12,9 @@ PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcpd.git
|
||||
PKG_MIRROR_HASH:=e2e00e2bb6b7bacda5dcb713e4f9a4b1e316d75b140a4aa77145471bf6fe5c17
|
||||
PKG_SOURCE_DATE:=2023-06-24
|
||||
PKG_SOURCE_VERSION:=52112643308bb02a3b4fa2894dd7d4340ba4a237
|
||||
PKG_MIRROR_HASH:=9936331b64880260cf969cc5656e1e1a8b7dc0e0843d64621242c500a330b4d6
|
||||
PKG_SOURCE_DATE:=2023-10-24
|
||||
PKG_SOURCE_VERSION:=d8118f6e76e5519881f9a37137c3a06b3cb60fd2
|
||||
|
||||
PKG_MAINTAINER:=Hans Dedecker <dedeckeh@gmail.com>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
@ -12,21 +12,31 @@ PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=https://github.com/jow-/ucode.git
|
||||
PKG_SOURCE_DATE:=2023-06-06
|
||||
PKG_SOURCE_VERSION:=c7d84aae09691a99ae3db427c0b2463732ef84f4
|
||||
PKG_MIRROR_HASH:=38826ae70d886d1d7ada3fc6591ac807169aa28107f60f7f2e617520083525fb
|
||||
PKG_SOURCE_DATE:=2023-11-02
|
||||
PKG_SOURCE_VERSION:=cfb24ea4f12131dcefe4f1ede2f51d3d16b88dec
|
||||
PKG_MIRROR_HASH:=f515a23ab438f92be5788c42b9f614a82e670de2df1c01cd63143cdc77fa24fe
|
||||
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
|
||||
PKG_LICENSE:=ISC
|
||||
|
||||
PKG_ABI_VERSION:=20220812
|
||||
PKG_ABI_VERSION:=20230711
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
CMAKE_OPTIONS += -DSOVERSION=$(PKG_ABI_VERSION)
|
||||
|
||||
ifeq ($(HOST_OS),Darwin)
|
||||
CMAKE_HOST_OPTIONS += \
|
||||
-DCMAKE_SKIP_RPATH=FALSE \
|
||||
-DCMAKE_MACOSX_RPATH=1 \
|
||||
-DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOSTPKG}/lib"
|
||||
else
|
||||
CMAKE_HOST_OPTIONS += \
|
||||
-DSOVERSION=$(PKG_ABI_VERSION)
|
||||
endif
|
||||
|
||||
CMAKE_HOST_OPTIONS += \
|
||||
-DSOVERSION=$(PKG_ABI_VERSION) \
|
||||
-DFS_SUPPORT=ON \
|
||||
-DMATH_SUPPORT=ON \
|
||||
-DNL80211_SUPPORT=OFF \
|
||||
@ -35,7 +45,9 @@ CMAKE_HOST_OPTIONS += \
|
||||
-DSTRUCT_SUPPORT=ON \
|
||||
-DUBUS_SUPPORT=OFF \
|
||||
-DUCI_SUPPORT=OFF \
|
||||
-DULOOP_SUPPORT=OFF
|
||||
-DULOOP_SUPPORT=OFF \
|
||||
-DDEBUG_SUPPORT=ON \
|
||||
-DLOG_SUPPORT=OFF
|
||||
|
||||
|
||||
define Package/ucode/default
|
||||
@ -70,105 +82,29 @@ define Package/libucode/description
|
||||
The libucode package provides the shared runtime library for the ucode interpreter.
|
||||
endef
|
||||
|
||||
# 1: name
|
||||
# 2: cmake symbol
|
||||
# 3: depends
|
||||
# 4: description
|
||||
define UcodeModule
|
||||
UCODE_MODULES += ucode-mod-$(strip $(1))
|
||||
CMAKE_OPTIONS += -D$(strip $(2))=$(if $(CONFIG_PACKAGE_ucode-mod-$(strip $(1))),ON,OFF)
|
||||
PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_ucode-mod-$(strip $(1))
|
||||
|
||||
define Package/ucode-mod-fs
|
||||
define Package/ucode-mod-$(strip $(1))
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (filesystem module)
|
||||
DEPENDS:=ucode
|
||||
endef
|
||||
TITLE+= ($(strip $(1)) module)
|
||||
DEPENDS:=ucode $(3)
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-fs/description
|
||||
The filesystem plugin module allows interaction with the local file system.
|
||||
endef
|
||||
define Package/ucode-mod-$(strip $(1))/description
|
||||
$(strip $(4))
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-math
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (math module)
|
||||
DEPENDS:=ucode
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-math/description
|
||||
The math plugin provides access to various <math.h> procedures.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-nl80211
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (nl80211 module)
|
||||
DEPENDS:=ucode +libnl-tiny +libubox
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-nl80211/description
|
||||
The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-resolv
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (resolv module)
|
||||
DEPENDS:=ucode
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-resolv/description
|
||||
The resolv plugin implements simple DNS resolving.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-rtnl
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (rtnl module)
|
||||
DEPENDS:=ucode +libnl-tiny +libubox
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-rtnl/description
|
||||
The rtnl plugin provides access to the Linux routing netlink API.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-struct
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (struct module)
|
||||
DEPENDS:=ucode
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-struct/description
|
||||
The struct plugin implements Python 3 compatible struct.pack/unpack functionality.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-ubus
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (ubus module)
|
||||
DEPENDS:=ucode +libubus +libblobmsg-json
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-ubus/description
|
||||
The ubus module allows ucode template scripts to enumerate and invoke ubus
|
||||
procedures.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-uci
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (uci module)
|
||||
DEPENDS:=ucode +libuci
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-uci/description
|
||||
The uci module allows templates to read and modify uci configuration.
|
||||
endef
|
||||
|
||||
|
||||
define Package/ucode-mod-uloop
|
||||
$(Package/ucode/default)
|
||||
TITLE+= (uloop module)
|
||||
DEPENDS:=ucode +libubox
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-uloop/description
|
||||
The uloop module allows ucode scripts to interact with OpenWrt uloop event
|
||||
loop implementation.
|
||||
define Package/ucode-mod-$(strip $(1))/install
|
||||
$(INSTALL_DIR) $$(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/$(strip $(1)).so $$(1)/usr/lib/ucode/
|
||||
endef
|
||||
endef
|
||||
|
||||
|
||||
@ -189,60 +125,55 @@ define Package/libucode/install
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libucode.so.* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-fs/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/fs.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
|
||||
define Package/ucode-mod-math/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/math.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
debug, DEBUG_SUPPORT, +libubox +libucode, \
|
||||
The debug plugin module provides runtime debugging and introspection facilities.))
|
||||
|
||||
define Package/ucode-mod-nl80211/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/nl80211.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
fs, FS_SUPPORT, , \
|
||||
The filesystem plugin module allows interaction with the local file system.))
|
||||
|
||||
define Package/ucode-mod-resolv/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/resolv.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
log, LOG_SUPPORT, +libubox, \
|
||||
The log plugin module provides access to the syslog and libubox ulog APIs.))
|
||||
|
||||
define Package/ucode-mod-rtnl/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/rtnl.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
math, MATH_SUPPORT, , \
|
||||
The math plugin provides access to various <math.h> procedures.))
|
||||
|
||||
define Package/ucode-mod-struct/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/struct.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
nl80211, NL80211_SUPPORT, +libnl-tiny +libubox, \
|
||||
The nl80211 plugin provides access to the Linux wireless 802.11 netlink API.))
|
||||
|
||||
define Package/ucode-mod-ubus/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/ubus.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
resolv, RESOLV_SUPPORT, , \
|
||||
The resolv plugin implements simple DNS resolving.))
|
||||
|
||||
define Package/ucode-mod-uci/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/uci.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
rtnl, RTNL_SUPPORT, +libnl-tiny +libubox, \
|
||||
The rtnl plugin provides access to the Linux routing netlink API.))
|
||||
|
||||
define Package/ucode-mod-uloop/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/ucode
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/uloop.so $(1)/usr/lib/ucode/
|
||||
endef
|
||||
$(eval $(call UcodeModule, \
|
||||
struct, STRUCT_SUPPORT, , \
|
||||
The struct plugin implements Python 3 compatible struct.pack/unpack functionality.))
|
||||
|
||||
$(eval $(call UcodeModule, \
|
||||
ubus, UBUS_SUPPORT, +libubus +libblobmsg-json, \
|
||||
The ubus module allows ucode template scripts to enumerate and invoke ubus procedures.))
|
||||
|
||||
$(eval $(call UcodeModule, \
|
||||
uci, UCI_SUPPORT, +libuci, \
|
||||
The uci module allows templates to read and modify uci configuration.))
|
||||
|
||||
$(eval $(call UcodeModule, \
|
||||
uloop, ULOOP_SUPPORT, +libubox, \
|
||||
The uloop module allows ucode scripts to interact with OpenWrt uloop event loop implementation.))
|
||||
|
||||
$(eval $(call BuildPackage,libucode))
|
||||
$(eval $(call BuildPackage,ucode))
|
||||
$(eval $(call BuildPackage,ucode-mod-fs))
|
||||
$(eval $(call BuildPackage,ucode-mod-math))
|
||||
$(eval $(call BuildPackage,ucode-mod-nl80211))
|
||||
$(eval $(call BuildPackage,ucode-mod-resolv))
|
||||
$(eval $(call BuildPackage,ucode-mod-rtnl))
|
||||
$(eval $(call BuildPackage,ucode-mod-struct))
|
||||
$(eval $(call BuildPackage,ucode-mod-ubus))
|
||||
$(eval $(call BuildPackage,ucode-mod-uci))
|
||||
$(eval $(call BuildPackage,ucode-mod-uloop))
|
||||
|
||||
$(foreach mod,$(UCODE_MODULES), \
|
||||
$(eval $(call BuildPackage,$(mod))))
|
||||
|
||||
$(eval $(call HostBuild))
|
||||
|
||||
@ -2,7 +2,7 @@ package metadata;
|
||||
use base 'Exporter';
|
||||
use strict;
|
||||
use warnings;
|
||||
our @EXPORT = qw(%package %vpackage %srcpackage %category %overrides clear_packages parse_package_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
|
||||
our @EXPORT = qw(%package %vpackage %srcpackage %category %overrides clear_packages parse_package_metadata parse_package_manifest_metadata parse_target_metadata get_multiline @ignore %usernames %groupnames);
|
||||
|
||||
our %package;
|
||||
our %vpackage;
|
||||
@ -256,6 +256,8 @@ sub parse_package_metadata($) {
|
||||
/^Source: \s*(.+)\s*$/ and $pkg->{source} = $1;
|
||||
/^License: \s*(.+)\s*$/ and $pkg->{license} = $1;
|
||||
/^LicenseFiles: \s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
|
||||
/^CPE-ID: \s*(.+)\s*$/ and $pkg->{cpe_id} = $1;
|
||||
/^ABI-Version: \s*(.+)\s*$/ and $pkg->{abi_version} = $1;
|
||||
/^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
|
||||
/^Provides: \s*(.+)\s*$/ and do {
|
||||
my @vpkg = split /\s+/, $1;
|
||||
@ -315,4 +317,42 @@ sub parse_package_metadata($) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub parse_package_manifest_metadata($) {
|
||||
my $file = shift;
|
||||
my $pkg;
|
||||
my %pkgs;
|
||||
|
||||
open FILE, "<$file" or do {
|
||||
warn "Cannot open '$file': $!\n";
|
||||
return undef;
|
||||
};
|
||||
|
||||
while (<FILE>) {
|
||||
chomp;
|
||||
/^Package:\s*(.+?)\s*$/ and do {
|
||||
$pkg = {};
|
||||
$pkg->{name} = $1;
|
||||
$pkg->{depends} = [];
|
||||
$pkgs{$1} = $pkg;
|
||||
};
|
||||
/^Version:\s*(.+)\s*$/ and $pkg->{version} = $1;
|
||||
/^Depends:\s*(.+)\s*$/ and $pkg->{depends} = [ split /\s+/, $1 ];
|
||||
/^Source:\s*(.+)\s*$/ and $pkg->{source} = $1;
|
||||
/^SourceName:\s*(.+)\s*$/ and $pkg->{sourcename} = $1;
|
||||
/^License:\s*(.+)\s*$/ and $pkg->{license} = $1;
|
||||
/^LicenseFiles:\s*(.+)\s*$/ and $pkg->{licensefiles} = $1;
|
||||
/^Section:\s*(.+)\s*$/ and $pkg->{section} = $1;
|
||||
/^SourceDateEpoch: \s*(.+)\s*$/ and $pkg->{sourcedateepoch} = $1;
|
||||
/^CPE-ID:\s*(.+)\s*$/ and $pkg->{cpe_id} = $1;
|
||||
/^Architecture:\s*(.+)\s*$/ and $pkg->{architecture} = $1;
|
||||
/^Installed-Size:\s*(.+)\s*$/ and $pkg->{installedsize} = $1;
|
||||
/^Filename:\s*(.+)\s*$/ and $pkg->{filename} = $1;
|
||||
/^Size:\s*(\d+)\s*$/ and $pkg->{size} = $1;
|
||||
/^SHA256sum:\s*(.*)\s*$/ and $pkg->{sha256sum} = $1;
|
||||
}
|
||||
|
||||
close FILE;
|
||||
return %pkgs;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
@ -4,6 +4,8 @@ use lib "$FindBin::Bin";
|
||||
use strict;
|
||||
use metadata;
|
||||
use Getopt::Long;
|
||||
use Time::Piece;
|
||||
use JSON::PP;
|
||||
|
||||
my %board;
|
||||
|
||||
@ -609,6 +611,7 @@ ${json}{
|
||||
"version":"$pkg->{version}",
|
||||
"category":"$pkg->{category}",
|
||||
"license":"$pkg->{license}",
|
||||
"cpe_id":"$pkg->{cpe_id}",
|
||||
"maintainer": [$pkg_maintainer],
|
||||
"depends":[$pkg_deps]},
|
||||
END_JSON
|
||||
@ -619,6 +622,173 @@ END_JSON
|
||||
print "[$json]";
|
||||
}
|
||||
|
||||
sub image_manifest_packages($)
|
||||
{
|
||||
my %packages;
|
||||
my $imgmanifest = shift;
|
||||
|
||||
open FILE, "<$imgmanifest" or return;
|
||||
while (<FILE>) {
|
||||
/^(.+?) - (.+)$/ and $packages{$1} = $2;
|
||||
}
|
||||
close FILE;
|
||||
|
||||
return %packages;
|
||||
}
|
||||
|
||||
sub dump_cyclonedxsbom_json {
|
||||
my (@components) = @_;
|
||||
|
||||
my $uuid = sprintf(
|
||||
"%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
|
||||
rand(0xffff), rand(0xffff), rand(0xffff),
|
||||
rand(0x0fff) | 0x4000,
|
||||
rand(0x3fff) | 0x8000,
|
||||
rand(0xffff), rand(0xffff), rand(0xffff)
|
||||
);
|
||||
|
||||
my $cyclonedx = {
|
||||
bomFormat => "CycloneDX",
|
||||
specVersion => "1.4",
|
||||
serialNumber => "urn:uuid:$uuid",
|
||||
version => 1,
|
||||
metadata => {
|
||||
timestamp => gmtime->datetime,
|
||||
},
|
||||
"components" => [@components],
|
||||
};
|
||||
|
||||
return encode_json($cyclonedx);
|
||||
}
|
||||
|
||||
sub gen_image_cyclonedxsbom() {
|
||||
my $pkginfo = shift @ARGV;
|
||||
my $imgmanifest = shift @ARGV;
|
||||
my @components;
|
||||
my %image_packages;
|
||||
|
||||
%image_packages = image_manifest_packages($imgmanifest);
|
||||
%image_packages or exit 1;
|
||||
parse_package_metadata($pkginfo) or exit 1;
|
||||
|
||||
$package{"kernel"} = {
|
||||
license => "GPL-2.0",
|
||||
cpe_id => "cpe:/o:linux:linux_kernel",
|
||||
name => "kernel",
|
||||
};
|
||||
|
||||
my %abimap;
|
||||
my @abipkgs = grep { defined $package{$_}->{abi_version} } keys %package;
|
||||
foreach my $name (@abipkgs) {
|
||||
my $pkg = $package{$name};
|
||||
my $abipkg = $name . $pkg->{abi_version};
|
||||
$abimap{$abipkg} = $name;
|
||||
}
|
||||
|
||||
foreach my $name (sort {uc($a) cmp uc($b)} keys %image_packages) {
|
||||
my $pkg = $package{$name};
|
||||
if (!$pkg) {
|
||||
$pkg = $package{$abimap{$name}};
|
||||
next if !$pkg;
|
||||
}
|
||||
|
||||
my @licenses;
|
||||
my @license = split(/\s+/, $pkg->{license});
|
||||
foreach my $lic (@license) {
|
||||
push @licenses, (
|
||||
{ "license" => { "name" => $lic } }
|
||||
);
|
||||
}
|
||||
my $type;
|
||||
if ($pkg->{category}) {
|
||||
my $category = $pkg->{category};
|
||||
my %cat_type = (
|
||||
"Firmware" => "firmware",
|
||||
"Libraries" => "library"
|
||||
);
|
||||
|
||||
if ($cat_type{$category}) {
|
||||
$type = $cat_type{$category};
|
||||
} else {
|
||||
$type = "application";
|
||||
}
|
||||
}
|
||||
|
||||
my $version = $pkg->{version};
|
||||
if ($image_packages{$name}) {
|
||||
$version = $image_packages{$name};
|
||||
}
|
||||
$version =~ s/-\d+$// if $version;
|
||||
if ($name =~ /^(kernel|kmod-)/ and $version =~ /^(\d+\.\d+\.\d+)/) {
|
||||
$version = $1;
|
||||
}
|
||||
|
||||
push @components, {
|
||||
name => $pkg->{name},
|
||||
version => $version,
|
||||
@licenses > 0 ? (licenses => [ @licenses ]) : (),
|
||||
$pkg->{cpe_id} ? (cpe => $pkg->{cpe_id}.":".$version) : (),
|
||||
$type ? (type => $type) : (),
|
||||
$version ? (version => $version) : (),
|
||||
};
|
||||
}
|
||||
|
||||
print dump_cyclonedxsbom_json(@components);
|
||||
}
|
||||
|
||||
sub gen_package_cyclonedxsbom() {
|
||||
my $pkgmanifest = shift @ARGV;
|
||||
my @components;
|
||||
my %mpkgs;
|
||||
|
||||
%mpkgs = parse_package_manifest_metadata($pkgmanifest);
|
||||
%mpkgs or exit 1;
|
||||
|
||||
foreach my $name (sort {uc($a) cmp uc($b)} keys %mpkgs) {
|
||||
my $pkg = $mpkgs{$name};
|
||||
|
||||
my @licenses;
|
||||
my @license = split(/\s+/, $pkg->{license});
|
||||
foreach my $lic (@license) {
|
||||
push @licenses, (
|
||||
{ "license" => { "name" => $lic } }
|
||||
);
|
||||
}
|
||||
|
||||
my $type;
|
||||
if ($pkg->{section}) {
|
||||
my $section = $pkg->{section};
|
||||
my %section_type = (
|
||||
"firmware" => "firmware",
|
||||
"libs" => "library"
|
||||
);
|
||||
|
||||
if ($section_type{$section}) {
|
||||
$type = $section_type{$section};
|
||||
} else {
|
||||
$type = "application";
|
||||
}
|
||||
}
|
||||
|
||||
my $version = $pkg->{version};
|
||||
$version =~ s/-\d+$// if $version;
|
||||
if ($name =~ /^(kernel|kmod-)/ and $version =~ /^(\d+\.\d+\.\d+)/) {
|
||||
$version = $1;
|
||||
}
|
||||
|
||||
push @components, {
|
||||
name => $name,
|
||||
version => $version,
|
||||
@licenses > 0 ? (licenses => [ @licenses ]) : (),
|
||||
$pkg->{cpe_id} ? (cpe => $pkg->{cpe_id}.":".$version) : (),
|
||||
$type ? (type => $type) : (),
|
||||
$version ? (version => $version) : (),
|
||||
};
|
||||
}
|
||||
|
||||
print dump_cyclonedxsbom_json(@components);
|
||||
}
|
||||
|
||||
sub parse_command() {
|
||||
GetOptions("ignore=s", \@ignore);
|
||||
my $cmd = shift @ARGV;
|
||||
@ -629,6 +799,8 @@ sub parse_command() {
|
||||
/^source$/ and return gen_package_source();
|
||||
/^pkgaux$/ and return gen_package_auxiliary();
|
||||
/^pkgmanifestjson$/ and return gen_package_manifest_json();
|
||||
/^imgcyclonedxsbom$/ and return gen_image_cyclonedxsbom();
|
||||
/^pkgcyclonedxsbom$/ and return gen_package_cyclonedxsbom();
|
||||
/^license$/ and return gen_package_license(0);
|
||||
/^licensefull$/ and return gen_package_license(1);
|
||||
/^usergroup$/ and return gen_usergroup_list();
|
||||
@ -642,6 +814,8 @@ Available Commands:
|
||||
$0 source [file] Package source file information
|
||||
$0 pkgaux [file] Package auxiliary variables in makefile format
|
||||
$0 pkgmanifestjson [file] Package manifests in JSON format
|
||||
$0 imgcyclonedxsbom <file> [manifest] Image package manifest in CycloneDX SBOM JSON format
|
||||
$0 pkgcyclonedxsbom <file> Package manifest in CycloneDX SBOM JSON format
|
||||
$0 license [file] Package license information
|
||||
$0 licensefull [file] Package license information (full list)
|
||||
$0 usergroup [file] Package usergroup allocation list
|
||||
|
||||
@ -34,7 +34,7 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
|
||||
mtd->type = MTD_NORFLASH;
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -847,6 +847,17 @@ out_error:
|
||||
@@ -870,6 +870,17 @@ out_error:
|
||||
*/
|
||||
static void mtd_set_dev_defaults(struct mtd_info *mtd)
|
||||
{
|
||||
|
||||
@ -0,0 +1,256 @@
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Thu, 14 Sep 2023 07:59:09 +0200
|
||||
Subject: [PATCH] nvmem: brcm_nvram: store a copy of NVRAM content
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This driver uses MMIO access for reading NVRAM from a flash device.
|
||||
Underneath there is a flash controller that reads data and provides
|
||||
mapping window.
|
||||
|
||||
Using MMIO interface affects controller configuration and may break real
|
||||
controller driver. It was reported by multiple users of devices with
|
||||
NVRAM stored on NAND.
|
||||
|
||||
Modify driver to read & cache NVRAM content during init and use that
|
||||
copy to provide NVMEM data when requested. On NAND flashes due to their
|
||||
alignment NVRAM partitions can be quite big (1 MiB and more) while
|
||||
actual NVRAM content stays quite small (usually 16 to 32 KiB). To avoid
|
||||
allocating so much memory check for actual data length.
|
||||
|
||||
Link: https://lore.kernel.org/linux-mtd/CACna6rwf3_9QVjYcM+847biTX=K0EoWXuXcSMkJO1Vy_5vmVqA@mail.gmail.com/
|
||||
Fixes: 3fef9ed0627a ("nvmem: brcm_nvram: new driver exposing Broadcom's NVRAM")
|
||||
Cc: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
Cc: Florian Fainelli <florian.fainelli@broadcom.com>
|
||||
Cc: Scott Branden <scott.branden@broadcom.com>
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com>
|
||||
---
|
||||
drivers/nvmem/brcm_nvram.c | 134 ++++++++++++++++++++++++++-----------
|
||||
1 file changed, 94 insertions(+), 40 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/brcm_nvram.c
|
||||
+++ b/drivers/nvmem/brcm_nvram.c
|
||||
@@ -17,9 +17,23 @@
|
||||
|
||||
#define NVRAM_MAGIC "FLSH"
|
||||
|
||||
+/**
|
||||
+ * struct brcm_nvram - driver state internal struct
|
||||
+ *
|
||||
+ * @dev: NVMEM device pointer
|
||||
+ * @nvmem_size: Size of the whole space available for NVRAM
|
||||
+ * @data: NVRAM data copy stored to avoid poking underlaying flash controller
|
||||
+ * @data_len: NVRAM data size
|
||||
+ * @padding_byte: Padding value used to fill remaining space
|
||||
+ * @cells: Array of discovered NVMEM cells
|
||||
+ * @ncells: Number of elements in cells
|
||||
+ */
|
||||
struct brcm_nvram {
|
||||
struct device *dev;
|
||||
- void __iomem *base;
|
||||
+ size_t nvmem_size;
|
||||
+ uint8_t *data;
|
||||
+ size_t data_len;
|
||||
+ uint8_t padding_byte;
|
||||
struct nvmem_cell_info *cells;
|
||||
int ncells;
|
||||
};
|
||||
@@ -36,10 +50,47 @@ static int brcm_nvram_read(void *context
|
||||
size_t bytes)
|
||||
{
|
||||
struct brcm_nvram *priv = context;
|
||||
- u8 *dst = val;
|
||||
+ size_t to_copy;
|
||||
+
|
||||
+ if (offset + bytes > priv->data_len)
|
||||
+ to_copy = max_t(ssize_t, (ssize_t)priv->data_len - offset, 0);
|
||||
+ else
|
||||
+ to_copy = bytes;
|
||||
+
|
||||
+ memcpy(val, priv->data + offset, to_copy);
|
||||
+
|
||||
+ memset((uint8_t *)val + to_copy, priv->padding_byte, bytes - to_copy);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int brcm_nvram_copy_data(struct brcm_nvram *priv, struct platform_device *pdev)
|
||||
+{
|
||||
+ struct resource *res;
|
||||
+ void __iomem *base;
|
||||
+
|
||||
+ base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
+ if (IS_ERR(base))
|
||||
+ return PTR_ERR(base);
|
||||
+
|
||||
+ priv->nvmem_size = resource_size(res);
|
||||
+
|
||||
+ priv->padding_byte = readb(base + priv->nvmem_size - 1);
|
||||
+ for (priv->data_len = priv->nvmem_size;
|
||||
+ priv->data_len;
|
||||
+ priv->data_len--) {
|
||||
+ if (readb(base + priv->data_len - 1) != priv->padding_byte)
|
||||
+ break;
|
||||
+ }
|
||||
+ WARN(priv->data_len > SZ_128K, "Unexpected (big) NVRAM size: %zu B\n", priv->data_len);
|
||||
|
||||
- while (bytes--)
|
||||
- *dst++ = readb(priv->base + offset++);
|
||||
+ priv->data = devm_kzalloc(priv->dev, priv->data_len, GFP_KERNEL);
|
||||
+ if (!priv->data)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ memcpy_fromio(priv->data, base, priv->data_len);
|
||||
+
|
||||
+ bcm47xx_nvram_init_from_iomem(base, priv->data_len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -67,8 +118,13 @@ static int brcm_nvram_add_cells(struct b
|
||||
size_t len)
|
||||
{
|
||||
struct device *dev = priv->dev;
|
||||
- char *var, *value, *eq;
|
||||
+ char *var, *value;
|
||||
+ uint8_t tmp;
|
||||
int idx;
|
||||
+ int err = 0;
|
||||
+
|
||||
+ tmp = priv->data[len - 1];
|
||||
+ priv->data[len - 1] = '\0';
|
||||
|
||||
priv->ncells = 0;
|
||||
for (var = data + sizeof(struct brcm_nvram_header);
|
||||
@@ -78,67 +134,68 @@ static int brcm_nvram_add_cells(struct b
|
||||
}
|
||||
|
||||
priv->cells = devm_kcalloc(dev, priv->ncells, sizeof(*priv->cells), GFP_KERNEL);
|
||||
- if (!priv->cells)
|
||||
- return -ENOMEM;
|
||||
+ if (!priv->cells) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
for (var = data + sizeof(struct brcm_nvram_header), idx = 0;
|
||||
var < (char *)data + len && *var;
|
||||
var = value + strlen(value) + 1, idx++) {
|
||||
+ char *eq, *name;
|
||||
+
|
||||
eq = strchr(var, '=');
|
||||
if (!eq)
|
||||
break;
|
||||
*eq = '\0';
|
||||
+ name = devm_kstrdup(dev, var, GFP_KERNEL);
|
||||
+ *eq = '=';
|
||||
+ if (!name) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto out;
|
||||
+ }
|
||||
value = eq + 1;
|
||||
|
||||
- priv->cells[idx].name = devm_kstrdup(dev, var, GFP_KERNEL);
|
||||
- if (!priv->cells[idx].name)
|
||||
- return -ENOMEM;
|
||||
+ priv->cells[idx].name = name;
|
||||
priv->cells[idx].offset = value - (char *)data;
|
||||
priv->cells[idx].bytes = strlen(value);
|
||||
priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name);
|
||||
- if (!strcmp(var, "et0macaddr") ||
|
||||
- !strcmp(var, "et1macaddr") ||
|
||||
- !strcmp(var, "et2macaddr")) {
|
||||
+ if (!strcmp(name, "et0macaddr") ||
|
||||
+ !strcmp(name, "et1macaddr") ||
|
||||
+ !strcmp(name, "et2macaddr")) {
|
||||
priv->cells[idx].raw_len = strlen(value);
|
||||
priv->cells[idx].bytes = ETH_ALEN;
|
||||
priv->cells[idx].read_post_process = brcm_nvram_read_post_process_macaddr;
|
||||
}
|
||||
}
|
||||
|
||||
- return 0;
|
||||
+out:
|
||||
+ priv->data[len - 1] = tmp;
|
||||
+ return err;
|
||||
}
|
||||
|
||||
static int brcm_nvram_parse(struct brcm_nvram *priv)
|
||||
{
|
||||
+ struct brcm_nvram_header *header = (struct brcm_nvram_header *)priv->data;
|
||||
struct device *dev = priv->dev;
|
||||
- struct brcm_nvram_header header;
|
||||
- uint8_t *data;
|
||||
size_t len;
|
||||
int err;
|
||||
|
||||
- memcpy_fromio(&header, priv->base, sizeof(header));
|
||||
-
|
||||
- if (memcmp(header.magic, NVRAM_MAGIC, 4)) {
|
||||
+ if (memcmp(header->magic, NVRAM_MAGIC, 4)) {
|
||||
dev_err(dev, "Invalid NVRAM magic\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
- len = le32_to_cpu(header.len);
|
||||
-
|
||||
- data = kzalloc(len, GFP_KERNEL);
|
||||
- if (!data)
|
||||
- return -ENOMEM;
|
||||
-
|
||||
- memcpy_fromio(data, priv->base, len);
|
||||
- data[len - 1] = '\0';
|
||||
-
|
||||
- err = brcm_nvram_add_cells(priv, data, len);
|
||||
- if (err) {
|
||||
- dev_err(dev, "Failed to add cells: %d\n", err);
|
||||
- return err;
|
||||
+ len = le32_to_cpu(header->len);
|
||||
+ if (len > priv->nvmem_size) {
|
||||
+ dev_err(dev, "NVRAM length (%zd) exceeds mapped size (%zd)\n", len,
|
||||
+ priv->nvmem_size);
|
||||
+ return -EINVAL;
|
||||
}
|
||||
|
||||
- kfree(data);
|
||||
+ err = brcm_nvram_add_cells(priv, priv->data, len);
|
||||
+ if (err)
|
||||
+ dev_err(dev, "Failed to add cells: %d\n", err);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -150,7 +207,6 @@ static int brcm_nvram_probe(struct platf
|
||||
.reg_read = brcm_nvram_read,
|
||||
};
|
||||
struct device *dev = &pdev->dev;
|
||||
- struct resource *res;
|
||||
struct brcm_nvram *priv;
|
||||
int err;
|
||||
|
||||
@@ -159,21 +215,19 @@ static int brcm_nvram_probe(struct platf
|
||||
return -ENOMEM;
|
||||
priv->dev = dev;
|
||||
|
||||
- priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
- if (IS_ERR(priv->base))
|
||||
- return PTR_ERR(priv->base);
|
||||
+ err = brcm_nvram_copy_data(priv, pdev);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
|
||||
err = brcm_nvram_parse(priv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
- bcm47xx_nvram_init_from_iomem(priv->base, resource_size(res));
|
||||
-
|
||||
config.dev = dev;
|
||||
config.cells = priv->cells;
|
||||
config.ncells = priv->ncells;
|
||||
config.priv = priv;
|
||||
- config.size = resource_size(res);
|
||||
+ config.size = priv->nvmem_size;
|
||||
|
||||
return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
From 9ccfcbeb8f32ff89e99b36cb9cdebaa0d1b44ed1 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:24 +0100
|
||||
Subject: [PATCH] nvmem: sunxi_sid: Convert to devm_platform_ioremap_resource()
|
||||
|
||||
Use devm_platform_ioremap_resource() to simplify code.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/sunxi_sid.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/sunxi_sid.c
|
||||
+++ b/drivers/nvmem/sunxi_sid.c
|
||||
@@ -125,7 +125,6 @@ static int sun8i_sid_read_by_reg(void *c
|
||||
static int sunxi_sid_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
- struct resource *res;
|
||||
struct nvmem_config *nvmem_cfg;
|
||||
struct nvmem_device *nvmem;
|
||||
struct sunxi_sid *sid;
|
||||
@@ -142,8 +141,7 @@ static int sunxi_sid_probe(struct platfo
|
||||
return -EINVAL;
|
||||
sid->value_offset = cfg->value_offset;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- sid->base = devm_ioremap_resource(dev, res);
|
||||
+ sid->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(sid->base))
|
||||
return PTR_ERR(sid->base);
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
From cfadd0e7d9225566f320bc4dc716682be910be6c Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:25 +0100
|
||||
Subject: [PATCH] nvmem: brcm_nvram: Use
|
||||
devm_platform_get_and_ioremap_resource()
|
||||
|
||||
Convert platform_get_resource(), devm_ioremap_resource() to a single
|
||||
call to devm_platform_get_and_ioremap_resource(), as this is exactly
|
||||
what this function does.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-4-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/brcm_nvram.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/brcm_nvram.c
|
||||
+++ b/drivers/nvmem/brcm_nvram.c
|
||||
@@ -159,8 +159,7 @@ static int brcm_nvram_probe(struct platf
|
||||
return -ENOMEM;
|
||||
priv->dev = dev;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- priv->base = devm_ioremap_resource(dev, res);
|
||||
+ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(priv->base))
|
||||
return PTR_ERR(priv->base);
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
From 0b49178e2b6b4aac3c7fa3ce8d8c02208a13b988 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:26 +0100
|
||||
Subject: [PATCH] nvmem: lpc18xx_otp: Convert to
|
||||
devm_platform_ioremap_resource()
|
||||
|
||||
Use devm_platform_ioremap_resource() to simplify code.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-5-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/lpc18xx_otp.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/lpc18xx_otp.c
|
||||
+++ b/drivers/nvmem/lpc18xx_otp.c
|
||||
@@ -68,14 +68,12 @@ static int lpc18xx_otp_probe(struct plat
|
||||
{
|
||||
struct nvmem_device *nvmem;
|
||||
struct lpc18xx_otp *otp;
|
||||
- struct resource *res;
|
||||
|
||||
otp = devm_kzalloc(&pdev->dev, sizeof(*otp), GFP_KERNEL);
|
||||
if (!otp)
|
||||
return -ENOMEM;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- otp->base = devm_ioremap_resource(&pdev->dev, res);
|
||||
+ otp->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(otp->base))
|
||||
return PTR_ERR(otp->base);
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
From 0a223a097709b99a0ba738d6be5b4f52c04ffb64 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:27 +0100
|
||||
Subject: [PATCH] nvmem: meson-mx-efuse: Convert to
|
||||
devm_platform_ioremap_resource()
|
||||
|
||||
Use devm_platform_ioremap_resource() to simplify code.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-6-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/meson-mx-efuse.c | 4 +---
|
||||
1 file changed, 1 insertion(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/meson-mx-efuse.c
|
||||
+++ b/drivers/nvmem/meson-mx-efuse.c
|
||||
@@ -194,7 +194,6 @@ static int meson_mx_efuse_probe(struct p
|
||||
{
|
||||
const struct meson_mx_efuse_platform_data *drvdata;
|
||||
struct meson_mx_efuse *efuse;
|
||||
- struct resource *res;
|
||||
|
||||
drvdata = of_device_get_match_data(&pdev->dev);
|
||||
if (!drvdata)
|
||||
@@ -204,8 +203,7 @@ static int meson_mx_efuse_probe(struct p
|
||||
if (!efuse)
|
||||
return -ENOMEM;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- efuse->base = devm_ioremap_resource(&pdev->dev, res);
|
||||
+ efuse->base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(efuse->base))
|
||||
return PTR_ERR(efuse->base);
|
||||
|
||||
@ -0,0 +1,31 @@
|
||||
From 94904db28db49ac8fbb2a273d25156db26a3a985 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:28 +0100
|
||||
Subject: [PATCH] nvmem: rockchip-efuse: Use
|
||||
devm_platform_get_and_ioremap_resource()
|
||||
|
||||
Convert platform_get_resource(), devm_ioremap_resource() to a single
|
||||
call to devm_platform_get_and_ioremap_resource(), as this is exactly
|
||||
what this function does.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-7-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/rockchip-efuse.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/rockchip-efuse.c
|
||||
+++ b/drivers/nvmem/rockchip-efuse.c
|
||||
@@ -267,8 +267,7 @@ static int rockchip_efuse_probe(struct p
|
||||
if (!efuse)
|
||||
return -ENOMEM;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- efuse->base = devm_ioremap_resource(dev, res);
|
||||
+ efuse->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(efuse->base))
|
||||
return PTR_ERR(efuse->base);
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
From 0a4a8c0d238fec1fa4b85591524ef42ad261cb97 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:29 +0100
|
||||
Subject: [PATCH] nvmem: stm32-romem: Use
|
||||
devm_platform_get_and_ioremap_resource()
|
||||
|
||||
Convert platform_get_resource(), devm_ioremap_resource() to a single
|
||||
call to devm_platform_get_and_ioremap_resource(), as this is exactly
|
||||
what this function does.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-8-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/stm32-romem.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/stm32-romem.c
|
||||
+++ b/drivers/nvmem/stm32-romem.c
|
||||
@@ -196,8 +196,7 @@ static int stm32_romem_probe(struct plat
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- priv->base = devm_ioremap_resource(dev, res);
|
||||
+ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(priv->base))
|
||||
return PTR_ERR(priv->base);
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
From 0bc0d6dc2a9a05ae6729b4622f09782d9f230815 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:30 +0100
|
||||
Subject: [PATCH] nvmem: qfprom: do some cleanup
|
||||
|
||||
Use devm_platform_ioremap_resource() and
|
||||
devm_platform_get_and_ioremap_resource() to simplify code.
|
||||
BTW convert to use dev_err_probe() instead of open it.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-9-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/qfprom.c | 17 +++++------------
|
||||
1 file changed, 5 insertions(+), 12 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/qfprom.c
|
||||
+++ b/drivers/nvmem/qfprom.c
|
||||
@@ -374,8 +374,7 @@ static int qfprom_probe(struct platform_
|
||||
return -ENOMEM;
|
||||
|
||||
/* The corrected section is always provided */
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- priv->qfpcorrected = devm_ioremap_resource(dev, res);
|
||||
+ priv->qfpcorrected = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(priv->qfpcorrected))
|
||||
return PTR_ERR(priv->qfpcorrected);
|
||||
|
||||
@@ -402,12 +401,10 @@ static int qfprom_probe(struct platform_
|
||||
priv->qfpraw = devm_ioremap_resource(dev, res);
|
||||
if (IS_ERR(priv->qfpraw))
|
||||
return PTR_ERR(priv->qfpraw);
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
|
||||
- priv->qfpconf = devm_ioremap_resource(dev, res);
|
||||
+ priv->qfpconf = devm_platform_ioremap_resource(pdev, 2);
|
||||
if (IS_ERR(priv->qfpconf))
|
||||
return PTR_ERR(priv->qfpconf);
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
|
||||
- priv->qfpsecurity = devm_ioremap_resource(dev, res);
|
||||
+ priv->qfpsecurity = devm_platform_ioremap_resource(pdev, 3);
|
||||
if (IS_ERR(priv->qfpsecurity))
|
||||
return PTR_ERR(priv->qfpsecurity);
|
||||
|
||||
@@ -427,12 +424,8 @@ static int qfprom_probe(struct platform_
|
||||
return PTR_ERR(priv->vcc);
|
||||
|
||||
priv->secclk = devm_clk_get(dev, "core");
|
||||
- if (IS_ERR(priv->secclk)) {
|
||||
- ret = PTR_ERR(priv->secclk);
|
||||
- if (ret != -EPROBE_DEFER)
|
||||
- dev_err(dev, "Error getting clock: %d\n", ret);
|
||||
- return ret;
|
||||
- }
|
||||
+ if (IS_ERR(priv->secclk))
|
||||
+ return dev_err_probe(dev, PTR_ERR(priv->secclk), "Error getting clock\n");
|
||||
|
||||
/* Only enable writing if we have SoC data. */
|
||||
if (priv->soc_data)
|
||||
@ -0,0 +1,29 @@
|
||||
From 6ac41c556e22a0d7d267c9b9d48681d73af4b368 Mon Sep 17 00:00:00 2001
|
||||
From: Yangtao Li <frank.li@vivo.com>
|
||||
Date: Wed, 23 Aug 2023 14:27:31 +0100
|
||||
Subject: [PATCH] nvmem: uniphier: Use devm_platform_get_and_ioremap_resource()
|
||||
|
||||
Convert platform_get_resource(), devm_ioremap_resource() to a single
|
||||
call to devm_platform_get_and_ioremap_resource(), as this is exactly
|
||||
what this function does.
|
||||
|
||||
Signed-off-by: Yangtao Li <frank.li@vivo.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20230823132744.350618-10-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/uniphier-efuse.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/uniphier-efuse.c
|
||||
+++ b/drivers/nvmem/uniphier-efuse.c
|
||||
@@ -41,8 +41,7 @@ static int uniphier_efuse_probe(struct p
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
- priv->base = devm_ioremap_resource(dev, res);
|
||||
+ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
if (IS_ERR(priv->base))
|
||||
return PTR_ERR(priv->base);
|
||||
|
||||
@ -0,0 +1,133 @@
|
||||
From c8efcf7a86ebf2ff48584d270b3070a7075bc345 Mon Sep 17 00:00:00 2001
|
||||
From: Richard Alpe <richard@bit42.se>
|
||||
Date: Mon, 10 Apr 2023 10:20:51 +0200
|
||||
Subject: [PATCH] nvmem: add new NXP QorIQ eFuse driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Add SFP (Security Fuse Processor) read support for NXP (Freescale)
|
||||
QorIQ series SOC's.
|
||||
|
||||
This patch adds support for the T1023 SOC using the SFP offset from
|
||||
the existing T1023 device tree. In theory this should also work for
|
||||
T1024, T1014 and T1013 which uses the same SFP base offset.
|
||||
|
||||
Signed-off-by: Richard Alpe <richard@bit42.se>
|
||||
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/Kconfig | 12 ++++++
|
||||
drivers/nvmem/Makefile | 2 +
|
||||
drivers/nvmem/qoriq-efuse.c | 78 +++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 92 insertions(+)
|
||||
create mode 100644 drivers/nvmem/qoriq-efuse.c
|
||||
|
||||
--- a/drivers/nvmem/Kconfig
|
||||
+++ b/drivers/nvmem/Kconfig
|
||||
@@ -392,4 +392,16 @@ config NVMEM_ZYNQMP
|
||||
|
||||
If sure, say yes. If unsure, say no.
|
||||
|
||||
+config NVMEM_QORIQ_EFUSE
|
||||
+ tristate "NXP QorIQ eFuse support"
|
||||
+ depends on PPC_85xx || COMPILE_TEST
|
||||
+ depends on HAS_IOMEM
|
||||
+ help
|
||||
+ This driver provides read support for the eFuses (SFP) on NXP QorIQ
|
||||
+ series SoC's. This includes secure boot settings, the globally unique
|
||||
+ NXP ID 'FUIDR' and the OEM unique ID 'OUIDR'.
|
||||
+
|
||||
+ This driver can also be built as a module. If so, the module
|
||||
+ will be called nvmem_qoriq_efuse.
|
||||
+
|
||||
endif
|
||||
--- a/drivers/nvmem/Makefile
|
||||
+++ b/drivers/nvmem/Makefile
|
||||
@@ -77,3 +77,5 @@ obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvme
|
||||
nvmem-vf610-ocotp-y := vf610-ocotp.o
|
||||
obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynqmp_nvmem.o
|
||||
nvmem_zynqmp_nvmem-y := zynqmp_nvmem.o
|
||||
+obj-$(CONFIG_NVMEM_QORIQ_EFUSE) += nvmem-qoriq-efuse.o
|
||||
+nvmem-qoriq-efuse-y := qoriq-efuse.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/nvmem/qoriq-efuse.c
|
||||
@@ -0,0 +1,78 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (C) 2023 Westermo Network Technologies AB
|
||||
+ */
|
||||
+
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/mod_devicetable.h>
|
||||
+#include <linux/nvmem-provider.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+struct qoriq_efuse_priv {
|
||||
+ void __iomem *base;
|
||||
+};
|
||||
+
|
||||
+static int qoriq_efuse_read(void *context, unsigned int offset, void *val,
|
||||
+ size_t bytes)
|
||||
+{
|
||||
+ struct qoriq_efuse_priv *priv = context;
|
||||
+
|
||||
+ /* .stride = 4 so offset is guaranteed to be aligned */
|
||||
+ __ioread32_copy(val, priv->base + offset, bytes / 4);
|
||||
+
|
||||
+ /* Ignore trailing bytes (there shouldn't be any) */
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int qoriq_efuse_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct nvmem_config config = {
|
||||
+ .dev = &pdev->dev,
|
||||
+ .read_only = true,
|
||||
+ .reg_read = qoriq_efuse_read,
|
||||
+ .stride = sizeof(u32),
|
||||
+ .word_size = sizeof(u32),
|
||||
+ .name = "qoriq_efuse_read",
|
||||
+ .id = NVMEM_DEVID_AUTO,
|
||||
+ .root_only = true,
|
||||
+ };
|
||||
+ struct qoriq_efuse_priv *priv;
|
||||
+ struct nvmem_device *nvmem;
|
||||
+ struct resource *res;
|
||||
+
|
||||
+ priv = devm_kzalloc(config.dev, sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
|
||||
+ if (IS_ERR(priv->base))
|
||||
+ return PTR_ERR(priv->base);
|
||||
+
|
||||
+ config.size = resource_size(res);
|
||||
+ config.priv = priv;
|
||||
+ nvmem = devm_nvmem_register(config.dev, &config);
|
||||
+
|
||||
+ return PTR_ERR_OR_ZERO(nvmem);
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id qoriq_efuse_of_match[] = {
|
||||
+ { .compatible = "fsl,t1023-sfp", },
|
||||
+ {/* sentinel */},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, qoriq_efuse_of_match);
|
||||
+
|
||||
+static struct platform_driver qoriq_efuse_driver = {
|
||||
+ .probe = qoriq_efuse_probe,
|
||||
+ .driver = {
|
||||
+ .name = "qoriq-efuse",
|
||||
+ .of_match_table = qoriq_efuse_of_match,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(qoriq_efuse_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Richard Alpe <richard.alpe@bit42.se>");
|
||||
+MODULE_DESCRIPTION("NXP QorIQ Security Fuse Processor (SFP) Reader");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@ -0,0 +1,37 @@
|
||||
From 9d53d595f688c9837e88a919229cc61a165c7b9e Mon Sep 17 00:00:00 2001
|
||||
From: Diederik de Haas <didi.debian@cknow.org>
|
||||
Date: Mon, 24 Jul 2023 13:36:22 +0200
|
||||
Subject: [PATCH] nvmem: Kconfig: Fix typo "drive" -> "driver"
|
||||
|
||||
Fix typo where "driver" was meant instead of "drive".
|
||||
While at it, also capitalize "OTP".
|
||||
|
||||
Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
|
||||
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/Kconfig | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/Kconfig
|
||||
+++ b/drivers/nvmem/Kconfig
|
||||
@@ -247,7 +247,7 @@ config NVMEM_ROCKCHIP_EFUSE
|
||||
depends on ARCH_ROCKCHIP || COMPILE_TEST
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
- This is a simple drive to dump specified values of Rockchip SoC
|
||||
+ This is a simple driver to dump specified values of Rockchip SoC
|
||||
from eFuse, such as cpu-leakage.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
@@ -258,8 +258,8 @@ config NVMEM_ROCKCHIP_OTP
|
||||
depends on ARCH_ROCKCHIP || COMPILE_TEST
|
||||
depends on HAS_IOMEM
|
||||
help
|
||||
- This is a simple drive to dump specified values of Rockchip SoC
|
||||
- from otp, such as cpu-leakage.
|
||||
+ This is a simple driver to dump specified values of Rockchip SoC
|
||||
+ from OTP, such as cpu-leakage.
|
||||
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called nvmem_rockchip_otp.
|
||||
@ -0,0 +1,152 @@
|
||||
From 0a9ec38c47c1ca4528aa058e2b9ea61901a7e632 Mon Sep 17 00:00:00 2001
|
||||
From: Komal Bajaj <quic_kbajaj@quicinc.com>
|
||||
Date: Tue, 1 Aug 2023 12:10:25 +0530
|
||||
Subject: [PATCH] nvmem: sec-qfprom: Add Qualcomm secure QFPROM support
|
||||
|
||||
For some of the Qualcomm SoC's, it is possible that
|
||||
some of the fuse regions or entire qfprom region is
|
||||
protected from non-secure access. In such situations,
|
||||
the OS will have to use secure calls to read the region.
|
||||
With that motivation, add secure qfprom driver.
|
||||
|
||||
Signed-off-by: Komal Bajaj <quic_kbajaj@quicinc.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/Kconfig | 13 ++++++
|
||||
drivers/nvmem/Makefile | 2 +
|
||||
drivers/nvmem/sec-qfprom.c | 96 ++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 111 insertions(+)
|
||||
create mode 100644 drivers/nvmem/sec-qfprom.c
|
||||
|
||||
--- a/drivers/nvmem/Kconfig
|
||||
+++ b/drivers/nvmem/Kconfig
|
||||
@@ -226,6 +226,19 @@ config NVMEM_QCOM_QFPROM
|
||||
This driver can also be built as a module. If so, the module
|
||||
will be called nvmem_qfprom.
|
||||
|
||||
+config NVMEM_QCOM_SEC_QFPROM
|
||||
+ tristate "QCOM SECURE QFPROM Support"
|
||||
+ depends on ARCH_QCOM || COMPILE_TEST
|
||||
+ depends on HAS_IOMEM
|
||||
+ depends on OF
|
||||
+ select QCOM_SCM
|
||||
+ help
|
||||
+ Say y here to enable secure QFPROM support. The secure QFPROM provides access
|
||||
+ functions for QFPROM data to rest of the drivers via nvmem interface.
|
||||
+
|
||||
+ This driver can also be built as a module. If so, the module will be called
|
||||
+ nvmem_sec_qfprom.
|
||||
+
|
||||
config NVMEM_RAVE_SP_EEPROM
|
||||
tristate "Rave SP EEPROM Support"
|
||||
depends on RAVE_SP_CORE
|
||||
--- a/drivers/nvmem/Makefile
|
||||
+++ b/drivers/nvmem/Makefile
|
||||
@@ -46,6 +46,8 @@ obj-$(CONFIG_NVMEM_NINTENDO_OTP) += nvme
|
||||
nvmem-nintendo-otp-y := nintendo-otp.o
|
||||
obj-$(CONFIG_NVMEM_QCOM_QFPROM) += nvmem_qfprom.o
|
||||
nvmem_qfprom-y := qfprom.o
|
||||
+obj-$(CONFIG_NVMEM_QCOM_SEC_QFPROM) += nvmem_sec_qfprom.o
|
||||
+nvmem_sec_qfprom-y := sec-qfprom.o
|
||||
obj-$(CONFIG_NVMEM_RAVE_SP_EEPROM) += nvmem-rave-sp-eeprom.o
|
||||
nvmem-rave-sp-eeprom-y := rave-sp-eeprom.o
|
||||
obj-$(CONFIG_NVMEM_RMEM) += nvmem-rmem.o
|
||||
--- /dev/null
|
||||
+++ b/drivers/nvmem/sec-qfprom.c
|
||||
@@ -0,0 +1,96 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-only
|
||||
+/*
|
||||
+ * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/firmware/qcom/qcom_scm.h>
|
||||
+#include <linux/mod_devicetable.h>
|
||||
+#include <linux/nvmem-provider.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/pm_runtime.h>
|
||||
+
|
||||
+/**
|
||||
+ * struct sec_qfprom - structure holding secure qfprom attributes
|
||||
+ *
|
||||
+ * @base: starting physical address for secure qfprom corrected address space.
|
||||
+ * @dev: qfprom device structure.
|
||||
+ */
|
||||
+struct sec_qfprom {
|
||||
+ phys_addr_t base;
|
||||
+ struct device *dev;
|
||||
+};
|
||||
+
|
||||
+static int sec_qfprom_reg_read(void *context, unsigned int reg, void *_val, size_t bytes)
|
||||
+{
|
||||
+ struct sec_qfprom *priv = context;
|
||||
+ unsigned int i;
|
||||
+ u8 *val = _val;
|
||||
+ u32 read_val;
|
||||
+ u8 *tmp;
|
||||
+
|
||||
+ for (i = 0; i < bytes; i++, reg++) {
|
||||
+ if (i == 0 || reg % 4 == 0) {
|
||||
+ if (qcom_scm_io_readl(priv->base + (reg & ~3), &read_val)) {
|
||||
+ dev_err(priv->dev, "Couldn't access fuse register\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ tmp = (u8 *)&read_val;
|
||||
+ }
|
||||
+
|
||||
+ val[i] = tmp[reg & 3];
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int sec_qfprom_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct nvmem_config econfig = {
|
||||
+ .name = "sec-qfprom",
|
||||
+ .stride = 1,
|
||||
+ .word_size = 1,
|
||||
+ .id = NVMEM_DEVID_AUTO,
|
||||
+ .reg_read = sec_qfprom_reg_read,
|
||||
+ };
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct nvmem_device *nvmem;
|
||||
+ struct sec_qfprom *priv;
|
||||
+ struct resource *res;
|
||||
+
|
||||
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
||||
+ if (!priv)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
+ if (!res)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ priv->base = res->start;
|
||||
+
|
||||
+ econfig.size = resource_size(res);
|
||||
+ econfig.dev = dev;
|
||||
+ econfig.priv = priv;
|
||||
+
|
||||
+ priv->dev = dev;
|
||||
+
|
||||
+ nvmem = devm_nvmem_register(dev, &econfig);
|
||||
+
|
||||
+ return PTR_ERR_OR_ZERO(nvmem);
|
||||
+}
|
||||
+
|
||||
+static const struct of_device_id sec_qfprom_of_match[] = {
|
||||
+ { .compatible = "qcom,sec-qfprom" },
|
||||
+ {/* sentinel */},
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(of, sec_qfprom_of_match);
|
||||
+
|
||||
+static struct platform_driver qfprom_driver = {
|
||||
+ .probe = sec_qfprom_probe,
|
||||
+ .driver = {
|
||||
+ .name = "qcom_sec_qfprom",
|
||||
+ .of_match_table = sec_qfprom_of_match,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(qfprom_driver);
|
||||
+MODULE_DESCRIPTION("Qualcomm Secure QFPROM driver");
|
||||
+MODULE_LICENSE("GPL");
|
||||
@ -0,0 +1,30 @@
|
||||
From c32f2186acc9abb4d766361255d7ddf07d15eeb2 Mon Sep 17 00:00:00 2001
|
||||
From: Atul Raut <rauji.raut@gmail.com>
|
||||
Date: Sun, 30 Jul 2023 15:39:15 -0700
|
||||
Subject: [PATCH] nvmem: u-boot-env:: Replace zero-length array with
|
||||
DECLARE_FLEX_ARRAY() helper
|
||||
|
||||
We are moving toward replacing zero-length arrays with C99 flexible-array
|
||||
members since they are deprecated. Therefore, the new DECLARE_FLEX_ARRAY()
|
||||
helper macro should be used to replace the zero-length array declaration.
|
||||
|
||||
This fixes warnings such as:
|
||||
./drivers/nvmem/u-boot-env.c:50:9-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
|
||||
|
||||
Signed-off-by: Atul Raut <rauji.raut@gmail.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/u-boot-env.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/nvmem/u-boot-env.c
|
||||
+++ b/drivers/nvmem/u-boot-env.c
|
||||
@@ -47,7 +47,7 @@ struct u_boot_env_image_broadcom {
|
||||
__le32 magic;
|
||||
__le32 len;
|
||||
__le32 crc32;
|
||||
- uint8_t data[0];
|
||||
+ DECLARE_FLEX_ARRAY(uint8_t, data);
|
||||
} __packed;
|
||||
|
||||
static int u_boot_env_read(void *context, unsigned int offset, void *val,
|
||||
@ -0,0 +1,40 @@
|
||||
From 104af6a5b199eb4dc7970d1304aef38ac5a6ed54 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Tue, 8 Aug 2023 08:29:26 +0200
|
||||
Subject: [PATCH] nvmem: core: Create all cells before adding the nvmem device
|
||||
|
||||
Let's pack all the cells creation in one place, so they are all created
|
||||
before we add the nvmem device.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Reviewed-by: Michael Walle <michael@walle.cc>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -998,17 +998,17 @@ struct nvmem_device *nvmem_register(cons
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
- dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
|
||||
-
|
||||
- rval = device_add(&nvmem->dev);
|
||||
+ rval = nvmem_add_cells_from_fixed_layout(nvmem);
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
- rval = nvmem_add_cells_from_fixed_layout(nvmem);
|
||||
+ rval = nvmem_add_cells_from_layout(nvmem);
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
- rval = nvmem_add_cells_from_layout(nvmem);
|
||||
+ dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
|
||||
+
|
||||
+ rval = device_add(&nvmem->dev);
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
From 6c7f48ea2e663b679aa8e60d8d8e1e6306a644f9 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Tue, 8 Aug 2023 08:29:27 +0200
|
||||
Subject: [PATCH] nvmem: core: Return NULL when no nvmem layout is found
|
||||
|
||||
Currently, of_nvmem_layout_get_container() returns NULL on error, or an
|
||||
error pointer if either CONFIG_NVMEM or CONFIG_OF is turned off. We
|
||||
should likely avoid this kind of mix for two reasons: to clarify the
|
||||
intend and anyway fix the !CONFIG_OF which will likely always if we use
|
||||
this helper somewhere else. Let's just return NULL when no layout is
|
||||
found, we don't need an error value here.
|
||||
|
||||
Link: https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
|
||||
Fixes: 266570f496b9 ("nvmem: core: introduce NVMEM layouts")
|
||||
Reported-by: kernel test robot <lkp@intel.com>
|
||||
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
|
||||
Closes: https://lore.kernel.org/r/202308030002.DnSFOrMB-lkp@intel.com/
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Reviewed-by: Michael Walle <michael@walle.cc>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
include/linux/nvmem-consumer.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/include/linux/nvmem-consumer.h
|
||||
+++ b/include/linux/nvmem-consumer.h
|
||||
@@ -256,7 +256,7 @@ static inline struct nvmem_device *of_nv
|
||||
static inline struct device_node *
|
||||
of_nvmem_layout_get_container(struct nvmem_device *nvmem)
|
||||
{
|
||||
- return ERR_PTR(-EOPNOTSUPP);
|
||||
+ return NULL;
|
||||
}
|
||||
#endif /* CONFIG_NVMEM && CONFIG_OF */
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From b8257f61b4ddac6d7d0e19a5a4e8b07afb3b4ed3 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Tue, 8 Aug 2023 08:29:28 +0200
|
||||
Subject: [PATCH] nvmem: core: Do not open-code existing functions
|
||||
|
||||
Use of_nvmem_layout_get_container() instead of hardcoding it.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Reviewed-by: Michael Walle <michael@walle.cc>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -786,10 +786,10 @@ EXPORT_SYMBOL_GPL(nvmem_layout_unregiste
|
||||
|
||||
static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem)
|
||||
{
|
||||
- struct device_node *layout_np, *np = nvmem->dev.of_node;
|
||||
+ struct device_node *layout_np;
|
||||
struct nvmem_layout *l, *layout = ERR_PTR(-EPROBE_DEFER);
|
||||
|
||||
- layout_np = of_get_child_by_name(np, "nvmem-layout");
|
||||
+ layout_np = of_nvmem_layout_get_container(nvmem);
|
||||
if (!layout_np)
|
||||
return NULL;
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
From 0991afbe4b1805e7f0113ef10d7c5f0698a739e4 Mon Sep 17 00:00:00 2001
|
||||
From: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Date: Tue, 8 Aug 2023 08:29:29 +0200
|
||||
Subject: [PATCH] nvmem: core: Notify when a new layout is registered
|
||||
|
||||
Tell listeners a new layout was introduced and is now available.
|
||||
|
||||
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
---
|
||||
drivers/nvmem/core.c | 4 ++++
|
||||
include/linux/nvmem-consumer.h | 2 ++
|
||||
2 files changed, 6 insertions(+)
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -772,12 +772,16 @@ int __nvmem_layout_register(struct nvmem
|
||||
list_add(&layout->node, &nvmem_layouts);
|
||||
spin_unlock(&nvmem_layout_lock);
|
||||
|
||||
+ blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_ADD, layout);
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__nvmem_layout_register);
|
||||
|
||||
void nvmem_layout_unregister(struct nvmem_layout *layout)
|
||||
{
|
||||
+ blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_REMOVE, layout);
|
||||
+
|
||||
spin_lock(&nvmem_layout_lock);
|
||||
list_del(&layout->node);
|
||||
spin_unlock(&nvmem_layout_lock);
|
||||
--- a/include/linux/nvmem-consumer.h
|
||||
+++ b/include/linux/nvmem-consumer.h
|
||||
@@ -43,6 +43,8 @@ enum {
|
||||
NVMEM_REMOVE,
|
||||
NVMEM_CELL_ADD,
|
||||
NVMEM_CELL_REMOVE,
|
||||
+ NVMEM_LAYOUT_ADD,
|
||||
+ NVMEM_LAYOUT_REMOVE,
|
||||
};
|
||||
|
||||
#if IS_ENABLED(CONFIG_NVMEM)
|
||||
@ -0,0 +1,28 @@
|
||||
From 414a98abbefd82d591f4e2d1efd2917bcd3b6f6d Mon Sep 17 00:00:00 2001
|
||||
From: Peng Fan <peng.fan@nxp.com>
|
||||
Date: Fri, 13 Oct 2023 13:49:02 +0100
|
||||
Subject: [PATCH] nvmem: imx: correct nregs for i.MX6SLL
|
||||
|
||||
The nregs for i.MX6SLL should be 80 per fuse map, correct it.
|
||||
|
||||
Fixes: 6da27821a6f5 ("nvmem: imx-ocotp: add support for imx6sll")
|
||||
Cc: Stable@vger.kernel.org
|
||||
Signed-off-by: Peng Fan <peng.fan@nxp.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231013124904.175782-2-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/imx-ocotp.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/nvmem/imx-ocotp.c
|
||||
+++ b/drivers/nvmem/imx-ocotp.c
|
||||
@@ -499,7 +499,7 @@ static const struct ocotp_params imx6sl_
|
||||
};
|
||||
|
||||
static const struct ocotp_params imx6sll_params = {
|
||||
- .nregs = 128,
|
||||
+ .nregs = 80,
|
||||
.bank_address_words = 0,
|
||||
.set_timing = imx_ocotp_set_imx6_timing,
|
||||
.ctrl = IMX_OCOTP_BM_CTRL_DEFAULT,
|
||||
@ -0,0 +1,28 @@
|
||||
From 7d6e10f5d254681983b53d979422c8de3fadbefb Mon Sep 17 00:00:00 2001
|
||||
From: Peng Fan <peng.fan@nxp.com>
|
||||
Date: Fri, 13 Oct 2023 13:49:03 +0100
|
||||
Subject: [PATCH] nvmem: imx: correct nregs for i.MX6UL
|
||||
|
||||
The nregs for i.MX6UL should be 144 per fuse map, correct it.
|
||||
|
||||
Fixes: 4aa2b4802046 ("nvmem: octop: Add support for imx6ul")
|
||||
Cc: Stable@vger.kernel.org
|
||||
Signed-off-by: Peng Fan <peng.fan@nxp.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231013124904.175782-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/imx-ocotp.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/nvmem/imx-ocotp.c
|
||||
+++ b/drivers/nvmem/imx-ocotp.c
|
||||
@@ -513,7 +513,7 @@ static const struct ocotp_params imx6sx_
|
||||
};
|
||||
|
||||
static const struct ocotp_params imx6ul_params = {
|
||||
- .nregs = 128,
|
||||
+ .nregs = 144,
|
||||
.bank_address_words = 0,
|
||||
.set_timing = imx_ocotp_set_imx6_timing,
|
||||
.ctrl = IMX_OCOTP_BM_CTRL_DEFAULT,
|
||||
@ -0,0 +1,28 @@
|
||||
From 2382c1b044231fd49eaf9aa82bc7113fc55487b8 Mon Sep 17 00:00:00 2001
|
||||
From: Peng Fan <peng.fan@nxp.com>
|
||||
Date: Fri, 13 Oct 2023 13:49:04 +0100
|
||||
Subject: [PATCH] nvmem: imx: correct nregs for i.MX6ULL
|
||||
|
||||
The nregs for i.MX6ULL should be 80 per fuse map, correct it.
|
||||
|
||||
Fixes: ffbc34bf0e9c ("nvmem: imx-ocotp: Implement i.MX6ULL/ULZ support")
|
||||
Cc: Stable@vger.kernel.org
|
||||
Signed-off-by: Peng Fan <peng.fan@nxp.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231013124904.175782-4-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/imx-ocotp.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/nvmem/imx-ocotp.c
|
||||
+++ b/drivers/nvmem/imx-ocotp.c
|
||||
@@ -520,7 +520,7 @@ static const struct ocotp_params imx6ul_
|
||||
};
|
||||
|
||||
static const struct ocotp_params imx6ull_params = {
|
||||
- .nregs = 64,
|
||||
+ .nregs = 80,
|
||||
.bank_address_words = 0,
|
||||
.set_timing = imx_ocotp_set_imx6_timing,
|
||||
.ctrl = IMX_OCOTP_BM_CTRL_DEFAULT,
|
||||
@ -0,0 +1,37 @@
|
||||
From 16724d6ea40a2c9315f5a0d81005dfa4d7a6da24 Mon Sep 17 00:00:00 2001
|
||||
From: Luca Weiss <luca.weiss@fairphone.com>
|
||||
Date: Fri, 20 Oct 2023 11:55:40 +0100
|
||||
Subject: [PATCH] nvmem: qfprom: Mark core clk as optional
|
||||
|
||||
On some platforms like sc7280 on non-ChromeOS devices the core clock
|
||||
cannot be touched by Linux so we cannot provide it. Mark it as optional
|
||||
as accessing qfprom for reading works without it but we still prohibit
|
||||
writing if we cannot provide the clock.
|
||||
|
||||
Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
|
||||
Reviewed-by: Douglas Anderson <dianders@chromium.org>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231020105545.216052-2-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/qfprom.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/qfprom.c
|
||||
+++ b/drivers/nvmem/qfprom.c
|
||||
@@ -423,12 +423,12 @@ static int qfprom_probe(struct platform_
|
||||
if (IS_ERR(priv->vcc))
|
||||
return PTR_ERR(priv->vcc);
|
||||
|
||||
- priv->secclk = devm_clk_get(dev, "core");
|
||||
+ priv->secclk = devm_clk_get_optional(dev, "core");
|
||||
if (IS_ERR(priv->secclk))
|
||||
return dev_err_probe(dev, PTR_ERR(priv->secclk), "Error getting clock\n");
|
||||
|
||||
- /* Only enable writing if we have SoC data. */
|
||||
- if (priv->soc_data)
|
||||
+ /* Only enable writing if we have SoC data and a valid clock */
|
||||
+ if (priv->soc_data && priv->secclk)
|
||||
econfig.reg_write = qfprom_reg_write;
|
||||
}
|
||||
|
||||
@ -0,0 +1,330 @@
|
||||
From 2cc3b37f5b6df8189d55d0e812d9658ce256dfec Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Fri, 20 Oct 2023 11:55:41 +0100
|
||||
Subject: [PATCH] nvmem: add explicit config option to read old syntax fixed OF
|
||||
cells
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Binding for fixed NVMEM cells defined directly as NVMEM device subnodes
|
||||
has been deprecated. It has been replaced by the "fixed-layout" NVMEM
|
||||
layout binding.
|
||||
|
||||
New syntax is meant to be clearer and should help avoiding imprecise
|
||||
bindings.
|
||||
|
||||
NVMEM subsystem already supports the new binding. It should be a good
|
||||
idea to limit support for old syntax to existing drivers that actually
|
||||
support & use it (we can't break backward compatibility!). That way we
|
||||
additionally encourage new bindings & drivers to ignore deprecated
|
||||
binding.
|
||||
|
||||
It wasn't clear (to me) if rtc and w1 code actually uses old syntax
|
||||
fixed cells. I enabled them to don't risk any breakage.
|
||||
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
[for meson-{efuse,mx-efuse}.c]
|
||||
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
|
||||
[for mtk-efuse.c, nvmem/core.c, nvmem-provider.h]
|
||||
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
[MT8192, MT8195 Chromebooks]
|
||||
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
|
||||
[for microchip-otpc.c]
|
||||
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
|
||||
[SAMA7G5-EK]
|
||||
Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com>
|
||||
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231020105545.216052-3-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/mtd/mtdcore.c | 2 ++
|
||||
drivers/nvmem/apple-efuses.c | 1 +
|
||||
drivers/nvmem/core.c | 8 +++++---
|
||||
drivers/nvmem/imx-ocotp-scu.c | 1 +
|
||||
drivers/nvmem/imx-ocotp.c | 1 +
|
||||
drivers/nvmem/meson-efuse.c | 1 +
|
||||
drivers/nvmem/meson-mx-efuse.c | 1 +
|
||||
drivers/nvmem/microchip-otpc.c | 1 +
|
||||
drivers/nvmem/mtk-efuse.c | 1 +
|
||||
drivers/nvmem/qcom-spmi-sdam.c | 1 +
|
||||
drivers/nvmem/qfprom.c | 1 +
|
||||
drivers/nvmem/rave-sp-eeprom.c | 1 +
|
||||
drivers/nvmem/rockchip-efuse.c | 1 +
|
||||
drivers/nvmem/sc27xx-efuse.c | 1 +
|
||||
drivers/nvmem/sec-qfprom.c | 1 +
|
||||
drivers/nvmem/sprd-efuse.c | 1 +
|
||||
drivers/nvmem/stm32-romem.c | 1 +
|
||||
drivers/nvmem/sunplus-ocotp.c | 1 +
|
||||
drivers/nvmem/sunxi_sid.c | 1 +
|
||||
drivers/nvmem/uniphier-efuse.c | 1 +
|
||||
drivers/nvmem/zynqmp_nvmem.c | 1 +
|
||||
drivers/rtc/nvmem.c | 1 +
|
||||
drivers/w1/slaves/w1_ds250x.c | 1 +
|
||||
include/linux/nvmem-provider.h | 2 ++
|
||||
24 files changed, 30 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -541,6 +541,7 @@ static int mtd_nvmem_add(struct mtd_info
|
||||
config.dev = &mtd->dev;
|
||||
config.name = dev_name(&mtd->dev);
|
||||
config.owner = THIS_MODULE;
|
||||
+ config.add_legacy_fixed_of_cells = of_device_is_compatible(node, "nvmem-cells");
|
||||
config.reg_read = mtd_nvmem_reg_read;
|
||||
config.size = mtd->size;
|
||||
config.word_size = 1;
|
||||
@@ -898,6 +899,7 @@ static struct nvmem_device *mtd_otp_nvme
|
||||
config.name = compatible;
|
||||
config.id = NVMEM_DEVID_AUTO;
|
||||
config.owner = THIS_MODULE;
|
||||
+ config.add_legacy_fixed_of_cells = true;
|
||||
config.type = NVMEM_TYPE_OTP;
|
||||
config.root_only = true;
|
||||
config.ignore_wp = true;
|
||||
--- a/drivers/nvmem/apple-efuses.c
|
||||
+++ b/drivers/nvmem/apple-efuses.c
|
||||
@@ -36,6 +36,7 @@ static int apple_efuses_probe(struct pla
|
||||
struct resource *res;
|
||||
struct nvmem_config config = {
|
||||
.dev = &pdev->dev,
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.read_only = true,
|
||||
.reg_read = apple_efuses_read,
|
||||
.stride = sizeof(u32),
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -998,9 +998,11 @@ struct nvmem_device *nvmem_register(cons
|
||||
if (rval)
|
||||
goto err_remove_cells;
|
||||
|
||||
- rval = nvmem_add_cells_from_legacy_of(nvmem);
|
||||
- if (rval)
|
||||
- goto err_remove_cells;
|
||||
+ if (config->add_legacy_fixed_of_cells) {
|
||||
+ rval = nvmem_add_cells_from_legacy_of(nvmem);
|
||||
+ if (rval)
|
||||
+ goto err_remove_cells;
|
||||
+ }
|
||||
|
||||
rval = nvmem_add_cells_from_fixed_layout(nvmem);
|
||||
if (rval)
|
||||
--- a/drivers/nvmem/imx-ocotp-scu.c
|
||||
+++ b/drivers/nvmem/imx-ocotp-scu.c
|
||||
@@ -220,6 +220,7 @@ static int imx_scu_ocotp_write(void *con
|
||||
|
||||
static struct nvmem_config imx_scu_ocotp_nvmem_config = {
|
||||
.name = "imx-scu-ocotp",
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.read_only = false,
|
||||
.word_size = 4,
|
||||
.stride = 1,
|
||||
--- a/drivers/nvmem/imx-ocotp.c
|
||||
+++ b/drivers/nvmem/imx-ocotp.c
|
||||
@@ -616,6 +616,7 @@ static int imx_ocotp_probe(struct platfo
|
||||
return PTR_ERR(priv->clk);
|
||||
|
||||
priv->params = of_device_get_match_data(&pdev->dev);
|
||||
+ imx_ocotp_nvmem_config.add_legacy_fixed_of_cells = true;
|
||||
imx_ocotp_nvmem_config.size = 4 * priv->params->nregs;
|
||||
imx_ocotp_nvmem_config.dev = dev;
|
||||
imx_ocotp_nvmem_config.priv = priv;
|
||||
--- a/drivers/nvmem/meson-efuse.c
|
||||
+++ b/drivers/nvmem/meson-efuse.c
|
||||
@@ -93,6 +93,7 @@ static int meson_efuse_probe(struct plat
|
||||
|
||||
econfig->dev = dev;
|
||||
econfig->name = dev_name(dev);
|
||||
+ econfig->add_legacy_fixed_of_cells = true;
|
||||
econfig->stride = 1;
|
||||
econfig->word_size = 1;
|
||||
econfig->reg_read = meson_efuse_read;
|
||||
--- a/drivers/nvmem/meson-mx-efuse.c
|
||||
+++ b/drivers/nvmem/meson-mx-efuse.c
|
||||
@@ -211,6 +211,7 @@ static int meson_mx_efuse_probe(struct p
|
||||
efuse->config.owner = THIS_MODULE;
|
||||
efuse->config.dev = &pdev->dev;
|
||||
efuse->config.priv = efuse;
|
||||
+ efuse->config.add_legacy_fixed_of_cells = true;
|
||||
efuse->config.stride = drvdata->word_size;
|
||||
efuse->config.word_size = drvdata->word_size;
|
||||
efuse->config.size = SZ_512;
|
||||
--- a/drivers/nvmem/microchip-otpc.c
|
||||
+++ b/drivers/nvmem/microchip-otpc.c
|
||||
@@ -261,6 +261,7 @@ static int mchp_otpc_probe(struct platfo
|
||||
return ret;
|
||||
|
||||
mchp_nvmem_config.dev = otpc->dev;
|
||||
+ mchp_nvmem_config.add_legacy_fixed_of_cells = true;
|
||||
mchp_nvmem_config.size = size;
|
||||
mchp_nvmem_config.priv = otpc;
|
||||
nvmem = devm_nvmem_register(&pdev->dev, &mchp_nvmem_config);
|
||||
--- a/drivers/nvmem/mtk-efuse.c
|
||||
+++ b/drivers/nvmem/mtk-efuse.c
|
||||
@@ -83,6 +83,7 @@ static int mtk_efuse_probe(struct platfo
|
||||
return PTR_ERR(priv->base);
|
||||
|
||||
pdata = device_get_match_data(dev);
|
||||
+ econfig.add_legacy_fixed_of_cells = true;
|
||||
econfig.stride = 1;
|
||||
econfig.word_size = 1;
|
||||
econfig.reg_read = mtk_reg_read;
|
||||
--- a/drivers/nvmem/qcom-spmi-sdam.c
|
||||
+++ b/drivers/nvmem/qcom-spmi-sdam.c
|
||||
@@ -142,6 +142,7 @@ static int sdam_probe(struct platform_de
|
||||
sdam->sdam_config.name = "spmi_sdam";
|
||||
sdam->sdam_config.id = NVMEM_DEVID_AUTO;
|
||||
sdam->sdam_config.owner = THIS_MODULE;
|
||||
+ sdam->sdam_config.add_legacy_fixed_of_cells = true;
|
||||
sdam->sdam_config.stride = 1;
|
||||
sdam->sdam_config.word_size = 1;
|
||||
sdam->sdam_config.reg_read = sdam_read;
|
||||
--- a/drivers/nvmem/qfprom.c
|
||||
+++ b/drivers/nvmem/qfprom.c
|
||||
@@ -357,6 +357,7 @@ static int qfprom_probe(struct platform_
|
||||
{
|
||||
struct nvmem_config econfig = {
|
||||
.name = "qfprom",
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.stride = 1,
|
||||
.word_size = 1,
|
||||
.id = NVMEM_DEVID_AUTO,
|
||||
--- a/drivers/nvmem/rave-sp-eeprom.c
|
||||
+++ b/drivers/nvmem/rave-sp-eeprom.c
|
||||
@@ -328,6 +328,7 @@ static int rave_sp_eeprom_probe(struct p
|
||||
of_property_read_string(np, "zii,eeprom-name", &config.name);
|
||||
config.priv = eeprom;
|
||||
config.dev = dev;
|
||||
+ config.add_legacy_fixed_of_cells = true;
|
||||
config.size = size;
|
||||
config.reg_read = rave_sp_eeprom_reg_read;
|
||||
config.reg_write = rave_sp_eeprom_reg_write;
|
||||
--- a/drivers/nvmem/rockchip-efuse.c
|
||||
+++ b/drivers/nvmem/rockchip-efuse.c
|
||||
@@ -205,6 +205,7 @@ static int rockchip_rk3399_efuse_read(vo
|
||||
|
||||
static struct nvmem_config econfig = {
|
||||
.name = "rockchip-efuse",
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.stride = 1,
|
||||
.word_size = 1,
|
||||
.read_only = true,
|
||||
--- a/drivers/nvmem/sc27xx-efuse.c
|
||||
+++ b/drivers/nvmem/sc27xx-efuse.c
|
||||
@@ -248,6 +248,7 @@ static int sc27xx_efuse_probe(struct pla
|
||||
econfig.reg_read = sc27xx_efuse_read;
|
||||
econfig.priv = efuse;
|
||||
econfig.dev = &pdev->dev;
|
||||
+ econfig.add_legacy_fixed_of_cells = true;
|
||||
nvmem = devm_nvmem_register(&pdev->dev, &econfig);
|
||||
if (IS_ERR(nvmem)) {
|
||||
dev_err(&pdev->dev, "failed to register nvmem config\n");
|
||||
--- a/drivers/nvmem/sec-qfprom.c
|
||||
+++ b/drivers/nvmem/sec-qfprom.c
|
||||
@@ -47,6 +47,7 @@ static int sec_qfprom_probe(struct platf
|
||||
{
|
||||
struct nvmem_config econfig = {
|
||||
.name = "sec-qfprom",
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.stride = 1,
|
||||
.word_size = 1,
|
||||
.id = NVMEM_DEVID_AUTO,
|
||||
--- a/drivers/nvmem/sprd-efuse.c
|
||||
+++ b/drivers/nvmem/sprd-efuse.c
|
||||
@@ -408,6 +408,7 @@ static int sprd_efuse_probe(struct platf
|
||||
econfig.read_only = false;
|
||||
econfig.name = "sprd-efuse";
|
||||
econfig.size = efuse->data->blk_nums * SPRD_EFUSE_BLOCK_WIDTH;
|
||||
+ econfig.add_legacy_fixed_of_cells = true;
|
||||
econfig.reg_read = sprd_efuse_read;
|
||||
econfig.reg_write = sprd_efuse_write;
|
||||
econfig.priv = efuse;
|
||||
--- a/drivers/nvmem/stm32-romem.c
|
||||
+++ b/drivers/nvmem/stm32-romem.c
|
||||
@@ -207,6 +207,7 @@ static int stm32_romem_probe(struct plat
|
||||
priv->cfg.priv = priv;
|
||||
priv->cfg.owner = THIS_MODULE;
|
||||
priv->cfg.type = NVMEM_TYPE_OTP;
|
||||
+ priv->cfg.add_legacy_fixed_of_cells = true;
|
||||
|
||||
priv->lower = 0;
|
||||
|
||||
--- a/drivers/nvmem/sunplus-ocotp.c
|
||||
+++ b/drivers/nvmem/sunplus-ocotp.c
|
||||
@@ -145,6 +145,7 @@ disable_clk:
|
||||
|
||||
static struct nvmem_config sp_ocotp_nvmem_config = {
|
||||
.name = "sp-ocotp",
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.read_only = true,
|
||||
.word_size = 1,
|
||||
.size = QAC628_OTP_SIZE,
|
||||
--- a/drivers/nvmem/sunxi_sid.c
|
||||
+++ b/drivers/nvmem/sunxi_sid.c
|
||||
@@ -154,6 +154,7 @@ static int sunxi_sid_probe(struct platfo
|
||||
nvmem_cfg->dev = dev;
|
||||
nvmem_cfg->name = "sunxi-sid";
|
||||
nvmem_cfg->type = NVMEM_TYPE_OTP;
|
||||
+ nvmem_cfg->add_legacy_fixed_of_cells = true;
|
||||
nvmem_cfg->read_only = true;
|
||||
nvmem_cfg->size = cfg->size;
|
||||
nvmem_cfg->word_size = 1;
|
||||
--- a/drivers/nvmem/uniphier-efuse.c
|
||||
+++ b/drivers/nvmem/uniphier-efuse.c
|
||||
@@ -52,6 +52,7 @@ static int uniphier_efuse_probe(struct p
|
||||
econfig.size = resource_size(res);
|
||||
econfig.priv = priv;
|
||||
econfig.dev = dev;
|
||||
+ econfig.add_legacy_fixed_of_cells = true;
|
||||
nvmem = devm_nvmem_register(dev, &econfig);
|
||||
|
||||
return PTR_ERR_OR_ZERO(nvmem);
|
||||
--- a/drivers/nvmem/zynqmp_nvmem.c
|
||||
+++ b/drivers/nvmem/zynqmp_nvmem.c
|
||||
@@ -58,6 +58,7 @@ static int zynqmp_nvmem_probe(struct pla
|
||||
|
||||
priv->dev = dev;
|
||||
econfig.dev = dev;
|
||||
+ econfig.add_legacy_fixed_of_cells = true;
|
||||
econfig.reg_read = zynqmp_nvmem_read;
|
||||
econfig.priv = priv;
|
||||
|
||||
--- a/drivers/rtc/nvmem.c
|
||||
+++ b/drivers/rtc/nvmem.c
|
||||
@@ -21,6 +21,7 @@ int devm_rtc_nvmem_register(struct rtc_d
|
||||
|
||||
nvmem_config->dev = dev;
|
||||
nvmem_config->owner = rtc->owner;
|
||||
+ nvmem_config->add_legacy_fixed_of_cells = true;
|
||||
nvmem = devm_nvmem_register(dev, nvmem_config);
|
||||
if (IS_ERR(nvmem))
|
||||
dev_err(dev, "failed to register nvmem device for RTC\n");
|
||||
--- a/drivers/w1/slaves/w1_ds250x.c
|
||||
+++ b/drivers/w1/slaves/w1_ds250x.c
|
||||
@@ -168,6 +168,7 @@ static int w1_eprom_add_slave(struct w1_
|
||||
struct nvmem_device *nvmem;
|
||||
struct nvmem_config nvmem_cfg = {
|
||||
.dev = &sl->dev,
|
||||
+ .add_legacy_fixed_of_cells = true,
|
||||
.reg_read = w1_nvmem_read,
|
||||
.type = NVMEM_TYPE_OTP,
|
||||
.read_only = true,
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -82,6 +82,7 @@ struct nvmem_cell_info {
|
||||
* @owner: Pointer to exporter module. Used for refcounting.
|
||||
* @cells: Optional array of pre-defined NVMEM cells.
|
||||
* @ncells: Number of elements in cells.
|
||||
+ * @add_legacy_fixed_of_cells: Read fixed NVMEM cells from old OF syntax.
|
||||
* @keepout: Optional array of keepout ranges (sorted ascending by start).
|
||||
* @nkeepout: Number of elements in the keepout array.
|
||||
* @type: Type of the nvmem storage
|
||||
@@ -112,6 +113,7 @@ struct nvmem_config {
|
||||
struct module *owner;
|
||||
const struct nvmem_cell_info *cells;
|
||||
int ncells;
|
||||
+ bool add_legacy_fixed_of_cells;
|
||||
const struct nvmem_keepout *keepout;
|
||||
unsigned int nkeepout;
|
||||
enum nvmem_type type;
|
||||
@ -0,0 +1,77 @@
|
||||
From 0720219f4d34a88a9badb4de70cfad7585687d48 Mon Sep 17 00:00:00 2001
|
||||
From: Rob Herring <robh@kernel.org>
|
||||
Date: Fri, 20 Oct 2023 11:55:45 +0100
|
||||
Subject: [PATCH] nvmem: Use device_get_match_data()
|
||||
|
||||
Use preferred device_get_match_data() instead of of_match_device() to
|
||||
get the driver match data. With this, adjust the includes to explicitly
|
||||
include the correct headers.
|
||||
|
||||
Signed-off-by: Rob Herring <robh@kernel.org>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231020105545.216052-7-srinivas.kandagatla@linaro.org
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/nvmem/mxs-ocotp.c | 10 ++++------
|
||||
drivers/nvmem/stm32-romem.c | 7 ++++---
|
||||
2 files changed, 8 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/nvmem/mxs-ocotp.c
|
||||
+++ b/drivers/nvmem/mxs-ocotp.c
|
||||
@@ -13,8 +13,9 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/nvmem-provider.h>
|
||||
-#include <linux/of_device.h>
|
||||
+#include <linux/of.h>
|
||||
#include <linux/platform_device.h>
|
||||
+#include <linux/property.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/stmp_device.h>
|
||||
|
||||
@@ -140,11 +141,10 @@ static int mxs_ocotp_probe(struct platfo
|
||||
struct device *dev = &pdev->dev;
|
||||
const struct mxs_data *data;
|
||||
struct mxs_ocotp *otp;
|
||||
- const struct of_device_id *match;
|
||||
int ret;
|
||||
|
||||
- match = of_match_device(dev->driver->of_match_table, dev);
|
||||
- if (!match || !match->data)
|
||||
+ data = device_get_match_data(dev);
|
||||
+ if (!data)
|
||||
return -EINVAL;
|
||||
|
||||
otp = devm_kzalloc(dev, sizeof(*otp), GFP_KERNEL);
|
||||
@@ -169,8 +169,6 @@ static int mxs_ocotp_probe(struct platfo
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
- data = match->data;
|
||||
-
|
||||
ocotp_config.size = data->size;
|
||||
ocotp_config.priv = otp;
|
||||
ocotp_config.dev = dev;
|
||||
--- a/drivers/nvmem/stm32-romem.c
|
||||
+++ b/drivers/nvmem/stm32-romem.c
|
||||
@@ -10,7 +10,9 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/nvmem-provider.h>
|
||||
-#include <linux/of_device.h>
|
||||
+#include <linux/of.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/property.h>
|
||||
#include <linux/tee_drv.h>
|
||||
|
||||
#include "stm32-bsec-optee-ta.h"
|
||||
@@ -211,8 +213,7 @@ static int stm32_romem_probe(struct plat
|
||||
|
||||
priv->lower = 0;
|
||||
|
||||
- cfg = (const struct stm32_romem_cfg *)
|
||||
- of_match_device(dev->driver->of_match_table, dev)->data;
|
||||
+ cfg = device_get_match_data(dev);
|
||||
if (!cfg) {
|
||||
priv->cfg.read_only = true;
|
||||
priv->cfg.size = resource_size(res);
|
||||
@ -0,0 +1,77 @@
|
||||
From f4cf4e5db331a5ce69e3f0b21d322cac0f4e4b5d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Mon, 23 Oct 2023 12:27:59 +0200
|
||||
Subject: [PATCH] Revert "nvmem: add new config option"
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This reverts commit 517f14d9cf3533d5ab4fded195ab6f80a92e378f.
|
||||
|
||||
Config option "no_of_node" is no longer needed since adding a more
|
||||
explicit and targeted option "add_legacy_fixed_of_cells".
|
||||
|
||||
That "no_of_node" config option was needed *earlier* to help mtd's case.
|
||||
|
||||
DT nodes of MTD partitions (that are also NVMEM devices) may contain
|
||||
subnodes. Those SHOULD NOT be treated as NVMEM fixed cells.
|
||||
|
||||
To prevent NVMEM core code from parsing subnodes a "no_of_node" option
|
||||
was added (and set to true in mtd) to make for_each_child_of_node() in
|
||||
NVMEM a no-op. That was a bit hacky because it was messing with
|
||||
"of_node" pointer to achieve some side-effect.
|
||||
|
||||
With the introduction of "add_legacy_fixed_of_cells" config option
|
||||
things got more explicit. MTD subsystem simply tells NVMEM when to look
|
||||
for fixed cells and there is no need to hack "of_node" pointer anymore.
|
||||
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
|
||||
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
||||
Link: https://lore.kernel.org/r/20231023102759.31529-1-zajec5@gmail.com
|
||||
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
||||
---
|
||||
drivers/mtd/mtdcore.c | 1 -
|
||||
drivers/nvmem/core.c | 2 +-
|
||||
include/linux/nvmem-provider.h | 2 --
|
||||
3 files changed, 1 insertion(+), 4 deletions(-)
|
||||
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -549,7 +549,6 @@ static int mtd_nvmem_add(struct mtd_info
|
||||
config.read_only = true;
|
||||
config.root_only = true;
|
||||
config.ignore_wp = true;
|
||||
- config.no_of_node = !of_device_is_compatible(node, "nvmem-cells");
|
||||
config.priv = mtd;
|
||||
|
||||
mtd->nvmem = nvmem_register(&config);
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -936,7 +936,7 @@ struct nvmem_device *nvmem_register(cons
|
||||
nvmem->nkeepout = config->nkeepout;
|
||||
if (config->of_node)
|
||||
nvmem->dev.of_node = config->of_node;
|
||||
- else if (!config->no_of_node)
|
||||
+ else
|
||||
nvmem->dev.of_node = config->dev->of_node;
|
||||
|
||||
switch (config->id) {
|
||||
--- a/include/linux/nvmem-provider.h
|
||||
+++ b/include/linux/nvmem-provider.h
|
||||
@@ -89,7 +89,6 @@ struct nvmem_cell_info {
|
||||
* @read_only: Device is read-only.
|
||||
* @root_only: Device is accessibly to root only.
|
||||
* @of_node: If given, this will be used instead of the parent's of_node.
|
||||
- * @no_of_node: Device should not use the parent's of_node even if it's !NULL.
|
||||
* @reg_read: Callback to read data.
|
||||
* @reg_write: Callback to write data.
|
||||
* @size: Device size.
|
||||
@@ -122,7 +121,6 @@ struct nvmem_config {
|
||||
bool ignore_wp;
|
||||
struct nvmem_layout *layout;
|
||||
struct device_node *of_node;
|
||||
- bool no_of_node;
|
||||
nvmem_reg_read_t reg_read;
|
||||
nvmem_reg_write_t reg_write;
|
||||
int size;
|
||||
@ -77,7 +77,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
#include "mtdcore.h"
|
||||
|
||||
@@ -1082,6 +1083,8 @@ int mtd_device_parse_register(struct mtd
|
||||
@@ -1106,6 +1107,8 @@ int mtd_device_parse_register(struct mtd
|
||||
register_reboot_notifier(&mtd->reboot_notifier);
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -761,7 +761,8 @@ int add_mtd_device(struct mtd_info *mtd)
|
||||
@@ -784,7 +784,8 @@ int add_mtd_device(struct mtd_info *mtd)
|
||||
|
||||
mutex_unlock(&mtd_table_mutex);
|
||||
|
||||
|
||||
@ -0,0 +1,48 @@
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Tue, 31 Oct 2023 15:51:01 +0100
|
||||
Subject: [PATCH] mtd: don't register NVMEM devices for partitions with custom
|
||||
drivers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This fixes issue exposed by upstream commit f4cf4e5db331 ("Revert
|
||||
"nvmem: add new config option"").
|
||||
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
---
|
||||
drivers/mtd/mtdcore.c | 23 +++++++++++++++++++++++
|
||||
1 file changed, 23 insertions(+)
|
||||
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -537,6 +537,29 @@ static int mtd_nvmem_add(struct mtd_info
|
||||
struct device_node *node = mtd_get_of_node(mtd);
|
||||
struct nvmem_config config = {};
|
||||
|
||||
+ /*
|
||||
+ * Do NOT register NVMEM device for any partition that is meant to be
|
||||
+ * handled by a U-Boot env driver. That would result in associating two
|
||||
+ * different NVMEM devices with the same OF node.
|
||||
+ *
|
||||
+ * An example of unwanted behaviour of above (forwardtrace):
|
||||
+ * of_get_mac_addr_nvmem()
|
||||
+ * of_nvmem_cell_get()
|
||||
+ * __nvmem_device_get()
|
||||
+ *
|
||||
+ * We can't have __nvmem_device_get() return "mtdX" NVMEM device instead
|
||||
+ * of U-Boot env NVMEM device. That would result in failing to find
|
||||
+ * NVMEM cell.
|
||||
+ *
|
||||
+ * This issue seems to affect U-Boot env case only and will go away with
|
||||
+ * switch to NVMEM layouts.
|
||||
+ */
|
||||
+ if (of_device_is_compatible(node, "u-boot,env") ||
|
||||
+ of_device_is_compatible(node, "u-boot,env-redundant-bool") ||
|
||||
+ of_device_is_compatible(node, "u-boot,env-redundant-count") ||
|
||||
+ of_device_is_compatible(node, "brcm,env"))
|
||||
+ return 0;
|
||||
+
|
||||
config.id = -1;
|
||||
config.dev = &mtd->dev;
|
||||
config.name = dev_name(&mtd->dev);
|
||||
@ -0,0 +1,40 @@
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Thu, 13 Jul 2023 17:30:59 +0200
|
||||
Subject: [PATCH] nvmem: core: fix support for fixed cells NVMEM layout
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Returning -EPROBE_DEFER for "fixed-layout" makes nvmem_register() always
|
||||
fail (that layout is supported internally with no external module). That
|
||||
makes callers (e.g. mtd_nvmem_add()) fail as well and prevents booting
|
||||
on devices with "fixed-layout" in DT.
|
||||
|
||||
Add a quick workaround for it.
|
||||
|
||||
Fixes: 6468a6f45148 ("nvmem: core: handle the absence of expected layouts")
|
||||
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
||||
---
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -798,6 +798,19 @@ static struct nvmem_layout *nvmem_layout
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
+ * We should return -EPROBE_DEFER only when layout driver is expected to
|
||||
+ * become available later. Otherwise NVMEM will never probe successfully
|
||||
+ * for unsupported layouts. There is no known solution for that right
|
||||
+ * now.
|
||||
+ *
|
||||
+ * This problem also affects "fixed-layout". It's supported in NVMEM
|
||||
+ * core code so there never will be layout for it. We shouldn't return
|
||||
+ * -EPROBE_DEFER in such case. Add a quick workaround for that.
|
||||
+ */
|
||||
+ if (of_device_is_compatible(layout_np, "fixed-layout"))
|
||||
+ return NULL;
|
||||
+
|
||||
+ /*
|
||||
* In case the nvmem device was built-in while the layout was built as a
|
||||
* module, we shall manually request the layout driver loading otherwise
|
||||
* we'll never have any match.
|
||||
@ -0,0 +1,93 @@
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
||||
Date: Thu, 13 Jul 2023 18:29:19 +0200
|
||||
Subject: [PATCH] nvmem: core: support "mac-base" fixed layout cells
|
||||
|
||||
Fixed layout binding allows specifying "mac-base" NVMEM cells. It's used
|
||||
for base MAC address (that can be used for calculating relative
|
||||
addresses). It can be stored in a raw binary format or as an ASCII
|
||||
string.
|
||||
---
|
||||
|
||||
--- a/drivers/nvmem/Kconfig
|
||||
+++ b/drivers/nvmem/Kconfig
|
||||
@@ -1,6 +1,7 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
menuconfig NVMEM
|
||||
bool "NVMEM Support"
|
||||
+ select GENERIC_NET_UTILS
|
||||
help
|
||||
Support for NVMEM(Non Volatile Memory) devices like EEPROM, EFUSES...
|
||||
|
||||
--- a/drivers/nvmem/core.c
|
||||
+++ b/drivers/nvmem/core.c
|
||||
@@ -7,9 +7,11 @@
|
||||
*/
|
||||
|
||||
#include <linux/device.h>
|
||||
+#include <linux/etherdevice.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/idr.h>
|
||||
+#include <linux/if_ether.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kref.h>
|
||||
#include <linux/module.h>
|
||||
@@ -696,6 +698,37 @@ static int nvmem_validate_keepouts(struc
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static int nvmem_mac_base_raw_read(void *context, const char *id, int index, unsigned int offset,
|
||||
+ void *buf, size_t bytes)
|
||||
+{
|
||||
+ if (WARN_ON(bytes != ETH_ALEN))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (index)
|
||||
+ eth_addr_add(buf, index);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int nvmem_mac_base_ascii_read(void *context, const char *id, int index, unsigned int offset,
|
||||
+ void *buf, size_t bytes)
|
||||
+{
|
||||
+ u8 mac[ETH_ALEN];
|
||||
+
|
||||
+ if (WARN_ON(bytes != 3 * ETH_ALEN - 1))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (!mac_pton(buf, mac))
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ if (index)
|
||||
+ eth_addr_add(mac, index);
|
||||
+
|
||||
+ ether_addr_copy(buf, mac);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np)
|
||||
{
|
||||
struct nvmem_layout *layout = nvmem->layout;
|
||||
@@ -731,6 +764,20 @@ static int nvmem_add_cells_from_dt(struc
|
||||
if (layout && layout->fixup_cell_info)
|
||||
layout->fixup_cell_info(nvmem, layout, &info);
|
||||
|
||||
+ if (of_device_is_compatible(np, "fixed-layout")) {
|
||||
+ if (of_device_is_compatible(child, "mac-base")) {
|
||||
+ if (info.bytes == 6) {
|
||||
+ info.raw_len = info.bytes;
|
||||
+ info.bytes = ETH_ALEN;
|
||||
+ info.read_post_process = nvmem_mac_base_raw_read;
|
||||
+ } else if (info.bytes == 3 * ETH_ALEN - 1) {
|
||||
+ info.raw_len = info.bytes;
|
||||
+ info.bytes = ETH_ALEN;
|
||||
+ info.read_post_process = nvmem_mac_base_ascii_read;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
ret = nvmem_add_one_cell(nvmem, &info);
|
||||
kfree(info.name);
|
||||
if (ret) {
|
||||
@ -308,6 +308,7 @@ CONFIG_NO_HZ_IDLE=y
|
||||
CONFIG_NR_CPUS=4
|
||||
CONFIG_NVMEM=y
|
||||
CONFIG_NVMEM_QCOM_QFPROM=y
|
||||
# CONFIG_NVMEM_QCOM_SEC_QFPROM is not set
|
||||
# CONFIG_NVMEM_SPMI_SDAM is not set
|
||||
CONFIG_NVMEM_SYSFS=y
|
||||
CONFIG_OF=y
|
||||
|
||||
@ -302,6 +302,7 @@ CONFIG_NO_HZ_IDLE=y
|
||||
CONFIG_NR_CPUS=2
|
||||
CONFIG_NVMEM=y
|
||||
CONFIG_NVMEM_QCOM_QFPROM=y
|
||||
# CONFIG_NVMEM_QCOM_SEC_QFPROM is not set
|
||||
# CONFIG_NVMEM_SPMI_SDAM is not set
|
||||
CONFIG_NVMEM_SYSFS=y
|
||||
CONFIG_OF=y
|
||||
|
||||
@ -256,6 +256,7 @@ CONFIG_NR_CPUS=4
|
||||
CONFIG_NVIDIA_CARMEL_CNP_ERRATUM=y
|
||||
CONFIG_NVMEM=y
|
||||
CONFIG_NVMEM_QCOM_QFPROM=y
|
||||
# CONFIG_NVMEM_QCOM_SEC_QFPROM is not set
|
||||
# CONFIG_NVMEM_SPMI_SDAM is not set
|
||||
CONFIG_NVMEM_SYSFS=y
|
||||
CONFIG_NVMEM_U_BOOT_ENV=y
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
compatible = "glinet,gl-mt3000", "mediatek,mt7981";
|
||||
|
||||
aliases {
|
||||
label-mac-device = &gmac0;
|
||||
led-boot = &led_lightblue;
|
||||
led-failsafe = &led_lightblue;
|
||||
led-running = &led_white;
|
||||
|
||||
@ -152,6 +152,7 @@ CONFIG_NLS=y
|
||||
CONFIG_NR_CPUS=1
|
||||
CONFIG_NR_IRQS=512
|
||||
CONFIG_NVMEM=y
|
||||
# CONFIG_NVMEM_QORIQ_EFUSE is not set
|
||||
CONFIG_OF=y
|
||||
CONFIG_OF_ADDRESS=y
|
||||
CONFIG_OF_DMA_DEFAULT_COHERENT=y
|
||||
|
||||
@ -34,7 +34,7 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
|
||||
mtd->type = MTD_NORFLASH;
|
||||
--- a/drivers/mtd/mtdcore.c
|
||||
+++ b/drivers/mtd/mtdcore.c
|
||||
@@ -847,6 +847,17 @@ out_error:
|
||||
@@ -870,6 +870,17 @@ out_error:
|
||||
*/
|
||||
static void mtd_set_dev_defaults(struct mtd_info *mtd)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user