[PATCH 4/5] fsl/qe: Add QE TDM lib

Joakim Tjernlund Joakim.Tjernlund at infinera.com
Wed Mar 30 22:50:00 AEDT 2016


On Wed, 2016-03-30 at 16:50 +0800, Zhao Qiang wrote:
> QE has module to support TDM, some other protocols
> supported by QE are based on TDM.
> add a qe-tdm lib, this lib provides functions to the protocols
> using TDM to configurate QE-TDM.
> 
> Signed-off-by: Zhao Qiang <qiang.zhao at nxp.com>
> ---
>  drivers/soc/fsl/qe/Kconfig    |   4 +
>  drivers/soc/fsl/qe/Makefile   |   1 +
>  drivers/soc/fsl/qe/qe_tdm.c   | 271 ++++++++++++++++++++++++++++++++++++++++++
>  include/soc/fsl/qe/immap_qe.h |   5 +-
>  include/soc/fsl/qe/qe_tdm.h   |  94 +++++++++++++++
>  5 files changed, 371 insertions(+), 4 deletions(-)
>  create mode 100644 drivers/soc/fsl/qe/qe_tdm.c
>  create mode 100644 include/soc/fsl/qe/qe_tdm.h
> 
> diff --git a/drivers/soc/fsl/qe/Kconfig b/drivers/soc/fsl/qe/Kconfig
> index 20978f2..463cf29 100644
> --- a/drivers/soc/fsl/qe/Kconfig
> +++ b/drivers/soc/fsl/qe/Kconfig
> @@ -31,6 +31,10 @@ config UCC
>  	bool
>  	default y if UCC_FAST || UCC_SLOW
>  
> +config QE_TDM
> +	bool
> +	select UCC_FAST
> +
>  config QE_USB
>  	bool
>  	default y if USB_FSL_QE
> diff --git a/drivers/soc/fsl/qe/Makefile b/drivers/soc/fsl/qe/Makefile
> index ffac541..2031d38 100644
> --- a/drivers/soc/fsl/qe/Makefile
> +++ b/drivers/soc/fsl/qe/Makefile
> @@ -6,5 +6,6 @@ obj-$(CONFIG_CPM)	+= qe_common.o
>  obj-$(CONFIG_UCC)	+= ucc.o
>  obj-$(CONFIG_UCC_SLOW)	+= ucc_slow.o
>  obj-$(CONFIG_UCC_FAST)	+= ucc_fast.o
> +obj-$(CONFIG_QE_TDM)	+= qe_tdm.o
>  obj-$(CONFIG_QE_USB)	+= usb.o
>  obj-$(CONFIG_QE_GPIO)	+= gpio.o
> diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c
> new file mode 100644
> index 0000000..9a2374d
> --- /dev/null
> +++ b/drivers/soc/fsl/qe/qe_tdm.c
> @@ -0,0 +1,271 @@
> +/*
> + * Copyright (C) 2015 Freescale Semiconductor, Inc. All rights reserved.
> + *
> + * Authors:	Zhao Qiang <qiang.zhao at nxp.com>
> + *
> + * Description:
> + * QE TDM API Set - TDM specific routines implementations.
> + *
> + * 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.
> + */
> +#include <linux/io.h>
> +#include <linux/kernel.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +#include <linux/of_platform.h>
> +#include <soc/fsl/qe/qe_tdm.h>
> +
> +static enum tdm_framer_t set_tdm_framer(const char *tdm_framer_type)
> +{
> +	if (strcmp(tdm_framer_type, "e1") == 0)
> +		return TDM_FRAMER_E1;
> +	else
> +		return TDM_FRAMER_T1;
> +}
> +
> +static void set_si_param(struct ucc_tdm *utdm, struct ucc_tdm_info *ut_info)
> +{
> +	struct si_mode_info *si_info = &ut_info->si_info;
> +
> +	if (utdm->tdm_mode == TDM_INTERNAL_LOOPBACK) {
> +		si_info->simr_crt = 1;
> +		si_info->simr_rfsd = 0;
> +	}
> +}
> +
> +int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm *utdm,
> +		     struct ucc_tdm_info *ut_info)
> +{
> +	const char *sprop;
> +	int ret = 0;
> +	u32 val;
> +	struct resource *res;
> +	struct device_node *np2;
> +	static int siram_init_flag;
> +	struct platform_device *pdev;
> +
> +	sprop = of_get_property(np, "fsl,rx-sync-clock", NULL);
> +	if (sprop) {
> +		ut_info->uf_info.rx_sync = qe_clock_source(sprop);
> +		if ((ut_info->uf_info.rx_sync < QE_CLK_NONE) ||
> +		    (ut_info->uf_info.rx_sync > QE_RSYNC_PIN)) {
> +			pr_err("QE-TDM: Invalid rx-sync-clock property\n");
> +			return -EINVAL;
> +		}
> +	} else {
> +		pr_err("QE-TDM: Invalid rx-sync-clock property\n");
> +		return -EINVAL;
> +	}
> +
> +	sprop = of_get_property(np, "fsl,tx-sync-clock", NULL);
> +	if (sprop) {
> +		ut_info->uf_info.tx_sync = qe_clock_source(sprop);
> +		if ((ut_info->uf_info.tx_sync < QE_CLK_NONE) ||
> +		    (ut_info->uf_info.tx_sync > QE_TSYNC_PIN)) {
> +			pr_err("QE-TDM: Invalid tx-sync-clock property\n");
> +		return -EINVAL;
> +		}
> +	} else {
> +		pr_err("QE-TDM: Invalid tx-sync-clock property\n");
> +		return -EINVAL;
> +	}
> +
> +	ret = of_property_read_u32_index(np, "fsl,tx-timeslot-mask", 0, &val);
> +	if (ret) {
> +		pr_err("QE-TDM: Invalid tx-timeslot-mask property\n");
> +		return -EINVAL;
> +	}
> +	utdm->tx_ts_mask = val;
> +
> +	ret = of_property_read_u32_index(np, "fsl,rx-timeslot-mask", 0, &val);
> +	if (ret) {
> +		ret = -EINVAL;
> +		pr_err("QE-TDM: Invalid rx-timeslot-mask property\n");
> +		return ret;
> +	}
> +	utdm->rx_ts_mask = val;
> +
> +	ret = of_property_read_u32_index(np, "fsl,tdm-id", 0, &val);
> +	if (ret) {
> +		ret = -EINVAL;
> +		pr_err("QE-TDM: No fsl,tdm-id property for this UCC\n");
> +		return ret;
> +	}
> +	utdm->tdm_port = val;
> +	ut_info->uf_info.tdm_num = utdm->tdm_port;
> +
> +	if (of_get_property(np, "fsl,tdm-internal-loopback", NULL))
> +		utdm->tdm_mode = TDM_INTERNAL_LOOPBACK;
> +	else
> +		utdm->tdm_mode = TDM_NORMAL;
> +
> +	sprop = of_get_property(np, "fsl,tdm-framer-type", NULL);
> +	if (!sprop) {
> +		ret = -EINVAL;
> +		pr_err("QE-TDM: No tdm-framer-type property for UCC\n");
> +		return ret;
> +	}
> +	utdm->tdm_framer_type = set_tdm_framer(sprop);
> +
> +	ret = of_property_read_u32_index(np, "fsl,siram-entry-id", 0, &val);
> +	if (ret) {
> +		ret = -EINVAL;
> +		pr_err("QE-TDM: No siram entry id for UCC\n");
> +		return ret;
> +	}
> +	utdm->siram_entry_id = val;
> +
> +	set_si_param(utdm, ut_info);
> +
> +	np2 = of_find_compatible_node(NULL, NULL, "fsl,t1040-qe-si");

fsl,t1040-qe-si only? What about mpc83xx?
I recall QE is a little bit different compared to T1040 or will this work(including the hdlc driver)
on 83xx as well?

 Jocke 


More information about the Linuxppc-dev mailing list