1 /***********************license start***************
2 * Copyright (c) 2003-2008 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 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * Source file for the zip (deflate) block
49 * <hr>$Revision: 41586 $<hr>
52 #include "executive-config.h"
53 #include "cvmx-config.h"
55 #include "cvmx-cmd-queue.h"
58 #ifdef CVMX_ENABLE_PKO_FUNCTIONS
61 * Initialize the ZIP block
63 * @return Zero on success, negative on failure
65 int cvmx_zip_initialize(void)
67 cvmx_zip_cmd_buf_t zip_cmd_buf;
68 cvmx_cmd_queue_result_t result;
69 result = cvmx_cmd_queue_initialize(CVMX_CMD_QUEUE_ZIP, 0,
70 CVMX_FPA_OUTPUT_BUFFER_POOL,
71 CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE);
72 if (result != CVMX_CMD_QUEUE_SUCCESS)
76 zip_cmd_buf.s.dwb = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/128;
77 zip_cmd_buf.s.pool = CVMX_FPA_OUTPUT_BUFFER_POOL;
78 zip_cmd_buf.s.size = CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE/8;
79 zip_cmd_buf.s.ptr = cvmx_ptr_to_phys(cvmx_cmd_queue_buffer(CVMX_CMD_QUEUE_ZIP))>>7;
80 cvmx_write_csr(CVMX_ZIP_CMD_BUF, zip_cmd_buf.u64);
81 cvmx_write_csr(CVMX_ZIP_ERROR, 1);
82 cvmx_read_csr(CVMX_ZIP_CMD_BUF); /* Read to make sure setup is complete */
87 * Shutdown the ZIP block. ZIP must be idle when
88 * this function is called.
90 * @return Zero on success, negative on failure
92 int cvmx_zip_shutdown(void)
94 cvmx_zip_cmd_ctl_t zip_cmd_ctl;
96 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_ZIP))
98 cvmx_dprintf("ERROR: cvmx_zip_shutdown: ZIP not idle.\n");
102 zip_cmd_ctl.u64 = cvmx_read_csr(CVMX_ZIP_CMD_CTL);
103 zip_cmd_ctl.s.reset = 1;
104 cvmx_write_csr(CVMX_ZIP_CMD_CTL, zip_cmd_ctl.u64);
107 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_ZIP);
112 * Submit a command to the ZIP block
114 * @param command Zip command to submit
116 * @return Zero on success, negative on failure
118 int cvmx_zip_submit(cvmx_zip_command_t *command)
120 cvmx_cmd_queue_result_t result = cvmx_cmd_queue_write(CVMX_CMD_QUEUE_ZIP, 1, 8, command->u64);
121 if (result == CVMX_CMD_QUEUE_SUCCESS)
122 cvmx_write_csr(CVMX_ADDR_DID(CVMX_FULL_DID(7, 0)), 8);