Skip to content

Commit

Permalink
imx-drm: convert to componentised device support
Browse files Browse the repository at this point in the history
Use the componentised device support for imx-drm.  This requires all
the sub-components and the master device to register with the component
device support.

Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Russell King committed Feb 24, 2014
1 parent f2d66aa commit 17b5001
Show file tree
Hide file tree
Showing 12 changed files with 275 additions and 92 deletions.
10 changes: 8 additions & 2 deletions arch/arm/boot/dts/imx51-babbage.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
reg = <0x90000000 0x20000000>;
};

display@di0 {
display0: display@di0 {
compatible = "fsl,imx-parallel-display";
crtcs = <&ipu 0>;
interface-pix-fmt = "rgb24";
Expand All @@ -43,7 +43,7 @@
};
};

display@di1 {
display1: display@di1 {
compatible = "fsl,imx-parallel-display";
crtcs = <&ipu 1>;
interface-pix-fmt = "rgb565";
Expand Down Expand Up @@ -81,6 +81,12 @@
};
};

imx-drm {
compatible = "fsl,imx-drm";
crtcs = <&ipu 0>, <&ipu 1>;
connectors = <&display0>, <&display1>;
};

sound {
compatible = "fsl,imx51-babbage-sgtl5000",
"fsl,imx-audio-sgtl5000";
Expand Down
8 changes: 7 additions & 1 deletion arch/arm/boot/dts/imx53-m53evk.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
};

soc {
display@di1 {
display1: display@di1 {
compatible = "fsl,imx-parallel-display";
crtcs = <&ipu 1>;
interface-pix-fmt = "bgr666";
Expand Down Expand Up @@ -53,6 +53,12 @@
default-brightness-level = <6>;
};

imx-drm {
compatible = "fsl,imx-drm";
crtcs = <&ipu 1>;
connectors = <&display1>;
};

leds {
compatible = "gpio-leds";
pinctrl-names = "default";
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/boot/dts/imx53-mba53.dts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
status = "disabled";
};

imx-drm {
compatible = "fsl,imx-drm";
crtcs = <&ipu 1>;
connectors = <&disp1>, <&tve>;
};

reg_3p2v: 3p2v {
compatible = "regulator-fixed";
regulator-name = "3P2V";
Expand Down
8 changes: 7 additions & 1 deletion arch/arm/boot/dts/imx53-qsb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
reg = <0x70000000 0x40000000>;
};

display@di0 {
display0: display@di0 {
compatible = "fsl,imx-parallel-display";
crtcs = <&ipu 0>;
interface-pix-fmt = "rgb565";
Expand Down Expand Up @@ -72,6 +72,12 @@
};
};

imx-drm {
compatible = "fsl,imx-drm";
crtcs = <&ipu 0>;
connectors = <&display0>;
};

leds {
compatible = "gpio-leds";
pinctrl-names = "default";
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/boot/dts/imx6q-sabresd.dts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
compatible = "fsl,imx6q-sabresd", "fsl,imx6q";
};

&imx_drm {
crtcs = <&ipu1 0>, <&ipu1 1>, <&ipu2 0>, <&ipu2 1>;
};

&sata {
status = "okay";
};
6 changes: 6 additions & 0 deletions arch/arm/boot/dts/imx6qdl-sabresd.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
};
};

imx_drm: imx-drm {
compatible = "fsl,imx-drm";
crtcs = <&ipu1 0>, <&ipu1 1>;
connectors = <&ldb>;
};

sound {
compatible = "fsl,imx6q-sabresd-wm8962",
"fsl,imx-audio-wm8962";
Expand Down
105 changes: 85 additions & 20 deletions drivers/staging/imx-drm/imx-drm-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* GNU General Public License for more details.
*
*/

#include <linux/component.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <drm/drmP.h>
Expand Down Expand Up @@ -90,6 +90,8 @@ static int imx_drm_driver_unload(struct drm_device *drm)
{
struct imx_drm_device *imxdrm = drm->dev_private;

component_unbind_all(drm->dev, drm);

imx_drm_device_put();

drm_vblank_cleanup(drm);
Expand Down Expand Up @@ -371,11 +373,8 @@ static void imx_drm_connector_unregister(
}

/*
* Called by the CRTC driver when all CRTCs are registered. This
* puts all the pieces together and initializes the driver.
* Once this is called no more CRTCs can be registered since
* the drm core has hardcoded the number of crtcs in several
* places.
* Main DRM initialisation. This binds, initialises and registers
* with DRM the subcomponents of the driver.
*/
static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
{
Expand Down Expand Up @@ -428,8 +427,15 @@ static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)

platform_set_drvdata(drm->platformdev, drm);
mutex_unlock(&imxdrm->mutex);

/* Now try and bind all our sub-components */
ret = component_bind_all(drm->dev, drm);
if (ret)
goto err_relock;
return 0;

err_relock:
mutex_lock(&imxdrm->mutex);
err_vblank:
drm_vblank_cleanup(drm);
err_kms:
Expand Down Expand Up @@ -809,6 +815,70 @@ static struct drm_driver imx_drm_driver = {
.patchlevel = 0,
};

static int compare_parent_of(struct device *dev, void *data)
{
struct of_phandle_args *args = data;
return dev->parent && dev->parent->of_node == args->np;
}

static int compare_of(struct device *dev, void *data)
{
return dev->of_node == data;
}

static int imx_drm_add_components(struct device *master, struct master *m)
{
struct device_node *np = master->of_node;
unsigned i;
int ret;

for (i = 0; ; i++) {
struct of_phandle_args args;

ret = of_parse_phandle_with_fixed_args(np, "crtcs", 1,
i, &args);
if (ret)
break;

ret = component_master_add_child(m, compare_parent_of, &args);
of_node_put(args.np);

if (ret)
return ret;
}

for (i = 0; ; i++) {
struct device_node *node;

node = of_parse_phandle(np, "connectors", i);
if (!node)
break;

ret = component_master_add_child(m, compare_of, node);
of_node_put(node);

if (ret)
return ret;
}
return 0;
}

static int imx_drm_bind(struct device *dev)
{
return drm_platform_init(&imx_drm_driver, to_platform_device(dev));
}

static void imx_drm_unbind(struct device *dev)
{
drm_put_dev(dev_get_drvdata(dev));
}

static const struct component_master_ops imx_drm_ops = {
.add_components = imx_drm_add_components,
.bind = imx_drm_bind,
.unbind = imx_drm_unbind,
};

static int imx_drm_platform_probe(struct platform_device *pdev)
{
int ret;
Expand All @@ -819,27 +889,31 @@ static int imx_drm_platform_probe(struct platform_device *pdev)

imx_drm_device->dev = &pdev->dev;

return drm_platform_init(&imx_drm_driver, pdev);
return component_master_add(&pdev->dev, &imx_drm_ops);
}

static int imx_drm_platform_remove(struct platform_device *pdev)
{
drm_put_dev(platform_get_drvdata(pdev));

component_master_del(&pdev->dev, &imx_drm_ops);
return 0;
}

static const struct of_device_id imx_drm_dt_ids[] = {
{ .compatible = "fsl,imx-drm", },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, imx_drm_dt_ids);

static struct platform_driver imx_drm_pdrv = {
.probe = imx_drm_platform_probe,
.remove = imx_drm_platform_remove,
.driver = {
.owner = THIS_MODULE,
.name = "imx-drm",
.of_match_table = imx_drm_dt_ids,
},
};

static struct platform_device *imx_drm_pdev;

static int __init imx_drm_init(void)
{
int ret;
Expand All @@ -852,29 +926,20 @@ static int __init imx_drm_init(void)
INIT_LIST_HEAD(&imx_drm_device->connector_list);
INIT_LIST_HEAD(&imx_drm_device->encoder_list);

imx_drm_pdev = platform_device_register_simple("imx-drm", -1, NULL, 0);
if (IS_ERR(imx_drm_pdev)) {
ret = PTR_ERR(imx_drm_pdev);
goto err_pdev;
}

ret = platform_driver_register(&imx_drm_pdrv);
if (ret)
goto err_pdrv;

return 0;

err_pdrv:
platform_device_unregister(imx_drm_pdev);
err_pdev:
kfree(imx_drm_device);

return ret;
}

static void __exit imx_drm_exit(void)
{
platform_device_unregister(imx_drm_pdev);
platform_driver_unregister(&imx_drm_pdrv);

kfree(imx_drm_device);
Expand Down
Loading

0 comments on commit 17b5001

Please sign in to comment.