frank-w / BPI-Router-Linux

Linux kernel 4.14+ for BPI-R2, 5.4+ for R64, 6.1+ for R2Pro and R3
Other
133 stars 48 forks source link

About the mainline linux kernel bluetooth and WiFi support for MediaTek #82

Closed alifilhan0 closed 1 year ago

alifilhan0 commented 3 years ago

I am really sorry to disturb with a bit of off topic issue. But I want to know how compatible is the mainline mediatek bluetooth driver a.k.a BTIF and btmtkuart/btmtksdio with the Banana Pi R2? is it usable at all? And what about the mainline WiFi support? The MT6625L is the RF frontend of the WiFi and bluetooth features right? Then there is an internal IP block for the BT/WiFi/ and whatnot on the board. How to get them working with mainline? Can you please point me to the right direction?

alifilhan0 commented 3 years ago

This is the part I am in problem with

drivers/misc/mediatek/connectivity/common/common_main/core/stp_core.c: In function ‘stp_parser_data_in_full_mode’: drivers/misc/mediatek/connectivity/common/common_main/core/stp_core.c:2081:25: error: this ‘else’ clause does not guard... [-Werror=misleading-indentation] 2081 | else | ^~~~ drivers/misc/mediatek/connectivity/common/common_main/core/stp_core.c:2083:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’ 2083 | stp_core_ctx.parser.type = (*p_data & 0x70) >> 4; | ^~~~~~~~~~~~ CC kernel/stop_machine.o CC fs/proc/util.o CC fs/proc/version.o CC kernel/utsname_sysctl.o cc1: all warnings being treated as errors make[7]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/common/common_main/core/stp_core.o] Error 1 make[6]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common/common_main/core] Error 2 make[5]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common/common_main] Error 2 make[4]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common] Error 2 make[3]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity] Error 2 make[2]: *** [scripts/Makefile.build:514: drivers/misc/mediatek] Error 2 make[1]: *** [scripts/Makefile.build:514: drivers/misc] Error 2 make: *** [Makefile:1851: drivers] Error 2 make: *** Waiting for unfinished jobs...

alifilhan0 commented 3 years ago

I tried only with the vendor kernel. And it works. Then I directly pasted and enabled these codes into the linux kernel 5.12.9. No inner-testing. One thing to note though this is from my board's kernel source. And a simple glance and I understood the directories in this kernel and the one of MT8516 we were trying with is almost same, with MT6735 files.

frank-w commented 3 years ago

error: this ‘else’ clause does not guard.

Is only indentation issue

https://github.com/frank-w/BPI-R2-4.14/commit/059b8b0eb049ecd84bd8e6826ce6efc55af4291a#diff-316ff3f2eb45ca2cb637970009b1b3c3b425a658daf49d7a024c58efa487934e

alifilhan0 commented 3 years ago

It's getting late everytime to give you updates, since the code base for me is much more bigger than in the repo. The return show_stack error doesn't fix. I added KERN_DEFAULT but still the error is same.

frank-w commented 3 years ago

Have you looked where show_stack is defined (header file) and if this is included?

Implicit declaration is using a function which is not declared before this use

Maybe it is moved to another header...have you uploaded code? What is exact error (file,line)?

Btw have you a datasheet with registervalues for mt6625l?

Do you try getting mt7623 support too?

alifilhan0 commented 3 years ago

Sorry, I forgot the error message. It was late in night. drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c: In function ‘osal_thread_show_stack’: drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:318:16: error: implicit declaration of function ‘show_stack’ [-Werror=implicit-function-declaration] 318 | return show_stack(pThread->pThread, NULL, KERN_DEFAULT); | ^~~~~~ drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:318:16: error: ‘return’ with a value, in function returning void [-Werror=return-type] 318 | return show_stack(pThread->pThread, NULL, KERN_DEFAULT); | ^~~~~~~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:316:20: note: declared here 316 | _osalinline VOID osal_thread_show_stack(P_OSAL_THREAD pThread) | ^~~~~~ In file included from ./include/linux/workqueue.h:9, from ./include/linux/mm_types.h:16, from ./include/linux/mmzone.h:21, from ./include/linux/gfp.h:6, from ./include/linux/umh.h:4, from ./include/linux/kmod.h:9, from ./include/linux/module.h:16, from drivers/misc/mediatek/connectivity/common/common_main/linux/include/osal_typedef.h:25, from drivers/misc/mediatek/connectivity/common/common_main/linux/include/osal.h:24, from drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:35: drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c: In function ‘osal_timer_create’: drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:629:33: error: passing argument 2 of ‘init_timer_key’ from incompatible pointer type [-Werror=incompatible-pointer-types] 629 | timer_setup(timer,pTimer->timeoutHandler,0); ./include/linux/timer.h:126:35: note: in definition of macro ‘__init_timer’ 126 | init_timer_key((_timer), (_fn), (_flags), NULL, NULL) | ^~~ drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:629:9: note: in expansion of macro ‘timer_setup’ 629 | timer_setup(timer,pTimer->timeoutHandler,0); | ^~~ ./include/linux/timer.h:92:28: note: expected ‘void ()(struct timer_list )’ but argument is of type ‘P_TIMEOUT_HANDLER’ {aka ‘void ()(long unsigned int)’} 92 | void (func)(struct timer_list *), unsigned int flags, | ~^~~~~~~~ CC drivers/misc/mediatek/connectivity/common/common_main/linux/wmt_dbg.o

As for datahseet of MT6625L, it seems a functional specification doesn't exist. Only the technical brief is found everywhere. The chinese vendors in those chinese tech forum sites are also looking for it and with no result. And as for chip support, this driver isn't SoC specific unless you add some platform codes. And I will try to get MT7623, MT673X(all) and MT8382 working with this driver. The register value datasheet for MT6625L simply doesn't exist, or at least not within our reach. But we might get the reg values from reverse engineering the firmware, since this is the most important blob for this chip.

alifilhan0 commented 3 years ago

Okay, I fixed show_stack error by including the include/linux/sched/debug.h file directly. No show stack errors again :)

frank-w commented 3 years ago

Timer_setup was bit tricky

http://forum.banana-pi.org/t/bpi-r2-internal-wifi-bt-mt6625l-kernel/4307/24

You can search my code to see how i have changed it

@@ -3331,9 +3331,7 @@ VOID kalOsTimerInitialize(IN P_GLUE_INFO_T prGlueInfo, IN 
PVOID prTimerHandler)

        ASSERT(prGlueInfo);

-       init_timer(&(prGlueInfo->tickfn));
-       prGlueInfo->tickfn.function = prTimerHandler;
-       prGlueInfo->tickfn.data = (ULONG) prGlueInfo;
+       timer_setup(&(prGlueInfo->tickfn), prTimerHandler, 0);
 }

 /* Todo */
@@ -3434,10 +3432,10 @@ UINT_32 kalRandomNumber(VOID)
  * \retval (none)
  */
 /*----------------------------------------------------------------------------*/
-VOID kalTimeoutHandler(ULONG arg)
+VOID kalTimeoutHandler(struct timer_list *t)
 {

-       P_GLUE_INFO_T prGlueInfo = (P_GLUE_INFO_T) arg;
+       P_GLUE_INFO_T prGlueInfo = from_timer(prGlueInfo, t, tickfn);

        ASSERT(prGlueInfo);

Btw this was bluetooth fix: https://github.com/frank-w/BPI-R2-4.14/commit/c0603006d7f020bbcb42bed36127fbfe94b1b512

Basicly allow building as module and loading after firmware is loaded

this change may come later too:

-       ret = vfs_write(file, data, size, &offset);
+       ret = kernel_write(file, data, size, &offset);

basicly you can do a

git diff 4.4-main..5.10-main -- drivers/misc/mediatek

in my repo to see all my changes (or maybe start at 4.9-main because i started from 4.9-patches)

alifilhan0 commented 3 years ago

Isn't this a bit weird? drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c: In function ‘osal_timer_create’: drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:630:33: error: passing argument 2 of ‘init_timer_key’ from incompatible pointer type [-Werror=incompatible-pointer-types] 630 | timer_setup(timer,pTimer->timeoutHandler,0); ./include/linux/timer.h:126:35: note: in definition of macro ‘__init_timer’ 126 | init_timer_key((_timer), (_fn), (_flags), NULL, NULL) | ^~~ drivers/misc/mediatek/connectivity/common/common_main/linux/osal.c:630:9: note: in expansion of macro ‘timer_setup’ 630 | timer_setup(timer,pTimer->timeoutHandler,0); | ^~~~~~~~~~~ ./include/linux/timer.h:92:28: note: expected ‘void (*)(struct timer_list *)’ but argument is of type ‘P_TIMEOUT_HANDLER’ {aka ‘void (*)(long unsigned int)’} 92 | void (*func)(struct timer_list *), unsigned int flags, | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/common/common_detect/wmt_detect.o] Error 1

frank-w commented 3 years ago

seems i have not changed

P_TIMEOUT_HANDLER

drivers/misc/mediatek/connectivity/common/conn_soc/linux/include/osal.h:116:typedef VOID(*P_TIMEOUT_HANDLER) (unsigned long);

but you need some change like this:

-VOID kalTimeoutHandler(ULONG arg);
+VOID kalTimeoutHandler(struct timer_list *t);

maybe

typedef VOID(P_TIMEOUT_HANDLER) (struct timer_list t);

and same for the handler itself

drivers/misc/mediatek/connectivity/common/conn_soc/linux/pri/stp_dbg.c:184:static void core_dump_timeout_handler(unsigned long data)

static void core_dump_timeout_handler(struct timer_list *t)

now you have to change from data to t like above (from_timer)

alifilhan0 commented 3 years ago

well, what is this by the way?

drivers/misc/mediatek/btif/common/mtk_btif.c:881:23: error: ‘flag_show’ undeclared here (not in a function) 881 | static DRIVER_ATTR_RW(flag); | ^~~~ ./include/linux/sysfs.h:104:19: note: in definition of macro ‘__ATTR’ 104 | .show = _show, \ | ^~~~~ ./include/linux/device/driver.h:142:55: note: in expansion of macro ‘__ATTR_RW’ 142 | struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) | ^~~~~~~~~ drivers/misc/mediatek/btif/common/mtk_btif.c:881:8: note: in expansion of macro ‘DRIVER_ATTR_RW’ 881 | static DRIVER_ATTR_RW(flag); | ^~~~~~~~~~~~~~ drivers/misc/mediatek/btif/common/mtk_btif.c:881:23: error: ‘flag_store’ undeclared here (not in a function); did you mean ‘xas_store’? 881 | static DRIVER_ATTR_RW(flag); | ^~~~ ./include/linux/sysfs.h:105:19: note: in definition of macro ‘__ATTR’ 105 | .store = _store, \ | ^~~~~~ ./include/linux/device/driver.h:142:55: note: in expansion of macro ‘__ATTR_RW’ 142 | struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) | ^~~~~~~~~ drivers/misc/mediatek/btif/common/mtk_btif.c:881:8: note: in expansion of macro ‘DRIVER_ATTR_RW’ 881 | static DRIVER_ATTR_RW(flag); | ^~~~~~~~~~~~~~

alifilhan0 commented 3 years ago

By the way I have another issue with the driver. It is not in this 5.10 kernel but we had it in the 4.4-mt6625l brnch, namely drivers/misc/mediatek/common/common_main/linux/stp_uart.c

The error drivers/misc/mediatek/connectivity/common/common_main/linux/stp_uart.c: In function ‘mtk_wcn_stp_uart_init’: drivers/misc/mediatek/connectivity/common/common_main/linux/stp_uart.c:776:41: error: assignment to ‘ssize_t (*)(struct tty_struct *, struct file *, unsigned char *, size_t, void **, long unsigned int)’ {aka ‘long int (*)(struct tty_struct *, struct file *, unsigned char *, long unsigned int, void **, long unsigned int)’} from incompatible pointer type ‘ssize_t (*)(struct tty_struct *, struct file *, unsigned char *, size_t)’ {aka ‘long int (*)(struct tty_struct *, struct file *, unsigned char *, long unsigned int)’} [-Werror=incompatible-pointer-types] 776 | stp_uart_ldisc.read = stp_uart_tty_read; | ^ stp_uart.zip

frank-w commented 3 years ago

Okay, I fixed show_stack error by including the include/linux/sched/debug.h file directly. No show stack errors again :)

In 4.4 this macro has params 3 show and 4 store (see your error message)

https://elixir.bootlin.com/linux/v4.4.270/source/include/linux/device.h#L303

This is there till 4.13,then dropped with 4.14

But DRIVER_ATTR_RO and DRIVER_ATTR_RW are still present

Based on https://linux.kernel.narkive.com/vS1tQDfe/patch-xen-xen-pciback-remove-driver-attr-usage functions need to be named xxx_show (read) and xxx_store and call DRIVER_ATTR_RW(xxx),or DRIVER_ATTR_RO if only a read function exists

alifilhan0 commented 3 years ago

I actually did those before commenting. But those functions pop up as flag_store defined but not used, flag_show defined but not used. And then the same macro errors again

frank-w commented 3 years ago

As your functions are not named flag_show and flag_store...

driver_flag_read needs to be renamed to flag_show and driver_flag_set to flag_store

But you should not name them flag_ more mtkbtif and pass mtk_btif

I did it with flag,but this is bo good name

https://github.com/frank-w/BPI-R2-4.14/blob/4.14-main/drivers/misc/mediatek/btif/common/mtk_btif.c#L891

alifilhan0 commented 3 years ago

I am struggling here. I just can't understand where is the mistake in this case...... drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c: In function ‘wmt_plat_wake_lock_ctrl’: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1349:17: error: ‘status’ undeclared (first use in this function); did you mean ‘kstatfs’? 1349 | status = wmtWakeLock->active; | ^~~~~~ | kstatfs drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1349:17: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1372:6: error: "MTK_MERGE_INTERFACE_SUPPORT" is not defined, evaluates to 0 [-Werror=undef] 1372 | #if (MTK_MERGE_INTERFACE_SUPPORT) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1401:2: error: unterminated argument list invoking macro "WMT_DBG_FUNC" 1401 | } | ^ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1350:9: error: ‘WMT_DBG_FUNC’ undeclared (first use in this function); did you mean ‘WMT_OPID_FUNC’? 1350 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^~~~~~~~~~~~ | WMT_OPID_FUNC drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1350:21: error: expected ‘;’ at end of input 1350 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^ | ; ...... drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1350:9: error: expected declaration or statement at end of input 1350 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^~~~~~~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1350:9: error: expected declaration or statement at end of input drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c: In function ‘wmt_plat_uart_ctrl’: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:893:17: error: this statement may fall through [-Werror=implicit-fallthrough=] 893 | pinctrl_select_state(gpio_ctrl_info.pinctrl_info, gpio_ctrl_info. | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 894 | gpio_ctrl_state[GPIO_COMBO_URXD_PIN].gpio_state[GPIO_IN_PULLUP]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:895:9: note: here 895 | default: | ^~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c: In function ‘wmt_plat_wake_lock_ctrl’: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1402: error: control reaches end of non-void function [-Werror=return-type] At top level: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:114:28: error: ‘gCommIfType’ defined but not used [-Werror=unused-variable] 114 | static ENUM_STP_TX_IF_TYPE gCommIfType = STP_MAX_IF_TX; | ^~~~~~~~~~~ cc1: all warnings being treated as errors make[8]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.o] Error 1 make[7]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common/common_main/platform/alps] Error 2 make[6]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common/common_main/platform] Error 2 make[6]: *** Waiting for unfinished jobs.... wmt_plat_alps.zip

frank-w commented 3 years ago

You try to assign to vriable status,but this is not defined...look for static vars in code and include the header...

Why do you not push the codebase?

alifilhan0 commented 3 years ago

Sorry actually, the code is far from being usable, I will try to clean it up a bit. Since it also has a lot of modem and other files I need. I suppose WMT_DBG_FUNC is defined in mach/emi_mpu.h, and can't understand what the pinctrl error is.

frank-w commented 3 years ago

error: this statement may fall through

?

Means you have a switch and one option has no break,so next option is called too. This can be intended,but with newer gcc this has to be noted afair with / fallthrough / newer kernels have a const/macro for this defined

https://patchwork.kernel.org/project/linux-security-module/patch/f31b38b9ad515a138edaecf85701b1e3db064114.camel@perches.com/

alifilhan0 commented 3 years ago

I had gone through a lot more issues, but now fixed them. But how did you fix this issue? After the connectivity directory is stabilized, I will push this code in github.

drivers/misc/mediatek/connectivity/common/common_main/linux/wmt_dev.c:479:32: error: implicit declaration of function ‘get_fs’; did you mean ‘sget_fc’? [-Werror=implicit-function-declaration] 479 | mm_segment_t orig_fs = get_fs(); | ^~~~~~ | sget_fc drivers/misc/mediatek/connectivity/common/common_main/linux/wmt_dev.c:479:32: error: invalid initializer In file included from drivers/misc/mediatek/connectivity/fmradio/core/fm_main.c:15: ./arch/arm64/include/asm/uaccess.h: In function ‘__range_ok’: ./arch/arm64/include/asm/uaccess.h:38:36: error: ‘TASK_SIZE_MAX’ undeclared (first use in this function); did you mean ‘XATTR_SIZE_MAX’? 38 | unsigned long ret, limit = TASK_SIZE_MAX - 1; | ^~~~~~~~~~~~~ | XATTR_SIZE_MAX ./arch/arm64/include/asm/uaccess.h:38:36: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/mediatek/connectivity/ant/stp_chrdev_ant.c:546:9: error: implicit declaration of function ‘set_fs’; did you mean ‘sget_fc’? [-Werror=implicit-function-declaration] 546 | set_fs(old_fs); | ^~~~~~ | sget_fc ./arch/arm64/include/asm/uaccess.h:46:14: error: ‘current’ undeclared (first use in this function) 46 | (current->flags & PF_KTHREAD || test_thread_flag(TIF_TAGGED_ADDR))) | ^~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/linux/wmt_dev.c:506:9: error: implicit declaration of function ‘set_fs’; did you mean ‘sget_fc’? [-Werror=implicit-function-declaration] 506 | set_fs(get_ds()); | ^~~~~~ | sget_fc ./arch/arm64/include/asm/uaccess.h:46:31: error: ‘PF_KTHREAD’ undeclared (first use in this function) 46 | (current->flags & PF_KTHREAD || test_thread_flag(TIF_TAGGED_ADDR))) | ^~~~~~~~~~ drivers/misc/mediatek/connectivity/ant/stp_chrdev_ant.c:546:16: error: ‘old_fs’ undeclared (first use in this function) 546 | set_fs(old_fs); | ^~~~~~ drivers/misc/mediatek/connectivity/ant/stp_chrdev_ant.c:546:16: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/mediatek/connectivity/common/common_main/linux/wmt_dev.c:506:16: error: implicit declaration of function ‘get_ds’ [-Werror=implicit-function-declaration] 506 | set_fs(get_ds()); | ^~~~~~ ./arch/arm64/include/asm/uaccess.h:46:45: error: implicit declaration of function ‘test_thread_flag’ [-Werror=implicit-function-declaration] 46 | (current->flags & PF_KTHREAD || test_thread_flag(TIF_TAGGED_ADDR))) | ^~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ./arch/arm64/include/asm/uaccess.h:46:62: error: ‘TIF_TAGGED_ADDR’ undeclared (first use in this function) 46 | (current->flags & PF_KTHREAD || test_thread_flag(TIF_TAGGED_ADDR))) | ^~~~~~~~~~~~~~~ make[5]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/ant/stp_chrdev_ant.o] Error 1 make[4]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/ant] Error 2 CC drivers/misc/mediatek/connectivity/fmradio/core/fm_utils.o ./arch/arm64/include/asm/uaccess.h: In function ‘__uaccess_mask_ptr’: ./arch/arm64/include/asm/uaccess.h:225:27: error: ‘TASK_SIZE_MAX’ undeclared (first use in this function); did you mean ‘XATTR_SIZE_MAX’? 225 | : "r" (ptr), "r" (TASK_SIZE_MAX - 1), | ^~~~~~~~~~~~~ | XATTR_SIZE_MAX cc1: all warnings being treated as errors

here, TASK_SIZE_MAX is alright, but still comes as error from the uaccess.h header. Maybe some arm64 issue with the kernel?

frank-w commented 3 years ago

Afair get_fs is not available for aarch64 and will be dropped in future kernel versions. Basicly get_fs switches from kernel to usermode and back for file operations. Here it depends of what you try to do

I have a non get_fs implementation for geting filesize in mt76 driver (load eeprom from file)

https://github.com/frank-w/BPI-R2-4.14/commits/5.9-mt76eeprom

This is for filesize...if your code something different you need to have to make it different

alifilhan0 commented 3 years ago

wmt_plat_alps.zip No matter what i do, I just can't get pover this error. the WMT_DBG_FUNC is defined in wmt_exp.h and I included it too, still no progress. drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c: In function ‘wmt_plat_wake_lock_ctrl’: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1357:17: error: ‘status’ undeclared (first use in this function); did you mean ‘kstatfs’? 1357 | status = wmtWakeLock->active; | ^~~~~~ | kstatfs drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1357:17: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1411:2: error: unterminated argument list invoking macro "WMT_DBG_FUNC" 1411 | } | ^ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1358:9: error: ‘WMT_DBG_FUNC’ undeclared (first use in this function); did you mean ‘WMT_OPID_FUNC’? 1358 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^~~~~~~~~~~~ | WMT_OPID_FUNC drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1358:21: error: expected ‘;’ at end of input 1358 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^ | ; ...... drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1358:9: error: expected declaration or statement at end of input 1358 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^~~~~~~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1358:9: error: expected declaration or statement at end of input drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1412: error: control reaches end of non-void function [-Werror=return-type] cc1: all warnings being treated as errors

frank-w commented 3 years ago

You have to fix the status first...i guess it is defined as static int in any header which needs to included...or you have it accidentally removed

frank-w commented 3 years ago

in my code i found only these

drivers/misc/mediatek/btif/common/btif_plat.c:344:  static ENUM_CLOCK_CTRL status = CLK_OUT_DISABLE;
drivers/misc/mediatek/btif/common/btif_dma_plat.c:272:  static ENUM_CLOCK_CTRL status = CLK_OUT_DISABLE;

it is imho bad style to define static vars in c files for use in other c files...

alifilhan0 commented 3 years ago

Should I move these to some header file?

frank-w commented 3 years ago

Imho this would be the best way

You need to find a headerfile which is used by all 3 files (and at best only these 3) c files,

And status is a bad name for var in global context...better name it mtk_clock_status or similar

alifilhan0 commented 3 years ago

Unfortunately, there's no common header file between btif files and the wmt_plat_alps.c file. So for now only, I just added it there in the c file. status error is gone, now still the WMT_DBG_FUNC remains. I have included the header containing it's definition but still no luck. drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1351:9: error: ‘WMT_DBG_FUNC’ undeclared (first use in this function); did you mean ‘WMT_OPID_FUNC’? 1351 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^~~~~~~~~~~~ | WMT_OPID_FUNC drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1351:9: note: each undeclared identifier is reported only once for each function it appears in drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1351:21: error: expected ‘;’ at end of input 1351 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^ | ; ...... drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1351:9: error: expected declaration or statement at end of input 1351 | WMT_DBG_FUNC("WMT-PLAT: after wake_lock(%d), counter(%d)\n"; | ^~~~~~~~~~~~ drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1351:9: error: expected declaration or statement at end of input drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.c:1405: error: control reaches end of non-void function [-Werror=return-type] cc1: all warnings being treated as errors make[8]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/common/common_main/platform/alps/wmt_plat_alps.o] Error 1 make[7]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common/common_main/platform/alps] Error 2 make[6]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/common/common_main/platform] Error 2 make[6]: *** Waiting for unfinished jobs....

frank-w commented 3 years ago

You could create a new header for this static...but if it works now it is ok...i thought about redefinition errors...

Is WMT_DBG_FUNC really defined? Maybe it's guarded by an ifdef or not defined due other error

alifilhan0 commented 3 years ago

For your tree, I think it is actually defined in drivers/misc/mediatek/connectivity/common/conn_soc/include/wmt_exp.h line 64. #define WMT_DBG_FUNC. Is this the right place?

frank-w commented 3 years ago

conn_soc is common_main in your (and my 4.4-mt6625) tree. I guess it's the right place as it works :)

alifilhan0 commented 3 years ago

In my tree, I do have it at drivers/misc/mediatek/connectivity/common_main/include/wmt_exp.h and I did include it in the .c file. Still not defined errors, same as above.

frank-w commented 3 years ago

In my code there is a comment for the if block

moved from wmt_lib.h

Maybe you need the while workaround too

Maybe your source does not include this defines...or other version of this file is used...some files were duplicates in original tree, over time i dropped them

alifilhan0 commented 3 years ago

But can you explain a little bit what function these moved codes do and how did it do the same thing staying at different header files?

By the way, I found this at wmt_exp.h line 205 WMT_SDIO_SLOT_SDIO1 = 1, / Wi-Fi dedicated SDIO1 /.

This makes me highly willing to try the MT6625 with mt7668 or mt7663 driver, might do it after I get this in-work kernel to booting. And the consys IP is just a SDIO interface, named differently I guess.

alifilhan0 commented 3 years ago

My source does include the comments moved from wmt_lib.h beforehand like your header file. So what's the fix here? it does have the exact same code as yours in 5.10, so which workaround I need?

frank-w commented 3 years ago

I mean the while workaround as macro body

https://github.com/frank-w/BPI-R2-4.14/blob/5.4-main/drivers/misc/mediatek/connectivity/common/conn_soc/include/wmt_exp.h#L64

alifilhan0 commented 3 years ago

Okay I fixed this issue, gonna focus on the GPS and FM errors, after fixed, will upload the code in a repo.

alifilhan0 commented 3 years ago

Now these errors are bugging me. Any suggestion?

In file included from ./include/acpi/acpi.h:24, from ./include/linux/acpi.h:22, from ./include/linux/i2c.h:13, from ./include/uapi/linux/fb.h:6, from ./include/linux/fb.h:6, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:150, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/dump.c:23: ./include/acpi/actypes.h:581:41: error: expected identifier before ‘(’ token 581 | #define ACPI_STATE_D0 (u8) 0 | ^ drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/wlan_def.h:385:9: note: in expansion of macro ‘ACPI_STATE_D0’ 385 | ACPI_STATE_D0 = 0, | ^~~~~~~~~~~~~ In file included from ./include/acpi/acpi.h:24, from ./include/linux/acpi.h:22, from ./include/linux/i2c.h:13, from ./include/uapi/linux/fb.h:6, from ./include/linux/fb.h:6, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:150, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_lib.c:23: ./include/acpi/actypes.h:581:41: error: expected identifier before ‘(’ token 581 | #define ACPI_STATE_D0 (u8) 0 | ^ drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/wlan_def.h:385:9: note: in expansion of macro ‘ACPI_STATE_D0’ 385 | ACPI_STATE_D0 = 0, | ^~~~~~~~~~~~~ CC [M] drivers/misc/mediatek/connectivity/wlan/gen2/common/debug.o CC [M] drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_p2p.o make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/common/dump.o] Error 1 make[6]: *** Waiting for unfinished jobs.... make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_lib.o] Error 1 In file included from ./include/acpi/acpi.h:24, from ./include/linux/acpi.h:22, from ./include/linux/i2c.h:13, from ./include/uapi/linux/fb.h:6, from ./include/linux/fb.h:6, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:150, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_bow.c:23: ./include/acpi/actypes.h:581:41: error: expected identifier before ‘(’ token 581 | #define ACPI_STATE_D0 (u8) 0 | ^ drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/wlan_def.h:385:9: note: in expansion of macro ‘ACPI_STATE_D0’ 385 | ACPI_STATE_D0 = 0, | ^~~~~~~~~~~~~ In file included from ./include/acpi/acpi.h:24, from ./include/linux/acpi.h:22, from ./include/linux/i2c.h:13, from ./include/uapi/linux/fb.h:6, from ./include/linux/fb.h:6, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:150, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_oid.c:23: ./include/acpi/actypes.h:581:41: error: expected identifier before ‘(’ token 581 | #define ACPI_STATE_D0 (u8) 0 | ^ drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/wlan_def.h:385:9: note: in expansion of macro ‘ACPI_STATE_D0’ 385 | ACPI_STATE_D0 = 0, | ^~~~~~~~~~~~~ make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_bow.o] Error 1 In file included from ./include/acpi/acpi.h:24, from ./include/linux/acpi.h:22, from ./include/linux/i2c.h:13, from ./include/uapi/linux/fb.h:6, from ./include/linux/fb.h:6, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:150, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/debug.c:14: ./include/acpi/actypes.h:581:41: error: expected identifier before ‘(’ token 581 | #define ACPI_STATE_D0 (u8) 0 | ^ drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/wlan_def.h:385:9: note: in expansion of macro ‘ACPI_STATE_D0’ 385 | ACPI_STATE_D0 = 0, | ^~~~~~~~~~~~~ In file included from ./include/linux/kernel.h:16, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:117, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_oid.c:23: drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_oid.c: In function ‘wlanoidSetAcpiDevicePowerState’: ./include/linux/printk.h:141:9: error: this statement may fall through [-Werror=implicit-fallthrough=] 141 | 0; \ | ^ ./include/linux/printk.h:430:9: note: in expansion of macro ‘no_printk’ 430 | no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_kal.h:450:53: note: in expansion of macro ‘pr_debug’ 450 | #define kalPrint(_Fmt...) pr_debug(WLAN_TAG _Fmt) | ^~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/include/debug.h:176:33: note: in expansion of macro ‘kalPrint’ 176 | #define LOG_FUNC kalPrint | ^~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/include/debug.h:183:17: note: in expansion of macro ‘LOG_FUNC’ 183 | LOG_FUNC("%s:(" #_Module " " #_Class ") " _Fmt, __func__, ##__VA_ARGS__); \ | ^~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_oid.c:5866:17: note: in expansion of macro ‘DBGLOG’ 5866 | DBGLOG(OID, INFO, "Set Power State: D2\n"); | ^~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_oid.c:5868:9: note: here 5868 | case ParamDeviceStateD3: | ^~~~ cc1: all warnings being treated as errors make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_oid.o] Error 1 make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/common/debug.o] Error 1 In file included from ./include/acpi/acpi.h:24, from ./include/linux/acpi.h:22, from ./include/linux/i2c.h:13, from ./include/uapi/linux/fb.h:6, from ./include/linux/fb.h:6, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:150, from drivers/misc/mediatek/connectivity/wlan/gen2/include/precomp.h:26, from drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_p2p.c:23: ./include/acpi/actypes.h:581:41: error: expected identifier before ‘(’ token 581 | #define ACPI_STATE_D0 (u8) 0 | ^ drivers/misc/mediatek/connectivity/wlan/gen2/include/nic/wlan_def.h:385:9: note: in expansion of macro ‘ACPI_STATE_D0’ 385 | ACPI_STATE_D0 = 0, | ^~~~~~~~~~~~~ make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/common/wlan_p2p.o] Error 1 make[5]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/wlan/gen2] Error 2 make[4]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity/wlan] Error 2 make[3]: *** [scripts/Makefile.build:514: drivers/misc/mediatek/connectivity] Error 2 make[2]: *** [scripts/Makefile.build:514: drivers/misc/mediatek] Error 2 make[1]: *** [scripts/Makefile.build:514: drivers/misc] Error 2 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1851: drivers] Error 2 make: *** Waiting for unfinished jobs....

This directly triggers the linux kernel headers, instead of the headers triggering the .c files, am I right?

EDIT:- Seems like it was a header file issue , include/linux/fb.h, Which I simply removed and it worked fine.

alifilhan0 commented 3 years ago

Now I am stuck here. Finally I think I am ready to deploy my code in github...what do you think? Further tries doesn't get me ahead in these erros and I can't figure out how to solve these.

drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.c:31:29: error: expected declaration specifiers or ‘...’ before string constant 31 | #define NIC_NAME "MT6582" | ^~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.c:3078:25: note: in expansion of macro ‘NIC_NAME’ 3078 | MODULE_SUPPORTED_DEVICE(NIC_NAME); | ^~~~~~~~ make[6]: *** [scripts/Makefile.build:271: drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_init.o] Error 1 make[6]: *** Waiting for unfinished jobs.... drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_wext_priv.c: In function ‘scanEnvResult’: drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_wext_priv.c:681:9: error: ISO C90 forbids variable length array ‘text’ [-Werror=vla] 681 | UCHAR text[ucTextLen]; | ^~~~~ cc1: all warnings being treated as errors

EDIT:- Simly adding Wno-vla to KCFLAGS in the make commands fixed the ISO c90 error. Only the NIC_NAME error remains.

frank-w commented 3 years ago

MODULE_SUPPORTED_DEVICE is not defined in 5.12 (seems to be dropped there...was still in 5.11). Either redefine it or better move code to new way

Based on this and comment above it is only a placeholder and can be dropped in source

https://lore.kernel.org/patchwork/patch/572238/

It would be nice if you have first version unchanged and then commit(s) with your changes for porting to see if changes are right

alifilhan0 commented 3 years ago

Now this error. I find it hard to find out this one. Can you help? BTW, your header gl_os.h is exactly same in defining the #define GLUE_SPIN_LOCK_DECLARATION() unsigned long __u4Flags. How to fix this error?

And for the commits, can you teach me how to do that? I do have the pristine version of the code, unchanged and the work-in-progress version of the code I am struggling with. I never used github for repos before.

drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:738:61: error: expected ‘,’ or ‘;’ before ‘unsigned’ 738 | #define GLUE_SPIN_LOCK_DECLARATION() unsigned long __u4Flags = 0 | ^~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_kal.c:885:9: note: in expansion of macro ‘GLUE_SPIN_LOCK_DECLARATION’ 885 | GLUE_SPIN_LOCK_DECLARATION(); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ./include/linux/kernel.h:15, from ./include/linux/bitmap.h:10, from ./include/linux/ethtool.h:16, from ./include/net/cfg80211.h:13, from drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_kal.c:23: ./drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:742:84: error: ‘__u4Flags’ undeclared (first use in this function) 742 | spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \ | ^~~~~~~~~ ./include/linux/typecheck.h:11:16: note: in definition of macro ‘typecheck’ 11 | typeof(x) __dummy2; \ | ^ ./include/linux/spinlock.h:384:9: note: in expansion of macro ‘raw_spin_lock_irqsave’ 384 | raw_spin_lock_irqsave(spinlock_check(lock), flags); \ | ^~~~~~~~~~~~~~~~~~~~~ ./drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:742:25: note: in expansion of macro ‘spin_lock_irqsave’ 742 | spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \ | ^~~~~~~~~~~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_kal.c:903:17: note: in expansion of macro ‘GLUE_ACQUIRE_SPIN_LOCK’ 903 | GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, SPIN_LOCK_NET_DEV); | ^~~~~~~~~~~~~~~~~~~~~~ ./drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:742:84: note: each undeclared identifier is reported only once for each function it appears in 742 | spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \ | ^~~~~~~~~ ./include/linux/typecheck.h:11:16: note: in definition of macro ‘typecheck’ 11 | typeof(x) __dummy2; \ | ^ ./include/linux/spinlock.h:384:9: note: in expansion of macro ‘raw_spin_lock_irqsave’ 384 | raw_spin_lock_irqsave(spinlock_check(lock), flags); \ | ^~~~~~~~~~~~~~~~~~~~~ ./drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:742:25: note: in expansion of macro ‘spin_lock_irqsave’ 742 | spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \ | ^~~~~~~~~~~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_kal.c:903:17: note: in expansion of macro ‘GLUE_ACQUIRE_SPIN_LOCK’ 903 | GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, SPIN_LOCK_NET_DEV); | ^~~~~~~~~~~~~~~~~~~~~~ ./include/linux/typecheck.h:12:25: error: comparison of distinct pointer types lacks a cast [-Werror] 12 | (void)(&__dummy == &__dummy2); \ | ^~ ./include/linux/spinlock.h:251:17: note: in expansion of macro ‘typecheck’ 251 | typecheck(unsigned long, flags); \ | ^~~~~~~~~ ./include/linux/spinlock.h:384:9: note: in expansion of macro ‘raw_spin_lock_irqsave’ 384 | raw_spin_lock_irqsave(spinlock_check(lock), flags); \ | ^~~~~~~~~~~~~~~~~~~~~ ./drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h:742:25: note: in expansion of macro ‘spin_lock_irqsave’ 742 | spin_lock_irqsave(&(prGlueInfo)->rSpinLock[rLockCategory], __u4Flags); \ | ^~~~~~~~~~~~~~~~~ drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_p2p_kal.c:903:17: note: in expansion of macro ‘GLUE_ACQUIRE_SPIN_LOCK’ 903 | GLUE_ACQUIRE_SPIN_LOCK(prGlueInfo, SPIN_LOCK_NET_DEV); | ^~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors

frank-w commented 3 years ago

For macro ig uess you need to change the line

define GLUE_SPIN_LOCK_DECLARATION() unsigned long __u4Flags = 0

But i don't know how...you need flags passed as second parameter to spin_lock_irqsave (i dont see link to it),first is the lock.

For git, it is a normal git procedure. Clone kernel-repo as base,add and commit original 4.4.source. then add your changes and commit them as second commit.

alifilhan0 commented 3 years ago

Can we use a different flag? Can you think for sometime and come up with the solution? I can't figure this out yet.. And how about using UINT_32 instead of unsigned long? What do you think? Looking forward for a solution, if found please let me know

alifilhan0 commented 3 years ago

And yes, remember the seemingly cleaner code of consys we found from BSP MT8516? I will work on it too again. I suppose it was some kernel problem with 4.4 that I failed to compile with, so without further testing with 4.4, I will just add it with the latest kernels possible. But it has the same header with the same problematic definition of unsigned long __u4Flags.....which do need a fix

frank-w commented 3 years ago

for GLUE_SPIN_LOCK_DECLARATION there are 2 definitions in drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/include/gl_os.h

one with flag (!CFG_USE_SPIN_LOCK_BOTTOM_HALF) , one without (CFG_USE_SPIN_LOCK_BOTTOM_HALF). as i can compile without this error, i guess in my code is somewhere different, but i don't see CFG_USE_SPIN_LOCK_BOTTOM_HALF set anywhere, so i should fall into this too

as far as i see in drivers/misc/mediatek/connectivity/wlan/gen2/os/linux/gl_kal.c GLUE_SPIN_LOCK_DECLARATION(); is always called without params...

for the cleaner code...my 4.4-mt6625 branch contains this, it only failes after adding mt7623 content

alifilhan0 commented 3 years ago

It is supposed to be enabled by 0 or 1 in the same header file, am I right? `

define CFG_USE_SPIN_LOCK_BOTTOM_HALF 0 /* 1: Enable use of SPIN LOCK Bottom Half for LINUX

                           0: Disable - use SPIN LOCK IRQ SAVE instead */`

If not defined, i.e 0, uses that __u4FLags code, and if defined, it has a slightly different code for this. But what does this SPIN_LOCK does actually? And did you set it to Zero?

alifilhan0 commented 3 years ago

By the way, what does that 0 mean after u4Flags = 0? I found similar definition with u4Flagsbut no zero.

`#define KAL_SPIN_LOCK_DECLARATION() unsigned long __u4Flags

define KAL_ACQUIRE_SPIN_LOCK(_prAdapter, _rLockCategory) \

    kalAcquireSpinLock(((P_ADAPTER_T)_prAdapter)->prGlueInfo, _rLockCategory, &__u4Flags)

define KAL_RELEASE_SPIN_LOCK(_prAdapter, _rLockCategory) \

    kalReleaseSpinLock(((P_ADAPTER_T)_prAdapter)->prGlueInfo, _rLockCategory, __u4Flags)`

And this code doesn't give me any errors. Maybe define XXX unsigned long __u4Flags = 0 is a bad c code? I mean maybe it is not supported to define two variables in a single line?

alifilhan0 commented 3 years ago

Apparently, this wasn't that hard at all :). I had looked into that and guessed maybe defining two variables together maybe the problem, so added ; after GLUE_SPIN_LOCK_DECLARATION() and taking the unsigned long part next line. I still have incomplete clk drivers, so I can't test yet(I stopped other tasks to fix these drivers) :( .

alifilhan0 commented 3 years ago

I have a question, can we use the legacy clkmgr driver for modem and consys? because writing new clk driver for these unknown interfaces will be really tough for me. Have you ever tried it? Or is it even theoretically possible to use the mainline Common Clock Framework for all other peripherals but for Consys and Modem systems, we use the CLKMGR? I can save a lot of work if I can find it is possible. Like I want to use the mainline Power Management system using device trees of MT6328(in-progress), and the legacy clk manager driver for these unknown interfaces.....

frank-w commented 3 years ago

I don't know if it is possible as i have no technical information about it,but afair i only ported no external (outside of drivers/misc/mediatek) clock driver

alifilhan0 commented 3 years ago

As far as I know, the consys required two clocks, one is the infra bus clock and the scpsys clock. The only thing I am worried about using the legacy clock manager is that it will conflict with the clocks already enabled by the common clock framework or vice-versa. Will this actually happen? By the way, I started my work from here, this is actually my base repo. I.E my phone's kernel source. https://github.com/ikull/kernel_motorola_woods. Look into the directory, https://github.com/ikull/kernel_motorola_woods/blob/los-14.1/drivers/clk/mediatek/clk-mt6735-pg.c, where it does define the clocks for modem and consys in a modern way, and these clock definitions are similar across all SoCs with the similar consys configuration. In drivers/msic/mediatek/base/power/, legacy clock manager is found. I don't understand what to do now, adapt the modern clock(is it useable at all? looks like a bit of scpsys driver and clk driver mixed to me) or adapt the legacy clock driver.