# Activate gpio expander

**URL:** <https://mangoh.discourse.group/t/activate-gpio-expander/2077>\
**Category:** mangOH Red\
**Created:** [November 6, 2018, 5:17pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077 "2018-11-06T17:17:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 6, 2018, 5:17pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/1 "2018-11-06T17:17:09Z")

</div>

hello, how can i activate gpio expander to enable the muxing between the SD card and iot0 on mangored?

thanks;

---

<div class="post-metadata">

**Author:** ![asifarshad](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@asifarshad](https://mangoh.discourse.group/u/asifarshad)\
**Post date:** [November 7, 2018, 6:03am UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/2 "2018-11-07T06:03:13Z")

</div>

To enbale gpio expander service just uncomment the line in the sdef file containing the expanderService app of the system build and make it.

 ![Screenshot%20from%202018-11-07%2011-01-24](https://us1.discourse-cdn.com/flex016/uploads/mangoh/original/1X/d56559e8715c6c35af875e4330d9cea515d84cb0.png)

---

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 7, 2018, 11:58am UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/3 "2018-11-07T11:58:15Z")

</div>

Thanks a lot for the quick response.

I tried that but not sure how to make it work.  
I think when the sdio is switched to iot0 the d401 led supposed to be on which didn’t happened.

I saw there is the user tool gpioexp that was added to the red board but not sure how to use it…

Will be glad for more tips how to make the sdio switched to iot0…

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 7, 2018, 5:04pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/4 "2018-11-07T17:04:52Z")

</div>

Changing the SDIO mux does not affect any LEDs on the mangOH Red. Unfortunately, the GPIO situation is still a bit of a mess. I have been pleading with the Sierra Wireless Linux reference team to help fix this for a long time, but I haven’t been able to get a commitment. Currently, the mangOH SDEF creates a kernel device controlled by the sx150x device driver to control the sx1509 GPIO expander. On top of that there’s a platform driver called `led` which allows the card detect LED to be controlled from userspace using sysfs. GpioExpanderService was a previous approach which uses a userspace driver to control the sx1509 so that Legato apps can manipulate GPIOs on the expander. This approach is incompatible with the current approach because it’s dangerous to have two drivers controlling the same device.

---

<div class="post-metadata">

**Author:** ![asifarshad](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@asifarshad](https://mangoh.discourse.group/u/asifarshad)\
**Post date:** [November 7, 2018, 5:06pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/5 "2018-11-07T17:06:27Z")

</div>

Yes, this situation really needs an improvement. The labels and the workarounds create conflicts using the expander service.

---

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 7, 2018, 5:59pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/6 "2018-11-07T17:59:28Z")

</div>

So after uncomment and build gpio expanderservice should I do anything else to activate the mux to iot0 or it will be the default state?

How can check it was changed to alternate configuration?

Thanks a lot

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 7, 2018, 6:03pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/7 "2018-11-07T18:03:12Z")

</div>

You have to write an app which binds to the gpioExpanderService and then configures that GPIO as an output and set it to the correct output level. There is some sample code here that might help: [https://github.com/mangOH/mangOH/tree/master/samples/tutorials/mangOH\_Red/gpio/TimerLed](https://github.com/mangOH/mangOH/tree/master/samples/tutorials/mangOH_Red/gpio/TimerLed)

---

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 7, 2018, 7:26pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/8 "2018-11-07T19:26:28Z")

</div>

Can the muxing be done using the gpioexp app that already on board?

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 7, 2018, 10:22pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/9 "2018-11-07T22:22:07Z")

</div>

I believe `gpioexp` could be used to control the mux as well. However that program is basically it’s own driver as well, so it’s going to step on top of any other driver trying to control the sx1509.

---

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 8, 2018, 11:05am UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/10 "2018-11-08T11:05:55Z")

</div>

Thanks for the support…  
I used the gpioexp and think i changed the mux (using the gpio 9 set to low) to iot0 on mango red, but can’t use it yet…

Could it be that we need to get the sdio driver to rescan the hw added on iot0 or something? If so how can it be done?

Thanks

---

<div class="post-metadata">

**Author:** ![asyal](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/asyal/32/78_2.png) [@asyal](https://mangoh.discourse.group/u/asyal)\
**Post date:** [November 8, 2018, 2:12pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/11 "2018-11-08T14:12:54Z")

</div>

gpioexp was written for mangoh green. Are you saying it works for you?

---

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 8, 2018, 5:16pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/12 "2018-11-08T17:16:22Z")

</div>

Yes I even got some led on using this tool…

---

<div class="post-metadata">

**Author:** ![nanomen](https://avatars.discourse-cdn.com/v4/letter/n/dbc845/32.png) [@nanomen](https://mangoh.discourse.group/u/nanomen)\
**Post date:** [November 11, 2018, 8:18pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/13 "2018-11-11T20:18:38Z")

</div>

still on the subject please:

Is there is a way to make the gpio9 (select sdio mux to expander) to be the default on boot, using some configuration on DTS files or something?

thanks

---

<div class="post-metadata">

**Author:** ![Zahid](https://avatars.discourse-cdn.com/v4/letter/z/e79b87/32.png) [@Zahid](https://mangoh.discourse.group/u/Zahid)\
**Post date:** [November 13, 2018, 2:24am UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/14 "2018-11-13T02:24:14Z")

</div>

@nanomen in regards to rescan - Actually, 2 different drivers and there associated SDIO controllers exist. The WP76/77 series has a built-in driver that sits in 1-sec. poll loop scanning forever, but once it finds any device across SDIO it never rescans - to cause re-scanning needs some changes to the Linux Reference code SDHCI-MSM driver. Whereas on the WP85 series it scans at boot and never rescans, you can just load & unload the driver (by rmmod msm\_sdcc; modprobe msm\_sdcc) to start the rescan. Thus, it depends.

---

<div class="post-metadata">

**Author:** ![dfrey](https://sea2.discourse-cdn.com/flex016/user_avatar/mangoh.discourse.group/dfrey/32/303_2.png) [@dfrey](https://mangoh.discourse.group/u/dfrey)\
**Post date:** [November 13, 2018, 6:31pm UTC](https://mangoh.discourse.group/t/activate-gpio-expander/2077/15 "2018-11-13T18:31:09Z")

</div>

> Is there is a way to make the gpio9 (select sdio mux to expander) to be the default on boot, using some configuration on DTS files or something?

The platform data associated with the sx150x driver doesn’t allow for the ports to be configured as outputs. It should be possible to add a few lines of code to the mangOH\_red driver to configure that specific GPIO as an output and write the appropriate value to it though.
