<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 8, 2019, at 9:53 AM, Andrew Jeffery <<a href="mailto:andrew@aj.id.au" class="">andrew@aj.id.au</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br class=""><br class="">On Tue, 7 May 2019, at 18:23, Brad Chou wrote:<br class=""><blockquote type="cite" class="">Hi Samuel,<br class="">Thanks for your reply, I am using AST2500.<br class="">I tried add gpio-hog settings into my device tree, and yes, the GPIO <br class="">works as it defined.<br class="">But all GPIOs defined by gpio-hog can not be modified in user space by <br class="">gpioset / gpioget utility.<br class="">I need to set all GPIOs to pre-defined state and can change it at run <br class="">time.<br class="">Set GPIOs in Device tree is trying to lock it by a fixed direction and <br class="">value.<br class=""><br class=""></blockquote><br class="">This problem is probably best taken up with upstream. Currently GPIO<br class="">nodes in the devicetree are ignored if they do not have the `gpio-hog`<br class="">property:<br class=""><br class=""><a href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/gpiolib-of.c?h=v5.1#n454" class="">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpio/gpiolib-of.c?h=v5.1#n454</a><br class=""><br class="">Changing that might be a hard argument - it may impact existing<br class="">devicetrees that expect the current behaviour.<br class=""><br class="">However, I'm interested in what you see wrong with doing this from<br class="">userspace? What requirements do you have that would need this to<br class="">be done in the kernel?<br class=""><br class="">Cheers,<br class=""><br class="">Andrew</div></blockquote><br class="">I don’t really need it to be set in the kernel.<div class="">Just curious about how openBMC initial all GPIOs, especially for AST2500 that has over 200+ GPIOs.<br class=""><div class=""><div>And gpio-hog meaning - to take or use a lot of something in a way that prevents other people from having this gpio.</div><div>So no one can operate it after set gpio-hog.</div><div>Any userspace operations just got an error similar to this, assume you hog gpio 35 in the kernel :</div><div>gpioget gpiochip0 35<br class="">gpioget: error reading GPIO values: Device or resource busy</div></div></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class="">On May 8, 2019, at 6:32 PM, Samuel Jiang <<a href="mailto:chyishian.jiang@gmail.com" class="">chyishian.jiang@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<title class=""></title>
<div class="">
<div name="messageBodySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<div style="caret-color: rgb(39, 39, 40);" class="">Hi Brad,</div>
</div>
<div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">On May 7, 2019, 4:52 PM +0800, Brad Chou <<a href="mailto:chou.brad@gmail.com" class="">chou.brad@gmail.com</a>>, wrote:<br class="">
<blockquote type="cite" class="spark_quote" style="margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid; border-left-color: rgb(26, 188, 156);">Hi Samuel,
<div class="">Thanks for your reply, I am using AST2500.</div>
<div class="">I tried add gpio-hog settings into my device tree, and yes, the GPIO works as it defined.</div>
<div class="">But all GPIOs defined by gpio-hog can not be modified in user space by gpioset / gpioget utility.</div>
<div class="">I need to set all GPIOs to pre-defined state and can change it at run time.</div>
<div class="">Set GPIOs in Device tree is trying to lock it by a fixed direction and value.</div>
<div class=""><br class=""></div>
<div class="">Thanks.</div>
<div class="">
<div class=""></div>
</div>
</blockquote>
<br class="">
<div class="">You could trace the gpioplus library how does it implement control pins, it seems direct modify by gpio chips.<br class=""></div></div></div></div></blockquote><div><br class=""></div><div>Since openBMC has no individual recipes to do GPIO initial.</div><div>Gpioplus is the preferred way to control GPIOs.</div><div>Thanks.</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div name="messageReplySection" style="font-size: 14px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" class="">
<div dir="auto" class=""><br class=""></div>
<div dir="auto" class="">
<blockquote type="cite" class="spark_quote" style="caret-color: rgb(39, 39, 40); margin: 5px; padding-left: 10px; border-left-width: thin; border-left-style: solid; border-left-color: rgb(26, 188, 156);">Now, I am using a shell script with gpioset utility to do the job.<br class="">
But I know using shell to do it is a bad idea.<br class="">
Does anyone have better ideas ? </blockquote>
<br class="">
<div class=""><br class=""></div>
</div>
<div dir="auto" class="">In my situation, I still use shell script export pin which didn't pre-define output high or low and control GPIOs program by c++ at runtime.<br class="">
But I think the previous shell script also could rewrite to c++.<br class=""></div>
<div dir="auto" class=""><br class=""></div>
<div dir="auto" class=""><br class=""></div>
<div dir="auto" class="">Thanks,</div>
<div dir="auto" class="">Samuel Jiang</div>
<div dir="auto" class=""><br class=""></div>
<div dir="auto" class=""><br class=""></div>
<br class=""></div>
</div>
</div></blockquote></div><br class=""></body></html>