add MediaTek MT6589 family support?
MediaTek MT6589 (MT6588?/MT6589M/MT6589/MT6589T?/MT8125/MT8389, the almost same kernel source code is used) is equipped with PowerVR SGX544MP, and it appears that a kernel space driver is based on a typical DDK.
- https://github.com/TeamYogaBlade2/android_kernel_lenovo_b8000-jellybean_osc/tree/main/mediatek/platform/mt6589/kernel/drivers/gpu/pvr
- https://github.com/bq/aquaris-5/tree/aquaris-5/mediatek/platform/mt6589/kernel/drivers/gpu/pvr
- https://github.com/bq/aquaris-5HD/tree/aquaris-5HD/mediatek/platform/mt6589/kernel/drivers/gpu/pvr
- https://github.com/hyperion70/iq451_mt6589/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr
Could you integrate MT6589 support into this kernel tree? However, MT6589 has very limited support in the mainline kernel. I am currently working on Linux and U-Boot near-mainline for the MT6589.
Yes, that is indeed interesting! There are 2 (or 3) new 1.9.2xxxx DDK versions and one 1.12. Integration into the code base does not seem to be difficult (some git clone + rewriting history to pick the interesting subdirectories). More complex is making it compile and the most challenging part is to get it up and running... That also needs a device to test on. But for making a first step, collecting the code into a single place is a good move. Thanks for the links!
Clock driver support is required to integrate the MT6589 PVR driver into the mainline, but currently the mainline does not support the MT6589 clock driver. It is difficult to integrate downstream clock drivers as is (due to code quality and not Driver Model), so it needs to be rewritten. I will soon be working on porting the clock driver.
I have now cloned the four repositories, did a git filter-branch to extract the drivers/gpu/drm/pvr code into a structure that fits into our tree. Interestingly it also contains some user-space code tailored for Android (which is now removed for our purposes but available in the original projects).
It turned out that iq451_mt6589 and TeamYogaBlade2 android_kernel_lenovo_b8000-jellybean are almost identical, except one difference in one config file. Nevertheless I did take all four versions and now we have two new DDK 1.9 and two DDK 1.12 variants. The collection gets more variants and at some point in time it may become possible to linearize this into some single "master" (closer to the original) and derive SoC-integration specific variants from it...
Next, I rebased the new branches on current mainline (v6.17-rc4) and modified the Kconfig and Makefile of our pvrsrvkm driver. This was almost straightforward, since there is for example a CONFIG_MACH_MT6589.
Then I tried to really build an pvrsrvkm. I had to modify the original Makefile because it makes some assumptions about how it is embedded into the kernel tree. Not difficult.
But now comes the real challenge: the code base is quite old and can not be directly compiled against the v6.17-rc4 APIs. The easiest parts are some #include files that do no longer exist. But several kernel functions have changed parameters and sometimes data types. Some are renamed or have been replaced. Well, this is not different from what happened to the other DDK versions we already have collected. So it is not too difficult to pick these changes from there, but needs some more work.
Anyways I have pushed the work-in progress (merged with letux-6.17-rc4) here: https://github.com/openpvrsgx-devgroup/linux_openpvrsgx/tree/work-pvrsrvkm-mt6589 or https://git.goldelico.com/?p=letux-kernel.git;a=shortlog;h=refs/heads/work-pvrsrvkm-mt6589 (to compile: "make letux_defconfig" to use the config I have used for my experiments).
Some other note: it turned out that there are three different GPU speed variants of the MT6589 (suffix M or T). These are currently handled by CONFIG definitions by the Makefile. This would mean we need to build 3 variants. Or if possible this could/should be handled by the DTS record.
Anyways there is a tentative addition to arch/arm/boot/dts/mediatek/mt6589.dtsi which should make a system finally load the right driver version (if there are multiple kernel modules installed in parallel).
great start. amazing! I've recalled some devices with SoCs from the MT6589 family, so list the kernel source code for pvr.
https://github.com/Dr-Shadow/android_kernel_mt6589/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/dragonpt/android_kernel_asus_me173x_new/tree/asus_n/mediatek/platform/mt6589/kernel/drivers/gpu/pvr (old tree https://github.com/dragonpt/android_kernel_asus_me173x/tree/asus/mediatek/platform/mt6589/kernel/drivers/gpu/pvr) https://github.com/z3ntu/android_kernel_fairphone_FP1/tree/mediatek-mt6589-3.4/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/lenovo-a3-dev/android_kernel_lenovo_mt8389/tree/cm-11.0/mediatek/platform/mt6589/kernel/drivers/gpu/pvr
You can also find many other source code when you search for mt6589, mt8125, mt8389 on GitHub. (Strangely, kernels for MT6588 cannot be found, but the kernel source code for MT6589 may be used just like the MT8125/MT8389.) -> MT6588 was renamed to MT6589!? https://www.gizmochina.com/2012/10/04/mediatek-rename-the-quad-core-processor-mt6588-to-mt6589/
https://github.com/varunchitre15/MT6589_kernel_source/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/kashifmin/KashKernel_MT6589/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/andreya108/bindu-kernel-mediatek/tree/master/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/jawad6233/Lenovo_A820_Kernel/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/AdryV/kernel_w200_kk_4.4.2_3.4.67_mt6589/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/Shr3ps/android_kernel_acer_V370_MT6589/tree/kk/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/dragonpt/Kernel_Xperia_C_Custom-/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/Shr3ps/kernel_acer_a1-810_MT8125/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr https://github.com/Red--Code/mt6589_kernel_3.4.67/tree/master/mediatek/platform/mt6589/kernel/drivers/gpu/pvr
MediaTek's PVR Drivers are in mediatek/platform/mt6589/kernel/drivers/gpu/pvr .
According to Wikipedia, in addition to the MT6589 family, there are also
- MT6513 / MT6573 (SGX531)
- MT6515 / MT6575(M) (SGX531[T])
- MT6517(T) / MT6577 / MT8317(T) / MT8377 (SGX531)
- MT8117 / MT8121 (SGX544)
- MT5327 (SGX543)
are equipped with PowerVR SGX. About the naming of MT65xx and MT81xx/MT83xx
I don't know anything about MediaTek SoCs other than the MT6589 family, but I know of a project working on the mainline for the MT6577 (They might have given up already...) It might be a good idea to contact them. https://github.com/arzam16/linux-mt6577
Thanks for this additional material! Well, it turns out that none of the other processors have mainline support So it is difficult to integrate them. Therefore, I have worked on the code to fix compile issues for the DDK 1.9.2204701-b8000 version. There are obvious changes, there are changes which can be fixed by looking into the 1.14.3699939 version, other are a little questionable (e.g. I have simply disabled ION which was available in mainline kernels for a while but has been removed).
But now I am stuck with drivers/gpu/drm/pvrsgx/1.9.2204701-b8000/services4/srvkm/bridged/sgx/bridged_sgx_bridge.c:73:10: fatal error: mach/mt_clkmgr.h: No such file or directory This is nowhere available mainline...
The current work has been pushed as branch work-pvrsrvkm-mt6589.
In total I think we should split the driver code into several branches. There are:
- the core DDK sources versions 1.5 up to 1.17
- environment specific sources (e.g. env/linux or system) which depend on Linux kernel API versions (a lot of #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
- SoC specific subdirectories
- SoC specific patches spread over the code...
Probably we need a branch for each of them so that the mix can rebuild any version we know about...
mt_clkmgr.h/.c is a clock framework and driver used in MediaTek's downstream kernel.
mediatek/platform/mt6589/kernel/core/include/mach/mt_clkmgr.hmediatek/platform/mt6589/kernel/core/mt_clkmgr.c
Copying these into the mainline and using them is so nonsense that it needs to be rewritten... It is known that MT6589 clock is mostly(?) common to MT2701/MT7623.
I started a port project a while ago, but it is esoteric and I cannot start writing the code. https://github.com/TeamYogaBlade2/linux/issues/2
note: The core revision of SGX544 on MT6589 is 115
https://github.com/openpvrsgx-devgroup/linux_openpvrsgx/blob/63f1ccc6355f0a25124131194645eeb9fba5ed15/drivers/gpu/drm/pvrsgx/1.9.2204701-b8000/include4/config_kernel_user.h#L6-L10
BQ Aquaris-5HD and Aquaris-5 has newer driver
Aquaris-5HD : 1.12-2701748 https://github.com/bq/aquaris-5HD/blob/1b08ad7554a863adb3eb2f8ec255c46f82571d94/mediatek/platform/mt6589/kernel/drivers/gpu/pvr/include4/pvrversion.h
Aquaris-5 : 1.12-2824438 https://github.com/bq/aquaris-5/blob/bc1d0d0e35c969670e2d869001be944ad0c9c5e5/mediatek/platform/mt6589/kernel/drivers/gpu/pvr/include4/pvrversion.h
Sorry to not answer recently. Too many other topics keep me busy...
Thanks for the SGX544-115 revision information.
Yes, I have seen that the Aquaris uses some 1.12 DDK but I had focused on he 1.9 version first, just to see how far it goes (well it is stuck).
In the meantime I have written a script for the idea mentioned in an earlier comment, that places all the individual vendor provided DDK versions into a sequence of git commits based on linus/master.
The first one tries to rebuild a DDK core history, i.e. all parts that are SGX specific. But otherwise it is generic so that there is not (much) dependency on the SoC or OS: https://github.com/openpvrsgx-devgroup/linux_openpvrsgx/tree/letux/pvrsrvkm-ddk-core
The second one contains all SoC integration (piling up older versions so that the last one should be the most universal): https://github.com/openpvrsgx-devgroup/linux_openpvrsgx/tree/letux/pvrsrvkm-generic
Of course this is just in an initial experimental stage. There is no Makefile to build a driver from it. And, it may not even be complete but contradictionary and duplicating some aspects.
In both cases the source files have been reformatted by clang-format so that there should be no unnecessary git diffs just by formatting changes. Also, some whitespace issues (e.g. space+tab or space before new-line) have been fixed.
Basically it should already be a good tool to better understand the DDK revisions and what has been modified. For example between 1.9 and 1.12 and what makes the difference between MT and other SoC.
If we want to model the whole process it may look like this:
- IMG developers have a DDK repository with fine grained history
- a shapshot (e.g. DDK 1.12.2701748) did go to licensees who had integrated SGX hardware into their SoC
- SoC vendor developers hacked the code until it works for the chip support package
- SoC driver code did go into devices (potentially hacked by device developers) and this was published
- we collected these publically available snapshots
- and try to reconstruct 1. and 3.+4. with a coarse history