// Definitions for Freeplay Zero/CM3 gpio-keys
/dts-v1/;
/plugin/;

/ {
	compatible = "brcm,bcm2708";

	fragment@0 {
		// Configure the gpio pin controller
		target = <&gpio>;
		__overlay__ {
			pin_state: button_pins@0 {
				brcm,pins =     <6 5 4 17 16 24 19 26 15 18 14 23>; // gpio number
				brcm,function = <0 0 0  0  0  0  0  0  0  0  0  0>; // 0 = input, 1 = output
				brcm,pull =     <2 2 2  2  2  2  2  2  2  2  2  2>; // 0 = none, 1 = pull down, 2 = pull up
			};
		};
	};
	fragment@1 {
		target-path = "/";
		__overlay__ {
			button: button@0 {
				compatible = "gpio-keys";
				pinctrl-names = "default";
				pinctrl-0 = <&pin_state>;
				status = "okay";

				key@0 { //dpad-l
					linux,code = <105>;  //KEY_LEFT
					gpios = <&gpio 6 1>;
				};
				key@1 { //dpad-r
					linux,code = <106>;  //KEY_RIGHT
					gpios = <&gpio 5 1>;
				};
				key@2 { //dpad-u
					linux,code = <103>;  //KEY_UP
					gpios = <&gpio 4 1>;
				};				
				key@3 { //dpad-d
					linux,code = <108>;  //KEY_DOWN
					gpios = <&gpio 17 1>;
				};	
				
				key@4 { //btn-a
					linux,code = <30>;	//KEY_A
					gpios = <&gpio 16 1>;
				};				
				key@5 { //btn-b
					linux,code = <31>;	//KEY_S
					gpios = <&gpio 24 1>;
				};		
				
				key@6 {
					linux,code = <28>;	//KEY_ENTER
					gpios = <&gpio 19 1>;
				};
				key@7 {
					linux,code = <57>;	//KEY_SPACE
					gpios = <&gpio 26 1>;
				};							
				
				key@8 { //btn-x
					linux,code = <45>;	//KEY_X
					gpios = <&gpio 15 1>;
				};	
				key@9 { //btn-y
					linux,code = <21>;	//KEY_Y
					gpios = <&gpio 18 1>;
				};	
					
				
				
				key@20 { //shoulder-l
					linux,code = <38>;
					gpios = <&gpio 14 1>;
					label = "KEY_L";
				};
				key@21 { //shoulder-r
					linux,code = <19>; 
					gpios = <&gpio 23 1>;
					label = "KEY_R";
				};
							
			};
		};
	};

/*
	__overrides__ {
		gpio =       <&key>,"gpios:4",
		             <&button>,"reg:0",
		             <&pin_state>,"brcm,pins:0",
		             <&pin_state>,"reg:0";
		label =      <&key>,"label";
		keycode =    <&key>,"linux,code:0";
		gpio_pull =  <&pin_state>,"brcm,pull:0";
		active_low = <&key>,"gpios:8";
	};
*/
};