1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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
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**************************************/
49 * Interface to RAID block. This is not available on all chips.
51 * <hr>$Revision: 70030 $<hr>
53 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
54 #include <linux/module.h>
55 #include <asm/octeon/cvmx.h>
56 #include <asm/octeon/cvmx-config.h>
57 #include <asm/octeon/cvmx-cmd-queue.h>
58 #include <asm/octeon/cvmx-raid.h>
60 #include "executive-config.h"
61 #include "cvmx-config.h"
63 #include "cvmx-cmd-queue.h"
64 #include "cvmx-raid.h"
67 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
70 * Initialize the RAID block
72 * @param polynomial Coefficients for the RAID polynomial
74 * @return Zero on success, negative on failure
76 int cvmx_raid_initialize(cvmx_rad_reg_polynomial_t polynomial)
78 cvmx_cmd_queue_result_t result;
79 cvmx_rad_reg_cmd_buf_t rad_reg_cmd_buf;
81 cvmx_write_csr(CVMX_RAD_REG_POLYNOMIAL, polynomial.u64);
83 result = cvmx_cmd_queue_initialize(CVMX_CMD_QUEUE_RAID, 0,
84 CVMX_FPA_OUTPUT_BUFFER_POOL,
85 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE);
86 if (result != CVMX_CMD_QUEUE_SUCCESS)
89 rad_reg_cmd_buf.u64 = 0;
90 rad_reg_cmd_buf.s.dwb = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/128;
91 rad_reg_cmd_buf.s.pool = CVMX_FPA_OUTPUT_BUFFER_POOL;
92 rad_reg_cmd_buf.s.size = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/8;
93 rad_reg_cmd_buf.s.ptr = cvmx_ptr_to_phys(cvmx_cmd_queue_buffer(CVMX_CMD_QUEUE_RAID))>>7;
94 cvmx_write_csr(CVMX_RAD_REG_CMD_BUF, rad_reg_cmd_buf.u64);
97 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
98 EXPORT_SYMBOL(cvmx_raid_initialize);
102 * Shutdown the RAID block. RAID must be idle when
103 * this function is called.
105 * @return Zero on success, negative on failure
107 int cvmx_raid_shutdown(void)
109 cvmx_rad_reg_ctl_t rad_reg_ctl;
111 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_RAID))
113 cvmx_dprintf("ERROR: cvmx_raid_shutdown: RAID not idle.\n");
117 rad_reg_ctl.u64 = cvmx_read_csr(CVMX_RAD_REG_CTL);
118 rad_reg_ctl.s.reset = 1;
119 cvmx_write_csr(CVMX_RAD_REG_CTL, rad_reg_ctl.u64);
122 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_RAID);
123 cvmx_write_csr(CVMX_RAD_REG_CMD_BUF, 0);
126 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
127 EXPORT_SYMBOL(cvmx_raid_shutdown);
131 * Submit a command to the RAID block
133 * @param num_words Number of command words to submit
134 * @param words Command words
136 * @return Zero on success, negative on failure
138 int cvmx_raid_submit(int num_words, cvmx_raid_word_t words[])
140 cvmx_cmd_queue_result_t result = cvmx_cmd_queue_write(CVMX_CMD_QUEUE_RAID, 1, num_words, (uint64_t *)words);
141 if (result == CVMX_CMD_QUEUE_SUCCESS)
142 cvmx_write_csr(CVMX_ADDR_DID(CVMX_FULL_DID(14, 0)), num_words);
145 #ifdef CVMX_BUILD_FOR_LINUX_KERNEL
146 EXPORT_SYMBOL(cvmx_raid_submit);