From: Tomasz Figa <tomasz.figa@gmail.com>
To: Chanho Park <chanho61.park@samsung.com>
Cc: inki.dae@samsung.com, kgene.kim@samsung.com,
jy0922.shim@samsung.com, sw0312.kim@samsung.com,
kyungmin.park@samsung.com, dri-devel@lists.freedesktop.org,
linux-samsung-soc@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
devicetree-discuss@lists.ozlabs.org
Subject: Re: [PATCH 1/3] drm/exynos: add device tree support for rotator
Date: Mon, 22 Jul 2013 21:32:07 +0200 [thread overview]
Message-ID: <1944640.dQgavdmLbq@flatron> (raw)
In-Reply-To: <1374475767-30085-2-git-send-email-chanho61.park@samsung.com>
On Monday 22 of July 2013 15:49:25 Chanho Park wrote:
> The exynos4 platform is only dt-based since 3.10, we should convert
> driver data and ids to dt-based parsing methods. The rotator driver has
> a limit table to get size limit. The minimum size of RGB888 format is 8
> x 8 and maximum size is 8K x 8K. The other format, YCbCr420 2-Plane has
> 32 x 32 min size and 32K x 32K max size. Each format should be multiple
> of 'align' value.
>
> Signed-off-by: Chanho Park <chanho61.park@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/gpu/drm/exynos/exynos_drm_rotator.c | 110
> +++++++++++++++++++-------- 1 file changed, 80 insertions(+), 30
> deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index 427640a..b353a10
> 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> @@ -96,7 +96,7 @@ struct rot_context {
> struct resource *regs_res;
> void __iomem *regs;
> struct clk *clock;
> - struct rot_limit_table *limit_tbl;
> + struct rot_limit_table limit_tbl;
> int irq;
> int cur_buf_id[EXYNOS_DRM_OPS_MAX];
> bool suspended;
> @@ -167,7 +167,7 @@ static irqreturn_t rotator_irq_handler(int irq, void
> *arg) static void rotator_align_size(struct rot_context *rot, u32 fmt,
> u32 *hsize, u32 *vsize)
> {
> - struct rot_limit_table *limit_tbl = rot->limit_tbl;
> + struct rot_limit_table *limit_tbl = &rot->limit_tbl;
> struct rot_limit *limit;
> u32 mask, val;
>
> @@ -632,6 +632,72 @@ static int rotator_ippdrv_start(struct device *dev,
> enum drm_exynos_ipp_cmd cmd) return 0;
> }
>
> +static const struct of_device_id exynos_rotator_match[] = {
> + {
> + .compatible = "samsung,exynos4210-rotator",
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, exynos_rotator_match);
> +
> +static int rotator_parse_dt_tbl(struct device_node *np, struct
> rot_limit *rlim) +{
> + int ret;
> +
> + ret = of_property_read_u32(np, "min_w", &rlim->min_w);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "min_h", &rlim->min_h);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "max_w", &rlim->max_w);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "max_h", &rlim->max_h);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "align", &rlim->align);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static int rotator_parse_dt(struct device *dev, struct rot_context
> *rot) +{
> + struct device_node *ycbcr_node, *rgb888_node;
> + int ret;
> +
> + ycbcr_node = of_get_child_by_name(dev->of_node, "ycbcr420_2p");
> + if (!ycbcr_node) {
> + dev_err(dev, "can't find ycbcr420_2p node\n");
> + return -ENODEV;
> + }
> +
> + rgb888_node = of_get_child_by_name(dev->of_node, "rgb888");
> + if (!rgb888_node) {
> + dev_err(dev, "can't find rgb888 node\n");
> + return -ENODEV;
> + }
> +
> + ret = rotator_parse_dt_tbl(ycbcr_node, &rot-
>limit_tbl.ycbcr420_2p);
> + if (ret) {
> + dev_err(dev, "failed to parse ycbcr420 data\n");
> + return ret;
> + }
> + ret = rotator_parse_dt_tbl(rgb888_node, &rot->limit_tbl.rgb888);
> + if (ret) {
> + dev_err(dev, "failed to parse rgb888 data\n");
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static int rotator_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -639,14 +705,23 @@ static int rotator_probe(struct platform_device
> *pdev) struct exynos_drm_ippdrv *ippdrv;
> int ret;
>
> + if (!dev->of_node) {
> + dev_err(dev, "Cannot find device tree node\n");
> + return -ENODEV;
> + }
> +
> rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL);
> if (!rot) {
> dev_err(dev, "failed to allocate rot\n");
> return -ENOMEM;
> }
>
> - rot->limit_tbl = (struct rot_limit_table *)
> - platform_get_device_id(pdev)->driver_data;
> + ret = rotator_parse_dt(dev, rot);
> + if (ret) {
> + dev_err(dev, "failed parse dt info\n");
> + devm_kfree(dev, rot);
> + return ret;
> + }
>
> rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> rot->regs = devm_ioremap_resource(dev, rot->regs_res);
> @@ -718,31 +793,6 @@ static int rotator_remove(struct platform_device
> *pdev) return 0;
> }
>
> -static struct rot_limit_table rot_limit_tbl = {
> - .ycbcr420_2p = {
> - .min_w = 32,
> - .min_h = 32,
> - .max_w = SZ_32K,
> - .max_h = SZ_32K,
> - .align = 3,
> - },
> - .rgb888 = {
> - .min_w = 8,
> - .min_h = 8,
> - .max_w = SZ_8K,
> - .max_h = SZ_8K,
> - .align = 2,
> - },
> -};
> -
> -static struct platform_device_id rotator_driver_ids[] = {
> - {
> - .name = "exynos-rot",
> - .driver_data = (unsigned long)&rot_limit_tbl,
> - },
> - {},
> -};
> -
I would keep these driver data here and just point to them from match_data
of OF match table, as suggested in other replies.
Best regards,
Tomasz
WARNING: multiple messages have this Message-ID (diff)
From: tomasz.figa@gmail.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] drm/exynos: add device tree support for rotator
Date: Mon, 22 Jul 2013 21:32:07 +0200 [thread overview]
Message-ID: <1944640.dQgavdmLbq@flatron> (raw)
In-Reply-To: <1374475767-30085-2-git-send-email-chanho61.park@samsung.com>
On Monday 22 of July 2013 15:49:25 Chanho Park wrote:
> The exynos4 platform is only dt-based since 3.10, we should convert
> driver data and ids to dt-based parsing methods. The rotator driver has
> a limit table to get size limit. The minimum size of RGB888 format is 8
> x 8 and maximum size is 8K x 8K. The other format, YCbCr420 2-Plane has
> 32 x 32 min size and 32K x 32K max size. Each format should be multiple
> of 'align' value.
>
> Signed-off-by: Chanho Park <chanho61.park@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> drivers/gpu/drm/exynos/exynos_drm_rotator.c | 110
> +++++++++++++++++++-------- 1 file changed, 80 insertions(+), 30
> deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c index 427640a..b353a10
> 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> @@ -96,7 +96,7 @@ struct rot_context {
> struct resource *regs_res;
> void __iomem *regs;
> struct clk *clock;
> - struct rot_limit_table *limit_tbl;
> + struct rot_limit_table limit_tbl;
> int irq;
> int cur_buf_id[EXYNOS_DRM_OPS_MAX];
> bool suspended;
> @@ -167,7 +167,7 @@ static irqreturn_t rotator_irq_handler(int irq, void
> *arg) static void rotator_align_size(struct rot_context *rot, u32 fmt,
> u32 *hsize, u32 *vsize)
> {
> - struct rot_limit_table *limit_tbl = rot->limit_tbl;
> + struct rot_limit_table *limit_tbl = &rot->limit_tbl;
> struct rot_limit *limit;
> u32 mask, val;
>
> @@ -632,6 +632,72 @@ static int rotator_ippdrv_start(struct device *dev,
> enum drm_exynos_ipp_cmd cmd) return 0;
> }
>
> +static const struct of_device_id exynos_rotator_match[] = {
> + {
> + .compatible = "samsung,exynos4210-rotator",
> + },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, exynos_rotator_match);
> +
> +static int rotator_parse_dt_tbl(struct device_node *np, struct
> rot_limit *rlim) +{
> + int ret;
> +
> + ret = of_property_read_u32(np, "min_w", &rlim->min_w);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "min_h", &rlim->min_h);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "max_w", &rlim->max_w);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "max_h", &rlim->max_h);
> + if (ret)
> + return ret;
> +
> + ret = of_property_read_u32(np, "align", &rlim->align);
> + if (ret)
> + return ret;
> +
> + return 0;
> +}
> +
> +static int rotator_parse_dt(struct device *dev, struct rot_context
> *rot) +{
> + struct device_node *ycbcr_node, *rgb888_node;
> + int ret;
> +
> + ycbcr_node = of_get_child_by_name(dev->of_node, "ycbcr420_2p");
> + if (!ycbcr_node) {
> + dev_err(dev, "can't find ycbcr420_2p node\n");
> + return -ENODEV;
> + }
> +
> + rgb888_node = of_get_child_by_name(dev->of_node, "rgb888");
> + if (!rgb888_node) {
> + dev_err(dev, "can't find rgb888 node\n");
> + return -ENODEV;
> + }
> +
> + ret = rotator_parse_dt_tbl(ycbcr_node, &rot-
>limit_tbl.ycbcr420_2p);
> + if (ret) {
> + dev_err(dev, "failed to parse ycbcr420 data\n");
> + return ret;
> + }
> + ret = rotator_parse_dt_tbl(rgb888_node, &rot->limit_tbl.rgb888);
> + if (ret) {
> + dev_err(dev, "failed to parse rgb888 data\n");
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static int rotator_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -639,14 +705,23 @@ static int rotator_probe(struct platform_device
> *pdev) struct exynos_drm_ippdrv *ippdrv;
> int ret;
>
> + if (!dev->of_node) {
> + dev_err(dev, "Cannot find device tree node\n");
> + return -ENODEV;
> + }
> +
> rot = devm_kzalloc(dev, sizeof(*rot), GFP_KERNEL);
> if (!rot) {
> dev_err(dev, "failed to allocate rot\n");
> return -ENOMEM;
> }
>
> - rot->limit_tbl = (struct rot_limit_table *)
> - platform_get_device_id(pdev)->driver_data;
> + ret = rotator_parse_dt(dev, rot);
> + if (ret) {
> + dev_err(dev, "failed parse dt info\n");
> + devm_kfree(dev, rot);
> + return ret;
> + }
>
> rot->regs_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> rot->regs = devm_ioremap_resource(dev, rot->regs_res);
> @@ -718,31 +793,6 @@ static int rotator_remove(struct platform_device
> *pdev) return 0;
> }
>
> -static struct rot_limit_table rot_limit_tbl = {
> - .ycbcr420_2p = {
> - .min_w = 32,
> - .min_h = 32,
> - .max_w = SZ_32K,
> - .max_h = SZ_32K,
> - .align = 3,
> - },
> - .rgb888 = {
> - .min_w = 8,
> - .min_h = 8,
> - .max_w = SZ_8K,
> - .max_h = SZ_8K,
> - .align = 2,
> - },
> -};
> -
> -static struct platform_device_id rotator_driver_ids[] = {
> - {
> - .name = "exynos-rot",
> - .driver_data = (unsigned long)&rot_limit_tbl,
> - },
> - {},
> -};
> -
I would keep these driver data here and just point to them from match_data
of OF match table, as suggested in other replies.
Best regards,
Tomasz
next prev parent reply other threads:[~2013-07-22 19:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-22 6:49 [PATCH 0/3] device tree support for exynos rotator Chanho Park
2013-07-22 6:49 ` Chanho Park
2013-07-22 6:49 ` [PATCH 1/3] drm/exynos: add device tree support for rotator Chanho Park
2013-07-22 6:49 ` Chanho Park
2013-07-22 12:20 ` Inki Dae
2013-07-22 12:20 ` Inki Dae
2013-07-22 19:32 ` Tomasz Figa [this message]
2013-07-22 19:32 ` Tomasz Figa
2013-07-22 6:49 ` [PATCH 2/3] drm/exynos: add dt-binding documentation " Chanho Park
2013-07-22 6:49 ` Chanho Park
2013-07-22 8:48 ` Mark Rutland
2013-07-22 8:48 ` Mark Rutland
2013-07-22 12:37 ` Inki Dae
2013-07-22 12:37 ` Inki Dae
2013-07-22 12:46 ` Lucas Stach
2013-07-22 12:46 ` Lucas Stach
2013-07-22 13:31 ` Inki Dae
2013-07-22 13:31 ` Inki Dae
2013-07-22 14:00 ` Sylwester Nawrocki
2013-07-22 14:00 ` Sylwester Nawrocki
2013-07-22 19:28 ` Tomasz Figa
2013-07-22 19:28 ` Tomasz Figa
2013-07-23 2:00 ` Inki Dae
2013-07-23 2:00 ` Inki Dae
2013-07-23 1:21 ` Chanho Park
2013-07-23 1:35 ` Inki Dae
2013-07-23 1:35 ` Inki Dae
2013-07-23 2:47 ` Chanho Park
2013-07-22 6:49 ` [PATCH 3/3] dts: ARM: add a rotator node for exynos4 Chanho Park
2013-07-22 6:49 ` Chanho Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1944640.dQgavdmLbq@flatron \
--to=tomasz.figa@gmail.com \
--cc=chanho61.park@samsung.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=inki.dae@samsung.com \
--cc=jy0922.shim@samsung.com \
--cc=kgene.kim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=sw0312.kim@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.