Iam working on 7x7 matrix keypad for custom board it’s using verdin imx8mp som with custom base board there are 41 buttons and 14 pins for keypad connection connected to board so iam accessing this 14 pins through gpio pins below.
line 8: “SODIMM_198” input gpio_pin-136
line 7: “SODIMM_200” input gpio_pin-135
line 9: “SODIMM_202” output active-low consumer="spi1 CS0"gpio_pin–137
line 0: “SODIMM_206” input gpio_pin–0
line 1: “SODIMM_208” input gpio_pin–1
line 5: “SODIMM_210” input gpio_pin–5
line 7: “SODIMM_216” input gpio_pin–7
line 13: “SODIMM_219” input gpio_pin–109
line 3: “SODIMM_220” input gpio_pin–99
line 1: “SODIMM_222” input gpio_pin–97
line 19: “SODIMM_244” output consumer=“PCIe reset” gpio_pin–115
line 0: “SODIMM_252” input active-low consumer=“Wake-Up” gpio_pin–96
->what is the pin number of SODIMM_200 how we can calculate.
so iam calculating gpio pins if gpio group starts from 0 then (banknumberX32)+(line number)
for example: SODIMM_200 is on gpiochip4 line 7 so gpio number = 4*32 + 7 = 135
2.Iam trying to export gpiopins using below command but it’s showing line busy or invalid line
export 10 > /sys/class/gpio
3.Explain How to interface the 7x7 keypad matrix with verdin imx8mp som so we can access the keypad on the custom base board.
4.when we use gpioget or gpioset the following error we are facing
root@verdin-imx8mp-15460537:~# gpioset /dev/gpiochip0 0
gpioset: invalid line value: ‘/dev/gpiochip0’
root@verdin-imx8mp-15460537:~# gpioset /dev/gpiochip0 12
gpioset: invalid line value: ‘/dev/gpiochip0’
root@verdin-imx8mp-15460537:~# gpioset /dev/gpiochip0 33
gpioset: invalid line value: ‘/dev/gpiochip0’
root@verdin-imx8mp-15460537:~# gpioset /dev/gpiochip0 2
gpioset: invalid line value: ‘/dev/gpiochip0’
Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!
Did you like my answer?
Hello Charan,
Thank you for reaching out with your questions about interfacing a 7x7 keypad matrix with the Verdin iMX8MP. Let’s address each of your concerns step by step:
Calculating GPIO Pin Numbers:
You are correct in using the formula (bank number * 32) + line number to calculate the GPIO number. For example, if SODIMM_200 is on gpiochip4 line 7, the GPIO number is 4 * 32 + 7 = 135.
Exporting GPIO Pins:
The sysfs interface (/sys/class/gpio) is deprecated. Instead, use the libgpiod tools, which are more modern and reliable. The “line busy” error often occurs if the pin is already in use by another process or not correctly configured in the device tree.
Using gpioget and gpioset:
Ensure you are using the correct syntax. For example, to set a GPIO, use gpioset gpiochipX Y=1 where X is the chip number and Y is the line number.
The error “invalid line value” suggests incorrect usage or that the line is not available. Use gpiodetect and gpioinfo to verify available lines and their status.
Interfacing the Keypad Matrix:
Ensure that the GPIO pins are correctly configured in the device tree. This might involve setting the pins to GPIO mode if they are multiplexed with other functions.
Consider using a GPIO matrix keypad driver in the Linux kernel, which can handle the scanning of the keypad matrix. You may need to modify the device tree to specify the GPIO lines used for rows and columns.
Device Tree Modifications:
If the default pin configuration does not match your requirements, you will need to create a device tree overlay to set the pins to GPIO mode. This involves editing the device tree source to specify the correct pin functions and re-compiling it.
By following these steps, you should be able to configure the GPIOs for your keypad matrix and resolve the issues with exporting and setting GPIO lines. If you continue to face issues, ensure that no other processes are using the GPIOs and that the device tree is correctly configured for your hardware setup.
I hope this helps! If you have any more questions, feel free to ask.
Best regards,
Toradex AI Assistant.
Please, also check if these links can help you solve your problem:
The response from the Toradex AI provides a helpful direction. To resolve the issue, ensure correct usage of the gpioset command and verify that the GPIO pins are properly configured in your device tree. Below are some resources to assist with troubleshooting: