[media] s5p-mfc: Add device tree support
This patch will add the device tree support for MFC driver. Signed-off-by: Arun Kumar K <arun.kk@samsung.com> Acked-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
371a664eea
commit
b27a23be0d
1 changed files with 84 additions and 16 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <media/v4l2-event.h>
|
#include <media/v4l2-event.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
|
#include <linux/of.h>
|
||||||
#include <media/videobuf2-core.h>
|
#include <media/videobuf2-core.h>
|
||||||
#include "s5p_mfc_common.h"
|
#include "s5p_mfc_common.h"
|
||||||
#include "s5p_mfc_ctrl.h"
|
#include "s5p_mfc_ctrl.h"
|
||||||
|
@ -1027,6 +1028,8 @@ static int match_child(struct device *dev, void *data)
|
||||||
return !strcmp(dev_name(dev), (char *)data);
|
return !strcmp(dev_name(dev), (char *)data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *mfc_get_drv_data(struct platform_device *pdev);
|
||||||
|
|
||||||
/* MFC probe function */
|
/* MFC probe function */
|
||||||
static int s5p_mfc_probe(struct platform_device *pdev)
|
static int s5p_mfc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
@ -1034,6 +1037,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
|
||||||
struct video_device *vfd;
|
struct video_device *vfd;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned int mem_info[2];
|
||||||
|
|
||||||
pr_debug("%s++\n", __func__);
|
pr_debug("%s++\n", __func__);
|
||||||
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
|
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
|
||||||
|
@ -1050,8 +1054,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->variant = (struct s5p_mfc_variant *)
|
dev->variant = mfc_get_drv_data(pdev);
|
||||||
platform_get_device_id(pdev)->driver_data;
|
|
||||||
|
|
||||||
ret = s5p_mfc_init_pm(dev);
|
ret = s5p_mfc_init_pm(dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -1081,21 +1084,56 @@ static int s5p_mfc_probe(struct platform_device *pdev)
|
||||||
goto err_res;
|
goto err_res;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->mem_dev_l = device_find_child(&dev->plat_dev->dev, "s5p-mfc-l",
|
if (pdev->dev.of_node) {
|
||||||
match_child);
|
dev->mem_dev_l = kzalloc(sizeof(struct device), GFP_KERNEL);
|
||||||
|
if (!dev->mem_dev_l) {
|
||||||
|
mfc_err("Not enough memory\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_res;
|
||||||
|
}
|
||||||
|
of_property_read_u32_array(pdev->dev.of_node, "samsung,mfc-l",
|
||||||
|
mem_info, 2);
|
||||||
|
if (dma_declare_coherent_memory(dev->mem_dev_l, mem_info[0],
|
||||||
|
mem_info[0], mem_info[1],
|
||||||
|
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) {
|
||||||
|
mfc_err("Failed to declare coherent memory for\n"
|
||||||
|
"MFC device\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_res;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->mem_dev_r = kzalloc(sizeof(struct device), GFP_KERNEL);
|
||||||
|
if (!dev->mem_dev_r) {
|
||||||
|
mfc_err("Not enough memory\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_res;
|
||||||
|
}
|
||||||
|
of_property_read_u32_array(pdev->dev.of_node, "samsung,mfc-r",
|
||||||
|
mem_info, 2);
|
||||||
|
if (dma_declare_coherent_memory(dev->mem_dev_r, mem_info[0],
|
||||||
|
mem_info[0], mem_info[1],
|
||||||
|
DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) {
|
||||||
|
pr_err("Failed to declare coherent memory for\n"
|
||||||
|
"MFC device\n");
|
||||||
|
ret = -ENOMEM;
|
||||||
|
goto err_res;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dev->mem_dev_l = device_find_child(&dev->plat_dev->dev,
|
||||||
|
"s5p-mfc-l", match_child);
|
||||||
if (!dev->mem_dev_l) {
|
if (!dev->mem_dev_l) {
|
||||||
mfc_err("Mem child (L) device get failed\n");
|
mfc_err("Mem child (L) device get failed\n");
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto err_res;
|
goto err_res;
|
||||||
}
|
}
|
||||||
|
dev->mem_dev_r = device_find_child(&dev->plat_dev->dev,
|
||||||
dev->mem_dev_r = device_find_child(&dev->plat_dev->dev, "s5p-mfc-r",
|
"s5p-mfc-r", match_child);
|
||||||
match_child);
|
|
||||||
if (!dev->mem_dev_r) {
|
if (!dev->mem_dev_r) {
|
||||||
mfc_err("Mem child (R) device get failed\n");
|
mfc_err("Mem child (R) device get failed\n");
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto err_res;
|
goto err_res;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l);
|
dev->alloc_ctx[0] = vb2_dma_contig_init_ctx(dev->mem_dev_l);
|
||||||
if (IS_ERR_OR_NULL(dev->alloc_ctx[0])) {
|
if (IS_ERR_OR_NULL(dev->alloc_ctx[0])) {
|
||||||
|
@ -1366,6 +1404,35 @@ static struct platform_device_id mfc_driver_ids[] = {
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(platform, mfc_driver_ids);
|
MODULE_DEVICE_TABLE(platform, mfc_driver_ids);
|
||||||
|
|
||||||
|
static const struct of_device_id exynos_mfc_match[] = {
|
||||||
|
{
|
||||||
|
.compatible = "samsung,mfc-v5",
|
||||||
|
.data = &mfc_drvdata_v5,
|
||||||
|
}, {
|
||||||
|
.compatible = "samsung,mfc-v6",
|
||||||
|
.data = &mfc_drvdata_v6,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, exynos_mfc_match);
|
||||||
|
|
||||||
|
static void *mfc_get_drv_data(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct s5p_mfc_variant *driver_data = NULL;
|
||||||
|
|
||||||
|
if (pdev->dev.of_node) {
|
||||||
|
const struct of_device_id *match;
|
||||||
|
match = of_match_node(of_match_ptr(exynos_mfc_match),
|
||||||
|
pdev->dev.of_node);
|
||||||
|
if (match)
|
||||||
|
driver_data = (struct s5p_mfc_variant *)match->data;
|
||||||
|
} else {
|
||||||
|
driver_data = (struct s5p_mfc_variant *)
|
||||||
|
platform_get_device_id(pdev)->driver_data;
|
||||||
|
}
|
||||||
|
return driver_data;
|
||||||
|
}
|
||||||
|
|
||||||
static struct platform_driver s5p_mfc_driver = {
|
static struct platform_driver s5p_mfc_driver = {
|
||||||
.probe = s5p_mfc_probe,
|
.probe = s5p_mfc_probe,
|
||||||
.remove = __devexit_p(s5p_mfc_remove),
|
.remove = __devexit_p(s5p_mfc_remove),
|
||||||
|
@ -1373,7 +1440,8 @@ static struct platform_driver s5p_mfc_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = S5P_MFC_NAME,
|
.name = S5P_MFC_NAME,
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.pm = &s5p_mfc_pm_ops
|
.pm = &s5p_mfc_pm_ops,
|
||||||
|
.of_match_table = exynos_mfc_match,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue