Mali kernel driver does not build in M3 BSP

Hi everyone,

I’ve been trying to build the mali kernel driver in the BSP, using the Makefile @ BPI-M3-bsp/linux-sunxi/modules/mali using:

LICHEE_PLATFORM=linux LICHEE_KDIR=${BSP_M3_LOCATION}/linux-sunxi V=2 make

With the PATH environment variable expanded with ${BSP_M3_LOCATION}/allwinner-tools/toolchain/bin

This result I get is this:

BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.c: In function 'get_gpu_clk':
BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.c:105:27: error: 'GPU_CLK' undeclared (first use in this function)
BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.c:105:27: note: each undeclared identifier is reported only once for each function it appears in
BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.c: In function 'sun8i_mali_platform_device_register':
BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.c:446:59: error: 'mali_gpu_resources' undeclared (first use in this function)
make[3]: *** [BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [_module_BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali] Error 2
make[2]: Leaving directory `BPI-M3-bsp/linux-sunxi'
make[1]: *** [all] Error 2
make[1]: Leaving directory `BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali'
make: *** [build] Error 2

The first error can probably be fixed by adding

#define GPU_CLK "gpu"

to the file BPI-M3-bsp/linux-sunxi/include/linux/clk/clk-sun8iw6.h

But the second one is a bit more tricky.

On lines 60-72 of BPI-M3-bsp/linux-sunxi/modules/mali/DX910-SW-99002-r5p0-01rel0/driver/src/devicedrv/mali/linux/mali_platform.c, mali_gpu_resources is defined thus:

#if defined(CONFIG_ARCH_SUN8IW3P1) || defined(CONFIG_ARCH_SUN8IW5P1) || defined(CONFIG_ARCH_SUN8IW9P1)
static struct resource mali_gpu_resources[]=
{
    MALI_GPU_RESOURCES_MALI400_MP2_PMU(SUNXI_GPU_PBASE, SUNXI_IRQ_GPUGP, SUNXI_IRQ_GPUGPMMU, \
                                        SUNXI_IRQ_GPUPP0, SUNXI_IRQ_GPUPPMMU0, SUNXI_IRQ_GPUPP1, SUNXI_IRQ_GPUPPMMU1)
};
#elif defined(CONFIG_ARCH_SUN8IW7P1)
static struct resource mali_gpu_resources[]=
{
    MALI_GPU_RESOURCES_MALI400_MP2_PMU(SUNXI_GPU_PBASE, SUNXI_IRQ_GPU_GP, SUNXI_IRQ_GPU_GPMMU, \
                                        SUNXI_IRQ_GPU_PP0, SUNXI_IRQ_GPU_PPMMU0, SUNXI_IRQ_GPU_PP1, SUNXI_IRQ_GPU_PPMMU1)
};
#endif

None of CONFIG_ARCH_SUN8IW3P1, CONFIG_ARCH_SUN8IW5P1, CONFIG_ARCH_SUN8IW9P1 or CONFIG_ARCH_SUN8IW7P1 is defined.

What is defined, however, is CONFIG_ARCH_SUN8IW6.

It could be that in this case mali_gpu_resources is defined as one of the above options or should be defined as something else entirely. I don’t have the proper documentation to be able to tell. I’m hoping someone here does.

Edit: It looks like is has its very own definition, since only SUNXI_IRQ_GPU is defined (in BPI-M3-bsp/linux-sunxi/arch/arm/mach-sunxi/include/mach/sun8i/irqs-sun8iw6p1.h)

Never mind. The M3 has an SGX544MP1 GPU,not a MALI GPU.
Still, I want to use it in dual-screen mode (7" LCD + HDMI as independent screens).
Anyone know how to do that?
Android for the M3 sort of does that, but only clones the LCD to the HDMI output.

My guess is a kernel patch that is needed, don’t know where…