Add support for QMC HDLC, framer infrastruture and PEF2256 framer
Subsystems (15)
Herve Codina
maintainercover Add support for QMC HDLC, framer infrastruture and PEF2256 framer
Hi,
I have a system where I need to handle an HDLC interface and some audio data.
The HDLC data are transferred using a TDM bus on which a PEF2256 (E1/T1 framer) is present. The PEF2256 transfers data from/to the TDM bus to/from the E1 line. This PEF2256 is connected to a PowerQUICC SoC for the control path and the TDM is connected to the SoC (QMC component) for the data path.
From the QMC HDLC driver, I need to handle HDLC data using the QMC, carrier detection using the PEF2256 (E1 line carrier) and set/get some PEF2256 configuration.
The QMC HDLC driver considers the PEF2256 as a generic framer. It performs operations that involve the PEF2256 through the generic framer API.
The audio data are exchanged with the PEF2256 using a CPU DAI connected to the TDM bus through the QMC and the PEF2256 needs to be seen as a codec in order to be linked to the CPU DAI.
The codec handles the carrier detection using the PEF2256 and reports the carrier state to the ALSA subsystem using the ASoC jack detection.
The codec, even if instantiated by the PEF2256 driver, considers the PEF2256 as a generic framer.
The generic framer has:
- 2 consumers (QMC HDLC drv and codec)
- 1 provider (PEF2256)
So, the design is the following:
+------------------+ +---------+
| QMC | <- TDM -> | PEF2256 | <-> E1
+---------+ | +-------------+ | | |
| CPU DAI | <-data--> | QMC channel | | | |
+---------+ | +-------------+ | | |
+--------------+ | +-------------+ | | |
| QMC HDLC drv | <-data--> | QMC channel | | | |
+--------------+ | +-------------+ | | |
^ +------------------+ | |
| +--------+ +-------------+ | |
+-> | framer | <-> | PEF2256 drv | <- local bus ->| |
| | | | +---------+
+-> | | | |
| +--------+ | +-------+ |
+-------------------> | codec | |
| +-------+ |
+-------------+Further more, the TDM timeslots used by the QMC HDLC driver need to be configured at runtime (QMC dynamic timeslots).
Several weeks ago, I sent two series related to this topic:
- Add the Lantiq PEF2256 audio support [1]
- RFC Add support for QMC HDLC and PHY [2]
This current series is a rework of these two series taking into account feedbacks previously received.
In order to implement all of this, I do the following:
1) Perform some fixes (patches 1, 2)
2) Introduce the QMC HDLC driver (patches 3, 4, 5)
3) Add QMC dynamic timeslot support (patches 6 - 16)
4) Add timeslots change support in QMC HDLC (patch 17)
5) Introduce framer infrastructure (patch 18)
6) Add PEF2256 framer provider (patches 19, 20, 21, 22, 23)
7) Add framer codec as a framer consumer (patch 24)
8) Add framer support as a framer consumer in QMC HDLC (patch 25, 26)
The series contains the full story and detailed modifications. If needed, the series can be split and/or commmits can be squashed. Let me know.
Best regards,
Hervé
[1]: https://lore.kernel.org/all/[email protected]/
[2]: https://lore.kernel.org/all/[email protected]/
Herve Codina (26):
soc: fsl: cpm1: qmc: Fix rx channel reset
soc: fsl: cpm1: qmc: Extend the API to provide Rx status
dt-bindings: net: Add support for QMC HDLC
net: wan: Add support for QMC HDLC
MAINTAINERS: Add the Freescale QMC HDLC driver entry
soc: fsl: cpm1: qmc: Introduce available timeslots masks
soc: fsl: cpm1: qmc: Rename qmc_setup_tsa* to qmc_init_tsa*
soc: fsl: cpm1: qmc: Introduce qmc_chan_setup_tsa*
soc: fsl: cpm1: qmc: Remove no more needed checks from
qmc_check_chans()
soc: fsl: cpm1: qmc: Check available timeslots in qmc_check_chans()
soc: fsl: cpm1: qmc: Add support for disabling channel TSA entries
soc: fsl: cpm1: qmc: Split Tx and Rx TSA entries setup
soc: fsl: cpm1: qmc: Introduce is_tsa_64rxtx flag
soc: fsl: cpm1: qmc: Handle timeslot entries at channel start() and
stop()
soc: fsl: cpm1: qmc: Remove timeslots handling from setup_chan()
soc: fsl: cpm1: qmc: Introduce functions to change timeslots at
runtime
wan: qmc_hdlc: Add runtime timeslots changes support
net: wan: Add framer framework support
dt-bindings: net: Add the Lantiq PEF2256 E1/T1/J1 framer
mfd: core: Ensure disabled devices are skiped without aborting
net: wan: framer: Add support for the Lantiq PEF2256 framer
pinctrl: Add support for the Lantic PEF2256 pinmux
MAINTAINERS: Add the Lantiq PEF2256 driver entry
ASoC: codecs: Add support for the framer codec
dt-bindings: net: fsl,qmc-hdlc: Add framer support
net: wan: fsl_qmc_hdlc: Add framer support
.../devicetree/bindings/net/fsl,qmc-hdlc.yaml | 46 + .../bindings/net/lantiq,pef2256.yaml | 226 +++++ MAINTAINERS | 17 + drivers/mfd/mfd-core.c | 18 +- drivers/net/wan/Kconfig | 14 + drivers/net/wan/Makefile | 3 + drivers/net/wan/framer/Kconfig | 35 + drivers/net/wan/framer/Makefile | 7 + drivers/net/wan/framer/framer-core.c | 935 ++++++++++++++++++ drivers/net/wan/framer/pef2256/Makefile | 8 + drivers/net/wan/framer/pef2256/pef2256-regs.h | 250 +++++ drivers/net/wan/framer/pef2256/pef2256.c | 880 +++++++++++++++++ drivers/net/wan/fsl_qmc_hdlc.c | 820 +++++++++++++++ drivers/pinctrl/Kconfig | 14 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-pef2256-regs.h | 65 ++ drivers/pinctrl/pinctrl-pef2256.c | 310 ++++++ drivers/soc/fsl/qe/qmc.c | 467 +++++++-- include/linux/framer/framer-provider.h | 194 ++++ include/linux/framer/framer.h | 215 ++++ include/linux/framer/pef2256.h | 31 + include/soc/fsl/qe/qmc.h | 25 +- sound/soc/codecs/Kconfig | 15 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/framer-codec.c | 423 ++++++++ sound/soc/fsl/fsl_qmc_audio.c | 2 +- 26 files changed, 4929 insertions(+), 94 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml create mode 100644 Documentation/devicetree/bindings/net/lantiq,pef2256.yaml create mode 100644 drivers/net/wan/framer/Kconfig create mode 100644 drivers/net/wan/framer/Makefile create mode 100644 drivers/net/wan/framer/framer-core.c create mode 100644 drivers/net/wan/framer/pef2256/Makefile create mode 100644 drivers/net/wan/framer/pef2256/pef2256-regs.h create mode 100644 drivers/net/wan/framer/pef2256/pef2256.c create mode 100644 drivers/net/wan/fsl_qmc_hdlc.c create mode 100644 drivers/pinctrl/pinctrl-pef2256-regs.h create mode 100644 drivers/pinctrl/pinctrl-pef2256.c create mode 100644 include/linux/framer/framer-provider.h create mode 100644 include/linux/framer/framer.h create mode 100644 include/linux/framer/pef2256.h create mode 100644 sound/soc/codecs/framer-codec.c
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 1/26 soc: fsl: cpm1: qmc: Fix rx channel reset
The qmc_chan_reset_rx() set the is_rx_stopped flag. This leads to an inconsistent state in the following sequence.
qmc_chan_stop()
qmc_chan_reset()Indeed, after the qmc_chan_reset() call, the channel must still be stopped. Only a qmc_chan_start() call can move the channel from stopped state to started state.
Fix the issue removing the is_rx_stopped flag setting from qmc_chan_reset()
--- drivers/soc/fsl/qe/qmc.c | 1 - 1 file changed, 1 deletion(-)
drivers/soc/fsl/qe/qmc.c +0 -1
@@ -685,7 +685,6 @@ static void qmc_chan_reset_rx(struct qmc_chan *chan) qmc_read16(chan->s_param + QMC_SPE_RBASE)); chan->rx_pending =0 ; - chan->is_rx_stopped = false;spin_unlock_irqrestore (&chan->rx_lock, flags); }
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 2/26 soc: fsl: cpm1: qmc: Extend the API to provide Rx status
In reply to Herve CodinaIn HDLC mode, some status flags related to the data read transfer can be set by the hardware and need to be known by a QMC consumer for further analysis.
Extend the API in order to provide these transfer status flags at the read complete() call.
In TRANSPARENT mode, these flags have no meaning. Keep only one read complete() API and update the consumers working in transparent mode. In this case, the newly introduced flags parameter is simply unused.
--- drivers/soc/fsl/qe/qmc.c | 29 +++++++++++++++++++++++++---- include/soc/fsl/qe/qmc.h | 15 ++++++++++++++- sound/soc/fsl/fsl_qmc_audio.c | 2 +- 3 files changed, 40 insertions(+), 6 deletions(-)
drivers/soc/fsl/qe/qmc.c +25 -4
@@ -166,7 +166,7 @@struct qmc_xfer_desc {union {void (*tx_complete)(void *context); -void (*rx_complete)(void *context,size_t length); +void (*rx_complete)(void *context,size_t length,unsigned int flags); };void *context; };
@@ -421,7 +421,8 @@ static void qmc_chan_write_done(struct qmc_chan *chan) }int qmc_chan_read_submit (struct qmc_chan *chan,dma_addr_t addr,size_t length, -void (*complete)(void *context,size_t length),void *context) +void (*complete)(void *context,size_t length,unsigned int flags), +void *context) {struct qmc_xfer_desc *xfer_desc;unsigned long flags;
@@ -454,6 +455,10 @@ int qmc_chan_read_submit(struct qmc_chan *chan, dma_addr_t addr, size_t length, xfer_desc->rx_complete = complete; xfer_desc->context = context; +/* Clear previous status flags */ + ctrl &= ~(QMC_BD_RX_L |QMC_BD_RX_F |QMC_BD_RX_LG |QMC_BD_RX_NO | +QMC_BD_RX_AB |QMC_BD_RX_CR ); +/* Activate the descriptor */ ctrl |= (QMC_BD_RX_E |QMC_BD_RX_UB );wmb ();/* Be sure to flush data before descriptor activation */
@@ -485,7 +490,7 @@ EXPORT_SYMBOL(qmc_chan_read_submit);static void qmc_chan_read_done (struct qmc_chan *chan) { -void (*complete)(void *context,size_t size); +void (*complete)(void *context,size_t size,unsigned int flags);struct qmc_xfer_desc *xfer_desc;unsigned long flags;cbd_t *__iomem bd;
@@ -527,7 +532,23 @@ static void qmc_chan_read_done(struct qmc_chan *chan)if (complete) {spin_unlock_irqrestore (&chan->rx_lock, flags); -complete (context, datalen); + +/* +* Avoid conversion between internal hardware flags and +* the software API flags. +* -> Be sure that the software API flags are consistent +* with the hardware flags +*/ +BUILD_BUG_ON (QMC_RX_FLAG_HDLC_LAST !=QMC_BD_RX_L ); +BUILD_BUG_ON (QMC_RX_FLAG_HDLC_FIRST !=QMC_BD_RX_F ); +BUILD_BUG_ON (QMC_RX_FLAG_HDLC_OVF !=QMC_BD_RX_LG ); +BUILD_BUG_ON (QMC_RX_FLAG_HDLC_UNA !=QMC_BD_RX_NO ); +BUILD_BUG_ON (QMC_RX_FLAG_HDLC_ABORT !=QMC_BD_RX_AB ); +BUILD_BUG_ON (QMC_RX_FLAG_HDLC_CRC !=QMC_BD_RX_CR ); + +complete (context, datalen, + ctrl & (QMC_BD_RX_L |QMC_BD_RX_F |QMC_BD_RX_LG | +QMC_BD_RX_NO |QMC_BD_RX_AB |QMC_BD_RX_CR ));spin_lock_irqsave (&chan->rx_lock, flags); }
include/soc/fsl/qe/qmc.h +14 -1
@@ -9,6 +9,7 @@#ifndef __SOC_FSL_QMC_H__#define __SOC_FSL_QMC_H__ +#include <linux/bits.h> #include <linux/types.h> struct device_node ;
@@ -56,8 +57,20 @@ int qmc_chan_set_param(struct qmc_chan *chan, const struct qmc_chan_param *paramint qmc_chan_write_submit (struct qmc_chan *chan,dma_addr_t addr,size_t length,void (*complete)(void *context),void *context); +/* Flags available (ORed) for read complete() flags parameter in HDLC mode. +* No flags are available in transparent mode and the read complete() flags +* parameter has no meaning in transparent mode. +*/ +#define QMC_RX_FLAG_HDLC_LAST BIT(11)/* Last in frame */ +#define QMC_RX_FLAG_HDLC_FIRST BIT(10)/* First in frame */ +#define QMC_RX_FLAG_HDLC_OVF BIT(5)/* Data overflow */ +#define QMC_RX_FLAG_HDLC_UNA BIT(4)/* Unaligned (ie. bits received not multiple of 8) */ +#define QMC_RX_FLAG_HDLC_ABORT BIT(3)/* Received an abort sequence (seven consecutive ones) */ +#define QMC_RX_FLAG_HDLC_CRC BIT(2)/* CRC error */ +int qmc_chan_read_submit (struct qmc_chan *chan,dma_addr_t addr,size_t length, -void (*complete)(void *context,size_t length), +void (*complete)(void *context,size_t length, +unsigned int flags),void *context);#define QMC_CHAN_READ (1<<0)
sound/soc/fsl/fsl_qmc_audio.c +1 -1
@@ -99,7 +99,7 @@ static void qmc_audio_pcm_write_complete(void *context)snd_pcm_period_elapsed (prtd->substream); } -static void qmc_audio_pcm_read_complete (void *context,size_t length) +static void qmc_audio_pcm_read_complete (void *context,size_t length,unsigned int flags) {struct qmc_dai_prtd *prtd = context;int ret;
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 3/26 dt-bindings: net: Add support for QMC HDLC
In reply to Herve CodinaThe QMC (QUICC mutichannel controller) is a controller present in some PowerQUICC SoC such as MPC885.
The QMC HDLC uses the QMC controller to transfer HDLC data.
--- .../devicetree/bindings/net/fsl,qmc-hdlc.yaml | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml
Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml new file +41 -0
@@ -0,0 +1,41 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/fsl,qmc-hdlc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: QMC HDLC + +maintainers: + - Herve Codina <[email protected]> + +description: | + The QMC HDLC uses a QMC (QUICC Multichannel Controller) channel to transfer + HDLC data. + +properties: + compatible: + const: fsl,qmc-hdlc + + fsl,qmc-chan: + $ref: /schemas/types.yaml#/definitions/phandle-array + items: + - items: + - description: phandle to QMC node + - description: Channel number + description: + Should be a phandle/number pair. The phandle to QMC node and the QMC + channel to use. + +required: + - compatible + - fsl,qmc-chan + +additionalProperties: false + +examples: + - | + hdlc { + compatible = "fsl,qmc-hdlc"; + fsl,qmc-chan = <&qmc 16>; + };
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 4/26 net: wan: Add support for QMC HDLC
In reply to Herve CodinaThe QMC HDLC driver provides support for HDLC using the QMC (QUICC Multichannel Controller) to transfer the HDLC data.
--- drivers/net/wan/Kconfig | 12 + drivers/net/wan/Makefile | 1 + drivers/net/wan/fsl_qmc_hdlc.c | 422 +++++++++++++++++++++++++++++++++ 3 files changed, 435 insertions(+) create mode 100644 drivers/net/wan/fsl_qmc_hdlc.c
drivers/net/wan/Kconfig +12 -0
@@ -195,6 +195,18 @@ config FARSYNC To compile this driver as a module, choose M here: the module will be called farsync. +config FSL_QMC_HDLC + tristate "Freescale QMC HDLC support" + depends on HDLC + depends on CPM_QMC + help + HDLC support using the Freescale QUICC Multichannel Controller (QMC). + + To compile this driver as a module, choose M here: the + module will be called fsl_qmc_hdlc. + + If unsure, say N. + config FSL_UCC_HDLC tristate "Freescale QUICC Engine HDLC support" depends on HDLC
drivers/net/wan/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-$(CONFIG_WANXL) += wanxl.o obj-$(CONFIG_PCI200SYN) += pci200syn.o obj-$(CONFIG_PC300TOO) += pc300too.o obj-$(CONFIG_IXP4XX_HSS) += ixp4xx_hss.o +obj-$(CONFIG_FSL_QMC_HDLC) += fsl_qmc_hdlc.o obj-$(CONFIG_FSL_UCC_HDLC) += fsl_ucc_hdlc.o obj-$(CONFIG_SLIC_DS26522) += slic_ds26522.o
drivers/net/wan/fsl_qmc_hdlc.c new file +422 -0
422 lines not on this page · raw message
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 5/26 MAINTAINERS: Add the Freescale QMC HDLC driver entry
In reply to Herve CodinaAfter contributing the driver, add myself as the maintainer for the Freescale QMC HDLC driver.
--- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+)
MAINTAINERS +8 -0
@@ -8304,6 +8304,14 @@ F: Documentation/devicetree/bindings/soc/fsl/cpm_qe/fsl,cpm1-scc-qmc.yaml F: drivers/soc/fsl/qe/qmc.c F: include/soc/fsl/qe/qmc.h +FREESCALE QUICC ENGINE QMC HDLC DRIVER +M: Herve Codina <[email protected]> +L: [email protected] +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml +F: drivers/net/wan/fsl_qmc_hdlc.c + FREESCALE QUICC ENGINE TSA DRIVER M: Herve Codina <[email protected]> L: [email protected]
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 6/26 soc: fsl: cpm1: qmc: Introduce available timeslots masks
In reply to Herve CodinaAvailable timeslots masks define timeslots available for the related channel. These timeslots are defined by the QMC binding.
Timeslots used are initialized to available timeslots but can be a subset of available timeslots.
This prepares the dynamic timeslots management (ie. changing timeslots at runtime).
--- drivers/soc/fsl/qe/qmc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/soc/fsl/qe/qmc.c +6 -2
@@ -177,7 +177,9 @@ struct qmc_chan {struct qmc *qmc;void *__iomem s_param;enum qmc_mode mode; +u64 tx_ts_mask_avail;u64 tx_ts_mask; +u64 rx_ts_mask_avail;u64 rx_ts_mask;bool is_reverse_data;
@@ -875,7 +877,8 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)of_node_put (chan_np);return ret; } - chan->tx_ts_mask = ts_mask; + chan->tx_ts_mask_avail = ts_mask; + chan->tx_ts_mask = chan->tx_ts_mask_avail; ret =of_property_read_u64 (chan_np,"fsl,rx-ts-mask" , &ts_mask);if (ret) {
@@ -884,7 +887,8 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)of_node_put (chan_np);return ret; } - chan->rx_ts_mask = ts_mask; + chan->rx_ts_mask_avail = ts_mask; + chan->rx_ts_mask = chan->rx_ts_mask_avail; mode ="transparent" ; ret =of_property_read_string (chan_np,"fsl,operational-mode" , &mode);
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 7/26 soc: fsl: cpm1: qmc: Rename qmc_setup_tsa* to qmc_init_tsa*
In reply to Herve Codinaqmc_setup_tsa* are called once at initialisation.
They initialize the QMC TSA table.
In order to introduce setup function later on for dynamic timeslots management, rename the function to avoid later confusion.
--- drivers/soc/fsl/qe/qmc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/soc/fsl/qe/qmc.c +8 -8
@@ -919,7 +919,7 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)return qmc_check_chans (qmc); } -static int qmc_setup_tsa_64rxtx (struct qmc *qmc,const struct tsa_serial_info *info) +static int qmc_init_tsa_64rxtx (struct qmc *qmc,const struct tsa_serial_info *info) {struct qmc_chan *chan;unsigned int i;
@@ -961,7 +961,7 @@ static int qmc_setup_tsa_64rxtx(struct qmc *qmc, const struct tsa_serial_info *ireturn 0 ; } -static int qmc_setup_tsa_32rx_32tx (struct qmc *qmc,const struct tsa_serial_info *info) +static int qmc_init_tsa_32rx_32tx (struct qmc *qmc,const struct tsa_serial_info *info) {struct qmc_chan *chan;unsigned int i;
@@ -1019,7 +1019,7 @@ static int qmc_setup_tsa_32rx_32tx(struct qmc *qmc, const struct tsa_serial_inforeturn 0 ; } -static int qmc_setup_tsa (struct qmc *qmc) +static int qmc_init_tsa (struct qmc *qmc) {struct tsa_serial_info info;int ret;
@@ -1030,12 +1030,12 @@ static int qmc_setup_tsa(struct qmc *qmc)return ret;/* -* Setup one common 64 entries table or two 32 entries (one for Tx and -* one for Tx) according to assigned TS numbers. +* Initialize one common 64 entries table or two 32 entries (one for Tx +* and one for Tx) according to assigned TS numbers. */ return ((info.nb_tx_ts >32 ) || (info.nb_rx_ts >32 )) ? -qmc_setup_tsa_64rxtx (qmc, &info) : -qmc_setup_tsa_32rx_32tx (qmc, &info); +qmc_init_tsa_64rxtx (qmc, &info) : +qmc_init_tsa_32rx_32tx (qmc, &info); }static int qmc_setup_chan_trnsync (struct qmc *qmc,struct qmc_chan *chan)
@@ -1391,7 +1391,7 @@ static int qmc_probe(struct platform_device *pdev)qmc_write32 (qmc->scc_pram +QMC_GBL_C_MASK32 ,0xDEBB20E3 );qmc_write16 (qmc->scc_pram +QMC_GBL_C_MASK16 ,0xF0B8 ); - ret =qmc_setup_tsa (qmc); + ret =qmc_init_tsa (qmc);if (ret) goto err_tsa_serial_disconnect;
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 8/26 soc: fsl: cpm1: qmc: Introduce qmc_chan_setup_tsa*
In reply to Herve CodinaIntroduce the qmc_chan_setup_tsa* functions to setup entries related to the given channel.
Use them during QMC channels setup.
--- drivers/soc/fsl/qe/qmc.c | 161 ++++++++++++++++++++++++++++++--------- 1 file changed, 125 insertions(+), 36 deletions(-)
drivers/soc/fsl/qe/qmc.c +125 -36
@@ -240,6 +240,11 @@ static inline void qmc_clrbits16(void *__iomem addr, u16 clr)qmc_write16 (addr,qmc_read16 (addr) & ~clr); } +static inline void qmc_clrsetbits16 (void *__iomem addr,u16 clr,u16 set) +{ +qmc_write16 (addr, (qmc_read16 (addr) & ~clr) | set); +} +static inline void qmc_write32 (void *__iomem addr,u32 val) {iowrite32be (val, addr);
@@ -562,6 +567,122 @@ static void qmc_chan_read_done(struct qmc_chan *chan)spin_unlock_irqrestore (&chan->rx_lock, flags); } +static int qmc_chan_setup_tsa_64rxtx (struct qmc_chan *chan,const struct tsa_serial_info *info) +{ +unsigned int i; +u16 curr; +u16 val; + +/* +* Use a common Tx/Rx 64 entries table. +* Tx and Rx related stuffs must be identical +*/ +if (chan->tx_ts_mask != chan->rx_ts_mask) { +dev_err (chan->qmc->dev,"chan %u uses different Rx and Tx TS\n" , chan->id); +return -EINVAL ; + } + + val =QMC_TSA_VALID |QMC_TSA_MASK |QMC_TSA_CHANNEL (chan->id); + +/* Check entries based on Rx stuff*/ +for (i =0 ; i < info->nb_rx_ts; i++) { +if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) +continue ; + + curr =qmc_read16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 )); +if (curr &QMC_TSA_VALID && (curr & ~QMC_TSA_WRAP ) != val) { +dev_err (chan->qmc->dev,"chan %u TxRx entry %d already used\n" , + chan->id, i); +return -EBUSY ; + } + } + +/* Set entries based on Rx stuff*/ +for (i =0 ; i < info->nb_rx_ts; i++) { +if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) +continue ; + +qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), + ~QMC_TSA_WRAP , val); + } + +return 0 ; +} + +static int qmc_chan_setup_tsa_32rx_32tx (struct qmc_chan *chan,const struct tsa_serial_info *info) +{ +unsigned int i; +u16 curr; +u16 val; + +/* Use a Tx 32 entries table and a Rx 32 entries table */ + + val =QMC_TSA_VALID |QMC_TSA_MASK |QMC_TSA_CHANNEL (chan->id); + +/* Check entries based on Rx stuff */ +for (i =0 ; i < info->nb_rx_ts; i++) { +if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) +continue ; + + curr =qmc_read16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 )); +if (curr &QMC_TSA_VALID && (curr & ~QMC_TSA_WRAP ) != val) { +dev_err (chan->qmc->dev,"chan %u Rx entry %d already used\n" , + chan->id, i); +return -EBUSY ; + } + } +/* Check entries based on Tx stuff */ +for (i =0 ; i < info->nb_tx_ts; i++) { +if (!(chan->tx_ts_mask & (((u64 )1 ) << i))) +continue ; + + curr =qmc_read16 (chan->qmc->scc_pram +QMC_GBL_TSATTX + (i *2 )); +if (curr &QMC_TSA_VALID && (curr & ~QMC_TSA_WRAP ) != val) { +dev_err (chan->qmc->dev,"chan %u Tx entry %d already used\n" , + chan->id, i); +return -EBUSY ; + } + } + +/* Set entries based on Rx stuff */ +for (i =0 ; i < info->nb_rx_ts; i++) { +if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) +continue ; + +qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), + ~QMC_TSA_WRAP , val); + } +/* Set entries based on Tx stuff */ +for (i =0 ; i < info->nb_tx_ts; i++) { +if (!(chan->tx_ts_mask & (((u64 )1 ) << i))) +continue ; + +qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATTX + (i *2 ), + ~QMC_TSA_WRAP , val); + } + +return 0 ; +} + +static int qmc_chan_setup_tsa (struct qmc_chan *chan) +{ +struct tsa_serial_info info; +int ret; + +/* Retrieve info from the TSA related serial */ + ret =tsa_serial_get_info (chan->qmc->tsa_serial, &info); +if (ret) +return ret; + +/* +* Setup one common 64 entries table or two 32 entries (one for Tx +* and one for Tx) according to assigned TS numbers. +*/ +return ((info.nb_tx_ts >32 ) || (info.nb_rx_ts >32 )) ? +qmc_chan_setup_tsa_64rxtx (chan, &info) : +qmc_chan_setup_tsa_32rx_32tx (chan, &info); +} +static int qmc_chan_command (struct qmc_chan *chan,u8 qmc_opcode) {return cpm_command (chan->id <<2 , (qmc_opcode <<4 ) |0x0E );
@@ -921,7 +1042,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)static int qmc_init_tsa_64rxtx (struct qmc *qmc,const struct tsa_serial_info *info) { -struct qmc_chan *chan;unsigned int i;u16 val;
@@ -935,18 +1055,6 @@ static int qmc_init_tsa_64rxtx(struct qmc *qmc, const struct tsa_serial_info *infor (i =0 ; i <64 ; i++)qmc_write16 (qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ),0x0000 ); -/* Set entries based on Rx stuff*/ -list_for_each_entry (chan, &qmc->chan_head, list) { -for (i =0 ; i < info->nb_rx_ts; i++) { -if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) -continue ; - - val =QMC_TSA_VALID |QMC_TSA_MASK | -QMC_TSA_CHANNEL (chan->id); -qmc_write16 (qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), val); - } - } -/* Set Wrap bit on last entry */ qmc_setbits16 (qmc->scc_pram +QMC_GBL_TSATRX + ((info->nb_rx_ts -1 ) *2 ),QMC_TSA_WRAP );
@@ -963,7 +1071,6 @@ static int qmc_init_tsa_64rxtx(struct qmc *qmc, const struct tsa_serial_info *instatic int qmc_init_tsa_32rx_32tx (struct qmc *qmc,const struct tsa_serial_info *info) { -struct qmc_chan *chan;unsigned int i;u16 val;
@@ -978,28 +1085,6 @@ static int qmc_init_tsa_32rx_32tx(struct qmc *qmc, const struct tsa_serial_infoqmc_write16 (qmc->scc_pram +QMC_GBL_TSATTX + (i *2 ),0x0000 ); } -/* Set entries based on Rx and Tx stuff*/ -list_for_each_entry (chan, &qmc->chan_head, list) { -/* Rx part */ -for (i =0 ; i < info->nb_rx_ts; i++) { -if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) -continue ; - - val =QMC_TSA_VALID |QMC_TSA_MASK | -QMC_TSA_CHANNEL (chan->id); -qmc_write16 (qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), val); - } -/* Tx part */ -for (i =0 ; i < info->nb_tx_ts; i++) { -if (!(chan->tx_ts_mask & (((u64 )1 ) << i))) -continue ; - - val =QMC_TSA_VALID |QMC_TSA_MASK | -QMC_TSA_CHANNEL (chan->id); -qmc_write16 (qmc->scc_pram +QMC_GBL_TSATTX + (i *2 ), val); - } - } -/* Set Wrap bit on last entries */ qmc_setbits16 (qmc->scc_pram +QMC_GBL_TSATRX + ((info->nb_rx_ts -1 ) *2 ),QMC_TSA_WRAP );
@@ -1081,6 +1166,10 @@ static int qmc_setup_chan(struct qmc *qmc, struct qmc_chan *chan) chan->qmc = qmc; + ret =qmc_chan_setup_tsa (chan); +if (ret) +return ret; +/* Set channel specific parameter base address */ chan->s_param = qmc->dpram + (chan->id *64 );/* 16 bd per channel (8 rx and 8 tx) */
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 9/26 soc: fsl: cpm1: qmc: Remove no more needed checks from qmc_check_chans()
In reply to Herve CodinaThe newly introduced qmc_chan_setup_tsa* functions check that the channel entries are not already used.
These checks are also performed by qmc_check_chans() and are no more needed.
Remove them from qmc_check_chans().
--- drivers/soc/fsl/qe/qmc.c | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/soc/fsl/qe/qmc.c +0 -20
@@ -884,10 +884,7 @@ EXPORT_SYMBOL(qmc_chan_reset);static int qmc_check_chans (struct qmc *qmc) {struct tsa_serial_info info; -bool is_one_table = false;struct qmc_chan *chan; -u64 tx_ts_mask =0 ; -u64 rx_ts_mask =0 ;u64 tx_ts_assigned_mask;u64 rx_ts_assigned_mask;int ret;
@@ -911,7 +908,6 @@ static int qmc_check_chans(struct qmc *qmc)dev_err (qmc->dev,"Number of TSA Tx/Rx TS assigned are not equal\n" );return -EINVAL ; } - is_one_table = true; } tx_ts_assigned_mask = info.nb_tx_ts ==64 ?U64_MAX : (((u64 )1 ) << info.nb_tx_ts) -1 ;
@@ -922,27 +918,11 @@ static int qmc_check_chans(struct qmc *qmc)dev_err (qmc->dev,"chan %u uses TSA unassigned Tx TS\n" , chan->id);return -EINVAL ; } -if (tx_ts_mask & chan->tx_ts_mask) { -dev_err (qmc->dev,"chan %u uses an already used Tx TS\n" , chan->id); -return -EINVAL ; - }if (chan->rx_ts_mask > rx_ts_assigned_mask) {dev_err (qmc->dev,"chan %u uses TSA unassigned Rx TS\n" , chan->id);return -EINVAL ; } -if (rx_ts_mask & chan->rx_ts_mask) { -dev_err (qmc->dev,"chan %u uses an already used Rx TS\n" , chan->id); -return -EINVAL ; - } - -if (is_one_table && (chan->tx_ts_mask != chan->rx_ts_mask)) { -dev_err (qmc->dev,"chan %u uses different Rx and Tx TS\n" , chan->id); -return -EINVAL ; - } - - tx_ts_mask |= chan->tx_ts_mask; - rx_ts_mask |= chan->rx_ts_mask; }return 0 ;
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 10/26 soc: fsl: cpm1: qmc: Check available timeslots in qmc_check_chans()
In reply to Herve CodinaThe timeslots checked in qmc_check_chans() are the timeslots used. With the introduction of the available timeslots, the used timeslots are a subset of the available timeslots. The timeslots checked during the qmc_check_chans() call should be the available ones.
Simply update and check the available timeslots instead of the used timeslots in qmc_check_chans().
--- drivers/soc/fsl/qe/qmc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soc/fsl/qe/qmc.c +4 -4
@@ -914,13 +914,13 @@ static int qmc_check_chans(struct qmc *qmc) rx_ts_assigned_mask = info.nb_rx_ts ==64 ?U64_MAX : (((u64 )1 ) << info.nb_rx_ts) -1 ;list_for_each_entry (chan, &qmc->chan_head, list) { -if (chan->tx_ts_mask > tx_ts_assigned_mask) { -dev_err (qmc->dev,"chan %u uses TSA unassigned Tx TS\n" , chan->id); +if (chan->tx_ts_mask_avail > tx_ts_assigned_mask) { +dev_err (qmc->dev,"chan %u can use TSA unassigned Tx TS\n" , chan->id);return -EINVAL ; } -if (chan->rx_ts_mask > rx_ts_assigned_mask) { -dev_err (qmc->dev,"chan %u uses TSA unassigned Rx TS\n" , chan->id); +if (chan->rx_ts_mask_avail > rx_ts_assigned_mask) { +dev_err (qmc->dev,"chan %u can use TSA unassigned Rx TS\n" , chan->id);return -EINVAL ; } }
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 11/26 soc: fsl: cpm1: qmc: Add support for disabling channel TSA entries
In reply to Herve CodinaIn order to allow runtime timeslot route changes, disabling channel TSA entries needs to be supported.
Add support for this new feature.
--- drivers/soc/fsl/qe/qmc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/soc/fsl/qe/qmc.c +11 -9
@@ -567,7 +567,8 @@ static void qmc_chan_read_done(struct qmc_chan *chan)spin_unlock_irqrestore (&chan->rx_lock, flags); } -static int qmc_chan_setup_tsa_64rxtx (struct qmc_chan *chan,const struct tsa_serial_info *info) +static int qmc_chan_setup_tsa_64rxtx (struct qmc_chan *chan,const struct tsa_serial_info *info, +bool enable) {unsigned int i;u16 curr;
@@ -603,13 +604,14 @@ static int qmc_chan_setup_tsa_64rxtx(struct qmc_chan *chan, const struct tsa_sercontinue ;qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), - ~QMC_TSA_WRAP , val); + ~QMC_TSA_WRAP , enable ? val :0x0000 ); }return 0 ; } -static int qmc_chan_setup_tsa_32rx_32tx (struct qmc_chan *chan,const struct tsa_serial_info *info) +static int qmc_chan_setup_tsa_32rx_32tx (struct qmc_chan *chan,const struct tsa_serial_info *info, +bool enable) {unsigned int i;u16 curr;
@@ -650,7 +652,7 @@ static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_continue ;qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), - ~QMC_TSA_WRAP , val); + ~QMC_TSA_WRAP , enable ? val :0x0000 ); }/* Set entries based on Tx stuff */ for (i =0 ; i < info->nb_tx_ts; i++) {
@@ -658,13 +660,13 @@ static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_continue ;qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATTX + (i *2 ), - ~QMC_TSA_WRAP , val); + ~QMC_TSA_WRAP , enable ? val :0x0000 ); }return 0 ; } -static int qmc_chan_setup_tsa (struct qmc_chan *chan) +static int qmc_chan_setup_tsa (struct qmc_chan *chan,bool enable) {struct tsa_serial_info info;int ret;
@@ -679,8 +681,8 @@ static int qmc_chan_setup_tsa(struct qmc_chan *chan)* and one for Tx) according to assigned TS numbers. */ return ((info.nb_tx_ts >32 ) || (info.nb_rx_ts >32 )) ? -qmc_chan_setup_tsa_64rxtx (chan, &info) : -qmc_chan_setup_tsa_32rx_32tx (chan, &info); +qmc_chan_setup_tsa_64rxtx (chan, &info, enable) : +qmc_chan_setup_tsa_32rx_32tx (chan, &info, enable); }static int qmc_chan_command (struct qmc_chan *chan,u8 qmc_opcode)
@@ -1146,7 +1148,7 @@ static int qmc_setup_chan(struct qmc *qmc, struct qmc_chan *chan) chan->qmc = qmc; - ret =qmc_chan_setup_tsa (chan); + ret =qmc_chan_setup_tsa (chan, true);if (ret)return ret;
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 12/26 soc: fsl: cpm1: qmc: Split Tx and Rx TSA entries setup
In reply to Herve CodinaThe Tx and Rx entries for a given channel are set in one function.
In order to modify Rx entries and Tx entries independently of one other, split this function in one for the Rx part and one for the Tx part.
--- drivers/soc/fsl/qe/qmc.c | 49 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-)
drivers/soc/fsl/qe/qmc.c +35 -14
@@ -610,14 +610,14 @@ static int qmc_chan_setup_tsa_64rxtx(struct qmc_chan *chan, const struct tsa_serreturn 0 ; } -static int qmc_chan_setup_tsa_32rx_32tx (struct qmc_chan *chan,const struct tsa_serial_info *info, -bool enable) +static int qmc_chan_setup_tsa_32rx (struct qmc_chan *chan,const struct tsa_serial_info *info, +bool enable) {unsigned int i;u16 curr;u16 val; -/* Use a Tx 32 entries table and a Rx 32 entries table */ +/* Use a Rx 32 entries table */ val =QMC_TSA_VALID |QMC_TSA_MASK |QMC_TSA_CHANNEL (chan->id);
@@ -633,6 +633,30 @@ static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_return -EBUSY ; } } + +/* Set entries based on Rx stuff */ +for (i =0 ; i < info->nb_rx_ts; i++) { +if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) +continue ; + +qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), + ~QMC_TSA_WRAP , enable ? val :0x0000 ); + } + +return 0 ; +} + +static int qmc_chan_setup_tsa_32tx (struct qmc_chan *chan,const struct tsa_serial_info *info, +bool enable) +{ +unsigned int i; +u16 curr; +u16 val; + +/* Use a Tx 32 entries table */ + + val =QMC_TSA_VALID |QMC_TSA_MASK |QMC_TSA_CHANNEL (chan->id); +/* Check entries based on Tx stuff */ for (i =0 ; i < info->nb_tx_ts; i++) {if (!(chan->tx_ts_mask & (((u64 )1 ) << i)))
@@ -646,14 +670,6 @@ static int qmc_chan_setup_tsa_32rx_32tx(struct qmc_chan *chan, const struct tsa_ } } -/* Set entries based on Rx stuff */ -for (i =0 ; i < info->nb_rx_ts; i++) { -if (!(chan->rx_ts_mask & (((u64 )1 ) << i))) -continue ; - -qmc_clrsetbits16 (chan->qmc->scc_pram +QMC_GBL_TSATRX + (i *2 ), - ~QMC_TSA_WRAP , enable ? val :0x0000 ); - }/* Set entries based on Tx stuff */ for (i =0 ; i < info->nb_tx_ts; i++) {if (!(chan->tx_ts_mask & (((u64 )1 ) << i)))
@@ -680,9 +696,14 @@ static int qmc_chan_setup_tsa(struct qmc_chan *chan, bool enable)* Setup one common 64 entries table or two 32 entries (one for Tx * and one for Tx) according to assigned TS numbers. */ -return ((info.nb_tx_ts >32 ) || (info.nb_rx_ts >32 )) ? -qmc_chan_setup_tsa_64rxtx (chan, &info, enable) : -qmc_chan_setup_tsa_32rx_32tx (chan, &info, enable); +if (info.nb_tx_ts >32 || info.nb_rx_ts >32 ) +return qmc_chan_setup_tsa_64rxtx (chan, &info, enable); + + ret =qmc_chan_setup_tsa_32rx (chan, &info, enable); +if (ret) +return ret; + +return qmc_chan_setup_tsa_32tx (chan, &info, enable); }static int qmc_chan_command (struct qmc_chan *chan,u8 qmc_opcode)
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 13/26 soc: fsl: cpm1: qmc: Introduce is_tsa_64rxtx flag
In reply to Herve CodinaIn order to support runtime timeslot route changes, some operations will be different according the routing table used (common Rx and Tx table or one table for Rx and one for Tx).
The is_tsa_64rxtx flag is introduced to avoid extra computation to determine the table format each time we need it.
It is set once at initialization.
--- drivers/soc/fsl/qe/qmc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/soc/fsl/qe/qmc.c +4 -1
@@ -216,6 +216,7 @@ struct qmc {u16 __iomem *int_curr;dma_addr_t int_dma_addr;size_t int_size; +bool is_tsa_64rxtx;struct list_head chan_head;struct qmc_chan *chans[64 ]; };
@@ -696,7 +697,7 @@ static int qmc_chan_setup_tsa(struct qmc_chan *chan, bool enable)* Setup one common 64 entries table or two 32 entries (one for Tx * and one for Tx) according to assigned TS numbers. */ -if (info.nb_tx_ts >32 || info.nb_rx_ts >32 ) +if (chan->qmc->is_tsa_64rxtx)return qmc_chan_setup_tsa_64rxtx (chan, &info, enable); ret =qmc_chan_setup_tsa_32rx (chan, &info, enable);
@@ -1053,6 +1054,7 @@ static int qmc_init_tsa_64rxtx(struct qmc *qmc, const struct tsa_serial_info *in* Everything was previously checked, Tx and Rx related stuffs are * identical -> Used Rx related stuff to build the table */ + qmc->is_tsa_64rxtx = true;/* Invalidate all entries */ for (i =0 ; i <64 ; i++)
@@ -1081,6 +1083,7 @@ static int qmc_init_tsa_32rx_32tx(struct qmc *qmc, const struct tsa_serial_info* Use a Tx 32 entries table and a Rx 32 entries table. * Everything was previously checked. */ + qmc->is_tsa_64rxtx = false;/* Invalidate all entries */ for (i =0 ; i <32 ; i++) {
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 14/26 soc: fsl: cpm1: qmc: Handle timeslot entries at channel start() and stop()
In reply to Herve CodinaIn order to support runtime timeslot route changes, enable the channel timeslot entries at channel start() and disable them at channel stop().
--- drivers/soc/fsl/qe/qmc.c | 175 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 163 insertions(+), 12 deletions(-)
drivers/soc/fsl/qe/qmc.c +163 -12
@@ -177,6 +177,7 @@ struct qmc_chan {struct qmc *qmc;void *__iomem s_param;enum qmc_mode mode; +spinlock_t ts_lock;/* Protect timeslots */ u64 tx_ts_mask_avail;u64 tx_ts_mask;u64 rx_ts_mask_avail;
@@ -265,6 +266,7 @@ static inline void qmc_setbits32(void *__iomem addr, u32 set)int qmc_chan_get_info (struct qmc_chan *chan,struct qmc_chan_info *info) {struct tsa_serial_info tsa_info; +unsigned long flags;int ret;/* Retrieve info from the TSA related serial */
@@ -272,6 +274,8 @@ int qmc_chan_get_info(struct qmc_chan *chan, struct qmc_chan_info *info)if (ret)return ret; +spin_lock_irqsave (&chan->ts_lock, flags); + info->mode = chan->mode; info->rx_fs_rate = tsa_info.rx_fs_rate; info->rx_bit_rate = tsa_info.rx_bit_rate;
@@ -280,6 +284,8 @@ int qmc_chan_get_info(struct qmc_chan *chan, struct qmc_chan_info *info) info->tx_bit_rate = tsa_info.tx_bit_rate; info->nb_rx_ts =hweight64 (chan->rx_ts_mask); +spin_unlock_irqrestore (&chan->ts_lock, flags); +return 0 ; }EXPORT_SYMBOL (qmc_chan_get_info);
@@ -683,6 +689,40 @@ static int qmc_chan_setup_tsa_32tx(struct qmc_chan *chan, const struct tsa_seriareturn 0 ; } +static int qmc_chan_setup_tsa_tx (struct qmc_chan *chan,bool enable) +{ +struct tsa_serial_info info; +int ret; + +/* Retrieve info from the TSA related serial */ + ret =tsa_serial_get_info (chan->qmc->tsa_serial, &info); +if (ret) +return ret; + +/* Setup entries */ +if (chan->qmc->is_tsa_64rxtx) +return qmc_chan_setup_tsa_64rxtx (chan, &info, enable); + +return qmc_chan_setup_tsa_32tx (chan, &info, enable); +} + +static int qmc_chan_setup_tsa_rx (struct qmc_chan *chan,bool enable) +{ +struct tsa_serial_info info; +int ret; + +/* Retrieve info from the TSA related serial */ + ret =tsa_serial_get_info (chan->qmc->tsa_serial, &info); +if (ret) +return ret; + +/* Setup entries */ +if (chan->qmc->is_tsa_64rxtx) +return qmc_chan_setup_tsa_64rxtx (chan, &info, enable); + +return qmc_chan_setup_tsa_32rx (chan, &info, enable); +} +static int qmc_chan_setup_tsa (struct qmc_chan *chan,bool enable) {struct tsa_serial_info info;
@@ -719,6 +759,12 @@ static int qmc_chan_stop_rx(struct qmc_chan *chan)spin_lock_irqsave (&chan->rx_lock, flags); +if (chan->is_rx_stopped) { +/* The channel is already stopped -> simply return ok */ + ret =0 ; + goto end; + } +/* Send STOP RECEIVE command */ ret =qmc_chan_command (chan,0x0 );if (ret) {
@@ -729,6 +775,15 @@ static int qmc_chan_stop_rx(struct qmc_chan *chan) chan->is_rx_stopped = true; +if (!chan->qmc->is_tsa_64rxtx || chan->is_tx_stopped) { + ret =qmc_chan_setup_tsa_rx (chan, false); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: Disable tsa entries failed (%d)\n" , + chan->id, ret); + goto end; + } + } + end:spin_unlock_irqrestore (&chan->rx_lock, flags);return ret;
@@ -741,6 +796,12 @@ static int qmc_chan_stop_tx(struct qmc_chan *chan)spin_lock_irqsave (&chan->tx_lock, flags); +if (chan->is_tx_stopped) { +/* The channel is already stopped -> simply return ok */ + ret =0 ; + goto end; + } +/* Send STOP TRANSMIT command */ ret =qmc_chan_command (chan,0x1 );if (ret) {
@@ -751,37 +812,82 @@ static int qmc_chan_stop_tx(struct qmc_chan *chan) chan->is_tx_stopped = true; +if (!chan->qmc->is_tsa_64rxtx || chan->is_rx_stopped) { + ret =qmc_chan_setup_tsa_tx (chan, false); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: Disable tsa entries failed (%d)\n" , + chan->id, ret); + goto end; + } + } + end:spin_unlock_irqrestore (&chan->tx_lock, flags);return ret; } +static int qmc_chan_start_rx (struct qmc_chan *chan); +int qmc_chan_stop (struct qmc_chan *chan,int direction) { -int ret; +bool is_rx_rollback_needed = false; +unsigned long flags; +int ret =0 ; + +spin_lock_irqsave (&chan->ts_lock, flags);if (direction &QMC_CHAN_READ ) { + is_rx_rollback_needed = !chan->is_rx_stopped; ret =qmc_chan_stop_rx (chan);if (ret) -return ret; + goto end; }if (direction &QMC_CHAN_WRITE ) { ret =qmc_chan_stop_tx (chan); -if (ret) -return ret; +if (ret) { +/* Restart rx if needed */ +if (is_rx_rollback_needed) +qmc_chan_start_rx (chan); + goto end; + } } -return 0 ; +end: +spin_unlock_irqrestore (&chan->ts_lock, flags); +return ret; }EXPORT_SYMBOL (qmc_chan_stop); -static void qmc_chan_start_rx (struct qmc_chan *chan) +static int qmc_setup_chan_trnsync (struct qmc *qmc,struct qmc_chan *chan); + +static int qmc_chan_start_rx (struct qmc_chan *chan) {unsigned long flags; +int ret;spin_lock_irqsave (&chan->rx_lock, flags); +if (!chan->is_rx_stopped) { +/* The channel is already started -> simply return ok */ + ret =0 ; + goto end; + } + + ret =qmc_chan_setup_tsa_rx (chan, true); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: Enable tsa entries failed (%d)\n" , + chan->id, ret); + goto end; + } + + ret =qmc_setup_chan_trnsync (chan->qmc, chan); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: setup TRNSYNC failed (%d)\n" , + chan->id, ret); + goto end; + } +/* Restart the receiver */ if (chan->mode ==QMC_TRANSPARENT )qmc_write32 (chan->s_param +QMC_SPE_ZDSTATE ,0x18000080 );
@@ -792,15 +898,38 @@ static void qmc_chan_start_rx(struct qmc_chan *chan) chan->is_rx_stopped = false; +end:spin_unlock_irqrestore (&chan->rx_lock, flags); +return ret; } -static void qmc_chan_start_tx (struct qmc_chan *chan) +static int qmc_chan_start_tx (struct qmc_chan *chan) {unsigned long flags; +int ret;spin_lock_irqsave (&chan->tx_lock, flags); +if (!chan->is_tx_stopped) { +/* The channel is already started -> simply return ok */ + ret =0 ; + goto end; + } + + ret =qmc_chan_setup_tsa_tx (chan, true); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: Enable tsa entries failed (%d)\n" , + chan->id, ret); + goto end; + } + + ret =qmc_setup_chan_trnsync (chan->qmc, chan); +if (ret) { +dev_err (chan->qmc->dev,"chan %u: setup TRNSYNC failed (%d)\n" , + chan->id, ret); + goto end; + } +/* * Enable channel transmitter as it could be disabled if * qmc_chan_reset() was called.
@@ -812,18 +941,39 @@ static void qmc_chan_start_tx(struct qmc_chan *chan) chan->is_tx_stopped = false; +end:spin_unlock_irqrestore (&chan->tx_lock, flags); +return ret; }int qmc_chan_start (struct qmc_chan *chan,int direction) { -if (direction &QMC_CHAN_READ ) -qmc_chan_start_rx (chan); +bool is_rx_rollback_needed = false; +unsigned long flags; +int ret =0 ; -if (direction &QMC_CHAN_WRITE ) -qmc_chan_start_tx (chan); +spin_lock_irqsave (&chan->ts_lock, flags); -return 0 ; +if (direction &QMC_CHAN_READ ) { + is_rx_rollback_needed = chan->is_rx_stopped; + ret =qmc_chan_start_rx (chan); +if (ret) + goto end; + } + +if (direction &QMC_CHAN_WRITE ) { + ret =qmc_chan_start_tx (chan); +if (ret) { +/* Restop rx if needed */ +if (is_rx_rollback_needed) +qmc_chan_stop_rx (chan); + goto end; + } + } + +end: +spin_unlock_irqrestore (&chan->ts_lock, flags); +return ret; }EXPORT_SYMBOL (qmc_chan_start);
@@ -992,6 +1142,7 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np) } chan->id = chan_id; +spin_lock_init (&chan->ts_lock);spin_lock_init (&chan->rx_lock);spin_lock_init (&chan->tx_lock);
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 15/26 soc: fsl: cpm1: qmc: Remove timeslots handling from setup_chan()
In reply to Herve CodinaTimeslots setting is done at channel start() and stop(). There is no more need to do that during setup_chan().
Simply remove timeslot setting from setup_chan().
--- drivers/soc/fsl/qe/qmc.c | 28 ---------------------------- 1 file changed, 28 deletions(-)
drivers/soc/fsl/qe/qmc.c +0 -28
@@ -723,30 +723,6 @@ static int qmc_chan_setup_tsa_rx(struct qmc_chan *chan, bool enable)return qmc_chan_setup_tsa_32rx (chan, &info, enable); } -static int qmc_chan_setup_tsa (struct qmc_chan *chan,bool enable) -{ -struct tsa_serial_info info; -int ret; - -/* Retrieve info from the TSA related serial */ - ret =tsa_serial_get_info (chan->qmc->tsa_serial, &info); -if (ret) -return ret; - -/* -* Setup one common 64 entries table or two 32 entries (one for Tx -* and one for Tx) according to assigned TS numbers. -*/ -if (chan->qmc->is_tsa_64rxtx) -return qmc_chan_setup_tsa_64rxtx (chan, &info, enable); - - ret =qmc_chan_setup_tsa_32rx (chan, &info, enable); -if (ret) -return ret; - -return qmc_chan_setup_tsa_32tx (chan, &info, enable); -} -static int qmc_chan_command (struct qmc_chan *chan,u8 qmc_opcode) {return cpm_command (chan->id <<2 , (qmc_opcode <<4 ) |0x0E );
@@ -1323,10 +1299,6 @@ static int qmc_setup_chan(struct qmc *qmc, struct qmc_chan *chan) chan->qmc = qmc; - ret =qmc_chan_setup_tsa (chan, true); -if (ret) -return ret; -/* Set channel specific parameter base address */ chan->s_param = qmc->dpram + (chan->id *64 );/* 16 bd per channel (8 rx and 8 tx) */
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 16/26 soc: fsl: cpm1: qmc: Introduce functions to change timeslots at runtime
In reply to Herve CodinaIntroduce qmc_chan_{get,set}_ts_info() function to allow timeslots modification at runtime.
The modification is provided using qmc_chan_set_ts_info() and will be applied on next qmc_chan_start().qmc_chan_set_ts_info() must be called with the channel rx and/or tx stopped.
--- drivers/soc/fsl/qe/qmc.c | 51 ++++++++++++++++++++++++++++++++++++++++ include/soc/fsl/qe/qmc.h | 10 ++++++++ 2 files changed, 61 insertions(+)
drivers/soc/fsl/qe/qmc.c +51 -0
@@ -290,6 +290,57 @@ int qmc_chan_get_info(struct qmc_chan *chan, struct qmc_chan_info *info) }EXPORT_SYMBOL (qmc_chan_get_info); +int qmc_chan_get_ts_info (struct qmc_chan *chan,struct qmc_chan_ts_info *ts_info) +{ +unsigned long flags; + +spin_lock_irqsave (&chan->ts_lock, flags); + + ts_info->rx_ts_mask_avail = chan->rx_ts_mask_avail; + ts_info->tx_ts_mask_avail = chan->tx_ts_mask_avail; + ts_info->rx_ts_mask = chan->rx_ts_mask; + ts_info->tx_ts_mask = chan->tx_ts_mask; + +spin_unlock_irqrestore (&chan->ts_lock, flags); + +return 0 ; +} +EXPORT_SYMBOL (qmc_chan_get_ts_info); + +int qmc_chan_set_ts_info (struct qmc_chan *chan,const struct qmc_chan_ts_info *ts_info) +{ +unsigned long flags; +int ret; + +/* Only a subset of available timeslots is allowed */ +if ((ts_info->rx_ts_mask & chan->rx_ts_mask_avail) != ts_info->rx_ts_mask) +return -EINVAL ; +if ((ts_info->tx_ts_mask & chan->tx_ts_mask_avail) != ts_info->tx_ts_mask) +return -EINVAL ; + +/* In case of common rx/tx table, rx/tx masks must be identical */ +if (chan->qmc->is_tsa_64rxtx) { +if (ts_info->rx_ts_mask != ts_info->tx_ts_mask) +return -EINVAL ; + } + +spin_lock_irqsave (&chan->ts_lock, flags); + +if ((chan->tx_ts_mask != ts_info->tx_ts_mask && !chan->is_tx_stopped) || + (chan->rx_ts_mask != ts_info->rx_ts_mask && !chan->is_rx_stopped)) { +dev_err (chan->qmc->dev,"Channel rx and/or tx not stopped\n" ); + ret = -EBUSY ; + }else { + chan->tx_ts_mask = ts_info->tx_ts_mask; + chan->rx_ts_mask = ts_info->rx_ts_mask; + ret =0 ; + } +spin_unlock_irqrestore (&chan->ts_lock, flags); + +return ret; +} +EXPORT_SYMBOL (qmc_chan_set_ts_info); +int qmc_chan_set_param (struct qmc_chan *chan,const struct qmc_chan_param *param) {if (param->mode != chan->mode)
include/soc/fsl/qe/qmc.h +10 -0
@@ -38,6 +38,16 @@ struct qmc_chan_info {int qmc_chan_get_info (struct qmc_chan *chan,struct qmc_chan_info *info); +struct qmc_chan_ts_info { +u64 rx_ts_mask_avail; +u64 tx_ts_mask_avail; +u64 rx_ts_mask; +u64 tx_ts_mask; +}; + +int qmc_chan_get_ts_info (struct qmc_chan *chan,struct qmc_chan_ts_info *ts_info); +int qmc_chan_set_ts_info (struct qmc_chan *chan,const struct qmc_chan_ts_info *ts_info); +struct qmc_chan_param {enum qmc_mode mode;union {
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 17/26 wan: qmc_hdlc: Add runtime timeslots changes support
In reply to Herve CodinaQMC channels support runtime timeslots changes but nothing is done at the QMC HDLC driver to handle these changes.
Use existing IFACE ioctl in order to configure the timeslots to use.
--- drivers/net/wan/fsl_qmc_hdlc.c | 170 ++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 1 deletion(-)
drivers/net/wan/fsl_qmc_hdlc.c +169 -1
@@ -32,6 +32,7 @@ struct qmc_hdlc {struct qmc_hdlc_desc tx_descs[8 ];unsigned int tx_out;struct qmc_hdlc_desc rx_descs[4 ]; +u32 slot_map; };static inline struct qmc_hdlc *netdev_to_qmc_hdlc (struct net_device *netdev)
@@ -202,6 +203,163 @@ static netdev_tx_t qmc_hdlc_xmit(struct sk_buff *skb, struct net_device *netdev)return NETDEV_TX_OK ; } +static int qmc_hdlc_xlate_slot_map (struct qmc_hdlc *qmc_hdlc, +u32 slot_map,struct qmc_chan_ts_info *ts_info) +{ +u64 ts_mask_avail; +unsigned int bit; +unsigned int i; +u64 ts_mask; +u64 map =0 ; + +/* Tx and Rx masks must be identical */ +if (ts_info->rx_ts_mask_avail != ts_info->tx_ts_mask_avail) { +dev_err (qmc_hdlc->dev,"tx and rx available timeslots mismatch (0x%llx, 0x%llx)\n" , + ts_info->rx_ts_mask_avail, ts_info->tx_ts_mask_avail); +return -EINVAL ; + } + + ts_mask_avail = ts_info->rx_ts_mask_avail; + ts_mask =0 ; + map = slot_map; + bit =0 ; +for (i =0 ; i <64 ; i++) { +if (ts_mask_avail &BIT_ULL (i)) { +if (map &BIT_ULL (bit)) + ts_mask |=BIT_ULL (i); + bit++; + } + } + +if (hweight64 (ts_mask) !=hweight64 (map)) { +dev_err (qmc_hdlc->dev,"Cannot translate timeslots 0x%llx -> (0x%llx,0x%llx)\n" , + map, ts_mask_avail, ts_mask); +return -EINVAL ; + } + + ts_info->tx_ts_mask = ts_mask; + ts_info->rx_ts_mask = ts_mask; +return 0 ; +} + +static int qmc_hdlc_xlate_ts_info (struct qmc_hdlc *qmc_hdlc, +const struct qmc_chan_ts_info *ts_info,u32 *slot_map) +{ +u64 ts_mask_avail; +unsigned int bit; +unsigned int i; +u64 ts_mask; +u64 map =0 ; + +/* Tx and Rx masks must be identical */ +if (ts_info->rx_ts_mask_avail != ts_info->tx_ts_mask_avail) { +dev_err (qmc_hdlc->dev,"tx and rx available timeslots mismatch (0x%llx, 0x%llx)\n" , + ts_info->rx_ts_mask_avail, ts_info->tx_ts_mask_avail); +return -EINVAL ; + } +if (ts_info->rx_ts_mask != ts_info->tx_ts_mask) { +dev_err (qmc_hdlc->dev,"tx and rx timeslots mismatch (0x%llx, 0x%llx)\n" , + ts_info->rx_ts_mask, ts_info->tx_ts_mask); +return -EINVAL ; + } + + ts_mask_avail = ts_info->rx_ts_mask_avail; + ts_mask = ts_info->rx_ts_mask; + map =0 ; + bit =0 ; +for (i =0 ; i <64 ; i++) { +if (ts_mask_avail &BIT_ULL (i)) { +if (ts_mask &BIT_ULL (i)) + map |=BIT_ULL (bit); + bit++; + } + } + +if (hweight64 (ts_mask) !=hweight64 (map)) { +dev_err (qmc_hdlc->dev,"Cannot translate timeslots (0x%llx,0x%llx) -> 0x%llx\n" , + ts_mask_avail, ts_mask, map); +return -EINVAL ; + } + +if (map >=BIT_ULL (32 )) { +dev_err (qmc_hdlc->dev,"Slot map out of 32bit (0x%llx,0x%llx) -> 0x%llx\n" , + ts_mask_avail, ts_mask, map); +return -EINVAL ; + } + + *slot_map = map; +return 0 ; +} + +static int qmc_hdlc_set_iface (struct qmc_hdlc *qmc_hdlc,int if_iface,const te1_settings *te1) +{ +struct qmc_chan_ts_info ts_info; +int ret; + + ret =qmc_chan_get_ts_info (qmc_hdlc->qmc_chan, &ts_info); +if (ret) { +dev_err (qmc_hdlc->dev,"get QMC channel ts info failed %d\n" , ret); +return ret; + } + ret =qmc_hdlc_xlate_slot_map (qmc_hdlc, te1->slot_map, &ts_info); +if (ret) +return ret; + + ret =qmc_chan_set_ts_info (qmc_hdlc->qmc_chan, &ts_info); +if (ret) { +dev_err (qmc_hdlc->dev,"set QMC channel ts info failed %d\n" , ret); +return ret; + } + + qmc_hdlc->slot_map = te1->slot_map; + +return 0 ; +} + +static int qmc_hdlc_ioctl (struct net_device *netdev,struct if_settings *ifs) +{ +struct qmc_hdlc *qmc_hdlc =netdev_to_qmc_hdlc (netdev); +te1_settings te1; +int ret; + +switch (ifs->type) { +case IF_GET_IFACE : + ifs->type =IF_IFACE_E1 ; +if (ifs->size <sizeof (te1)) { +if (!ifs->size) +return 0 ;/* only type requested */ + + ifs->size =sizeof (te1);/* data size wanted */ +return -ENOBUFS ; + } + +memset (&te1,0 ,sizeof (te1)); + +/* Update slot_map */ + te1.slot_map = qmc_hdlc->slot_map; + +if (copy_to_user (ifs->ifs_ifsu.te1, &te1,sizeof (te1))) +return -EFAULT ; +return 0 ; + +case IF_IFACE_E1 : +case IF_IFACE_T1 : +if (!capable (CAP_NET_ADMIN )) +return -EPERM ; + +if (netdev->flags &IFF_UP ) +return -EBUSY ; + +if (copy_from_user (&te1, ifs->ifs_ifsu.te1,sizeof (te1))) +return -EFAULT ; + +return qmc_hdlc_set_iface (qmc_hdlc, ifs->type, &te1); + +default : +return hdlc_ioctl (netdev, ifs); + } +} +static int qmc_hdlc_open (struct net_device *netdev) {struct qmc_hdlc *qmc_hdlc =netdev_to_qmc_hdlc (netdev);
@@ -328,13 +486,14 @@ static const struct net_device_ops qmc_hdlc_netdev_ops = { .ndo_open = qmc_hdlc_open, .ndo_stop = qmc_hdlc_close, .ndo_start_xmit = hdlc_start_xmit, - .ndo_siocwandev = hdlc_ioctl, + .ndo_siocwandev = qmc_hdlc_ioctl, };static int qmc_hdlc_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node;struct qmc_hdlc *qmc_hdlc; +struct qmc_chan_ts_info ts_info;struct qmc_chan_info info;hdlc_device *hdlc;int ret;
@@ -364,6 +523,15 @@ static int qmc_hdlc_probe(struct platform_device *pdev)return -EINVAL ; } + ret =qmc_chan_get_ts_info (qmc_hdlc->qmc_chan, &ts_info); +if (ret) { +dev_err (qmc_hdlc->dev,"get QMC channel ts info failed %d\n" , ret); +return ret; + } + ret =qmc_hdlc_xlate_ts_info (qmc_hdlc, &ts_info, &qmc_hdlc->slot_map); +if (ret) +return ret; + qmc_hdlc->netdev =alloc_hdlcdev (qmc_hdlc);if (!qmc_hdlc->netdev) {dev_err (qmc_hdlc->dev,"failed to alloc hdlc dev\n" );
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 18/26 net: wan: Add framer framework support
In reply to Herve CodinaA framer is a component in charge of an E1/T1 line interface. Connected usually to a TDM bus, it converts TDM frames to/from E1/T1 frames. It also provides information related to the E1/T1 line.
The framer framework provides a set of APIs for the framer drivers (framer provider) to create/destroy a framer and APIs for the framer users (framer consumer) to obtain a reference to the framer, and use the framer.
This basic implementation provides a framer abstraction for:
- power on/off the framer
- get the framer status (line state)
- be notified on framer status changes
- get/set the framer configuration
--- drivers/net/wan/Kconfig | 2 + drivers/net/wan/Makefile | 2 + drivers/net/wan/framer/Kconfig | 19 + drivers/net/wan/framer/Makefile | 6 + drivers/net/wan/framer/framer-core.c | 935 +++++++++++++++++++++++++ include/linux/framer/framer-provider.h | 194 +++++ include/linux/framer/framer.h | 215 ++++++ 7 files changed, 1373 insertions(+) create mode 100644 drivers/net/wan/framer/Kconfig create mode 100644 drivers/net/wan/framer/Makefile create mode 100644 drivers/net/wan/framer/framer-core.c create mode 100644 include/linux/framer/framer-provider.h create mode 100644 include/linux/framer/framer.h
drivers/net/wan/Kconfig +2 -0
@@ -95,6 +95,8 @@ config HDLC_X25 comment "X.25/LAPB support is disabled" depends on HDLC && (LAPB!=m || HDLC!=m) && LAPB!=y +source "drivers/net/wan/framer/Kconfig" + config PCI200SYN tristate "Goramo PCI200SYN support" depends on HDLC && PCI
drivers/net/wan/Makefile +2 -0
@@ -14,6 +14,8 @@ obj-$(CONFIG_HDLC_FR) += hdlc_fr.o obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o obj-$(CONFIG_HDLC_X25) += hdlc_x25.o +obj-y += framer/ + obj-$(CONFIG_FARSYNC) += farsync.o obj-$(CONFIG_LAPBETHER) += lapbether.o
drivers/net/wan/framer/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# FRAMER +# + +menu "Framer Subsystem" + +config GENERIC_FRAMER + bool "Framer Core" + help + Generic Framer support. + + This framework is designed to provide a generic interface for framer + devices present in the kernel. This layer will have the generic + API by which framer drivers can create framer using the framer + framework and framer users can obtain reference to the framer. + All the users of this framework should select this config. + +endmenu
drivers/net/wan/framer/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the framer drivers. +# + +obj-$(CONFIG_GENERIC_FRAMER) += framer-core.o
drivers/net/wan/framer/framer-core.c new file +935 -0
935 lines not on this page · raw message
include/linux/framer/framer-provider.h new file +194 -0
194 lines not on this page · raw message
include/linux/framer/framer.h new file +215 -0
215 lines not on this page · raw message
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 19/26 dt-bindings: net: Add the Lantiq PEF2256 E1/T1/J1 framer
In reply to Herve CodinaThe Lantiq PEF2256 is a framer and line interface component designed to fulfill all required interfacing between an analog E1/T1/J1 line and the digital PCM system highway/H.100 bus.
--- .../bindings/net/lantiq,pef2256.yaml | 226 ++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/lantiq,pef2256.yaml
Documentation/devicetree/bindings/net/lantiq,pef2256.yaml new file +226 -0
@@ -0,0 +1,226 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/lantiq,pef2256.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Lantiq PEF2256 + +maintainers: + - Herve Codina <[email protected]> + +description: + The Lantiq PEF2256, also known as Infineon PEF2256 or FALC56, is a framer and + line interface component designed to fulfill all required interfacing between + an analog E1/T1/J1 line and the digital PCM system highway/H.100 bus. + +properties: + compatible: + items: + - const: lantiq,pef2256 + + reg: + maxItems: 1 + + clocks: + items: + - description: Master clock + - description: Receive System Clock + - description: Transmit System Clock + + clock-names: + items: + - const: mclk + - const: sclkr + - const: sclkx + + interrupts: + maxItems: 1 + + reset-gpios: + description: + GPIO used to reset the device. + maxItems: 1 + + '#framer-cells': + const: 0 + + pinctrl: + $ref: /schemas/pinctrl/pinctrl.yaml# + additionalProperties: false + + patternProperties: + '-pins$': + type: object + $ref: /schemas/pinctrl/pincfg-node.yaml# + additionalProperties: false + + properties: + pins: + enum: [ RPA, RPB, RPC, RPD, XPA, XPB, XPC, XPD ] + + function: + enum: [ SYPR, RFM, RFMB, RSIGM, RSIG, DLR, FREEZE, RFSP, LOS, + SYPX, XFMS, XSIG, TCLK, XMFB, XSIGM, DLX, XCLK, XLT, + GPI, GPOH, GPOL ] + + required: + - pins + - function + + lantiq,data-rate-bps: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [2048000, 4096000, 8192000, 16384000] + default: 2048000 + description: + Data rate (bit per seconds) on the system highway. + + lantiq,clock-falling-edge: + $ref: /schemas/types.yaml#/definitions/flag + description: + Data is sent on falling edge of the clock (and received on the rising + edge). If 'clock-falling-edge' is not present, data is sent on the + rising edge (and received on the falling edge). + + lantiq,channel-phase: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3, 4, 5, 6, 7] + default: 0 + description: + The pef2256 delivers a full frame (32 8bit time-slots in E1 and 24 8bit + time-slots 8 8bit signaling in E1/J1) every 125us. This lead to a data + rate of 2048000 bit/s. When lantiq,data-rate-bps is more than 2048000 + bit/s, the data (all 32 8bit) present in the frame are interleave with + unused time-slots. The lantiq,channel-phase property allows to set the + correct alignment of the interleave mechanism. + For instance, suppose lantiq,data-rate-bps = 8192000 (ie 4*2048000), and + lantiq,channel-phase = 2, the interleave schema with unused time-slots + (nu) and used time-slots (XX) for TSi is + nu nu XX nu nu nu XX nu nu nu XX nu + <-- TSi --> <- TSi+1 -> <- TSi+2 -> + With lantiq,data-rate-bps = 8192000, and lantiq,channel-phase = 1, the + interleave schema is + nu XX nu nu nu XX nu nu nu XX nu nu + <-- TSi --> <- TSi+1 -> <- TSi+2 -> + With lantiq,data-rate-bps = 4096000 (ie 2*2048000), and + lantiq,channel-phase = 1, the interleave schema is + nu XX nu XX nu XX + <-- TSi --> <- TSi+1 -> <- TSi+2 -> + +patternProperties: + '^codec(-([0-9]|[1-2][0-9]|3[0-1]))?$': + type: object + $ref: /schemas/sound/dai-common.yaml + unevaluatedProperties: false + description: + Codec provided by the pef2256. This codec allows to use some of the PCM + system highway time-slots as audio channels to transport audio data over + the E1/T1/J1 lines. + The time-slots used by the codec must be set and so, the properties + 'dai-tdm-slot-num', 'dai-tdm-slot-width', 'dai-tdm-slot-tx-mask' and + 'dai-tdm-slot-rx-mask' must be present in the sound card node for + sub-nodes that involve the codec. The codec uses 8bit time-slots. + 'dai-tdm-tdm-slot-with' must be set to 8. + The tx and rx masks define the pef2256 time-slots assigned to the codec. + + properties: + compatible: + const: lantiq,pef2256-codec + + '#sound-dai-cells': + const: 0 + + framer: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the framer node + + required: + - compatible + - '#sound-dai-cells' + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + - '#framer-cells' + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/interrupt-controller/irq.h> + + pef2256: framer@2000000 { + compatible = "lantiq,pef2256"; + reg = <0x2000000 0x100>; + interrupts = <8 IRQ_TYPE_LEVEL_LOW>; + interrupt-parent = <&intc>; + clocks = <&clk_mclk>, <&clk_sclkr>, <&clk_sclkx>; + clock-names = "mclk", "sclkr", "sclkx"; + reset-gpios = <&gpio 11 GPIO_ACTIVE_LOW>; + lantiq,data-rate-bps = <4096000>; + #framer-cells = <0>; + + pinctrl { + pef2256_rpa_sypr: rpa-pins { + pins = "RPA"; + function = "SYPR"; + }; + pef2256_xpa_sypx: xpa-pins { + pins = "XPA"; + function = "SYPX"; + }; + }; + + pef2256_codec0: codec-0 { + compatible = "lantiq,pef2256-codec"; + framer = <&pef2256>; + #sound-dai-cells = <0>; + sound-name-prefix = "PEF2256_0"; + }; + + pef2256_codec1: codec-1 { + compatible = "lantiq,pef2256-codec"; + framer = <&pef2256>; + #sound-dai-cells = <0>; + sound-name-prefix = "PEF2256_1"; + }; + }; + + sound { + compatible = "simple-audio-card"; + #address-cells = <1>; + #size-cells = <0>; + simple-audio-card,dai-link@0 { /* CPU DAI1 - pef2256 codec 1 */ + reg = <0>; + cpu { + sound-dai = <&cpu_dai1>; + }; + codec { + sound-dai = <&pef2256_codec0>; + dai-tdm-slot-num = <4>; + dai-tdm-slot-width = <8>; + /* TS 1, 2, 3, 4 */ + dai-tdm-slot-tx-mask = <0 1 1 1 1>; + dai-tdm-slot-rx-mask = <0 1 1 1 1>; + }; + }; + simple-audio-card,dai-link@1 { /* CPU DAI2 - pef2256 codec 2 */ + reg = <1>; + cpu { + sound-dai = <&cpu_dai2>; + }; + codec { + sound-dai = <&pef2256_codec1>; + dai-tdm-slot-num = <4>; + dai-tdm-slot-width = <8>; + /* TS 5, 6, 7, 8 */ + dai-tdm-slot-tx-mask = <0 0 0 0 0 1 1 1 1>; + dai-tdm-slot-rx-mask = <0 0 0 0 0 1 1 1 1>; + }; + }; + };
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 20/26 mfd: core: Ensure disabled devices are skiped without aborting
In reply to Herve CodinaThe loop searching for a matching device based on its compatible string is aborted when a matching disabled device is found. This abort avoid to add devices as soon as one disabled device is found.
Continue searching for an other device instead of aborting on the first disabled one fixes the issue.
--- drivers/mfd/mfd-core.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/mfd/mfd-core.c +13 -5
@@ -146,6 +146,7 @@ static int mfd_add_device(struct device *parent, int id,struct platform_device *pdev;struct device_node *np =NULL ;struct mfd_of_node_entry *of_entry, *tmp; +bool disabled;int ret = -ENOMEM ;int platform_id;int r;
@@ -181,13 +182,13 @@ static int mfd_add_device(struct device *parent, int id, goto fail_res;if (IS_ENABLED (CONFIG_OF ) && parent->of_node && cell->of_compatible) { + disabled = false;for_each_child_of_node (parent->of_node, np) {if (of_device_is_compatible (np, cell->of_compatible)) { -/* Ignore 'disabled' devices error free */ +/* Skip 'disabled' devices */ if (!of_device_is_available (np)) { -of_node_put (np); - ret =0 ; - goto fail_alias; + disabled = true; +continue ; } ret =mfd_match_of_node_to_dev (pdev, np, cell);
@@ -197,10 +198,17 @@ static int mfd_add_device(struct device *parent, int id,if (ret) goto fail_alias; -break ; + goto match; } } +if (disabled) { +/* Ignore 'disabled' devices error free */ + ret =0 ; + goto fail_alias; + } + +match:if (!pdev->dev.of_node)pr_warn ("%s: Failed to locate of_node [id: %d]\n" , cell->name, platform_id);
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 21/26 net: wan: framer: Add support for the Lantiq PEF2256 framer
In reply to Herve CodinaThe Lantiq PEF2256 is a framer and line interface component designed to fulfill all required interfacing between an analog E1/T1/J1 line and the digital PCM system highway/H.100 bus.
--- drivers/net/wan/framer/Kconfig | 16 + drivers/net/wan/framer/Makefile | 1 + drivers/net/wan/framer/pef2256/Makefile | 8 + drivers/net/wan/framer/pef2256/pef2256-regs.h | 250 +++++ drivers/net/wan/framer/pef2256/pef2256.c | 880 ++++++++++++++++++ include/linux/framer/pef2256.h | 31 + 6 files changed, 1186 insertions(+) create mode 100644 drivers/net/wan/framer/pef2256/Makefile create mode 100644 drivers/net/wan/framer/pef2256/pef2256-regs.h create mode 100644 drivers/net/wan/framer/pef2256/pef2256.c create mode 100644 include/linux/framer/pef2256.h
drivers/net/wan/framer/Kconfig +16 -0
@@ -16,4 +16,20 @@ config GENERIC_FRAMER framework and framer users can obtain reference to the framer. All the users of this framework should select this config. +config FRAMER_PEF2256 + tristate "Lantiq PEF2256" + depends on OF + select GENERIC_FRAMER + select MFD_CORE + select REGMAP_MMIO + help + Enable support for the Lantiq PEF2256 (FALC56) framer. + The PEF2256 is a framer and line interface between analog E1/T1/J1 + line and a digital PCM bus. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called framer-pef2256. + endmenu
drivers/net/wan/framer/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_GENERIC_FRAMER) += framer-core.o +obj-$(CONFIG_FRAMER_PEF2256) += pef2256/
drivers/net/wan/framer/pef2256/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for the pef2256 driver. +# + +obj-$(CONFIG_FRAMER_PEF2256) += framer-pef2256.o + +framer-pef2256-objs := pef2256.o
drivers/net/wan/framer/pef2256/pef2256-regs.h new file +250 -0
250 lines not on this page · raw message
drivers/net/wan/framer/pef2256/pef2256.c new file +880 -0
880 lines not on this page · raw message
include/linux/framer/pef2256.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* PEF2256 consumer API +* +* Copyright 2023 CS GROUP France +* +* Author: Herve Codina <[email protected]> +*/ +#ifndef __PEF2256_H__ +#define __PEF2256_H__ + +#include <linux/types.h> + +struct pef2256 ; +struct regmap ; + +/* Retrieve the PEF2256 regmap */ +struct regmap *pef2256_get_regmap (struct pef2256 *pef2256); + +/* PEF2256 hardware versions */ +enum pef2256_version { +PEF2256_VERSION_UNKNOWN , +PEF2256_VERSION_1_2 , +PEF2256_VERSION_2_1 , +PEF2256_VERSION_2_2 , +}; + +/* Get the PEF2256 hardware version */ +enum pef2256_version pef2256_get_version (struct pef2256 *pef2256); + +#endif /* __PEF2256_H__ */
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 22/26 pinctrl: Add support for the Lantic PEF2256 pinmux
In reply to Herve CodinaThe Lantiq PEF2256 is a framer and line interface component designed to fulfill all required interfacing between an analog E1/T1/J1 line and the digital PCM system highway/H.100 bus.
This pinmux support handles the pin muxing part (pins RP(A..D) and pins XP(A..D)) of the PEF2256.
--- drivers/pinctrl/Kconfig | 14 ++ drivers/pinctrl/Makefile | 1 + drivers/pinctrl/pinctrl-pef2256-regs.h | 65 ++++++ drivers/pinctrl/pinctrl-pef2256.c | 310 +++++++++++++++++++++++++ 4 files changed, 390 insertions(+) create mode 100644 drivers/pinctrl/pinctrl-pef2256-regs.h create mode 100644 drivers/pinctrl/pinctrl-pef2256.c
drivers/pinctrl/Kconfig +14 -0
@@ -377,6 +377,20 @@ config PINCTRL_PALMAS open drain configuration for the Palmas series devices like TPS65913, TPS80036 etc. +config PINCTRL_PEF2256 + tristate "Lantiq PEF2256 (FALC56) pin controller driver" + depends on OF && FRAMER_PEF2256 + select PINMUX + select GENERIC_PINCONF + help + This option enables the pin controller support for the Lantiq PEF2256 + framer, also known as FALC56. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called pinctrl-pef2256. + config PINCTRL_PIC32 bool "Microchip PIC32 pin controller driver" depends on OF
drivers/pinctrl/Makefile +1 -0
@@ -40,6 +40,7 @@ obj-$(CONFIG_PINCTRL_MLXBF3) += pinctrl-mlxbf3.o obj-$(CONFIG_PINCTRL_OCELOT) += pinctrl-ocelot.o obj-$(CONFIG_PINCTRL_OXNAS) += pinctrl-oxnas.o obj-$(CONFIG_PINCTRL_PALMAS) += pinctrl-palmas.o +obj-$(CONFIG_PINCTRL_PEF2256) += pinctrl-pef2256.o obj-$(CONFIG_PINCTRL_PIC32) += pinctrl-pic32.o obj-$(CONFIG_PINCTRL_PISTACHIO) += pinctrl-pistachio.o obj-$(CONFIG_PINCTRL_RK805) += pinctrl-rk805.o
drivers/pinctrl/pinctrl-pef2256-regs.h new file +65 -0
65 lines not on this page · raw message
drivers/pinctrl/pinctrl-pef2256.c new file +310 -0
310 lines not on this page · raw message
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 23/26 MAINTAINERS: Add the Lantiq PEF2256 driver entry
In reply to Herve CodinaAfter contributing the driver, add myself as the maintainer for the Lantiq PEF2256 driver.
--- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
@@ -11776,6 +11776,15 @@ S: Maintained F: arch/mips/lantiq F: drivers/soc/lantiq +LANTIQ PEF2256 DRIVER +M: Herve Codina <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/lantiq,pef2256.yaml +F: drivers/net/wan/framer/pef2256/ +F: drivers/pinctrl/pinctrl-pef2256-regs.h +F: drivers/pinctrl/pinctrl-pef2256.c +F: include/linux/framer/pef2256.h + LASI 53c700 driver for PARISC M: "James E.J. Bottomley" <[email protected]> L: [email protected]
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 24/26 ASoC: codecs: Add support for the framer codec
In reply to Herve CodinaThe framer codec interracts with a framer.
It allows to use some of the framer timeslots as audio channels to transport audio data over the framer E1/T1/J1 lines.
It also reports line carrier detection events through the ALSA jack detection feature.
--- sound/soc/codecs/Kconfig | 15 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/framer-codec.c | 423 ++++++++++++++++++++++++++++++++ 3 files changed, 440 insertions(+) create mode 100644 sound/soc/codecs/framer-codec.c
sound/soc/codecs/Kconfig +15 -0
@@ -110,6 +110,7 @@ config SND_SOC_ALL_CODECS imply SND_SOC_ES8328_I2C imply SND_SOC_ES7134 imply SND_SOC_ES7241 + imply SND_SOC_FRAMER imply SND_SOC_GTM601 imply SND_SOC_HDAC_HDMI imply SND_SOC_HDAC_HDA
@@ -1043,6 +1044,20 @@ config SND_SOC_ES8328_SPI depends on SPI_MASTER select SND_SOC_ES8328 +config SND_SOC_FRAMER + tristate "Framer codec" + depends on GENERIC_FRAMER + help + Enable support for the framer codec. + The framer codec uses the generic framer infrastructure to transport + some audio data over an analog E1/T1/J1 line. + This codec allows to use some of the time slots available on the TDM + bus on with the framer is connected to transport the audio data. + + To compile this driver as a module, choose M here: the module + will be called snd-soc-framer. + + config SND_SOC_GTM601 tristate 'GTM601 UMTS modem audio codec'
sound/soc/codecs/Makefile +2 -0
@@ -116,6 +116,7 @@ snd-soc-es8326-objs := es8326.o snd-soc-es8328-objs := es8328.o snd-soc-es8328-i2c-objs := es8328-i2c.o snd-soc-es8328-spi-objs := es8328-spi.o +snd-soc-framer-objs := framer-codec.o snd-soc-gtm601-objs := gtm601.o snd-soc-hdac-hdmi-objs := hdac_hdmi.o snd-soc-hdac-hda-objs := hdac_hda.o
@@ -499,6 +500,7 @@ obj-$(CONFIG_SND_SOC_ES8326) += snd-soc-es8326.o obj-$(CONFIG_SND_SOC_ES8328) += snd-soc-es8328.o obj-$(CONFIG_SND_SOC_ES8328_I2C)+= snd-soc-es8328-i2c.o obj-$(CONFIG_SND_SOC_ES8328_SPI)+= snd-soc-es8328-spi.o +obj-$(CONFIG_SND_SOC_FRAMER) += snd-soc-framer.o obj-$(CONFIG_SND_SOC_GTM601) += snd-soc-gtm601.o obj-$(CONFIG_SND_SOC_HDAC_HDMI) += snd-soc-hdac-hdmi.o obj-$(CONFIG_SND_SOC_HDAC_HDA) += snd-soc-hdac-hda.o
sound/soc/codecs/framer-codec.c new file +423 -0
423 lines not on this page · raw message
Signature · 1 line
2.41.0
Re: [PATCH 24/26] ASoC: codecs: Add support for the framer codec
sound/soc/codecs/Kconfig config SND_SOC_ES8328_SPI · line 1055
Quoted 9 lines · Herve Codina
sound/soc/codecs/Kconfig +9
-0+config SND_SOC_FRAMER + tristate "Framer codec" + depends on GENERIC_FRAMER + help + Enable support for the framer codec. + The framer codec uses the generic framer infrastructure to transport + some audio data over an analog E1/T1/J1 line. + This codec allows to use some of the time slots available on the TDM + bus on with the framer is connected to transport the audio data.
on which
Quoted 3 lines
sound/soc/codecs/Kconfig +3
-0+ + To compile this driver as a module, choose M here: the module + will be called snd-soc-framer.
Signature · 1 line
~Randy
Herve Codina
maintainerPATCH 25/26 dt-bindings: net: fsl,qmc-hdlc: Add framer support
In reply to Herve CodinaA framer can be connected to the QMC HDLC.
If present, this framer is the interface between the TDM used by the QMC HDLC and the E1/T1 line.
The QMC HDLC can use this framer to get information about the line and configure the line.
Add an optional framer property to reference the framer itself.
--- Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/net/fsl,qmc-hdlc.yaml +5 -0
@@ -27,6 +27,11 @@ properties: Should be a phandle/number pair. The phandle to QMC node and the QMC channel to use. + framer: + $ref: /schemas/types.yaml#/definitions/phandle + description: + phandle to the framer node + required: - compatible - fsl,qmc-chan
Signature · 1 line
2.41.0
Herve Codina
maintainerPATCH 26/26 net: wan: fsl_qmc_hdlc: Add framer support
In reply to Herve CodinaAdd framer support in the fsl_qmc_hdlc driver in order to be able to signal carrier changes to the network stack based on the framer status Also use this framer to provide information related to the E1/T1 line interface on IF_GET_IFACE and configure the line interface according to IF_IFACE_{E1,T1} information.
--- drivers/net/wan/fsl_qmc_hdlc.c | 238 ++++++++++++++++++++++++++++++++- 1 file changed, 234 insertions(+), 4 deletions(-)
drivers/net/wan/fsl_qmc_hdlc.c +234 -4
@@ -8,6 +8,7 @@*/ #include <linux/dma-mapping.h> +#include <linux/framer/framer.h> #include <linux/hdlc.h> #include <linux/module.h> #include <linux/of.h>
@@ -27,6 +28,9 @@ struct qmc_hdlc {struct device *dev;struct qmc_chan *qmc_chan;struct net_device *netdev; +struct framer *framer; +spinlock_t carrier_lock;/* Protect carrier detection */ +struct notifier_block nb;bool is_crc32;spinlock_t tx_lock;/* Protect tx descriptors */ struct qmc_hdlc_desc tx_descs[8 ];
@@ -40,6 +44,195 @@ static inline struct qmc_hdlc *netdev_to_qmc_hdlc(struct net_device *netdev)return (struct qmc_hdlc *)dev_to_hdlc (netdev)->priv; } +static int qmc_hdlc_framer_set_carrier (struct qmc_hdlc *qmc_hdlc) +{ +struct framer_status framer_status; +unsigned long flags; +int ret; + +if (!qmc_hdlc->framer) +return 0 ; + +spin_lock_irqsave (&qmc_hdlc->carrier_lock, flags); + + ret =framer_get_status (qmc_hdlc->framer, &framer_status); +if (ret) { +dev_err (qmc_hdlc->dev,"get framer status failed (%d)\n" , ret); + goto end; + } +if (framer_status.link_is_on) +netif_carrier_on (qmc_hdlc->netdev); +else +netif_carrier_off (qmc_hdlc->netdev); + +end: +spin_unlock_irqrestore (&qmc_hdlc->carrier_lock, flags); +return ret; +} + +static int qmc_hdlc_framer_notifier (struct notifier_block *nb,unsigned long action, +void *data) +{ + struct qmc_hdlc *qmc_hdlc = container_of(nb, struct qmc_hdlc, nb); +int ret; + +if (action !=FRAMER_EVENT_STATUS ) +return NOTIFY_DONE ; + + ret =qmc_hdlc_framer_set_carrier (qmc_hdlc); +return ret ?NOTIFY_DONE :NOTIFY_OK ; +} + +static int qmc_hdlc_framer_start (struct qmc_hdlc *qmc_hdlc) +{ +struct framer_status framer_status; +int ret; + +if (!qmc_hdlc->framer) +return 0 ; + + ret =framer_power_on (qmc_hdlc->framer); +if (ret) { +dev_err (qmc_hdlc->dev,"framer power-on failed (%d)\n" , ret); +return ret; + } + +/* Be sure that get_status is supported */ + ret =framer_get_status (qmc_hdlc->framer, &framer_status); +if (ret) { +dev_err (qmc_hdlc->dev,"get framer status failed (%d)\n" , ret); + goto framer_power_off; + } + + qmc_hdlc->nb.notifier_call = qmc_hdlc_framer_notifier; + ret =framer_notifier_register (qmc_hdlc->framer, &qmc_hdlc->nb); +if (ret) { +dev_err (qmc_hdlc->dev,"framer notifier register failed (%d)\n" , ret); + goto framer_power_off; + } + +return 0 ; + +framer_power_off: +framer_power_off (qmc_hdlc->framer); +return ret; +} + +static void qmc_hdlc_framer_stop (struct qmc_hdlc *qmc_hdlc) +{ +if (!qmc_hdlc->framer) +return ; + +framer_notifier_unregister (qmc_hdlc->framer, &qmc_hdlc->nb); +framer_power_off (qmc_hdlc->framer); +} + +static int qmc_hdlc_framer_set_iface (struct qmc_hdlc *qmc_hdlc,int if_iface, +const te1_settings *te1) +{ +struct framer_config config; +int ret; + +if (!qmc_hdlc->framer) +return 0 ; + + ret =framer_get_config (qmc_hdlc->framer, &config); +if (ret) +return ret; + +switch (if_iface) { +case IF_IFACE_E1 : + config.iface =FRAMER_IFACE_E1 ; +break ; +case IF_IFACE_T1 : + config.iface =FRAMER_IFACE_T1 ; +break ; +default : +return -EINVAL ; + } + +switch (te1->clock_type) { +case CLOCK_DEFAULT : +/* Keep current value */ +break ; +case CLOCK_EXT : + config.clock_type =FRAMER_CLOCK_EXT ; +break ; +case CLOCK_INT : + config.clock_type =FRAMER_CLOCK_INT ; +break ; +default : +return -EINVAL ; + } + config.line_clock_rate = te1->clock_rate; + +return framer_set_config (qmc_hdlc->framer, &config); +} + +static int qmc_hdlc_framer_get_iface (struct qmc_hdlc *qmc_hdlc,int *if_iface,te1_settings *te1) +{ +struct framer_config config; +int ret; + +if (!qmc_hdlc->framer) { + *if_iface =IF_IFACE_E1 ; +return 0 ; + } + + ret =framer_get_config (qmc_hdlc->framer, &config); +if (ret) +return ret; + +switch (config.iface) { +case FRAMER_IFACE_E1 : + *if_iface =IF_IFACE_E1 ; +break ; +case FRAMER_IFACE_T1 : + *if_iface =IF_IFACE_T1 ; +break ; + } + +if (!te1) +return 0 ;/* Only iface type requested */ + +switch (config.clock_type) { +case FRAMER_CLOCK_EXT : + te1->clock_type =CLOCK_EXT ; +break ; +case FRAMER_CLOCK_INT : + te1->clock_type =CLOCK_INT ; +break ; +default : +return -EINVAL ; + } + te1->clock_rate = config.line_clock_rate; +return 0 ; +} + +static int qmc_hdlc_framer_init (struct qmc_hdlc *qmc_hdlc) +{ +int ret; + +if (!qmc_hdlc->framer) +return 0 ; + + ret =framer_init (qmc_hdlc->framer); +if (ret) { +dev_err (qmc_hdlc->dev,"framer init failed (%d)\n" , ret); +return ret; + } + +return 0 ; +} + +static void qmc_hdlc_framer_exit (struct qmc_hdlc *qmc_hdlc) +{ +if (!qmc_hdlc->framer) +return ; + +framer_exit (qmc_hdlc->framer); +} +static int qmc_hdlc_recv_queue (struct qmc_hdlc *qmc_hdlc,struct qmc_hdlc_desc *desc,size_t size);#define QMC_HDLC_RX_ERROR_FLAGS (QMC_RX_FLAG_HDLC_OVF | \
@@ -313,6 +506,12 @@ static int qmc_hdlc_set_iface(struct qmc_hdlc *qmc_hdlc, int if_iface, const te1 qmc_hdlc->slot_map = te1->slot_map; + ret =qmc_hdlc_framer_set_iface (qmc_hdlc, if_iface, te1); +if (ret) { +dev_err (qmc_hdlc->dev,"framer set iface failed %d\n" , ret); +return ret; + } +return 0 ; }
@@ -324,8 +523,12 @@ static int qmc_hdlc_ioctl(struct net_device *netdev, struct if_settings *ifs)switch (ifs->type) {case IF_GET_IFACE : - ifs->type =IF_IFACE_E1 ;if (ifs->size <sizeof (te1)) { +/* Retrieve type only */ + ret =qmc_hdlc_framer_get_iface (qmc_hdlc, &ifs->type,NULL ); +if (ret) +return ret; +if (!ifs->size)return 0 ;/* only type requested */
@@ -335,6 +538,11 @@ static int qmc_hdlc_ioctl(struct net_device *netdev, struct if_settings *ifs)memset (&te1,0 ,sizeof (te1)); +/* Retrieve info from framer */ + ret =qmc_hdlc_framer_get_iface (qmc_hdlc, &ifs->type, &te1); +if (ret) +return ret; +/* Update slot_map */ te1.slot_map = qmc_hdlc->slot_map;
@@ -368,10 +576,17 @@ static int qmc_hdlc_open(struct net_device *netdev)int ret;int i; - ret =hdlc_open (netdev); + ret =qmc_hdlc_framer_start (qmc_hdlc);if (ret)return ret; + ret =hdlc_open (netdev); +if (ret) + goto framer_stop; + +/* Update carrier */ +qmc_hdlc_framer_set_carrier (qmc_hdlc); + chan_param.mode =QMC_HDLC ;/* HDLC_MAX_MRU + 4 for the CRC * HDLC_MAX_MRU + 4 + 8 for the CRC and some extraspace needed by the QMC
@@ -421,6 +636,8 @@ static int qmc_hdlc_open(struct net_device *netdev) } hdlc_close:hdlc_close (netdev); +framer_stop: +qmc_hdlc_framer_stop (qmc_hdlc);return ret; }
@@ -456,6 +673,7 @@ static int qmc_hdlc_close(struct net_device *netdev) }hdlc_close (netdev); +qmc_hdlc_framer_stop (qmc_hdlc);return 0 ; }
@@ -504,6 +722,7 @@ static int qmc_hdlc_probe(struct platform_device *pdev) qmc_hdlc->dev = &pdev->dev;spin_lock_init (&qmc_hdlc->tx_lock); +spin_lock_init (&qmc_hdlc->carrier_lock); qmc_hdlc->qmc_chan =devm_qmc_chan_get_byphandle (qmc_hdlc->dev, np,"fsl,qmc-chan" );if (IS_ERR (qmc_hdlc->qmc_chan)) {
@@ -532,10 +751,19 @@ static int qmc_hdlc_probe(struct platform_device *pdev)if (ret)return ret; + qmc_hdlc->framer =devm_framer_optional_get (qmc_hdlc->dev,"framer" ); +if (IS_ERR (qmc_hdlc->framer)) +return PTR_ERR (qmc_hdlc->framer); + + ret =qmc_hdlc_framer_init (qmc_hdlc); +if (ret) +return ret; + qmc_hdlc->netdev =alloc_hdlcdev (qmc_hdlc);if (!qmc_hdlc->netdev) {dev_err (qmc_hdlc->dev,"failed to alloc hdlc dev\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto framer_exit; } hdlc =dev_to_hdlc (qmc_hdlc->netdev);
@@ -551,11 +779,12 @@ static int qmc_hdlc_probe(struct platform_device *pdev) }platform_set_drvdata (pdev, qmc_hdlc); -return 0 ; free_netdev:free_netdev (qmc_hdlc->netdev); +framer_exit: +qmc_hdlc_framer_exit (qmc_hdlc);return ret; }
@@ -565,6 +794,7 @@ static int qmc_hdlc_remove(struct platform_device *pdev)unregister_hdlc_device (qmc_hdlc->netdev);free_netdev (qmc_hdlc->netdev); +qmc_hdlc_framer_exit (qmc_hdlc);return 0 ; }
Signature · 1 line
2.41.0
Jakub Kicinski
maintainerQuoted 2 lines · On Tue, 25 Jul 2023 11:23:36 +0200 Herve Codina wrote:
I have a system where I need to handle an HDLC interface and some audio data.
The new code must build cleanly with C=1 W=1, after every individual patch.
Signature · 1 line
pw-bot: cr