Skip to content

Commit 29e56ae

Browse files
jamwandliviu
authored andcommitted
drm/komeda: Add DT parsing
Parse DT and initialize corresponding dev/pipeline attributes. Changes in v4: - Rebase. Changes in v3: - Fixed style problem found by checkpatch.pl --strict. Changes in v2: - Unified abbreviation of "pipeline" to "pipe". Signed-off-by: James Qian Wang (Arm Technology China) <[email protected]> Acked-by: Liviu Dudau <[email protected]> Signed-off-by: Liviu Dudau <[email protected]>
1 parent 26bd43a commit 29e56ae

File tree

4 files changed

+90
-0
lines changed

4 files changed

+90
-0
lines changed

drivers/gpu/drm/arm/display/komeda/komeda_dev.c

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,76 @@
99
#include <linux/of_graph.h>
1010
#include "komeda_dev.h"
1111

12+
static int komeda_parse_pipe_dt(struct komeda_dev *mdev, struct device_node *np)
13+
{
14+
struct komeda_pipeline *pipe;
15+
struct clk *clk;
16+
u32 pipe_id;
17+
int ret = 0;
18+
19+
ret = of_property_read_u32(np, "reg", &pipe_id);
20+
if (ret != 0 || pipe_id >= mdev->n_pipelines)
21+
return -EINVAL;
22+
23+
pipe = mdev->pipelines[pipe_id];
24+
25+
clk = of_clk_get_by_name(np, "aclk");
26+
if (IS_ERR(clk)) {
27+
DRM_ERROR("get aclk for pipeline %d failed!\n", pipe_id);
28+
return PTR_ERR(clk);
29+
}
30+
pipe->aclk = clk;
31+
32+
clk = of_clk_get_by_name(np, "pxclk");
33+
if (IS_ERR(clk)) {
34+
DRM_ERROR("get pxclk for pipeline %d failed!\n", pipe_id);
35+
return PTR_ERR(clk);
36+
}
37+
pipe->pxlclk = clk;
38+
39+
/* enum ports */
40+
pipe->of_output_dev =
41+
of_graph_get_remote_node(np, KOMEDA_OF_PORT_OUTPUT, 0);
42+
pipe->of_output_port =
43+
of_graph_get_port_by_id(np, KOMEDA_OF_PORT_OUTPUT);
44+
45+
pipe->of_node = np;
46+
47+
return 0;
48+
}
49+
50+
static int komeda_parse_dt(struct device *dev, struct komeda_dev *mdev)
51+
{
52+
struct platform_device *pdev = to_platform_device(dev);
53+
struct device_node *child, *np = dev->of_node;
54+
struct clk *clk;
55+
int ret;
56+
57+
clk = devm_clk_get(dev, "mclk");
58+
if (IS_ERR(clk))
59+
return PTR_ERR(clk);
60+
61+
mdev->mclk = clk;
62+
mdev->irq = platform_get_irq(pdev, 0);
63+
if (mdev->irq < 0) {
64+
DRM_ERROR("could not get IRQ number.\n");
65+
return mdev->irq;
66+
}
67+
68+
for_each_available_child_of_node(np, child) {
69+
if (of_node_cmp(child->name, "pipeline") == 0) {
70+
ret = komeda_parse_pipe_dt(mdev, child);
71+
if (ret) {
72+
DRM_ERROR("parse pipeline dt error!\n");
73+
of_node_put(child);
74+
break;
75+
}
76+
}
77+
}
78+
79+
return ret;
80+
}
81+
1282
struct komeda_dev *komeda_dev_create(struct device *dev)
1383
{
1484
struct platform_device *pdev = to_platform_device(dev);
@@ -71,6 +141,12 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
71141
goto err_cleanup;
72142
}
73143

144+
err = komeda_parse_dt(dev, mdev);
145+
if (err) {
146+
DRM_ERROR("parse device tree failed.\n");
147+
goto err_cleanup;
148+
}
149+
74150
return mdev;
75151

76152
err_cleanup:

drivers/gpu/drm/arm/display/komeda/komeda_dev.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ struct komeda_dev {
7272
/** @mck: HW main engine clk */
7373
struct clk *mclk;
7474

75+
/** @irq: irq number */
76+
u32 irq;
77+
7578
int n_pipelines;
7679
struct komeda_pipeline *pipelines[KOMEDA_MAX_PIPELINES];
7780

drivers/gpu/drm/arm/display/komeda/komeda_pipeline.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ void komeda_pipeline_destroy(struct komeda_dev *mdev,
5353
clk_put(pipe->pxlclk);
5454
clk_put(pipe->aclk);
5555

56+
of_node_put(pipe->of_output_dev);
57+
of_node_put(pipe->of_output_port);
58+
of_node_put(pipe->of_node);
59+
5660
devm_kfree(mdev->dev, pipe);
5761
}
5862

drivers/gpu/drm/arm/display/komeda/komeda_pipeline.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ struct komeda_pipeline {
288288
struct komeda_improc *improc;
289289
struct komeda_timing_ctrlr *ctrlr;
290290
struct komeda_pipeline_funcs *funcs; /* private pipeline functions */
291+
292+
/** @of_node: pipeline dt node */
293+
struct device_node *of_node;
294+
/** @of_output_port: pipeline output port */
295+
struct device_node *of_output_port;
296+
/** @of_output_dev: output connector device node */
297+
struct device_node *of_output_dev;
291298
};
292299

293300
/**

0 commit comments

Comments
 (0)