This source file includes following definitions.
- qoriq_read_be
- qoriq_write_be
- qoriq_read_le
- qoriq_write_le
- ptp_qoriq_create_debugfs
- ptp_qoriq_remove_debugfs
1
2
3
4
5
6 #ifndef __PTP_QORIQ_H__
7 #define __PTP_QORIQ_H__
8
9 #include <linux/io.h>
10 #include <linux/interrupt.h>
11 #include <linux/ptp_clock_kernel.h>
12
13
14
15
16 struct ctrl_regs {
17 u32 tmr_ctrl;
18 u32 tmr_tevent;
19 u32 tmr_temask;
20 u32 tmr_pevent;
21 u32 tmr_pemask;
22 u32 tmr_stat;
23 u32 tmr_cnt_h;
24 u32 tmr_cnt_l;
25 u32 tmr_add;
26 u32 tmr_acc;
27 u32 tmr_prsc;
28 u8 res1[4];
29 u32 tmroff_h;
30 u32 tmroff_l;
31 };
32
33 struct alarm_regs {
34 u32 tmr_alarm1_h;
35 u32 tmr_alarm1_l;
36 u32 tmr_alarm2_h;
37 u32 tmr_alarm2_l;
38 };
39
40 struct fiper_regs {
41 u32 tmr_fiper1;
42 u32 tmr_fiper2;
43 u32 tmr_fiper3;
44 };
45
46 struct etts_regs {
47 u32 tmr_etts1_h;
48 u32 tmr_etts1_l;
49 u32 tmr_etts2_h;
50 u32 tmr_etts2_l;
51 };
52
53 struct ptp_qoriq_registers {
54 struct ctrl_regs __iomem *ctrl_regs;
55 struct alarm_regs __iomem *alarm_regs;
56 struct fiper_regs __iomem *fiper_regs;
57 struct etts_regs __iomem *etts_regs;
58 };
59
60
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
65
66 #define CTRL_REGS_OFFSET 0x80
67 #define ALARM_REGS_OFFSET 0xb8
68 #define FIPER_REGS_OFFSET 0xd0
69 #define ETTS_REGS_OFFSET 0xe0
70
71
72
73 #define ALM1P (1<<31)
74 #define ALM2P (1<<30)
75 #define FIPERST (1<<28)
76 #define PP1L (1<<27)
77 #define PP2L (1<<26)
78 #define TCLK_PERIOD_SHIFT (16)
79 #define TCLK_PERIOD_MASK (0x3ff)
80 #define RTPE (1<<15)
81 #define FRD (1<<14)
82 #define ESFDP (1<<11)
83 #define ESFDE (1<<10)
84 #define ETEP2 (1<<9)
85 #define ETEP1 (1<<8)
86 #define COPH (1<<7)
87 #define CIPH (1<<6)
88 #define TMSR (1<<5)
89 #define BYP (1<<3)
90 #define TE (1<<2)
91 #define CKSEL_SHIFT (0)
92 #define CKSEL_MASK (0x3)
93
94
95 #define ETS2 (1<<25)
96 #define ETS1 (1<<24)
97 #define ALM2 (1<<17)
98 #define ALM1 (1<<16)
99 #define PP1 (1<<7)
100 #define PP2 (1<<6)
101 #define PP3 (1<<5)
102
103
104 #define ETS2EN (1<<25)
105 #define ETS1EN (1<<24)
106 #define ALM2EN (1<<17)
107 #define ALM1EN (1<<16)
108 #define PP1EN (1<<7)
109 #define PP2EN (1<<6)
110
111
112 #define TXP2 (1<<9)
113 #define TXP1 (1<<8)
114 #define RXP (1<<0)
115
116
117 #define TXP2EN (1<<9)
118 #define TXP1EN (1<<8)
119 #define RXPEN (1<<0)
120
121
122 #define STAT_VEC_SHIFT (0)
123 #define STAT_VEC_MASK (0x3f)
124 #define ETS1_VLD (1<<24)
125 #define ETS2_VLD (1<<25)
126
127
128 #define PRSC_OCK_SHIFT (0)
129 #define PRSC_OCK_MASK (0xffff)
130
131
132 #define DRIVER "ptp_qoriq"
133 #define N_EXT_TS 2
134
135 #define DEFAULT_CKSEL 1
136 #define DEFAULT_TMR_PRSC 2
137 #define DEFAULT_FIPER1_PERIOD 1000000000
138 #define DEFAULT_FIPER2_PERIOD 100000
139
140 struct ptp_qoriq {
141 void __iomem *base;
142 struct ptp_qoriq_registers regs;
143 spinlock_t lock;
144 struct ptp_clock *clock;
145 struct ptp_clock_info caps;
146 struct resource *rsrc;
147 struct dentry *debugfs_root;
148 struct device *dev;
149 bool extts_fifo_support;
150 int irq;
151 int phc_index;
152 u64 alarm_interval;
153 u64 alarm_value;
154 u32 tclk_period;
155 u32 tmr_prsc;
156 u32 tmr_add;
157 u32 cksel;
158 u32 tmr_fiper1;
159 u32 tmr_fiper2;
160 u32 (*read)(unsigned __iomem *addr);
161 void (*write)(unsigned __iomem *addr, u32 val);
162 };
163
164 static inline u32 qoriq_read_be(unsigned __iomem *addr)
165 {
166 return ioread32be(addr);
167 }
168
169 static inline void qoriq_write_be(unsigned __iomem *addr, u32 val)
170 {
171 iowrite32be(val, addr);
172 }
173
174 static inline u32 qoriq_read_le(unsigned __iomem *addr)
175 {
176 return ioread32(addr);
177 }
178
179 static inline void qoriq_write_le(unsigned __iomem *addr, u32 val)
180 {
181 iowrite32(val, addr);
182 }
183
184 irqreturn_t ptp_qoriq_isr(int irq, void *priv);
185 int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
186 const struct ptp_clock_info *caps);
187 void ptp_qoriq_free(struct ptp_qoriq *ptp_qoriq);
188 int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm);
189 int ptp_qoriq_adjtime(struct ptp_clock_info *ptp, s64 delta);
190 int ptp_qoriq_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts);
191 int ptp_qoriq_settime(struct ptp_clock_info *ptp,
192 const struct timespec64 *ts);
193 int ptp_qoriq_enable(struct ptp_clock_info *ptp,
194 struct ptp_clock_request *rq, int on);
195 #ifdef CONFIG_DEBUG_FS
196 void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq);
197 void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq);
198 #else
199 static inline void ptp_qoriq_create_debugfs(struct ptp_qoriq *ptp_qoriq)
200 { }
201 static inline void ptp_qoriq_remove_debugfs(struct ptp_qoriq *ptp_qoriq)
202 { }
203 #endif
204
205 #endif