Deleted Added
full compact
octeon-feature.c (232812) octeon-feature.c (242342)
1/***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17
18 * * Neither the name of Cavium Inc. nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
21 * permission.
22
23 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
26 * countries.
27
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
39
40/**
41 * @file
42 *
43 * File defining checks for different Octeon features.
44 *
45 * <hr>$Revision: 1 $<hr>
46 */
47#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
48#include <linux/init.h>
49
50#include <asm/octeon/octeon.h>
51#else
52#include "cvmx.h"
53#endif
54
55CVMX_SHARED uint8_t octeon_feature_map[FEATURE_MAP_SIZE] __attribute__((aligned(128)));
56#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
57EXPORT_SYMBOL(octeon_feature_map);
58#else
59#define __init
60#endif
61
62/*
63 * Set the bit in octeon_feature_map for feature.
64 *
65 * @param feature
66 * @return 0 for success and nonzero for error.
67 */
68static int __init octeon_feature_set(octeon_feature_t feature)
69{
70 int bit, byte;
71
72 byte = feature >> 3;
73 bit = feature & 0x7;
74 octeon_feature_map[byte] |= (((uint8_t)1) << bit);
75
76 return 0;
77}
78
79void __init octeon_feature_init(void)
80{
81 octeon_feature_result_t val;
82
83 /*
84 * Check feature map size
85 */
86 if (OCTEON_MAX_FEATURE > (FEATURE_MAP_SIZE * 8 - 1))
87 {
88 val = OCTEON_FEATURE_MAP_OVERFLOW;
89 goto feature_check;
90 }
91
92 /*
93 * Feature settings
94 */
95#define OCTEON_FEATURE_SET(feature_x) \
96 if (old_octeon_has_feature(feature_x)) \
97 octeon_feature_set(feature_x)
98
99 OCTEON_FEATURE_SET(OCTEON_FEATURE_SAAD);
100 OCTEON_FEATURE_SET(OCTEON_FEATURE_ZIP);
101 OCTEON_FEATURE_SET(OCTEON_FEATURE_CRYPTO);
102 OCTEON_FEATURE_SET(OCTEON_FEATURE_DORM_CRYPTO);
103 OCTEON_FEATURE_SET(OCTEON_FEATURE_PCIE);
104 OCTEON_FEATURE_SET(OCTEON_FEATURE_SRIO);
105 OCTEON_FEATURE_SET(OCTEON_FEATURE_ILK);
106 OCTEON_FEATURE_SET(OCTEON_FEATURE_KEY_MEMORY);
107 OCTEON_FEATURE_SET(OCTEON_FEATURE_LED_CONTROLLER);
108 OCTEON_FEATURE_SET(OCTEON_FEATURE_TRA);
109 OCTEON_FEATURE_SET(OCTEON_FEATURE_MGMT_PORT);
110 OCTEON_FEATURE_SET(OCTEON_FEATURE_RAID);
111 OCTEON_FEATURE_SET(OCTEON_FEATURE_USB);
112 OCTEON_FEATURE_SET(OCTEON_FEATURE_NO_WPTR);
113 OCTEON_FEATURE_SET(OCTEON_FEATURE_DFA);
114 OCTEON_FEATURE_SET(OCTEON_FEATURE_MDIO_CLAUSE_45);
115 OCTEON_FEATURE_SET(OCTEON_FEATURE_NPEI);
116 OCTEON_FEATURE_SET(OCTEON_FEATURE_PKND);
117 OCTEON_FEATURE_SET(OCTEON_FEATURE_CN68XX_WQE);
118 OCTEON_FEATURE_SET(OCTEON_FEATURE_HFA);
119 OCTEON_FEATURE_SET(OCTEON_FEATURE_DFM);
120 OCTEON_FEATURE_SET(OCTEON_FEATURE_CIU2);
121 OCTEON_FEATURE_SET(OCTEON_FEATURE_DICI_MODE);
122 OCTEON_FEATURE_SET(OCTEON_FEATURE_BIT_EXTRACTOR);
123 OCTEON_FEATURE_SET(OCTEON_FEATURE_NAND);
124 OCTEON_FEATURE_SET(OCTEON_FEATURE_MMC);
125
126 val = OCTEON_FEATURE_SUCCESS;
127
128feature_check:
129
130 if (val != OCTEON_FEATURE_SUCCESS)
131 {
132 cvmx_dprintf("octeon_feature_init(): ");
133 switch (val)
134 {
135 case OCTEON_FEATURE_MAP_OVERFLOW:
136 cvmx_dprintf("feature map overflow.\n");
137 break;
138 default:
139 cvmx_dprintf("unknown error %d.\n", val);
140 break;
141 }
1/***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights
3 * reserved.
4 *
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17
18 * * Neither the name of Cavium Inc. nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
21 * permission.
22
23 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
26 * countries.
27
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
39
40/**
41 * @file
42 *
43 * File defining checks for different Octeon features.
44 *
45 * <hr>$Revision: 1 $<hr>
46 */
47#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
48#include <linux/init.h>
49
50#include <asm/octeon/octeon.h>
51#else
52#include "cvmx.h"
53#endif
54
55CVMX_SHARED uint8_t octeon_feature_map[FEATURE_MAP_SIZE] __attribute__((aligned(128)));
56#ifdef CVMX_BUILD_FOR_LINUX_KERNEL
57EXPORT_SYMBOL(octeon_feature_map);
58#else
59#define __init
60#endif
61
62/*
63 * Set the bit in octeon_feature_map for feature.
64 *
65 * @param feature
66 * @return 0 for success and nonzero for error.
67 */
68static int __init octeon_feature_set(octeon_feature_t feature)
69{
70 int bit, byte;
71
72 byte = feature >> 3;
73 bit = feature & 0x7;
74 octeon_feature_map[byte] |= (((uint8_t)1) << bit);
75
76 return 0;
77}
78
79void __init octeon_feature_init(void)
80{
81 octeon_feature_result_t val;
82
83 /*
84 * Check feature map size
85 */
86 if (OCTEON_MAX_FEATURE > (FEATURE_MAP_SIZE * 8 - 1))
87 {
88 val = OCTEON_FEATURE_MAP_OVERFLOW;
89 goto feature_check;
90 }
91
92 /*
93 * Feature settings
94 */
95#define OCTEON_FEATURE_SET(feature_x) \
96 if (old_octeon_has_feature(feature_x)) \
97 octeon_feature_set(feature_x)
98
99 OCTEON_FEATURE_SET(OCTEON_FEATURE_SAAD);
100 OCTEON_FEATURE_SET(OCTEON_FEATURE_ZIP);
101 OCTEON_FEATURE_SET(OCTEON_FEATURE_CRYPTO);
102 OCTEON_FEATURE_SET(OCTEON_FEATURE_DORM_CRYPTO);
103 OCTEON_FEATURE_SET(OCTEON_FEATURE_PCIE);
104 OCTEON_FEATURE_SET(OCTEON_FEATURE_SRIO);
105 OCTEON_FEATURE_SET(OCTEON_FEATURE_ILK);
106 OCTEON_FEATURE_SET(OCTEON_FEATURE_KEY_MEMORY);
107 OCTEON_FEATURE_SET(OCTEON_FEATURE_LED_CONTROLLER);
108 OCTEON_FEATURE_SET(OCTEON_FEATURE_TRA);
109 OCTEON_FEATURE_SET(OCTEON_FEATURE_MGMT_PORT);
110 OCTEON_FEATURE_SET(OCTEON_FEATURE_RAID);
111 OCTEON_FEATURE_SET(OCTEON_FEATURE_USB);
112 OCTEON_FEATURE_SET(OCTEON_FEATURE_NO_WPTR);
113 OCTEON_FEATURE_SET(OCTEON_FEATURE_DFA);
114 OCTEON_FEATURE_SET(OCTEON_FEATURE_MDIO_CLAUSE_45);
115 OCTEON_FEATURE_SET(OCTEON_FEATURE_NPEI);
116 OCTEON_FEATURE_SET(OCTEON_FEATURE_PKND);
117 OCTEON_FEATURE_SET(OCTEON_FEATURE_CN68XX_WQE);
118 OCTEON_FEATURE_SET(OCTEON_FEATURE_HFA);
119 OCTEON_FEATURE_SET(OCTEON_FEATURE_DFM);
120 OCTEON_FEATURE_SET(OCTEON_FEATURE_CIU2);
121 OCTEON_FEATURE_SET(OCTEON_FEATURE_DICI_MODE);
122 OCTEON_FEATURE_SET(OCTEON_FEATURE_BIT_EXTRACTOR);
123 OCTEON_FEATURE_SET(OCTEON_FEATURE_NAND);
124 OCTEON_FEATURE_SET(OCTEON_FEATURE_MMC);
125
126 val = OCTEON_FEATURE_SUCCESS;
127
128feature_check:
129
130 if (val != OCTEON_FEATURE_SUCCESS)
131 {
132 cvmx_dprintf("octeon_feature_init(): ");
133 switch (val)
134 {
135 case OCTEON_FEATURE_MAP_OVERFLOW:
136 cvmx_dprintf("feature map overflow.\n");
137 break;
138 default:
139 cvmx_dprintf("unknown error %d.\n", val);
140 break;
141 }
142#if !defined(CVMX_BUILD_FOR_LINUX_KERNEL) && !defined(__U_BOOT__) && !defined(CVMX_BUILD_FOR_TOOLCHAIN)
142#if !defined(CVMX_BUILD_FOR_LINUX_KERNEL) && !defined(__U_BOOT__) && !defined(CVMX_BUILD_FOR_TOOLCHAIN) && !defined(CVMX_BUILD_FOR_FREEBSD_KERNEL)
143 exit (1);
144#endif
145 }
146}
143 exit (1);
144#endif
145 }
146}