2019-10-04 08:05 AM
I'am a newbbie on STM32MP1 and linux embedded.
I want to use available pins on STM32MP1-DK2 to as buttons input. I want to use CN14 connector pin (1 to 4) as buttons inputs.
I've modified the stm32mp157c-dk2.dts adding these lines:
buttonkeys {
compatible= "gpio-keys";
left-key {
label = "Left key";
gpios = <&gpioe 7 GPIO_ACTIVE_LOW>;
linux,code = <105>; // KEY_LEFT
};
right-key {
label = "Right key";
gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
linux,code = <106>; // KEY_RIGHT
};
down-key {
label = "Down key";
gpios = <&gpioe 8 GPIO_ACTIVE_LOW>;
linux,code = <108>; // KEY_DOWN
};
up-key {
label = "Up key";
gpios = <&gpioe 1 GPIO_ACTIVE_LOW>;
linux,code = <103>; // KEY_UP
};
};
If I declare only the left and down keys (GPIOE7 and GPIOE8) the button keys work fine (running evtest the gpio-keys device is shows and the detection of inputs status work fine ).
If I add other inputs, or use only one of other inputs (except GPIOE7 or GPIOE8) the evtest not shows any device (except the default touch screen and pmic-powerkey).
Are the device tree defined correctly for my purpose? Why enabling other inputs stop also working input?
2019-10-10 05:39 AM
Hello Giuseppe
Could you please try the same but with gpiod 14 instead of gpiod 4? Which corresponds to GPIOs available on CN14.
Best Regards
Olivier
2019-10-10 05:57 AM
Hi Olivier, thank you for your reply.
I've tried with gpioe 1 instead of gpiod 4 (that was wrong) but I have same result: with only GPIOE7 and E8 work fine, adding the GPIOE1 stops to work.
I've noted that PE7 and PE8 are mapped as USART 7; I suppose that should be interrupts assigned to this pins.... for GPIO PE1 I suppose that no interrupt is defined.
The gpio-keys should be works with interrupts, maybe this issue can be related to interrupt definition?
I haven't defined nothing in the Device tree expect for adding these lines in stm32mp157c-dk2.dts :
buttonkeys {
compatible= "gpio-keys";
left-key {
label = "Left key";
gpios = <&gpioe 7 GPIO_ACTIVE_LOW>;
linux,code = <105>; // KEY_LEFT
};
right-key {
label = "Right key";
gpios = <&gpioe 1 GPIO_ACTIVE_LOW>;
linux,code = <106>; // KEY_RIGHT
};
down-key {
label = "Down key";
gpios = <&gpioe 8 GPIO_ACTIVE_LOW>;
linux,code = <108>; // KEY_DOWN
};
up-key {
label = "Up key";
gpios = <&gpioe 1 GPIO_ACTIVE_LOW>;
linux,code = <103>; // KEY_UP
};
};
2019-11-06 08:18 AM
Hello Giuseppe Cannarella (Community Member)
Sorry for the delay. The issue seems to be linked to the gpiolib framework which assigns an interrupt that cannot be overriden in the dts file.
The method that most fit in your case is the example of the "joystick" using the pinctrl framework in the file stm32mp157c-ev1.dts (available in our MMDV Dev package for our STM32MP157 eval board ), The only difference would be that the interrupt parent is linked to a GPIO expander (stmfx_pinctl) on the ev1 board, To fit this example to your case, you should replace the interrupt-parent by the gpio ctrl bank directly.
Ex 1 ev1, pinctrl:
joystick {
compatible = "gpio-keys";
#size-cells = <0>;
pinctrl-0 = <&joystick_pins>;
pinctrl-names = "default";
button-0 {
label = "JoySel";
linux,code = <KEY_ENTER>;
interrupt-parent = <&stmfx_pinctrl>;
interrupts = <0 IRQ_TYPE_EDGE_RISING>;
};
};
Let me know if it helps.
Best Regards,
Olivier