size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
alignment = <0x0 0x400000>;
no-kernel-map;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x4000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x4C00000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
alignment = <0x0 0x400000>;
no-kernel-map;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
ion_dev {
compatible = "amlogic, ion_dev";
- memory-region = <&ion_cma_reserved>;
+ memory-region = <&ion_cma_reserved
+ &ion_fb_reserved>;
};/* end of ion_dev*/
audiobus: audiobus@0xff642000 {
ion_dev {
compatible = "amlogic, ion_dev";
- memory-region = <&ion_cma_reserved>;
+ memory-region = <&ion_cma_reserved
+ &ion_fb_reserved>;
};/* end of ion_dev*/
audiobus: audiobus@0xff642000 {
/*
- * arch/arm64/boot/dts/amlogic/mesong12a.dtsi
+ * arch/arm64/boot/dts/amlogic/mesong12b.dtsi
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
ion_dev {
compatible = "amlogic, ion_dev";
- memory-region = <&ion_cma_reserved>;
+ memory-region = <&ion_cma_reserved
+ &ion_fb_reserved>;
};/* end of ion_dev*/
audiobus: audiobus@0xFF660000 {
size = <0x0 0x3000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
alignment = <0x0 0x400000>;
no-kernel-map;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x3000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
alignment = <0x0 0x400000>;
no-kernel-map;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
alignment = <0x0 0x400000>;
no-kernel-map;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x0000000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
size = <0x0 0x8000000>;
alignment = <0x0 0x400000>;
};
+ ion_fb_reserved:linux,ion-fb {
+ compatible = "amlogic, ion-fb-mem";
+ reusable;
+ /* 1920x1080x4x3 round up 4M align */
+ size = <0x0 0x1c00000>;
+ alignment = <0x0 0x400000>;
+ };
//di_reserved:linux,di {
//compatible = "amlogic, di-mem";
/* buffer_size = 3621952(yuv422 8bit) */
&dummy_venc {
status = "okay";
-};
\ No newline at end of file
+};
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Amlogic SH");
-static unsigned int debug = 2;
-module_param(debug, uint, 0644);
-MODULE_PARM_DESC(debug, "activates debug info");
-
-#define dprintk(level, fmt, arg...) \
- do { \
- if (debug > level) \
- pr_debug("ion-dev: " fmt, ## arg); \
- } while (0)
+#define ION_INFO(fmt, args...) pr_info("ion-dev: " fmt "", ## args)
+#define ION_DEBUG(fmt, args...) pr_debug("ion-dev: debug: " fmt "", ## args)
+#define ION_ERR(fmt, args...) pr_err("ion-dev: error: " fmt "", ## args)
/*
* TODO instead with enum ion_heap_type from ion.h
*
*/
if (idev == NULL) {
- dprintk(0, "create error");
+ ION_DEBUG("create error");
return ERR_PTR(-EPROBE_DEFER);
}
if (IS_ERR(idev)) {
- dprintk(0, "idev error");
+ ION_DEBUG("idev error");
return (struct ion_client *)idev;
}
}
ret = ion_phys(client, handle, addr, (size_t *)len);
- pr_debug("ion_phys ret=%d, phys=0x%lx\n", ret, *addr);
+ ION_DEBUG("ion_phys ret=%d, phys=0x%lx\n", ret, *addr);
ion_free(client, handle);
if (ret < 0) {
- pr_err("ion_get_phys error, ret=%d\n", ret);
+ ION_ERR("ion_get_phys error, ret=%d\n", ret);
return ret;
}
}
handle = ion_import_dma_buf_fd(client, data.handle);
if (IS_ERR_OR_NULL(handle)) {
- dprintk(0, "EINVAL, client=%p, share_fd=%d\n",
+ ION_DEBUG("EINVAL, client=%p, share_fd=%d\n",
client, data.handle);
return PTR_ERR(handle);
}
ret = ion_phys(client, handle, &addr, (size_t *)&len);
- dprintk(1, "ret=%d, phys=0x%lX\n", ret, addr);
+ ION_DEBUG("ret=%d, phys=0x%lX\n", ret, addr);
ion_free(client, handle);
if (ret < 0) {
- dprintk(0, "meson_ion_get_phys error, ret=%d\n", ret);
+ ION_DEBUG("meson_ion_get_phys error, ret=%d\n", ret);
return ret;
}
{
int err = 0;
int i;
+#ifdef CONFIG_AMLOGIC_TEE
+ unsigned int handle;
+#endif
my_ion_heap[num_heaps].type = ION_HEAP_TYPE_SYSTEM;
my_ion_heap[num_heaps].id = ION_HEAP_TYPE_SYSTEM;
/* init reserved memory */
err = of_reserved_mem_device_init(&pdev->dev);
if (err != 0)
- dprintk(1, "failed get reserved memory\n");
+ ION_INFO("failed get reserved memory\n");
+ err = of_reserved_mem_device_init_by_idx(&pdev->dev,
+ pdev->dev.of_node, 1);
+ if (err != 0)
+ ION_INFO("failed get fb memory\n");
+ err = of_reserved_mem_device_init_by_idx(&pdev->dev,
+ pdev->dev.of_node, 2);
+ if (err != 0)
+ ION_INFO("failed get secure memory\n");
heaps = kcalloc(num_heaps, sizeof(struct ion_heap *), GFP_KERNEL);
if (!heaps)
return -ENOMEM;
err = PTR_ERR(heaps[i]);
goto failed;
}
+#ifdef CONFIG_AMLOGIC_TEE
+ if (my_ion_heap[i].type == ION_HEAP_TYPE_CUSTOM &&
+ my_ion_heap[i].id == ION_HEAP_ID_SECURE &&
+ my_ion_heap[i].base &&
+ my_ion_heap[i].size) {
+ tee_protect_mem_by_type(TEE_MEM_TYPE_GPU,
+ (u32)my_ion_heap[i].base,
+ (u32)my_ion_heap[i].size,
+ &handle);
+ ION_INFO("tee protect gpu mem done\n");
+ }
+#endif
ion_device_add_heap(idev, heaps[i]);
- dprintk(2, "add heap type:%d id:%d\n",
+ ION_INFO("add heap type:%d id:%d\n",
my_ion_heap[i].type, my_ion_heap[i].id);
}
- dprintk(1, "%s, create %d heaps\n", __func__, num_heaps);
+ ION_INFO("%s, create %d heaps\n", __func__, num_heaps);
return 0;
failed:
- dprintk(0, "ion heap create failed\n");
+ ION_ERR("ion heap create failed\n");
kfree(heaps);
heaps = NULL;
panic(0);
*/
static int ion_dev_mem_init(struct reserved_mem *rmem, struct device *dev)
{
-
my_ion_heap[num_heaps].type = ION_HEAP_TYPE_CARVEOUT;
my_ion_heap[num_heaps].id = ION_HEAP_TYPE_CARVEOUT;
my_ion_heap[num_heaps].name = "carveout_ion";
my_ion_heap[num_heaps].base = (ion_phys_addr_t) rmem->base;
my_ion_heap[num_heaps].size = rmem->size;
-
- pr_info("ion_dev_mem_init size=%pa\n", &rmem->size);
+ ION_INFO("ion_dev_mem_init size=%pa\n", &rmem->size);
num_heaps++;
return 0;
-
-
}
static const struct reserved_mem_ops rmem_ion_dev_ops = {
#else
rmem->ops = &rmem_ion_dev_ops;
#endif
- pr_debug("ion_dev mem setup\n");
+ ION_DEBUG("ion_dev mem setup\n");
+
+ return 0;
+}
+
+static int ion_secure_mem_init(struct reserved_mem *rmem, struct device *dev)
+{
+ my_ion_heap[num_heaps].type = ION_HEAP_TYPE_CUSTOM;
+ my_ion_heap[num_heaps].id = ION_HEAP_ID_SECURE;
+ my_ion_heap[num_heaps].name = "secure_ion";
+ my_ion_heap[num_heaps].base = (ion_phys_addr_t)rmem->base;
+ my_ion_heap[num_heaps].size = rmem->size;
+ ION_INFO("ion secure_mem_init size=0x%pa, paddr=0x%pa\n",
+ &rmem->size, &rmem->base);
+ num_heaps++;
+ return 0;
+}
+
+static const struct reserved_mem_ops rmem_ion_secure_ops = {
+ .device_init = ion_secure_mem_init,
+};
+static int __init ion_secure_mem_setup(struct reserved_mem *rmem)
+{
+ rmem->ops = &rmem_ion_secure_ops;
+ ION_DEBUG("ion secure mem setup\n");
return 0;
}
+static int ion_fb_mem_init(struct reserved_mem *rmem, struct device *dev)
+{
+ my_ion_heap[num_heaps].type = ION_HEAP_TYPE_CUSTOM;
+ my_ion_heap[num_heaps].id = ION_HEAP_ID_FB;
+ my_ion_heap[num_heaps].name = "fb_ion";
+ my_ion_heap[num_heaps].base = (ion_phys_addr_t)rmem->base;
+ my_ion_heap[num_heaps].size = rmem->size;
+ ION_INFO("ion fb_mem_init size=0x%pa, paddr=0x%pa\n",
+ &rmem->size, &rmem->base);
+ num_heaps++;
+ return 0;
+}
+
+static const struct reserved_mem_ops rmem_ion_fb_ops = {
+ .device_init = ion_fb_mem_init,
+};
+
+static int __init ion_fb_mem_setup(struct reserved_mem *rmem)
+{
+ rmem->ops = &rmem_ion_fb_ops;
+ ION_DEBUG("ion fb mem setup\n");
+ return 0;
+}
+
+RESERVEDMEM_OF_DECLARE(ion_fb_mem, "amlogic, ion-fb-mem",
+ ion_fb_mem_setup);
+
+RESERVEDMEM_OF_DECLARE(ion_secure_mem, "amlogic, ion-secure-mem",
+ ion_secure_mem_setup);
+
RESERVEDMEM_OF_DECLARE(ion_dev_mem, "amlogic, idev-mem", ion_dev_mem_setup);
/*
* reserved memory initialize end
#include <linux/types.h>
#include <ion/ion.h>
+#include <linux/amlogic/tee.h>
/**
* CUSTOM IOCTL - CMD
int ion_phys(struct ion_client *client, struct ion_handle *handle,
ion_phys_addr_t *addr, size_t *len);
-
#endif
obj-$(CONFIG_ION) += ion.o ion-ioctl.o ion_heap.o \
ion_page_pool.o ion_system_heap.o \
- ion_carveout_heap.o ion_chunk_heap.o ion_cma_heap.o ion_codec_mm_heap.o
+ ion_carveout_heap.o ion_chunk_heap.o ion_cma_heap.o ion_codec_mm_heap.o ion_secure_heap.o ion_fb_heap.o
obj-$(CONFIG_ION_TEST) += ion_test.o
ifdef CONFIG_COMPAT
obj-$(CONFIG_ION) += compat_ion.o
--- /dev/null
+/*
+ * drivers/staging/android/ion/ion_fb_heap.c
+ *
+ * Copyright (C) 2021 amlogic, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <linux/spinlock.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/genalloc.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include "ion.h"
+#include "ion_priv.h"
+
+#define ION_FB_ALLOCATE_FAIL -1
+#define ION_FLAG_EXTEND_MESON_HEAP BIT(30)
+
+struct ion_fb_heap {
+ struct ion_heap heap;
+ struct gen_pool *pool;
+ ion_phys_addr_t base;
+};
+
+static ion_phys_addr_t ion_fb_allocate(struct ion_heap *heap,
+ unsigned long size,
+ unsigned long align)
+{
+ struct ion_fb_heap *fb_heap =
+ container_of(heap, struct ion_fb_heap, heap);
+ unsigned long offset = gen_pool_alloc(fb_heap->pool, size);
+
+ if (!offset)
+ return ION_FB_ALLOCATE_FAIL;
+
+ return offset;
+}
+
+static void ion_fb_free(struct ion_heap *heap, ion_phys_addr_t addr,
+ unsigned long size)
+{
+ struct ion_fb_heap *fb_heap =
+ container_of(heap, struct ion_fb_heap, heap);
+
+ if (addr == ION_FB_ALLOCATE_FAIL)
+ return;
+ gen_pool_free(fb_heap->pool, addr, size);
+}
+
+static int ion_fb_heap_allocate(struct ion_heap *heap,
+ struct ion_buffer *buffer,
+ unsigned long size, unsigned long align,
+ unsigned long flags)
+{
+ struct sg_table *table;
+ ion_phys_addr_t paddr;
+ int ret;
+
+ if (align > PAGE_SIZE)
+ return -EINVAL;
+
+ if (!(flags & ION_FLAG_EXTEND_MESON_HEAP))
+ return -ENOMEM;
+
+ table = kmalloc(sizeof(*table), GFP_KERNEL);
+ if (!table)
+ return -ENOMEM;
+ ret = sg_alloc_table(table, 1, GFP_KERNEL);
+ if (ret)
+ goto err_free;
+
+ paddr = ion_fb_allocate(heap, size, align);
+ if (paddr == ION_FB_ALLOCATE_FAIL) {
+ ret = -ENOMEM;
+ goto err_free_table;
+ }
+
+ sg_set_page(table->sgl, pfn_to_page(PFN_DOWN(paddr)), size, 0);
+ buffer->sg_table = table;
+
+ return 0;
+
+err_free_table:
+ sg_free_table(table);
+err_free:
+ kfree(table);
+ return ret;
+}
+
+static void ion_fb_heap_free(struct ion_buffer *buffer)
+{
+ struct ion_heap *heap = buffer->heap;
+ struct sg_table *table = buffer->sg_table;
+ struct page *page = sg_page(table->sgl);
+ ion_phys_addr_t paddr = PFN_PHYS(page_to_pfn(page));
+
+ ion_fb_free(heap, paddr, buffer->size);
+ sg_free_table(table);
+ kfree(table);
+}
+
+static struct ion_heap_ops fb_heap_ops = {
+ .allocate = ion_fb_heap_allocate,
+ .free = ion_fb_heap_free,
+ .map_user = ion_heap_map_user,
+ .map_kernel = ion_heap_map_kernel,
+ .unmap_kernel = ion_heap_unmap_kernel,
+};
+
+struct ion_heap *ion_fb_heap_create(struct ion_platform_heap *heap_data)
+{
+ struct ion_fb_heap *fb_heap;
+ int ret;
+ struct page *page;
+ size_t size;
+
+ page = pfn_to_page(PFN_DOWN(heap_data->base));
+ size = heap_data->size;
+
+ ion_pages_sync_for_device(NULL, page, size, DMA_BIDIRECTIONAL);
+
+ ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL));
+ if (ret)
+ return ERR_PTR(ret);
+ fb_heap = kzalloc(sizeof(*fb_heap), GFP_KERNEL);
+ if (!fb_heap)
+ return ERR_PTR(-ENOMEM);
+
+ fb_heap->pool = gen_pool_create(PAGE_SHIFT, -1);
+ if (!fb_heap->pool) {
+ kfree(fb_heap);
+ return ERR_PTR(-ENOMEM);
+ }
+ fb_heap->base = heap_data->base;
+ gen_pool_add(fb_heap->pool, fb_heap->base, heap_data->size, -1);
+ fb_heap->heap.ops = &fb_heap_ops;
+ fb_heap->heap.type = ION_HEAP_TYPE_CUSTOM;
+ fb_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
+
+ return &fb_heap->heap;
+}
+
+void ion_fb_heap_destroy(struct ion_heap *heap)
+{
+ struct ion_fb_heap *fb_heap =
+ container_of(heap, struct ion_fb_heap, heap);
+
+ gen_pool_destroy(fb_heap->pool);
+ kfree(fb_heap);
+ fb_heap = NULL;
+}
heap = ion_cma_heap_create(heap_data);
break;
case ION_HEAP_TYPE_CUSTOM:
- heap = ion_codec_mm_heap_create(heap_data);
+ if (heap_data->id == ION_HEAP_ID_FB)
+ heap = ion_fb_heap_create(heap_data);
+ else if (heap_data->id == ION_HEAP_ID_SECURE)
+ heap = ion_secure_heap_create(heap_data);
+ else
+ heap = ion_codec_mm_heap_create(heap_data);
break;
default:
pr_err("%s: Invalid heap type %d\n", __func__,
ion_cma_heap_destroy(heap);
break;
case ION_HEAP_TYPE_CUSTOM:
- ion_codec_mm_heap_destroy(heap);
+ if (heap->id == ION_HEAP_ID_FB)
+ ion_fb_heap_destroy(heap);
+ else if (heap->id == ION_HEAP_ID_SECURE)
+ ion_secure_heap_destroy(heap);
+ else
+ ion_codec_mm_heap_destroy(heap);
break;
default:
pr_err("%s: Invalid heap type %d\n", __func__,
struct ion_heap *ion_codec_mm_heap_create(struct ion_platform_heap *heap_data);
void ion_codec_mm_heap_destroy(struct ion_heap *heap);
+#define ION_HEAP_ID_SECURE (ION_HEAP_TYPE_CUSTOM + 2)
+struct ion_heap *ion_secure_heap_create(struct ion_platform_heap *heap_data);
+void ion_secure_heap_destroy(struct ion_heap *heap);
+
+#define ION_HEAP_ID_FB (ION_HEAP_TYPE_CUSTOM + 1)
+struct ion_heap *ion_fb_heap_create(struct ion_platform_heap *heap_data);
+void ion_fb_heap_destroy(struct ion_heap *heap);
+
/**
* functions for creating and destroying a heap pool -- allows you
* to keep a pool of pre allocated memory to use from your heap. Keeping
--- /dev/null
+/*
+ * drivers/staging/android/ion/ion_secure_heap.c
+ *
+ * Copyright (C) 2019 amlogic, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <linux/spinlock.h>
+#include <linux/dma-mapping.h>
+#include <linux/err.h>
+#include <linux/genalloc.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/scatterlist.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include "ion.h"
+#include "ion_priv.h"
+
+#define ION_SECURE_ALLOCATE_FAIL -1
+
+struct ion_secure_heap {
+ struct ion_heap heap;
+ struct gen_pool *pool;
+ ion_phys_addr_t base;
+};
+
+static ion_phys_addr_t ion_secure_allocate(struct ion_heap *heap,
+ unsigned long size,
+ unsigned long align)
+{
+ struct ion_secure_heap *secure_heap =
+ container_of(heap, struct ion_secure_heap, heap);
+ unsigned long offset = gen_pool_alloc(secure_heap->pool, size);
+
+ if (!offset)
+ return ION_SECURE_ALLOCATE_FAIL;
+
+ return offset;
+}
+
+static void ion_secure_free(struct ion_heap *heap, ion_phys_addr_t addr,
+ unsigned long size)
+{
+ struct ion_secure_heap *secure_heap =
+ container_of(heap, struct ion_secure_heap, heap);
+
+ if (addr == ION_SECURE_ALLOCATE_FAIL)
+ return;
+ gen_pool_free(secure_heap->pool, addr, size);
+}
+
+static int ion_secure_heap_allocate(struct ion_heap *heap,
+ struct ion_buffer *buffer,
+ unsigned long size, unsigned long align,
+ unsigned long flags)
+{
+ struct sg_table *table;
+ ion_phys_addr_t paddr;
+ int ret;
+
+ if (align > PAGE_SIZE)
+ return -EINVAL;
+
+ table = kmalloc(sizeof(*table), GFP_KERNEL);
+ if (!table)
+ return -ENOMEM;
+ ret = sg_alloc_table(table, 1, GFP_KERNEL);
+ if (ret)
+ goto err_free;
+
+ paddr = ion_secure_allocate(heap, size, align);
+ if (paddr == ION_SECURE_ALLOCATE_FAIL) {
+ ret = -ENOMEM;
+ goto err_free_table;
+ }
+
+ sg_set_page(table->sgl, pfn_to_page(PFN_DOWN(paddr)), size, 0);
+ buffer->sg_table = table;
+
+ return 0;
+
+err_free_table:
+ sg_free_table(table);
+err_free:
+ kfree(table);
+ return ret;
+}
+
+static void ion_secure_heap_free(struct ion_buffer *buffer)
+{
+ struct ion_heap *heap = buffer->heap;
+ struct sg_table *table = buffer->sg_table;
+ struct page *page = sg_page(table->sgl);
+ ion_phys_addr_t paddr = PFN_PHYS(page_to_pfn(page));
+
+ ion_secure_free(heap, paddr, buffer->size);
+ sg_free_table(table);
+ kfree(table);
+}
+
+static struct ion_heap_ops secure_heap_ops = {
+ .allocate = ion_secure_heap_allocate,
+ .free = ion_secure_heap_free,
+ .map_user = ion_heap_map_user,
+ .map_kernel = ion_heap_map_kernel,
+ .unmap_kernel = ion_heap_unmap_kernel,
+};
+
+struct ion_heap *ion_secure_heap_create(struct ion_platform_heap *heap_data)
+{
+ struct ion_secure_heap *secure_heap;
+ int ret;
+ struct page *page;
+ size_t size;
+
+ page = pfn_to_page(PFN_DOWN(heap_data->base));
+ size = heap_data->size;
+
+ ion_pages_sync_for_device(NULL, page, size, DMA_BIDIRECTIONAL);
+
+ ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL));
+ if (ret)
+ return ERR_PTR(ret);
+ secure_heap = kzalloc(sizeof(*secure_heap), GFP_KERNEL);
+ if (!secure_heap)
+ return ERR_PTR(-ENOMEM);
+
+ secure_heap->pool = gen_pool_create(PAGE_SHIFT, -1);
+ if (!secure_heap->pool) {
+ kfree(secure_heap);
+ return ERR_PTR(-ENOMEM);
+ }
+ secure_heap->base = heap_data->base;
+ gen_pool_add(secure_heap->pool, secure_heap->base, heap_data->size, -1);
+ secure_heap->heap.ops = &secure_heap_ops;
+ secure_heap->heap.type = ION_HEAP_TYPE_CUSTOM;
+ secure_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
+
+ return &secure_heap->heap;
+}
+
+void ion_secure_heap_destroy(struct ion_heap *heap)
+{
+ struct ion_secure_heap *secure_heap =
+ container_of(heap, struct ion_secure_heap, heap);
+
+ gen_pool_destroy(secure_heap->pool);
+ kfree(secure_heap);
+ secure_heap = NULL;
+}