1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Copyright (C) ASPEED Technology Inc. 4 */ 5 6 #include <common.h> 7 #include <clk.h> 8 #include <dm.h> 9 #include <errno.h> 10 #include <fdtdec.h> 11 #include <asm/io.h> 12 #include <asm/arch/ahbc_aspeed.h> 13 14 #define AHBC_UNLOCK 0xaeed1a03 15 struct aspeed_ahbc_priv { 16 struct aspeed_ahbc_reg *ahbc; 17 }; 18 19 extern void aspeed_ahbc_remap_enable(struct aspeed_ahbc_reg *ahbc) 20 { 21 writel(AHBC_UNLOCK, &ahbc->protection_key); 22 writel(0x20, &ahbc->addr_remap); 23 writel(0x1, &ahbc->protection_key); 24 } 25 26 static int aspeed_ahbc_probe(struct udevice *dev) 27 { 28 struct aspeed_ahbc_priv *priv = dev_get_priv(dev); 29 30 debug("%s(dev=%p) \n", __func__, dev); 31 32 priv->ahbc = devfdt_get_addr_ptr(dev); 33 if (IS_ERR(priv->ahbc)) 34 return PTR_ERR(priv->ahbc); 35 36 return 0; 37 } 38 39 static const struct udevice_id aspeed_ahbc_ids[] = { 40 { .compatible = "aspeed,aspeed-ahbc" }, 41 { } 42 }; 43 44 U_BOOT_DRIVER(aspeed_ahbc) = { 45 .name = "aspeed_ahbc", 46 .id = UCLASS_MISC, 47 .of_match = aspeed_ahbc_ids, 48 .probe = aspeed_ahbc_probe, 49 .priv_auto_alloc_size = sizeof(struct aspeed_ahbc_priv), 50 }; 51