/* * Check LiteX CSR read/write access * * This function reads and writes a scratch register in order to verify if CSR * access works. * * In case any problems are detected, the driver should panic. * * Access to the LiteX CSR is, by design, done in CPU native endianness. * The driver should not dynamically configure access functions when * the endianness mismatch is detected. Such situation indicates problems in * the soft SoC design and should be solved at the LiteX generator level, * not in the software.
*/ staticint litex_check_csr_access(void __iomem *reg_addr)
{ unsignedlong reg;
reg = litex_read32(reg_addr + SCRATCH_REG_OFF);
if (reg != SCRATCH_REG_VALUE) {
panic("Scratch register read error - the system is probably broken! Expected: 0x%x but got: 0x%lx",
SCRATCH_REG_VALUE, reg); return -EINVAL;
}
if (reg != SCRATCH_TEST_VALUE) {
panic("Scratch register write error - the system is probably broken! Expected: 0x%x but got: 0x%lx",
SCRATCH_TEST_VALUE, reg); return -EINVAL;
}
/* restore original value of the SCRATCH register */
litex_write32(reg_addr + SCRATCH_REG_OFF, SCRATCH_REG_VALUE);
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.