Commit 8ddfc01a authored by Thierry Reding's avatar Thierry Reding Committed by Hans de Goede

fbdev/simplefb: Support memory-region property

The simple-framebuffer bindings specify that the "memory-region"
property can be used as an alternative to the "reg" property to define
the framebuffer memory used by the display hardware. Implement support
for this in the simplefb driver.
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231101172017.3872242-2-thierry.reding@gmail.com
parent 3c6c7ca4
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_clk.h> #include <linux/of_clk.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/parser.h> #include <linux/parser.h>
...@@ -121,12 +122,13 @@ struct simplefb_params { ...@@ -121,12 +122,13 @@ struct simplefb_params {
u32 height; u32 height;
u32 stride; u32 stride;
struct simplefb_format *format; struct simplefb_format *format;
struct resource memory;
}; };
static int simplefb_parse_dt(struct platform_device *pdev, static int simplefb_parse_dt(struct platform_device *pdev,
struct simplefb_params *params) struct simplefb_params *params)
{ {
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node, *mem;
int ret; int ret;
const char *format; const char *format;
int i; int i;
...@@ -166,6 +168,23 @@ static int simplefb_parse_dt(struct platform_device *pdev, ...@@ -166,6 +168,23 @@ static int simplefb_parse_dt(struct platform_device *pdev,
return -EINVAL; return -EINVAL;
} }
mem = of_parse_phandle(np, "memory-region", 0);
if (mem) {
ret = of_address_to_resource(mem, 0, &params->memory);
if (ret < 0) {
dev_err(&pdev->dev, "failed to parse memory-region\n");
of_node_put(mem);
return ret;
}
if (of_property_present(np, "reg"))
dev_warn(&pdev->dev, "preferring \"memory-region\" over \"reg\" property\n");
of_node_put(mem);
} else {
memset(&params->memory, 0, sizeof(params->memory));
}
return 0; return 0;
} }
...@@ -193,6 +212,8 @@ static int simplefb_parse_pd(struct platform_device *pdev, ...@@ -193,6 +212,8 @@ static int simplefb_parse_pd(struct platform_device *pdev,
return -EINVAL; return -EINVAL;
} }
memset(&params->memory, 0, sizeof(params->memory));
return 0; return 0;
} }
...@@ -431,11 +452,15 @@ static int simplefb_probe(struct platform_device *pdev) ...@@ -431,11 +452,15 @@ static int simplefb_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
if (params.memory.start == 0 && params.memory.end == 0) {
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
dev_err(&pdev->dev, "No memory resource\n"); dev_err(&pdev->dev, "No memory resource\n");
return -EINVAL; return -EINVAL;
} }
} else {
res = &params.memory;
}
mem = request_mem_region(res->start, resource_size(res), "simplefb"); mem = request_mem_region(res->start, resource_size(res), "simplefb");
if (!mem) { if (!mem) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment