pinctrl: at91-pio4: Bind GPIO driver to the pinctrl DT node
authorSergiu Moga <sergiu.moga@microchip.com>
Thu, 1 Sep 2022 14:22:41 +0000 (17:22 +0300)
committerEugen Hristev <eugen.hristev@microchip.com>
Mon, 19 Sep 2022 06:51:04 +0000 (09:51 +0300)
commit2ed96a87d2c7f22fe2649f6e041cc3884a0dbea7
tree3093ba59302781f0ac253d862034437dbc9eb0c4
parentf02e52b7e68eeebca1d9e2c4bfccff9bd647e393
pinctrl: at91-pio4: Bind GPIO driver to the pinctrl DT node

This has been done in order to align the DT of U-Boot with the DT
of Linux. In Linux, a phandle from a '-gpio' DT property is linked
to the pinctrl driver, a single driver that handles both pinctrl
settings and offers GPIO API to callers. On the other hand,
U-Boot redirects such phandle to a corresponding UCLASS_GPIO
driver, because U-Boot offers two different types of drivers
in this case: UCLASS_PINCTRL which handles pin functions and
UCLASS_GPIO which handles gpio requests as a gpio provider.
Due to this, we have two drivers in Uboot, but the Devicetree
has a single node. Thus, just one of the drivers can be probed
for the DT node during platform initialization, before relocation.

Our previous solution in U-Boot was to have a different devicetree:
the gpio node has a subnode for the pinctrl driver, which
is not compliant with Linux ABI. Furthermore, our documentation
for this type of nodes mentions no such gpio compatible.

After this patch, we can no longer add nodes with a gpio
compatible in the DT. Thus, in order to link the pinctrl driver to
the gpio one, a hook to the bind method of the former in U-Boot has
been added and the GPIO related compatibles have been removed to
avoid conflict when compatibles are enumerated and bound to drivers
during platform start before relocation. The bind method will attach
the GPIO driver to the pinctrl DT node so that every phandle coming
from '-gpio' DT properties will be redirected to a valid driver
attached to the pinctrl DT node.

Signed-off-by: Sergiu Moga <sergiu.moga@microchip.com>
drivers/gpio/atmel_pio4.c
drivers/pinctrl/pinctrl-at91-pio4.c