aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2015-02-19 18:21:36 -0500
committerAlex Deucher <alexander.deucher@amd.com>2015-03-19 12:26:44 -0400
commit875711f0e217b00cba1a851eee01c4e33041a91c (patch)
tree94b7f9745a466d224b3030f1a0b6a18f94c92d48
parentfd99a0943ffaa0320ea4f69d09ed188f950c0432 (diff)
drm/radeon: program auxch directly (v2)
The atombios tables have an unfortunate restriction on only being able to write 12 bytes, MST really wants 16-bytes here, and since the hw can do it, we should just write directly to it. This uses a module option to allow for it now, and maybe we should provide the old code as a fallback for a while. v2: (agd5f) - move registers to a proper register header - only enable on DCE5+ - enable by default on DCE5+ - Switch pad to aux mode before using it - reformat instance handling to better match the rest of the driver Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/radeon/Makefile2
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c13
-rw-r--r--drivers/gpu/drm/radeon/nid.h46
-rw-r--r--drivers/gpu/drm/radeon/radeon.h1
-rw-r--r--drivers/gpu/drm/radeon/radeon_dp_auxch.c206
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h3
7 files changed, 272 insertions, 3 deletions
diff --git a/drivers/gpu/drm/radeon/Makefile b/drivers/gpu/drm/radeon/Makefile
index 4605633e253b..fa635f09bb0f 100644
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -81,7 +81,7 @@ radeon-y += radeon_device.o radeon_asic.o radeon_kms.o \
81 rv770_smc.o cypress_dpm.o btc_dpm.o sumo_dpm.o sumo_smc.o trinity_dpm.o \ 81 rv770_smc.o cypress_dpm.o btc_dpm.o sumo_dpm.o sumo_smc.o trinity_dpm.o \
82 trinity_smc.o ni_dpm.o si_smc.o si_dpm.o kv_smc.o kv_dpm.o ci_smc.o \ 82 trinity_smc.o ni_dpm.o si_smc.o si_dpm.o kv_smc.o kv_dpm.o ci_smc.o \
83 ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o \ 83 ci_dpm.o dce6_afmt.o radeon_vm.o radeon_ucode.o radeon_ib.o \
84 radeon_sync.o radeon_audio.o 84 radeon_sync.o radeon_audio.o radeon_dp_auxch.o
85 85
86radeon-$(CONFIG_MMU_NOTIFIER) += radeon_mn.o 86radeon-$(CONFIG_MMU_NOTIFIER) += radeon_mn.o
87 87
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 8d74de82456e..a014c7bfa764 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -158,7 +158,7 @@ done:
158#define HEADER_SIZE (BARE_ADDRESS_SIZE + 1) 158#define HEADER_SIZE (BARE_ADDRESS_SIZE + 1)
159 159
160static ssize_t 160static ssize_t
161radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) 161radeon_dp_aux_transfer_atom(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
162{ 162{
163 struct radeon_i2c_chan *chan = 163 struct radeon_i2c_chan *chan =
164 container_of(aux, struct radeon_i2c_chan, aux); 164 container_of(aux, struct radeon_i2c_chan, aux);
@@ -226,11 +226,20 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
226 226
227void radeon_dp_aux_init(struct radeon_connector *radeon_connector) 227void radeon_dp_aux_init(struct radeon_connector *radeon_connector)
228{ 228{
229 struct drm_device *dev = radeon_connector->base.dev;
230 struct radeon_device *rdev = dev->dev_private;
229 int ret; 231 int ret;
230 232
231 radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd; 233 radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd;
232 radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; 234 radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev;
233 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer; 235 if (ASIC_IS_DCE5(rdev)) {
236 if (radeon_auxch)
237 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_native;
238 else
239 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_atom;
240 } else {
241 radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_atom;
242 }
234 243
235 ret = drm_dp_aux_register(&radeon_connector->ddc_bus->aux); 244 ret = drm_dp_aux_register(&radeon_connector->ddc_bus->aux);
236 if (!ret) 245 if (!ret)
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index 2e5cdc4e98a1..3b290838918c 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -816,6 +816,52 @@
816#define MC_PMG_CMD_MRS2 0x2b5c 816#define MC_PMG_CMD_MRS2 0x2b5c
817#define MC_SEQ_PMG_CMD_MRS2_LP 0x2b60 817#define MC_SEQ_PMG_CMD_MRS2_LP 0x2b60
818 818
819#define AUX_CONTROL 0x6200
820#define AUX_EN (1 << 0)
821#define AUX_LS_READ_EN (1 << 8)
822#define AUX_LS_UPDATE_DISABLE(x) (((x) & 0x1) << 12)
823#define AUX_HPD_DISCON(x) (((x) & 0x1) << 16)
824#define AUX_DET_EN (1 << 18)
825#define AUX_HPD_SEL(x) (((x) & 0x7) << 20)
826#define AUX_IMPCAL_REQ_EN (1 << 24)
827#define AUX_TEST_MODE (1 << 28)
828#define AUX_DEGLITCH_EN (1 << 29)
829#define AUX_SW_CONTROL 0x6204
830#define AUX_SW_GO (1 << 0)
831#define AUX_LS_READ_TRIG (1 << 2)
832#define AUX_SW_START_DELAY(x) (((x) & 0xf) << 4)
833#define AUX_SW_WR_BYTES(x) (((x) & 0x1f) << 16)
834
835#define AUX_SW_INTERRUPT_CONTROL 0x620c
836#define AUX_SW_DONE_INT (1 << 0)
837#define AUX_SW_DONE_ACK (1 << 1)
838#define AUX_SW_DONE_MASK (1 << 2)
839#define AUX_SW_LS_DONE_INT (1 << 4)
840#define AUX_SW_LS_DONE_MASK (1 << 6)
841#define AUX_SW_STATUS 0x6210
842#define AUX_SW_DONE (1 << 0)
843#define AUX_SW_REQ (1 << 1)
844#define AUX_SW_RX_TIMEOUT_STATE(x) (((x) & 0x7) << 4)
845#define AUX_SW_RX_TIMEOUT (1 << 7)
846#define AUX_SW_RX_OVERFLOW (1 << 8)
847#define AUX_SW_RX_HPD_DISCON (1 << 9)
848#define AUX_SW_RX_PARTIAL_BYTE (1 << 10)
849#define AUX_SW_NON_AUX_MODE (1 << 11)
850#define AUX_SW_RX_MIN_COUNT_VIOL (1 << 12)
851#define AUX_SW_RX_INVALID_STOP (1 << 14)
852#define AUX_SW_RX_SYNC_INVALID_L (1 << 17)
853#define AUX_SW_RX_SYNC_INVALID_H (1 << 18)
854#define AUX_SW_RX_INVALID_START (1 << 19)
855#define AUX_SW_RX_RECV_NO_DET (1 << 20)
856#define AUX_SW_RX_RECV_INVALID_H (1 << 22)
857#define AUX_SW_RX_RECV_INVALID_V (1 << 23)
858
859#define AUX_SW_DATA 0x6218
860#define AUX_SW_DATA_RW (1 << 0)
861#define AUX_SW_DATA_MASK(x) (((x) & 0xff) << 8)
862#define AUX_SW_DATA_INDEX(x) (((x) & 0x1f) << 16)
863#define AUX_SW_AUTOINCREMENT_DISABLE (1 << 31)
864
819#define LB_SYNC_RESET_SEL 0x6b28 865#define LB_SYNC_RESET_SEL 0x6b28
820#define LB_SYNC_RESET_SEL_MASK (3 << 0) 866#define LB_SYNC_RESET_SEL_MASK (3 << 0)
821#define LB_SYNC_RESET_SEL_SHIFT 0 867#define LB_SYNC_RESET_SEL_SHIFT 0
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 88bcada6d133..26a339b1b2cd 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -111,6 +111,7 @@ extern int radeon_deep_color;
111extern int radeon_use_pflipirq; 111extern int radeon_use_pflipirq;
112extern int radeon_bapm; 112extern int radeon_bapm;
113extern int radeon_backlight; 113extern int radeon_backlight;
114extern int radeon_auxch;
114 115
115/* 116/*
116 * Copy from radeon_drv.h so we don't have to include both and have conflicting 117 * Copy from radeon_drv.h so we don't have to include both and have conflicting
diff --git a/drivers/gpu/drm/radeon/radeon_dp_auxch.c b/drivers/gpu/drm/radeon/radeon_dp_auxch.c
new file mode 100644
index 000000000000..bf1fecc6cceb
--- /dev/null
+++ b/drivers/gpu/drm/radeon/radeon_dp_auxch.c
@@ -0,0 +1,206 @@
1/*
2 * Copyright 2015 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Dave Airlie
23 */
24#include <drm/drmP.h>
25#include <drm/radeon_drm.h>
26#include "radeon.h"
27#include "nid.h"
28
29#define AUX_RX_ERROR_FLAGS (AUX_SW_RX_OVERFLOW | \
30 AUX_SW_RX_HPD_DISCON | \
31 AUX_SW_RX_PARTIAL_BYTE | \
32 AUX_SW_NON_AUX_MODE | \
33 AUX_SW_RX_MIN_COUNT_VIOL | \
34 AUX_SW_RX_INVALID_STOP | \
35 AUX_SW_RX_SYNC_INVALID_L | \
36 AUX_SW_RX_SYNC_INVALID_H | \
37 AUX_SW_RX_INVALID_START | \
38 AUX_SW_RX_RECV_NO_DET | \
39 AUX_SW_RX_RECV_INVALID_H | \
40 AUX_SW_RX_RECV_INVALID_V)
41
42#define AUX_SW_REPLY_GET_BYTE_COUNT(x) (((x) >> 24) & 0x1f)
43
44#define BARE_ADDRESS_SIZE 3
45
46static const u32 aux_offset[] =
47{
48 0x6200 - 0x6200,
49 0x6250 - 0x6200,
50 0x62a0 - 0x6200,
51 0x6300 - 0x6200,
52 0x6350 - 0x6200,
53 0x63a0 - 0x6200,
54};
55
56ssize_t
57radeon_dp_aux_transfer_native(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
58{
59 struct radeon_i2c_chan *chan =
60 container_of(aux, struct radeon_i2c_chan, aux);
61 struct drm_device *dev = chan->dev;
62 struct radeon_device *rdev = dev->dev_private;
63 int ret = 0, i;
64 uint32_t tmp, ack = 0;
65 int instance = chan->rec.i2c_id & 0xf;
66 u8 byte;
67 u8 *buf = msg->buffer;
68 int retry_count = 0;
69 int bytes;
70 int msize;
71 bool is_write = false;
72
73 if (WARN_ON(msg->size > 16))
74 return -E2BIG;
75
76 switch (msg->request & ~DP_AUX_I2C_MOT) {
77 case DP_AUX_NATIVE_WRITE:
78 case DP_AUX_I2C_WRITE:
79 is_write = true;
80 break;
81 case DP_AUX_NATIVE_READ:
82 case DP_AUX_I2C_READ:
83 break;
84 default:
85 return -EINVAL;
86 }
87
88 /* work out two sizes required */
89 msize = 0;
90 bytes = BARE_ADDRESS_SIZE;
91 if (msg->size) {
92 msize = msg->size - 1;
93 bytes++;
94 if (is_write)
95 bytes += msg->size;
96 }
97
98 mutex_lock(&chan->mutex);
99
100 /* switch the pad to aux mode */
101 tmp = RREG32(chan->rec.mask_clk_reg);
102 tmp |= (1 << 16);
103 WREG32(chan->rec.mask_clk_reg, tmp);
104
105 /* setup AUX control register with correct HPD pin */
106 tmp = RREG32(AUX_CONTROL + aux_offset[instance]);
107
108 tmp &= AUX_HPD_SEL(0x7);
109 tmp |= AUX_HPD_SEL(chan->rec.hpd);
110 tmp |= AUX_EN | AUX_LS_READ_EN;
111
112 WREG32(AUX_CONTROL + aux_offset[instance], tmp);
113
114 /* atombios appears to write this twice lets copy it */
115 WREG32(AUX_SW_CONTROL + aux_offset[instance],
116 AUX_SW_WR_BYTES(bytes));
117 WREG32(AUX_SW_CONTROL + aux_offset[instance],
118 AUX_SW_WR_BYTES(bytes));
119
120 /* write the data header into the registers */
121 /* request, addres, msg size */
122 byte = (msg->request << 4);
123 WREG32(AUX_SW_DATA + aux_offset[instance],
124 AUX_SW_DATA_MASK(byte) | AUX_SW_AUTOINCREMENT_DISABLE);
125
126 byte = (msg->address >> 8) & 0xff;
127 WREG32(AUX_SW_DATA + aux_offset[instance],
128 AUX_SW_DATA_MASK(byte));
129
130 byte = msg->address & 0xff;
131 WREG32(AUX_SW_DATA + aux_offset[instance],
132 AUX_SW_DATA_MASK(byte));
133
134 byte = msize;
135 WREG32(AUX_SW_DATA + aux_offset[instance],
136 AUX_SW_DATA_MASK(byte));
137
138 /* if we are writing - write the msg buffer */
139 if (is_write) {
140 for (i = 0; i < msg->size; i++) {
141 WREG32(AUX_SW_DATA + aux_offset[instance],
142 AUX_SW_DATA_MASK(buf[i]));
143 }
144 }
145
146 /* clear the ACK */
147 WREG32(AUX_SW_INTERRUPT_CONTROL + aux_offset[instance], AUX_SW_DONE_ACK);
148
149 /* write the size and GO bits */
150 WREG32(AUX_SW_CONTROL + aux_offset[instance],
151 AUX_SW_WR_BYTES(bytes) | AUX_SW_GO);
152
153 /* poll the status registers - TODO irq support */
154 do {
155 tmp = RREG32(AUX_SW_STATUS + aux_offset[instance]);
156 if (tmp & AUX_SW_DONE) {
157 break;
158 }
159 usleep_range(100, 200);
160 } while (retry_count++ < 1000);
161
162 if (retry_count >= 1000) {
163 DRM_ERROR("auxch hw never signalled completion, error %08x\n", tmp);
164 ret = -EIO;
165 goto done;
166 }
167
168 if (tmp & AUX_SW_RX_TIMEOUT) {
169 DRM_DEBUG_KMS("dp_aux_ch timed out\n");
170 ret = -ETIMEDOUT;
171 goto done;
172 }
173 if (tmp & AUX_RX_ERROR_FLAGS) {
174 DRM_DEBUG_KMS("dp_aux_ch flags not zero: %08x\n", tmp);
175 ret = -EIO;
176 goto done;
177 }
178
179 bytes = AUX_SW_REPLY_GET_BYTE_COUNT(tmp);
180 if (bytes) {
181 WREG32(AUX_SW_DATA + aux_offset[instance],
182 AUX_SW_DATA_RW | AUX_SW_AUTOINCREMENT_DISABLE);
183
184 tmp = RREG32(AUX_SW_DATA + aux_offset[instance]);
185 ack = (tmp >> 8) & 0xff;
186
187 for (i = 0; i < bytes - 1; i++) {
188 tmp = RREG32(AUX_SW_DATA + aux_offset[instance]);
189 if (buf)
190 buf[i] = (tmp >> 8) & 0xff;
191 }
192 if (buf)
193 ret = bytes - 1;
194 }
195
196 WREG32(AUX_SW_INTERRUPT_CONTROL + aux_offset[instance], AUX_SW_DONE_ACK);
197
198 if (is_write)
199 ret = msg->size;
200done:
201 mutex_unlock(&chan->mutex);
202
203 if (ret >= 0)
204 msg->reply = ack >> 4;
205 return ret;
206}
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 3b00690112b2..b088507057da 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -190,6 +190,7 @@ int radeon_deep_color = 0;
190int radeon_use_pflipirq = 2; 190int radeon_use_pflipirq = 2;
191int radeon_bapm = -1; 191int radeon_bapm = -1;
192int radeon_backlight = -1; 192int radeon_backlight = -1;
193int radeon_auxch = -1;
193 194
194MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers"); 195MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers");
195module_param_named(no_wb, radeon_no_wb, int, 0444); 196module_param_named(no_wb, radeon_no_wb, int, 0444);
@@ -275,6 +276,9 @@ module_param_named(bapm, radeon_bapm, int, 0444);
275MODULE_PARM_DESC(backlight, "backlight support (1 = enable, 0 = disable, -1 = auto)"); 276MODULE_PARM_DESC(backlight, "backlight support (1 = enable, 0 = disable, -1 = auto)");
276module_param_named(backlight, radeon_backlight, int, 0444); 277module_param_named(backlight, radeon_backlight, int, 0444);
277 278
279MODULE_PARM_DESC(auxch, "Use native auxch experimental support (1 = enable, 0 = disable, -1 = auto)");
280module_param_named(auxch, radeon_auxch, int, 0444);
281
278static struct pci_device_id pciidlist[] = { 282static struct pci_device_id pciidlist[] = {
279 radeon_PCI_IDS 283 radeon_PCI_IDS
280}; 284};
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index 664825c01aa6..60043bfdcbd7 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -722,6 +722,9 @@ extern int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
722extern void radeon_dp_set_rx_power_state(struct drm_connector *connector, 722extern void radeon_dp_set_rx_power_state(struct drm_connector *connector,
723 u8 power_state); 723 u8 power_state);
724extern void radeon_dp_aux_init(struct radeon_connector *radeon_connector); 724extern void radeon_dp_aux_init(struct radeon_connector *radeon_connector);
725extern ssize_t
726radeon_dp_aux_transfer_native(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);
727
725extern void atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mode); 728extern void atombios_dig_encoder_setup(struct drm_encoder *encoder, int action, int panel_mode);
726extern void radeon_atom_encoder_init(struct radeon_device *rdev); 729extern void radeon_atom_encoder_init(struct radeon_device *rdev);
727extern void radeon_atom_disp_eng_pll_init(struct radeon_device *rdev); 730extern void radeon_atom_disp_eng_pll_init(struct radeon_device *rdev);