Jump to content

Porting driver from Raspberry Pi zero to Banana Pi M2 Zero


Benoît Clouet

Recommended Posts

Hi all,

 

I'm trying to port a driver built for Raspberry Zero to Banana Pi M2 Zero. The original driver is here : https://github.com/pguyot/tagtagtag-ears (it's supposed to drive the ears of a Nabaztag, which recently got resurected thanks to an Ulule campaign).

 

My understanding is that at least half of the problem is to adapt the device tree overlay for the BPI M2 Zero. If it"s not half of the work, it's definitely required. So far I've been unsuccessful.

 

The original DTS overlay is like this :

/dts-v1/;
/plugin/;

/ {
    compatible = "brcm,bcm2708";

	fragment@0 {
		target = <&gpio>;
		__overlay__ {
			gpio_encoder_left_pin: gpio_encoder_left_pin@24 {
				brcm,pins = <24>;
				brcm,function = <0>;	// in
			};
			gpio_encoder_right_pin: gpio_encoder_right_pin@23 {
				brcm,pins = <23>;
				brcm,function = <0>;	// in
			};
                        // left: when looking at the rabbit (matching hardware spec)
                        // forward: for the rabbit's left ear (right), counter-clock-wise
                        // for the rabbit's right ear (left below), clock-wise
			gpio_motor_left_forward_pin: gpio_motor_left_forward_pin@12 {
				brcm,pins = <12>;
				brcm,function = <1>;	// out
			};
			gpio_motor_left_backward_pin: gpio_motor_left_backward_pin@11 {
				brcm,pins = <11>;
				brcm,function = <1>;	// out
			};
			gpio_motor_right_forward_pin: gpio_motor_right_forward_pin@10 {
				brcm,pins = <10>;
				brcm,function = <1>;	// out
			};
			gpio_motor_right_backward_pin: gpio_motor_right_backward_pin@9 {
				brcm,pins = <9>;
				brcm,function = <1>;	// out
			};
		};
	};
    fragment@1 {
        target-path="/";
        __overlay__ {
            tagtagtag_ears: tagtagtag-ears {
                compatible = "linux,tagtagtag-ears";
                left-encoder-gpio = <&gpio 24 0>;
                left-motor-gpios = <&gpio 12 0 &gpio 11 0>;
                right-encoder-gpio = <&gpio 23 0>;
                right-motor-gpios = <&gpio 10 0 &gpio 9 0>;

                // Declare a single pinctrl state (referencing the one declared above) and name it
                // default, so it is activated automatically.
                pinctrl-names = "default";
                pinctrl-0 = <&gpio_encoder_left_pin &gpio_motor_left_forward_pin &gpio_motor_left_backward_pin &gpio_encoder_right_pin &gpio_motor_right_forward_pin &gpio_motor_right_backward_pin>;
            };
        };
    };
};

 

I tried to adapt it following what I understand from the schematics of the device and the documentation of the BPI M2 Zero board. It resulted in the version below :

/dts-v1/;
/plugin/;

/ {
    compatible = "sinovoip,bpi-m2-zero\0allwinner,sun8i-h2-plus";

	fragment@0 {
		target = <&pio>;
		__overlay__ {
			gpio_encoder_left_pin: gpio_encoder_left_pin@24 {
				//pins = <24>;
				pins = "PC4";
				function = <0>;	// in
			};
			gpio_encoder_right_pin: gpio_encoder_right_pin@23 {
				//pins = <23>;
				pins = "PA15";
				function = <0>;	// in
			};
                        // left: when looking at the rabbit (matching hardware spec)
                        // forward: for the rabbit's left ear (right), counter-clock-wise
                        // for the rabbit's right ear (left below), clock-wise
			gpio_motor_left_forward_pin: gpio_motor_left_forward_pin@12 {
				//pins = <12>;
				pins = "PA2";
				function = <1>;	// out
			};
			gpio_motor_left_backward_pin: gpio_motor_left_backward_pin@11 {
				//pins = <11>;
				pins = "PC2";
				function = <1>;	// out
			};
			gpio_motor_right_forward_pin: gpio_motor_right_forward_pin@10 {
				//pins = <10>;
				pins = "PC0";
				function = <1>;	// out
			};
			gpio_motor_right_backward_pin: gpio_motor_right_backward_pin@9 {
				//pins = <9>;
				pins = "PC1";
				function = <1>;	// out
			};
		};
	};
    fragment@1 {
        target-path="/";
        __overlay__ {
            tagtagtag_ears: tagtagtag-ears {
                compatible = "linux,tagtagtag-ears";
                //left-encoder-gpio = <&gpio 24 0>;
				left-encoder-gpio = <&gpio 24 0>;
                left-motor-gpios = <&gpio 12 0 &gpio 11 0>;
                right-encoder-gpio = <&gpio 23 0>;
                right-motor-gpios = <&gpio 10 0 &gpio 9 0>;

                // Declare a single pinctrl state (referencing the one declared above) and name it
                // default, so it is activated automatically.
                pinctrl-names = "default";
                pinctrl-0 = <&gpio_encoder_left_pin &gpio_motor_left_forward_pin &gpio_motor_left_backward_pin &gpio_encoder_right_pin &gpio_motor_right_forward_pin &gpio_motor_right_backward_pin>;
            };
        };
    };
};

 

I just changed the compatible clause and the pins definition trying to follow the indications in the documentation here https://docs.armbian.com/User-Guide_Allwinner_overlays/#using-custom-overlays without much success.

 

Would someone have an idea or more useful, an example of such portage ? I already looked at the Device Tree for dummies but I think I need some more directions to look at.

 

Thanks in advance for your help,

 

Benoît

 

 

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines