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 #include <linux/types.h> 14 15 #define AHBC_UNLOCK 0xaeed1a03 16 struct aspeed_ahbc_priv { 17 struct aspeed_ahbc_reg *ahbc; 18 }; 19 20 extern void aspeed_ahbc_remap_enable(struct aspeed_ahbc_reg *ahbc) 21 { 22 uint32_t tmp_val; 23 24 tmp_val = readl(&ahbc->addr_remap); 25 tmp_val |= 0x20; 26 writel(AHBC_UNLOCK, &ahbc->protection_key); 27 writel(tmp_val, &ahbc->addr_remap); 28 writel(0x1, &ahbc->protection_key); 29 } 30 31 static int aspeed_ahbc_probe(struct udevice *dev) 32 { 33 struct aspeed_ahbc_priv *priv = dev_get_priv(dev); 34 35 debug("%s(dev=%p) \n", __func__, dev); 36 37 priv->ahbc = devfdt_get_addr_ptr(dev); 38 if (IS_ERR(priv->ahbc)) 39 return PTR_ERR(priv->ahbc); 40 41 return 0; 42 } 43 44 static const struct udevice_id aspeed_ahbc_ids[] = { 45 { .compatible = "aspeed,aspeed-ahbc" }, 46 { } 47 }; 48 49 U_BOOT_DRIVER(aspeed_ahbc) = { 50 .name = "aspeed_ahbc", 51 .id = UCLASS_MISC, 52 .of_match = aspeed_ahbc_ids, 53 .probe = aspeed_ahbc_probe, 54 .priv_auto_alloc_size = sizeof(struct aspeed_ahbc_priv), 55 }; 56