# Kernel module gpio numbers

**URL:** <https://forum.legato.io/t/kernel-module-gpio-numbers/6823>\
**Category:** Legato Linux distribution (Yocto project)\
**Created:** [October 30, 2024, 6:21pm UTC](https://forum.legato.io/t/kernel-module-gpio-numbers/6823 "2024-10-30T18:21:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmark](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pmark](https://forum.legato.io/u/pmark)\
**Post date:** [October 30, 2024, 6:21pm UTC](https://forum.legato.io/t/kernel-module-gpio-numbers/6823/1 "2024-10-30T18:21:00Z")

</div>

I am trying to use gpio pins in a kernel module,  
if i use the commandline everything is fine if i use ex.  
root@swi-mdm9x28-wp:/sys/devices/platform/1000000.pinctrl/gpiochip0/gpio/gpio23# echo 1 \> value  
but from the kernel module i don’t see any changes no matter if i use the WP7702 gpio pin numer or the QCOM number

```
		int res1 = gpio_request(resetpin, "sysfs");
		printk(KERN_DEBUG "gpio_request %d pin:%d\n", __func__ , res1, resetpin);

		res1 = gpio_direction_output(resetpin, true);
		printk(KERN_DEBUG "gpio_direction_output %d \n", __func__ , res1);

		gpio_set_value(resetpin, 0);
		printk(KERN_DEBUG "gpio_set_value \n", __func__ );
		for (i = 0; i < 100; i++)
		{
			gpio_set_value(resetpin, val);
			if (val == 0)
				val = 1;
			else
				val = 0;

			mdelay(50);
		}

```

if resetpin = 11  
[501.981865] gpio\_request -16 pin:11 pin is busy error???  
[501.981877] gpio\_direction\_output 0  
[501.981884] gpio\_set\_value

if resetpin = 23  
[748.879787] gpio\_request 0 pin:23 no error  
[748.879805] gpio\_direction\_output 0  
[748.879813] gpio\_set\_value

```
	gpio-bit-map = <38 1>,
			<30 3>,
			<16 6>,
			<58 7>,
			<76 12>,
			<8 20>,
			<9 21>,
			<10 22>,
			<11 23>,
			<51 24>,
			<45 27>,
			<46 28>,
			<47 29>,
			<48 30>,
			<77 31>,
			<78 32>,
			<37 34>,
			<79 41>;

```

AT+WIOCFG?  
+WIOCFG: 2,16,0,0,1,0,0  
+WIOCFG: 4,3,0,0,1,0,0  
+WIOCFG: 6,0,0,0,1,0,0  
+WIOCFG: 7,16,1,0,0,0,0  
+WIOCFG: 8,16,1,0,0,0,0  
+WIOCFG: 13,16,0,0,1,0,0  
+WIOCFG: 21,16,0,0,1,0,0  
+WIOCFG: 22,16,1,0,1,0,0  
+WIOCFG: 23,16,1,0,1,0,0  
+WIOCFG: 24,16,1,0,1,0,0  
+WIOCFG: 25,16,1,0,1,0,0  
+WIOCFG: 28,16,0,0,1,0,0  
+WIOCFG: 29,16,0,0,1,0,0  
+WIOCFG: 30,16,0,0,1,0,0  
+WIOCFG: 31,16,0,0,1,0,0  
+WIOCFG: 32,16,1,0,1,0,0  
+WIOCFG: 33,16,1,0,1,0,0  
+WIOCFG: 35,16,0,0,1,0,0  
+WIOCFG: 42,16,0,0,1,0,0

AT!CUSTOM?  
!CUSTOM:  
GPSENABLE 0x01  
GPSLPM 0x01  
IPV6ENABLE 0x01  
CFUNPERSISTEN 0x01  
UIM2ENABLE 0x01  
SIMLPM 0x01  
USBSERIALENABLE 0x01  
PCSCDISABLE 0x03  
SINGLEAPNSWITCH 0x01  
TXONINDICATION 0x01  
HSICENABLE 0x01  
SCRUBEN 0x01  
EXTGPSLNAEN 0x01  
UIMAUTOSWITCH 0x01

---

<div class="post-metadata">

**Author:** ![jyijyi](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.legato.io/jyijyi/32/822_2.png) [@jyijyi](https://forum.legato.io/u/jyijyi)\
**Post date:** [October 31, 2024, 3:33am UTC](https://forum.legato.io/t/kernel-module-gpio-numbers/6823/2 "2024-10-31T03:33:56Z")

</div>

probably you have used the wrong QCOM number for GPIO23:

```auto
root@swi-mdm9x28-wp:~# echo 23 > /sys/class/gpio/export
[234.646922] gpio_map_name_to_num: find GPIO 10

```

I have also tried this PWM kernel driver to control GPIO23 in WP76 FW16.3, I can see the GPIO23 going up and down periodically:

> [@\[WP7605\]\[SW\] How to indicate the periodic signal, in order to use external Window WDT](https://forum.legato.io/t/wp7605-sw-how-to-indicate-the-periodic-signal-in-order-to-use-external-window-wdt/5087/2):
>
> please see the attached doc on generating PWM signal.[Example\_on\_simulating\_pulse\_width\_modulation(PWM).docx](https://forum.legato.io/uploads/short-url/qXMGFOqg36U5uZ7TN5w7clqQ7HA.docx) (77.5 KB)

---

<div class="post-metadata">

**Author:** ![pmark](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@pmark](https://forum.legato.io/u/pmark)\
**Post date:** [October 31, 2024, 2:28pm UTC](https://forum.legato.io/t/kernel-module-gpio-numbers/6823/3 "2024-10-31T14:28:41Z")

</div>

Thanks, it worked with gpio10
