+++ /dev/null
-# Copyright (C) 2012 OpenWrt.org
-# Copyright (C) 2015-2016 Lantiq Beteiligungs GmbH & Co KG.
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-
-include $(TOPDIR)/rules.mk
-include $(INCLUDE_DIR)/kernel.mk
-
-PKG_NAME:=ltq-vdsl-vr9-mei
-PKG_VERSION:=1.5.17.6
-PKG_RELEASE:=6
-
-PKG_BASE_NAME:=drv_mei_cpe
-PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
-PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_BASE_NAME)-$(PKG_VERSION)
-PKG_SOURCE_URL:=@OPENWRT
-PKG_HASH:=94f6904364348b7f74087e721968abc28b2564fb9bd8899aa930d36490387662
-PKG_FIXUP:=autoreconf
-PKG_FLAGS:=nonshared
-PKG_MAINTAINER:=John Crispin <john@phrozen.org>
-PKG_LICENSE:=GPL-2.0 BSD-2-Clause
-PKG_LICENSE_FILES:=LICENSE
-PKG_EXTMOD_SUBDIRS:=src
-
-include $(INCLUDE_DIR)/package.mk
-
-define KernelPackage/ltq-vdsl-vr9-mei
- TITLE:=mei driver for vdsl
- SECTION:=sys
- SUBMENU:=Network Devices
- DEPENDS:=@TARGET_lantiq_xrx200 +kmod-ltq-ifxos +kmod-ltq-vectoring
- FILES:=$(PKG_BUILD_DIR)/src/drv_mei_cpe.ko
- AUTOLOAD:=$(call AutoLoad,50,drv_mei_cpe)
-endef
-
-define KernelPackage/ltq-vdsl-vr9-mei/description
- Lantiq MEI CPE Kernel Module Driver
-endef
-
-
-define Package/ltq-vdsl-mei-test
- SECTION:=net
- CATEGORY:=Network
- TITLE:=Lantiq mei driver test tool
- URL:=http://www.lantiq.com/
- DEPENDS:=@TARGET_lantiq_xrx200
-endef
-
-define Package/ltq-vdsl-mei-test/description
- Userland tool to directly control the mei driver, this is only needed
- for test and development purposes.
-endef
-
-MAKE_FLAGS += \
- $(KERNEL_MAKE_FLAGS) \
- SHELL="$(BASH)"
-
-# ltq-vdsl-app uses a header provided by the MEI driver which has some
-# conditionals.
-# Define the conditionals here to have the same view on both sides. If you
-# change them, you need to change them for the ltq-vdsl-app as well
-MEI_DRV_CFLAGS = \
- -DMEI_DRV_ATM_PTM_INTERFACE_ENABLE=1 \
- -DMEI_SUPPORT_DEBUG_STREAMS=1 \
- -DMEI_SUPPORT_OPTIMIZED_FW_DL=1
-
-CONFIGURE_ARGS += \
- --enable-kernelincl="$(LINUX_DIR)/include" \
- --enable-device=vr9 \
- --with-max-device=1 \
- --with-lines-per-device=1 \
- --enable-debug \
- --enable-error_print \
- --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos/" \
- --enable-ifxos-library="-L$(STAGING_DIR)/usr/lib" \
- --enable-add_drv_cflags="$(MEI_DRV_CFLAGS)" \
- --enable-linux-26 \
- --enable-kernelbuild="$(LINUX_DIR)" \
- --enable-drv_test_appl=yes \
- ARCH=$(LINUX_KARCH)
-
-define Build/InstallDev
- $(INSTALL_DIR) $(1)/usr/include/vdsl
- $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_intern.h $(1)/usr/include/vdsl/
- $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_atm_ptm_intern.h $(1)/usr/include/vdsl/
- $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_interface.h $(1)/usr/include/vdsl
- $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_config.h $(1)/usr/include/vdsl/
- $(CP) $(PKG_BUILD_DIR)/src/cmv_message_format.h $(1)/usr/include/vdsl/
-endef
-
-$(eval $(call KernelPackage,ltq-vdsl-vr9-mei))
-
-define Package/ltq-vdsl-mei-test/install
- $(INSTALL_DIR) $(1)/bin
- $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mei_cpe_drv_test $(1)/bin
-endef
-
-$(eval $(call BuildPackage,ltq-vdsl-mei-test))
+++ /dev/null
---- a/src/drv_mei_cpe_linux.h
-+++ b/src/drv_mei_cpe_linux.h
-@@ -31,6 +31,9 @@
- #include <linux/module.h>
-
- #include <linux/sched.h>
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
-+#include <linux/sched/signal.h>
-+#endif
- #include <linux/interrupt.h>
- #include <linux/version.h>
- #include <linux/crc32.h>
-@@ -121,7 +124,11 @@ typedef int (*MEI_RequestIrq_WrapLinux_t
- /**
- Function typedef for the Linux free_irq()
- */
-+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
-+typedef const void *(*MEI_FreeIrq_WrapLinux_t)( unsigned int usedIrq,
-+#else
- typedef void (*MEI_FreeIrq_WrapLinux_t)( unsigned int usedIrq,
-+#endif
- void *usedDevId );
-
-
---- a/src/drv_mei_cpe_linux.c
-+++ b/src/drv_mei_cpe_linux.c
-@@ -129,7 +129,7 @@ static int MEI_module_init(void);
- #endif
-
- #if (MEI_DRV_LKM_ENABLE == 1) && (MEI_SUPPORT_DEVICE_VR10_320 != 1)
--static void __exit MEI_module_exit(void);
-+static void MEI_module_exit(void);
- #else
- static void MEI_module_exit(void);
- #endif
-@@ -2188,7 +2188,7 @@ static int MEI_module_init (void)
- Called by the kernel.
- */
- #if (MEI_DRV_LKM_ENABLE == 1) && (MEI_SUPPORT_DEVICE_VR10_320 != 1)
--static void __exit MEI_module_exit (void)
-+static void MEI_module_exit (void)
- #else
- static void MEI_module_exit (void)
- #endif
+++ /dev/null
---- a/src/drv_mei_cpe_api.h
-+++ b/src/drv_mei_cpe_api.h
-@@ -1000,7 +1000,7 @@ typedef struct MEI_dev_s
- #if ( defined(MEI_DRVOS_HAVE_DRV_SELECT) && (MEI_DRVOS_HAVE_DRV_SELECT == 1) )
- /** support for select() */
- IFX_boolean_t bNfcNeedWakeUp;
-- MEI_DRVOS_event_t selNfcWakeupList;
-+ IFXOS_drvSelectQueue_t selNfcWakeupList;
- #endif
-
- /** list of all open instances which can receive NFC's, EVT's ALM's */
---- a/src/drv_mei_cpe_linux.c
-+++ b/src/drv_mei_cpe_linux.c
-@@ -1302,9 +1302,9 @@ static unsigned int MEI_Poll (struct fil
- }
-
- MEI_DRVOS_SelectQueueAddTask(
-- (MEI_DRVOS_select_OSArg_t*) filp,
-- (MEI_DRVOS_selectQueue_t*) &(pMeiDev->selNfcWakeupList),
-- (MEI_DRVOS_selectTable_t*) wait);
-+ filp,
-+ &(pMeiDev->selNfcWakeupList),
-+ wait);
-
- if (pDynNfc->pRecvDataCntrl[pDynNfc->rdIdxRd].bufCtrl != MEI_RECV_BUF_CTRL_FREE) /* buffer in use */
- {
+++ /dev/null
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -213,8 +213,7 @@ drv_mei_cpe_common_cflags = $(AM_CFLAGS)
- else
-
- drv_mei_cpe_common_cflags = \
-- $(AM_CFLAGS) -D__KERNEL__ -DLINUX -D__linux__ -DMODULE -DEXPORT_SYMTAB \
-- -pipe -Wimplicit -Wunused -Wuninitialized -Wsign-compare -Wstrict-aliasing
-+ -D__KERNEL__ -DLINUX -D__linux__ -DMODULE -DEXPORT_SYMTAB
-
- endif
-
-@@ -354,7 +353,7 @@ drv_mei_cpe.ko: $(drv_mei_cpe_SOURCES)
- @echo -e "# drv_mei_cpe: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
- @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
- @echo -e "$(subst .ko,,$@)-y := $(drv_mei_cpe_OBJS)" >> $(PWD)/Kbuild
-- @echo -e "EXTRA_CFLAGS := $(CFLAGS) $(drv_mei_cpe_CFLAGS) -I@abs_srcdir@ -I@abs_srcdir@/auto_header $(IFXOS_INCLUDE_PATH)" >> $(PWD)/Kbuild
-+ @echo -e "EXTRA_CFLAGS := $(drv_mei_cpe_CFLAGS) -I@abs_srcdir@ -I@abs_srcdir@/auto_header $(IFXOS_INCLUDE_PATH)" >> $(PWD)/Kbuild
- $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
-
- clean-generic:
+++ /dev/null
-This removes -static compile option. The -static option tells GCC to
-link this statically with the libc, which we do not want in OpenWrt. We
-want to link everything dynamically to the libc. This fixes a compile
-problem with glibc.
-
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -198,10 +198,10 @@ AM_CFLAGS = -Wall -Wimplicit -Wunused -W
-
- if IFXOS_ENABLE
- AM_LDFLAGS= \
-- -Bstatic -dn -static @IFXOS_LIBRARY_PATH@
-+ -Bstatic -dn @IFXOS_LIBRARY_PATH@
- else
- AM_LDFLAGS= \
-- -Bstatic -dn -static
-+ -Bstatic -dn
- endif
-
- #
-@@ -304,7 +304,7 @@ mei_cpe_appl_ldflags= $(ADD_APPL_LDFLAGS
- else
- if TARGET_ADM5120_MIPSEL
- mei_cpe_appl_cflags = -O1 -g
--mei_cpe_appl_ldflags = -static
-+mei_cpe_appl_ldflags =
- else
- mei_cpe_appl_cflags = -DPPC
- endif
-@@ -318,7 +318,7 @@ mei_cpe_drv_test_CPPFLAGS = -I@srcdir@\
- mei_cpe_drv_test_CFLAGS = $(mei_cpe_app_common_cflags) \
- $(mei_cpe_appl_cflags) $(MEI_DRV_TARGET_OPTIONS)
-
--mei_cpe_drv_test_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn -static @IFXOS_LIBRARY_PATH@
-+mei_cpe_drv_test_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn @IFXOS_LIBRARY_PATH@
-
- mei_cpe_drv_test_LDADD = -lifxos
- endif
-@@ -333,7 +333,7 @@ mei_cpe_drv_dbg_strm_dmp_CPPFLAGS = -I@s
- -I@KERNEL_INCL_PATH@ $(IFXOS_INCLUDE_PATH)
- mei_cpe_drv_dbg_strm_dmp_CFLAGS = $(mei_cpe_app_common_cflags) \
- $(mei_cpe_appl_cflags) $(MEI_DRV_TARGET_OPTIONS)
--mei_cpe_drv_dbg_strm_dmp_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn -static @IFXOS_LIBRARY_PATH@
-+mei_cpe_drv_dbg_strm_dmp_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn @IFXOS_LIBRARY_PATH@
- mei_cpe_drv_dbg_strm_dmp_LDADD = -lifxos
-
- # linux 2.6 kernel object - dummy to force dependencies
+++ /dev/null
---- a/src/drv_mei_cpe_common.c
-+++ b/src/drv_mei_cpe_common.c
-@@ -19,7 +19,6 @@
- /* get at first the driver configuration */
- #include "drv_mei_cpe_config.h"
-
--#include "ifx_types.h"
- #include "drv_mei_cpe_os.h"
- #include "drv_mei_cpe_dbg.h"
-
---- a/src/drv_mei_cpe_linux.h
-+++ b/src/drv_mei_cpe_linux.h
-@@ -60,12 +60,6 @@
- #include <linux/poll.h>
- #include <linux/types.h>
-
--#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
-- #include <asm/ifx/ifx_types.h>
--#else
-- #include <ifx_types.h>
--#endif
--
- #endif /* #if (MEI_DRV_IFXOS_ENABLE == 0)*/
-
- #include <linux/dma-mapping.h>
---- a/src/drv_mei_cpe_linux.c
-+++ b/src/drv_mei_cpe_linux.c
-@@ -114,6 +114,8 @@
-
- #include "drv_mei_cpe_api_atm_ptm_intern.h"
-
-+#include <lantiq_soc.h>
-+
- /* ===================================
- extern function declarations
- =================================== */
-@@ -220,6 +222,8 @@ static void MEI_NlSendMsg(IFX_char_t* pM
- /* Local variables (LINUX) */
- /* =================================== */
- static IFX_uint8_t major_number = 0;
-+static struct class *mei_class;
-+static dev_t mei_devt;
- #ifdef MODULE
- #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
- MODULE_PARM(major_number, "b");
-@@ -1479,7 +1483,11 @@ struct proc_entry {
- char name[32];
- proc_rd_callback_t rd;
- proc_wr_callback_t wr;
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
- struct file_operations ops;
-+#else
-+ struct proc_ops ops;
-+#endif
- int entity;
- };
-
-@@ -1869,6 +1877,7 @@ static int mei_proc_single_open(struct i
- static void mei_proc_entry_create(struct proc_dir_entry *parent_node,
- struct proc_entry *proc_entry)
- {
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
- memset(&proc_entry->ops, 0, sizeof(struct file_operations));
- proc_entry->ops.owner = THIS_MODULE;
-
-@@ -1879,6 +1888,17 @@ static void mei_proc_entry_create(struct
- proc_entry->ops.llseek = seq_lseek;
- if (proc_entry->wr)
- proc_entry->ops.write = proc_entry->wr;
-+#else
-+ memset(&proc_entry->ops, 0, sizeof(struct proc_ops));
-+
-+ proc_entry->ops.proc_open = mei_proc_single_open;
-+ proc_entry->ops.proc_release = single_release;
-+
-+ proc_entry->ops.proc_read = seq_read;
-+ proc_entry->ops.proc_lseek = seq_lseek;
-+ if (proc_entry->wr)
-+ proc_entry->ops.proc_write = proc_entry->wr;
-+#endif
-
- proc_create_data(proc_entry->name,
- (S_IFREG | S_IRUGO),
-@@ -2174,9 +2194,11 @@ static int MEI_module_init (void)
- return (result);
- }
-
-+#if 0
- #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
- ppa_callback_set(LTQ_MEI_SHOWTIME_CHECK, (void *)ltq_mei_showtime_check);
- #endif /* #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
-+#endif
-
- return 0;
- }
-@@ -2304,6 +2326,10 @@ static void MEI_module_exit (void)
-
- #else
- unregister_chrdev ( major_number , DRV_MEI_NAME );
-+ device_destroy(mei_class, mei_devt);
-+ mei_devt = 0;
-+ class_destroy(mei_class);
-+ mei_class = NULL;
- #endif
-
- #if CONFIG_PROC_FS
-@@ -2388,9 +2414,11 @@ static void MEI_module_exit (void)
- ("MEI_DRV: Chipset Basic Exit failed" MEI_DRV_CRLF));
- }
-
-+#if 0
- #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
- ppa_callback_set(LTQ_MEI_SHOWTIME_CHECK, (void *)NULL);
- #endif /* #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
-+#endif
-
- #if (MEI_SUPPORT_DEBUG_LOGGER == 1)
- if (nl_debug_sock)
-@@ -2514,6 +2542,10 @@ static int MEI_InitModuleRegCharDev(cons
- ("Using major number %d" MEI_DRV_CRLF, major_number));
- }
-
-+ mei_class = class_create(THIS_MODULE, devName);
-+ mei_devt = MKDEV(major_number, 0);
-+ device_create(mei_class, NULL, mei_devt, NULL, "%s/%i", devName, 0);
-+
- return 0;
- #endif /* CONFIG_DEVFS_FS */
- }
-@@ -2563,21 +2595,32 @@ static int MEI_InitModuleBasics(void)
- }
-
- #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
-+
-+#define PMU_DFE BIT(9)
-+
- static int MEI_SysClkEnable(struct clk *clk)
- {
-+#if 0
- if (IS_ERR(clk))
- return -1;
- clk_enable(clk);
-+#else
-+ ltq_pmu_enable(PMU_DFE);
-+#endif
-
- return 0;
- }
-
- static int MEI_SysClkDisable(struct clk *clk)
- {
-+#if 0
- if (IS_ERR(clk))
- return -1;
- clk_disable(clk);
- clk_put(clk);
-+#else
-+ ltq_pmu_disable(PMU_DFE);
-+#endif
-
- return 0;
- }
-@@ -2905,11 +2948,15 @@ IFX_int32_t MEI_IoctlInitDevice(
- pMeiDev->eModePoll = e_MEI_DEV_ACCESS_MODE_IRQ;
- pMeiDev->intMask = ME_ARC2ME_INTERRUPT_UNMASK_ALL;
-
-+#if 1
-+ virq = (IFX_uint32_t)pInitDev->usedIRQ;
-+#else
- #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
- virq = (IFX_uint32_t)pInitDev->usedIRQ;
- #else
- virq = irq_create_mapping(NULL, (IFX_uint32_t)pInitDev->usedIRQ);
- #endif
-+#endif
-
- pTmpXCntrl = MEI_VrxXDevToIrqListAdd(
- MEI_DRV_LINENUM_GET(pMeiDev),
---- a/src/drv_mei_cpe_api_atm_ptm_intern.c
-+++ b/src/drv_mei_cpe_api_atm_ptm_intern.c
-@@ -147,6 +147,7 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit
- return retVal;
- }
-
-+#if 0
- IFX_int32_t MEI_InternalTcRequest(
- MEI_DYN_CNTRL_T *pMeiDynCntrl,
- MEI_TC_Request_t *pArgTcRequest)
-@@ -232,6 +233,7 @@ IFX_int32_t MEI_InternalTcReset(
-
- return retVal;
- }
-+#endif
-
- /**
- Function that is used by the PP subsystem to get some showtime relevant data
-@@ -311,10 +313,57 @@ int ifx_mei_atm_led_blink(void)
- return IFX_SUCCESS;
- }
-
-+#if MEI_MAX_DFE_CHAN_DEVICES > 1
-+#error "Compat functions do not support MEI_MAX_DFE_CHAN_DEVICES > 1 yet"
-+#else
-+int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
-+int (*ifx_mei_atm_showtime_exit)(void) = NULL;
-+
-+int ltq_ifx_mei_atm_showtime_enter_compat(IFX_uint8_t dslLineNum,
-+ struct port_cell_info *cellInfo,
-+ void *xdata) {
-+ if (ifx_mei_atm_showtime_enter)
-+ return ifx_mei_atm_showtime_enter(cellInfo, xdata);
-+
-+ return -e_MEI_ERR_OP_FAILED;
-+}
-+
-+int ltq_ifx_mei_atm_showtime_exit_compat(IFX_uint8_t dslLineNum) {
-+ if (ifx_mei_atm_showtime_exit)
-+ return ifx_mei_atm_showtime_exit();
-+
-+ return -e_MEI_ERR_OP_FAILED;
-+}
-+
-+void* ppa_callback_get(e_ltq_mei_cb_type type) {
-+ switch (type) {
-+ case LTQ_MEI_SHOWTIME_ENTER:
-+ return <q_ifx_mei_atm_showtime_enter_compat;
-+ case LTQ_MEI_SHOWTIME_EXIT:
-+ return <q_ifx_mei_atm_showtime_exit_compat;
-+ break;
-+ }
-+
-+ BUG();
-+}
-+
-+int ifx_mei_atm_showtime_check(int *is_showtime,
-+ struct port_cell_info *port_cell,
-+ void **xdata_addr) {
-+ return ltq_mei_showtime_check(0, is_showtime, port_cell, xdata_addr);
-+}
-+
-+EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
-+EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
-+EXPORT_SYMBOL(ifx_mei_atm_showtime_check);
-+#endif
-+
- EXPORT_SYMBOL (MEI_InternalXtmSwhowtimeEntrySignal);
- EXPORT_SYMBOL (MEI_InternalXtmSwhowtimeExitSignal);
-+#if 0
- EXPORT_SYMBOL (MEI_InternalTcRequest);
- EXPORT_SYMBOL (MEI_InternalTcReset);
-+#endif
- EXPORT_SYMBOL(ifx_mei_atm_led_blink);
-
- #endif /* #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
---- a/src/drv_mei_cpe_api_atm_ptm_intern.h
-+++ b/src/drv_mei_cpe_api_atm_ptm_intern.h
-@@ -21,7 +21,6 @@
-
- #include "drv_mei_cpe_config.h"
- #include "drv_mei_cpe_interface.h"
--#include <net/ppa_stack_al.h>
-
- #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
-
-@@ -59,8 +58,21 @@ extern IFX_int32_t MEI_InternalTcReset(
- MEI_DYN_CNTRL_T *pMeiDynCntrl,
- MEI_TC_Reset_t *pArgTcReset);
-
-+#if 1
-+#include <lantiq_atm.h>
-+typedef enum {
-+ LTQ_MEI_SHOWTIME_ENTER,
-+ LTQ_MEI_SHOWTIME_EXIT
-+} e_ltq_mei_cb_type;
-+
-+typedef void (*ltq_mei_atm_showtime_enter_t)(IFX_uint8_t, struct port_cell_info *, void *);
-+typedef void (*ltq_mei_atm_showtime_exit_t)(IFX_uint8_t);
-+
-+void* ppa_callback_get(e_ltq_mei_cb_type type);
-+#else
- extern int ppa_callback_set(e_ltq_mei_cb_type type, void *func);
- extern void* ppa_callback_get(e_ltq_mei_cb_type type);
-+#endif
-
- int ltq_mei_showtime_check(
- const unsigned char line_idx,
---- a/src/drv_mei_cpe_device_vrx.c
-+++ b/src/drv_mei_cpe_device_vrx.c
-@@ -28,17 +28,6 @@
- #include "drv_mei_cpe_api.h"
- #include "drv_mei_cpe_mei_vrx.h"
-
--#if defined(LINUX)
--# if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
--# if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
--# include "ifx_pcie.h"
--# else
--# include "../drivers/net/ethernet/lantiq/lantiq_pcie.h"
--# endif
--# else
--# include "lantiq_pcie.h"
--# endif
--#endif /* #if defined(LINUX)*/
-
- IFX_int32_t MEI_GPIntProcess(MEI_MeiRegVal_t processInt, MEI_DEV_T *pMeiDev)
- {
-@@ -86,6 +75,7 @@ IFX_int32_t MEI_GetChipInfo(MEI_DEV_T *p
- */
- IFX_int32_t MEI_VR10_PcieEntitiesCheck(IFX_uint8_t nEntityNum)
- {
-+#if 0
- IFX_uint32_t pcie_entitiesNum;
-
- /* get information from pcie driver */
-@@ -110,6 +100,9 @@ IFX_int32_t MEI_VR10_PcieEntitiesCheck(I
- }
-
- return IFX_SUCCESS;
-+#else
-+ return IFX_ERROR;
-+#endif
- }
-
- /**
-@@ -124,6 +117,7 @@ IFX_int32_t MEI_VR10_PcieEntitiesCheck(I
- */
- IFX_int32_t MEI_VR10_PcieEntityInit(MEI_MEI_DRV_CNTRL_T *pMeiDrvCntrl)
- {
-+#if 0
- IFX_uint8_t entityNum;
- #if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
- ifx_pcie_ep_dev_t MEI_pcie_ep_dev;
-@@ -156,6 +150,9 @@ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_
- pMeiDrvCntrl->MEI_pcie_irq = 99;
-
- return IFX_SUCCESS;
-+#else
-+ return IFX_ERROR;
-+#endif
- }
-
- /**
-@@ -170,6 +167,7 @@ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_
- */
- IFX_int32_t MEI_VR10_PcieEntityFree(IFX_uint8_t entityNum)
- {
-+#if 0
- #if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
- if (ifx_pcie_ep_dev_info_release(entityNum))
- #else
-@@ -183,6 +181,9 @@ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_
- }
-
- return IFX_SUCCESS;
-+#else
-+ return IFX_ERROR;
-+#endif
- }
-
- /**
-@@ -197,6 +198,7 @@ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_
- */
- IFX_int32_t MEI_VR10_InternalInitDevice(MEI_DYN_CNTRL_T *pMeiDynCntrl)
- {
-+#if 0
- IFX_int32_t retVal;
- IOCTL_MEI_devInit_t InitDev;
- MEI_DEV_T *pMeiDev = pMeiDynCntrl->pMeiDev;
-@@ -221,6 +223,9 @@ IFX_int32_t MEI_VR10_InternalInitDevice(
- *MEI_GPIO_U32REG(GPIO_P0_ALSEL1) &= ~((1 << 0) | (1 << 3) | (1 << 8));
-
- return IFX_SUCCESS;
-+#else
-+ return IFX_ERROR;
-+#endif
- }
-
- IFX_int32_t MEI_PLL_ConfigInit(MEI_DEV_T *pMeiDev)
---- a/src/drv_mei_cpe_download_vrx.c
-+++ b/src/drv_mei_cpe_download_vrx.c
-@@ -3281,12 +3281,14 @@ IFX_int32_t MEI_DEV_IoctlFirmwareDownloa
- /* reset TC layer */
- if (ret == 0)
- {
-+#if 0
- if (MEI_InternalTcReset(pMeiDynCntrl, &tc_reset) != 0)
- {
- PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_WRN,
- ("MEI_DRV[%02d]: Could not perform reset of TC-Layer!"
- MEI_DRV_CRLF, MEI_DRV_LINENUM_GET(pMeiDev)));
- }
-+#endif
- }
- #endif
-
---- a/src/drv_mei_cpe_linux_proc_config.c
-+++ b/src/drv_mei_cpe_linux_proc_config.c
-@@ -1039,6 +1039,7 @@ static int mei_proc_single_open(struct i
- return single_open(file, mei_seq_single_show, PDE_DATA(inode));
- }
-
-+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
- static struct file_operations proc_ops = {
- .owner = THIS_MODULE,
- .open = mei_proc_single_open,
-@@ -1047,6 +1048,15 @@ static struct file_operations proc_ops =
- .llseek = seq_lseek,
- .write = MEI_ProcWriteConfig
- };
-+#else
-+static struct proc_ops proc_ops = {
-+ .proc_open = mei_proc_single_open,
-+ .proc_release = single_release,
-+ .proc_read = seq_read,
-+ .proc_lseek = seq_lseek,
-+ .proc_write = MEI_ProcWriteConfig
-+};
-+#endif
-
- /**
- Create an read/write proc entry for configuration.
+++ /dev/null
---- a/src/drv_mei_cpe_linux.c
-+++ b/src/drv_mei_cpe_linux.c
-@@ -1503,8 +1503,8 @@ struct proc_entry {
- static void MEI_GetVersionProc(struct seq_file *s)
- {
- seq_printf(s, "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]);
-- seq_printf(s, "Compiled on %s, %s for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF,
-- __DATE__, __TIME__, UTS_RELEASE, jiffies);
-+ seq_printf(s, "Compiled for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF,
-+ UTS_RELEASE, jiffies);
- }
-
- /**
+++ /dev/null
---- a/src/drv_mei_cpe_api_atm_ptm_intern.c
-+++ b/src/drv_mei_cpe_api_atm_ptm_intern.c
-@@ -124,6 +124,9 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit
- /* Get line number*/
- dslLineNum = pMeiDynCntrl->pMeiDev->meiDrvCntrl.dslLineNum;
-
-+ g_tx_link_rate[dslLineNum][0] = 0;
-+ g_tx_link_rate[dslLineNum][1] = 0;
-+
- /* get NULL or function pointer */
- mei_showtime_exit =
- (ltq_mei_atm_showtime_exit_t)ppa_callback_get(LTQ_MEI_SHOWTIME_EXIT);
+++ /dev/null
---- a/src/drv_mei_cpe_common.c
-+++ b/src/drv_mei_cpe_common.c
-@@ -104,6 +104,8 @@ IFX_uint32_t MEI_FsmStateSetMsgPreAction
- MEI_DEVCFG_DATA_T MEI_DevCfgData;
- #endif
-
-+static DEFINE_SPINLOCK(MEI_InterruptLock);
-+
- /* ============================================================================
- Proc-FS and debug variable definitions
- ========================================================================= */
-@@ -2134,6 +2136,9 @@ IFX_int32_t MEI_ProcessIntPerIrq(MEIX_CN
- #if (MEI_SUPPORT_DEBUG_STREAMS == 1)
- IFX_int_t extraDbgStreamLoop = 0;
- #endif
-+ unsigned long flags;
-+
-+ spin_lock_irqsave(&MEI_InterruptLock, flags);
-
- /* get the actual chip device from the list and step through the VRX devices */
- while(pNextXCntrl)
-@@ -2167,6 +2172,8 @@ IFX_int32_t MEI_ProcessIntPerIrq(MEIX_CN
- }
- #endif
-
-+ spin_unlock_irqrestore(&MEI_InterruptLock, flags);
-+
- return meiIntCnt;
- }
-
-@@ -2639,9 +2646,14 @@ IFX_int32_t MEI_MsgSendPreAction(
- */
- IFX_void_t MEI_DisableDeviceInt(MEI_DEV_T *pMeiDev)
- {
-+ unsigned long flags;
-+ spin_lock_irqsave(&MEI_InterruptLock, flags);
-+
- MEI_MaskInterrupts( &pMeiDev->meiDrvCntrl,
- ME_ARC2ME_INTERRUPT_MASK_ALL);
-
-+ spin_unlock_irqrestore(&MEI_InterruptLock, flags);
-+
- return;
- }
-
--- /dev/null
+# Copyright (C) 2012 OpenWrt.org
+# Copyright (C) 2015-2016 Lantiq Beteiligungs GmbH & Co KG.
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=ltq-vdsl-vr9-mei
+PKG_VERSION:=1.5.17.6
+PKG_RELEASE:=6
+
+PKG_BASE_NAME:=drv_mei_cpe
+PKG_SOURCE:=$(PKG_BASE_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_BASE_NAME)-$(PKG_VERSION)
+PKG_SOURCE_URL:=@OPENWRT
+PKG_HASH:=94f6904364348b7f74087e721968abc28b2564fb9bd8899aa930d36490387662
+PKG_FIXUP:=autoreconf
+PKG_FLAGS:=nonshared
+PKG_MAINTAINER:=John Crispin <john@phrozen.org>
+PKG_LICENSE:=GPL-2.0 BSD-2-Clause
+PKG_LICENSE_FILES:=LICENSE
+PKG_EXTMOD_SUBDIRS:=src
+
+include $(INCLUDE_DIR)/package.mk
+
+define KernelPackage/ltq-vdsl-vr9-mei
+ TITLE:=mei driver for vdsl
+ SECTION:=sys
+ SUBMENU:=Network Devices
+ DEPENDS:=@TARGET_lantiq_xrx200 +kmod-ltq-ifxos +kmod-ltq-vectoring
+ FILES:=$(PKG_BUILD_DIR)/src/drv_mei_cpe.ko
+ AUTOLOAD:=$(call AutoLoad,50,drv_mei_cpe)
+endef
+
+define KernelPackage/ltq-vdsl-vr9-mei/description
+ Lantiq MEI CPE Kernel Module Driver
+endef
+
+
+define Package/ltq-vdsl-vr9-mei-test
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Lantiq mei driver test tool
+ URL:=http://www.lantiq.com/
+ DEPENDS:=@TARGET_lantiq_xrx200
+endef
+
+define Package/ltq-vdsl-vr9-mei-test/description
+ Userland tool to directly control the mei driver, this is only needed
+ for test and development purposes.
+endef
+
+MAKE_FLAGS += \
+ $(KERNEL_MAKE_FLAGS) \
+ SHELL="$(BASH)"
+
+# ltq-vdsl-app uses a header provided by the MEI driver which has some
+# conditionals.
+# Define the conditionals here to have the same view on both sides. If you
+# change them, you need to change them for the ltq-vdsl-app as well
+MEI_DRV_CFLAGS = \
+ -DMEI_DRV_ATM_PTM_INTERFACE_ENABLE=1 \
+ -DMEI_SUPPORT_DEBUG_STREAMS=1 \
+ -DMEI_SUPPORT_OPTIMIZED_FW_DL=1
+
+CONFIGURE_ARGS += \
+ --enable-kernelincl="$(LINUX_DIR)/include" \
+ --enable-device=vr9 \
+ --with-max-device=1 \
+ --with-lines-per-device=1 \
+ --enable-debug \
+ --enable-error_print \
+ --enable-ifxos-include="-I$(STAGING_DIR)/usr/include/ifxos/" \
+ --enable-ifxos-library="-L$(STAGING_DIR)/usr/lib" \
+ --enable-add_drv_cflags="$(MEI_DRV_CFLAGS)" \
+ --enable-linux-26 \
+ --enable-kernelbuild="$(LINUX_DIR)" \
+ --enable-drv_test_appl=yes \
+ ARCH=$(LINUX_KARCH)
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/vdsl
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_intern.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_api_atm_ptm_intern.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_interface.h $(1)/usr/include/vdsl
+ $(CP) $(PKG_BUILD_DIR)/src/drv_mei_cpe_config.h $(1)/usr/include/vdsl/
+ $(CP) $(PKG_BUILD_DIR)/src/cmv_message_format.h $(1)/usr/include/vdsl/
+endef
+
+$(eval $(call KernelPackage,ltq-vdsl-vr9-mei))
+
+define Package/ltq-vdsl-vr9-mei-test/install
+ $(INSTALL_DIR) $(1)/bin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mei_cpe_drv_test $(1)/bin
+endef
+
+$(eval $(call BuildPackage,ltq-vdsl-vr9-mei-test))
--- /dev/null
+--- a/src/drv_mei_cpe_linux.h
++++ b/src/drv_mei_cpe_linux.h
+@@ -31,6 +31,9 @@
+ #include <linux/module.h>
+
+ #include <linux/sched.h>
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0))
++#include <linux/sched/signal.h>
++#endif
+ #include <linux/interrupt.h>
+ #include <linux/version.h>
+ #include <linux/crc32.h>
+@@ -121,7 +124,11 @@ typedef int (*MEI_RequestIrq_WrapLinux_t
+ /**
+ Function typedef for the Linux free_irq()
+ */
++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
++typedef const void *(*MEI_FreeIrq_WrapLinux_t)( unsigned int usedIrq,
++#else
+ typedef void (*MEI_FreeIrq_WrapLinux_t)( unsigned int usedIrq,
++#endif
+ void *usedDevId );
+
+
+--- a/src/drv_mei_cpe_linux.c
++++ b/src/drv_mei_cpe_linux.c
+@@ -129,7 +129,7 @@ static int MEI_module_init(void);
+ #endif
+
+ #if (MEI_DRV_LKM_ENABLE == 1) && (MEI_SUPPORT_DEVICE_VR10_320 != 1)
+-static void __exit MEI_module_exit(void);
++static void MEI_module_exit(void);
+ #else
+ static void MEI_module_exit(void);
+ #endif
+@@ -2188,7 +2188,7 @@ static int MEI_module_init (void)
+ Called by the kernel.
+ */
+ #if (MEI_DRV_LKM_ENABLE == 1) && (MEI_SUPPORT_DEVICE_VR10_320 != 1)
+-static void __exit MEI_module_exit (void)
++static void MEI_module_exit (void)
+ #else
+ static void MEI_module_exit (void)
+ #endif
--- /dev/null
+--- a/src/drv_mei_cpe_api.h
++++ b/src/drv_mei_cpe_api.h
+@@ -1000,7 +1000,7 @@ typedef struct MEI_dev_s
+ #if ( defined(MEI_DRVOS_HAVE_DRV_SELECT) && (MEI_DRVOS_HAVE_DRV_SELECT == 1) )
+ /** support for select() */
+ IFX_boolean_t bNfcNeedWakeUp;
+- MEI_DRVOS_event_t selNfcWakeupList;
++ IFXOS_drvSelectQueue_t selNfcWakeupList;
+ #endif
+
+ /** list of all open instances which can receive NFC's, EVT's ALM's */
+--- a/src/drv_mei_cpe_linux.c
++++ b/src/drv_mei_cpe_linux.c
+@@ -1302,9 +1302,9 @@ static unsigned int MEI_Poll (struct fil
+ }
+
+ MEI_DRVOS_SelectQueueAddTask(
+- (MEI_DRVOS_select_OSArg_t*) filp,
+- (MEI_DRVOS_selectQueue_t*) &(pMeiDev->selNfcWakeupList),
+- (MEI_DRVOS_selectTable_t*) wait);
++ filp,
++ &(pMeiDev->selNfcWakeupList),
++ wait);
+
+ if (pDynNfc->pRecvDataCntrl[pDynNfc->rdIdxRd].bufCtrl != MEI_RECV_BUF_CTRL_FREE) /* buffer in use */
+ {
--- /dev/null
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -213,8 +213,7 @@ drv_mei_cpe_common_cflags = $(AM_CFLAGS)
+ else
+
+ drv_mei_cpe_common_cflags = \
+- $(AM_CFLAGS) -D__KERNEL__ -DLINUX -D__linux__ -DMODULE -DEXPORT_SYMTAB \
+- -pipe -Wimplicit -Wunused -Wuninitialized -Wsign-compare -Wstrict-aliasing
++ -D__KERNEL__ -DLINUX -D__linux__ -DMODULE -DEXPORT_SYMTAB
+
+ endif
+
+@@ -354,7 +353,7 @@ drv_mei_cpe.ko: $(drv_mei_cpe_SOURCES)
+ @echo -e "# drv_mei_cpe: Generated to build Linux 2.6.x kernel object" > $(PWD)/Kbuild
+ @echo -e "obj-m := $(subst .ko,.o,$@)" >> $(PWD)/Kbuild
+ @echo -e "$(subst .ko,,$@)-y := $(drv_mei_cpe_OBJS)" >> $(PWD)/Kbuild
+- @echo -e "EXTRA_CFLAGS := $(CFLAGS) $(drv_mei_cpe_CFLAGS) -I@abs_srcdir@ -I@abs_srcdir@/auto_header $(IFXOS_INCLUDE_PATH)" >> $(PWD)/Kbuild
++ @echo -e "EXTRA_CFLAGS := $(drv_mei_cpe_CFLAGS) -I@abs_srcdir@ -I@abs_srcdir@/auto_header $(IFXOS_INCLUDE_PATH)" >> $(PWD)/Kbuild
+ $(MAKE) ARCH=@KERNEL_ARCH@ -C @KERNEL_BUILD_PATH@ O=@KERNEL_BUILD_PATH@ M=$(PWD) modules
+
+ clean-generic:
--- /dev/null
+This removes -static compile option. The -static option tells GCC to
+link this statically with the libc, which we do not want in OpenWrt. We
+want to link everything dynamically to the libc. This fixes a compile
+problem with glibc.
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -198,10 +198,10 @@ AM_CFLAGS = -Wall -Wimplicit -Wunused -W
+
+ if IFXOS_ENABLE
+ AM_LDFLAGS= \
+- -Bstatic -dn -static @IFXOS_LIBRARY_PATH@
++ -Bstatic -dn @IFXOS_LIBRARY_PATH@
+ else
+ AM_LDFLAGS= \
+- -Bstatic -dn -static
++ -Bstatic -dn
+ endif
+
+ #
+@@ -304,7 +304,7 @@ mei_cpe_appl_ldflags= $(ADD_APPL_LDFLAGS
+ else
+ if TARGET_ADM5120_MIPSEL
+ mei_cpe_appl_cflags = -O1 -g
+-mei_cpe_appl_ldflags = -static
++mei_cpe_appl_ldflags =
+ else
+ mei_cpe_appl_cflags = -DPPC
+ endif
+@@ -318,7 +318,7 @@ mei_cpe_drv_test_CPPFLAGS = -I@srcdir@\
+ mei_cpe_drv_test_CFLAGS = $(mei_cpe_app_common_cflags) \
+ $(mei_cpe_appl_cflags) $(MEI_DRV_TARGET_OPTIONS)
+
+-mei_cpe_drv_test_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn -static @IFXOS_LIBRARY_PATH@
++mei_cpe_drv_test_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn @IFXOS_LIBRARY_PATH@
+
+ mei_cpe_drv_test_LDADD = -lifxos
+ endif
+@@ -333,7 +333,7 @@ mei_cpe_drv_dbg_strm_dmp_CPPFLAGS = -I@s
+ -I@KERNEL_INCL_PATH@ $(IFXOS_INCLUDE_PATH)
+ mei_cpe_drv_dbg_strm_dmp_CFLAGS = $(mei_cpe_app_common_cflags) \
+ $(mei_cpe_appl_cflags) $(MEI_DRV_TARGET_OPTIONS)
+-mei_cpe_drv_dbg_strm_dmp_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn -static @IFXOS_LIBRARY_PATH@
++mei_cpe_drv_dbg_strm_dmp_LDFLAGS = $(mei_cpe_appl_ldflags) -Bstatic -dn @IFXOS_LIBRARY_PATH@
+ mei_cpe_drv_dbg_strm_dmp_LDADD = -lifxos
+
+ # linux 2.6 kernel object - dummy to force dependencies
--- /dev/null
+--- a/src/drv_mei_cpe_common.c
++++ b/src/drv_mei_cpe_common.c
+@@ -19,7 +19,6 @@
+ /* get at first the driver configuration */
+ #include "drv_mei_cpe_config.h"
+
+-#include "ifx_types.h"
+ #include "drv_mei_cpe_os.h"
+ #include "drv_mei_cpe_dbg.h"
+
+--- a/src/drv_mei_cpe_linux.h
++++ b/src/drv_mei_cpe_linux.h
+@@ -60,12 +60,6 @@
+ #include <linux/poll.h>
+ #include <linux/types.h>
+
+-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+- #include <asm/ifx/ifx_types.h>
+-#else
+- #include <ifx_types.h>
+-#endif
+-
+ #endif /* #if (MEI_DRV_IFXOS_ENABLE == 0)*/
+
+ #include <linux/dma-mapping.h>
+--- a/src/drv_mei_cpe_linux.c
++++ b/src/drv_mei_cpe_linux.c
+@@ -114,6 +114,8 @@
+
+ #include "drv_mei_cpe_api_atm_ptm_intern.h"
+
++#include <lantiq_soc.h>
++
+ /* ===================================
+ extern function declarations
+ =================================== */
+@@ -220,6 +222,8 @@ static void MEI_NlSendMsg(IFX_char_t* pM
+ /* Local variables (LINUX) */
+ /* =================================== */
+ static IFX_uint8_t major_number = 0;
++static struct class *mei_class;
++static dev_t mei_devt;
+ #ifdef MODULE
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
+ MODULE_PARM(major_number, "b");
+@@ -1479,7 +1483,11 @@ struct proc_entry {
+ char name[32];
+ proc_rd_callback_t rd;
+ proc_wr_callback_t wr;
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
+ struct file_operations ops;
++#else
++ struct proc_ops ops;
++#endif
+ int entity;
+ };
+
+@@ -1869,6 +1877,7 @@ static int mei_proc_single_open(struct i
+ static void mei_proc_entry_create(struct proc_dir_entry *parent_node,
+ struct proc_entry *proc_entry)
+ {
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
+ memset(&proc_entry->ops, 0, sizeof(struct file_operations));
+ proc_entry->ops.owner = THIS_MODULE;
+
+@@ -1879,6 +1888,17 @@ static void mei_proc_entry_create(struct
+ proc_entry->ops.llseek = seq_lseek;
+ if (proc_entry->wr)
+ proc_entry->ops.write = proc_entry->wr;
++#else
++ memset(&proc_entry->ops, 0, sizeof(struct proc_ops));
++
++ proc_entry->ops.proc_open = mei_proc_single_open;
++ proc_entry->ops.proc_release = single_release;
++
++ proc_entry->ops.proc_read = seq_read;
++ proc_entry->ops.proc_lseek = seq_lseek;
++ if (proc_entry->wr)
++ proc_entry->ops.proc_write = proc_entry->wr;
++#endif
+
+ proc_create_data(proc_entry->name,
+ (S_IFREG | S_IRUGO),
+@@ -2174,9 +2194,11 @@ static int MEI_module_init (void)
+ return (result);
+ }
+
++#if 0
+ #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
+ ppa_callback_set(LTQ_MEI_SHOWTIME_CHECK, (void *)ltq_mei_showtime_check);
+ #endif /* #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
++#endif
+
+ return 0;
+ }
+@@ -2304,6 +2326,10 @@ static void MEI_module_exit (void)
+
+ #else
+ unregister_chrdev ( major_number , DRV_MEI_NAME );
++ device_destroy(mei_class, mei_devt);
++ mei_devt = 0;
++ class_destroy(mei_class);
++ mei_class = NULL;
+ #endif
+
+ #if CONFIG_PROC_FS
+@@ -2388,9 +2414,11 @@ static void MEI_module_exit (void)
+ ("MEI_DRV: Chipset Basic Exit failed" MEI_DRV_CRLF));
+ }
+
++#if 0
+ #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
+ ppa_callback_set(LTQ_MEI_SHOWTIME_CHECK, (void *)NULL);
+ #endif /* #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
++#endif
+
+ #if (MEI_SUPPORT_DEBUG_LOGGER == 1)
+ if (nl_debug_sock)
+@@ -2514,6 +2542,10 @@ static int MEI_InitModuleRegCharDev(cons
+ ("Using major number %d" MEI_DRV_CRLF, major_number));
+ }
+
++ mei_class = class_create(THIS_MODULE, devName);
++ mei_devt = MKDEV(major_number, 0);
++ device_create(mei_class, NULL, mei_devt, NULL, "%s/%i", devName, 0);
++
+ return 0;
+ #endif /* CONFIG_DEVFS_FS */
+ }
+@@ -2563,21 +2595,32 @@ static int MEI_InitModuleBasics(void)
+ }
+
+ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
++
++#define PMU_DFE BIT(9)
++
+ static int MEI_SysClkEnable(struct clk *clk)
+ {
++#if 0
+ if (IS_ERR(clk))
+ return -1;
+ clk_enable(clk);
++#else
++ ltq_pmu_enable(PMU_DFE);
++#endif
+
+ return 0;
+ }
+
+ static int MEI_SysClkDisable(struct clk *clk)
+ {
++#if 0
+ if (IS_ERR(clk))
+ return -1;
+ clk_disable(clk);
+ clk_put(clk);
++#else
++ ltq_pmu_disable(PMU_DFE);
++#endif
+
+ return 0;
+ }
+@@ -2905,11 +2948,15 @@ IFX_int32_t MEI_IoctlInitDevice(
+ pMeiDev->eModePoll = e_MEI_DEV_ACCESS_MODE_IRQ;
+ pMeiDev->intMask = ME_ARC2ME_INTERRUPT_UNMASK_ALL;
+
++#if 1
++ virq = (IFX_uint32_t)pInitDev->usedIRQ;
++#else
+ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
+ virq = (IFX_uint32_t)pInitDev->usedIRQ;
+ #else
+ virq = irq_create_mapping(NULL, (IFX_uint32_t)pInitDev->usedIRQ);
+ #endif
++#endif
+
+ pTmpXCntrl = MEI_VrxXDevToIrqListAdd(
+ MEI_DRV_LINENUM_GET(pMeiDev),
+--- a/src/drv_mei_cpe_api_atm_ptm_intern.c
++++ b/src/drv_mei_cpe_api_atm_ptm_intern.c
+@@ -147,6 +147,7 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit
+ return retVal;
+ }
+
++#if 0
+ IFX_int32_t MEI_InternalTcRequest(
+ MEI_DYN_CNTRL_T *pMeiDynCntrl,
+ MEI_TC_Request_t *pArgTcRequest)
+@@ -232,6 +233,7 @@ IFX_int32_t MEI_InternalTcReset(
+
+ return retVal;
+ }
++#endif
+
+ /**
+ Function that is used by the PP subsystem to get some showtime relevant data
+@@ -311,10 +313,57 @@ int ifx_mei_atm_led_blink(void)
+ return IFX_SUCCESS;
+ }
+
++#if MEI_MAX_DFE_CHAN_DEVICES > 1
++#error "Compat functions do not support MEI_MAX_DFE_CHAN_DEVICES > 1 yet"
++#else
++int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
++int (*ifx_mei_atm_showtime_exit)(void) = NULL;
++
++int ltq_ifx_mei_atm_showtime_enter_compat(IFX_uint8_t dslLineNum,
++ struct port_cell_info *cellInfo,
++ void *xdata) {
++ if (ifx_mei_atm_showtime_enter)
++ return ifx_mei_atm_showtime_enter(cellInfo, xdata);
++
++ return -e_MEI_ERR_OP_FAILED;
++}
++
++int ltq_ifx_mei_atm_showtime_exit_compat(IFX_uint8_t dslLineNum) {
++ if (ifx_mei_atm_showtime_exit)
++ return ifx_mei_atm_showtime_exit();
++
++ return -e_MEI_ERR_OP_FAILED;
++}
++
++void* ppa_callback_get(e_ltq_mei_cb_type type) {
++ switch (type) {
++ case LTQ_MEI_SHOWTIME_ENTER:
++ return <q_ifx_mei_atm_showtime_enter_compat;
++ case LTQ_MEI_SHOWTIME_EXIT:
++ return <q_ifx_mei_atm_showtime_exit_compat;
++ break;
++ }
++
++ BUG();
++}
++
++int ifx_mei_atm_showtime_check(int *is_showtime,
++ struct port_cell_info *port_cell,
++ void **xdata_addr) {
++ return ltq_mei_showtime_check(0, is_showtime, port_cell, xdata_addr);
++}
++
++EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
++EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
++EXPORT_SYMBOL(ifx_mei_atm_showtime_check);
++#endif
++
+ EXPORT_SYMBOL (MEI_InternalXtmSwhowtimeEntrySignal);
+ EXPORT_SYMBOL (MEI_InternalXtmSwhowtimeExitSignal);
++#if 0
+ EXPORT_SYMBOL (MEI_InternalTcRequest);
+ EXPORT_SYMBOL (MEI_InternalTcReset);
++#endif
+ EXPORT_SYMBOL(ifx_mei_atm_led_blink);
+
+ #endif /* #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
+--- a/src/drv_mei_cpe_api_atm_ptm_intern.h
++++ b/src/drv_mei_cpe_api_atm_ptm_intern.h
+@@ -21,7 +21,6 @@
+
+ #include "drv_mei_cpe_config.h"
+ #include "drv_mei_cpe_interface.h"
+-#include <net/ppa_stack_al.h>
+
+ #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
+
+@@ -59,8 +58,21 @@ extern IFX_int32_t MEI_InternalTcReset(
+ MEI_DYN_CNTRL_T *pMeiDynCntrl,
+ MEI_TC_Reset_t *pArgTcReset);
+
++#if 1
++#include <lantiq_atm.h>
++typedef enum {
++ LTQ_MEI_SHOWTIME_ENTER,
++ LTQ_MEI_SHOWTIME_EXIT
++} e_ltq_mei_cb_type;
++
++typedef void (*ltq_mei_atm_showtime_enter_t)(IFX_uint8_t, struct port_cell_info *, void *);
++typedef void (*ltq_mei_atm_showtime_exit_t)(IFX_uint8_t);
++
++void* ppa_callback_get(e_ltq_mei_cb_type type);
++#else
+ extern int ppa_callback_set(e_ltq_mei_cb_type type, void *func);
+ extern void* ppa_callback_get(e_ltq_mei_cb_type type);
++#endif
+
+ int ltq_mei_showtime_check(
+ const unsigned char line_idx,
+--- a/src/drv_mei_cpe_device_vrx.c
++++ b/src/drv_mei_cpe_device_vrx.c
+@@ -28,17 +28,6 @@
+ #include "drv_mei_cpe_api.h"
+ #include "drv_mei_cpe_mei_vrx.h"
+
+-#if defined(LINUX)
+-# if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+-# if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
+-# include "ifx_pcie.h"
+-# else
+-# include "../drivers/net/ethernet/lantiq/lantiq_pcie.h"
+-# endif
+-# else
+-# include "lantiq_pcie.h"
+-# endif
+-#endif /* #if defined(LINUX)*/
+
+ IFX_int32_t MEI_GPIntProcess(MEI_MeiRegVal_t processInt, MEI_DEV_T *pMeiDev)
+ {
+@@ -86,6 +75,7 @@ IFX_int32_t MEI_GetChipInfo(MEI_DEV_T *p
+ */
+ IFX_int32_t MEI_VR10_PcieEntitiesCheck(IFX_uint8_t nEntityNum)
+ {
++#if 0
+ IFX_uint32_t pcie_entitiesNum;
+
+ /* get information from pcie driver */
+@@ -110,6 +100,9 @@ IFX_int32_t MEI_VR10_PcieEntitiesCheck(I
+ }
+
+ return IFX_SUCCESS;
++#else
++ return IFX_ERROR;
++#endif
+ }
+
+ /**
+@@ -124,6 +117,7 @@ IFX_int32_t MEI_VR10_PcieEntitiesCheck(I
+ */
+ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_MEI_DRV_CNTRL_T *pMeiDrvCntrl)
+ {
++#if 0
+ IFX_uint8_t entityNum;
+ #if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
+ ifx_pcie_ep_dev_t MEI_pcie_ep_dev;
+@@ -156,6 +150,9 @@ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_
+ pMeiDrvCntrl->MEI_pcie_irq = 99;
+
+ return IFX_SUCCESS;
++#else
++ return IFX_ERROR;
++#endif
+ }
+
+ /**
+@@ -170,6 +167,7 @@ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_
+ */
+ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_uint8_t entityNum)
+ {
++#if 0
+ #if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
+ if (ifx_pcie_ep_dev_info_release(entityNum))
+ #else
+@@ -183,6 +181,9 @@ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_
+ }
+
+ return IFX_SUCCESS;
++#else
++ return IFX_ERROR;
++#endif
+ }
+
+ /**
+@@ -197,6 +198,7 @@ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_
+ */
+ IFX_int32_t MEI_VR10_InternalInitDevice(MEI_DYN_CNTRL_T *pMeiDynCntrl)
+ {
++#if 0
+ IFX_int32_t retVal;
+ IOCTL_MEI_devInit_t InitDev;
+ MEI_DEV_T *pMeiDev = pMeiDynCntrl->pMeiDev;
+@@ -221,6 +223,9 @@ IFX_int32_t MEI_VR10_InternalInitDevice(
+ *MEI_GPIO_U32REG(GPIO_P0_ALSEL1) &= ~((1 << 0) | (1 << 3) | (1 << 8));
+
+ return IFX_SUCCESS;
++#else
++ return IFX_ERROR;
++#endif
+ }
+
+ IFX_int32_t MEI_PLL_ConfigInit(MEI_DEV_T *pMeiDev)
+--- a/src/drv_mei_cpe_download_vrx.c
++++ b/src/drv_mei_cpe_download_vrx.c
+@@ -3281,12 +3281,14 @@ IFX_int32_t MEI_DEV_IoctlFirmwareDownloa
+ /* reset TC layer */
+ if (ret == 0)
+ {
++#if 0
+ if (MEI_InternalTcReset(pMeiDynCntrl, &tc_reset) != 0)
+ {
+ PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_WRN,
+ ("MEI_DRV[%02d]: Could not perform reset of TC-Layer!"
+ MEI_DRV_CRLF, MEI_DRV_LINENUM_GET(pMeiDev)));
+ }
++#endif
+ }
+ #endif
+
+--- a/src/drv_mei_cpe_linux_proc_config.c
++++ b/src/drv_mei_cpe_linux_proc_config.c
+@@ -1039,6 +1039,7 @@ static int mei_proc_single_open(struct i
+ return single_open(file, mei_seq_single_show, PDE_DATA(inode));
+ }
+
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
+ static struct file_operations proc_ops = {
+ .owner = THIS_MODULE,
+ .open = mei_proc_single_open,
+@@ -1047,6 +1048,15 @@ static struct file_operations proc_ops =
+ .llseek = seq_lseek,
+ .write = MEI_ProcWriteConfig
+ };
++#else
++static struct proc_ops proc_ops = {
++ .proc_open = mei_proc_single_open,
++ .proc_release = single_release,
++ .proc_read = seq_read,
++ .proc_lseek = seq_lseek,
++ .proc_write = MEI_ProcWriteConfig
++};
++#endif
+
+ /**
+ Create an read/write proc entry for configuration.
--- /dev/null
+--- a/src/drv_mei_cpe_linux.c
++++ b/src/drv_mei_cpe_linux.c
+@@ -1503,8 +1503,8 @@ struct proc_entry {
+ static void MEI_GetVersionProc(struct seq_file *s)
+ {
+ seq_printf(s, "%s" MEI_DRV_CRLF, &MEI_WHATVERSION[4]);
+- seq_printf(s, "Compiled on %s, %s for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF,
+- __DATE__, __TIME__, UTS_RELEASE, jiffies);
++ seq_printf(s, "Compiled for Linux kernel %s (jiffies: %ld)" MEI_DRV_CRLF,
++ UTS_RELEASE, jiffies);
+ }
+
+ /**
--- /dev/null
+--- a/src/drv_mei_cpe_api_atm_ptm_intern.c
++++ b/src/drv_mei_cpe_api_atm_ptm_intern.c
+@@ -124,6 +124,9 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit
+ /* Get line number*/
+ dslLineNum = pMeiDynCntrl->pMeiDev->meiDrvCntrl.dslLineNum;
+
++ g_tx_link_rate[dslLineNum][0] = 0;
++ g_tx_link_rate[dslLineNum][1] = 0;
++
+ /* get NULL or function pointer */
+ mei_showtime_exit =
+ (ltq_mei_atm_showtime_exit_t)ppa_callback_get(LTQ_MEI_SHOWTIME_EXIT);
--- /dev/null
+--- a/src/drv_mei_cpe_common.c
++++ b/src/drv_mei_cpe_common.c
+@@ -104,6 +104,8 @@ IFX_uint32_t MEI_FsmStateSetMsgPreAction
+ MEI_DEVCFG_DATA_T MEI_DevCfgData;
+ #endif
+
++static DEFINE_SPINLOCK(MEI_InterruptLock);
++
+ /* ============================================================================
+ Proc-FS and debug variable definitions
+ ========================================================================= */
+@@ -2134,6 +2136,9 @@ IFX_int32_t MEI_ProcessIntPerIrq(MEIX_CN
+ #if (MEI_SUPPORT_DEBUG_STREAMS == 1)
+ IFX_int_t extraDbgStreamLoop = 0;
+ #endif
++ unsigned long flags;
++
++ spin_lock_irqsave(&MEI_InterruptLock, flags);
+
+ /* get the actual chip device from the list and step through the VRX devices */
+ while(pNextXCntrl)
+@@ -2167,6 +2172,8 @@ IFX_int32_t MEI_ProcessIntPerIrq(MEIX_CN
+ }
+ #endif
+
++ spin_unlock_irqrestore(&MEI_InterruptLock, flags);
++
+ return meiIntCnt;
+ }
+
+@@ -2639,9 +2646,14 @@ IFX_int32_t MEI_MsgSendPreAction(
+ */
+ IFX_void_t MEI_DisableDeviceInt(MEI_DEV_T *pMeiDev)
+ {
++ unsigned long flags;
++ spin_lock_irqsave(&MEI_InterruptLock, flags);
++
+ MEI_MaskInterrupts( &pMeiDev->meiDrvCntrl,
+ ME_ARC2ME_INTERRUPT_MASK_ALL);
+
++ spin_unlock_irqrestore(&MEI_InterruptLock, flags);
++
+ return;
+ }
+