cvmx-zip.c revision 215990
1/***********************license start*************** 2 * Copyright (c) 2003-2010 Cavium Networks (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 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 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 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**************************************/ 39 40 41 42 43 44 45 46/** 47 * @file 48 * 49 * Source file for the zip (deflate) block 50 * 51 * <hr>$Revision: 49448 $<hr> 52 */ 53 54#include "executive-config.h" 55#include "cvmx-config.h" 56#include "cvmx.h" 57#include "cvmx-cmd-queue.h" 58#include "cvmx-zip.h" 59 60#ifdef CVMX_ENABLE_PKO_FUNCTIONS 61 62/** 63 * Initialize the ZIP block 64 * 65 * @return Zero on success, negative on failure 66 */ 67int cvmx_zip_initialize(void) 68{ 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) 75 return -1; 76 77 zip_cmd_buf.u64 = 0; 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 */ 85 return 0; 86} 87 88/** 89 * Shutdown the ZIP block. ZIP must be idle when 90 * this function is called. 91 * 92 * @return Zero on success, negative on failure 93 */ 94int cvmx_zip_shutdown(void) 95{ 96 cvmx_zip_cmd_ctl_t zip_cmd_ctl; 97 98 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_ZIP)) 99 { 100 cvmx_dprintf("ERROR: cvmx_zip_shutdown: ZIP not idle.\n"); 101 return -1; 102 } 103 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); 107 cvmx_wait(100); 108 109 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_ZIP); 110 return 0; 111} 112 113/** 114 * Submit a command to the ZIP block 115 * 116 * @param command Zip command to submit 117 * 118 * @return Zero on success, negative on failure 119 */ 120int cvmx_zip_submit(cvmx_zip_command_t *command) 121{ 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); 125 return result; 126} 127 128#endif 129 130