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 <reset.h> 11 #include <fdtdec.h> 12 #include <asm/io.h> 13 #include "dp_mcu_firmware.h" 14 15 struct aspeed_dp_priv { 16 void *ctrl_base; 17 }; 18 19 static int aspeed_dp_probe(struct udevice *dev) 20 { 21 struct aspeed_dp_priv *dp = dev_get_priv(dev); 22 struct reset_ctl dp_reset_ctl, dpmcu_reset_ctrl; 23 int i, ret = 0; 24 25 /* Get the controller base address */ 26 dp->ctrl_base = (void *)devfdt_get_addr_index(dev, 0); 27 28 debug("%s(dev=%p) \n", __func__, dev); 29 30 ret = reset_get_by_index(dev, 0, &dp_reset_ctl); 31 if (ret) { 32 printf("%s(): Failed to get dp reset signal\n", __func__); 33 return ret; 34 } 35 36 ret = reset_get_by_index(dev, 1, &dpmcu_reset_ctrl); 37 if (ret) { 38 printf("%s(): Failed to get dp mcu reset signal\n", __func__); 39 return ret; 40 } 41 42 /* release reset for DPTX and DPMCU */ 43 reset_assert(&dp_reset_ctl); 44 reset_assert(&dpmcu_reset_ctrl); 45 reset_deassert(&dp_reset_ctl); 46 reset_deassert(&dpmcu_reset_ctrl); 47 48 /* select HOST or BMC as display control master 49 enable or disable sending EDID to Host */ 50 writel(readl(dp->ctrl_base + 0xB8) & ~(BIT(24) | BIT(28)), dp->ctrl_base + 0xB8); 51 52 /* DPMCU */ 53 /* clear display format and enable region */ 54 writel(0, 0x18000de0); 55 56 /* load DPMCU firmware to internal instruction memory */ 57 writel(0x10550010, 0x180100e0); 58 writel(0x10440010, 0x180100e0); 59 writel(0x10000010, 0x180100e0); 60 writel(0x10000011, 0x180100e0); 61 62 for (i = 0; i < ARRAY_SIZE(firmware_ast2600_dp); i++) 63 writel(firmware_ast2600_dp[i], 0x18020000 + (i * 4)); 64 65 /* release DPMCU internal reset */ 66 writel(0x10000010, 0x180100e0); 67 writel(0x10001110, 0x180100e0); 68 //disable dp interrupt 69 writel(0x00ff0000, 0x180100e8); 70 //set vga ASTDP with DPMCU FW handling scratch 71 writel(readl(0x1e6e2100) | (0x7 << 9), 0x1e6e2100); 72 73 return 0; 74 } 75 76 static int dp_aspeed_ofdata_to_platdata(struct udevice *dev) 77 { 78 struct aspeed_dp_priv *dp = dev_get_priv(dev); 79 80 /* Get the controller base address */ 81 dp->ctrl_base = (void *)devfdt_get_addr_index(dev, 0); 82 83 return 0; 84 } 85 86 static const struct udevice_id aspeed_dp_ids[] = { 87 { .compatible = "aspeed,ast2600-displayport" }, 88 { } 89 }; 90 91 U_BOOT_DRIVER(aspeed_dp) = { 92 .name = "aspeed_dp", 93 .id = UCLASS_MISC, 94 .of_match = aspeed_dp_ids, 95 .probe = aspeed_dp_probe, 96 .ofdata_to_platdata = dp_aspeed_ofdata_to_platdata, 97 .priv_auto_alloc_size = sizeof(struct aspeed_dp_priv), 98 }; 99