diff options
author | Xu Jiucheng <Jiucheng.Xu@freescale.com> | 2012-08-20 15:48:51 (GMT) |
---|---|---|
committer | Fleming Andrew-AFLEMING <AFLEMING@freescale.com> | 2013-04-05 15:59:36 (GMT) |
commit | d14836692a559a23fc99d140bff3a7bbdf463635 (patch) | |
tree | 3a7756412aa4b8c0f65e66e27aac3940f5c421c8 /drivers/tdm | |
parent | 7bf4e0ec67136a6f5bd99fc1f8f224c4e8611665 (diff) | |
download | linux-fsl-qoriq-d14836692a559a23fc99d140bff3a7bbdf463635.tar.xz |
TDM: QUICC Engine UCC TDM test module
This is a small test module to transfer and receive data via tdm.
It also supports zarlink LM card phone call.
Signed-off-by: Jiucheng Xu <Jiucheng.Xu@freescale.com>
Signed-off-by: Kai.Jiang <Kai.Jiang@freescale.com>
Signed-off-by: Xie Xiaobo <X.Xie@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
Change-Id: I47396d43b37e31e8de926af353dadfdaf637f13f
Reviewed-on: http://git.am.freescale.net:8181/906
Reviewed-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Tested-by: Fleming Andrew-AFLEMING <AFLEMING@freescale.com>
Diffstat (limited to 'drivers/tdm')
-rw-r--r-- | drivers/tdm/Kconfig | 9 | ||||
-rw-r--r-- | drivers/tdm/Makefile | 3 | ||||
-rw-r--r-- | drivers/tdm/test/Kconfig | 22 | ||||
-rw-r--r-- | drivers/tdm/test/Makefile | 1 | ||||
-rw-r--r-- | drivers/tdm/test/ucc_tdm_test.c | 169 |
5 files changed, 194 insertions, 10 deletions
diff --git a/drivers/tdm/Kconfig b/drivers/tdm/Kconfig index 25fed1c..434ad6e 100644 --- a/drivers/tdm/Kconfig +++ b/drivers/tdm/Kconfig @@ -22,14 +22,7 @@ config TDM_DEBUG_CORE messages to the system log. Select this if you are having a problem with TDM support and want to see more of what is going on. -config TDM_TEST - tristate "TDM test Module" - default n - ---help--- - This TDM test module is a small test module which - registers with the TDM core(framework) and sets up - a TDM Voice path between diff channels of a slic. - +source drivers/tdm/test/Kconfig source drivers/tdm/device/Kconfig source drivers/tdm/line_ctrl/Kconfig endif # TDM diff --git a/drivers/tdm/Makefile b/drivers/tdm/Makefile index ea66fff..2a2e0a5 100644 --- a/drivers/tdm/Makefile +++ b/drivers/tdm/Makefile @@ -2,8 +2,7 @@ # Makefile for the TDM core. # -obj-$(CONFIG_TDM) += tdm-core.o device/ line_ctrl/ -obj-$(CONFIG_TDM_TEST) += test/ +obj-$(CONFIG_TDM) += tdm-core.o device/ line_ctrl/ test/ ifeq ($(CONFIG_TDM_DEBUG_CORE),y) EXTRA_CFLAGS += -DDEBUG endif diff --git a/drivers/tdm/test/Kconfig b/drivers/tdm/test/Kconfig new file mode 100644 index 0000000..81fc3f4 --- /dev/null +++ b/drivers/tdm/test/Kconfig @@ -0,0 +1,22 @@ +# +# TDM TEST MODULE +# + +menu "TDM test" + +config TDM_TEST + tristate "TDM test Module" + depends on FSL_SOC + ---help--- + This TDM test module is a small test module which + registers with the TDM core(framework) and sets up + a TDM Voice path between diff channels of a slic. + +config UCC_TDM_TEST + tristate "UCC TDM test Module" + depends on FSL_SOC || CONFIG_QE + ---help--- + This UCC TDM test module is a small test module to test + ucc tdm transfer and receive data via ucc1. + +endmenu diff --git a/drivers/tdm/test/Makefile b/drivers/tdm/test/Makefile index 3ef9cb4..c229934 100644 --- a/drivers/tdm/test/Makefile +++ b/drivers/tdm/test/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_TDM_TEST) += tdm_test.o +obj-$(CONFIG_UCC_TDM_TEST) += ucc_tdm_test.o diff --git a/drivers/tdm/test/ucc_tdm_test.c b/drivers/tdm/test/ucc_tdm_test.c new file mode 100644 index 0000000..f4112bd --- /dev/null +++ b/drivers/tdm/test/ucc_tdm_test.c @@ -0,0 +1,169 @@ +/* + * + * Copyright 2011-2012 Freescale Semiconductor, Inc. + * + * TDM Test Module. + * This TDM test module is a small test module which registers with the + * TDM framework and transfer and receive data via UCC1. + * + * Author: Kai Jiang <Kai.Jiang@freescale.com> + * Modifier: Jiucheng Xu <Jiucheng.Xu@freescale.com> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <linux/module.h> +#include <linux/device.h> +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/kthread.h> +#include <linux/wait.h> +#include <linux/param.h> +#include <linux/tdm.h> +#include <linux/fs.h> +#include <linux/slab.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/tdm.h> + +#define READ_LEN (72 * 32) /* BD buffer max len */ +#define WRITE_LEN 0x80 +#define READ_COUNT 4 /* BD ring len */ + +static struct task_struct *tdm_thread_task; +static struct tdm_driver test_tdmdev_driver; +static int ucc_num = 1; +static int forward; +static u8 *buf; + +module_param(ucc_num, int, S_IRUGO); +module_param(forward, int, S_IRUGO); + +static int tdm_check_data(void) +{ + int i, j; + unsigned long stamp; + + stamp = jiffies + HZ; /* 1 sec for overtime */ + while (time_before(jiffies, stamp)) { + memset(buf, 0xff, READ_LEN); + tdm_read_direct(test_tdmdev_driver.adapter, buf, READ_LEN); + + for (i = 0; (i < READ_LEN); i++) { + if (buf[i] != 0xff) { + for (j = 0; j < WRITE_LEN; j += 4) + pr_info("%x\t%x\t%x\t%x\n", + buf[i+j], buf[i+j+1], + buf[i+j+2], buf[i+j+3]); + return 0; + } + } + } + + pr_warn("ucc_tdm_test: check data overtime\n"); + return 0; +} + +static int tdm_thread(void *ptr) +{ + int i; + + tdm_adap_enable(&test_tdmdev_driver); + + if (forward == 1) { + /* data forwarding application for zarlink */ + while (!kthread_should_stop()) { + memset(buf, 0, READ_LEN); + tdm_read_direct(test_tdmdev_driver.adapter, buf, + READ_LEN); + tdm_write_direct(test_tdmdev_driver.adapter, buf, + READ_LEN); + } + } else { + /* transmit-recieve test with loopback cable */ + for (i = 0; i < WRITE_LEN; i++) + buf[i] = i; /* generate test data */ + + tdm_write_direct(test_tdmdev_driver.adapter, buf, + WRITE_LEN); + + tdm_check_data(); + } + + tdm_adap_disable(&test_tdmdev_driver); + + return 0; +} + +static int test_attach_adapter(struct tdm_adapter *adap) +{ + buf = kmalloc(READ_LEN, GFP_KERNEL); + if (!buf) { + dev_err(adap->parent, "No memory for TDM\n"); + return -ENOMEM; + } + + tdm_thread_task = kthread_run(tdm_thread, NULL, "tdm_thread"); + + return 0; +} + +static int test_detach_adapter(struct tdm_adapter *adap) +{ + if (forward == 1) + kthread_stop(tdm_thread_task); + + kfree(buf); + + return 0; +} + +static const struct tdm_device_id test_ucc_tdm_id[] = { + { "tdm_ucc_1", 0 }, + { } +}; + +static struct tdm_driver test_tdmdev_driver = { + .attach_adapter = test_attach_adapter, + .detach_adapter = test_detach_adapter, + .id_table = test_ucc_tdm_id, +}; + +static int __init tdm_test_init(void) +{ + if ((ucc_num < 0) || (ucc_num > 8)) + pr_warn("ucc_tdm_test: invalid ucc_num %d(1 ~7), " + "use the defaut ucc_num = 1\n", ucc_num); + else + sprintf((char *)test_ucc_tdm_id[0].name, "%s%d", + "tdm_ucc_", ucc_num); + + test_tdmdev_driver.id = 1; + + /* create a binding with TDM driver */ + return tdm_add_driver(&test_tdmdev_driver); +} + +static void __exit tdm_test_exit(void) +{ + tdm_unregister_driver(&test_tdmdev_driver); +} + +module_init(tdm_test_init); +module_exit(tdm_test_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR(" Kai Jiang <Kai.Jiang@freescale.com>"); +MODULE_DESCRIPTION("Test Module for Freescale Platforms with TDM support"); |