ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/utils/lm-sensors/Makefile b/external/subpack/utils/lm-sensors/Makefile
new file mode 100644
index 0000000..ee81b6c
--- /dev/null
+++ b/external/subpack/utils/lm-sensors/Makefile
@@ -0,0 +1,128 @@
+#
+# Copyright (C) 2006-2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=lm-sensors
+PKG_VERSION:=3.6.0
+PKG_RELEASE:=1
+
+PKG_VERSION_SUBST=$(subst .,-,$(PKG_VERSION))
+PKG_SOURCE_URL:=https://codeload.github.com/lm-sensors/lm-sensors/tar.gz/V$(PKG_VERSION_SUBST)?
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_HASH:=0591f9fa0339f0d15e75326d0365871c2d4e2ed8aa1ff759b3a55d3734b7d197
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION_SUBST)
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_LICENSE:=GPL-2.0-or-later LGPL-2.1-or-later
+PKG_CPE_ID:=cpe:/a:lm_sensors:lm_sensors
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/lm-sensors/Default
+  DEPENDS:=+sysfsutils
+  URL:=https://hwmon.wiki.kernel.org/lm_sensors
+endef
+
+define Package/lm-sensors
+  $(call Package/lm-sensors/Default)
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=lm-sensors
+  DEPENDS+=+libsensors
+endef
+
+define Package/lm-sensors-detect
+  $(call Package/lm-sensors/Default)
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=lm-sensors-detect
+  DEPENDS+=+lm-sensors \
+	+PACKAGE_lm-sensors-detect:perl \
+	+PACKAGE_lm-sensors-detect:perlbase-essential \
+	+PACKAGE_lm-sensors-detect:perlbase-fcntl \
+	+PACKAGE_lm-sensors-detect:perlbase-file \
+	+PACKAGE_lm-sensors-detect:perlbase-xsloader
+endef
+
+define Package/libsensors
+  $(call Package/lm-sensors/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=libsensors
+  ABI_VERSION:=5
+endef
+
+define Package/lm-sensors/description
+ utility to read hardware sensor data
+endef
+
+define Package/lm-sensors-detect/description
+ script to autodetect sensor hardware
+endef
+
+define Package/libsensors/description
+ lm-sensors libraries
+endef
+
+define Package/lm-sensors/conffiles
+/etc/sensors.conf
+/etc/sensors3.conf
+endef
+
+define Build/Compile
+	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+		$(TARGET_CONFIGURE_OPTS) \
+		KERNELVERSION="$(LINUX_VERSION)" \
+		LINUX="$(LINUX_DIR)" \
+		CC="$(TARGET_CC)" \
+		CFLAGS="$(TARGET_CFLAGS)" \
+		CPPFLAGS="$(TARGET_CPPFLAGS)" \
+		STAGING_DIR="$(STAGING_DIR)" \
+		PREFIX="/usr" \
+		MACHINE="$(ARCH)" \
+		EXLDFLAGS="" \
+		user
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/sensors
+	$(CP) \
+		$(PKG_BUILD_DIR)/lib/sensors.h \
+		$(1)/usr/include/sensors
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_BUILD_DIR)/lib/libsensors.{a,so*} \
+		$(1)/usr/lib
+endef
+
+define Package/lm-sensors/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/prog/sensors/sensors $(1)/usr/sbin
+ifeq ($(ARCH),i386)
+	$(INSTALL_DIR) $(1)/etc
+	$(INSTALL_CONF) ./files/sensors.conf $(1)/etc/sensors.conf
+endif
+	$(INSTALL_DIR) $(1)/etc/init.d
+	$(INSTALL_BIN) ./files/lm-sensors.init $(1)/etc/init.d/lm-sensors
+endef
+
+define Package/lm-sensors-detect/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/prog/detect/sensors-detect $(1)/usr/sbin
+endef
+
+define Package/libsensors/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/lib/libsensors.so* $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,libsensors))
+$(eval $(call BuildPackage,lm-sensors))
+$(eval $(call BuildPackage,lm-sensors-detect))
diff --git a/external/subpack/utils/lm-sensors/files/lm-sensors.init b/external/subpack/utils/lm-sensors/files/lm-sensors.init
new file mode 100644
index 0000000..5ac7a72
--- /dev/null
+++ b/external/subpack/utils/lm-sensors/files/lm-sensors.init
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2017 Philip Prindeville, Redfish Solutions LLC
+
+START=28
+STOP=
+
+PROG=/usr/sbin/sensors
+
+start() {
+	[ -f /etc/sensors.conf -o -f /etc/sensors3.conf ] || return
+
+	$PROG -s
+}
+
diff --git a/external/subpack/utils/lm-sensors/files/sensors.conf b/external/subpack/utils/lm-sensors/files/sensors.conf
new file mode 100644
index 0000000..505b9d9
--- /dev/null
+++ b/external/subpack/utils/lm-sensors/files/sensors.conf
@@ -0,0 +1,117 @@
+chip "pc87366-*"
+
+# Soekris net4801 configuration
+
+# Written by Henrik Brix Andersen <henrik@brixandersen.dk>
+# Latest version can be found at http://www.brixandersen.dk/
+
+# The configuration is partly based on the PC87366 datasheet and
+# partly borrowed from the env4801 utility by Poul-Henning
+# Kamp <phk@phk.freebsd.dk>
+
+# Datasheet: http://www.winbond.com/PDF/APCsheet/PC87366.pdf
+# env4801:   http://phk.freebsd.dk/soekris/env4801/
+
+
+# Voltage inputs
+  ignore vid
+
+  # Unknown
+  # label in0     "avi0"
+  ignore in0
+
+
+  # Core Voltage, +2.0V
+  label in1     "VCORE"
+  set in1_min   1.9
+  set in1_max   2.1
+
+
+  # VCC, +5.0V
+  label in2     "VCC"
+  compute in2   @*2, @/2
+
+
+  # Power Supply Input, +6.0V - +28.0V
+  label in3     "VPWR"
+  compute in3   @*20.1, @/20.1
+  set in3_min    6.0
+  set in3_max   28.0
+
+
+  # +12V
+  label in4     "+12V"
+  compute in4   @*4.83, @/4.83
+  set in4_min   11
+  set in4_max   13
+
+
+  # -12V
+  label in5     "-12V"
+  # If in10 on your net4801 doesn't have the 3.3V reference, use this
+  # compute line instead:
+  # compute in5   (@-3.3)*19.2+3.3, (@-3.3)/19.2+3.3
+  compute in5   (@-in10)*19.2+in10, (@-in10)/19.2+in10
+  set in5_min   -13
+  set in5_max   -11
+
+
+  # GND, 0V
+  label in6     "GND"
+  set in6_min   0
+  set in6_max   0
+
+
+  # Standby Voltage, +3.3V
+  # Internally divided by 2
+  label in7     "Vsb"
+  compute in7   @*2, @/2
+  set in7_min    3.0
+  set in7_max    3.6
+
+
+  # Supply Voltage, +3.3V
+  # Internally divided by 2
+  label in8     "Vdd"
+  compute in8   @*2, @/2
+  set in8_min    3.0
+  set in8_max    3.6
+
+
+  # Battery Backup Supply Voltage, +3.0V
+  label in9     "Vbat"
+  set in9_min    2.4
+  set in9_max    3.6
+
+
+  # Analog Supply Voltage, +3.3V
+  # Internally divided by 2
+  label in10    "AVdd"
+  compute in10  @*2, @/2
+  set in10_min   3.0
+  set in10_max   3.6
+
+
+# Temperature inputs
+  ignore temp1
+  ignore temp2
+
+  # PC87366 Internal Temperature
+  # PC87366 Recommended Operating Conditions: 0 - 70C
+  # SC1100  Recommended Operating Conditions: 0 - 85C
+  label temp3       "Temp"
+  label temp3_crit  "Critical"
+  set temp3_min      0
+  set temp3_max     70
+  set temp3_crit    85
+
+
+  ignore temp4
+  ignore temp5
+  ignore temp6
+
+
+# Fan inputs
+  ignore fan1
+  ignore fan2
+  ignore fan3
diff --git a/external/subpack/utils/lm-sensors/patches/001-Add_support_for_dev_name_formatted_like_a000000.wifi.patch b/external/subpack/utils/lm-sensors/patches/001-Add_support_for_dev_name_formatted_like_a000000.wifi.patch
new file mode 100644
index 0000000..a29b4ce
--- /dev/null
+++ b/external/subpack/utils/lm-sensors/patches/001-Add_support_for_dev_name_formatted_like_a000000.wifi.patch
@@ -0,0 +1,23 @@
+From 6da486d7415e426ec983baa5f8edafe0ff4c4171 Mon Sep 17 00:00:00 2001
+From: 7217043955 <85880133+7217043955@users.noreply.github.com>
+Date: Tue, 6 Sep 2022 15:48:11 +0800
+Subject: [PATCH] Add support for dev_name formatted like "a000000.wifi"
+
+---
+ lib/sysfs.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/lib/sysfs.c
++++ b/lib/sysfs.c
+@@ -663,8 +663,9 @@ static int classify_device(const char *d
+ 	if ((!subsys || !strcmp(subsys, "platform") ||
+ 			!strcmp(subsys, "of_platform"))) {
+ 		/* must be new ISA (platform driver) */
+-		if (sscanf(dev_name, "%*[a-z0-9_].%d", &entry->chip.addr) != 1)
+-			entry->chip.addr = 0;
++		if (sscanf(dev_name, "%*[a-zA-Z0-9_]%*1[.:]%d", &entry->chip.addr) == 1);
++		else if (sscanf(dev_name, "%x.%*s", &entry->chip.addr) == 1);
++		else entry->chip.addr = 0;
+ 		entry->chip.bus.type = SENSORS_BUS_TYPE_ISA;
+ 		entry->chip.bus.nr = 0;
+ 	} else if (subsys && !strcmp(subsys, "acpi")) {