blob: d0e5986107b7f26776a41c1501184f43bf83d576 [file] [log] [blame]
Ziyuan Xu48890e22016-10-27 19:07:35 +08001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Ziyuan Xu4060cfd2017-02-10 11:54:52 +08007#include <cdn_dp.h>
8#include <smcc.h>
Ziyuan Xu48890e22016-10-27 19:07:35 +08009#include <stdlib.h>
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080010#include <string.h>
Ziyuan Xu48890e22016-10-27 19:07:35 +080011
12__asm__(
13 ".pushsection .text.hdcp_handler, \"ax\", %progbits\n"
14 ".global hdcp_handler\n"
15 ".balign 4\n"
16 "hdcp_handler:\n"
17 ".incbin \"" __XSTRING(HDCPFW) "\"\n"
18 ".type hdcp_handler, %function\n"
19 ".size hdcp_handler, .- hdcp_handler\n"
20 ".popsection\n"
21);
22
Ziyuan Xu4060cfd2017-02-10 11:54:52 +080023static uint64_t *hdcp_key_pdata;
24static struct cdn_dp_hdcp_key_1x key;
25
26int hdcp_handler(struct cdn_dp_hdcp_key_1x *key);
27
28uint64_t dp_hdcp_ctrl(uint64_t type)
29{
30 switch (type) {
31 case HDCP_KEY_DATA_START_TRANSFER:
32 memset(&key, 0x00, sizeof(key));
33 hdcp_key_pdata = (uint64_t *)&key;
34 return 0;
35 case HDCP_KEY_DATA_START_DECRYPT:
36 if (hdcp_key_pdata == (uint64_t *)(&key + 1))
37 return hdcp_handler(&key);
38 else
39 return PSCI_E_INVALID_PARAMS;
40 default:
41 return SMC_UNK;
42 }
43}
44
45uint64_t dp_hdcp_store_key(uint64_t x1,
46 uint64_t x2,
47 uint64_t x3,
48 uint64_t x4,
49 uint64_t x5,
50 uint64_t x6)
51{
52 if (hdcp_key_pdata < (uint64_t *)&key ||
53 hdcp_key_pdata + 6 > (uint64_t *)(&key + 1))
54 return PSCI_E_INVALID_PARAMS;
55
56 hdcp_key_pdata[0] = x1;
57 hdcp_key_pdata[1] = x2;
58 hdcp_key_pdata[2] = x3;
59 hdcp_key_pdata[3] = x4;
60 hdcp_key_pdata[4] = x5;
61 hdcp_key_pdata[5] = x6;
62 hdcp_key_pdata += 6;
63
64 return 0;
65}