aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Deucher <alexander.deucher@amd.com>2013-08-07 19:34:53 -0400
committerAlex Deucher <alexander.deucher@amd.com>2013-08-30 16:30:38 -0400
commit4543eda52113d1e2cc0e9bf416f79597e6ef1ec7 (patch)
tree16ea2493eb505eaedd2c933348a1440d5e82aa7d
parent1bd4cff651350380f9fb6847313cb78e84c03846 (diff)
drm/radeon: fix endian bugs in hw i2c atom routines
Need to swap the data fetched over i2c properly. This is the same fix as the endian fix for aux channel transactions. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c6
-rw-r--r--drivers/gpu/drm/radeon/atombios_i2c.c4
2 files changed, 6 insertions, 4 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 32501f6ec991..16023986d301 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -50,7 +50,7 @@ static char *pre_emph_names[] = {
50 * or from atom. Note that atom operates on 50 * or from atom. Note that atom operates on
51 * dw units. 51 * dw units.
52 */ 52 */
53static void radeon_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le) 53void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
54{ 54{
55#ifdef __BIG_ENDIAN 55#ifdef __BIG_ENDIAN
56 u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */ 56 u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
@@ -100,7 +100,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
100 100
101 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1); 101 base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);
102 102
103 radeon_copy_swap(base, send, send_bytes, true); 103 radeon_atom_copy_swap(base, send, send_bytes, true);
104 104
105 args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4)); 105 args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4));
106 args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4)); 106 args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4));
@@ -137,7 +137,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
137 recv_bytes = recv_size; 137 recv_bytes = recv_size;
138 138
139 if (recv && recv_size) 139 if (recv && recv_size)
140 radeon_copy_swap(recv, base + 16, recv_bytes, false); 140 radeon_atom_copy_swap(recv, base + 16, recv_bytes, false);
141 141
142 return recv_bytes; 142 return recv_bytes;
143} 143}
diff --git a/drivers/gpu/drm/radeon/atombios_i2c.c b/drivers/gpu/drm/radeon/atombios_i2c.c
index 082338df708a..2ca389d19258 100644
--- a/drivers/gpu/drm/radeon/atombios_i2c.c
+++ b/drivers/gpu/drm/radeon/atombios_i2c.c
@@ -27,6 +27,8 @@
27#include "radeon.h" 27#include "radeon.h"
28#include "atom.h" 28#include "atom.h"
29 29
30extern void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
31
30#define TARGET_HW_I2C_CLOCK 50 32#define TARGET_HW_I2C_CLOCK 50
31 33
32/* these are a limitation of ProcessI2cChannelTransaction not the hw */ 34/* these are a limitation of ProcessI2cChannelTransaction not the hw */
@@ -77,7 +79,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
77 } 79 }
78 80
79 if (!(flags & HW_I2C_WRITE)) 81 if (!(flags & HW_I2C_WRITE))
80 memcpy(buf, base, num); 82 radeon_atom_copy_swap(buf, base, num, false);
81 83
82 return 0; 84 return 0;
83} 85}