From: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
To: "davem@davemloft.net" <davem@davemloft.net>,
"qiang.zhao@nxp.com" <qiang.zhao@nxp.com>
Cc: "linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"xiaobo.xie@nxp.com" <xiaobo.xie@nxp.com>,
"oss@buserror.net" <oss@buserror.net>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH 4/5] fsl/qe: Add QE TDM lib
Date: Wed, 30 Mar 2016 11:50:00 +0000 [thread overview]
Message-ID: <1459338701.3538.17.camel@infinera.com> (raw)
In-Reply-To: <1459327830-19829-4-git-send-email-qiang.zhao@nxp.com>
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@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@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
next prev parent reply other threads:[~2016-03-30 12:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-30 8:50 [PATCH 1/5] fsl/qe: add rx_sync and tx_sync for TDM mode Zhao Qiang
2016-03-30 8:50 ` [PATCH 2/5] fsl/qe: setup clock source " Zhao Qiang
2016-03-30 8:50 ` [PATCH 3/5] fsl/qe: Make regs resouce_size_t Zhao Qiang
2016-03-30 8:50 ` [PATCH 4/5] fsl/qe: Add QE TDM lib Zhao Qiang
2016-03-30 11:50 ` Joakim Tjernlund [this message]
2016-03-31 1:25 ` Qiang Zhao
2016-03-30 8:50 ` [PATCH 5/5] drivers/net: support hdlc function for QE-UCC Zhao Qiang
2016-03-30 9:53 ` kbuild test robot
2016-03-30 12:27 ` kbuild test robot
2016-03-30 12:53 ` kbuild test robot
2016-04-19 16:22 ` Christophe Leroy
2016-04-20 2:28 ` Qiang Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459338701.3538.17.camel@infinera.com \
--to=joakim.tjernlund@infinera.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=oss@buserror.net \
--cc=qiang.zhao@nxp.com \
--cc=xiaobo.xie@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox