[PATCH 06/12] fsl/fman: Add the FMan MAC FLIB

2015-06-10 Thread Igal . Liberman
From: Igal Liberman igal.liber...@freescale.com

The FMan MAC FLib provides basic API used by the drivers to
configure and control the FMan MAC hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Makefile   |1 +
 drivers/net/ethernet/freescale/fman/mac/Makefile   |5 +
 .../net/ethernet/freescale/fman/mac/fman_dtsec.c   |  571 
 .../freescale/fman/mac/fman_dtsec_mii_acc.c|  168 ++
 .../net/ethernet/freescale/fman/mac/fman_memac.c   |  365 +
 .../freescale/fman/mac/fman_memac_mii_acc.c|  217 
 .../net/ethernet/freescale/fman/mac/fman_tgec.c|  217 
 7 files changed, 1544 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_dtsec_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_memac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_memac_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_tgec.c

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 50a4de2..1841b03 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -5,3 +5,4 @@ obj-y   += fsl_fman.o
 fsl_fman-objs  := fman.o
 
 obj-y  += port/
+obj-y  += mac/
diff --git a/drivers/net/ethernet/freescale/fman/mac/Makefile 
b/drivers/net/ethernet/freescale/fman/mac/Makefile
new file mode 100644
index 000..ce03e25
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac/Makefile
@@ -0,0 +1,5 @@
+obj-y  += fsl_fman_mac.o
+
+fsl_fman_mac-objs  := fman_dtsec.o fman_dtsec_mii_acc.o\
+  fman_memac.o fman_memac_mii_acc.o\
+  fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
new file mode 100644
index 000..290a037
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
@@ -0,0 +1,571 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman_dtsec.h
+
+void fman_dtsec_stop_rx(struct dtsec_regs __iomem *regs)
+{
+   /* Assert the graceful stop bit */
+   iowrite32be(ioread32be(regs-rctrl) | RCTRL_GRS, regs-rctrl);
+}
+
+void fman_dtsec_stop_tx(struct dtsec_regs __iomem *regs)
+{
+   /* Assert the graceful stop bit */
+   iowrite32be(ioread32be(regs-tctrl) | DTSEC_TCTRL_GTS, regs-tctrl);
+}
+
+void fman_dtsec_start_tx(struct dtsec_regs __iomem *regs)
+{
+   /* clear the graceful stop bit */
+   iowrite32be(ioread32be(regs-tctrl)  ~DTSEC_TCTRL_GTS, regs-tctrl);
+}
+
+void fman_dtsec_start_rx(struct dtsec_regs __iomem *regs)
+{
+   /* clear the graceful stop bit */
+   iowrite32be(ioread32be(regs-rctrl)  ~RCTRL_GRS, regs-rctrl);
+}
+
+void fman_dtsec_defconfig(struct dtsec_cfg *cfg)
+{
+   cfg-halfdup_on = DEFAULT_HALFDUP_ON;
+   cfg-halfdup_retransmit = DEFAULT_HALFDUP_RETRANSMIT;
+  

[PATCH 06/12] fsl/fman: Add the FMan MAC FLIB

2015-06-10 Thread Madalin Bucur
From: Igal Liberman igal.liber...@freescale.com

The FMan MAC FLib provides basic API used by the drivers to
configure and control the FMan MAC hardware.

Signed-off-by: Igal Liberman igal.liber...@freescale.com
---
 drivers/net/ethernet/freescale/fman/Makefile   |   1 +
 drivers/net/ethernet/freescale/fman/mac/Makefile   |   5 +
 .../net/ethernet/freescale/fman/mac/fman_dtsec.c   | 571 +
 .../freescale/fman/mac/fman_dtsec_mii_acc.c| 168 ++
 .../net/ethernet/freescale/fman/mac/fman_memac.c   | 365 +
 .../freescale/fman/mac/fman_memac_mii_acc.c| 217 
 .../net/ethernet/freescale/fman/mac/fman_tgec.c| 217 
 7 files changed, 1544 insertions(+)
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/Makefile
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_dtsec_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_memac.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_memac_mii_acc.c
 create mode 100644 drivers/net/ethernet/freescale/fman/mac/fman_tgec.c

diff --git a/drivers/net/ethernet/freescale/fman/Makefile 
b/drivers/net/ethernet/freescale/fman/Makefile
index 50a4de2..1841b03 100644
--- a/drivers/net/ethernet/freescale/fman/Makefile
+++ b/drivers/net/ethernet/freescale/fman/Makefile
@@ -5,3 +5,4 @@ obj-y   += fsl_fman.o
 fsl_fman-objs  := fman.o
 
 obj-y  += port/
+obj-y  += mac/
diff --git a/drivers/net/ethernet/freescale/fman/mac/Makefile 
b/drivers/net/ethernet/freescale/fman/mac/Makefile
new file mode 100644
index 000..ce03e25
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac/Makefile
@@ -0,0 +1,5 @@
+obj-y  += fsl_fman_mac.o
+
+fsl_fman_mac-objs  := fman_dtsec.o fman_dtsec_mii_acc.o\
+  fman_memac.o fman_memac_mii_acc.o\
+  fman_tgec.o
diff --git a/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c 
b/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
new file mode 100644
index 000..290a037
--- /dev/null
+++ b/drivers/net/ethernet/freescale/fman/mac/fman_dtsec.c
@@ -0,0 +1,571 @@
+/*
+ * Copyright 2008 - 2015 Freescale Semiconductor Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ *  notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ * * Neither the name of Freescale Semiconductor nor the
+ *  names of its contributors may be used to endorse or promote products
+ *  derived from this software without specific prior written permission.
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License (GPL) as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include fsl_fman_dtsec.h
+
+void fman_dtsec_stop_rx(struct dtsec_regs __iomem *regs)
+{
+   /* Assert the graceful stop bit */
+   iowrite32be(ioread32be(regs-rctrl) | RCTRL_GRS, regs-rctrl);
+}
+
+void fman_dtsec_stop_tx(struct dtsec_regs __iomem *regs)
+{
+   /* Assert the graceful stop bit */
+   iowrite32be(ioread32be(regs-tctrl) | DTSEC_TCTRL_GTS, regs-tctrl);
+}
+
+void fman_dtsec_start_tx(struct dtsec_regs __iomem *regs)
+{
+   /* clear the graceful stop bit */
+   iowrite32be(ioread32be(regs-tctrl)  ~DTSEC_TCTRL_GTS, regs-tctrl);
+}
+
+void fman_dtsec_start_rx(struct dtsec_regs __iomem *regs)
+{
+   /* clear the graceful stop bit */
+   iowrite32be(ioread32be(regs-rctrl)  ~RCTRL_GRS, regs-rctrl);
+}
+
+void fman_dtsec_defconfig(struct dtsec_cfg *cfg)
+{
+   cfg-halfdup_on = DEFAULT_HALFDUP_ON;
+   cfg-halfdup_retransmit = DEFAULT_HALFDUP_RETRANSMIT;
+