Skip to content

Instantly share code, notes, and snippets.

@valpackett
Created December 29, 2024 06:09
Show Gist options
  • Save valpackett/ce0d39a50fbb799e4f6ee8b878b7bb52 to your computer and use it in GitHub Desktop.
Save valpackett/ce0d39a50fbb799e4f6ee8b878b7bb52 to your computer and use it in GitHub Desktop.
simpledrm hack to parse ATAGS for dynamic fb address
diff --git i/drivers/gpu/drm/tiny/simpledrm.c w/drivers/gpu/drm/tiny/simpledrm.c
index 5d9ab8adf8005..78f0b4b8d3df6 100644
--- i/drivers/gpu/drm/tiny/simpledrm.c
+++ w/drivers/gpu/drm/tiny/simpledrm.c
@@ -3,6 +3,7 @@
#include <linux/aperture.h>
#include <linux/clk.h>
#include <linux/of_clk.h>
+#include <linux/of_fdt.h>
#include <linux/minmax.h>
#include <linux/of_address.h>
#include <linux/platform_data/simplefb.h>
@@ -773,6 +774,16 @@ static struct drm_display_mode simpledrm_mode(unsigned int width,
return mode;
}
+static int fb_early_init_dt_get_chosen(unsigned long node, const char *uname, int depth,
+ void *p_ret_node)
+{
+ if (depth != 1 || (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0))
+ return 0;
+
+ *(unsigned long *)p_ret_node = node;
+ return 1;
+}
+
static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
struct platform_device *pdev)
{
@@ -879,9 +890,29 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
* Memory management
*/
+ unsigned long node = 0;
+ of_scan_flat_dt(fb_early_init_dt_get_chosen, &node);
+ int size;
+ struct tag_videolfb {
+ u64 fb_base;
+ u32 islcmfound;
+ u32 fps;
+ u32 vram;
+ char lcmname[1];
+ } *videolfb_tag = (struct tag_videolfb *)of_get_flat_dt_prop(node, "atag,videolfb", &size);
+ if (videolfb_tag)
+ pr_err("got mediatek atag,videolfb 0x%08llx\n", videolfb_tag->fb_base);
+ else
+ pr_err("no mediatek atag,videolfb\n");
+
if (mem) {
void *screen_base;
+ if (videolfb_tag) {
+ mem->start = videolfb_tag->fb_base;
+ mem->end = videolfb_tag->fb_base + videolfb_tag->vram;
+ }
+
ret = devm_aperture_acquire_for_platform_device(pdev, mem->start,
resource_size(mem));
if (ret) {
@@ -903,6 +934,11 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv,
if (!res)
return ERR_PTR(-EINVAL);
+ if (videolfb_tag) {
+ res->start = videolfb_tag->fb_base;
+ res->end = videolfb_tag->fb_base + videolfb_tag->vram;
+ }
+
ret = devm_aperture_acquire_for_platform_device(pdev, res->start,
resource_size(res));
if (ret) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment