Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1421832 > unrolled thread

[PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data

Started byYakir Yang <ykk@rock-chips.com>
First post2016-06-14 13:50 +0200
Last post2016-06-29 09:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data Yakir Yang <ykk@rock-chips.com> - 2016-06-14 13:50 +0200
    Re: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select  setting into device data Sean Paul <seanpaul@chromium.org> - 2016-06-23 16:40 +0200
      Re: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data Heiko Stuebner <heiko@sntech.de> - 2016-06-23 18:20 +0200
        Re: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select  setting into device data[Involving remittance information, please pay  attention to the safety of property] Yakir Yang <ykk@rock-chips.com> - 2016-06-29 09:20 +0200

#1421832 — [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data

FromYakir Yang <ykk@rock-chips.com>
Date2016-06-14 13:50 +0200
Subject[PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data
Message-ID<rJV10-4hM-47@gated-at.bofh.it>
eDP controller need to declare which vop provide the video source,
and it's defined in GRF registers.

But different chips have different GRF register address, so we need to
create a device data to declare the GRF messages for each chips.

Signed-off-by: Yakir Yang <ykk@rock-chips.com>
Acked-by: Mark Yao <mark.yao@rock-chips.com>
---
Changes in v3:
- Write a kerneldoc-style comment explaining the chips data fields (Tomasz, reviewed at Google Gerrit)
    [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c@39]
- Drop the '.lcdcsel_mask' number in chips data field (Tomasz, reviewed at Google Gerrit)
    [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c@382]
- Add acked flag from Mark.

Changes in v2: None

 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 39 +++++++++++++++++++------
 1 file changed, 30 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 2bc8a7e..3855f46 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -14,6 +14,7 @@
 
 #include <linux/component.h>
 #include <linux/mfd/syscon.h>
+#include <linux/of_device.h>
 #include <linux/of_graph.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
@@ -35,11 +36,17 @@
 
 #define to_dp(nm)	container_of(nm, struct rockchip_dp_device, nm)
 
-/* dp grf register offset */
-#define GRF_SOC_CON6                            0x025c
-#define GRF_EDP_LCD_SEL_MASK                    BIT(5)
-#define GRF_EDP_SEL_VOP_LIT                     BIT(5)
-#define GRF_EDP_SEL_VOP_BIG                     0
+/**
+ * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
+ * @lcdsel_grf_reg: grf register offset of lcdc select
+ * @lcdsel_big: reg value of selecting vop big for eDP
+ * @lcdsel_lit: reg value of selecting vop little for eDP
+ */
+struct rockchip_dp_chip_data {
+	u32	lcdsel_grf_reg;
+	u32	lcdsel_big;
+	u32	lcdsel_lit;
+};
 
 struct rockchip_dp_device {
 	struct drm_device        *drm_dev;
@@ -51,6 +58,8 @@ struct rockchip_dp_device {
 	struct regmap            *grf;
 	struct reset_control     *rst;
 
+	const struct rockchip_dp_chip_data *data;
+
 	struct analogix_dp_plat_data plat_data;
 };
 
@@ -119,13 +128,13 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder)
 		return;
 
 	if (ret)
-		val = GRF_EDP_SEL_VOP_LIT | (GRF_EDP_LCD_SEL_MASK << 16);
+		val = dp->data->lcdsel_lit;
 	else
-		val = GRF_EDP_SEL_VOP_BIG | (GRF_EDP_LCD_SEL_MASK << 16);
+		val = dp->data->lcdsel_big;
 
 	dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
 
-	ret = regmap_write(dp->grf, GRF_SOC_CON6, val);
+	ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val);
 	if (ret != 0) {
 		dev_err(dp->dev, "Could not write to GRF: %d\n", ret);
 		return;
@@ -246,6 +255,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
 			    void *data)
 {
 	struct rockchip_dp_device *dp = dev_get_drvdata(dev);
+	const struct rockchip_dp_chip_data *dp_data;
 	struct drm_device *drm_dev = data;
 	int ret;
 
@@ -256,10 +266,15 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
 	 */
 	dev_set_drvdata(dev, NULL);
 
+	dp_data = of_device_get_match_data(dev);
+	if (!dp_data)
+		return -ENODEV;
+
 	ret = rockchip_dp_init(dp);
 	if (ret < 0)
 		return ret;
 
+	dp->data = dp_data;
 	dp->drm_dev = drm_dev;
 
 	ret = rockchip_dp_drm_create_encoder(dp);
@@ -365,8 +380,14 @@ static const struct dev_pm_ops rockchip_dp_pm_ops = {
 	SET_SYSTEM_SLEEP_PM_OPS(rockchip_dp_suspend, rockchip_dp_resume)
 };
 
+static const struct rockchip_dp_chip_data rk3288_dp = {
+	.lcdsel_grf_reg = 0x025c,
+	.lcdsel_big = 0 | BIT(21),
+	.lcdsel_lit = BIT(5) | BIT(21),
+};
+
 static const struct of_device_id rockchip_dp_dt_ids[] = {
-	{.compatible = "rockchip,rk3288-dp",},
+	{.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
 	{}
 };
 MODULE_DEVICE_TABLE(of, rockchip_dp_dt_ids);
-- 
1.9.1

[toc] | [next] | [standalone]


#1429907 — Re: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data

FromSean Paul <seanpaul@chromium.org>
Date2016-06-23 16:40 +0200
SubjectRe: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data
Message-ID<rNdXs-2Tn-29@gated-at.bofh.it>
In reply to#1421832
On Tue, Jun 14, 2016 at 7:46 AM, Yakir Yang <ykk@rock-chips.com> wrote:
> eDP controller need to declare which vop provide the video source,
> and it's defined in GRF registers.
>
> But different chips have different GRF register address, so we need to
> create a device data to declare the GRF messages for each chips.
>
> Signed-off-by: Yakir Yang <ykk@rock-chips.com>
> Acked-by: Mark Yao <mark.yao@rock-chips.com>
> ---
> Changes in v3:
> - Write a kerneldoc-style comment explaining the chips data fields (Tomasz, reviewed at Google Gerrit)
>     [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c@39]
> - Drop the '.lcdcsel_mask' number in chips data field (Tomasz, reviewed at Google Gerrit)
>     [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c@382]
> - Add acked flag from Mark.
>
> Changes in v2: None
>
>  drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 39 +++++++++++++++++++------
>  1 file changed, 30 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> index 2bc8a7e..3855f46 100644
> --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> @@ -14,6 +14,7 @@
>
>  #include <linux/component.h>
>  #include <linux/mfd/syscon.h>
> +#include <linux/of_device.h>
>  #include <linux/of_graph.h>
>  #include <linux/regmap.h>
>  #include <linux/reset.h>
> @@ -35,11 +36,17 @@
>
>  #define to_dp(nm)      container_of(nm, struct rockchip_dp_device, nm)
>
> -/* dp grf register offset */
> -#define GRF_SOC_CON6                            0x025c
> -#define GRF_EDP_LCD_SEL_MASK                    BIT(5)
> -#define GRF_EDP_SEL_VOP_LIT                     BIT(5)
> -#define GRF_EDP_SEL_VOP_BIG                     0
> +/**
> + * struct rockchip_dp_chip_data - splite the grf setting of kind of chips
> + * @lcdsel_grf_reg: grf register offset of lcdc select
> + * @lcdsel_big: reg value of selecting vop big for eDP
> + * @lcdsel_lit: reg value of selecting vop little for eDP
> + */
> +struct rockchip_dp_chip_data {
> +       u32     lcdsel_grf_reg;
> +       u32     lcdsel_big;
> +       u32     lcdsel_lit;
> +};
>
>  struct rockchip_dp_device {
>         struct drm_device        *drm_dev;
> @@ -51,6 +58,8 @@ struct rockchip_dp_device {
>         struct regmap            *grf;
>         struct reset_control     *rst;
>
> +       const struct rockchip_dp_chip_data *data;
> +
>         struct analogix_dp_plat_data plat_data;
>  };
>
> @@ -119,13 +128,13 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder)
>                 return;
>
>         if (ret)
> -               val = GRF_EDP_SEL_VOP_LIT | (GRF_EDP_LCD_SEL_MASK << 16);
> +               val = dp->data->lcdsel_lit;
>         else
> -               val = GRF_EDP_SEL_VOP_BIG | (GRF_EDP_LCD_SEL_MASK << 16);
> +               val = dp->data->lcdsel_big;
>
>         dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
>
> -       ret = regmap_write(dp->grf, GRF_SOC_CON6, val);
> +       ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val);
>         if (ret != 0) {
>                 dev_err(dp->dev, "Could not write to GRF: %d\n", ret);
>                 return;
> @@ -246,6 +255,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
>                             void *data)
>  {
>         struct rockchip_dp_device *dp = dev_get_drvdata(dev);
> +       const struct rockchip_dp_chip_data *dp_data;
>         struct drm_device *drm_dev = data;
>         int ret;
>
> @@ -256,10 +266,15 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
>          */
>         dev_set_drvdata(dev, NULL);
>
> +       dp_data = of_device_get_match_data(dev);
> +       if (!dp_data)
> +               return -ENODEV;
> +
>         ret = rockchip_dp_init(dp);
>         if (ret < 0)
>                 return ret;
>
> +       dp->data = dp_data;
>         dp->drm_dev = drm_dev;
>
>         ret = rockchip_dp_drm_create_encoder(dp);
> @@ -365,8 +380,14 @@ static const struct dev_pm_ops rockchip_dp_pm_ops = {
>         SET_SYSTEM_SLEEP_PM_OPS(rockchip_dp_suspend, rockchip_dp_resume)
>  };
>
> +static const struct rockchip_dp_chip_data rk3288_dp = {
> +       .lcdsel_grf_reg = 0x025c,
> +       .lcdsel_big = 0 | BIT(21),
> +       .lcdsel_lit = BIT(5) | BIT(21),

I'm not sure what convention is in other drivers, but this seems less
readable to me.

I'd prefer that the magic numbers were assigned to a #define that
corresponds to a TRM name in some header. Then you have names in the
assignment instead of meaningless numbers.

Sean

> +};
> +
>  static const struct of_device_id rockchip_dp_dt_ids[] = {
> -       {.compatible = "rockchip,rk3288-dp",},
> +       {.compatible = "rockchip,rk3288-dp", .data = &rk3288_dp },
>         {}
>  };
>  MODULE_DEVICE_TABLE(of, rockchip_dp_dt_ids);
> --
> 1.9.1
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

[toc] | [prev] | [next] | [standalone]


#1429956

FromHeiko Stuebner <heiko@sntech.de>
Date2016-06-23 18:20 +0200
Message-ID<rNfwe-45d-5@gated-at.bofh.it>
In reply to#1429907
Am Donnerstag, 23. Juni 2016, 10:32:53 schrieb Sean Paul:
> On Tue, Jun 14, 2016 at 7:46 AM, Yakir Yang <ykk@rock-chips.com> wrote:
> > eDP controller need to declare which vop provide the video source,
> > and it's defined in GRF registers.
> > 
> > But different chips have different GRF register address, so we need to
> > create a device data to declare the GRF messages for each chips.
> > 
> > Signed-off-by: Yakir Yang <ykk@rock-chips.com>
> > Acked-by: Mark Yao <mark.yao@rock-chips.com>
> > ---
> > Changes in v3:
> > - Write a kerneldoc-style comment explaining the chips data fields
> > (Tomasz, reviewed at Google Gerrit)> 
> >     [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/
> >     drm/rockchip/analogix_dp-rockchip.c@39]> 
> > - Drop the '.lcdcsel_mask' number in chips data field (Tomasz, reviewed
> > at Google Gerrit)> 
> >     [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/
> >     drm/rockchip/analogix_dp-rockchip.c@382]> 
> > - Add acked flag from Mark.
> > 
> > Changes in v2: None
> > 
> >  drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 39
> >  +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9
> >  deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> > b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index
> > 2bc8a7e..3855f46 100644
> > --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> > +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
> > @@ -14,6 +14,7 @@
> > 
> >  #include <linux/component.h>
> >  #include <linux/mfd/syscon.h>
> > 
> > +#include <linux/of_device.h>
> > 
> >  #include <linux/of_graph.h>
> >  #include <linux/regmap.h>
> >  #include <linux/reset.h>
> > 
> > @@ -35,11 +36,17 @@
> > 
> >  #define to_dp(nm)      container_of(nm, struct rockchip_dp_device, nm)
> > 
> > -/* dp grf register offset */
> > -#define GRF_SOC_CON6                            0x025c
> > -#define GRF_EDP_LCD_SEL_MASK                    BIT(5)
> > -#define GRF_EDP_SEL_VOP_LIT                     BIT(5)
> > -#define GRF_EDP_SEL_VOP_BIG                     0
> > +/**
> > + * struct rockchip_dp_chip_data - splite the grf setting of kind of
> > chips + * @lcdsel_grf_reg: grf register offset of lcdc select
> > + * @lcdsel_big: reg value of selecting vop big for eDP
> > + * @lcdsel_lit: reg value of selecting vop little for eDP
> > + */
> > +struct rockchip_dp_chip_data {
> > +       u32     lcdsel_grf_reg;
> > +       u32     lcdsel_big;
> > +       u32     lcdsel_lit;
> > +};
> > 
> >  struct rockchip_dp_device {
> >  
> >         struct drm_device        *drm_dev;
> > 
> > @@ -51,6 +58,8 @@ struct rockchip_dp_device {
> > 
> >         struct regmap            *grf;
> >         struct reset_control     *rst;
> > 
> > +       const struct rockchip_dp_chip_data *data;
> > +
> > 
> >         struct analogix_dp_plat_data plat_data;
> >  
> >  };
> > 
> > @@ -119,13 +128,13 @@ static void rockchip_dp_drm_encoder_enable(struct
> > drm_encoder *encoder)> 
> >                 return;
> >         
> >         if (ret)
> > 
> > -               val = GRF_EDP_SEL_VOP_LIT | (GRF_EDP_LCD_SEL_MASK <<
> > 16);
> > +               val = dp->data->lcdsel_lit;
> > 
> >         else
> > 
> > -               val = GRF_EDP_SEL_VOP_BIG | (GRF_EDP_LCD_SEL_MASK <<
> > 16);
> > +               val = dp->data->lcdsel_big;
> > 
> >         dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" :
> >         "BIG");
> > 
> > -       ret = regmap_write(dp->grf, GRF_SOC_CON6, val);
> > +       ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val);
> > 
> >         if (ret != 0) {
> >         
> >                 dev_err(dp->dev, "Could not write to GRF: %d\n", ret);
> >                 return;
> > 
> > @@ -246,6 +255,7 @@ static int rockchip_dp_bind(struct device *dev,
> > struct device *master,> 
> >                             void *data)
> >  
> >  {
> >  
> >         struct rockchip_dp_device *dp = dev_get_drvdata(dev);
> > 
> > +       const struct rockchip_dp_chip_data *dp_data;
> > 
> >         struct drm_device *drm_dev = data;
> >         int ret;
> > 
> > @@ -256,10 +266,15 @@ static int rockchip_dp_bind(struct device *dev,
> > struct device *master,> 
> >          */
> >         
> >         dev_set_drvdata(dev, NULL);
> > 
> > +       dp_data = of_device_get_match_data(dev);
> > +       if (!dp_data)
> > +               return -ENODEV;
> > +
> > 
> >         ret = rockchip_dp_init(dp);
> >         if (ret < 0)
> >         
> >                 return ret;
> > 
> > +       dp->data = dp_data;
> > 
> >         dp->drm_dev = drm_dev;
> >         
> >         ret = rockchip_dp_drm_create_encoder(dp);
> > 
> > @@ -365,8 +380,14 @@ static const struct dev_pm_ops rockchip_dp_pm_ops =
> > {> 
> >         SET_SYSTEM_SLEEP_PM_OPS(rockchip_dp_suspend, rockchip_dp_resume)
> >  
> >  };
> > 
> > +static const struct rockchip_dp_chip_data rk3288_dp = {
> > +       .lcdsel_grf_reg = 0x025c,
> > +       .lcdsel_big = 0 | BIT(21),
> > +       .lcdsel_lit = BIT(5) | BIT(21),
> 
> I'm not sure what convention is in other drivers, but this seems less
> readable to me.
> 
> I'd prefer that the magic numbers were assigned to a #define that
> corresponds to a TRM name in some header. Then you have names in the
> assignment instead of meaningless numbers.

I guess what irks me personally more is that it hides the write-mask as well

So I guess something like the following would also define it somewhat future-
proof

#define RK3288_GRF_SOC_CON6	0x25c
#define RK3288_EDP_LCDC_SEL		BIT(5)

#define HIWORD_UPDATE(val, mask) \
		(val | (mask) << 16)

static const struct rockchip_dp_chip_data rk3288_dp = {
	.lcdsel_grf_reg = RK3288_GRF_SOC_CON6,
	.lcdsel_big = HIWORD_UPDATE(0, RK3288_EDP_LCDC_SEL),
	.lcdsel_lit = HIWORD_UPDATE(RK3288_EDP_LCDC_SEL, RK3288_EDP_LCDC_SEL),

[toc] | [prev] | [next] | [standalone]


#1433499 — Re: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data[Involving remittance information, please pay attention to the safety of property]

FromYakir Yang <ykk@rock-chips.com>
Date2016-06-29 09:20 +0200
SubjectRe: [PATCH v3 02/10] drm/rockchip: analogix_dp: split the lcdc select setting into device data[Involving remittance information, please pay attention to the safety of property]
Message-ID<rPhWV-1co-3@gated-at.bofh.it>
In reply to#1429956
Heiko & Sean

On 06/24/2016 12:16 AM, Heiko Stuebner wrote:
> Am Donnerstag, 23. Juni 2016, 10:32:53 schrieb Sean Paul:
>> On Tue, Jun 14, 2016 at 7:46 AM, Yakir Yang <ykk@rock-chips.com> wrote:
>>> eDP controller need to declare which vop provide the video source,
>>> and it's defined in GRF registers.
>>>
>>> But different chips have different GRF register address, so we need to
>>> create a device data to declare the GRF messages for each chips.
>>>
>>> Signed-off-by: Yakir Yang <ykk@rock-chips.com>
>>> Acked-by: Mark Yao <mark.yao@rock-chips.com>
>>> ---
>>> Changes in v3:
>>> - Write a kerneldoc-style comment explaining the chips data fields
>>> (Tomasz, reviewed at Google Gerrit)>
>>>      [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/
>>>      drm/rockchip/analogix_dp-rockchip.c@39]>
>>> - Drop the '.lcdcsel_mask' number in chips data field (Tomasz, reviewed
>>> at Google Gerrit)>
>>>      [https://chromium-review.googlesource.com/#/c/346313/10/drivers/gpu/
>>>      drm/rockchip/analogix_dp-rockchip.c@382]>
>>> - Add acked flag from Mark.
>>>
>>> Changes in v2: None
>>>
>>>   drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 39
>>>   +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9
>>>   deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
>>> b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c index
>>> 2bc8a7e..3855f46 100644
>>> --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
>>> +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
>>> @@ -14,6 +14,7 @@
>>>
>>>   #include <linux/component.h>
>>>   #include <linux/mfd/syscon.h>
>>>
>>> +#include <linux/of_device.h>
>>>
>>>   #include <linux/of_graph.h>
>>>   #include <linux/regmap.h>
>>>   #include <linux/reset.h>
>>>
>>> @@ -35,11 +36,17 @@
>>>
>>>   #define to_dp(nm)      container_of(nm, struct rockchip_dp_device, nm)
>>>
>>> -/* dp grf register offset */
>>> -#define GRF_SOC_CON6                            0x025c
>>> -#define GRF_EDP_LCD_SEL_MASK                    BIT(5)
>>> -#define GRF_EDP_SEL_VOP_LIT                     BIT(5)
>>> -#define GRF_EDP_SEL_VOP_BIG                     0
>>> +/**
>>> + * struct rockchip_dp_chip_data - splite the grf setting of kind of
>>> chips + * @lcdsel_grf_reg: grf register offset of lcdc select
>>> + * @lcdsel_big: reg value of selecting vop big for eDP
>>> + * @lcdsel_lit: reg value of selecting vop little for eDP
>>> + */
>>> +struct rockchip_dp_chip_data {
>>> +       u32     lcdsel_grf_reg;
>>> +       u32     lcdsel_big;
>>> +       u32     lcdsel_lit;
>>> +};
>>>
>>>   struct rockchip_dp_device {
>>>   
>>>          struct drm_device        *drm_dev;
>>>
>>> @@ -51,6 +58,8 @@ struct rockchip_dp_device {
>>>
>>>          struct regmap            *grf;
>>>          struct reset_control     *rst;
>>>
>>> +       const struct rockchip_dp_chip_data *data;
>>> +
>>>
>>>          struct analogix_dp_plat_data plat_data;
>>>   
>>>   };
>>>
>>> @@ -119,13 +128,13 @@ static void rockchip_dp_drm_encoder_enable(struct
>>> drm_encoder *encoder)>
>>>                  return;
>>>          
>>>          if (ret)
>>>
>>> -               val = GRF_EDP_SEL_VOP_LIT | (GRF_EDP_LCD_SEL_MASK <<
>>> 16);
>>> +               val = dp->data->lcdsel_lit;
>>>
>>>          else
>>>
>>> -               val = GRF_EDP_SEL_VOP_BIG | (GRF_EDP_LCD_SEL_MASK <<
>>> 16);
>>> +               val = dp->data->lcdsel_big;
>>>
>>>          dev_dbg(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" :
>>>          "BIG");
>>>
>>> -       ret = regmap_write(dp->grf, GRF_SOC_CON6, val);
>>> +       ret = regmap_write(dp->grf, dp->data->lcdsel_grf_reg, val);
>>>
>>>          if (ret != 0) {
>>>          
>>>                  dev_err(dp->dev, "Could not write to GRF: %d\n", ret);
>>>                  return;
>>>
>>> @@ -246,6 +255,7 @@ static int rockchip_dp_bind(struct device *dev,
>>> struct device *master,>
>>>                              void *data)
>>>   
>>>   {
>>>   
>>>          struct rockchip_dp_device *dp = dev_get_drvdata(dev);
>>>
>>> +       const struct rockchip_dp_chip_data *dp_data;
>>>
>>>          struct drm_device *drm_dev = data;
>>>          int ret;
>>>
>>> @@ -256,10 +266,15 @@ static int rockchip_dp_bind(struct device *dev,
>>> struct device *master,>
>>>           */
>>>          
>>>          dev_set_drvdata(dev, NULL);
>>>
>>> +       dp_data = of_device_get_match_data(dev);
>>> +       if (!dp_data)
>>> +               return -ENODEV;
>>> +
>>>
>>>          ret = rockchip_dp_init(dp);
>>>          if (ret < 0)
>>>          
>>>                  return ret;
>>>
>>> +       dp->data = dp_data;
>>>
>>>          dp->drm_dev = drm_dev;
>>>          
>>>          ret = rockchip_dp_drm_create_encoder(dp);
>>>
>>> @@ -365,8 +380,14 @@ static const struct dev_pm_ops rockchip_dp_pm_ops =
>>> {>
>>>          SET_SYSTEM_SLEEP_PM_OPS(rockchip_dp_suspend, rockchip_dp_resume)
>>>   
>>>   };
>>>
>>> +static const struct rockchip_dp_chip_data rk3288_dp = {
>>> +       .lcdsel_grf_reg = 0x025c,
>>> +       .lcdsel_big = 0 | BIT(21),
>>> +       .lcdsel_lit = BIT(5) | BIT(21),
>> I'm not sure what convention is in other drivers, but this seems less
>> readable to me.
>>
>> I'd prefer that the magic numbers were assigned to a #define that
>> corresponds to a TRM name in some header. Then you have names in the
>> assignment instead of meaningless numbers.
> I guess what irks me personally more is that it hides the write-mask as well
>
> So I guess something like the following would also define it somewhat future-
> proof
>
> #define RK3288_GRF_SOC_CON6	0x25c
> #define RK3288_EDP_LCDC_SEL		BIT(5)
>
> #define HIWORD_UPDATE(val, mask) \
> 		(val | (mask) << 16)
>
> static const struct rockchip_dp_chip_data rk3288_dp = {
> 	.lcdsel_grf_reg = RK3288_GRF_SOC_CON6,
> 	.lcdsel_big = HIWORD_UPDATE(0, RK3288_EDP_LCDC_SEL),
> 	.lcdsel_lit = HIWORD_UPDATE(RK3288_EDP_LCDC_SEL, RK3288_EDP_LCDC_SEL),
>

Ah, great, thanks for your code, this should be more readable now.

Thanks,
- Yakir

>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web