x86-power-control

Bills, Jason M jason.m.bills at linux.intel.com
Fri Oct 18 03:02:06 AEDT 2019



On 10/17/2019 6:38 AM, Oskar Senft wrote:
> Hi Michael
> 
>     Why in a target system wouldn't naming it in DTS be the most
>     reliable and
>     most easily accessible mechanism?  I can see that in development
>     being able to define
>     things helps, but it is not like the production systems would have
>     wire-wrap
>     where the GPIO pin might change.
> 
> 
> I totally agree. I was actually experimenting on our platform (TYAN 
> S7106) to name GPIO pins in the DTS, but I couldn't figure out how to 
> read those names from userspace.
> 
> Here's what I tried in the DTS:
> 
> &gpio {
>          pin_gpio_d2 {
>                  gpios = <ASPEED_GPIO(D, 2) GPIO_ACTIVE_HIGH>;
>                  input;
>                  line-name = "SYS_PWROK_BUF";
>          };
> ...
> 
> However, from what I can tell line-name is actually only relevant when 
> used together with "gpiohog", which is not what we want.
> 
> Did you manage to make this work?

In our DTS we use gpio-line-names to name all of the GPIOs in one block:

&gpio {
	status = "okay";
	gpio-line-names =
	/*A0-A7*/	"","","","","","","","",
	/*B0-B7*/	"","","","","","","","",
	/*C0-C7*/	"","","","","","","","",
	/*D0-D7*/	"","","","","","","","",
	/*E0-E7*/ 
"RESET_BUTTON","RESET_OUT","POWER_BUTTON","POWER_OUT","","","","",
	/*F0-F7*/	"NMI_OUT","","","","CPU_ERR0","CPU_ERR1","","",
	/*G0-G7*/	"CPU_ERR2","CPU_CATERR","PCH_BMC_THERMTRIP","","","","","",
	/*H0-H7*/	"","","","","","","","",
	/*I0-I7*/	"","","","","","","","",
	/*J0-J7*/	"","","","","","","","",
	/*K0-K7*/	"","","","","","","","",
	/*L0-L7*/	"","","","","","","","",
	/*M0-M7*/	"","","","","","","","",
	/*N0-N7*/	"","","","","","","","",
	/*O0-O7*/	"","","","","","","","",
	/*P0-P7*/	"","","","","","","","",
	/*Q0-Q7*/	"","","","","","","","",
	/*R0-R7*/	"","","","","","","","",
	/*S0-S7*/	"","","","","","","","",
	/*T0-T7*/	"","","","","","","","",
	/*U0-U7*/	"","","","","","","","",
	/*V0-V7*/	"","","","","","","","",
	/*W0-W7*/	"","","","","","","","",
	/*X0-X7*/	"","","","","","","","",
	/*Y0-Y7*/	"SIO_S3","SIO_S5","","SIO_ONCONTROL","","","","",
	/*Z0-Z7*/	"","SIO_POWER_GOOD","","","","","","",
	/*AA0-AA7*/	"P3VBAT_BRIDGE_EN","","","","","","SMI","POST_COMPLETE",
	/*AB0-AB7*/	"","NMI_BUTTON","ID_BUTTON","PS_PWROK","","","","",
	/*AC0-AC7*/	"","","","","","","","";
};

https://github.com/Intel-BMC/openbmc/blob/intel/meta-openbmc-mods/meta-ast2500/recipes-kernel/linux/linux-aspeed/0001-arm-dts-add-DTS-for-Intel-platforms.patch#L144

Then, in user space, libgpiod has a gpiod::find_line() function that 
takes the GPIO name and returns a gpiod::line object that can request 
various functions from the GPIO.

Here is an example of requesting GPIO edge events in x86-power-control:
https://github.com/openbmc/x86-power-control/blob/master/power-control-x86/src/power_control.cpp#L805

> 
> Thanks
> Oskar.


More information about the openbmc mailing list