Hello,
The source code of the kernel can be get from the BSP build. We use Yocto to build the BSP.
You can get the documentation from here.
https://www.nxp.com/design/software/embedded-software/i-mx-software/embedded-linux-for-i-mx-applicat...
Then follow the i.MX_Yocto_Project_User's_Guide.pdf to build the BSP. After built successfully, the source code can be found in the <yocto_folder>/<build_folder>/tmp/work/<board_folder>/linux-imx
And here is the web page version for the kernel source code
https://source.codeaurora.org/external/imx/linux-imx/tree/?h=imx_4.14.98_2.0.0_ga