aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0395-LF-183-sdk_fman-add-an-option-for-RTC-1588-timer-ini.patch
blob: 138d2b666f16f31e8347cbf41f4c5943059de18d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
From f7ed64503d5e27571833b76acee721d00448fdec Mon Sep 17 00:00:00 2001
From: Yangbo Lu <yangbo.lu@nxp.com>
Date: Mon, 2 Sep 2019 15:33:16 +0800
Subject: [PATCH] LF-183 sdk_fman: add an option for RTC (1588 timer)
 initialization and APIs

The RTC (1588 timer) could be managed by either ptp_qoriq driver
or sdk_fman RTC driver. So add an option for sdk_fman RTC
(1588 timer) initialization and APIs, so that user could select
it or not.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/net/ethernet/freescale/sdk_fman/Kconfig    |  9 +++++++++
 .../freescale/sdk_fman/Peripherals/FM/Makefile     |  3 ++-
 .../freescale/sdk_fman/Peripherals/FM/fm.c         |  4 ++++
 .../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h     | 22 ++++++++++++++++++++++
 .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c     | 18 +++++++++++++-----
 5 files changed, 50 insertions(+), 6 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_fman/Kconfig
+++ b/drivers/net/ethernet/freescale/sdk_fman/Kconfig
@@ -49,6 +49,15 @@ config FMAN_V3L
 endchoice
 endmenu
 
+config FSL_SDK_FMAN_RTC_API
+	bool "FMan RTC (1588 timer) APIs"
+	default n
+	help
+		This option enables RTC (1588 timer) initialization and
+		APIs support. The ptp_qoriq driver is not available if
+		it is selected for RTC (1588 timer). Neither of them
+		were not able to be used together.
+
 config FMAN_MIB_CNT_OVF_IRQ_EN
 	bool "Enable the dTSEC MIB counters overflow interrupt"
 	default n
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/Makefile
@@ -19,5 +19,6 @@ obj-y		+= Pcd/
 obj-y		+= SP/
 obj-y		+= Port/
 obj-y		+= HC/
-obj-y		+= Rtc/
 obj-y		+= MACSEC/
+
+obj-$(CONFIG_FSL_SDK_FMAN_RTC_API)	+= Rtc/
--- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/fm.c
@@ -602,8 +602,10 @@ do {
         FM_G_CALL_10G_MAC_ISR(0);
     if (pending & INTR_EN_10G_MAC1)
         FM_G_CALL_10G_MAC_ISR(1);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     if (pending & INTR_EN_TMR)
         p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
+#endif
 }
 
 #if (DPAA_VERSION >= 11)
@@ -4318,8 +4320,10 @@ void FM_EventIsr(t_Handle h_Fm)
         p_Fm->intrMng[e_FM_EV_PRS].f_Isr(p_Fm->intrMng[e_FM_EV_PRS].h_SrcHandle);
     if (pending & INTR_EN_PLCR)
         p_Fm->intrMng[e_FM_EV_PLCR].f_Isr(p_Fm->intrMng[e_FM_EV_PLCR].h_SrcHandle);
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     if (pending & INTR_EN_TMR)
             p_Fm->intrMng[e_FM_EV_TMR].f_Isr(p_Fm->intrMng[e_FM_EV_TMR].h_SrcHandle);
+#endif
 
     /* MAC events may belong to different partitions */
     if (pending & INTR_EN_1G_MAC0)
--- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
@@ -802,6 +802,7 @@ int fm_mac_set_rx_pause_frames(
 int fm_mac_set_tx_pause_frames(struct fm_mac_dev *fm_mac_dev,
 					     bool en);
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
 int fm_rtc_enable(struct fm *fm_dev);
 
 int fm_rtc_disable(struct fm *fm_dev);
@@ -819,6 +820,27 @@ int fm_rtc_set_alarm(struct fm *fm_dev,
 
 int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id,
 		uint64_t fiper);
+#else
+static inline int fm_rtc_enable(struct fm *fm_dev) { return 0; }
+
+static inline int fm_rtc_disable(struct fm *fm_dev) { return 0; }
+
+static inline int fm_rtc_get_cnt(struct fm *fm_dev, uint64_t *ts) { return 0; }
+
+static inline int fm_rtc_set_cnt(struct fm *fm_dev, uint64_t ts) { return 0; }
+
+static inline int fm_rtc_get_drift(struct fm *fm_dev, uint32_t *drift)
+{ return 0; }
+
+static inline int fm_rtc_set_drift(struct fm *fm_dev, uint32_t drift)
+{ return 0; }
+
+static inline int fm_rtc_set_alarm(struct fm *fm_dev, uint32_t id,
+				   uint64_t time) { return 0; }
+
+static inline int fm_rtc_set_fiper(struct fm *fm_dev, uint32_t id,
+				   uint64_t fiper) { return 0; }
+#endif
 
 int fm_mac_set_wol(struct fm_port *port, struct fm_mac_dev *fm_mac_dev,
 			bool en);
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
@@ -695,11 +695,7 @@ static t_LnxWrpFmDev * ReadFmDevTreeNode
         }
     }
 
-/* DPAA PTP timer was managed by ptp_qoriq driver in drivers/ptp/.
- * We will no longer manage it in sdk_fman driver and use related
- * APIs.
- */
-#if 0
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     /* Get the RTC base address and size */
     memset(ids, 0, sizeof(ids));
     if (WARN_ON(strlen("ptp-timer") >= sizeof(ids[0].name)))
@@ -941,6 +937,7 @@ static t_Error ConfigureFmDev(t_LnxWrpFm
     if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmMuramBaseAddr, (uint64_t)p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize) != E_OK)
         RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM MURAM memory map"));
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     if (p_LnxWrpFmDev->fmRtcPhysBaseAddr)
     {
         dev_res = __devm_request_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize, "fman-ptp-timer");
@@ -954,6 +951,7 @@ static t_Error ConfigureFmDev(t_LnxWrpFm
         if (SYS_RegisterIoMap((uint64_t)p_LnxWrpFmDev->fmRtcBaseAddr, (uint64_t)p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize) != E_OK)
             RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC memory map"));
     }
+#endif
 
 #if (DPAA_VERSION >= 11)
     if (p_LnxWrpFmDev->fmVspPhysBaseAddr) {
@@ -1187,6 +1185,7 @@ static t_Error InitFmDev(t_LnxWrpFmDev
          * FM_SetException(p_LnxWrpFmDev->h_Dev,e_FM_EX_MURAM_ECC,FALSE);*/
     }
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     if (p_LnxWrpFmDev->fmRtcBaseAddr)
     {
         t_FmRtcParams   fmRtcParam;
@@ -1205,6 +1204,7 @@ static t_Error InitFmDev(t_LnxWrpFmDev
         if (FM_RTC_Init(p_LnxWrpFmDev->h_RtcDev) != E_OK)
             RETURN_ERROR(MAJOR, E_INVALID_STATE, ("FM-RTC"));
     }
+#endif
 
     return E_OK;
 }
@@ -1219,8 +1219,10 @@ static void FreeFmDev(t_LnxWrpFmDev  *p_
 
     FreeFmPcdDev(p_LnxWrpFmDev);
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     if (p_LnxWrpFmDev->h_RtcDev)
 	FM_RTC_Free(p_LnxWrpFmDev->h_RtcDev);
+#endif
 
     if (p_LnxWrpFmDev->h_Dev)
         FM_Free(p_LnxWrpFmDev->h_Dev);
@@ -1228,12 +1230,14 @@ static void FreeFmDev(t_LnxWrpFmDev  *p_
     if (p_LnxWrpFmDev->h_MuramDev)
         FM_MURAM_Free(p_LnxWrpFmDev->h_MuramDev);
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
     if (p_LnxWrpFmDev->fmRtcBaseAddr)
     {
         SYS_UnregisterIoMap(p_LnxWrpFmDev->fmRtcBaseAddr);
         devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmRtcBaseAddr));
         __devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmRtcPhysBaseAddr, p_LnxWrpFmDev->fmRtcMemSize);
     }
+#endif
     SYS_UnregisterIoMap(p_LnxWrpFmDev->fmMuramBaseAddr);
     devm_iounmap(p_LnxWrpFmDev->dev, UINT_TO_PTR(p_LnxWrpFmDev->fmMuramBaseAddr));
     __devm_release_region(p_LnxWrpFmDev->dev, p_LnxWrpFmDev->res, p_LnxWrpFmDev->fmMuramPhysBaseAddr, p_LnxWrpFmDev->fmMuramMemSize);
@@ -1463,6 +1467,7 @@ void * fm_get_handle(struct fm *fm)
 }
 EXPORT_SYMBOL(fm_get_handle);
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
 void * fm_get_rtc_handle(struct fm *fm)
 {
     t_LnxWrpFmDev       *p_LnxWrpFmDev = (t_LnxWrpFmDev*)fm;
@@ -1470,6 +1475,7 @@ void * fm_get_rtc_handle(struct fm *fm)
     return (void *)p_LnxWrpFmDev->h_RtcDev;
 }
 EXPORT_SYMBOL(fm_get_rtc_handle);
+#endif
 
 struct fm_port * fm_port_bind (struct device *fm_port_dev)
 {
@@ -2053,6 +2059,7 @@ int fm_mac_set_tx_pause_frames(struct fm
 #endif
 EXPORT_SYMBOL(fm_mac_set_tx_pause_frames);
 
+#ifdef CONFIG_FSL_SDK_FMAN_RTC_API
 int fm_rtc_enable(struct fm *fm_dev)
 {
 	int			 _errno;
@@ -2209,6 +2216,7 @@ int fm_rtc_disable_interrupt(struct fm *
 }
 EXPORT_SYMBOL(fm_rtc_disable_interrupt);
 #endif
+#endif /* CONFIG_FSL_SDK_FMAN_RTC_API */
 
 int fm_mac_set_wol(struct fm_port *port, struct fm_mac_dev *fm_mac_dev, bool en)
 {