Commit | Line | Data |
---|---|---|
60032381 JJ |
1 | /* |
2 | * Secure RPMB header for Exynos MMC 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 | ||
12 | #ifndef _MMC_SRPMB_H | |
13 | #define _MMC_SRPMB_H | |
14 | ||
15 | #define GET_WRITE_COUNTER 1 | |
16 | #define WRITE_DATA 2 | |
17 | #define READ_DATA 3 | |
18 | ||
19 | #define AUTHEN_KEY_PROGRAM_RES 0x0100 | |
20 | #define AUTHEN_KEY_PROGRAM_REQ 0x0001 | |
21 | #define RESULT_READ_REQ 0x0005 | |
22 | #define RPMB_END_ADDRESS 0x4000 | |
23 | ||
24 | #define RPMB_PACKET_SIZE 512 | |
25 | ||
26 | #define WRITE_COUNTER_DATA_LEN_ERROR 0x601 | |
27 | #define WRITE_COUNTER_SECURITY_OUT_ERROR 0x602 | |
28 | #define WRITE_COUNTER_SECURITY_IN_ERROR 0x603 | |
29 | #define WRITE_DATA_LEN_ERROR 0x604 | |
30 | #define WRITE_DATA_SECURITY_OUT_ERROR 0x605 | |
31 | #define WRITE_DATA_RESULT_SECURITY_OUT_ERROR 0x606 | |
32 | #define WRITE_DATA_SECURITY_IN_ERROR 0x607 | |
33 | #define READ_LEN_ERROR 0x608 | |
34 | #define READ_DATA_SECURITY_OUT_ERROR 0x609 | |
35 | #define READ_DATA_SECURITY_IN_ERROR 0x60A | |
36 | ||
37 | #define PASS_STATUS 0xBABA | |
38 | ||
39 | #define IS_INCLUDE_RPMB_DEVICE "0:0:0:1" | |
40 | ||
41 | #define ON 1 | |
42 | #define OFF 0 | |
43 | ||
44 | #define RPMB_BUF_MAX_SIZE 32 * 1024 | |
45 | #define RELIABLE_WRITE_REQ_SET (1 << 31) | |
46 | ||
47 | struct _mmc_rpmb_ctx { | |
48 | struct device *dev; | |
49 | int irq; | |
50 | void *wsm_virtaddr; | |
51 | dma_addr_t wsm_phyaddr; | |
52 | struct workqueue_struct *srpmb_queue; | |
53 | struct work_struct work; | |
54 | struct block_device *bdev; | |
55 | struct wake_lock wakelock; | |
56 | }; | |
57 | ||
58 | struct _mmc_rpmb_req { | |
59 | uint32_t cmd; | |
60 | ||
61 | volatile uint32_t status_flag; | |
62 | uint32_t type; | |
63 | uint32_t data_len; | |
64 | uint32_t inlen; | |
65 | uint32_t outlen; | |
66 | uint8_t rpmb_data[0]; | |
67 | }; | |
68 | ||
69 | struct rpmb_packet { | |
70 | u16 request; | |
71 | u16 result; | |
72 | u16 count; | |
73 | u16 address; | |
74 | u32 write_counter; | |
75 | u8 nonce[16]; | |
76 | u8 data[256]; | |
77 | u8 Key_MAC[32]; | |
78 | u8 stuff[196]; | |
79 | }; | |
80 | ||
81 | #endif |