This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM335x - GPIO Matrix Keypad Standby Wakeup

I'm working on a custom AM3352-based board which has a GPIO matrix keypad. I'd like to be able to place the processor into the Standby mode, and wake it whenever a key is pressed. Since each key is a GPIO and the AM335x supposedly supports waking from Standby mode on any GPIO port, I think this should be possible. All of this has been tried using the 3.14.17 kernel.

Unfortunately, I'm not sure how to actually do this. While looking up info on the AM335x Standby mode, I stumbled across a few posts with similar questions. In general, the consensus was to create a gpio_keys entry in the kernel's device tree, and set the gpio-key,wakeup property. Since my GPIO pins are configured as a keypad and not plain-old-GPIO, I don't think I can do this.


In the kernel documentation for gpio-matrix-keypad bindings, there is an optional property, linux,wakeup, which appears to try and provide the same behaviour. However, when I add this property to my device tree, I cannot wake up my processor from the Standby mode when I press any key on the keypad. Here's the entire device tree blurb regarding the keypad:

matrix_keypad: matrix_keypad@0 {
	compatible = "gpio-matrix-keypad";
	linux,wakeup;
	debounce-delay-ms = <5>;
	col-scan-delay-us = <2>;

	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&matrix_keypad_default>;
	pinctrl-1 = <&matrix_keypad_sleep>;

	keypad,num-rows = <4>;
	keypad,num-columns = <7>;


	row-gpios = 	<&gpio2 0 GPIO_ACTIVE_HIGH		
			 &gpio2 1 GPIO_ACTIVE_HIGH		
			 &gpio2 2 GPIO_ACTIVE_HIGH	
			 &gpio2 3 GPIO_ACTIVE_HIGH		
			 >;
		

	col-gpios = 	<&gpio3 14 GPIO_ACTIVE_HIGH		
			 &gpio3 15 GPIO_ACTIVE_HIGH
			 &gpio3 16 GPIO_ACTIVE_HIGH
			 &gpio3 17 GPIO_ACTIVE_HIGH
			 &gpio3 18 GPIO_ACTIVE_HIGH
			 &gpio3 19 GPIO_ACTIVE_HIGH
			 &gpio3 20 GPIO_ACTIVE_HIGH
			 >;	
	/*
	- linux,keymap: an array of packed 1-cell entries containing the equivalent
	of row, column and linux key-code. The 32-bit big endian cell is packed
	as:
		row << 24 | column << 16 | key-code

	using macro:
		MATRIX_KEY(row,column,key-code)
	*/
	linux,keymap = <
			/* Row 0*/
			MATRIX_KEY(0, 0, KEY_DOT)	
			MATRIX_KEY(0, 1, KEY_0)		
			MATRIX_KEY(0, 2, KEY_DELETE)				
			MATRIX_KEY(0, 3, KEY_RESERVED)		
			MATRIX_KEY(0, 4, KEY_RESERVED)	 				
			MATRIX_KEY(0, 5, KEY_RESERVED)	 		
			MATRIX_KEY(0, 6, KEY_RESERVED)			
			/* Row 1*/
			MATRIX_KEY(1, 0, KEY_9)
			MATRIX_KEY(1, 1, KEY_8)
			MATRIX_KEY(1, 2, KEY_7)
			MATRIX_KEY(1, 3, KEY_EQUAL)	
			MATRIX_KEY(1, 4, KEY_DOWN)	
			MATRIX_KEY(1, 5, KEY_HELP)	
			MATRIX_KEY(1, 6, KEY_MINUS)	
			/* Row 2*/
			MATRIX_KEY(2, 0, KEY_6)
			MATRIX_KEY(2, 1, KEY_5)
			MATRIX_KEY(2, 2, KEY_4)
			MATRIX_KEY(2, 3, KEY_RIGHT)
			MATRIX_KEY(2, 4, KEY_ENTER)
			MATRIX_KEY(2, 5, KEY_LEFT)
			MATRIX_KEY(2, 6, KEY_F1)		
			/* Row 3*/
			MATRIX_KEY(3, 0, KEY_3)
			MATRIX_KEY(3, 1, KEY_2)
			MATRIX_KEY(3, 2, KEY_1)
			MATRIX_KEY(3, 3, KEY_F2)
			MATRIX_KEY(3, 4, KEY_UP)
			MATRIX_KEY(3, 5, KEY_ESC)	
			MATRIX_KEY(3, 6, KEY_F3)
			>;

};

Honestly, I'm pretty stumped at this point. I'm not very familiar with device trees, so I'm not sure if this is correct or not. I'm really just looking for any advice on what I might be able to do from here. Any help would be greatly appreciated. 

 

  • Hi,
    Have you added this "gpio-key,wakeup" in your dts file and able to wakeup ?

    Apply the patch and use "wakeup-source" and see if it helps.

    www.spinics.net/.../msg39870.html
  • I'm currently recompiling the kernel with that patch, and I'll let you know if that works for me. From the looks of source, all it does is change the name of the device tree property that triggers the wakeup behaviour. It doesn't look like it will actually change any behaviour, but I'll give it a shot.

    I haven't tried adding the "gpio-key, wakeup" property, because I'm not sure where it would go. I have a very basic understanding of device trees, so this is a little confusing to me. Can I configure the same GPIO pin as both a matrix keypad key, and as a generic "GPIO key" in the same device tree? The matrix keypad driver doesn't parse the tree for "gpio-key, wakeup" so I'd need to add a separate entry for the same GPIO with a different driver, correct? They have separate drivers in the kernel source, so this seems a little counter-intuitive (two drivers fighting to handle the same interrupts?) but I really don't know enough about this to be sure.

    [edit] Patch hasn't made a difference