blob: 274522afd621e202b1f78f34e0bd15f169b7ece7 [file] [log] [blame]
Tim Zimmermann6a834b72020-09-03 09:11:59 +02001/*
2 * Secure RPMB header for Exynos scsi rpmb
3 *
4 * Copyright (C) 2016 Samsung Electronics Co., Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef _SCSI_SRPMB_H
12#define _SCSI_SRPMB_H
13
14#include <linux/pm_wakeup.h>
15
16#define GET_WRITE_COUNTER 1
17#define WRITE_DATA 2
18#define READ_DATA 3
19
20#define AUTHEN_KEY_PROGRAM_RES 0x0100
21#define AUTHEN_KEY_PROGRAM_REQ 0x0001
22#define RESULT_READ_REQ 0x0005
23#define RPMB_END_ADDRESS 0x4000
24
25#define RPMB_PACKET_SIZE 512
26#define RPMB_REQRES 510
27#define RPMB_RESULT 508
28
29
30#define WRITE_COUTNER_DATA_LEN_ERROR 0x601
31#define WRITE_COUTNER_SECURITY_OUT_ERROR 0x602
32#define WRITE_COUTNER_SECURITY_IN_ERROR 0x603
33#define WRITE_DATA_LEN_ERROR 0x604
34#define WRITE_DATA_SECURITY_OUT_ERROR 0x605
35#define WRITE_DATA_RESULT_SECURITY_OUT_ERROR 0x606
36#define WRITE_DATA_SECURITY_IN_ERROR 0x607
37#define READ_LEN_ERROR 0x608
38#define READ_DATA_SECURITY_OUT_ERROR 0x609
39#define READ_DATA_SECURITY_IN_ERROR 0x60A
40#define RPMB_INVALID_COMMAND 0x60B
41#define RPMB_FAIL_SUSPEND_STATUS 0x60C
42
43#define RPMB_IN_PROGRESS 0xDCDC
44#define RPMB_PASSED 0xBABA
45
46#define IS_INCLUDE_RPMB_DEVICE "0:0:0:1"
47
48#define ON 1
49#define OFF 0
50
51#define RPMB_BUF_MAX_SIZE (32 * 1024)
52
53struct rpmb_irq_ctx {
54 struct device *dev;
55 int irq;
56 u8 *vir_addr;
57 dma_addr_t phy_addr;
58 struct work_struct work;
59 struct workqueue_struct *srpmb_queue;
60 struct notifier_block pm_notifier;
61 struct wakeup_source wakesrc;
62 spinlock_t lock;
63};
64
65struct rpmb_packet {
66 u16 request;
67 u16 result;
68 u16 count;
69 u16 address;
70 u32 write_counter;
71 u8 nonce[16];
72 u8 data[256];
73 u8 Key_MAC[32];
74 u8 stuff[196];
75};
76
77int init_wsm(struct device *dev);
78
79#endif /* _SCSI_SRPMB_H */