staticvoid pnv_gmbus_clock_gating(struct intel_display *display, bool enable)
{ /* When using bit bashing for I2C, this bit needs to be set to 1 */
intel_de_rmw(display, DSPCLK_GATE_D(display),
PNV_GMBUSUNIT_CLOCK_GATE_DISABLE,
!enable ? PNV_GMBUSUNIT_CLOCK_GATE_DISABLE : 0);
}
/* On most chips, these bits must be preserved in software. */ if (!display->platform.i830 && !display->platform.i845g)
reserved = intel_de_read_notrace(display, bus->gpio_reg) &
(GPIO_DATA_PULLUP_DISABLE | GPIO_CLOCK_PULLUP_DISABLE);
/* Important: The hw handles only the first bit, so set only one! Since * we also need to check for NAKs besides the hw ready/idle signal, we * need to wake up periodically and check that ourselves.
*/ if (!has_gmbus_irq(display))
irq_en = 0;
if (burst_read) { /* * As per HW Spec, for 512Bytes need to read extra Byte and * Ignore the extra byte read.
*/ if (len == 512) {
extra_byte_added = true;
len++;
}
size = len % 256 + 256;
intel_de_write_fw(display, GMBUS0(display),
gmbus0_reg | GMBUS_BYTE_CNT_OVERRIDE);
}
ret = gmbus_wait(display, GMBUS_HW_RDY, GMBUS_HW_RDY_EN); if (ret) return ret;
val = intel_de_read_fw(display, GMBUS3(display)); do { if (extra_byte_added && len == 1) break;
*buf++ = val & 0xff;
val >>= 8;
} while (--len && ++loop < 4);
if (burst_read && len == size - 4) /* Reset the override bit */
intel_de_write_fw(display, GMBUS0(display), gmbus0_reg);
}
return 0;
}
/* * HW spec says that 512Bytes in Burst read need special treatment. * But it doesn't talk about other multiple of 256Bytes. And couldn't locate * an I2C target, which supports such a lengthy burst read too for experiments. * * So until things get clarified on HW support, to avoid the burst read length * in fold of 256Bytes except 512, max burst read length is fixed at 767Bytes.
*/ #define INTEL_GMBUS_BURST_READ_MAX_LEN 767U
/* * The gmbus controller can combine a 1 or 2 byte write with another read/write * that immediately follows it by using an "INDEX" cycle.
*/ staticbool
gmbus_is_index_xfer(struct i2c_msg *msgs, int i, int num)
{ return (i + 1 < num &&
msgs[i].addr == msgs[i + 1].addr &&
!(msgs[i].flags & I2C_M_RD) &&
(msgs[i].len == 1 || msgs[i].len == 2) &&
msgs[i + 1].len > 0);
}
for (; i < num; i += inc) {
inc = 1; if (gmbus_is_index_xfer(msgs, i, num)) {
ret = gmbus_index_xfer(display, &msgs[i],
gmbus0_source | bus->reg0);
inc = 2; /* an index transmission is two msgs */
} elseif (msgs[i].flags & I2C_M_RD) {
ret = gmbus_xfer_read(display, &msgs[i],
gmbus0_source | bus->reg0, 0);
} else {
ret = gmbus_xfer_write(display, &msgs[i], 0);
}
if (!ret)
ret = gmbus_wait(display,
GMBUS_HW_WAIT_PHASE, GMBUS_HW_WAIT_EN); if (ret == -ETIMEDOUT) goto timeout; elseif (ret) goto clear_err;
}
/* Generate a STOP condition on the bus. Note that gmbus can't generata * a STOP on the very first cycle. To simplify the code we * unconditionally generate the STOP condition with an additional gmbus
* cycle. */
intel_de_write_fw(display, GMBUS1(display), GMBUS_CYCLE_STOP | GMBUS_SW_RDY);
/* Mark the GMBUS interface as disabled after waiting for idle. * We will re-enable it at the start of the next xfer, * till then let it sleep.
*/ if (gmbus_wait_idle(display)) {
drm_dbg_kms(display->drm, "GMBUS [%s] timed out waiting for idle\n",
adapter->name);
ret = -ETIMEDOUT;
}
intel_de_write_fw(display, GMBUS0(display), 0);
ret = ret ?: i; goto out;
clear_err: /* * Wait for bus to IDLE before clearing NAK. * If we clear the NAK while bus is still active, then it will stay * active and the next transaction may fail. * * If no ACK is received during the address phase of a transaction, the * adapter must report -ENXIO. It is not clear what to return if no ACK * is received at other times. But we have to be careful to not return * spurious -ENXIO because that will prevent i2c and drm edid functions * from retrying. So return -ENXIO only when gmbus properly quiescents - * timing out seems to happen when there _is_ a ddc chip present, but * it's slow responding and only answers on the 2nd retry.
*/
ret = -ENXIO; if (gmbus_wait_idle(display)) {
drm_dbg_kms(display->drm, "GMBUS [%s] timed out after NAK\n",
adapter->name);
ret = -ETIMEDOUT;
}
/* Toggle the Software Clear Interrupt bit. This has the effect * of resetting the GMBUS controller and so clearing the * BUS_ERROR raised by the target's NAK.
*/
intel_de_write_fw(display, GMBUS1(display), GMBUS_SW_CLR_INT);
intel_de_write_fw(display, GMBUS1(display), 0);
intel_de_write_fw(display, GMBUS0(display), 0);
/* * Passive adapters sometimes NAK the first probe. Retry the first * message once on -ENXIO for GMBUS transfers; the bit banging algorithm * has retries internally. See also the retry loop in * drm_do_probe_ddc_edid, which bails out on the first -ENXIO.
*/ if (ret == -ENXIO && i == 0 && try++ == 0) {
drm_dbg_kms(display->drm, "GMBUS [%s] NAK on first message, retry\n",
adapter->name); goto retry;
}
goto out;
timeout:
drm_dbg_kms(display->drm, "GMBUS [%s] timed out, falling back to bit banging on pin %d\n",
bus->adapter.name, bus->reg0 & 0xff);
intel_de_write_fw(display, GMBUS0(display), 0);
/* * Hardware may not support GMBUS over these pins? Try GPIO bitbanging * instead. Use EAGAIN to have i2c core retry.
*/
ret = -EAGAIN;
out: /* Display WA #0868: skl,bxt,kbl,cfl,glk */ if (display->platform.geminilake || display->platform.broxton)
bxt_gmbus_clock_gating(display, true); elseif (HAS_PCH_SPT(display) || HAS_PCH_CNP(display))
pch_gmbus_clock_gating(display, true);
/* * In order to output Aksv to the receiver, use an indexed write to * pass the i2c command, and tell GMBUS to use the HW-provided value * instead of sourcing GMBUS3 for the data.
*/
ret = do_gmbus_xfer(adapter, msgs, ARRAY_SIZE(msgs), GMBUS_AKSV_SELECT);
/** * intel_gmbus_setup - instantiate all Intel i2c GMBuses * @display: display device
*/ int intel_gmbus_setup(struct intel_display *display)
{ struct pci_dev *pdev = to_pci_dev(display->drm->dev); unsignedint pin; int ret;
if (display->platform.valleyview || display->platform.cherryview)
display->gmbus.mmio_base = VLV_DISPLAY_BASE; elseif (!HAS_GMCH(display)) /* * Broxton uses the same PCH offsets for South Display Engine, * even though it doesn't have a PCH.
*/
display->gmbus.mmio_base = PCH_DISPLAY_BASE;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.