@@ -43,8 +43,8 @@ static u64 tmr_cnt_read(struct ptp_qoriq *ptp_qoriq)
43
43
u64 ns ;
44
44
u32 lo , hi ;
45
45
46
- lo = qoriq_read (& regs -> ctrl_regs -> tmr_cnt_l );
47
- hi = qoriq_read (& regs -> ctrl_regs -> tmr_cnt_h );
46
+ lo = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_cnt_l );
47
+ hi = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_cnt_h );
48
48
ns = ((u64 ) hi ) << 32 ;
49
49
ns |= lo ;
50
50
return ns ;
@@ -57,8 +57,8 @@ static void tmr_cnt_write(struct ptp_qoriq *ptp_qoriq, u64 ns)
57
57
u32 hi = ns >> 32 ;
58
58
u32 lo = ns & 0xffffffff ;
59
59
60
- qoriq_write (& regs -> ctrl_regs -> tmr_cnt_l , lo );
61
- qoriq_write (& regs -> ctrl_regs -> tmr_cnt_h , hi );
60
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_cnt_l , lo );
61
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_cnt_h , hi );
62
62
}
63
63
64
64
/* Caller must hold ptp_qoriq->lock. */
@@ -73,8 +73,8 @@ static void set_alarm(struct ptp_qoriq *ptp_qoriq)
73
73
ns -= ptp_qoriq -> tclk_period ;
74
74
hi = ns >> 32 ;
75
75
lo = ns & 0xffffffff ;
76
- qoriq_write (& regs -> alarm_regs -> tmr_alarm1_l , lo );
77
- qoriq_write (& regs -> alarm_regs -> tmr_alarm1_h , hi );
76
+ ptp_qoriq -> write (& regs -> alarm_regs -> tmr_alarm1_l , lo );
77
+ ptp_qoriq -> write (& regs -> alarm_regs -> tmr_alarm1_h , hi );
78
78
}
79
79
80
80
/* Caller must hold ptp_qoriq->lock. */
@@ -83,8 +83,8 @@ static void set_fipers(struct ptp_qoriq *ptp_qoriq)
83
83
struct ptp_qoriq_registers * regs = & ptp_qoriq -> regs ;
84
84
85
85
set_alarm (ptp_qoriq );
86
- qoriq_write (& regs -> fiper_regs -> tmr_fiper1 , ptp_qoriq -> tmr_fiper1 );
87
- qoriq_write (& regs -> fiper_regs -> tmr_fiper2 , ptp_qoriq -> tmr_fiper2 );
86
+ ptp_qoriq -> write (& regs -> fiper_regs -> tmr_fiper1 , ptp_qoriq -> tmr_fiper1 );
87
+ ptp_qoriq -> write (& regs -> fiper_regs -> tmr_fiper2 , ptp_qoriq -> tmr_fiper2 );
88
88
}
89
89
90
90
static int extts_clean_up (struct ptp_qoriq * ptp_qoriq , int index ,
@@ -115,16 +115,16 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
115
115
event .index = index ;
116
116
117
117
do {
118
- lo = qoriq_read (reg_etts_l );
119
- hi = qoriq_read (reg_etts_h );
118
+ lo = ptp_qoriq -> read (reg_etts_l );
119
+ hi = ptp_qoriq -> read (reg_etts_h );
120
120
121
121
if (update_event ) {
122
122
event .timestamp = ((u64 ) hi ) << 32 ;
123
123
event .timestamp |= lo ;
124
124
ptp_clock_event (ptp_qoriq -> clock , & event );
125
125
}
126
126
127
- stat = qoriq_read (& regs -> ctrl_regs -> tmr_stat );
127
+ stat = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_stat );
128
128
} while (ptp_qoriq -> extts_fifo_support && (stat & valid ));
129
129
130
130
return 0 ;
@@ -144,8 +144,8 @@ irqreturn_t ptp_qoriq_isr(int irq, void *priv)
144
144
145
145
spin_lock (& ptp_qoriq -> lock );
146
146
147
- val = qoriq_read (& regs -> ctrl_regs -> tmr_tevent );
148
- mask = qoriq_read (& regs -> ctrl_regs -> tmr_temask );
147
+ val = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_tevent );
148
+ mask = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_temask );
149
149
150
150
spin_unlock (& ptp_qoriq -> lock );
151
151
@@ -173,14 +173,14 @@ irqreturn_t ptp_qoriq_isr(int irq, void *priv)
173
173
ns = ptp_qoriq -> alarm_value + ptp_qoriq -> alarm_interval ;
174
174
hi = ns >> 32 ;
175
175
lo = ns & 0xffffffff ;
176
- qoriq_write (& regs -> alarm_regs -> tmr_alarm2_l , lo );
177
- qoriq_write (& regs -> alarm_regs -> tmr_alarm2_h , hi );
176
+ ptp_qoriq -> write (& regs -> alarm_regs -> tmr_alarm2_l , lo );
177
+ ptp_qoriq -> write (& regs -> alarm_regs -> tmr_alarm2_h , hi );
178
178
ptp_qoriq -> alarm_value = ns ;
179
179
} else {
180
180
spin_lock (& ptp_qoriq -> lock );
181
- mask = qoriq_read (& regs -> ctrl_regs -> tmr_temask );
181
+ mask = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_temask );
182
182
mask &= ~ALM2EN ;
183
- qoriq_write (& regs -> ctrl_regs -> tmr_temask , mask );
183
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_temask , mask );
184
184
spin_unlock (& ptp_qoriq -> lock );
185
185
ptp_qoriq -> alarm_value = 0 ;
186
186
ptp_qoriq -> alarm_interval = 0 ;
@@ -194,7 +194,7 @@ irqreturn_t ptp_qoriq_isr(int irq, void *priv)
194
194
}
195
195
196
196
if (ack ) {
197
- qoriq_write (& regs -> ctrl_regs -> tmr_tevent , ack );
197
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_tevent , ack );
198
198
return IRQ_HANDLED ;
199
199
} else
200
200
return IRQ_NONE ;
@@ -229,7 +229,7 @@ int ptp_qoriq_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
229
229
230
230
tmr_add = neg_adj ? tmr_add - diff : tmr_add + diff ;
231
231
232
- qoriq_write (& regs -> ctrl_regs -> tmr_add , tmr_add );
232
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_add , tmr_add );
233
233
234
234
return 0 ;
235
235
}
@@ -326,15 +326,15 @@ int ptp_qoriq_enable(struct ptp_clock_info *ptp,
326
326
327
327
spin_lock_irqsave (& ptp_qoriq -> lock , flags );
328
328
329
- mask = qoriq_read (& regs -> ctrl_regs -> tmr_temask );
329
+ mask = ptp_qoriq -> read (& regs -> ctrl_regs -> tmr_temask );
330
330
if (on ) {
331
331
mask |= bit ;
332
- qoriq_write (& regs -> ctrl_regs -> tmr_tevent , bit );
332
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_tevent , bit );
333
333
} else {
334
334
mask &= ~bit ;
335
335
}
336
336
337
- qoriq_write (& regs -> ctrl_regs -> tmr_temask , mask );
337
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_temask , mask );
338
338
339
339
spin_unlock_irqrestore (& ptp_qoriq -> lock , flags );
340
340
return 0 ;
@@ -496,6 +496,14 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
496
496
return - ENODEV ;
497
497
}
498
498
499
+ if (of_property_read_bool (node , "little-endian" )) {
500
+ ptp_qoriq -> read = qoriq_read_le ;
501
+ ptp_qoriq -> write = qoriq_write_le ;
502
+ } else {
503
+ ptp_qoriq -> read = qoriq_read_be ;
504
+ ptp_qoriq -> write = qoriq_write_be ;
505
+ }
506
+
499
507
if (of_device_is_compatible (node , "fsl,fman-ptp-timer" )) {
500
508
ptp_qoriq -> regs .ctrl_regs = base + FMAN_CTRL_REGS_OFFSET ;
501
509
ptp_qoriq -> regs .alarm_regs = base + FMAN_ALARM_REGS_OFFSET ;
@@ -519,13 +527,14 @@ int ptp_qoriq_init(struct ptp_qoriq *ptp_qoriq, void __iomem *base,
519
527
spin_lock_irqsave (& ptp_qoriq -> lock , flags );
520
528
521
529
regs = & ptp_qoriq -> regs ;
522
- qoriq_write (& regs -> ctrl_regs -> tmr_ctrl , tmr_ctrl );
523
- qoriq_write (& regs -> ctrl_regs -> tmr_add , ptp_qoriq -> tmr_add );
524
- qoriq_write (& regs -> ctrl_regs -> tmr_prsc , ptp_qoriq -> tmr_prsc );
525
- qoriq_write (& regs -> fiper_regs -> tmr_fiper1 , ptp_qoriq -> tmr_fiper1 );
526
- qoriq_write (& regs -> fiper_regs -> tmr_fiper2 , ptp_qoriq -> tmr_fiper2 );
530
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_ctrl , tmr_ctrl );
531
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_add , ptp_qoriq -> tmr_add );
532
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_prsc , ptp_qoriq -> tmr_prsc );
533
+ ptp_qoriq -> write (& regs -> fiper_regs -> tmr_fiper1 , ptp_qoriq -> tmr_fiper1 );
534
+ ptp_qoriq -> write (& regs -> fiper_regs -> tmr_fiper2 , ptp_qoriq -> tmr_fiper2 );
527
535
set_alarm (ptp_qoriq );
528
- qoriq_write (& regs -> ctrl_regs -> tmr_ctrl , tmr_ctrl |FIPERST |RTPE |TE |FRD );
536
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_ctrl ,
537
+ tmr_ctrl |FIPERST |RTPE |TE |FRD );
529
538
530
539
spin_unlock_irqrestore (& ptp_qoriq -> lock , flags );
531
540
@@ -543,8 +552,8 @@ void ptp_qoriq_free(struct ptp_qoriq *ptp_qoriq)
543
552
{
544
553
struct ptp_qoriq_registers * regs = & ptp_qoriq -> regs ;
545
554
546
- qoriq_write (& regs -> ctrl_regs -> tmr_temask , 0 );
547
- qoriq_write (& regs -> ctrl_regs -> tmr_ctrl , 0 );
555
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_temask , 0 );
556
+ ptp_qoriq -> write (& regs -> ctrl_regs -> tmr_ctrl , 0 );
548
557
549
558
ptp_qoriq_remove_debugfs (ptp_qoriq );
550
559
ptp_clock_unregister (ptp_qoriq -> clock );
0 commit comments