crypto: stm32/hash - Support Ux500 hash
authorLinus Walleij <linus.walleij@linaro.org>
Wed, 25 Jan 2023 00:23:10 +0000 (01:23 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 3 Feb 2023 04:54:55 +0000 (12:54 +0800)
commitb56403a25af703064bed0d7e81d2c9ffb30511ff
treea0dd99c5e776a9a7cf0326aab1b40800c79d4fe6
parent5a2d52b54065c2aeb0012d050734ead78252215a
crypto: stm32/hash - Support Ux500 hash

The Ux500 has a hash block which is an ancestor to the STM32
hash block. With some minor code path additions we can
support also this variant in the STM32 driver. Differences:

- Ux500 only supports SHA1 and SHA256 (+/- MAC) so we split
  up the algorithm registration per-algorithm and register
  each algorithm along with its MAC variant separately.

- Ux500 does not have an interrupt to indicate that hash
  calculation is complete, so we add code paths to handle
  polling for completion if the interrupt is missing in the
  device tree.

- Ux500 is lacking the SR status register, to check if an
  operating is complete, we need to poll the HASH_STR_DCAL
  bit in the HASH_STR register instead.

- Ux500 had the resulting hash at address offset 0x0c and
  8 32bit registers ahead. We account for this with a special
  code path when reading out the hash digest.

- Ux500 need a special bit set in the control register before
  performing the final hash calculation on an empty message.

- Ux500 hashes on empty messages will be performed if the
  above bit is set, but are incorrect. For this reason we
  just make an inline synchronous hash using a fallback
  hash.

Tested on the Ux500 Golden device with the extended tests.

Acked-by: Lionel Debieve <lionel.debieve@foss.st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/stm32/stm32-hash.c