From 33cd3da5ada6f99ff03d707fe7f00732febc5b83 Mon Sep 17 00:00:00 2001 From: Jiucheng Xu Date: Tue, 28 Aug 2012 15:34:14 +0000 Subject: TDM: Add a directly R/W API for tdm core Tdm core exported the simple function interfaces for user in kernel space. Signed-off-by: Jiucheng Xu Signed-off-by: Kai.Jiang Signed-off-by: Haiying Wang Signed-off-by: Xie Xiaobo Change-Id: Ifc8ef6b14f7cbc3c88fcfc5e4a1afd59564d8059 Reviewed-on: http://git.am.freescale.net:8181/904 Reviewed-by: Fleming Andrew-AFLEMING Tested-by: Fleming Andrew-AFLEMING diff --git a/drivers/tdm/tdm-core.c b/drivers/tdm/tdm-core.c index 666710a..3fd3242 100644 --- a/drivers/tdm/tdm-core.c +++ b/drivers/tdm/tdm-core.c @@ -1,6 +1,6 @@ /* driver/tdm/tdm-core.c * - * Copyright (C) 2012 Freescale Semiconductor, Inc, All rights reserved. + * Copyright 2012 Freescale Semiconductor, Inc. * * TDM core is the interface between TDM clients and TDM devices. * It is also intended to serve as an interface for line controld @@ -359,6 +359,54 @@ module_exit(tdm_exit); /* Interface to the tdm device/adapter */ +/* tdm_read_direct - issue a TDM read + * @adap: Handle to TDM device + * @buf: Data that will be read from the TDM device + * @len: How many bytes to read + * + * Returns negative errno, or else 0. + */ +int tdm_read_direct(struct tdm_adapter *adap, u8 *buf, u32 len) +{ + int res; + + if (adap->algo->tdm_read_simple) + res = adap->algo->tdm_read_simple(adap, buf, len); + else { + pr_err("TDM level read not supported\n"); + return -EOPNOTSUPP; + } + /* If everything went ok (i.e. frame received), return #bytes + transmitted, else error code. */ + + return res; + + +} +EXPORT_SYMBOL(tdm_read_direct); + +/* tdm_write_direct - issue a TDM write + * @adap: Handle to TDM device + * @buf: Data that will be written to the TDM device + * @len: How many bytes to write + * + * Returns negative errno, or else 0. + */ +int tdm_write_direct(struct tdm_adapter *adap, u8 *buf, u32 len) +{ + int res; + + if (adap->algo->tdm_write_simple) + res = adap->algo->tdm_write_simple(adap, buf, len); + else { + pr_err("TDM level write not supported\n"); + return -EOPNOTSUPP; + } + + return res; +} +EXPORT_SYMBOL(tdm_write_direct); + /* tdm_adap_send - issue a TDM write * @adap: Handle to TDM device * @buf: Data that will be written to the TDM device diff --git a/include/linux/tdm.h b/include/linux/tdm.h index 8cf4ef5..1b64cb8 100644 --- a/include/linux/tdm.h +++ b/include/linux/tdm.h @@ -1,6 +1,6 @@ /* include/linux/tdm.h * - * Copyright (C) 2012 Freescale Semiconductor, Inc, All rights reserved. + * Copyright 2012 Freescale Semiconductor, Inc. * * tdm.h - definitions for the tdm-device framework interface * @@ -62,6 +62,11 @@ static inline int ALIGN_SIZE(u64 size, u32 alignment) return (size + alignment - 1) & (~(alignment - 1)); } +int tdm_master_send(struct tdm_adapter *adap, void **buf, int count); +int tdm_master_recv(struct tdm_adapter *adap, void **buf); +int tdm_read_direct(struct tdm_adapter *adap, u8 *buf, u32 len); +int tdm_write_direct(struct tdm_adapter *adap, u8 *buf, u32 len); + /** * struct tdm_driver - represent an TDM device driver * @class: What kind of tdm device we instantiate (for detect) @@ -221,6 +226,8 @@ struct tdm_channel { struct tdm_adapt_algorithm { u32 (*tdm_read)(struct tdm_adapter *, u16 **); u32 (*tdm_get_write_buf)(struct tdm_adapter *, u16 **); + int (*tdm_read_simple)(struct tdm_adapter *, u8 *, u32 len); + int (*tdm_write_simple)(struct tdm_adapter *, u8 *, u32 len); u32 (*tdm_write)(struct tdm_adapter *, void * , unsigned int len); int (*tdm_enable)(struct tdm_adapter *); int (*tdm_disable)(struct tdm_adapter *); -- cgit v0.10.2