Skip to contentSkip to conversation

fec: Unify fec_ptp.c and fec.c

PATCH In review Fabio Estevam 4 participants 7 messages Mar 20, 2013 – Mar 21, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fec: Unify fec_ptp.c and fec.c

From: Fabio Estevam <[email protected]>

Currently CONFIG_FEC=y generates two separate modules: fec_ptp.ko and fec.ko.

These modules cannot be used independently, so it is better to unify them.

Move fec_ptp.c code into fec.c and its definitions into fec.h.

---
 drivers/net/ethernet/freescale/Makefile  |    2 +-
 drivers/net/ethernet/freescale/fec.c     |  315 ++++++++++++++++++++++++
 drivers/net/ethernet/freescale/fec.h     |   23 ++
 drivers/net/ethernet/freescale/fec_ptp.c |  388 ------------------------------
 4 files changed, 339 insertions(+), 389 deletions(-)
 delete mode 100644 drivers/net/ethernet/freescale/fec_ptp.c
drivers/net/ethernet/freescale/Makefile +1 -1
index b7d58fe..3d1839a 100644
@@ -2,7 +2,7 @@
 # Makefile for the Freescale network device drivers.
 #
 
-obj-$(CONFIG_FEC) += fec.o fec_ptp.o
+obj-$(CONFIG_FEC) += fec.o
 obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o
 ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y)
 	obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o
drivers/net/ethernet/freescale/fec.c +315 -0

321 lines not on this page · raw message

drivers/net/ethernet/freescale/fec.h +23 -0
index eb43729..2a01f79 100644
@@ -191,6 +191,29 @@ struct bufdesc_ex {
 #define BD_ENET_RX_INT          0x00800000
 #define BD_ENET_RX_PTP          ((ushort)0x0400)
 
+/* FEC 1588 register bits */
+#define FEC_T_CTRL_SLAVE                0x00002000
+#define FEC_T_CTRL_CAPTURE              0x00000800
+#define FEC_T_CTRL_RESTART              0x00000200
+#define FEC_T_CTRL_PERIOD_RST           0x00000030
+#define FEC_T_CTRL_PERIOD_EN		0x00000010
+#define FEC_T_CTRL_ENABLE               0x00000001
+
+#define FEC_T_INC_MASK                  0x0000007f
+#define FEC_T_INC_OFFSET                0
+#define FEC_T_INC_CORR_MASK             0x00007f00
+#define FEC_T_INC_CORR_OFFSET           8
+
+#define FEC_ATIME_CTRL		0x400
+#define FEC_ATIME		0x404
+#define FEC_ATIME_EVT_OFFSET	0x408
+#define FEC_ATIME_EVT_PERIOD	0x40c
+#define FEC_ATIME_CORR		0x410
+#define FEC_ATIME_INC		0x414
+#define FEC_TS_TIMESTAMP	0x418
+
+#define FEC_CC_MULT	(1 << 31)
+
 /* The FEC buffer descriptors track the ring buffers.  The rx_bd_base and
  * tx_bd_base always point to the base of the buffer descriptors.  The
  * cur_rx and cur_tx point to the currently available buffer.
drivers/net/ethernet/freescale/fec_ptp.c deleted +0 -388

388 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

Hello Fabio,

Quoted 1 line · Fabio Estevam

Currently CONFIG_FEC=y generates two separate modules: fec_ptp.ko and fec.ko.

CONFIG_FEC=m

Quoted 5 lines

These modules cannot be used independently, so it is better to unify them.

Move fec_ptp.c code into fec.c and its definitions into fec.h.

s/Koe/Kö/

Quoted 1 line

You could note that you dropped the EXPORT_SYMBOLs. Other than that I assume it's a 1:1 change?

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#2 lore raw

I suggest use below patch to fix this problem

drivers/net/ethernet/freescale/Makefile +2 -1
@@ -2,7 +2,8 @@
 # Makefile for the Freescale network device drivers.
 #
 
-obj-$(CONFIG_FEC) += fec.o fec_ptp.o
+obj-$(CONFIG_FEC) += fec_driver.o
+fec_driver-objs := fec.o fec_ptp.o
 obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o
 ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y)
        obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o

2013/3/21 Uwe Kleine-König <[email protected]>:

Quoted 28 lines

Hello Fabio,

Quoted 1 line · Fabio Estevam

Currently CONFIG_FEC=y generates two separate modules: fec_ptp.ko and fec.ko.

CONFIG_FEC=m

Quoted 5 lines

These modules cannot be used independently, so it is better to unify them.

Move fec_ptp.c code into fec.c and its definitions into fec.h.

s/Koe/Kö/

Quoted 1 line

You could note that you dropped the EXPORT_SYMBOLs. Other than that I assume it's a 1:1 change?

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Hello,

Quoted 5 lines · Frank Li

I suggest use below patch to fix this problem

drivers/net/ethernet/freescale/Makefile line 9

Quoted 9 lines
drivers/net/ethernet/freescale/Makefile +2 -1
@@ -2,7 +2,8 @@
 # Makefile for the Freescale network device drivers.
 #
 
-obj-$(CONFIG_FEC) += fec.o fec_ptp.o
+obj-$(CONFIG_FEC) += fec_driver.o
+fec_driver-objs := fec.o fec_ptp.o
 obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o
 ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y)
        obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o

I thought about suggesting something similar, too. I would have renamed fec.c to (say) fec_base.c and then kept the module name fec.ko. Not sure keeping the module name is critical.

What is missing from your patch is dropping the EXPORT_SYMBOLs. Other than that I like it better than using a single .c file.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#4 lore raw

2013/3/21 Uwe Kleine-König <[email protected]>:

Quoted 11 lines

Hello,

Quoted 8 lines · Frank Li

I suggest use below patch to fix this problem

drivers/net/ethernet/freescale/Makefile +0 -0
@@ -2,7 +2,8 @@
 # Makefile for the Freescale network device drivers.
 #
 
Quoted 9 lines

drivers/net/ethernet/freescale/Makefile line 9

Quoted 6 lines
drivers/net/ethernet/freescale/Makefile +2 -1
-obj-$(CONFIG_FEC) += fec.o fec_ptp.o
+obj-$(CONFIG_FEC) += fec_driver.o
+fec_driver-objs := fec.o fec_ptp.o
 obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx.o
 ifeq ($(CONFIG_FEC_MPC52xx_MDIO),y)
        obj-$(CONFIG_FEC_MPC52xx) += fec_mpc52xx_phy.o

I thought about suggesting something similar, too. I would have renamed fec.c to (say) fec_base.c and then kept the module name fec.ko. Not sure keeping the module name is critical.

Okay, how about rename fec.c to fec_main.c?

Quoted 3 lines

What is missing from your patch is dropping the EXPORT_SYMBOLs. Other than that I like it better than using a single .c file.

There are not EXPORT_SYMBOL in my fec.c? which version do you use?

Quoted 7 lines

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |

#5 lore raw

Hello Frank,

Quoted 5 lines · Frank Li

2013/3/21 Uwe Kleine-König <[email protected]>:

Quoted 2 lines

What is missing from your patch is dropping the EXPORT_SYMBOLs. Other than that I like it better than using a single .c file.

There are not EXPORT_SYMBOL in my fec.c? which version do you use?

As David said he took Fabio's patch for stable I assume they are in net-next. I didn't check though.

Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
#6 lore raw
In reply to Fabio Estevam
Quoted 1 line · Fabio Estevam

Move fec_ptp.c code into fec.c and its definitions into fec.h.

...

drivers/net/ethernet/freescale/fec.c static const struct net_device_ops fec_netdev_ops = { · line 1619

Quoted 10 lines
drivers/net/ethernet/freescale/fec.c +10 -0
+/**
+ * fec_ptp_start_cyclecounter - create the cycle counter from hw
+ * @ndev: network device
+ *
+ * this function initializes the timecounter and cyclecounter
+ * structures for use in generated a ns counter from the arbitrary
+ * fixed point cycles registers in the hardware.
+ */
+void fec_ptp_start_cyclecounter(struct net_device *ndev)
+{

This function and the other, previously global functions should now be changed to 'static'.

Thanks,
Richard