lantiq: ltq-vdsl-mei: add kernel 5.10 compatiblity
[openwrt/staging/hauke.git] / package / kernel / lantiq / ltq-vdsl-mei / patches / 100-compat.patch
1 --- a/src/drv_mei_cpe_common.c
2 +++ b/src/drv_mei_cpe_common.c
3 @@ -19,7 +19,6 @@
4 /* get at first the driver configuration */
5 #include "drv_mei_cpe_config.h"
6
7 -#include "ifx_types.h"
8 #include "drv_mei_cpe_os.h"
9 #include "drv_mei_cpe_dbg.h"
10
11 --- a/src/drv_mei_cpe_linux.h
12 +++ b/src/drv_mei_cpe_linux.h
13 @@ -60,12 +60,6 @@
14 #include <linux/poll.h>
15 #include <linux/types.h>
16
17 -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
18 - #include <asm/ifx/ifx_types.h>
19 -#else
20 - #include <ifx_types.h>
21 -#endif
22 -
23 #endif /* #if (MEI_DRV_IFXOS_ENABLE == 0)*/
24
25 #include <linux/dma-mapping.h>
26 --- a/src/drv_mei_cpe_linux.c
27 +++ b/src/drv_mei_cpe_linux.c
28 @@ -114,6 +114,8 @@
29
30 #include "drv_mei_cpe_api_atm_ptm_intern.h"
31
32 +#include <lantiq_soc.h>
33 +
34 /* ===================================
35 extern function declarations
36 =================================== */
37 @@ -220,6 +222,8 @@ static void MEI_NlSendMsg(IFX_char_t* pM
38 /* Local variables (LINUX) */
39 /* =================================== */
40 static IFX_uint8_t major_number = 0;
41 +static struct class *mei_class;
42 +static dev_t mei_devt;
43 #ifdef MODULE
44 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
45 MODULE_PARM(major_number, "b");
46 @@ -1479,7 +1483,11 @@ struct proc_entry {
47 char name[32];
48 proc_rd_callback_t rd;
49 proc_wr_callback_t wr;
50 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
51 struct file_operations ops;
52 +#else
53 + struct proc_ops ops;
54 +#endif
55 int entity;
56 };
57
58 @@ -1869,6 +1877,7 @@ static int mei_proc_single_open(struct i
59 static void mei_proc_entry_create(struct proc_dir_entry *parent_node,
60 struct proc_entry *proc_entry)
61 {
62 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
63 memset(&proc_entry->ops, 0, sizeof(struct file_operations));
64 proc_entry->ops.owner = THIS_MODULE;
65
66 @@ -1879,6 +1888,17 @@ static void mei_proc_entry_create(struct
67 proc_entry->ops.llseek = seq_lseek;
68 if (proc_entry->wr)
69 proc_entry->ops.write = proc_entry->wr;
70 +#else
71 + memset(&proc_entry->ops, 0, sizeof(struct proc_ops));
72 +
73 + proc_entry->ops.proc_open = mei_proc_single_open;
74 + proc_entry->ops.proc_release = single_release;
75 +
76 + proc_entry->ops.proc_read = seq_read;
77 + proc_entry->ops.proc_lseek = seq_lseek;
78 + if (proc_entry->wr)
79 + proc_entry->ops.proc_write = proc_entry->wr;
80 +#endif
81
82 proc_create_data(proc_entry->name,
83 (S_IFREG | S_IRUGO),
84 @@ -2174,9 +2194,11 @@ static int MEI_module_init (void)
85 return (result);
86 }
87
88 +#if 0
89 #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
90 ppa_callback_set(LTQ_MEI_SHOWTIME_CHECK, (void *)ltq_mei_showtime_check);
91 #endif /* #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
92 +#endif
93
94 return 0;
95 }
96 @@ -2304,6 +2326,10 @@ static void MEI_module_exit (void)
97
98 #else
99 unregister_chrdev ( major_number , DRV_MEI_NAME );
100 + device_destroy(mei_class, mei_devt);
101 + mei_devt = 0;
102 + class_destroy(mei_class);
103 + mei_class = NULL;
104 #endif
105
106 #if CONFIG_PROC_FS
107 @@ -2388,9 +2414,11 @@ static void MEI_module_exit (void)
108 ("MEI_DRV: Chipset Basic Exit failed" MEI_DRV_CRLF));
109 }
110
111 +#if 0
112 #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
113 ppa_callback_set(LTQ_MEI_SHOWTIME_CHECK, (void *)NULL);
114 #endif /* #if (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
115 +#endif
116
117 #if (MEI_SUPPORT_DEBUG_LOGGER == 1)
118 if (nl_debug_sock)
119 @@ -2514,6 +2542,10 @@ static int MEI_InitModuleRegCharDev(cons
120 ("Using major number %d" MEI_DRV_CRLF, major_number));
121 }
122
123 + mei_class = class_create(THIS_MODULE, devName);
124 + mei_devt = MKDEV(major_number, 0);
125 + device_create(mei_class, NULL, mei_devt, NULL, "%s/%i", devName, 0);
126 +
127 return 0;
128 #endif /* CONFIG_DEVFS_FS */
129 }
130 @@ -2563,21 +2595,32 @@ static int MEI_InitModuleBasics(void)
131 }
132
133 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0))
134 +
135 +#define PMU_DFE BIT(9)
136 +
137 static int MEI_SysClkEnable(struct clk *clk)
138 {
139 +#if 0
140 if (IS_ERR(clk))
141 return -1;
142 clk_enable(clk);
143 +#else
144 + ltq_pmu_enable(PMU_DFE);
145 +#endif
146
147 return 0;
148 }
149
150 static int MEI_SysClkDisable(struct clk *clk)
151 {
152 +#if 0
153 if (IS_ERR(clk))
154 return -1;
155 clk_disable(clk);
156 clk_put(clk);
157 +#else
158 + ltq_pmu_disable(PMU_DFE);
159 +#endif
160
161 return 0;
162 }
163 @@ -2905,11 +2948,15 @@ IFX_int32_t MEI_IoctlInitDevice(
164 pMeiDev->eModePoll = e_MEI_DEV_ACCESS_MODE_IRQ;
165 pMeiDev->intMask = ME_ARC2ME_INTERRUPT_UNMASK_ALL;
166
167 +#if 1
168 + virq = (IFX_uint32_t)pInitDev->usedIRQ;
169 +#else
170 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
171 virq = (IFX_uint32_t)pInitDev->usedIRQ;
172 #else
173 virq = irq_create_mapping(NULL, (IFX_uint32_t)pInitDev->usedIRQ);
174 #endif
175 +#endif
176
177 pTmpXCntrl = MEI_VrxXDevToIrqListAdd(
178 MEI_DRV_LINENUM_GET(pMeiDev),
179 --- a/src/drv_mei_cpe_api_atm_ptm_intern.c
180 +++ b/src/drv_mei_cpe_api_atm_ptm_intern.c
181 @@ -147,6 +147,7 @@ IFX_int32_t MEI_InternalXtmSwhowtimeExit
182 return retVal;
183 }
184
185 +#if 0
186 IFX_int32_t MEI_InternalTcRequest(
187 MEI_DYN_CNTRL_T *pMeiDynCntrl,
188 MEI_TC_Request_t *pArgTcRequest)
189 @@ -232,6 +233,7 @@ IFX_int32_t MEI_InternalTcReset(
190
191 return retVal;
192 }
193 +#endif
194
195 /**
196 Function that is used by the PP subsystem to get some showtime relevant data
197 @@ -311,10 +313,57 @@ int ifx_mei_atm_led_blink(void)
198 return IFX_SUCCESS;
199 }
200
201 +#if MEI_MAX_DFE_CHAN_DEVICES > 1
202 +#error "Compat functions do not support MEI_MAX_DFE_CHAN_DEVICES > 1 yet"
203 +#else
204 +int (*ifx_mei_atm_showtime_enter)(struct port_cell_info *, void *) = NULL;
205 +int (*ifx_mei_atm_showtime_exit)(void) = NULL;
206 +
207 +int ltq_ifx_mei_atm_showtime_enter_compat(IFX_uint8_t dslLineNum,
208 + struct port_cell_info *cellInfo,
209 + void *xdata) {
210 + if (ifx_mei_atm_showtime_enter)
211 + return ifx_mei_atm_showtime_enter(cellInfo, xdata);
212 +
213 + return -e_MEI_ERR_OP_FAILED;
214 +}
215 +
216 +int ltq_ifx_mei_atm_showtime_exit_compat(IFX_uint8_t dslLineNum) {
217 + if (ifx_mei_atm_showtime_exit)
218 + return ifx_mei_atm_showtime_exit();
219 +
220 + return -e_MEI_ERR_OP_FAILED;
221 +}
222 +
223 +void* ppa_callback_get(e_ltq_mei_cb_type type) {
224 + switch (type) {
225 + case LTQ_MEI_SHOWTIME_ENTER:
226 + return &ltq_ifx_mei_atm_showtime_enter_compat;
227 + case LTQ_MEI_SHOWTIME_EXIT:
228 + return &ltq_ifx_mei_atm_showtime_exit_compat;
229 + break;
230 + }
231 +
232 + BUG();
233 +}
234 +
235 +int ifx_mei_atm_showtime_check(int *is_showtime,
236 + struct port_cell_info *port_cell,
237 + void **xdata_addr) {
238 + return ltq_mei_showtime_check(0, is_showtime, port_cell, xdata_addr);
239 +}
240 +
241 +EXPORT_SYMBOL(ifx_mei_atm_showtime_enter);
242 +EXPORT_SYMBOL(ifx_mei_atm_showtime_exit);
243 +EXPORT_SYMBOL(ifx_mei_atm_showtime_check);
244 +#endif
245 +
246 EXPORT_SYMBOL (MEI_InternalXtmSwhowtimeEntrySignal);
247 EXPORT_SYMBOL (MEI_InternalXtmSwhowtimeExitSignal);
248 +#if 0
249 EXPORT_SYMBOL (MEI_InternalTcRequest);
250 EXPORT_SYMBOL (MEI_InternalTcReset);
251 +#endif
252 EXPORT_SYMBOL(ifx_mei_atm_led_blink);
253
254 #endif /* #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1) */
255 --- a/src/drv_mei_cpe_api_atm_ptm_intern.h
256 +++ b/src/drv_mei_cpe_api_atm_ptm_intern.h
257 @@ -21,7 +21,6 @@
258
259 #include "drv_mei_cpe_config.h"
260 #include "drv_mei_cpe_interface.h"
261 -#include <net/ppa_stack_al.h>
262
263 #if (MEI_EXPORT_INTERNAL_API == 1) && (MEI_DRV_ATM_PTM_INTERFACE_ENABLE == 1)
264
265 @@ -59,8 +58,21 @@ extern IFX_int32_t MEI_InternalTcReset(
266 MEI_DYN_CNTRL_T *pMeiDynCntrl,
267 MEI_TC_Reset_t *pArgTcReset);
268
269 +#if 1
270 +#include <lantiq_atm.h>
271 +typedef enum {
272 + LTQ_MEI_SHOWTIME_ENTER,
273 + LTQ_MEI_SHOWTIME_EXIT
274 +} e_ltq_mei_cb_type;
275 +
276 +typedef void (*ltq_mei_atm_showtime_enter_t)(IFX_uint8_t, struct port_cell_info *, void *);
277 +typedef void (*ltq_mei_atm_showtime_exit_t)(IFX_uint8_t);
278 +
279 +void* ppa_callback_get(e_ltq_mei_cb_type type);
280 +#else
281 extern int ppa_callback_set(e_ltq_mei_cb_type type, void *func);
282 extern void* ppa_callback_get(e_ltq_mei_cb_type type);
283 +#endif
284
285 int ltq_mei_showtime_check(
286 const unsigned char line_idx,
287 --- a/src/drv_mei_cpe_device_vrx.c
288 +++ b/src/drv_mei_cpe_device_vrx.c
289 @@ -28,17 +28,6 @@
290 #include "drv_mei_cpe_api.h"
291 #include "drv_mei_cpe_mei_vrx.h"
292
293 -#if defined(LINUX)
294 -# if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
295 -# if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
296 -# include "ifx_pcie.h"
297 -# else
298 -# include "../drivers/net/ethernet/lantiq/lantiq_pcie.h"
299 -# endif
300 -# else
301 -# include "lantiq_pcie.h"
302 -# endif
303 -#endif /* #if defined(LINUX)*/
304
305 IFX_int32_t MEI_GPIntProcess(MEI_MeiRegVal_t processInt, MEI_DEV_T *pMeiDev)
306 {
307 @@ -86,6 +75,7 @@ IFX_int32_t MEI_GetChipInfo(MEI_DEV_T *p
308 */
309 IFX_int32_t MEI_VR10_PcieEntitiesCheck(IFX_uint8_t nEntityNum)
310 {
311 +#if 0
312 IFX_uint32_t pcie_entitiesNum;
313
314 /* get information from pcie driver */
315 @@ -110,6 +100,9 @@ IFX_int32_t MEI_VR10_PcieEntitiesCheck(I
316 }
317
318 return IFX_SUCCESS;
319 +#else
320 + return IFX_ERROR;
321 +#endif
322 }
323
324 /**
325 @@ -124,6 +117,7 @@ IFX_int32_t MEI_VR10_PcieEntitiesCheck(I
326 */
327 IFX_int32_t MEI_VR10_PcieEntityInit(MEI_MEI_DRV_CNTRL_T *pMeiDrvCntrl)
328 {
329 +#if 0
330 IFX_uint8_t entityNum;
331 #if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
332 ifx_pcie_ep_dev_t MEI_pcie_ep_dev;
333 @@ -156,6 +150,9 @@ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_
334 pMeiDrvCntrl->MEI_pcie_irq = 99;
335
336 return IFX_SUCCESS;
337 +#else
338 + return IFX_ERROR;
339 +#endif
340 }
341
342 /**
343 @@ -170,6 +167,7 @@ IFX_int32_t MEI_VR10_PcieEntityInit(MEI_
344 */
345 IFX_int32_t MEI_VR10_PcieEntityFree(IFX_uint8_t entityNum)
346 {
347 +#if 0
348 #if (MEI_SUPPORT_DEVICE_VR10_320 != 1)
349 if (ifx_pcie_ep_dev_info_release(entityNum))
350 #else
351 @@ -183,6 +181,9 @@ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_
352 }
353
354 return IFX_SUCCESS;
355 +#else
356 + return IFX_ERROR;
357 +#endif
358 }
359
360 /**
361 @@ -197,6 +198,7 @@ IFX_int32_t MEI_VR10_PcieEntityFree(IFX_
362 */
363 IFX_int32_t MEI_VR10_InternalInitDevice(MEI_DYN_CNTRL_T *pMeiDynCntrl)
364 {
365 +#if 0
366 IFX_int32_t retVal;
367 IOCTL_MEI_devInit_t InitDev;
368 MEI_DEV_T *pMeiDev = pMeiDynCntrl->pMeiDev;
369 @@ -221,6 +223,9 @@ IFX_int32_t MEI_VR10_InternalInitDevice(
370 *MEI_GPIO_U32REG(GPIO_P0_ALSEL1) &= ~((1 << 0) | (1 << 3) | (1 << 8));
371
372 return IFX_SUCCESS;
373 +#else
374 + return IFX_ERROR;
375 +#endif
376 }
377
378 IFX_int32_t MEI_PLL_ConfigInit(MEI_DEV_T *pMeiDev)
379 --- a/src/drv_mei_cpe_dsm.c
380 +++ b/src/drv_mei_cpe_dsm.c
381 @@ -144,7 +144,7 @@ IFX_void_t MEI_VRX_DSM_DataInit(MEI_DEV_
382 memset((IFX_uint8_t *)&pMeiDev->firmwareFeatures, 0x00, sizeof(IOCTL_MEI_firmwareFeatures_t));
383 pMeiDev->meiFwDlCount = 0;
384
385 - pMeiDev->meiERBbuf.pCallBackFunc = mei_dsm_cb_func_hook;
386 + pMeiDev->meiERBbuf.pCallBackFunc = NULL;
387
388 PRN_DBG_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_NORMAL,
389 ("MEI_DRV: PP callback function addr = 0x%08X" MEI_DRV_CRLF,
390 --- a/src/drv_mei_cpe_download_vrx.c
391 +++ b/src/drv_mei_cpe_download_vrx.c
392 @@ -3281,12 +3281,14 @@ IFX_int32_t MEI_DEV_IoctlFirmwareDownloa
393 /* reset TC layer */
394 if (ret == 0)
395 {
396 +#if 0
397 if (MEI_InternalTcReset(pMeiDynCntrl, &tc_reset) != 0)
398 {
399 PRN_ERR_USR_NL( MEI_DRV, MEI_DRV_PRN_LEVEL_WRN,
400 ("MEI_DRV[%02d]: Could not perform reset of TC-Layer!"
401 MEI_DRV_CRLF, MEI_DRV_LINENUM_GET(pMeiDev)));
402 }
403 +#endif
404 }
405 #endif
406
407 --- a/src/drv_mei_cpe_linux_proc_config.c
408 +++ b/src/drv_mei_cpe_linux_proc_config.c
409 @@ -1039,6 +1039,7 @@ static int mei_proc_single_open(struct i
410 return single_open(file, mei_seq_single_show, PDE_DATA(inode));
411 }
412
413 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0))
414 static struct file_operations proc_ops = {
415 .owner = THIS_MODULE,
416 .open = mei_proc_single_open,
417 @@ -1047,6 +1048,15 @@ static struct file_operations proc_ops =
418 .llseek = seq_lseek,
419 .write = MEI_ProcWriteConfig
420 };
421 +#else
422 +static struct proc_ops proc_ops = {
423 + .proc_open = mei_proc_single_open,
424 + .proc_release = single_release,
425 + .proc_read = seq_read,
426 + .proc_lseek = seq_lseek,
427 + .proc_write = MEI_ProcWriteConfig
428 +};
429 +#endif
430
431 /**
432 Create an read/write proc entry for configuration.