link/graphics: New state machine

This is a new state machine. It is more programmatic, in the
case of auxio, and has much more symbolic naming, and very few
"magic" numbers, except in the case of undocumented settings.

As before, the 'pre-computed' IO ops are encoded in the iodefs
table. A function, run, is passed and index into the table and
runs the ops.

A new operator, I, has been added. When the I operator is hit,
run() returns the index of the next operator in the table.

The i915lightup function runs the table. All the AUX channel ops
have been removed from the table, however, and are now called as
functions, using the previously committed auxio function.

The iodefs table has been grouped into blocks of ops, which end in
an I operator. As the lightup function progresses through startup,
and the run() returns, the lightup function performs aux channel
operations.

This code is symbolic enough, I hope, that it will make haswell
graphics bringup simpler.

i915io.c, and the core of the code in i915lightup.c, were
programatically generated, starting with IO logs from the DRM
startup code in the kernel. It is possible to apply the tools that
do this generation to newer IO logs from the kernel.

Change-Id: I8a8e121dc0d9674f0c6a866343b28e179a1e3d8a
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-on: http://review.coreboot.org/2836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Ronald G. Minnich
2013-03-05 17:07:40 -08:00
committed by Stefan Reinauer
parent ec2d914e19
commit a95a13bd47
5 changed files with 757 additions and 555 deletions

View File

@@ -32,8 +32,9 @@
#include "i915io.h"
u32
pack_aux(u8 *src, int src_bytes)
pack_aux(u32 *src32, int src_bytes)
{
u8 *src = (u8 *)src32;
int i;
u32 v = 0;
@@ -45,8 +46,10 @@ pack_aux(u8 *src, int src_bytes)
}
void
unpack_aux(u32 src, u8 *dst, int dst_bytes)
unpack_aux(u32 src, u32 *dst32, int dst_bytes)
{
u8 *dst = (u8 *)dst32;
int i;
if (dst_bytes > 4)
dst_bytes = 4;
@@ -55,8 +58,8 @@ unpack_aux(u32 src, u8 *dst, int dst_bytes)
}
int
intel_dp_aux_ch(u32 ch_ctl, u32 ch_data, u8 *send, int send_bytes,
u8 *recv, int recv_size)
intel_dp_aux_ch(u32 ch_ctl, u32 ch_data, u32 *send, int send_bytes,
u32 *recv, int recv_size)
{
int i;
int recv_bytes;
@@ -93,11 +96,10 @@ intel_dp_aux_ch(u32 ch_ctl, u32 ch_data, u8 *send, int send_bytes,
for (try = 0; try < 5; try++) {
/* Load the send data into the aux channel data registers */
for (i = 0; i < send_bytes; i += 4)
io_i915_WRITE32(ch_data + i,
pack_aux(send + i, send_bytes - i));
io_i915_WRITE32(send[i], ch_data + i);
/* Send the command and wait for it to complete */
io_i915_WRITE32(ch_ctl,
io_i915_WRITE32(
DP_AUX_CH_CTL_SEND_BUSY |
DP_AUX_CH_CTL_TIME_OUT_400us |
(send_bytes << DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT) |
@@ -105,7 +107,7 @@ intel_dp_aux_ch(u32 ch_ctl, u32 ch_data, u8 *send, int send_bytes,
(aux_clock_divider << DP_AUX_CH_CTL_BIT_CLOCK_2X_SHIFT) |
DP_AUX_CH_CTL_DONE |
DP_AUX_CH_CTL_TIME_OUT_ERROR |
DP_AUX_CH_CTL_RECEIVE_ERROR);
DP_AUX_CH_CTL_RECEIVE_ERROR, ch_ctl);
for (;;) {
status = io_i915_READ32(ch_ctl);
if ((status & DP_AUX_CH_CTL_SEND_BUSY) == 0)
@@ -114,11 +116,11 @@ intel_dp_aux_ch(u32 ch_ctl, u32 ch_data, u8 *send, int send_bytes,
}
/* Clear done status and any errors */
io_i915_WRITE32(ch_ctl,
io_i915_WRITE32(
status |
DP_AUX_CH_CTL_DONE |
DP_AUX_CH_CTL_TIME_OUT_ERROR |
DP_AUX_CH_CTL_RECEIVE_ERROR);
DP_AUX_CH_CTL_RECEIVE_ERROR, ch_ctl);
if (status & (DP_AUX_CH_CTL_TIME_OUT_ERROR |
DP_AUX_CH_CTL_RECEIVE_ERROR))