1 
2 /***********************license start***************
3  * Copyright (c) 2003-2010  Cavium Inc. ([email protected]). All rights
4  * reserved.
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met:
10  *
11  *   * Redistributions of source code must retain the above copyright
12  *     notice, this list of conditions and the following disclaimer.
13  *
14  *   * Redistributions in binary form must reproduce the above
15  *     copyright notice, this list of conditions and the following
16  *     disclaimer in the documentation and/or other materials provided
17  *     with the distribution.
18 
19  *   * Neither the name of Cavium Inc. nor the names of
20  *     its contributors may be used to endorse or promote products
21  *     derived from this software without specific prior written
22  *     permission.
23 
24  * This Software, including technical data, may be subject to U.S. export  control
25  * laws, including the U.S. Export Administration Act and its  associated
26  * regulations, and may be subject to export or import  regulations in other
27  * countries.
28 
29  * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
30  * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
31  * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
32  * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
33  * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
34  * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
35  * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
36  * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
37  * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE  RISK ARISING OUT OF USE OR
38  * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
39  ***********************license end**************************************/
40 
41 
42 /**
43  * @file
44  *
45  * Helper utilities for enabling crypto.
46  *
47  * <hr>$Revision: $<hr>
48  */
49 #include "executive-config.h"
50 #include "cvmx-config.h"
51 #include "cvmx.h"
52 
cvmx_crypto_dormant_enable(uint64_t key)53 int cvmx_crypto_dormant_enable(uint64_t key)
54 {
55     if (octeon_has_feature(OCTEON_FEATURE_CRYPTO))
56         return 1;
57 
58     if (octeon_has_feature(OCTEON_FEATURE_DORM_CRYPTO)) {
59         cvmx_rnm_eer_key_t v;
60         v.s.key = key;
61         cvmx_write_csr(CVMX_RNM_EER_KEY, v.u64);
62     }
63 
64     return octeon_has_feature(OCTEON_FEATURE_CRYPTO);
65 }
66 
cvmx_crypto_dormant_dbg(void)67 uint64_t cvmx_crypto_dormant_dbg(void)
68 {
69     cvmx_rnm_eer_dbg_t dbg;
70 
71     if (!octeon_has_feature(OCTEON_FEATURE_DORM_CRYPTO))
72         return 0;
73 
74     dbg.u64 = cvmx_read_csr(CVMX_RNM_EER_DBG);
75     return dbg.s.dat;
76 }
77 
78 
79