aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/atsha204a-i2c.c
AgeCommit message (Collapse)Author
2024-03-05misc: atsha204a: fix wakeup functionMichał Barnaś
The ATSHA204A chip requires SDA line to go low for at least 60us to wake up the chip. Previous implementation did not meet this requirement due to the NAK received on bus and not sending the zeroes. The function to ignore the NAK and send bytes regardless is not supported in the u-boot making it impossible to wake up the chip this way. Instead, the bus speed, if needed, is set to lowest value and the message is sent to the address 0x0. This way, the address of zero makes the SDA line go low for about 80us, meeting the required time to wake up the chip. The zero length packet is not sent by the i2c, so the one byte is sent to the transfer function, but only the address is sent anyway. After sending the zero address, the bus speed is restored to the previous value if it was slowed down to wake up the chip. Signed-off-by: Michał Barnaś <barnas@google.com>
2024-03-05misc: atsha204a: fix sleep functionMichał Barnaś
Fix the sleep function to issue the sleep command instead of idle one. Signed-off-by: Michał Barnaś <barnas@google.com>
2024-03-05misc: atsha204a: remove broken for loopMichał Barnaś
Some previous commit changed the continue statement to return, making the for loop used to retry waking up the chip to always return after one iteration. This commit removes the loop, cleaning the code a little. Signed-off-by: Michał Barnaś <barnas@google.com>
2022-08-09misc: atsha204a: Don't check for error when waking up the devicePali Rohár
The device ignores any levels or transitions on the SCL pin when the device is idle, asleep or during waking up. Linux kernel driver for atsha204a (atmel-sha204a.ko) also ignores return value from i2c wakeup send command, see: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/crypto/atmel-i2c.c?h=v5.19#n174 And also userspace Turris libatsha204 library ignores return value from wakeup send command, see: https://gitlab.nic.cz/turris/libatsha204/-/blob/v29.2/src/libatsha204/layer_ni2c.c#L75-76 U-Boot driver should do same thing. Fixes waking up ATSHA204 on Turris 1.x boards. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Paweł Anikiel <pan@semihalf.com> Reviewed-by: Marek Behún <kabel@kernel.org>
2022-07-21treewide: Fix Marek's name and change my e-mail addressMarek Behún
Fix diacritics in some instances of my name and change my e-mail address to kabel@kernel.org. Add corresponding .mailmap entries. Signed-off-by: Marek Behún <kabel@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
2022-07-01misc: atsha204a: Increase wake delay by tWHIPaweł Anikiel
From the ATSHA204A datasheet (document DS40002025A): Wake: If SDA is held low for a period greater than tWLO, the device exits low-power mode and, after a delay of tWHI, is ready to receive I2C commands. tWHI value can be found in table 7-2. Signed-off-by: Paweł Anikiel <pan@semihalf.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-05-10misc: atsha204a: Add support for atsha204 chipPali Rohár
atsha204 chip is predecessor of atsha204a chip. Current U-Boot driver atsha204a-i2c.c can use both atsha204 and atsha204a chips because it does not call specific functions to just one of these chips. So just add compatible string for atsha204. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2022-04-21misc: atsha204a: Remove duplicate CRC-16 implementationPali Rohár
ATSHA204A uses bit-reversed checksum of standard CRC-16 with polynomial x^16 + x^15 + x^2 + 1. This ATSHA204A specific checksum can be calculated just by using common U-Boot functions bitrev16() and crc16(). So replace custom driver CRC-16 implementation by common U-Boot functions. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
2022-04-14misc: atsha204a: Fix big endian supportPali Rohár
Callers of function atsha204a_crc16() expect to return value in host cpu endianity. So remove cpu_to_le16() conversion. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2022-03-23misc: atsha204a: fix i2c address readout from DTSAdrian Fiergolski
This patch replaces use fdtdec_get_addr with simpler dev_read_addr(). fdtdec_get_addr doesn't work properly on ZynqMP-based (64bit) system. Although not confirmed, it could be related to the fact, that quoting the documentation, "This variant hard-codes the number of cells used to represent the address and size based on sizeof(fdt_addr_t) and sizeof(fdt_size_t)". Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2022-03-23misc: atsha204a: add delay after sending the messageAdrian Fiergolski
Once request is sent, and before receiving a response, the delay is required. This patch fixes missing delay for before first response try. Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2022-03-23misc: atsha204a: return timeout from wakeup functionAdrian Fiergolski
If the maximum number of wake-up attempts is exceeded, return -ETIMEDOUT. Signed-off-by: Adrian Fiergolski <adrian.fiergolski@fastree3d.com> Reviewed-by: Marek Behún <marek.behun@nic.cz>
2021-09-30WS cleanup: remove SPACE(s) followed by TABWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de>
2021-09-30WS cleanup: remove trailing white spaceWolfgang Denk
Signed-off-by: Wolfgang Denk <wd@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-02common: Drop asm/global_data.h from common headerSimon Glass
Move this out of the common header and include it only where needed. In a number of cases this requires adding "struct udevice;" to avoid adding another large header or in other cases replacing / adding missing header files that had been pulled in, very indirectly. Finally, we have a few cases where we did not need to include <asm/global_data.h> at all, so remove that include. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2020-12-13dm: treewide: Rename ofdata_to_platdata() to of_to_plat()Simon Glass
This name is far too long. Rename it to remove the 'data' bits. This makes it consistent with the platdata->plat rename. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-12-13dm: treewide: Rename auto_alloc_size members to be shorterSimon Glass
This construct is quite long-winded. In earlier days it made some sense since auto-allocation was a strange concept. But with driver model now used pretty universally, we can shorten this to 'auto'. This reduces verbosity and makes it easier to read. Coincidentally it also ensures that every declaration is on one line, thus making dtoc's job easier. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop linux/delay.h from common headerSimon Glass
Move this uncommon header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-05-18common: Drop log.h from common headerSimon Glass
Move this header out of the common header. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-12-02crc32: Use the crc.h header for crc functionsSimon Glass
Drop inclusion of crc.h in common.h and use the correct header directly instead. With this we can drop the conflicting definition in fw_env.h and rely on the crc.h header, which is already included. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2017-07-12drivers/misc: Add basic support for ATSHA204A Crypto moduleMarek Behún
This module can be found on the Turris Omnia board connected via the I2C interface. Among some cryptographic functions, the chip has a 512 bit One Time Programmable memory, 88 byte configuration memory and 512 byte general purpose memory. The Turris Omnia stores serial number and device MAC address in the OTP memory. This commit adds basic support for reading the EEPROM and also exposes the chips Random Number Generator. The driver is based on code by Josh Datko, Cryptotronix, jbd@cryptotronix.com and also Tomas Hlavacek, CZ.NIC, tomas.hlavacek@nic.cz Signed-off-by: Tomas Hlavacek <tomas.hlavacek@nic.cz> Signed-off-by: Marek Behun <marek.behun@nic.cz> create mode 100644 drivers/misc/atsha204a-i2c.c create mode 100644 include/atsha204a-i2c.h Signed-off-by: Stefan Roese <sr@denx.de>