# FreeBSD 12.0 - module init function is called few times - Raspberry Pi 3.



## mattsk (Jul 8, 2019)

Hi,
I write a driver of LCD, witch use SPI and GPIO and works on kernelspace. Source code is available on my github:








						freebsd_rpi3_lcd_ili9486_driver/lcd.c at master · mattpro/freebsd_rpi3_lcd_ili9486_driver
					

FreeBSD Driver for ILI9486. Contribute to mattpro/freebsd_rpi3_lcd_ili9486_driver development by creating an account on GitHub.




					github.com
				



I'll try to test spi but I find strength things. When I load module into kernel:

`kldload ./lcd.ko`

I see that init module calls four times:

`lcdRpiX0: <Lcd MattPro> at cs 1 mode 0 onspibus0
Module Init
lcdRpiX1: <Lcd MattPro> at cs 0 mode 0 onspibus0
Module Init
lcdRpiX2: <Lcd MattPro> at cs 0 mode 0 onspibus0
Module Init
lcdRpiX3: <Lcd MattPro> at cs 1 mode 0 onspibus0
Module Init`
Before spi development, I applied SPI patch for Raspberry Pi 3, witch is described here:








						SPI driver for Raspberry Pi 3 in FreeBSD v-12
					

Does anyone know of Documentation or Sample Programs for this interface?  As of aarch64 snapshot of V-12.0-CURRENT r321072 of July 18, several kernel modules showed up in /boot/kernel. kldload spigen.ko creates /dev/spigen0. There's also gpiospi.ko which I have not experimented with. I've hunted...




					forums.freebsd.org
				




When I comment spigen1 and cs pins:


```
/* $FreeBSD:$ */
 
 /dts-v1/;
 /plugin/;
 
 / {
         compatible = "brcm,bcm2837";
 };
         
 &{/soc/spi@7e204000} {
         status = "okay";
         spigen0: spigen0 {
                 compatible = "freebsd,spigen";
                 reg = <0>;
                 spi-max-frequency = <500000>; /* Req'd property, override with spi(8) */
                 status = "okay";
         };
         //spigen1: spigen1 {
         //        compatible = "freebsd,spigen";
         //        reg = <1>;
         //        spi-max-frequency = <500000>; /* Req'd property, override with spi(8) */
         //        status = "okay";
         //};
 };
 
 &{/soc/gpio@7e200000/spi0_cs_pins} {
        // brcm,pins = <8 7>;
         brcm,pins = <7>;
         brcm,function = <4>; /* ALT0 */
 };
```
Module init call only three times.
What can be the reason for this?


----------

