diff options
author | maxims@google.com <maxims@google.com> | 2017-04-17 19:00:23 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-05-08 15:57:31 (GMT) |
commit | 413353b30b5d23c409b6a2fd70aa1cc28451a451 (patch) | |
tree | aa519ca9b5e97b5a6e95c4902959f3b68c0cc0ee /arch/arm | |
parent | 1eb0a464b7434175800c98a175909588d38c1dae (diff) | |
download | u-boot-413353b30b5d23c409b6a2fd70aa1cc28451a451.tar.xz |
aspeed: Make SCU lock/unlock functions part of SCU API
Make functions for locking and unlocking SCU part of SCU API.
Many drivers need to modify settings in SCU and thus need to unlock it
first. This change makes it possible.
Signed-off-by: Maxim Sloyko <maxims@google.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/include/asm/arch-aspeed/scu_ast2500.h | 14 | ||||
-rw-r--r-- | arch/arm/mach-aspeed/ast2500/clk_ast2500.c | 15 |
2 files changed, 29 insertions, 0 deletions
diff --git a/arch/arm/include/asm/arch-aspeed/scu_ast2500.h b/arch/arm/include/asm/arch-aspeed/scu_ast2500.h index fc0c01a..0fa3ecb 100644 --- a/arch/arm/include/asm/arch-aspeed/scu_ast2500.h +++ b/arch/arm/include/asm/arch-aspeed/scu_ast2500.h @@ -120,6 +120,20 @@ int ast_get_clk(struct udevice **devp); */ void *ast_get_scu(void); +/** + * ast_scu_unlock() - unlock protected registers + * + * @scu, pointer to ast2500_scu + */ +void ast_scu_unlock(struct ast2500_scu *scu); + +/** + * ast_scu_lock() - lock protected registers + * + * @scu, pointer to ast2500_scu + */ +void ast_scu_lock(struct ast2500_scu *scu); + #endif /* __ASSEMBLY__ */ #endif /* _ASM_ARCH_SCU_AST2500_H */ diff --git a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c index 079909f..30cfac1 100644 --- a/arch/arm/mach-aspeed/ast2500/clk_ast2500.c +++ b/arch/arm/mach-aspeed/ast2500/clk_ast2500.c @@ -6,6 +6,7 @@ #include <common.h> #include <dm.h> +#include <asm/io.h> #include <asm/arch/scu_ast2500.h> int ast_get_clk(struct udevice **devp) @@ -28,3 +29,17 @@ void *ast_get_scu(void) return priv->scu; } + +void ast_scu_unlock(struct ast2500_scu *scu) +{ + writel(SCU_UNLOCK_VALUE, &scu->protection_key); + while (!readl(&scu->protection_key)) + ; +} + +void ast_scu_lock(struct ast2500_scu *scu) +{ + writel(~SCU_UNLOCK_VALUE, &scu->protection_key); + while (readl(&scu->protection_key)) + ; +} |