<?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中的主题 Detect button press at u-boot</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Detect-button-press-at-u-boot/m-p/1771319#M217082</link>
    <description>&lt;P&gt;Hi there,&lt;BR /&gt;I am using custom i.MX8MM board. I have some issue regarding u-boot button press detection.&lt;BR /&gt;I have custom functionality that, I have 4 button (as gpio), when We press 4 buttons together, I want to jump to fastboot mode. I have found gpio library in uboot and tried to detect one gpio and reading its state, but I am unable to read gpio state it always gives me 0. Here is my basuc code which I tried,&lt;/P&gt;&lt;P&gt;ret = gpio_to_device(46, &amp;amp;desc);&lt;BR /&gt;if (ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in gpio_to_device\n");&lt;BR /&gt;return ret;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("\nsuccess gpio_to_device\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;ret = dm_gpio_request(&amp;amp;desc, "MINUS");&lt;BR /&gt;if(ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in dm_gpio_request\n");&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("success in dm_gpio_request ret=%d\n", ret);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;value = dm_gpio_get_value(&amp;amp;desc);&lt;BR /&gt;if(ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in gpio_get_value ***** value=%d\n", value);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("success in gpio_get_value ***** value=%d\n", value);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Then I also tried with&amp;nbsp;&lt;BR /&gt;ret = gpio_direction_input(46);&lt;BR /&gt;if (ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in gpio_direction_input\n");&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("\nsuccess gpio_direction_input ret=%d\n", ret);&lt;BR /&gt;}&lt;BR /&gt;But adding above function gives me error like,&lt;BR /&gt;"gpio not reserved"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me, How can I detect button press at u-boot?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Fri, 08 Dec 2023 05:25:34 GMT</pubDate>
    <dc:creator>Dhvani</dc:creator>
    <dc:date>2023-12-08T05:25:34Z</dc:date>
    <item>
      <title>Detect button press at u-boot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Detect-button-press-at-u-boot/m-p/1771319#M217082</link>
      <description>&lt;P&gt;Hi there,&lt;BR /&gt;I am using custom i.MX8MM board. I have some issue regarding u-boot button press detection.&lt;BR /&gt;I have custom functionality that, I have 4 button (as gpio), when We press 4 buttons together, I want to jump to fastboot mode. I have found gpio library in uboot and tried to detect one gpio and reading its state, but I am unable to read gpio state it always gives me 0. Here is my basuc code which I tried,&lt;/P&gt;&lt;P&gt;ret = gpio_to_device(46, &amp;amp;desc);&lt;BR /&gt;if (ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in gpio_to_device\n");&lt;BR /&gt;return ret;&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("\nsuccess gpio_to_device\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;ret = dm_gpio_request(&amp;amp;desc, "MINUS");&lt;BR /&gt;if(ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in dm_gpio_request\n");&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("success in dm_gpio_request ret=%d\n", ret);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;value = dm_gpio_get_value(&amp;amp;desc);&lt;BR /&gt;if(ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in gpio_get_value ***** value=%d\n", value);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("success in gpio_get_value ***** value=%d\n", value);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;Then I also tried with&amp;nbsp;&lt;BR /&gt;ret = gpio_direction_input(46);&lt;BR /&gt;if (ret)&lt;BR /&gt;{&lt;BR /&gt;printf("error in gpio_direction_input\n");&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;printf("\nsuccess gpio_direction_input ret=%d\n", ret);&lt;BR /&gt;}&lt;BR /&gt;But adding above function gives me error like,&lt;BR /&gt;"gpio not reserved"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me, How can I detect button press at u-boot?&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 05:25:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Detect-button-press-at-u-boot/m-p/1771319#M217082</guid>
      <dc:creator>Dhvani</dc:creator>
      <dc:date>2023-12-08T05:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Detect button press at u-boot</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Detect-button-press-at-u-boot/m-p/1772671#M217182</link>
      <description>&lt;P&gt;Please refer gpio operation in&amp;nbsp;&lt;SPAN&gt;setup_typec&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;static int setup_typec(void)
{
	int ret;
	struct gpio_desc per_12v_desc;

	debug("tcpc_init port 2\n");
	ret = tcpc_init(&amp;amp;port2, port2_config, NULL);
	if (ret) {
		printf("%s: tcpc port2 init failed, err=%d\n",
		       __func__, ret);
	} else if (tcpc_pd_sink_check_charging(&amp;amp;port2)) {
		printf("Power supply on USB2\n");

		/* Enable PER 12V, any check before it? */
		ret = dm_gpio_lookup_name("gpio@20_1", &amp;amp;per_12v_desc);
		if (ret) {
			printf("%s lookup gpio@20_1 failed ret = %d\n", __func__, ret);
			return -ENODEV;
		}

		ret = dm_gpio_request(&amp;amp;per_12v_desc, "per_12v_en");
		if (ret) {
			printf("%s request per_12v failed ret = %d\n", __func__, ret);
			return -EIO;
		}

		/* Enable PER 12V regulator */
		dm_gpio_set_dir_flags(&amp;amp;per_12v_desc, GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
	}

	debug("tcpc_init port 1\n");
	imx_iomux_v3_setup_multiple_pads(ss_mux_gpio, ARRAY_SIZE(ss_mux_gpio));
	gpio_request(USB_TYPEC_SEL, "typec_sel");
	gpio_request(USB_TYPEC_EN, "typec_en");
	gpio_direction_output(USB_TYPEC_EN, 0);

	ret = tcpc_init(&amp;amp;port1, port1_config, &amp;amp;ss_mux_select);
	if (ret) {
		printf("%s: tcpc port1 init failed, err=%d\n",
		       __func__, ret);
	} else {
		return ret;
	}

	return ret;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Dec 2023 02:22:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Detect-button-press-at-u-boot/m-p/1772671#M217182</guid>
      <dc:creator>Zhiming_Liu</dc:creator>
      <dc:date>2023-12-12T02:22:48Z</dc:date>
    </item>
  </channel>
</rss>

