| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include <linux/kernel.h> |
| 24 |
#include <linux/module.h> |
| 25 |
#include <linux/slab.h> |
| 26 |
#include <linux/hrtimer.h> |
| 27 |
|
| 28 |
#include <dahdi/kernel.h> |
| 29 |
|
| 30 |
#include "oct612x.h" |
| 31 |
|
| 32 |
UINT32 Oct6100UserGetTime(tPOCT6100_GET_TIME f_pTime) |
| 33 |
{ |
| 34 |
|
| 35 |
u64 total_usecs; |
| 36 |
|
| 37 |
total_usecs = ktime_to_us(ktime_get_real()); |
| 38 |
f_pTime->aulWallTimeUs[0] = total_usecs; |
| 39 |
f_pTime->aulWallTimeUs[1] = total_usecs >> 32; |
| 40 |
return cOCT6100_ERR_OK; |
| 41 |
} |
| 42 |
|
| 43 |
UINT32 Oct6100UserMemSet(PVOID f_pAddress, UINT32 f_ulPattern, |
| 44 |
UINT32 f_ulLength) |
| 45 |
{ |
| 46 |
memset(f_pAddress, f_ulPattern, f_ulLength); |
| 47 |
return cOCT6100_ERR_OK; |
| 48 |
} |
| 49 |
|
| 50 |
UINT32 Oct6100UserMemCopy(PVOID f_pDestination, const void *f_pSource, |
| 51 |
UINT32 f_ulLength) |
| 52 |
{ |
| 53 |
memcpy(f_pDestination, f_pSource, f_ulLength); |
| 54 |
return cOCT6100_ERR_OK; |
| 55 |
} |
| 56 |
|
| 57 |
UINT32 Oct6100UserCreateSerializeObject( |
| 58 |
tPOCT6100_CREATE_SERIALIZE_OBJECT f_pCreate) |
| 59 |
{ |
| 60 |
struct oct612x_context *context = f_pCreate->pProcessContext; |
| 61 |
struct mutex *lock = kzalloc(sizeof(*lock), GFP_KERNEL); |
| 62 |
if (!lock) { |
| 63 |
dev_err(context->dev, "Out of memory in %s.\n", __func__); |
| 64 |
return cOCT6100_ERR_BASE; |
| 65 |
} |
| 66 |
mutex_init(lock); |
| 67 |
f_pCreate->ulSerialObjHndl = lock; |
| 68 |
return cOCT6100_ERR_OK; |
| 69 |
} |
| 70 |
|
| 71 |
UINT32 Oct6100UserDestroySerializeObject( |
| 72 |
tPOCT6100_DESTROY_SERIALIZE_OBJECT f_pDestroy) |
| 73 |
{ |
| 74 |
struct mutex *lock = f_pDestroy->ulSerialObjHndl; |
| 75 |
kfree(lock); |
| 76 |
return cOCT6100_ERR_OK; |
| 77 |
} |
| 78 |
|
| 79 |
UINT32 Oct6100UserSeizeSerializeObject( |
| 80 |
tPOCT6100_SEIZE_SERIALIZE_OBJECT f_pSeize) |
| 81 |
{ |
| 82 |
struct mutex *lock = f_pSeize->ulSerialObjHndl; |
| 83 |
mutex_lock(lock); |
| 84 |
return cOCT6100_ERR_OK; |
| 85 |
} |
| 86 |
|
| 87 |
UINT32 Oct6100UserReleaseSerializeObject( |
| 88 |
tPOCT6100_RELEASE_SERIALIZE_OBJECT f_pRelease) |
| 89 |
{ |
| 90 |
struct mutex *lock = f_pRelease->ulSerialObjHndl; |
| 91 |
mutex_unlock(lock); |
| 92 |
return cOCT6100_ERR_OK; |
| 93 |
} |
| 94 |
|
| 95 |
UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams) |
| 96 |
{ |
| 97 |
struct oct612x_context *context = f_pWriteParams->pProcessContext; |
| 98 |
#ifdef OCTASIC_DEBUG |
| 99 |
if (!context || !context->ops || !context->ops->write) { |
| 100 |
pr_debug("Invalid call to %s\n", __func__); |
| 101 |
return cOCT6100_ERR_BASE; |
| 102 |
} |
| 103 |
#endif |
| 104 |
context->ops->write(context, f_pWriteParams->ulWriteAddress, |
| 105 |
f_pWriteParams->usWriteData); |
| 106 |
return cOCT6100_ERR_OK; |
| 107 |
} |
| 108 |
|
| 109 |
UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParams) |
| 110 |
{ |
| 111 |
struct oct612x_context *context = f_pSmearParams->pProcessContext; |
| 112 |
#ifdef OCTASIC_DEBUG |
| 113 |
if (!context || !context->ops || !context->ops->write_smear) { |
| 114 |
pr_debug("Invalid call to %s\n", __func__); |
| 115 |
return cOCT6100_ERR_BASE; |
| 116 |
} |
| 117 |
#endif |
| 118 |
context->ops->write_smear(context, f_pSmearParams->ulWriteAddress, |
| 119 |
f_pSmearParams->usWriteData, |
| 120 |
f_pSmearParams->ulWriteLength); |
| 121 |
return cOCT6100_ERR_OK; |
| 122 |
} |
| 123 |
|
| 124 |
UINT32 Oct6100UserDriverWriteBurstApi( |
| 125 |
tPOCT6100_WRITE_BURST_PARAMS f_pBurstParams) |
| 126 |
{ |
| 127 |
struct oct612x_context *context = f_pBurstParams->pProcessContext; |
| 128 |
#ifdef OCTASIC_DEBUG |
| 129 |
if (!context || !context->ops || !context->ops->write_burst) { |
| 130 |
pr_debug("Invalid call to %s\n", __func__); |
| 131 |
return cOCT6100_ERR_BASE; |
| 132 |
} |
| 133 |
#endif |
| 134 |
context->ops->write_burst(context, f_pBurstParams->ulWriteAddress, |
| 135 |
f_pBurstParams->pusWriteData, |
| 136 |
f_pBurstParams->ulWriteLength); |
| 137 |
return cOCT6100_ERR_OK; |
| 138 |
} |
| 139 |
|
| 140 |
UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams) |
| 141 |
{ |
| 142 |
struct oct612x_context *context = f_pReadParams->pProcessContext; |
| 143 |
#ifdef OCTASIC_DEBUG |
| 144 |
if (!context || !context->ops || !context->ops->read) { |
| 145 |
pr_debug("Invalid call to %s\n", __func__); |
| 146 |
return cOCT6100_ERR_BASE; |
| 147 |
} |
| 148 |
#endif |
| 149 |
context->ops->read(context, f_pReadParams->ulReadAddress, |
| 150 |
f_pReadParams->pusReadData); |
| 151 |
return cOCT6100_ERR_OK; |
| 152 |
} |
| 153 |
|
| 154 |
UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams) |
| 155 |
{ |
| 156 |
struct oct612x_context *context = f_pBurstParams->pProcessContext; |
| 157 |
#ifdef OCTASIC_DEBUG |
| 158 |
if (!context || !context->ops || !context->ops->read_burst) { |
| 159 |
pr_debug("Invalid call to %s\n", __func__); |
| 160 |
return cOCT6100_ERR_BASE; |
| 161 |
} |
| 162 |
#endif |
| 163 |
context->ops->read_burst(context, f_pBurstParams->ulReadAddress, |
| 164 |
f_pBurstParams->pusReadData, |
| 165 |
f_pBurstParams->ulReadLength); |
| 166 |
return cOCT6100_ERR_OK; |
| 167 |
} |
| 168 |
|
| 169 |
EXPORT_SYMBOL(Oct6100ChipOpen); |
| 170 |
EXPORT_SYMBOL(Oct6100ChipClose); |
| 171 |
EXPORT_SYMBOL(Oct6100ChipCloseDef); |
| 172 |
EXPORT_SYMBOL(Oct6100GetInstanceSize); |
| 173 |
EXPORT_SYMBOL(Oct6100GetInstanceSizeDef); |
| 174 |
EXPORT_SYMBOL(Oct6100ChipOpenDef); |
| 175 |
EXPORT_SYMBOL(Oct6100ChannelModify); |
| 176 |
EXPORT_SYMBOL(Oct6100ToneDetectionEnableDef); |
| 177 |
EXPORT_SYMBOL(Oct6100InterruptServiceRoutine); |
| 178 |
EXPORT_SYMBOL(Oct6100InterruptServiceRoutineDef); |
| 179 |
EXPORT_SYMBOL(Oct6100ApiGetCapacityPins); |
| 180 |
EXPORT_SYMBOL(Oct6100ToneDetectionEnable); |
| 181 |
EXPORT_SYMBOL(Oct6100EventGetToneDef); |
| 182 |
EXPORT_SYMBOL(Oct6100EventGetTone); |
| 183 |
EXPORT_SYMBOL(Oct6100ApiGetCapacityPinsDef); |
| 184 |
EXPORT_SYMBOL(Oct6100ChannelOpen); |
| 185 |
EXPORT_SYMBOL(Oct6100ChannelOpenDef); |
| 186 |
EXPORT_SYMBOL(Oct6100ChannelModifyDef); |
| 187 |
|
| 188 |
static int __init oct612x_module_init(void) |
| 189 |
{ |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
dahdi_register_device(NULL, NULL); |
| 195 |
return 0; |
| 196 |
} |
| 197 |
module_init(oct612x_module_init); |
| 198 |
|
| 199 |
static void __exit oct612x_module_cleanup(void) |
| 200 |
{ |
| 201 |
; |
| 202 |
} |
| 203 |
module_exit(oct612x_module_cleanup); |
| 204 |
|
| 205 |
MODULE_AUTHOR("Digium Incorporated <[email protected]>"); |
| 206 |
MODULE_DESCRIPTION("Octasic OCT6100 Hardware Echocan Library"); |
| 207 |
MODULE_LICENSE("GPL v2"); |