cvmx-zip.c revision 210284
1/***********************license start*************** 2 * Copyright (c) 2003-2008 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 * 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. 33 * 34 * 35 * For any questions regarding licensing please contact marketing@caviumnetworks.com 36 * 37 ***********************license end**************************************/ 38 39 40 41 42 43 44/** 45 * @file 46 * 47 * Source file for the zip (deflate) block 48 * 49 * <hr>$Revision: 41586 $<hr> 50 */ 51 52#include "executive-config.h" 53#include "cvmx-config.h" 54#include "cvmx.h" 55#include "cvmx-cmd-queue.h" 56#include "cvmx-zip.h" 57 58#ifdef CVMX_ENABLE_PKO_FUNCTIONS 59 60/** 61 * Initialize the ZIP block 62 * 63 * @return Zero on success, negative on failure 64 */ 65int cvmx_zip_initialize(void) 66{ 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) 73 return -1; 74 75 zip_cmd_buf.u64 = 0; 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 */ 83 return 0; 84} 85 86/** 87 * Shutdown the ZIP block. ZIP must be idle when 88 * this function is called. 89 * 90 * @return Zero on success, negative on failure 91 */ 92int cvmx_zip_shutdown(void) 93{ 94 cvmx_zip_cmd_ctl_t zip_cmd_ctl; 95 96 if (cvmx_cmd_queue_length(CVMX_CMD_QUEUE_ZIP)) 97 { 98 cvmx_dprintf("ERROR: cvmx_zip_shutdown: ZIP not idle.\n"); 99 return -1; 100 } 101 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); 105 cvmx_wait(100); 106 107 cvmx_cmd_queue_shutdown(CVMX_CMD_QUEUE_ZIP); 108 return 0; 109} 110 111/** 112 * Submit a command to the ZIP block 113 * 114 * @param command Zip command to submit 115 * 116 * @return Zero on success, negative on failure 117 */ 118int cvmx_zip_submit(cvmx_zip_command_t *command) 119{ 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); 123 return result; 124} 125 126#endif 127 128