From 280d1cd164bd9442b643d2522e8eb54d9dee3ba8 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Tue, 3 May 2022 14:15:23 +0800 Subject: [PATCH] Create openwrt package --- Makefile | 47 +++++++++++++++++++ ...-r8168-add-LED-configuration-from-OF.patch | 42 +++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 Makefile create mode 100644 patches/001-r8168-add-LED-configuration-from-OF.patch diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5c05b8a --- /dev/null +++ b/Makefile @@ -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)) diff --git a/patches/001-r8168-add-LED-configuration-from-OF.patch b/patches/001-r8168-add-LED-configuration-from-OF.patch new file mode 100644 index 0000000..a07af36 --- /dev/null +++ b/patches/001-r8168-add-LED-configuration-from-OF.patch @@ -0,0 +1,42 @@ +--- a/r8168_n.c ++++ b/r8168_n.c +@@ -47,6 +47,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -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);