1 /****************************************************************************
2 * (C) Copyright 2008 Samsung Electronics Co., Ltd., All rights reserved
4 * @file s3c-otg-hcdi-memory.h
5 * @brief header of s3c-otg-hcdi-memory \n
7 * -# Jun 9,2008 v1.0 by SeungSoo Yang (ss1.yang@samsung.com) \n
8 * : Creating the initial version of this code \n
9 * -# Jul 15,2008 v1.2 by SeungSoo Yang (ss1.yang@samsung.com) \n
10 * : Optimizing for performance \n
12 ****************************************************************************/
13 /****************************************************************************
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 ****************************************************************************/
29 #ifndef _S3C_OTG_HCDI_MEMORY_H_
30 #define _S3C_OTG_HCDI_MEMORY_H_
37 #include "s3c-otg-common-common.h"
38 #include "s3c-otg-hcdi-debug.h"
40 #include <linux/kernel.h>
41 #include <linux/slab.h>
44 * @enum otg_mem_alloc_flag
46 * @brief enumeration for flag of memory allocation
49 enum otg_mem_alloc_flag
51 USB_MEM_SYNC, USB_MEM_ASYNC, USB_MEM_DMA
52 }otg_mem_alloc_flag_t;
53 //---------------------------------------------------------------------------------------
56 inline int otg_mem_alloc(void ** addr_pp, u16 byte_size, otg_mem_alloc_flag_t type);
57 inline int otg_mem_copy(void * to_addr_p, void * from_addr_p, u16 byte_size);
58 //inline int otg_mem_free(void * addr_p);
59 inline int otg_mem_set(void * addr_p, char value, u16 byte_size);
63 * int otg_mem_alloc(void ** addr_pp, u16 byte_size, u8 ubType);
65 * @brief allocating momory specified
67 * @param [inout] addr_pp : address to be assigned
68 * [in] byte_size : size of memory
69 * [in] type : otg_mem_alloc_flag_t type
71 * @return USB_ERR_SUCCESS : If success \n
72 * USB_ERR_FAIL : If call fail \n
78 otg_mem_alloc_flag_t type
82 otg_dbg(OTG_DBG_OTGHCDI_MEM, "otg_mem_alloc \n");
95 otg_err(OTG_DBG_OTGHCDI_MEM,
96 "not proper otg_mem_alloc_flag_t in otg_mem_alloc \n");
100 *addr_pp = kmalloc((size_t)byte_size, flags);
102 otg_err(OTG_DBG_OTGHCDI_MEM,
106 return USB_ERR_SUCCESS;
108 //-------------------------------------------------------------------------------
111 * int otg_mem_copy(void * to_addr_p, void * from_addr_p, u16 byte_size);
115 * @param [in] to_addr_p : target address
116 * [in] from_addr_p : source address
117 * [in] byte_size : size
119 * @return USB_ERR_SUCCESS : If success \n
120 * USB_ERR_FAIL : If call fail \n
130 otg_dbg(OTG_DBG_OTGHCDI_MEM,
133 memcpy(to_addr_p, from_addr_p, (size_t)byte_size);
135 return USB_ERR_SUCCESS;
137 //-------------------------------------------------------------------------------
140 * int otg_mem_free(void * addr_p);
142 * @brief de-allocating memory
144 * @param [in] addr_p : target address to be de-allocated
146 * @return USB_ERR_SUCCESS : If success \n
147 * USB_ERR_FAIL : If call fail \n
150 otg_mem_free(void * addr_p)
152 otg_dbg(OTG_DBG_OTGHCDI_MEM,
155 return USB_ERR_SUCCESS;
158 //-------------------------------------------------------------------------------
161 * int otg_mem_set(void * addr_p, char value, u16 byte_size)
163 * @brief writing a value to memory
165 * @param [in] addr_p : target address
166 * [in] value : value to be written
167 * [in] byte_size : size
169 * @return USB_ERR_SUCCESS : If success \n
170 * USB_ERR_FAIL : If call fail \n
180 otg_dbg(OTG_DBG_OTGHCDI_MEM,
182 memset(addr_p, value, (size_t)byte_size);
183 return USB_ERR_SUCCESS;
185 //-------------------------------------------------------------------------------
191 #endif /* _S3C_OTG_HCDI_MEMORY_H_ */