diff options
author | Peter Maydell | 2021-01-25 12:52:00 +0100 |
---|---|---|
committer | Peter Maydell | 2021-01-25 12:52:00 +0100 |
commit | 55d98950a642d3526a0b2e1e106744b007c8adf6 (patch) | |
tree | 4027ce91bb81ea35a74852d4182b02a081334043 /include/qemu | |
parent | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210124' into... (diff) | |
parent | hw/sd: sd.h: Cosmetic change of using spaces (diff) | |
download | qemu-55d98950a642d3526a0b2e1e106744b007c8adf6.tar.gz qemu-55d98950a642d3526a0b2e1e106744b007c8adf6.tar.xz qemu-55d98950a642d3526a0b2e1e106744b007c8adf6.zip |
Merge remote-tracking branch 'remotes/philmd-gitlab/tags/sdmmc-20210124' into staging
SD/MMC patches
- Various improvements for SD cards in SPI mode (Bin Meng)
# gpg: Signature made Sun 24 Jan 2021 19:16:55 GMT
# gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE
# gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <f4bug@amsat.org>" [full]
# Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE
* remotes/philmd-gitlab/tags/sdmmc-20210124:
hw/sd: sd.h: Cosmetic change of using spaces
hw/sd: ssi-sd: Use macros for the dummy value and tokens in the transfer
hw/sd: ssi-sd: Fix the wrong command index for STOP_TRANSMISSION
hw/sd: ssi-sd: Add a state representing Nac
hw/sd: ssi-sd: Suffix a data block with CRC16
util: Add CRC16 (CCITT) calculation routines
hw/sd: sd: Drop sd_crc16()
hw/sd: sd: Support CMD59 for SPI mode
hw/sd: ssi-sd: Fix incorrect card response sequence
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include/qemu')
-rw-r--r-- | include/qemu/crc-ccitt.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/qemu/crc-ccitt.h b/include/qemu/crc-ccitt.h new file mode 100644 index 0000000000..06ee55b159 --- /dev/null +++ b/include/qemu/crc-ccitt.h @@ -0,0 +1,33 @@ +/* + * CRC16 (CCITT) Checksum Algorithm + * + * Copyright (c) 2021 Wind River Systems, Inc. + * + * Author: + * Bin Meng <bin.meng@windriver.com> + * + * From Linux kernel v5.10 include/linux/crc-ccitt.h + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef _CRC_CCITT_H +#define _CRC_CCITT_H + +extern uint16_t const crc_ccitt_table[256]; +extern uint16_t const crc_ccitt_false_table[256]; + +extern uint16_t crc_ccitt(uint16_t crc, const uint8_t *buffer, size_t len); +extern uint16_t crc_ccitt_false(uint16_t crc, const uint8_t *buffer, size_t len); + +static inline uint16_t crc_ccitt_byte(uint16_t crc, const uint8_t c) +{ + return (crc >> 8) ^ crc_ccitt_table[(crc ^ c) & 0xff]; +} + +static inline uint16_t crc_ccitt_false_byte(uint16_t crc, const uint8_t c) +{ + return (crc << 8) ^ crc_ccitt_false_table[(crc >> 8) ^ c]; +} + +#endif /* _CRC_CCITT_H */ |