Skip to content

Commit 304e6be

Browse files
committed
gpu: ipu-v3: Assign of_node of child platform devices to corresponding ports
The crtc child device driver shouldn't have to modify the of_node of its platform device in the probe function. Instead, let the IPU core driver set the of_node when the platform device is created. Also reorder the client_reg array so the elements are in port id order (CSIs first, then DIs). Suggested-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent 99ae78c commit 304e6be

1 file changed

Lines changed: 38 additions & 18 deletions

File tree

drivers/gpu/ipu-v3/ipu-common.c

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/irqchip/chained_irq.h>
2929
#include <linux/irqdomain.h>
3030
#include <linux/of_device.h>
31+
#include <linux/of_graph.h>
3132

3233
#include <drm/drm_fourcc.h>
3334

@@ -995,8 +996,23 @@ struct ipu_platform_reg {
995996
const char *name;
996997
};
997998

999+
/* These must be in the order of the corresponding device tree port nodes */
9981000
static const struct ipu_platform_reg client_reg[] = {
9991001
{
1002+
.pdata = {
1003+
.csi = 0,
1004+
.dma[0] = IPUV3_CHANNEL_CSI0,
1005+
.dma[1] = -EINVAL,
1006+
},
1007+
.name = "imx-ipuv3-camera",
1008+
}, {
1009+
.pdata = {
1010+
.csi = 1,
1011+
.dma[0] = IPUV3_CHANNEL_CSI1,
1012+
.dma[1] = -EINVAL,
1013+
},
1014+
.name = "imx-ipuv3-camera",
1015+
}, {
10001016
.pdata = {
10011017
.di = 0,
10021018
.dc = 5,
@@ -1014,20 +1030,6 @@ static const struct ipu_platform_reg client_reg[] = {
10141030
.dma[1] = -EINVAL,
10151031
},
10161032
.name = "imx-ipuv3-crtc",
1017-
}, {
1018-
.pdata = {
1019-
.csi = 0,
1020-
.dma[0] = IPUV3_CHANNEL_CSI0,
1021-
.dma[1] = -EINVAL,
1022-
},
1023-
.name = "imx-ipuv3-camera",
1024-
}, {
1025-
.pdata = {
1026-
.csi = 1,
1027-
.dma[0] = IPUV3_CHANNEL_CSI1,
1028-
.dma[1] = -EINVAL,
1029-
},
1030-
.name = "imx-ipuv3-camera",
10311033
},
10321034
};
10331035

@@ -1049,11 +1051,29 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
10491051
const struct ipu_platform_reg *reg = &client_reg[i];
10501052
struct platform_device *pdev;
10511053

1052-
pdev = platform_device_register_data(dev, reg->name,
1053-
id++, &reg->pdata, sizeof(reg->pdata));
1054+
pdev = platform_device_alloc(reg->name, id++);
1055+
if (!pdev) {
1056+
ret = -ENOMEM;
1057+
goto err_register;
1058+
}
1059+
1060+
pdev->dev.parent = dev;
1061+
1062+
/* Associate subdevice with the corresponding port node */
1063+
pdev->dev.of_node = of_graph_get_port_by_id(dev->of_node, i);
1064+
if (!pdev->dev.of_node) {
1065+
dev_err(dev, "missing port@%d node in %s\n", i,
1066+
dev->of_node->full_name);
1067+
ret = -ENODEV;
1068+
goto err_register;
1069+
}
10541070

1055-
if (IS_ERR(pdev)) {
1056-
ret = PTR_ERR(pdev);
1071+
ret = platform_device_add_data(pdev, &reg->pdata,
1072+
sizeof(reg->pdata));
1073+
if (!ret)
1074+
ret = platform_device_add(pdev);
1075+
if (ret) {
1076+
platform_device_put(pdev);
10571077
goto err_register;
10581078
}
10591079
}

0 commit comments

Comments
 (0)