<?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>topic Re: imx8mp kernel  L5.4.70 driver/tty/serial/imx.c can not control gpio in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1538231#M196403</link>
    <description>&lt;P&gt;FYI.&lt;/P&gt;&lt;P&gt;There is an example of getting the gpio for "wlf,mute" from DT in the wm8524 driver.&lt;/P&gt;&lt;P&gt;&lt;A href="https://source.codeaurora.org/external/imx/linux-imx/tree/sound/soc/codecs/wm8524.c?h=imx_5.4.70_2.3.0" target="_blank"&gt;https://source.codeaurora.org/external/imx/linux-imx/tree/sound/soc/codecs/wm8524.c?h=imx_5.4.70_2.3.0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the DT.&lt;/P&gt;&lt;P&gt;&lt;A href="https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.dts?h=imx_5.4.70_2.3.0" target="_blank"&gt;https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.dts?h=imx_5.4.70_2.3.0&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 04:07:15 GMT</pubDate>
    <dc:creator>jimmychan</dc:creator>
    <dc:date>2022-10-17T04:07:15Z</dc:date>
    <item>
      <title>imx8mp kernel  L5.4.70 driver/tty/serial/imx.c can not control gpio</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1535955#M196247</link>
      <description>&lt;P&gt;问题：&lt;BR /&gt;设备树uart3中增加 txen-gpios = &amp;lt;&amp;amp;gpio4 23 GPIO_ACTIVE_HIGH&amp;gt;;以实现485流控该方法，之前在imx6平台，linux4.9.11上实现并获得验证。&lt;BR /&gt;&amp;amp;uart3 {&lt;BR /&gt;pinctrl-names = "default";&lt;BR /&gt;pinctrl-0 = &amp;lt;&amp;amp;pinctrl_uart3&amp;gt;;&lt;BR /&gt;assigned-clocks = &amp;lt;&amp;amp;clk IMX8MP_CLK_UART3&amp;gt;;&lt;BR /&gt;assigned-clock-parents = &amp;lt;&amp;amp;clk IMX8MP_SYS_PLL1_80M&amp;gt;;&lt;BR /&gt;txen-gpios = &amp;lt;&amp;amp;gpio4 23 GPIO_ACTIVE_HIGH&amp;gt;;&lt;BR /&gt;linux,rs485-enabled-at-boot-time;&lt;BR /&gt;status = "okay";&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;drivers/tty/serial/imx.c imx_uart_probe_dt函数增加如下&lt;BR /&gt;已添加头文件&lt;BR /&gt;#include &amp;lt;linux/gpio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/of_gpio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/gpio/consumer.h&amp;gt;&lt;/P&gt;&lt;P&gt;if (of_get_property(np, "txen-gpios", NULL))&lt;BR /&gt;sport-&amp;gt;have_txengpio = 1;&lt;BR /&gt;else&lt;BR /&gt;sport-&amp;gt;txen_gpio = -1;&lt;/P&gt;&lt;P&gt;if (sport-&amp;gt;have_txengpio){&lt;BR /&gt;sport-&amp;gt;txen_gpio = devm_gpiod_get(&amp;amp;pdev-&amp;gt;dev, "txen",gflags);&lt;BR /&gt;printk("###sport-&amp;gt;txen_gpio=%d",sport-&amp;gt;txen_gpio);&lt;BR /&gt;if (IS_ERR(sport-&amp;gt;txen_gpio)){&lt;BR /&gt;sport-&amp;gt;txen_gpio = -1;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;驱动运行后打印&lt;BR /&gt;###sport-&amp;gt;txen_gpio=-517&lt;BR /&gt;源码跟踪&lt;BR /&gt;drivers/gpio/gpiolib-of.c&lt;BR /&gt;static struct gpio_desc *of_get_named_gpiod_flags&lt;BR /&gt;chip = of_find_gpiochip_by_xlate(&amp;amp;gpiospec);&lt;BR /&gt;if (!chip) {&lt;BR /&gt;printk("####err=%d",-EPROBE_DEFER);&lt;BR /&gt;desc = ERR_PTR(-EPROBE_DEFER);&lt;BR /&gt;goto out;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;返回错误-EPROBE_DEFER为-517&lt;BR /&gt;gpio4_23在用户层可操作，表明该GPIO未被其他驱动占用。&lt;BR /&gt;echo 119 &amp;gt;/sys/class/gpio/export&lt;BR /&gt;echo out &amp;gt;/sys/class/gpio/gpio119/direction&lt;BR /&gt;echo 1 &amp;gt;/sys/class/gpio/gpio119/value&lt;/P&gt;&lt;P&gt;验证1：&lt;BR /&gt;设备树中添加&lt;BR /&gt;test:test {&lt;BR /&gt;compatible = "Jason_hello";&lt;BR /&gt;txen-gpios111;&lt;BR /&gt;hello = &amp;lt;&amp;amp;gpio4 23 GPIO_ACTIVE_HIGH&amp;gt;;&lt;BR /&gt;};&lt;BR /&gt;添加模块驱动gpio.c&lt;BR /&gt;#include &amp;lt;linux/init.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/kernel.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/module.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/gpio.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/of.h&amp;gt;&lt;BR /&gt;#include &amp;lt;linux/of_gpio.h&amp;gt;&lt;/P&gt;&lt;P&gt;static int __init mypinctrl_init(void)&lt;BR /&gt;{&lt;BR /&gt;int gpionum = 0;&lt;BR /&gt;int ret = 0;&lt;BR /&gt;struct device_node *node = NULL;&lt;BR /&gt;node = of_find_compatible_node(NULL,NULL,"Jason_hello");&lt;BR /&gt;if(!node){&lt;BR /&gt;printk("get node error\n");&lt;BR /&gt;return ret;&lt;BR /&gt;}&lt;BR /&gt;gpionum = of_get_named_gpio(node,"hello",0);&lt;BR /&gt;if(gpionum &amp;lt; 0){&lt;BR /&gt;printk("get gpionum error=%d\n",gpionum);&lt;BR /&gt;return ret;&lt;BR /&gt;}&lt;BR /&gt;ret = gpio_request(gpionum,"hello");&lt;BR /&gt;if(ret){&lt;BR /&gt;printk("gpio_request error\n");&lt;BR /&gt;return ret;&lt;BR /&gt;}&lt;BR /&gt;printk("gpio(%d) value = %d\n",gpionum,ret);&lt;BR /&gt;ret = gpio_get_value(gpionum);&lt;BR /&gt;printk("gpio(%d) value = %d\n",gpionum,ret);&lt;BR /&gt;gpio_direction_output(gpionum,1); // 设置 gpio 输出低电平&lt;BR /&gt;ret = gpio_get_value(gpionum);&lt;BR /&gt;printk("gpio(%d) value = %d\n",gpionum,ret);&lt;BR /&gt;return 0;&lt;BR /&gt;}&lt;BR /&gt;static void __exit mypinctrl_exit(void)&lt;BR /&gt;{&lt;BR /&gt;printk("%s\n",__func__);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;module_init(mypinctrl_init);&lt;BR /&gt;module_exit(mypinctrl_exit);&lt;BR /&gt;MODULE_LICENSE("GPL");&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;编译后加载模块驱动，该io可以被驱动正常申请控制。&lt;BR /&gt;insmod gpio.ko&lt;BR /&gt;[ 30.910031] gpio(119) value = 0&lt;BR /&gt;[ 30.913236] gpio(119) value = 0&lt;BR /&gt;[ 30.916442] gpio(119) value = 1&lt;BR /&gt;验证2：&lt;BR /&gt;将上述控制函数修改后添加到drivers/tty/serial/imx.c中运行，依旧无法申请gpio，报错依旧为-517&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;验证3：&lt;BR /&gt;在drivers/tty/serial/imx.c 直接添加&lt;BR /&gt;gpio_request(119,"hello");依旧报错gpio_request error=-517&lt;/P&gt;</description>
      <pubDate>Wed, 12 Oct 2022 03:32:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1535955#M196247</guid>
      <dc:creator>yqa</dc:creator>
      <dc:date>2022-10-12T03:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: imx8mp kernel  L5.4.70 driver/tty/serial/imx.c can not control gpio</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1538231#M196403</link>
      <description>&lt;P&gt;FYI.&lt;/P&gt;&lt;P&gt;There is an example of getting the gpio for "wlf,mute" from DT in the wm8524 driver.&lt;/P&gt;&lt;P&gt;&lt;A href="https://source.codeaurora.org/external/imx/linux-imx/tree/sound/soc/codecs/wm8524.c?h=imx_5.4.70_2.3.0" target="_blank"&gt;https://source.codeaurora.org/external/imx/linux-imx/tree/sound/soc/codecs/wm8524.c?h=imx_5.4.70_2.3.0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this is the DT.&lt;/P&gt;&lt;P&gt;&lt;A href="https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.dts?h=imx_5.4.70_2.3.0" target="_blank"&gt;https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mm-evk.dts?h=imx_5.4.70_2.3.0&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 04:07:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1538231#M196403</guid>
      <dc:creator>jimmychan</dc:creator>
      <dc:date>2022-10-17T04:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: imx8mp kernel  L5.4.70 driver/tty/serial/imx.c can not control gpio</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1788501#M218692</link>
      <description>&lt;P&gt;I meet the same problem but I couldn't open the website that you given, could you give the newer again? Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jan 2024 05:41:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1788501#M218692</guid>
      <dc:creator>chenhongsheng</dc:creator>
      <dc:date>2024-01-15T05:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: imx8mp kernel  L5.4.70 driver/tty/serial/imx.c can not control gpio</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1789040#M218732</link>
      <description>&lt;P&gt;The source code moved to github.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/nxp-imx/linux-imx/tree/imx_5.4.70_2.3.0" target="_blank"&gt;https://github.com/nxp-imx/linux-imx/tree/imx_5.4.70_2.3.0&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 01:58:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/imx8mp-kernel-L5-4-70-driver-tty-serial-imx-c-can-not-control/m-p/1789040#M218732</guid>
      <dc:creator>jimmychan</dc:creator>
      <dc:date>2024-01-16T01:58:33Z</dc:date>
    </item>
  </channel>
</rss>

