diff --git a/arch/arm64/boot/dts/phytium/e2000q-miniitx-board.dts b/arch/arm64/boot/dts/phytium/e2000q-miniitx-board.dts index 6829a30793d7ff01b93713c3bded0e24f9f8b163..d4ff241f611f384f867237b97f89d9c5652ece4f 100644 --- a/arch/arm64/boot/dts/phytium/e2000q-miniitx-board.dts +++ b/arch/arm64/boot/dts/phytium/e2000q-miniitx-board.dts @@ -14,7 +14,7 @@ /dts-v1/; /memreserve/ 0x80000000 0x10000; -/memreserve/ 0xf4000000 0x4000000; + #include "pe2204.dtsi" @@ -38,6 +38,19 @@ memory@00{ reg = <0x0 0x80000000 0x2 0x00000000>; }; + reserved-memory { + #address-cells = <2>; + #size-cells = <2>; + ranges; + + phytium_display_reserved: share@0xf4000000 { + compatible = "phytium-display-carveout-mem"; + device_type = "display"; + reg = <0x00 0xf4000000 0x0 0x4000000>; + status = "okay"; + }; + }; + sound_card: sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; @@ -219,8 +232,8 @@ &macb2 { }; &dc0 { - reg = <0x0 0x32000000 0x0 0x8000>, - <0x0 0xf4000000 0x0 0x4000000>; // (optional) + reg = <0x0 0x32000000 0x0 0x8000>; + dc-memory-region = <&phytium_display_reserved>; pipe_mask = [03]; edp_mask = [00]; status = "okay"; diff --git a/drivers/gpu/drm/phytium/phytium_platform.c b/drivers/gpu/drm/phytium/phytium_platform.c index 27815ecc9c500733d725a55a5b9f42bb62b1bbba..6efddfa4bfc0fe11382d0d43a5d41aa39cf7836e 100644 --- a/drivers/gpu/drm/phytium/phytium_platform.c +++ b/drivers/gpu/drm/phytium/phytium_platform.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -19,14 +20,38 @@ int phytium_platform_carveout_mem_init(struct platform_device *pdev, struct phytium_display_private *priv) { - struct resource *res; - int ret = 0; + struct device_node *np; + struct resource res, *mem_region; + int ret = 0; + + if (!pdev->dev.of_node) { + DRM_ERROR("This driver must be probed from devicetree!\n"); + return -EINVAL; + } + + np = of_parse_phandle(pdev->dev.of_node, "dc-memory-region", 0); + if(!np) { + DRM_ERROR("No %s specified\n", "dc-memory-region"); + return -EINVAL; + } + + ret = of_address_to_resource(np, 0, &res); + if(ret) { + DRM_ERROR("No memory address assigned to the region\n"); + return ret; + } + + mem_region = request_mem_region(res.start, resource_size(&res), "phytium-display"); + if (!mem_region) { + DRM_WARN("Failed to request reserved memory\n"); + priv->pool_size = resource_size(&res); + priv->pool_phys_addr = res.start; + } + else { + priv->pool_size = resource_size(mem_region); + priv->pool_phys_addr = mem_region->start; + } - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (res) { - priv->pool_size = resource_size(res); - priv->pool_phys_addr = res->start; - } if ((priv->pool_phys_addr != 0) && (priv->pool_size != 0)) { priv->pool_virt_addr = ioremap_cache(priv->pool_phys_addr, priv->pool_size); @@ -54,6 +79,9 @@ int phytium_platform_carveout_mem_init(struct platform_device *pdev, failed_init_memory_pool: iounmap(priv->pool_virt_addr); failed_ioremap: + if (mem_region) + release_mem_region(mem_region->start, resource_size(mem_region)); + return ret; }