All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>, David Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>
Cc: "Ahmad Fatoum" <a.fatoum@pengutronix.de>,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	dri-devel@lists.freedesktop.org,
	"Abhinav Kumar" <quic_abhinavk@quicinc.com>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	linux-renesas-soc@vger.kernel.org,
	"Andy Shevchenko" <andy.shevchenko@gmail.com>,
	"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Biju Das" <biju.das.jz@bp.renesas.com>,
	"Adam Ford" <aford173@gmail.com>,
	"Bogdan Togorean" <bogdan.togorean@analog.com>
Subject: [PATCH v2 5/8] drm: adv7511: Add reg_cec_offset variable to struct adv7511_chip_info
Date: Wed, 30 Aug 2023 15:23:55 +0100	[thread overview]
Message-ID: <20230830142358.275459-6-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20230830142358.275459-1-biju.das.jz@bp.renesas.com>

The ADV7533 and ADV7535 have an offset(0x70) for the CEC register map
compared to ADV7511. Add the reg_cec_offset variable to struct
adv7511_chip_info to handle this difference and drop the reg_cec_offset
variable from struct adv7511.

This will avoid assigning reg_cec_offset based on chip type and also
testing for multiple chip types for calling adv7533_patch_cec_registers().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2:
 * New patch.
---
 drivers/gpu/drm/bridge/adv7511/adv7511.h     |  2 +-
 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c | 14 +++++++-------
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c |  8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index edf7be9c21d3..a728bfb33d03 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -339,6 +339,7 @@ struct adv7511_chip_info {
 	unsigned int max_lane_freq_khz;
 	const char * const *supply_names;
 	unsigned int num_supplies;
+	unsigned int reg_cec_offset;
 };
 
 struct adv7511 {
@@ -349,7 +350,6 @@ struct adv7511 {
 
 	struct regmap *regmap;
 	struct regmap *regmap_cec;
-	unsigned int reg_cec_offset;
 	enum drm_connector_status status;
 	bool powered;
 
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
index 2a6b91f752cb..44451a9658a3 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
@@ -33,7 +33,7 @@ static const u8 ADV7511_REG_CEC_RX_FRAME_LEN[] = {
 
 static void adv_cec_tx_raw_status(struct adv7511 *adv7511, u8 tx_raw_status)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	unsigned int val;
 
 	if (regmap_read(adv7511->regmap_cec,
@@ -84,7 +84,7 @@ static void adv_cec_tx_raw_status(struct adv7511 *adv7511, u8 tx_raw_status)
 
 static void adv7511_cec_rx(struct adv7511 *adv7511, int rx_buf)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	struct cec_msg msg = {};
 	unsigned int len;
 	unsigned int val;
@@ -121,7 +121,7 @@ static void adv7511_cec_rx(struct adv7511 *adv7511, int rx_buf)
 
 void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	const u32 irq_tx_mask = ADV7511_INT1_CEC_TX_READY |
 				ADV7511_INT1_CEC_TX_ARBIT_LOST |
 				ADV7511_INT1_CEC_TX_RETRY_TIMEOUT;
@@ -177,7 +177,7 @@ void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1)
 static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
 	struct adv7511 *adv7511 = cec_get_drvdata(adap);
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 
 	if (adv7511->i2c_cec == NULL)
 		return -EIO;
@@ -223,7 +223,7 @@ static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 static int adv7511_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
 	struct adv7511 *adv7511 = cec_get_drvdata(adap);
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	unsigned int i, free_idx = ADV7511_MAX_ADDRS;
 
 	if (!adv7511->cec_enabled_adap)
@@ -292,7 +292,7 @@ static int adv7511_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				     u32 signal_free_time, struct cec_msg *msg)
 {
 	struct adv7511 *adv7511 = cec_get_drvdata(adap);
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	u8 len = msg->len;
 	unsigned int i;
 
@@ -345,7 +345,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
 
 int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	int ret = adv7511_cec_parse_dt(dev, adv7511);
 
 	if (ret)
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 2bcd17953221..d806c870bf76 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -1035,7 +1035,7 @@ static bool adv7511_cec_register_volatile(struct device *dev, unsigned int reg)
 	struct i2c_client *i2c = to_i2c_client(dev);
 	struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
 
-	reg -= adv7511->reg_cec_offset;
+	reg -= adv7511->info->reg_cec_offset;
 
 	switch (reg) {
 	case ADV7511_REG_CEC_RX1_FRAME_HDR:
@@ -1086,12 +1086,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
 		goto err;
 	}
 
-	if (adv->info->type == ADV7533 || adv->info->type == ADV7535) {
+	if (adv->info->reg_cec_offset == ADV7533_REG_CEC_OFFSET) {
 		ret = adv7533_patch_cec_registers(adv);
 		if (ret)
 			goto err;
-
-		adv->reg_cec_offset = ADV7533_REG_CEC_OFFSET;
 	}
 
 	return 0;
@@ -1368,6 +1366,7 @@ static const struct adv7511_chip_info adv7533_chip_info = {
 	.max_lane_freq_khz = 800000,
 	.supply_names = adv7533_supply_names,
 	.num_supplies = ARRAY_SIZE(adv7533_supply_names),
+	.reg_cec_offset = ADV7533_REG_CEC_OFFSET,
 };
 
 static const struct adv7511_chip_info adv7535_chip_info = {
@@ -1376,6 +1375,7 @@ static const struct adv7511_chip_info adv7535_chip_info = {
 	.max_lane_freq_khz = 891000,
 	.supply_names = adv7533_supply_names,
 	.num_supplies = ARRAY_SIZE(adv7533_supply_names),
+	.reg_cec_offset = ADV7533_REG_CEC_OFFSET,
 };
 
 static const struct i2c_device_id adv7511_i2c_ids[] = {
-- 
2.25.1


WARNING: multiple messages have this Message-ID (diff)
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Andrzej Hajda <andrzej.hajda@intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>, David Airlie <airlied@gmail.com>,
	Daniel Vetter <daniel@ffwll.ch>
Cc: "Biju Das" <biju.das.jz@bp.renesas.com>,
	"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Abhinav Kumar" <quic_abhinavk@quicinc.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Andy Shevchenko" <andy.shevchenko@gmail.com>,
	"Javier Martinez Canillas" <javierm@redhat.com>,
	"Ahmad Fatoum" <a.fatoum@pengutronix.de>,
	"Rob Herring" <robh@kernel.org>,
	"Bogdan Togorean" <bogdan.togorean@analog.com>,
	"Adam Ford" <aford173@gmail.com>,
	dri-devel@lists.freedesktop.org,
	"Geert Uytterhoeven" <geert+renesas@glider.be>,
	linux-renesas-soc@vger.kernel.org
Subject: [PATCH v2 5/8] drm: adv7511: Add reg_cec_offset variable to struct adv7511_chip_info
Date: Wed, 30 Aug 2023 15:23:55 +0100	[thread overview]
Message-ID: <20230830142358.275459-6-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20230830142358.275459-1-biju.das.jz@bp.renesas.com>

The ADV7533 and ADV7535 have an offset(0x70) for the CEC register map
compared to ADV7511. Add the reg_cec_offset variable to struct
adv7511_chip_info to handle this difference and drop the reg_cec_offset
variable from struct adv7511.

This will avoid assigning reg_cec_offset based on chip type and also
testing for multiple chip types for calling adv7533_patch_cec_registers().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v2:
 * New patch.
---
 drivers/gpu/drm/bridge/adv7511/adv7511.h     |  2 +-
 drivers/gpu/drm/bridge/adv7511/adv7511_cec.c | 14 +++++++-------
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c |  8 ++++----
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index edf7be9c21d3..a728bfb33d03 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -339,6 +339,7 @@ struct adv7511_chip_info {
 	unsigned int max_lane_freq_khz;
 	const char * const *supply_names;
 	unsigned int num_supplies;
+	unsigned int reg_cec_offset;
 };
 
 struct adv7511 {
@@ -349,7 +350,6 @@ struct adv7511 {
 
 	struct regmap *regmap;
 	struct regmap *regmap_cec;
-	unsigned int reg_cec_offset;
 	enum drm_connector_status status;
 	bool powered;
 
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
index 2a6b91f752cb..44451a9658a3 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c
@@ -33,7 +33,7 @@ static const u8 ADV7511_REG_CEC_RX_FRAME_LEN[] = {
 
 static void adv_cec_tx_raw_status(struct adv7511 *adv7511, u8 tx_raw_status)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	unsigned int val;
 
 	if (regmap_read(adv7511->regmap_cec,
@@ -84,7 +84,7 @@ static void adv_cec_tx_raw_status(struct adv7511 *adv7511, u8 tx_raw_status)
 
 static void adv7511_cec_rx(struct adv7511 *adv7511, int rx_buf)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	struct cec_msg msg = {};
 	unsigned int len;
 	unsigned int val;
@@ -121,7 +121,7 @@ static void adv7511_cec_rx(struct adv7511 *adv7511, int rx_buf)
 
 void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	const u32 irq_tx_mask = ADV7511_INT1_CEC_TX_READY |
 				ADV7511_INT1_CEC_TX_ARBIT_LOST |
 				ADV7511_INT1_CEC_TX_RETRY_TIMEOUT;
@@ -177,7 +177,7 @@ void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1)
 static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 {
 	struct adv7511 *adv7511 = cec_get_drvdata(adap);
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 
 	if (adv7511->i2c_cec == NULL)
 		return -EIO;
@@ -223,7 +223,7 @@ static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable)
 static int adv7511_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
 {
 	struct adv7511 *adv7511 = cec_get_drvdata(adap);
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	unsigned int i, free_idx = ADV7511_MAX_ADDRS;
 
 	if (!adv7511->cec_enabled_adap)
@@ -292,7 +292,7 @@ static int adv7511_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
 				     u32 signal_free_time, struct cec_msg *msg)
 {
 	struct adv7511 *adv7511 = cec_get_drvdata(adap);
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	u8 len = msg->len;
 	unsigned int i;
 
@@ -345,7 +345,7 @@ static int adv7511_cec_parse_dt(struct device *dev, struct adv7511 *adv7511)
 
 int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511)
 {
-	unsigned int offset = adv7511->reg_cec_offset;
+	unsigned int offset = adv7511->info->reg_cec_offset;
 	int ret = adv7511_cec_parse_dt(dev, adv7511);
 
 	if (ret)
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 2bcd17953221..d806c870bf76 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -1035,7 +1035,7 @@ static bool adv7511_cec_register_volatile(struct device *dev, unsigned int reg)
 	struct i2c_client *i2c = to_i2c_client(dev);
 	struct adv7511 *adv7511 = i2c_get_clientdata(i2c);
 
-	reg -= adv7511->reg_cec_offset;
+	reg -= adv7511->info->reg_cec_offset;
 
 	switch (reg) {
 	case ADV7511_REG_CEC_RX1_FRAME_HDR:
@@ -1086,12 +1086,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
 		goto err;
 	}
 
-	if (adv->info->type == ADV7533 || adv->info->type == ADV7535) {
+	if (adv->info->reg_cec_offset == ADV7533_REG_CEC_OFFSET) {
 		ret = adv7533_patch_cec_registers(adv);
 		if (ret)
 			goto err;
-
-		adv->reg_cec_offset = ADV7533_REG_CEC_OFFSET;
 	}
 
 	return 0;
@@ -1368,6 +1366,7 @@ static const struct adv7511_chip_info adv7533_chip_info = {
 	.max_lane_freq_khz = 800000,
 	.supply_names = adv7533_supply_names,
 	.num_supplies = ARRAY_SIZE(adv7533_supply_names),
+	.reg_cec_offset = ADV7533_REG_CEC_OFFSET,
 };
 
 static const struct adv7511_chip_info adv7535_chip_info = {
@@ -1376,6 +1375,7 @@ static const struct adv7511_chip_info adv7535_chip_info = {
 	.max_lane_freq_khz = 891000,
 	.supply_names = adv7533_supply_names,
 	.num_supplies = ARRAY_SIZE(adv7533_supply_names),
+	.reg_cec_offset = ADV7533_REG_CEC_OFFSET,
 };
 
 static const struct i2c_device_id adv7511_i2c_ids[] = {
-- 
2.25.1


  parent reply	other threads:[~2023-08-30 14:24 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 14:23 [PATCH v2 0/8] ADV7511 driver enhancements Biju Das
2023-08-30 14:23 ` Biju Das
2023-08-30 14:23 ` [PATCH v2 1/8] drm: adv7511: Add struct adv7511_chip_info and use i2c_get_match_data() Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  9:07   ` Robert Foss
2023-10-16  9:07     ` Robert Foss
2023-08-30 14:23 ` [PATCH v2 2/8] drm: adv7511: Add max_mode_clock_khz variable to struct adv7511_chip_info Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  9:06   ` Robert Foss
2023-10-16  9:06     ` Robert Foss
2023-08-30 14:23 ` [PATCH v2 3/8] drm: adv7511: Add max_lane_freq_khz " Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  9:05   ` Robert Foss
2023-10-16  9:05     ` Robert Foss
2023-08-30 14:23 ` [PATCH v2 4/8] drm: adv7511: Add supply_names and num_supplies variables " Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  9:03   ` Robert Foss
2023-10-16  9:03     ` Robert Foss
2023-08-30 14:23 ` Biju Das [this message]
2023-08-30 14:23   ` [PATCH v2 5/8] drm: adv7511: Add reg_cec_offset variable " Biju Das
2023-10-16  8:58   ` Robert Foss
2023-10-16  8:58     ` Robert Foss
2023-10-16  9:37     ` Biju Das
2023-10-16  9:37       ` Biju Das
2023-08-30 14:23 ` [PATCH v2 6/8] drm: adv7511: Add has_dsi " Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  9:01   ` Robert Foss
2023-10-16  9:01     ` Robert Foss
2023-08-30 14:23 ` [PATCH v2 7/8] drm: adv7511: Add link_config " Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  8:59   ` Robert Foss
2023-10-16  8:59     ` Robert Foss
2023-08-30 14:23 ` [PATCH v2 8/8] drm: adv7511: Add hpd_override_enable " Biju Das
2023-08-30 14:23   ` Biju Das
2023-10-16  8:59   ` Robert Foss
2023-10-16  8:59     ` Robert Foss
2023-10-02  7:14 ` [PATCH v2 0/8] ADV7511 driver enhancements Biju Das
2023-10-02  7:14   ` Biju Das
2023-10-09  7:04   ` Biju Das
2023-10-09  7:04     ` Biju Das
2023-10-16  9:12 ` Robert Foss
2023-10-16  9:12   ` Robert Foss
2023-10-16  9:28   ` Biju Das
2023-10-16  9:28     ` Biju Das

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=20230830142358.275459-6-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=aford173@gmail.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bogdan.togorean@analog.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=geert+renesas@glider.be \
    --cc=javierm@redhat.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=rfoss@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    /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.