drm/tegra: dp: Support address-only I2C-over-AUX transactions
PATCH 1/1 drm/tegra: dp: Support address-only I2C-over-AUX transactions
From: Thierry Reding <[email protected]>
Certain types of I2C-over-AUX transactions require that only the address is transferred. Detect this by looking at the AUX message's size and set the address-only bit appropriately.
---
Hi Alex,
This patch is required to make eDP work properly on Tegra with your I2C- over-AUX patch series applied. Would you consider carrying this in your series so that bisectability can be maintained? It would need to be applied prior to the core change (patch 2/4 in the latest series) to do so.
Thanks,
Thierry
drivers/gpu/drm/tegra/dpaux.c | 44 ++++++++++++++++++++++++++++++------------- drivers/gpu/drm/tegra/dpaux.h | 1 + 2 files changed, 32 insertions(+), 13 deletions(-)
drivers/gpu/drm/tegra/dpaux.c +31 -13
@@ -99,55 +99,73 @@ static void tegra_dpaux_read_fifo(struct tegra_dpaux *dpaux, u8 *buffer,static ssize_t tegra_dpaux_transfer (struct drm_dp_aux *aux,struct drm_dp_aux_msg *msg) { -unsigned long value =DPAUX_DP_AUXCTL_TRANSACTREQ ;unsigned long timeout =msecs_to_jiffies (250 );struct tegra_dpaux *dpaux =to_dpaux (aux);unsigned long status;ssize_t ret =0 ; +u32 value; -if (msg->size <1 || msg->size >16 ) +/* Tegra has 4x4 byte DP AUX transmit and receive FIFOs. */ +if (msg->size >16 )return -EINVAL ; -tegra_dpaux_writel (dpaux, msg->address,DPAUX_DP_AUXADDR ); +/* +* Allow zero-sized messages only for I2C, in which case they specify +* address-only transactions. +*/ +if (msg->size <1 ) { +switch (msg->request & ~DP_AUX_I2C_MOT ) { +case DP_AUX_I2C_WRITE : +case DP_AUX_I2C_READ : + value =DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY ; +break ; + +default : +return -EINVAL ; + } + }else { +/* For non-zero-sized messages, set the CMDLEN field. */ + value =DPAUX_DP_AUXCTL_CMDLEN (msg->size -1 ); + }switch (msg->request & ~DP_AUX_I2C_MOT ) {case DP_AUX_I2C_WRITE :if (msg->request &DP_AUX_I2C_MOT ) - value =DPAUX_DP_AUXCTL_CMD_MOT_WR ; + value |=DPAUX_DP_AUXCTL_CMD_MOT_WR ;else - value =DPAUX_DP_AUXCTL_CMD_I2C_WR ; + value |=DPAUX_DP_AUXCTL_CMD_I2C_WR ;break ;case DP_AUX_I2C_READ :if (msg->request &DP_AUX_I2C_MOT ) - value =DPAUX_DP_AUXCTL_CMD_MOT_RD ; + value |=DPAUX_DP_AUXCTL_CMD_MOT_RD ;else - value =DPAUX_DP_AUXCTL_CMD_I2C_RD ; + value |=DPAUX_DP_AUXCTL_CMD_I2C_RD ;break ;case DP_AUX_I2C_STATUS :if (msg->request &DP_AUX_I2C_MOT ) - value =DPAUX_DP_AUXCTL_CMD_MOT_RQ ; + value |=DPAUX_DP_AUXCTL_CMD_MOT_RQ ;else - value =DPAUX_DP_AUXCTL_CMD_I2C_RQ ; + value |=DPAUX_DP_AUXCTL_CMD_I2C_RQ ;break ;case DP_AUX_NATIVE_WRITE : - value =DPAUX_DP_AUXCTL_CMD_AUX_WR ; + value |=DPAUX_DP_AUXCTL_CMD_AUX_WR ;break ;case DP_AUX_NATIVE_READ : - value =DPAUX_DP_AUXCTL_CMD_AUX_RD ; + value |=DPAUX_DP_AUXCTL_CMD_AUX_RD ;break ;default :return -EINVAL ; } - value |=DPAUX_DP_AUXCTL_CMDLEN (msg->size -1 ); +tegra_dpaux_writel (dpaux, msg->address,DPAUX_DP_AUXADDR );tegra_dpaux_writel (dpaux, value,DPAUX_DP_AUXCTL );if ((msg->request &DP_AUX_I2C_READ ) ==0 ) {
@@ -198,7 +216,7 @@ static ssize_t tegra_dpaux_transfer(struct drm_dp_aux *aux,break ; } -if (msg->reply ==DP_AUX_NATIVE_REPLY_ACK ) { +if ((msg->size >0 ) && (msg->reply ==DP_AUX_NATIVE_REPLY_ACK )) {if (msg->request &DP_AUX_I2C_READ ) {size_t count = value &DPAUX_DP_AUXSTAT_REPLY_MASK ;
drivers/gpu/drm/tegra/dpaux.h +1 -0
@@ -32,6 +32,7 @@#define DPAUX_DP_AUXCTL_CMD_I2C_RQ (2 << 12)#define DPAUX_DP_AUXCTL_CMD_I2C_RD (1 << 12)#define DPAUX_DP_AUXCTL_CMD_I2C_WR (0 << 12) +#define DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY (1 << 8)#define DPAUX_DP_AUXCTL_CMDLEN (x) ((x) & 0xff)#define DPAUX_DP_AUXSTAT 0x31
Signature · 1 line
1.9.1
PATCH 1/1 drm/i915: support address only i2c-over-aux transactions
To support bare address requests used by the drm dp helpers.
---
Hi Alex, similar to Thierry's patch for i915.
BR,
Jani.
--- drivers/gpu/drm/i915/intel_dp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +4 -3
@@ -575,7 +575,8 @@ out:return ret; } -#define HEADER_SIZE 4 +#define BARE_ADDRESS_SIZE 3 +#define HEADER_SIZE (BARE_ADDRESS_SIZE + 1)static ssize_t intel_dp_aux_transfer (struct drm_dp_aux *aux,struct drm_dp_aux_msg *msg) {
@@ -592,7 +593,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)switch (msg->request & ~DP_AUX_I2C_MOT ) {case DP_AUX_NATIVE_WRITE :case DP_AUX_I2C_WRITE : - txsize =HEADER_SIZE + msg->size; + txsize = msg->size ?HEADER_SIZE + msg->size :BARE_ADDRESS_SIZE ; rxsize =1 ;if (WARN_ON (txsize >20 ))
@@ -611,7 +612,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)case DP_AUX_NATIVE_READ :case DP_AUX_I2C_READ : - txsize =HEADER_SIZE ; + txsize = msg->size ?HEADER_SIZE :BARE_ADDRESS_SIZE ; rxsize = msg->size +1 ;if (WARN_ON (rxsize >20 ))
Signature · 1 line
1.7.9.5
Re: [PATCH] drm/i915: support address only i2c-over-aux transactions
Quoted 8 lines · Jani Nikula
To support bare address requests used by the drm dp helpers.
Signed-off-by Jani Nikula <[email protected]>---
Hi Alex, similar to Thierry's patch for i915.
Looks good to me.
Do you want me to add this to the patch set?
Alex
Quoted 41 lines
BR,
Jani.--- drivers/gpu/drm/i915/intel_dp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpu/drm/i915/intel_dp.c +4
-4@@ -575,7 +575,8 @@ out:return ret; } -#define HEADER_SIZE 4 +#define BARE_ADDRESS_SIZE 3 +#define HEADER_SIZE (BARE_ADDRESS_SIZE + 1)static ssize_t intel_dp_aux_transfer (struct drm_dp_aux *aux,struct drm_dp_aux_msg *msg) {@@ -592,7 +593,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)switch (msg->request & ~DP_AUX_I2C_MOT ) {case DP_AUX_NATIVE_WRITE :case DP_AUX_I2C_WRITE : - txsize =HEADER_SIZE + msg->size; + txsize = msg->size ?HEADER_SIZE + msg->size :BARE_ADDRESS_SIZE ; rxsize =1 ;if (WARN_ON (txsize >20 ))@@ -611,7 +612,7 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)case DP_AUX_NATIVE_READ :case DP_AUX_I2C_READ : - txsize =HEADER_SIZE ; + txsize = msg->size ?HEADER_SIZE :BARE_ADDRESS_SIZE ; rxsize = msg->size +1 ;if (WARN_ON (rxsize >20 )) --1.7.9.5
Re: [PATCH] drm/i915: support address only i2c-over-aux transactions
Quoted 7 lines · Alex Deucher
Quoted 6 lines · Jani Nikula
To support bare address requests used by the drm dp helpers.
Signed-off-by Jani Nikula <[email protected]>---
Quoted 8 lines
Quoted 2 lines
Hi Alex, similar to Thierry's patch for i915.
Looks good to me.
Reviewed-by Alex Deucher <[email protected]>Do you want me to add this to the patch set?
Afaict we've done an unconditional msg_bytes = send_bytes + 4; in the i915 driver before the conversion to the dp aux helper, which is why I've slapped an r-b onto your patch without asking for a i915 adjustement. Otoh we have a pile of bugs for dp dongles still. Imo my preferred approach would be to get the helper + radeon stuff in and then hawk the i915 patch to a bunch of bug reporter and see whether it sticks. Ofc if we already know that we need it it would be best to merge it in one pull together with all your other patches.
Jani?
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH] drm/i915: support address only i2c-over-aux transactions
Quoted 26 lines · Daniel Vetter
Quoted 7 lines · Alex Deucher
Quoted 6 lines · Jani Nikula
To support bare address requests used by the drm dp helpers.
Signed-off-by Jani Nikula <[email protected]>---
Quoted 8 lines
Quoted 2 lines
Hi Alex, similar to Thierry's patch for i915.
Looks good to me.
Reviewed-by Alex Deucher <[email protected]>Do you want me to add this to the patch set?
Afaict we've done an unconditional
msg_bytes=send_bytes+ 4; in the i915 driver before the conversion to the dp aux helper, which is why I've slapped an r-b onto your patch without asking for a i915 adjustement. Otoh we have a pile of bugs for dp dongles still. Imo my preferred approach would be to get the helper + radeon stuff in and then hawk the i915 patch to a bunch of bug reporter and see whether it sticks. Ofc if we already know that we need it it would be best to merge it in one pull together with all your other patches.
Quoted 1 line
Jani?
Before the conversion to dp aux helpers there was a switch case [1] that ended up in msg_bytes = 3 for address only start/stop messages (MODE_I2C_START or MODE_I2C_STOP bit set [2]). With Alex's series in, but without my patch, we'd send the four byte header but with 0 - 1 = 0xff in txbuf[3]. I'm pretty sure breakage would follow.
Thus I'd like to have my patch in before the dp aux helpers use msg->size == 0 for address only messages.
Daniel, convinced yet?
BR,
Jani.
Quoted 9 lines
-Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Re: [PATCH] drm/i915: support address only i2c-over-aux transactions
Quoted 10 lines · Jani Nikula
Before the conversion to dp aux helpers there was a switch case [1] that ended up in
msg_bytes= 3 for address only start/stop messages (MODE_I2C_STARTorMODE_I2C_STOPbit set [2]). With Alex's series in, but without my patch, we'd send the four byte header but with 0 - 1 =0xffin txbuf[3]. I'm pretty sure breakage would follow.Thus I'd like to have my patch in before the dp aux helpers use
msg->size== 0 for address only messages.Daniel, convinced yet?
Indeed, I've been blinding. Acked for merging through radeon trees together with the other patches as a fixup for 3.15. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [Intel-gfx] [PATCH] drm/i915: support address only i2c-over-aux transactions
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Jani Nikula
Before the conversion to dp aux helpers there was a switch case [1] that ended up in
msg_bytes= 3 for address only start/stop messages (MODE_I2C_STARTorMODE_I2C_STOPbit set [2]). With Alex's series in, but without my patch, we'd send the four byte header but with 0 - 1 =0xffin txbuf[3]. I'm pretty sure breakage would follow.
Quoted 7 lines
Quoted 4 lines
Thus I'd like to have my patch in before the dp aux helpers use
msg->size== 0 for address only messages.Daniel, convinced yet?
Indeed, I've been blinding. Acked for merging through radeon trees together with the other patches as a fixup for 3.15.
Christian,
Can you pull this into the radeon 3.15 branch as well?
Thanks,
Alex
Re: [Intel-gfx] [PATCH] drm/i915: support address only i2c-over-aux transactions
Am 08.04.2014 15:04, schrieb Alex Deucher:
Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Jani Nikula
Quoted 9 lines
Before the conversion to dp aux helpers there was a switch case [1] that ended up in
msg_bytes= 3 for address only start/stop messages (MODE_I2C_STARTorMODE_I2C_STOPbit set [2]). With Alex's series in, but without my patch, we'd send the four byte header but with 0 - 1 =0xffin txbuf[3]. I'm pretty sure breakage would follow.Thus I'd like to have my patch in before the dp aux helpers use
msg->size== 0 for address only messages.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Daniel, convinced yet?
Indeed, I've been blinding. Acked for merging through radeon trees together with the other patches as a fixup for 3.15.
Christian,
Can you pull this into the radeon 3.15 branch as well?
Sure, directly before your other patches I would assume.
Going to send out the pull request to Dave this evening if nobody objects.
Christian.
Quoted 4 lines
Thanks,
Alex
Re: [Intel-gfx] [PATCH] drm/i915: support address only i2c-over-aux transactions
Quoted 21 lines · Christian König
Am 08.04.2014 15:04, schrieb Alex Deucher:
Quoted 19 lines · Daniel Vetter
Quoted 17 lines
Quoted 11 lines · Jani Nikula
Before the conversion to dp aux helpers there was a switch case [1] that ended up in
msg_bytes= 3 for address only start/stop messages (MODE_I2C_STARTorMODE_I2C_STOPbit set [2]). With Alex's series in, but without my patch, we'd send the four byte header but with 0 - 1 =0xffin txbuf[3]. I'm pretty sure breakage would follow.Thus I'd like to have my patch in before the dp aux helpers use
msg->size== 0 for address only messages.Daniel, convinced yet?
Indeed, I've been blinding. Acked for merging through radeon trees together with the other patches as a fixup for 3.15.
Quoted 6 lines
Quoted 3 lines
Christian,
Can you pull this into the radeon 3.15 branch as well?
Sure, directly before your other patches I would assume.
yes.
Quoted 3 lines
Going to send out the pull request to Dave this evening if nobody objects.
Sounds good to me.
Thanks!
Alex
Quoted 8 lines
Christian.
Quoted 4 lines
Thanks,
Alex
Am 07.04.2014 10:37, schrieb Thierry Reding:
Quoted 7 lines
From: Thierry Reding <[email protected]>
Certain types of I2C-over-AUX transactions require that only the address is transferred. Detect this by looking at the AUX message's size and set the address-only bit appropriately.
Signed-off-by Thierry Reding <[email protected]>
Quoted 8 lines
---
Hi Alex,This patch is required to make eDP work properly on Tegra with your I2C- over-AUX patch series applied. Would you consider carrying this in your series so that bisectability can be maintained? It would need to be applied prior to the core change (patch 2/4 in the latest series) to do so.
Hi Thierry,
do you already have this patch in drm-next or should I send it do Dave together with the pull request for the dp aux helper changes?
Regards,
Christian.
Quoted 119 lines
Thanks,
Thierrydrivers/gpu/drm/tegra/dpaux.c | 44 ++++++++++++++++++++++++++++++------------- drivers/gpu/drm/tegra/dpaux.h | 1 + 2 files changed, 32 insertions(+), 13 deletions(-)drivers/gpu/drm/tegra/dpaux.c +31
-13@@ -99,55 +99,73 @@ static void tegra_dpaux_read_fifo(struct tegra_dpaux *dpaux, u8 *buffer,static ssize_t tegra_dpaux_transfer (struct drm_dp_aux *aux,struct drm_dp_aux_msg *msg) { -unsigned long value =DPAUX_DP_AUXCTL_TRANSACTREQ ;unsigned long timeout =msecs_to_jiffies (250 );struct tegra_dpaux *dpaux =to_dpaux (aux);unsigned long status;ssize_t ret =0 ; +u32 value; -if (msg->size <1 || msg->size >16 ) +/* Tegra has 4x4 byte DP AUX transmit and receive FIFOs. */ +if (msg->size >16 )return -EINVAL ; -tegra_dpaux_writel (dpaux, msg->address,DPAUX_DP_AUXADDR ); +/* +* Allow zero-sized messages only for I2C, in which case they specify +* address-only transactions. +*/ +if (msg->size <1 ) { +switch (msg->request & ~DP_AUX_I2C_MOT ) { +case DP_AUX_I2C_WRITE : +case DP_AUX_I2C_READ : + value =DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY ; +break ; + +default : +return -EINVAL ; + } + }else { +/* For non-zero-sized messages, set the CMDLEN field. */ + value =DPAUX_DP_AUXCTL_CMDLEN (msg->size -1 ); + }switch (msg->request & ~DP_AUX_I2C_MOT ) {case DP_AUX_I2C_WRITE :if (msg->request &DP_AUX_I2C_MOT ) - value =DPAUX_DP_AUXCTL_CMD_MOT_WR ; + value |=DPAUX_DP_AUXCTL_CMD_MOT_WR ;else - value =DPAUX_DP_AUXCTL_CMD_I2C_WR ; + value |=DPAUX_DP_AUXCTL_CMD_I2C_WR ;break ;case DP_AUX_I2C_READ :if (msg->request &DP_AUX_I2C_MOT ) - value =DPAUX_DP_AUXCTL_CMD_MOT_RD ; + value |=DPAUX_DP_AUXCTL_CMD_MOT_RD ;else - value =DPAUX_DP_AUXCTL_CMD_I2C_RD ; + value |=DPAUX_DP_AUXCTL_CMD_I2C_RD ;break ;case DP_AUX_I2C_STATUS :if (msg->request &DP_AUX_I2C_MOT ) - value =DPAUX_DP_AUXCTL_CMD_MOT_RQ ; + value |=DPAUX_DP_AUXCTL_CMD_MOT_RQ ;else - value =DPAUX_DP_AUXCTL_CMD_I2C_RQ ; + value |=DPAUX_DP_AUXCTL_CMD_I2C_RQ ;break ;case DP_AUX_NATIVE_WRITE : - value =DPAUX_DP_AUXCTL_CMD_AUX_WR ; + value |=DPAUX_DP_AUXCTL_CMD_AUX_WR ;break ;case DP_AUX_NATIVE_READ : - value =DPAUX_DP_AUXCTL_CMD_AUX_RD ; + value |=DPAUX_DP_AUXCTL_CMD_AUX_RD ;break ;default :return -EINVAL ; } - value |=DPAUX_DP_AUXCTL_CMDLEN (msg->size -1 ); +tegra_dpaux_writel (dpaux, msg->address,DPAUX_DP_AUXADDR );tegra_dpaux_writel (dpaux, value,DPAUX_DP_AUXCTL );if ((msg->request &DP_AUX_I2C_READ ) ==0 ) {@@ -198,7 +216,7 @@ static ssize_t tegra_dpaux_transfer(struct drm_dp_aux *aux,break ; } -if (msg->reply ==DP_AUX_NATIVE_REPLY_ACK ) { +if ((msg->size >0 ) && (msg->reply ==DP_AUX_NATIVE_REPLY_ACK )) {if (msg->request &DP_AUX_I2C_READ ) {size_t count = value &DPAUX_DP_AUXSTAT_REPLY_MASK ;drivers/gpu/drm/tegra/dpaux.h +1
-0@@ -32,6 +32,7 @@#define DPAUX_DP_AUXCTL_CMD_I2C_RQ (2 << 12)#define DPAUX_DP_AUXCTL_CMD_I2C_RD (1 << 12)#define DPAUX_DP_AUXCTL_CMD_I2C_WR (0 << 12) +#define DPAUX_DP_AUXCTL_CMD_ADDRESS_ONLY (1 << 8)#define DPAUX_DP_AUXCTL_CMDLEN (x) ((x) & 0xff)#define DPAUX_DP_AUXSTAT 0x31
Quoted 19 lines · Christian König
Am 07.04.2014 10:37, schrieb Thierry Reding:
Quoted 7 lines
From: Thierry Reding <[email protected]>
Certain types of I2C-over-AUX transactions require that only the address is transferred. Detect this by looking at the AUX message's size and set the address-only bit appropriately.
Signed-off-by Thierry Reding <[email protected]>Quoted 8 lines
---
Hi Alex,This patch is required to make eDP work properly on Tegra with your I2C- over-AUX patch series applied. Would you consider carrying this in your series so that bisectability can be maintained? It would need to be applied prior to the core change (patch 2/4 in the latest series) to do so.
Quoted 4 lines
Hi Thierry,
do you already have this patch in drm-next or should I send it do Dave together with the pull request for the dp aux helper changes?
The patch is not in drm-next. To preserve bisectability it should be part of Alex' patch set and it needs to be applied before the patch that makes use of the bare address transactions (patch 2/4 in the series).
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel