video: drm: Add Device tree support to DRM-FIMD
Subsystems (3)
cover video: drm: Add Device tree support to DRM-FIMD
This patch set adds device tree support for DRM-FIMD for Samsung's Exynos5250. It includes parsing platform data from dts file.
This patchset is based and tested on top of v3.5-rc4.
Leela Krishna Amudala (1):
video: drm: exynos: Add device tree support
Prathyush K (1):
drm/exynos: Modifying exynos drm fimd to support exynos5
drivers/gpu/drm/exynos/exynos_drm_fimd.c | 104 +++++++++++++++++++++++++++++- include/drm/exynos_drm.h | 6 ++ 2 files changed, 107 insertions(+), 3 deletions(-)
PATCH 1/2 video: drm: exynos: Add device tree support
Add device tree based discovery support for DRM-FIMD driver.
drivers/gpu/drm/exynos/exynos_drm_fimd.c +89 -2
@@ -18,6 +18,7 @@#include <linux/platform_device.h> #include <linux/clk.h> #include <linux/pm_runtime.h> +#include <linux/of.h> #include <drm/exynos_drm.h> #include <plat/regs-fb-v4.h>
@@ -788,12 +789,84 @@ static int fimd_power_on(struct fimd_context *ctx, bool enable)return 0 ; } +#ifdef CONFIG_OF +static struct exynos_drm_fimd_pdata *drm_fimd_dt_parse_pdata (struct device *dev) +{ +struct device_node *np = dev->of_node; +struct device_node *disp_np; +struct exynos_drm_fimd_pdata *pd; +u32 data[4 ]; + + pd =kzalloc (sizeof (*pd),GFP_KERNEL ); +if (!pd) { +dev_err (dev,"memory allocation for pdata failed\n" ); +return ERR_PTR (-ENOMEM ); + } + +if (of_get_property (np,"samsung,fimd-vidout-rgb" ,NULL )) + pd->vidcon0 |=VIDCON0_VIDOUT_RGB |VIDCON0_PNRMODE_RGB ; +if (of_get_property (np,"samsung,fimd-vidout-tv" ,NULL )) + pd->vidcon0 |=VIDCON0_VIDOUT_TV ; +if (of_get_property (np,"samsung,fimd-inv-hsync" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_HSYNC ; +if (of_get_property (np,"samsung,fimd-inv-vsync" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_VSYNC ; +if (of_get_property (np,"samsung,fimd-inv-vclk" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_VCLK ; +if (of_get_property (np,"samsung,fimd-inv-vden" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_VDEN ; + + disp_np =of_parse_phandle (np,"samsung,fimd-display" ,0 ); +if (!disp_np) { +dev_err (dev,"unable to find display panel info\n" ); +return ERR_PTR (-EINVAL ); + } + +if (of_property_read_u32_array (disp_np,"lcd-htiming" , data,4 )) { +dev_err (dev,"invalid horizontal timing\n" ); +return ERR_PTR (-EINVAL ); + } + pd->panel.timing.left_margin = data[0 ]; + pd->panel.timing.right_margin = data[1 ]; + pd->panel.timing.hsync_len = data[2 ]; + pd->panel.timing.xres = data[3 ]; + +if (of_property_read_u32_array (disp_np,"lcd-vtiming" , data,4 )) { +dev_err (dev,"invalid vertical timing\n" ); +return ERR_PTR (-EINVAL ); + } + pd->panel.timing.upper_margin = data[0 ]; + pd->panel.timing.lower_margin = data[1 ]; + pd->panel.timing.vsync_len = data[2 ]; + pd->panel.timing.yres = data[3 ]; + +of_property_read_u32 (disp_np,"lcd-panel-type" , &pd->panel_type); + +of_property_read_u32 (np,"samsung,fimd-frame-rate" , + &pd->panel.timing.refresh); + +of_property_read_u32 (np,"samsung, defalut-window" , &pd->default_win); + +of_property_read_u32 (np,"samsung,fimd-win-bpp" , &pd->bpp); + +return pd; +} +#else +static int drm_fimd_dt_parse_pdata (struct device *dev, +struct exynos_drm_fimd_pdata **pdata) +{ +return 0 ; +} +#endif /* CONFIG_OF */ + +static const struct of_device_id drm_fimd_dt_match[]; +static int __devinit fimd_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct fimd_context *ctx;struct exynos_drm_subdrv *subdrv; -struct exynos_drm_fimd_pdata *pdata; +struct exynos_drm_fimd_pdata *pdata = pdev->dev.platform_data;struct exynos_drm_panel_info *panel;struct resource *res;int win;
@@ -801,7 +874,11 @@ static int __devinit fimd_probe(struct platform_device *pdev)DRM_DEBUG_KMS ("%s\n" , __FILE__); - pdata = pdev->dev.platform_data; +if (pdev->dev.of_node) { + pdata =drm_fimd_dt_parse_pdata (&pdev->dev); +if (IS_ERR (pdata)) +return PTR_ERR (pdata); + }if (!pdata) {dev_err (dev,"no platform data specified\n" );return -EINVAL ;
@@ -1006,6 +1083,15 @@ static int fimd_runtime_resume(struct device *dev) }#endif +#ifdef CONFIG_OF +static const struct of_device_id drm_fimd_dt_match[] = { + { .compatible ="samsung,exynos5-fb" , + .data = (void *)NULL }, + {}, +}; +MODULE_DEVICE_TABLE (of, drm_fimd_dt_match); +#endif +static const struct dev_pm_ops fimd_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume)SET_RUNTIME_PM_OPS (fimd_runtime_suspend, fimd_runtime_resume,NULL )
@@ -1018,5 +1104,6 @@ struct platform_driver fimd_driver = { .name = "exynos4-fb", .owner = THIS_MODULE, .pm = &fimd_pm_ops, + .of_match_table = of_match_ptr(drm_fimd_dt_match), }, };
include/drm/exynos_drm.h +6 -0
@@ -224,6 +224,11 @@ struct exynos_drm_panel_info {u32 height_mm; }; +enum disp_panel_type { +MIPI_LCD , +DP_LCD +}; +/** * Platform Specific Structure for DRM based FIMD. *
@@ -237,6 +242,7 @@ struct exynos_drm_fimd_pdata {u32 vidcon1;unsigned int default_win;unsigned int bpp; +enum disp_panel_type panel_type; };/**
Signature · 1 line
1.7.0.4
Re: [PATCH 1/2] video: drm: exynos: Add device tree support
Hi,
Quoted 4 lines · Leela Krishna Amudala
Add device tree based discovery support for DRM-FIMD driver.
Signed-off-by Leela Krishna Amudala <[email protected]>
This also needs to be sent to [email protected], and the device tree bindings need to be documented under Documentation/devicetree/bindings.
I'll hold off comments on the bindings until the documentation piece is available.
A couple of other nits:
Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +0
-0
[...]
Quoted 1 line
+
of_property_read_u32(np, "samsung, defalut-window", &pd->default_win);
Two typos in one property.
[...]
drivers/gpu/drm/exynos/exynos_drm_fimd.c static int fimd_runtime_resume(struct device *dev) · line 1089
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +4
-0@@ -1006,6 +1083,15 @@ static int fimd_runtime_resume(struct device *dev) }#endif +#ifdef CONFIG_OF +static const struct of_device_id drm_fimd_dt_match[] = { + { .compatible ="samsung,exynos5-fb" , + .data = (void *)NULL },
No need to initialize data here.
Quoted 32 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +6
-0+ {}, +}; +MODULE_DEVICE_TABLE (of, drm_fimd_dt_match); +#endif +static const struct dev_pm_ops fimd_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume)SET_RUNTIME_PM_OPS (fimd_runtime_suspend, fimd_runtime_resume,NULL )@@ -1018,5 +1104,6 @@ struct platform_driver fimd_driver = { .name = "exynos4-fb", .owner = THIS_MODULE, .pm = &fimd_pm_ops, + .of_match_table = of_match_ptr(drm_fimd_dt_match), }, };include/drm/exynos_drm.h +5
-0@@ -224,6 +224,11 @@ struct exynos_drm_panel_info {u32 height_mm; }; +enum disp_panel_type { +MIPI_LCD , +DP_LCD +}; +/** * Platform Specific Structure for DRM based FIMD. *
include/drm/exynos_drm.h struct exynos_drm_fimd_pdata { · line 246
Quoted 5 lines
include/drm/exynos_drm.h +1
-0@@ -237,6 +242,7 @@ struct exynos_drm_fimd_pdata {u32 vidcon1;unsigned int default_win;unsigned int bpp; +enum disp_panel_type panel_type; };
This seems unrelated?
-Olof
Re: [PATCH 1/2] video: drm: exynos: Add device tree support
In reply to Leela Krishna AmudalaHi,
Quoted 67 lines · Leela Krishna Amudala
Add device tree based discovery support for DRM-FIMD driver.
Signed-off-by Leela Krishna Amudala <[email protected]>drivers/gpu/drm/exynos/exynos_drm_fimd.c +48
-0@@ -18,6 +18,7 @@#include <linux/platform_device.h> #include <linux/clk.h> #include <linux/pm_runtime.h> +#include <linux/of.h> #include <drm/exynos_drm.h> #include <plat/regs-fb-v4.h> @@ -788,12 +789,84 @@ static int fimd_power_on(struct fimd_context *ctx, bool enable)return 0 ; } +#ifdef CONFIG_OF +static struct exynos_drm_fimd_pdata *drm_fimd_dt_parse_pdata (struct device *dev) +{ +struct device_node *np = dev->of_node; +struct device_node *disp_np; +struct exynos_drm_fimd_pdata *pd; +u32 data[4 ]; + + pd =kzalloc (sizeof (*pd),GFP_KERNEL ); +if (!pd) { +dev_err (dev,"memory allocation for pdata failed\n" ); +return ERR_PTR (-ENOMEM ); + } + +if (of_get_property (np,"samsung,fimd-vidout-rgb" ,NULL )) + pd->vidcon0 |=VIDCON0_VIDOUT_RGB |VIDCON0_PNRMODE_RGB ; +if (of_get_property (np,"samsung,fimd-vidout-tv" ,NULL )) + pd->vidcon0 |=VIDCON0_VIDOUT_TV ; +if (of_get_property (np,"samsung,fimd-inv-hsync" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_HSYNC ; +if (of_get_property (np,"samsung,fimd-inv-vsync" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_VSYNC ; +if (of_get_property (np,"samsung,fimd-inv-vclk" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_VCLK ; +if (of_get_property (np,"samsung,fimd-inv-vden" ,NULL )) + pd->vidcon1 |=VIDCON1_INV_VDEN ; + + disp_np =of_parse_phandle (np,"samsung,fimd-display" ,0 ); +if (!disp_np) { +dev_err (dev,"unable to find display panel info\n" ); +return ERR_PTR (-EINVAL ); + } + +if (of_property_read_u32_array (disp_np,"lcd-htiming" , data,4 )) { +dev_err (dev,"invalid horizontal timing\n" ); +return ERR_PTR (-EINVAL ); + } + pd->panel.timing.left_margin = data[0 ]; + pd->panel.timing.right_margin = data[1 ]; + pd->panel.timing.hsync_len = data[2 ]; + pd->panel.timing.xres = data[3 ]; + +if (of_property_read_u32_array (disp_np,"lcd-vtiming" , data,4 )) { +dev_err (dev,"invalid vertical timing\n" ); +return ERR_PTR (-EINVAL ); + } + pd->panel.timing.upper_margin = data[0 ];
drivers/gpu/drm/exynos/exynos_drm_fimd.c static int fimd_power_on(struct fimd_context *ctx, bool enable) · line 848
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +10
-0+ pd->panel.timing.lower_margin = data[1 ]; + pd->panel.timing.vsync_len = data[2 ]; + pd->panel.timing.yres = data[3 ]; + +of_property_read_u32 (disp_np,"lcd-panel-type" , &pd->panel_type); + +of_property_read_u32 (np,"samsung,fimd-frame-rate" , + &pd->panel.timing.refresh); + +of_property_read_u32 (np,"samsung, defalut-window" , &pd->default_win);
No space between after comma.
Quoted 39 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +21
-2+ +of_property_read_u32 (np,"samsung,fimd-win-bpp" , &pd->bpp); + + return pd; +} +#else +static int drm_fimd_dt_parse_pdata (struct device *dev, +struct exynos_drm_fimd_pdata **pdata) +{ +return 0 ; +} +#endif /* CONFIG_OF */ + +static const struct of_device_id drm_fimd_dt_match[]; +static int __devinit fimd_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct fimd_context *ctx;struct exynos_drm_subdrv *subdrv; -struct exynos_drm_fimd_pdata *pdata; +struct exynos_drm_fimd_pdata *pdata = pdev->dev.platform_data;struct exynos_drm_panel_info *panel;struct resource *res;int win;@@ -801,7 +874,11 @@ static int __devinit fimd_probe(struct platform_device *pdev)DRM_DEBUG_KMS ("%s\n" , __FILE__); - pdata = pdev->dev.platform_data; +if (pdev->dev.of_node) { + pdata =drm_fimd_dt_parse_pdata (&pdev->dev); +if (IS_ERR (pdata)) +return PTR_ERR (pdata); + }if (!pdata) {dev_err (dev,"no platform data specified\n" );return -EINVAL ;
drivers/gpu/drm/exynos/exynos_drm_fimd.c static int fimd_runtime_resume(struct device *dev) · line 1088
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +3
-0@@ -1006,6 +1083,15 @@ static int fimd_runtime_resume(struct device *dev) }#endif +#ifdef CONFIG_OF +static const struct of_device_id drm_fimd_dt_match[] = { + { .compatible = "samsung,exynos5-fb",
It's ambiguous. it's better to use "samsung,exynos5-drm". Yes I know, previous it uses exynos4-fb to reduce the modification with mainline. but correct name is exynoxX-drm.
Thank you,
Kyungmin Park
Quoted 47 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +7
-0+ .data = (void *)NULL }, + {}, +}; +MODULE_DEVICE_TABLE (of, drm_fimd_dt_match); +#endif +static const struct dev_pm_ops fimd_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume)SET_RUNTIME_PM_OPS (fimd_runtime_suspend, fimd_runtime_resume,NULL )@@ -1018,5 +1104,6 @@ struct platform_driver fimd_driver = { .name = "exynos4-fb", .owner = THIS_MODULE, .pm = &fimd_pm_ops, + .of_match_table = of_match_ptr(drm_fimd_dt_match), }, };include/drm/exynos_drm.h +6
-1@@ -224,6 +224,11 @@ struct exynos_drm_panel_info {u32 height_mm; }; +enum disp_panel_type { +MIPI_LCD , +DP_LCD +}; +/** * Platform Specific Structure for DRM based FIMD. * @@ -237,6 +242,7 @@ struct exynos_drm_fimd_pdata {u32 vidcon1;unsigned int default_win;unsigned int bpp; +enum disp_panel_type panel_type; };/** -- 1.7.0.4
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/exynos: Modifying exynos drm fimd to support exynos5
In reply to Leela Krishna AmudalaFrom: Prathyush K <[email protected]>
The name of the exynos drm fimd device is renamed to exynos-drm-fimd and two ids are created for exynos4-fb and exynos5-fb.
drivers/gpu/drm/exynos/exynos_drm_fimd.c +12 -1
@@ -1092,6 +1092,16 @@ static const struct of_device_id drm_fimd_dt_match[] = {MODULE_DEVICE_TABLE (of, drm_fimd_dt_match);#endif +static struct platform_device_id exynos_drm_driver_ids[] = { + { + .name ="exynos4-fb" , + }, { + .name ="exynos5-fb" , + }, + {}, +}; +MODULE_DEVICE_TABLE (platform, exynos_drm_driver_ids); +static const struct dev_pm_ops fimd_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume)SET_RUNTIME_PM_OPS (fimd_runtime_suspend, fimd_runtime_resume,NULL )
@@ -1100,8 +1110,9 @@ static const struct dev_pm_ops fimd_pm_ops = {struct platform_driver fimd_driver = { .probe = fimd_probe, .remove =__devexit_p (fimd_remove), + .id_table = exynos_drm_driver_ids, .driver = { - .name ="exynos4-fb" , + .name ="exynos-drm-fimd" , .owner =THIS_MODULE , .pm = &fimd_pm_ops, .of_match_table =of_match_ptr (drm_fimd_dt_match),
Signature · 1 line
1.7.0.4
Re: [PATCH 2/2] drm/exynos: Modifying exynos drm fimd to support exynos5
Hi,
Some minor commants.
Quoted 4 lines · Leela Krishna Amudala
From: Prathyush K <[email protected]>
The name of the exynos drm fimd device is renamed to exynos-drm-fimd and two ids are created for exynos4-fb and exynos5-fb.
Please write the subject clearly this patch is to do what. How about "add platform_device_id table for exynos5 fimd"?
drivers/gpu/drm/exynos/exynos_drm_fimd.c static const struct of_device_id drm_fimd_dt_match[] = { · line 1095
Quoted 12 lines
Signed-off-by Prathyush K <[email protected]>drivers/gpu/drm/exynos/exynos_drm_fimd.c +1
-0@@ -1092,6 +1092,16 @@ static const struct of_device_id drm_fimd_dt_match[] = {MODULE_DEVICE_TABLE (of, drm_fimd_dt_match);#endif +static struct platform_device_id exynos_drm_driver_ids[] = {
Use fimd_ prefix, such as "fimd_driver_ids".
Quoted 13 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +9
-0+ { + .name = "exynos4-fb", + }, { + .name = "exynos5-fb", + }, + {}, +}; +MODULE_DEVICE_TABLE (platform, exynos_drm_driver_ids); +static const struct dev_pm_ops fimd_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(fimd_suspend, fimd_resume) SET_RUNTIME_PM_OPS(fimd_runtime_suspend, fimd_runtime_resume, NULL)
drivers/gpu/drm/exynos/exynos_drm_fimd.c static const struct dev_pm_ops fimd_pm_ops = { · line 1118
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_fimd.c +2
-1@@ -1100,8 +1110,9 @@ static const struct dev_pm_ops fimd_pm_ops = {struct platform_driver fimd_driver = { .probe = fimd_probe, .remove =__devexit_p (fimd_remove), + .id_table = exynos_drm_driver_ids, .driver = { - .name ="exynos4-fb" , + .name ="exynos-drm-fimd" , .owner =THIS_MODULE , .pm = &fimd_pm_ops, .of_match_table =of_match_ptr (drm_fimd_dt_match),
Thanks.