mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-17 15:38:51 +09:00
![Marek Behún](/assets/img/avatar_default.png)
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>
70 lines
1.5 KiB
C
70 lines
1.5 KiB
C
/*
|
|
* I2C Driver for Atmel ATSHA204 over I2C
|
|
*
|
|
* Copyright (C) 2014 Josh Datko, Cryptotronix, jbd@cryptotronix.com
|
|
* 2016 Tomas Hlavacek, CZ.NIC, tmshlvck@gmail.com
|
|
* 2017 Marek Behun, CZ.NIC, marek.behun@nic.cz
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
#ifndef _ATSHA204_I2C_H_
|
|
#define _ATSHA204_I2C_H_
|
|
|
|
enum atsha204a_zone
|
|
{
|
|
ATSHA204A_ZONE_CONFIG = 0,
|
|
ATSHA204A_ZONE_OTP = 1,
|
|
ATSHA204A_ZONE_DATA = 2,
|
|
};
|
|
|
|
enum atsha204a_status
|
|
{
|
|
ATSHA204A_STATUS_SUCCESS = 0x00,
|
|
ATSHA204A_STATUS_MISCOMPARE = 0x01,
|
|
ATSHA204A_STATUS_PARSE_ERROR = 0x03,
|
|
ATSHA204A_STATUS_EXEC_ERROR = 0x0F,
|
|
ATSHA204A_STATUS_AFTER_WAKE = 0x11,
|
|
ATSHA204A_STATUS_CRC_ERROR = 0xFF,
|
|
};
|
|
|
|
enum atsha204a_func
|
|
{
|
|
ATSHA204A_FUNC_RESET = 0x00,
|
|
ATSHA204A_FUNC_SLEEP = 0x01,
|
|
ATSHA204A_FUNC_IDLE = 0x02,
|
|
ATSHA204A_FUNC_COMMAND = 0x03,
|
|
};
|
|
|
|
enum atsha204a_cmd
|
|
{
|
|
ATSHA204A_CMD_READ = 0x02,
|
|
ATSHA204A_CMD_RANDOM = 0x1B,
|
|
};
|
|
|
|
struct atsha204a_resp
|
|
{
|
|
u8 length;
|
|
u8 code;
|
|
u8 data[82];
|
|
} __attribute__ ((packed));
|
|
|
|
struct atsha204a_req
|
|
{
|
|
u8 function;
|
|
u8 length;
|
|
u8 command;
|
|
u8 param1;
|
|
u16 param2;
|
|
u8 data[78];
|
|
} __attribute__ ((packed));
|
|
|
|
int atsha204a_wakeup(struct udevice *);
|
|
int atsha204a_idle(struct udevice *);
|
|
int atsha204a_sleep(struct udevice *);
|
|
int atsha204a_read(struct udevice *, enum atsha204a_zone, bool, u16, u8 *);
|
|
int atsha204a_get_random(struct udevice *, u8 *, size_t);
|
|
|
|
#endif /* _ATSHA204_I2C_H_ */
|