About new gpio API in linux/gpio.h adopted by kernel 4.8
Andrew Jeffery
andrew at aj.id.au
Thu Sep 6 23:29:53 AEST 2018
On Thu, 6 Sep 2018, at 22:17, Andrew Geissler wrote:
> Hey Kuiying, this seems like more of a 4.18 kernel question for
> Joel/AndrewJ. Put them on cc.
> On Thu, Sep 6, 2018 at 2:30 AM Wang, Kuiying <kuiying.wang at intel.com> wrote:
> >
> > Hi Brad/Andrew,
> > I found the new gpio API adopted by kernel 4.8, is not fully ready, all the lines are "unnamed".
I expect this is because no-one has given them an name in your devicetree. For example, here's some output from a system I have handy:
root at witherspoon:/tmp# gpioinfo /dev/gpiochip3
gpiochip3 - 16 lines:
line 0: "PS_SMBUS_RESET_N" unused input active-high
line 1: "APSS_RESET_N" unused input active-high
line 2: "GPU0_TH_OVERT_N_BUFF" unused input active-high
line 3: "GPU1_TH_OVERT_N_BUFF" unused input active-high
line 4: "GPU2_TH_OVERT_N_BUFF" unused input active-high
line 5: "GPU3_TH_OVERT_N_BUFF" unused input active-high
line 6: "GPU4_TH_OVERT_N_BUFF" unused input active-high
line 7: "GPU5_TH_OVERT_N_BUFF" unused input active-high
line 8: "GPU0_PWR_GOOD_BUFF" unused input active-high
line 9: "GPU1_PWR_GOOD_BUFF" unused input active-high
line 10: "GPU2_PWR_GOOD_BUFF" unused input active-high
line 11: "GPU3_PWR_GOOD_BUFF" unused input active-high
line 12: "GPU4_PWR_GOOD_BUFF" unused input active-high
line 13: "GPU5_PWR_GOOD_BUFF" unused input active-high
line 14: "12V_BREAKER_FLT_N" unused input active-high
line 15: "THROTTLE_UNLATCHED_N" unused input active-high
Which corresponds to:
https://github.com/openbmc/linux/blob/dev-4.18/arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts#L501
> > If that we cannot switch to it now.
> > Or there is special kernel based configuration I have to do?
> >
> > root at wolfpass:/tmp# ./gpiodetect
> > gpiochip0 [SGPIOA] (8 lines)
> > gpiochip1 [SGPIOB] (8 lines)
> > gpiochip10 [1e780000.gpio] (232 lines)
> > gpiochip2 [SGPIOC] (8 lines)
> > gpiochip3 [SGPIOD] (8 lines)
> > gpiochip4 [SGPIOE] (8 lines)
> > gpiochip5 [SGPIOF] (8 lines)
> > gpiochip6 [SGPIOG] (8 lines)
> > gpiochip7 [SGPIOH] (8 lines)
> > gpiochip8 [SGPIOI] (8 lines)
> > gpiochip9 [SGPIOJ] (8 lines)
> > root at wolfpass:/tmp# ./gpioinfo /dev/gpiochip1
> > gpiochip1 - 8 lines:
> > line 0: unnamed unused output active-high
> > line 1: unnamed unused output active-high
> > line 2: unnamed unused output active-high
> > line 3: unnamed unused output active-high
> > line 4: unnamed unused output active-high
> > line 5: unnamed unused output active-high
> > line 6: unnamed unused output active-high
> > line 7: unnamed unused output active-high
> > root at wolfpass:/tmp# ./gpioinfo /dev/gpiochip10
> > gpiochip10 - 232 lines:
> > line 0: unnamed unused input active-high
> > line 1: unnamed unused input active-high
> > line 2: unnamed unused input active-high
> > line 3: unnamed unused input active-high
> > line 4: unnamed unused input active-high
> > line 5: unnamed unused input active-high
> > line 6: unnamed unused input active-high
> > line 7: unnamed unused input active-high
> > line 8: unnamed unused input active-high
> > line 9: unnamed unused input active-high
> > line 10: unnamed unused input active-high
> > line 11: unnamed unused input active-high
> > line 12: unnamed unused input active-high
> > line 13: unnamed unused input active-high
> > line 14: unnamed unused input active-high
> > line 15: unnamed unused input active-high
> > line 16: unnamed unused input active-high
> > root at wolfpass:/tmp# ./gpioget /dev/gpiochip10 219
> > ./gpioget: error reading GPIO values: Device or resource busy
> >
This all works fine for me. Busy is because the GPIO has been exported through some other means, for example the sysfs interface:
root at witherspoon:/tmp# ls /sys/class/gpio
export gpio305 gpio347 gpio417 gpiochip238 gpiochip280
gpio281 gpio306 gpio353 gpiochip222 gpiochip254 unexport
root at witherspoon:/tmp# gpioget /dev/gpiochip0 $((305 - 280))
gpioget: error reading GPIO values: Device or resource busy
Hope that helps.
Andrew
More information about the openbmc
mailing list