aspeed: pinctrl: Allow disabling Port D and Port E loopback mode
Subsystems (4)
PATCH RESEND 1/1 aspeed: pinctrl: Allow disabling Port D and Port E loopback mode
Port D and port E GPIO loopback modes are commonly enabled via hardware straps for use with front-panel buttons. When the BMC is powered off or fails to boot, the front-panel buttons are directly connected to the host chipset via the loopback to allow direct power-on and reset control. Once the BMC has booted, the loopback mode must be disabled for the BMC to take over control of host power-on and reset.
Disabling these loopback modes requires writing to the hardware strap register which violates the current design of assuming the system designer chose the strap settings for a specific reason and they should be treated as read-only. Only the two bits of the strap register related to these loopback modes are allowed to be written and comments have been added to explain why.
--- drivers/pinctrl/aspeed/pinctrl-aspeed.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +12 -2
@@ -198,9 +198,19 @@ static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,* them. This may mean that certain functions cannot be * deconfigured and is the reason we re-evaluate after writing * all descriptor bits. +* +* Port D and port E GPIO loopback modes are the only exception +* as those are commonly used with front-panel buttons to allow +* normal operation of the host when the BMC is powered off or +* fails to boot. Once the BMC has booted, the loopback mode +* must be disabled for the BMC to control host power-on and +* reset. */ -if ((desc->reg ==HW_STRAP1 || desc->reg ==HW_STRAP2 ) && - desc->ip ==ASPEED_IP_SCU ) +if (desc->ip ==ASPEED_IP_SCU && desc->reg ==HW_STRAP1 && + !(desc->mask & (BIT (21 ) |BIT (22 )))) +continue ; + +if (desc->ip ==ASPEED_IP_SCU && desc->reg ==HW_STRAP2 )continue ; ret = regmap_update_bits(maps[desc->ip], desc->reg,
Signature · 1 line
2.11.0.483.g087da7b7c-goog
Quoted 7 lines · Rick Altherr
Port D and port E GPIO loopback modes are commonly enabled via hardware straps for use with front-panel buttons. When the BMC is powered off or fails to boot, the front-panel buttons are directly connected to the host chipset via the loopback to allow direct power-on and reset control. Once the BMC has booted, the loopback mode must be disabled for the BMC to take over control of host power-on and reset.
Quoted 6 lines
Disabling these loopback modes requires writing to the hardware strap register which violates the current design of assuming the system designer chose the strap settings for a specific reason and they should be treated as read-only. Only the two bits of the strap register related to these loopback modes are allowed to be written and comments have been added to explain why.
I had to clarify this on IRC. The Aspeed soc is flexible if you want no-passthrough when powered off and want to enable it at runtime with normal SCU registers.
However if you want passthrough when powered off, and then disable it at runtime, you need to change the strap. Hence the patch.
Quoted 1 line
Signed-off-by Rick Altherr <[email protected]>
Cheers,
Joel
Quoted 33 lines
--- drivers/pinctrl/aspeed/pinctrl-aspeed.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)drivers/pinctrl/aspeed/pinctrl-aspeed.c +12
-3@@ -198,9 +198,19 @@ static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,* them. This may mean that certain functions cannot be * deconfigured and is the reason we re-evaluate after writing * all descriptor bits. +* +* Port D and port E GPIO loopback modes are the only exception +* as those are commonly used with front-panel buttons to allow +* normal operation of the host when the BMC is powered off or +* fails to boot. Once the BMC has booted, the loopback mode +* must be disabled for the BMC to control host power-on and +* reset. */ -if ((desc->reg ==HW_STRAP1 || desc->reg ==HW_STRAP2 ) && - desc->ip ==ASPEED_IP_SCU ) +if (desc->ip ==ASPEED_IP_SCU && desc->reg ==HW_STRAP1 && + !(desc->mask & (BIT (21 ) |BIT (22 )))) +continue ; + +if (desc->ip ==ASPEED_IP_SCU && desc->reg ==HW_STRAP2 )continue ; ret = regmap_update_bits(maps[desc->ip], desc->reg, --2.11.0.483.g087da7b7c-goog
Quoted 7 lines · Rick Altherr
Port D and port E GPIO loopback modes are commonly enabled via hardware straps for use with front-panel buttons. When the BMC is powered off or fails to boot, the front-panel buttons are directly connected to the host chipset via the loopback to allow direct power-on and reset control. Once the BMC has booted, the loopback mode must be disabled for the BMC to take over control of host power-on and reset.
Quoted 8 lines
Disabling these loopback modes requires writing to the hardware strap register which violates the current design of assuming the system designer chose the strap settings for a specific reason and they should be treated as read-only. Only the two bits of the strap register related to these loopback modes are allowed to be written and comments have been added to explain why.
Signed-off-by Rick Altherr <[email protected]>
For the record this is one of at least two awkward cases. The other is runtime switching between the using the SoC as an SPI master, and simply performing SPI pass-through for an external controller (e.g. to allow either the BMC or the host to reprogram the host BIOS image).
If the list of exceptions continues to grow we should pull the tests out to a separate function so we can keep the condition readable.
Quoted 30 lines
---
drivers/pinctrl/aspeed/pinctrl-aspeed.c | 14 ++++++++++++--1 file changed, 12 insertions(+), 2 deletions(-)drivers/pinctrl/aspeed/pinctrl-aspeed.c +0
-0@@ -198,9 +198,19 @@ static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,Quoted 11 lines
* them. This may mean that certain functions cannot be
* deconfigured and is the reason we re-evaluate after writing
* all descriptor bits.drivers/pinctrl/aspeed/pinctrl-aspeed.c +7
-0+ * + * Port D and port E GPIO loopback modes are the only exception + * as those are commonly used with front-panel buttons to allow + * normal operation of the host when the BMC is powered off or + * fails to boot. Once the BMC has booted, the loopback mode + * must be disabled for the BMC to control host power-on and + * reset.*/
drivers/pinctrl/aspeed/pinctrl-aspeed.c static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr, · line 211
Quoted 5 lines
drivers/pinctrl/aspeed/pinctrl-aspeed.c +3
-2-if ((desc->reg ==HW_STRAP1 || desc->reg ==HW_STRAP2 ) && - desc->ip ==ASPEED_IP_SCU ) +if (desc->ip ==ASPEED_IP_SCU && desc->reg ==HW_STRAP1 && + !(desc->mask & (BIT(21) | BIT(22)))) +continue ;+
Quoted 2 lines
drivers/pinctrl/aspeed/pinctrl-aspeed.c +1
-0+if (desc->ip ==ASPEED_IP_SCU && desc->reg ==HW_STRAP2 )continue;
Quoted 1 line
ret = regmap_update_bits(maps[desc->ip],
desc->reg,
[removing upstream cc]
Quoted 22 lines · Andrew Jeffery
Quoted 7 lines · Rick Altherr
Port D and port E GPIO loopback modes are commonly enabled via hardware straps for use with front-panel buttons. When the BMC is powered off or fails to boot, the front-panel buttons are directly connected to the host chipset via the loopback to allow direct power-on and reset control. Once the BMC has booted, the loopback mode must be disabled for the BMC to take over control of host power-on and reset.
Quoted 8 lines
Disabling these loopback modes requires writing to the hardware strap register which violates the current design of assuming the system designer chose the strap settings for a specific reason and they should be treated as read-only. Only the two bits of the strap register related to these loopback modes are allowed to be written and comments have been added to explain why.
Signed-off-by Rick Altherr <[email protected]>For the record this is one of at least two awkward cases. The other is runtime switching between the using the SoC as an SPI master, and simply performing SPI pass-through for an external controller (e.g. to allow either the BMC or the host to reprogram the host BIOS image).
Quoted 4 lines
If the list of exceptions continues to grow we should pull the tests out to a separate function so we can keep the condition readable.
Reviewed-by Andrew Jeffery <[email protected]>
I have applied this to dev-4.7.
Cheers,
Joel
Quoted 4 lines
Quoted 4 lines
--- drivers/pinctrl/aspeed/pinctrl-aspeed.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)