1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Networks (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 Networks 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 NETWORKS 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 * Source file for the zip (deflate) block
51 * <hr>$Revision: 49448 $<hr>
54 #include "executive-config.h"
55 #include "cvmx-config.h"
57 #include "cvmx-cmd-queue.h"
60 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
63 * Initialize the ZIP block
65 * @return Zero on success, negative on failure
67 int cvmx_zip_initialize(void)
69 cvmx_zip_cmd_buf_t zip_cmd_buf;
70 cvmx_cmd_queue_result_t result;
71 result = cvmx_cmd_queue_initialize(CVMX_CMD_QUEUE_ZIP, 0,
72 CVMX_FPA_OUTPUT_BUFFER_POOL,
73 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE);
74 if (result != CVMX_CMD_QUEUE_SUCCESS)
78 zip_cmd_buf.s.dwb = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/128;
79 zip_cmd_buf.s.pool = CVMX_FPA_OUTPUT_BUFFER_POOL;
80 zip_cmd_buf.s.size = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/8;
81 zip_cmd_buf.s.ptr = cvmx_ptr_to_phys(cvmx_cmd_queue_buffer(CVMX_CMD_QUEUE_ZIP))>>7;
82 cvmx_write_csr(CVMX_ZIP_CMD_BUF, zip_cmd_buf.u64);
83 cvmx_write_csr(CVMX_ZIP_ERROR, 1);
84 cvmx_read_csr(CVMX_ZIP_CMD_BUF); /* Read to make sure setup is complete */
89 * Shutdown the ZIP block. ZIP must be idle when
90 * this function is called.
92 * @return Zero on success, negative on failure
94 int cvmx_zip_shutdown(void)
96 cvmx_zip_cmd_ctl_t zip_cmd_ctl;
98 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_ZIP))
100 cvmx_dprintf("ERROR: cvmx_zip_shutdown: ZIP not idle.\n");
104 zip_cmd_ctl.u64 = cvmx_read_csr(CVMX_ZIP_CMD_CTL);
105 zip_cmd_ctl.s.reset = 1;
106 cvmx_write_csr(CVMX_ZIP_CMD_CTL, zip_cmd_ctl.u64);
109 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_ZIP);
114 * Submit a command to the ZIP block
116 * @param command Zip command to submit
118 * @return Zero on success, negative on failure
120 int cvmx_zip_submit(cvmx_zip_command_t *command)
122 cvmx_cmd_queue_result_t result = cvmx_cmd_queue_write(CVMX_CMD_QUEUE_ZIP, 1, 8, command->u64);
123 if (result == CVMX_CMD_QUEUE_SUCCESS)
124 cvmx_write_csr(CVMX_ADDR_DID(CVMX_FULL_DID(7, 0)), 8);