Lines Matching full:crc

54  * CRC routines adapted from public domain code written by Lammert Bies.
65 * CRC checking is enabled by default, but can be disabled at runtime
166 unsigned char use_crc; /* do crc checking for this command */
194 unsigned int crc_enabled; /* crc checking is enabled */
195 unsigned int crc_init_done; /* whether the initial crc setting has
205 unsigned int use_crc; /* command CRC checking */
267 update_crc7(uint8_t crc, uint8_t *buf, unsigned int len) in update_crc7() argument
273 tmp = (crc << 1) ^ buf[i]; in update_crc7()
274 crc = crc7tab[tmp]; in update_crc7()
277 return (crc); in update_crc7()
281 update_crc16(uint16_t crc, uint8_t *buf, unsigned int len) in update_crc16() argument
289 tmp = (crc >> 8) ^ c16; in update_crc16()
290 crc = (crc << 8) ^ crc16tab[tmp]; in update_crc16()
293 return (crc); in update_crc16()
302 uint8_t crc, c; in init_crc7tab() local
307 crc = (c & 0x80) ? c ^ P_CRC7 : c; in init_crc7tab()
310 crc = crc << 1; in init_crc7tab()
312 if (crc & 0x80) in init_crc7tab()
313 crc = crc ^ P_CRC7; in init_crc7tab()
316 crc7tab[i] = crc; in init_crc7tab()
326 uint16_t crc, c; in init_crc16tab() local
330 crc = 0; in init_crc16tab()
335 if ((crc ^ c) & 0x8000) crc = ( crc << 1 ) ^ P_CCITT; in init_crc16tab()
336 else crc = crc << 1; in init_crc16tab()
341 crc16tab[i] = crc; in init_crc16tab()
454 &sc->use_crc, sizeof(sc->use_crc), "Enable/disable crc checking"); in mmcspi_attach()
1185 uint8_t crc; in mmcspi_send_cmd() local
1212 crc = update_crc7(CRC7_INITIAL, &txbuf[1], 5); in mmcspi_send_cmd()
1214 crc = 0; in mmcspi_send_cmd()
1216 txbuf[6] = (crc << 1) | 0x01; in mmcspi_send_cmd()
1343 /* copy any crc captured in the poll buf to the crc buf */ in mmcspi_read_block()
1346 /* get any remaining crc */ in mmcspi_read_block()
1348 TRACE(dev, DETAILS, "crc bytes to read = %u\n", in mmcspi_read_block()
1354 TRACE(dev, ERROR, "spi read of crc failed\n"); in mmcspi_read_block()
1361 * The following crc checking code is deliberately structured to in mmcspi_read_block()
1362 * allow a passing crc-7 check to override a failing crc-16 check in mmcspi_read_block()
1435 * Retry stop commands that fail due to bad crc here because having in mmcspi_send_stop()
1450 /* retry on crc error */ in mmcspi_send_stop()
1462 * caller's retry-on-crc-error mechanism, effectively in mmcspi_send_stop()
1500 * The CID and CSD data blocks contain both a trailing crc-7 in mmcspi_read_phase()
1501 * inside the data block and the standard crc-16 following in mmcspi_read_phase()
1504 * When crc checking has been enabled via CMD59, some cards in mmcspi_read_phase()
1505 * send CID and CSD data blocks with correct crc-7 values in mmcspi_read_phase()
1506 * but incorrect crc-16 values. read_block will accept in mmcspi_read_phase()
1507 * those responses as valid as long as the crc-7 is correct. in mmcspi_read_phase()
1547 uint16_t crc; in mmcspi_write_block() local
1552 crc = update_crc16(CRC16_INITIAL, data, MMCSPI_DATA_BLOCK_LEN); in mmcspi_write_block()
1554 crc = 0; in mmcspi_write_block()
1556 TRACE(dev, ACTION, "write block(512) crc=0x%04x\n", crc); in mmcspi_write_block()
1565 txbuf[0] = crc >> 8; in mmcspi_write_block()
1566 txbuf[1] = crc & 0xff; in mmcspi_write_block()
1628 * A CRC error can't be ignored here, even if crc in mmcspi_write_phase()