hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/include/linux/fsl/ptp_qoriq.h
....@@ -7,6 +7,7 @@
77 #define __PTP_QORIQ_H__
88
99 #include <linux/io.h>
10
+#include <linux/interrupt.h>
1011 #include <linux/ptp_clock_kernel.h>
1112
1213 /*
....@@ -49,7 +50,7 @@
4950 u32 tmr_etts2_l; /* Timestamp of general purpose external trigger */
5051 };
5152
52
-struct qoriq_ptp_registers {
53
+struct ptp_qoriq_registers {
5354 struct ctrl_regs __iomem *ctrl_regs;
5455 struct alarm_regs __iomem *alarm_regs;
5556 struct fiper_regs __iomem *fiper_regs;
....@@ -57,15 +58,15 @@
5758 };
5859
5960 /* Offset definitions for the four register groups */
60
-#define CTRL_REGS_OFFSET 0x0
61
-#define ALARM_REGS_OFFSET 0x40
62
-#define FIPER_REGS_OFFSET 0x80
63
-#define ETTS_REGS_OFFSET 0xa0
61
+#define ETSEC_CTRL_REGS_OFFSET 0x0
62
+#define ETSEC_ALARM_REGS_OFFSET 0x40
63
+#define ETSEC_FIPER_REGS_OFFSET 0x80
64
+#define ETSEC_ETTS_REGS_OFFSET 0xa0
6465
65
-#define FMAN_CTRL_REGS_OFFSET 0x80
66
-#define FMAN_ALARM_REGS_OFFSET 0xb8
67
-#define FMAN_FIPER_REGS_OFFSET 0xd0
68
-#define FMAN_ETTS_REGS_OFFSET 0xe0
66
+#define CTRL_REGS_OFFSET 0x80
67
+#define ALARM_REGS_OFFSET 0xb8
68
+#define FIPER_REGS_OFFSET 0xd0
69
+#define ETTS_REGS_OFFSET 0xe0
6970
7071
7172 /* Bit definitions for the TMR_CTRL register */
....@@ -120,6 +121,8 @@
120121 /* Bit definitions for the TMR_STAT register */
121122 #define STAT_VEC_SHIFT (0) /* Timer general purpose status vector */
122123 #define STAT_VEC_MASK (0x3f)
124
+#define ETS1_VLD (1<<24)
125
+#define ETS2_VLD (1<<25)
123126
124127 /* Bit definitions for the TMR_PRSC register */
125128 #define PRSC_OCK_SHIFT (0) /* Output clock division/prescale factor. */
....@@ -132,38 +135,73 @@
132135 #define DEFAULT_CKSEL 1
133136 #define DEFAULT_TMR_PRSC 2
134137 #define DEFAULT_FIPER1_PERIOD 1000000000
135
-#define DEFAULT_FIPER2_PERIOD 100000
138
+#define DEFAULT_FIPER2_PERIOD 1000000000
139
+#define DEFAULT_FIPER3_PERIOD 1000000000
136140
137
-struct qoriq_ptp {
141
+struct ptp_qoriq {
138142 void __iomem *base;
139
- struct qoriq_ptp_registers regs;
143
+ struct ptp_qoriq_registers regs;
140144 spinlock_t lock; /* protects regs */
141145 struct ptp_clock *clock;
142146 struct ptp_clock_info caps;
143147 struct resource *rsrc;
148
+ struct dentry *debugfs_root;
149
+ struct device *dev;
150
+ bool extts_fifo_support;
151
+ bool fiper3_support;
144152 int irq;
145153 int phc_index;
146
- u64 alarm_interval; /* for periodic alarm */
147
- u64 alarm_value;
148154 u32 tclk_period; /* nanoseconds */
149155 u32 tmr_prsc;
150156 u32 tmr_add;
151157 u32 cksel;
152158 u32 tmr_fiper1;
153159 u32 tmr_fiper2;
160
+ u32 tmr_fiper3;
161
+ u32 (*read)(unsigned __iomem *addr);
162
+ void (*write)(unsigned __iomem *addr, u32 val);
154163 };
155164
156
-static inline u32 qoriq_read(unsigned __iomem *addr)
165
+static inline u32 qoriq_read_be(unsigned __iomem *addr)
157166 {
158
- u32 val;
159
-
160
- val = ioread32be(addr);
161
- return val;
167
+ return ioread32be(addr);
162168 }
163169
164
-static inline void qoriq_write(unsigned __iomem *addr, u32 val)
170
+static inline void qoriq_write_be(unsigned __iomem *addr, u32 val)
165171 {
166172 iowrite32be(val, addr);
167173 }
168174
175
+static inline u32 qoriq_read_le(unsigned __iomem *addr)
176
+{
177
+ return ioread32(addr);
178
+}
179
+
180
+static inline void qoriq_write_le(unsigned __iomem *addr, u32 val)
181
+{
182
+ iowrite32(val, addr);
183
+}
184
+
185
+irqreturn_t ptp_qoriq_isr(int irq, void *priv);
186
+int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
187
+ const struct ptp_clock_info *caps);
188
+void ptp_qoriq_free(struct ptp_qoriq *ptp_qoriq);
189
+int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm);
190
+int ptp_qoriq_adjtime(struct ptp_clock_info *ptp, s64 delta);
191
+int ptp_qoriq_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts);
192
+int ptp_qoriq_settime(struct ptp_clock_info *ptp,
193
+ const struct timespec64 *ts);
194
+int ptp_qoriq_enable(struct ptp_clock_info *ptp,
195
+ struct ptp_clock_request *rq, int on);
196
+int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index, bool update_event);
197
+#ifdef CONFIG_DEBUG_FS
198
+void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq);
199
+void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq);
200
+#else
201
+static inline void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq)
202
+{ }
203
+static inline void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq)
204
+{ }
205
+#endif
206
+
169207 #endif