<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>i.MX Processors中的主题 Re: How to use device tree to get a rotary-encoder device</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012791#M149983</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answer. Some parts are still not clear to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Where does the code has to go inside the device tree file? At the moment my code is under the root element. Is that the right place or do i have to put it somewhere else? I already found the code you posted but modified it. I will revert it back to the suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I also found the second link you posted. In the part "Board integration" I found this text:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;Because the driver uses generic device properties, this can be done either via device tree, ACPI, or using static board files, like in example below:
[Code]&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So i concluded it is enough to have a device tree file without a driver.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Feb 2020 10:51:48 GMT</pubDate>
    <dc:creator>mopfi</dc:creator>
    <dc:date>2020-02-28T10:51:48Z</dc:date>
    <item>
      <title>How to use device tree to get a rotary-encoder device</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012789#M149981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;What I want to do:&lt;/STRONG&gt;&lt;BR /&gt;Create a rotary encoder device in Linux with Yocto Project and device tree (/dev/rotary-encoder). The device should be visible after boot, so that it can be used in user space.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My Hardware:&lt;/STRONG&gt;&lt;BR /&gt;i.MX8M Mini Evaluation Board (imx8mm evk)&lt;BR /&gt;Rotary encoder using two GPIOs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I tried:&lt;/STRONG&gt;&lt;BR /&gt;I changed the dts file and added code for the rotary encoder (tmp/work-shared/imx8mmevk/kernel-source/arch/arm64/boot/dts/freescale/fsl-imx8mm-evk.dts):&lt;/P&gt;&lt;PRE class="language-c line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;/&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;

    rotary&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;encoder &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
        compatible &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"rotary-encoder"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        status &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"okay"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        gpios &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;pca6416 &lt;SPAN class="number token"&gt;14&lt;/SPAN&gt; GPIO_ACTIVE_HIGH&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt;pca6416 &lt;SPAN class="number token"&gt;13&lt;/SPAN&gt; GPIO_ACTIVE_HIGH&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        linux&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;axis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;/* REL_X */&lt;/SPAN&gt;
        rotary&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;encoder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;encoding &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"gray"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        rotary&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;encoder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;relative&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;axis&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the right way and do I maybe need some device driver in addition to the device tree file? I thought Linux would have one for rotary encoders. The problem is that my knowledge about device trees is limited. I tried to find a solution via google, but couldn't. Maybe someone can help how to integrate this with the evaluation board.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 13:20:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012789#M149981</guid>
      <dc:creator>mopfi</dc:creator>
      <dc:date>2020-02-25T13:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use device tree to get a rotary-encoder device</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012790#M149982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on the Linux Documentation the implementation of the Device Tree for a Rotary.Encoder should be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE data-tab-size="8"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;rotary@0 {&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE data-tab-size="8"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;compatible = "rotary-encoder";&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE data-tab-size="8"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;gpios = &amp;lt;&amp;amp;gpio 19 1&amp;gt;, &amp;lt;&amp;amp;gpio 20 0&amp;gt;; /* GPIO19 is inverted */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE data-tab-size="8"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;linux,axis = &amp;lt;0&amp;gt;; /* REL_X */&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE data-tab-size="8"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;rotary-encoder,encoding = "gray";&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE data-tab-size="8"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD class=""&gt;rotary-encoder,relative-axis;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can find the complete documentation in the following link:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/input/rotary-encoder.txt" title="https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/input/rotary-encoder.txt"&gt;linux/rotary-encoder.txt at master · torvalds/linux · GitHub&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And you need consider how to implemented the driver and you can find the information in the following link:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://www.kernel.org/doc/Documentation/input/devices/rotary-encoder.rst" title="https://www.kernel.org/doc/Documentation/input/devices/rotary-encoder.rst"&gt;https://www.kernel.org/doc/Documentation/input/devices/rotary-encoder.rst&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2020 17:51:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012790#M149982</guid>
      <dc:creator>jamesbone</dc:creator>
      <dc:date>2020-02-26T17:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use device tree to get a rotary-encoder device</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012791#M149983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answer. Some parts are still not clear to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Where does the code has to go inside the device tree file? At the moment my code is under the root element. Is that the right place or do i have to put it somewhere else? I already found the code you posted but modified it. I will revert it back to the suggested.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I also found the second link you posted. In the part "Board integration" I found this text:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;PRE&gt;Because the driver uses generic device properties, this can be done either via device tree, ACPI, or using static board files, like in example below:
[Code]&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So i concluded it is enough to have a device tree file without a driver.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Feb 2020 10:51:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012791#M149983</guid>
      <dc:creator>mopfi</dc:creator>
      <dc:date>2020-02-28T10:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use device tree to get a rotary-encoder device</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012792#M149984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I still had no success. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I use the code from here I get an error loading the module in Linux.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.kernel.org/doc/Documentation/input/devices/rotary-encoder.rst"&gt;https://www.kernel.org/doc/Documentation/input/devices/rotary-encoder.rst &lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function gpiod_add_lookup_table is not found. I guess it's maybe a problem with the kernel version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there really nobody who ever tried using a rotary encoder on the eval board?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Mar 2020 10:00:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/How-to-use-device-tree-to-get-a-rotary-encoder-device/m-p/1012792#M149984</guid>
      <dc:creator>mopfi</dc:creator>
      <dc:date>2020-03-03T10:00:34Z</dc:date>
    </item>
  </channel>
</rss>

