Create openwrt package

This commit is contained in:
sbwml 2022-05-03 14:15:23 +08:00
parent 192aca6d38
commit 280d1cd164
No known key found for this signature in database
GPG Key ID: 5D4FE7692E4164A9
2 changed files with 89 additions and 0 deletions

47
Makefile Normal file
View File

@ -0,0 +1,47 @@
#
# Download realtek r8168 linux driver from official site:
# [https://www.realtek.com/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software]
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=r8168
PKG_VERSION:=8.050.00
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define KernelPackage/r8168
TITLE:=Driver for Realtek r8168 chipsets
SUBMENU:=Network Devices
VERSION:=$(LINUX_VERSION)+$(PKG_VERSION)-$(BOARD)-$(PKG_RELEASE)
DEPENDS:=@PCI_SUPPORT
FILES:= $(PKG_BUILD_DIR)/r8168.ko
AUTOLOAD:=$(call AutoProbe,r8168)
CONFLICTS:=kmod-r8169
endef
define Package/r8168/description
This package contains a driver for Realtek r8168 chipsets.
endef
R8168_MAKEOPTS= -C $(PKG_BUILD_DIR) \
PATH="$(TARGET_PATH)" \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
TARGET="$(HAL_TARGET)" \
TOOLPREFIX="$(KERNEL_CROSS)" \
TOOLPATH="$(KERNEL_CROSS)" \
KERNELPATH="$(LINUX_DIR)" \
KERNELDIR="$(LINUX_DIR)" \
LDOPTS=" " \
DOMULTI=1
define Build/Compile
$(MAKE) $(R8168_MAKEOPTS) modules
endef
$(eval $(call KernelPackage,r8168))

View File

@ -0,0 +1,42 @@
--- a/r8168_n.c
+++ b/r8168_n.c
@@ -47,6 +47,7 @@
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/mii.h>
+#include <linux/of.h>
#include <linux/if_vlan.h>
#include <linux/crc32.h>
#include <linux/interrupt.h>
@@ -24605,6 +24606,22 @@ rtl8168_set_bios_setting(struct net_device *dev)
}
}
+static int rtl8168_led_configuration(struct rtl8168_private *tp)
+{
+ u32 led_data;
+ int ret;
+
+ ret = of_property_read_u32(tp->pci_dev->dev.of_node,
+ "realtek,led-data", &led_data);
+
+ if (ret)
+ return ret;
+
+ RTL_W16(tp, CustomLED, led_data);
+
+ return 0;
+}
+
static void
rtl8168_init_software_variable(struct net_device *dev)
{
@@ -25164,6 +25181,8 @@ rtl8168_init_software_variable(struct net_device *dev)
tp->NotWrMcuPatchCode = TRUE;
}
+ rtl8168_led_configuration(tp);
+
tp->NicCustLedValue = RTL_R16(tp, CustomLED);
rtl8168_get_hw_wol(dev);