pinctrl: renesas: Make sure the pin type is updated after setting the MUX
authorLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Sat, 28 Nov 2020 13:13:08 +0000 (13:13 +0000)
committerMarek Vasut <marek.vasut+renesas@gmail.com>
Mon, 18 Jan 2021 12:29:12 +0000 (13:29 +0100)
commitcc6aa80dd1b75ee9f4661b4aa0719c13c66f1fde
tree27c1014898abb179457045cd795174057b993271
parent14ea1b3635b4af8d9e283e3671f7ee872d50b859
pinctrl: renesas: Make sure the pin type is updated after setting the MUX

By default on startup all the pin types are configured to
PINMUX_TYPE_NONE (in sh_pfc_map_pins()), when pin is set as GPIO the
pin type is updated to PINMUX_TYPE_GPIO. But the type is not updated
when the pin is set as a function in sh_pfc_pinctrl_pin_set() or
sh_pfc_pinctrl_group_set() calls (these calls only set the MUX if
the pin type is PINMUX_TYPE_NONE ie unused).

So with the current implementation pin functionality could be overwritten
silently, for example if the same pin is added for SPI and serial.

This patch makes sure of updating pin type after every successful call to
sh_pfc_config_mux() and thus fixing from pin functionality to be
overwritten. Also a warning message is printed if the current pin is being
overwritten before abort.

This also avoids pin re-muxing to same type that is for example from
command line device is asked to re-probe/select (mmc dev x) we return
early with success in this case as the pin is already muxed.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
drivers/pinctrl/renesas/pfc.c