Open main menu

DAVE Developer's Wiki β

Changes

DESK-MX6-L/Peripherals/GPIOs

305 bytes removed, 13:43, 12 October 2020
no edit summary
!style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#73B2C7; padding:5px; color:white"|Notes
|-
|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|X1.Y0.Z0|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Month YearOct 2020|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|TBDFirst DESK release|-|-|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|[TBD_link X.Y.Z]|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|Month Year|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|TBD|-|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|...|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|...|style="border-left:solid 2px #73B2C7; border-right:solid 2px #73B2C7;border-top:solid 2px #73B2C7; border-bottom:solid 2px #73B2C7; background-color:#edf8fb; padding:5px; color:#000000"|...|-
|}
<section end=History/>
==Peripheral GPIOs ==
''TBD: sostituire tutti i dump con le informazioni sull'uso della periferica''.MX6 can handle external pins in many different ways and most of them can be configured as GPIOs. When a pin is set as a GPIO, it is possible to read its value, change its direction or change output value directly from the shell.
=== Device tree configuration ===
Here below an example of device tree configuration for using the RS-485 GPIOs used on standard DAVE's kit for the AXEL Lite SOM:
From <code>''carrierimx6q-sbcx-cb0012.dts''</code>:
<pre>
&can1 leds { compatible = "gpio-leds"; pinctrl-names = "default"; pinctrl-0 = <&pinctrl_flexcan1_axelpinctrl_rs232_485_422_1>; status rs232_485_422 { gpios = <&gpio7 13 GPIO_ACTIVE_HIGH>; linux,default-trigger = "default-on"; };  rs232_on { gpios = <&gpio5 29 GPIO_ACTIVE_LOW>; linux,default-trigger = "okaydefault-on"; }; };
};
</pre>
From <code>''carriermx6qdl-sbcx-revb-common.dtsi''</code>:
<pre>
can1 rs232_485_422 { pinctrl_flexcan1_axelpinctrl_rs232_485_422_1: flexcan1axelgrppinctrl_rs232_485_422_grp-1 {
fsl,pins = <
MX6QDL_PAD_GPIO_7__FLEXCAN1_TX 0x80000000MX6QDL_PAD_GPIO_18__GPIO7_IO13 0x1b0b1 /* UART5_485/232 */ MX6QDL_PAD_GPIO_8__FLEXCAN1_RX 0x80000000MX6QDL_PAD_CSI0_DAT11__GPIO5_IO29 0x1b0b1 /* UART5_ON */
>;
};
===Accessing the peripheral===
====Linux messages at boot time====
 
With the previous <code>leds</code> configuration for the GPIOs, it is possible to find them on <code>sysfs</code> under ''/sys/class/leds'' sub-directory:
<pre class="workstation-terminal">
root@imx6qdlxelk:~# ls -la /sys/class/leds/total 0drwxr-xr-x 2 root root 0 Apr 2 2020 .drwxr-xr-x 54 root root 0 Apr 2 2020 ..lrwxrwxrwx 1 root root 0 Apr 2 2020 mmc0:: -> ../.[ 1.807495] flexcan 2090000/devices/soc0/soc/2100000.aips-bus/2190000.flexcanusdhc/leds/mmc0:: 2090000.flexcan supply xceiver not found, using dummy regulator[ lrwxrwxrwx 1root root 0 Apr 2 2020 mmc1:: -> ..817366] flexcan 2090000/.flexcan: device registered (reg_base=c0a30000, irq=31)./devices/soc0/soc/2100000.aips-bus/2194000.usdhc/leds/mmc1::lrwxrwxrwx 1 root root 0 Apr 2 2020 rs232_485_422 -> ../../devices/soc0/leds/leds/rs232_485_422[ 3lrwxrwxrwx 1 root root 0 Apr 2 2020 rs232_on -> .952659] can: controller area network core (rev 20170425 abi 9)[ 3.963413] can: raw protocol (rev 20170425)[ 3/..967717] can: broadcast manager protocol (rev 20170425 t)/devices/soc0/leds/leds/rs232_on[ 3.973397] canroot@imx6qdlxelk: netlink gateway (rev 20170425) max_hops=1~#
</pre>
====Enable the interface and check statusUsage with [https://www.kernel.org/doc/Documentation/gpio/sysfs.txt sysfs] ==== * set EIM_D26 (MX6QDL_PAD_EIM_D26__GPIO3_IO26) as output GPIO** GPIO3_IO26 => (n-1)*32 + IO = (3-1)*32+26 = 90 
<pre class="workstation-terminal">
root@imx6qxelkimx6qdlxelk:~# ip link set can0 type can bitrate 500000echo 90 > /sys/class/gpio/exportroot@imx6qxelkimx6qdlxelk:~# ifconfig can0 upecho out > /sys/class/gpio/gpio90/directionroot@imx6qxelkimx6qdlxelk:~# ifconfig can0can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP RUNNING NOARP MTU:16 Metric:echo 1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:31> /sys/class/gpio/gpio90/valueroot@imx6qxelkimx6qdlxelk:~#
</pre>
==== Usage with [https://github.com/linux-can/can-utils can-utils] ==== ''TBD: reference verso eventuali informazioni sul web''* set EIM_D27 (MX6QDL_PAD_EIM_D27__GPIO3_IO27) as input GPIO
<pre class="workstation-terminal">
root@imx6qxelkimx6qdlxelk:~# ip link set can0 type can bitrate 500000 triple-sampling onecho 91 > /sys/class/gpio/exportroot@imx6qxelkimx6qdlxelk:~# ifconfig can0 upecho in > /sys/class/gpio/gpio91/directionroot@imx6qxelkimx6qdlxelk:~# cansend can0 128#1122334455667788root@imx6qxelk:~# candump can0cat /sys/class/gpio/gpio91/value can0 128 [8] 11 22 33 44 55 66 77 881root@imx6qxelkimx6qdlxelk:~#
</pre>
=== Additional information ===
Each CAN port appears like a networking Information about GPIOs usage under sysfs directory ''https://www.kernel.org/doc/Documentation/gpio/sysfs.txt'' {{WarningMessage|text=''sysfs'' GPIO ABI has been deprecated. See more inofrmation [https://www.kernel.org/doc/Documentation/gpio/sysfs.rst here] about it. A character device access has to be used, more information [https://embeddedbits.org/new-linux-kernel-gpio-user-space-interface in the form <code>canX</code> where <b><i>X<here]}} Information about GPIOs library '''libgpiod''' - C library and tools - can be found on [https:/i></b> is the port numbergit.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/ git.kernel. org]
Information about programming the CAN socket interface is given in the kernel tree under ''Documentation/networking/can.txt''
<section end=Body/>
8,226
edits