Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41255 )
Change subject: src/include/gpio.h: Drop 'include <soc/gpio.h>' ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41255/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/41255/1//COMMIT_MSG@9 PS1, Line 9: include <soc/gpio.h> in 'src/include/gpio.h' does not make sense.
looks like this file is only used by soc. […]
This is a common API that relies on SoC-specific interna in the backend. gpio_input(), gpio_output(), etc. are common coreboot functions that can be used by all platforms which implement the GPIO API, which allows us to build common code on top of it. But the hardware details of how to actually set or read a GPIO are of course specific to each SoC and have to be implemented by SoC code. It is in that sense no different than e.g. <device/i2c.h> which declares platform_i2c_transfer() that is then implemented by different files in the respective SoC directories.
The difference here is that we don't just need SoC-specific code but also SoC-specific definitions, for gpio_t. The API just specifies that each gpio_t must be 4 bytes long, but not exactly how they look. For many SoCs GPIOs are identified by more than one number (e.g. bank number and pin number), so it is advantageous to define gpio_t as a struct of bit fields (e.g. see rockchip/common/include/soc/gpio.h). <soc/gpio.h> is a well-known SoC header name that any SoC which wants to be compatible with this API must provide and which must contain a typedef for gpio_t, as is explained in the comment in <gpio.h>.