aboutsummaryrefslogtreecommitdiffstats
path: root/trace-seq.c
Commit message (Expand)AuthorAge
* Added trace_seq_terminateSteven Rostedt2009-12-02
* keep track of buffer fullJohannes Berg2009-11-25
* Move trace-seq header into parse-events.hSteven Rostedt2009-11-24
* Remove unused functions from trace-seqSteven Rostedt2009-11-24
* Add trace-seqSteven Rostedt2009-11-16
e85529a'>8417eb7a168
1da177e4c3f
ada8e9514b5
1da177e4c3f














bd0765098bf
1da177e4c3f


bd0765098bf
1da177e4c3f
8417eb7a168
1da177e4c3f


5d2a50371dd
1da177e4c3f


1da177e4c3f
1da177e4c3f
ada8e9514b5
1da177e4c3f
4cad4431fcd
1da177e4c3f
1da177e4c3f































1da177e4c3f











34af946a227
1da177e4c3f
1da177e4c3f
9b5ef64a3a7
2fac6674ddf

1da177e4c3f
1da177e4c3f

8417eb7a168
1da177e4c3f
8417eb7a168
1da177e4c3f

























8417eb7a168
1da177e4c3f
1da177e4c3f


8417eb7a168




1da177e4c3f


bd0765098bf

1da177e4c3f

8417eb7a168
1da177e4c3f





8417eb7a168


1da177e4c3f

8417eb7a168
1da177e4c3f







8417eb7a168

1da177e4c3f

8417eb7a168
1da177e4c3f
8417eb7a168

1da177e4c3f
8417eb7a168
1da177e4c3f
8417eb7a168


9b5ef64a3a7
1da177e4c3f
8417eb7a168
1da177e4c3f
8417eb7a168
1da177e4c3f
8417eb7a168

1da177e4c3f
8417eb7a168



1da177e4c3f
8417eb7a168

1da177e4c3f
8417eb7a168
1da177e4c3f
9b5ef64a3a7
bd0765098bf
9b5ef64a3a7
8417eb7a168


1da177e4c3f
9b5ef64a3a7
bd0765098bf
9b5ef64a3a7


8417eb7a168
1da177e4c3f



4cad4431fcd
1da177e4c3f
61df33370c5
1da177e4c3f
5d2a50371dd

4cad4431fcd


4cad4431fcd

61df33370c5


4cad4431fcd

















1da177e4c3f

9b5ef64a3a7


bd0765098bf
9b5ef64a3a7



1da177e4c3f

9b5ef64a3a7


bd0765098bf
9b5ef64a3a7



1da177e4c3f
1da177e4c3f





1da177e4c3f


b3969e5831a
1da177e4c3f




7d12e780e00
1da177e4c3f
8417eb7a168

1da177e4c3f
8417eb7a168
1da177e4c3f
ab6a2d70d18
1da177e4c3f



7d12e780e00
1da177e4c3f
8417eb7a168

1da177e4c3f

1da177e4c3f




ab6a2d70d18
1da177e4c3f



ff8371ac9a5
8417eb7a168





4cad4431fcd

1da177e4c3f

d39b6cfe664
1da177e4c3f
bd0765098bf
8417eb7a168
1da177e4c3f

bd0765098bf
1da177e4c3f

bd0765098bf

1da177e4c3f

a91912f8e4e
bd0765098bf
1da177e4c3f
bd0765098bf






a91912f8e4e
bd0765098bf


1da177e4c3f

8417eb7a168

bd0765098bf

1da177e4c3f

4cad4431fcd

1da177e4c3f







1da177e4c3f

bd0765098bf
2fac6674ddf
bd0765098bf

1da177e4c3f

bd0765098bf





2fac6674ddf
bd0765098bf





1da177e4c3f
8417eb7a168

bd0765098bf

1da177e4c3f
1da177e4c3f


bd0765098bf















1da177e4c3f

8417eb7a168
1da177e4c3f
8417eb7a168
1da177e4c3f
8417eb7a168
bd0765098bf
8417eb7a168


1da177e4c3f
bd0765098bf


1da177e4c3f
bd0765098bf
1da177e4c3f




ad28a07bcad


8417eb7a168
1da177e4c3f
d39b6cfe664
3ae5eaec1d2

d39b6cfe664
3ae5eaec1d2
1da177e4c3f

d39b6cfe664
1da177e4c3f
bd0765098bf
1da177e4c3f

d39b6cfe664
1da177e4c3f
8417eb7a168
1da177e4c3f



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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
  
                                                      
  
                                                                














                                                                             
                      


                         
                            
                         
                                  


                           
                       


                      
                        
 
                                                     
                                                   
                         
 































                                     











                                                                             
                                 
                               
                                    
                                  

                   
 

                                                     
 
                                                       
 

























                                                                         
                                                  
 


                                 




                                 


                                   

                             

 
                                                                          





                                                 


                                                      

 
                                                                         







                                                                                   

                 

 
                                                                               
 

                                              
 
                                 
 


                                   
                                        
 
                                   
 
                                                                      
 

                 
 



                                                                              
 

                                                                                 
 
                                 
 
                          
                                     
 


                                                          
 
                            
                                    


                                        
                                   



                 
                                                                
 
                  
 

                                 


                              

                                 


                                                    

















                                                                                    

                        


                                         
                                            



                                           

                         


                                         
                                             



                                           
                      





                                                                    


                            
                                    




                 
                                                               
 

                                                                        
 
                                               
 
                                       



                           
                                                            
 

                                                                        

                                             




                                            
                                       



                           
                                                    





                                                

                                                   

  
                                                            
 
                             
                               

                   
                                     

                              

                                                             

                              
                                                            
                       
                              






                                                             
                                                            


                                      

         

                                                                                      

                                      

         

                                               







                                 

                                   
                                            
                           

                                           

         





                                                                           
                         





                                                                        
 

                                        

                             
 


                                                                        















                                   

 
                                                             
 
                               
 
                                         
                


                                           
 


                                
                                   
                      




                                   


                                    
                                                     
                                    
                                                  

                                   
                                      
          

  
                                       
 
                                                              

 
                                        
 
                                                         



                             
/*
 *  Driver for NEC VR4100 series Real Time Clock unit.
 *
 *  Copyright (C) 2003-2008  Yoichi Yuasa <yuasa@linux-mips.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
#include <linux/err.h>
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/log2.h>

#include <asm/div64.h>
#include <asm/io.h>
#include <asm/uaccess.h>

MODULE_AUTHOR("Yoichi Yuasa <yuasa@linux-mips.org>");
MODULE_DESCRIPTION("NEC VR4100 series RTC driver");
MODULE_LICENSE("GPL v2");

/* RTC 1 registers */
#define ETIMELREG		0x00
#define ETIMEMREG		0x02
#define ETIMEHREG		0x04
/* RFU */
#define ECMPLREG		0x08
#define ECMPMREG		0x0a
#define ECMPHREG		0x0c
/* RFU */
#define RTCL1LREG		0x10
#define RTCL1HREG		0x12
#define RTCL1CNTLREG		0x14
#define RTCL1CNTHREG		0x16
#define RTCL2LREG		0x18
#define RTCL2HREG		0x1a
#define RTCL2CNTLREG		0x1c
#define RTCL2CNTHREG		0x1e

/* RTC 2 registers */
#define TCLKLREG		0x00
#define TCLKHREG		0x02
#define TCLKCNTLREG		0x04
#define TCLKCNTHREG		0x06
/* RFU */
#define RTCINTREG		0x1e
 #define TCLOCK_INT		0x08
 #define RTCLONG2_INT		0x04
 #define RTCLONG1_INT		0x02
 #define ELAPSEDTIME_INT	0x01

#define RTC_FREQUENCY		32768
#define MAX_PERIODIC_RATE	6553

static void __iomem *rtc1_base;
static void __iomem *rtc2_base;

#define rtc1_read(offset)		readw(rtc1_base + (offset))
#define rtc1_write(offset, value)	writew((value), rtc1_base + (offset))

#define rtc2_read(offset)		readw(rtc2_base + (offset))
#define rtc2_write(offset, value)	writew((value), rtc2_base + (offset))

static unsigned long epoch = 1970;	/* Jan 1 1970 00:00:00 */

static DEFINE_SPINLOCK(rtc_lock);
static char rtc_name[] = "RTC";
static unsigned long periodic_count;
static unsigned int alarm_enabled;
static int aie_irq;
static int pie_irq;

static inline unsigned long read_elapsed_second(void)
{

	unsigned long first_low, first_mid, first_high;

	unsigned long second_low, second_mid, second_high;

	do {
		first_low = rtc1_read(ETIMELREG);
		first_mid = rtc1_read(ETIMEMREG);
		first_high = rtc1_read(ETIMEHREG);
		second_low = rtc1_read(ETIMELREG);
		second_mid = rtc1_read(ETIMEMREG);
		second_high = rtc1_read(ETIMEHREG);
	} while (first_low != second_low || first_mid != second_mid ||
	         first_high != second_high);

	return (first_high << 17) | (first_mid << 1) | (first_low >> 15);
}

static inline void write_elapsed_second(unsigned long sec)
{
	spin_lock_irq(&rtc_lock);

	rtc1_write(ETIMELREG, (uint16_t)(sec << 15));
	rtc1_write(ETIMEMREG, (uint16_t)(sec >> 1));
	rtc1_write(ETIMEHREG, (uint16_t)(sec >> 17));

	spin_unlock_irq(&rtc_lock);
}

static void vr41xx_rtc_release(struct device *dev)
{

	spin_lock_irq(&rtc_lock);

	rtc1_write(ECMPLREG, 0);
	rtc1_write(ECMPMREG, 0);
	rtc1_write(ECMPHREG, 0);
	rtc1_write(RTCL1LREG, 0);
	rtc1_write(RTCL1HREG, 0);

	spin_unlock_irq(&rtc_lock);

	disable_irq(aie_irq);
	disable_irq(pie_irq);
}

static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time)
{
	unsigned long epoch_sec, elapsed_sec;

	epoch_sec = mktime(epoch, 1, 1, 0, 0, 0);
	elapsed_sec = read_elapsed_second();

	rtc_time_to_tm(epoch_sec + elapsed_sec, time);

	return 0;
}

static int vr41xx_rtc_set_time(struct device *dev, struct rtc_time *time)
{
	unsigned long epoch_sec, current_sec;

	epoch_sec = mktime(epoch, 1, 1, 0, 0, 0);
	current_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
	                     time->tm_hour, time->tm_min, time->tm_sec);

	write_elapsed_second(current_sec - epoch_sec);

	return 0;
}

static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
{
	unsigned long low, mid, high;
	struct rtc_time *time = &wkalrm->time;

	spin_lock_irq(&rtc_lock);

	low = rtc1_read(ECMPLREG);
	mid = rtc1_read(ECMPMREG);
	high = rtc1_read(ECMPHREG);
	wkalrm->enabled = alarm_enabled;

	spin_unlock_irq(&rtc_lock);

	rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time);

	return 0;
}

static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm)
{
	unsigned long alarm_sec;
	struct rtc_time *time = &wkalrm->time;

	alarm_sec = mktime(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
	                   time->tm_hour, time->tm_min, time->tm_sec);

	spin_lock_irq(&rtc_lock);

	if (alarm_enabled)
		disable_irq(aie_irq);

	rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15));
	rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1));
	rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17));

	if (wkalrm->enabled)
		enable_irq(aie_irq);

	alarm_enabled = wkalrm->enabled;

	spin_unlock_irq(&rtc_lock);

	return 0;
}

static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq)
{
	u64 count;

	if (!is_power_of_2(freq))
		return -EINVAL;
	count = RTC_FREQUENCY;
	do_div(count, freq);

	spin_lock_irq(&rtc_lock);

	periodic_count = count;
	rtc1_write(RTCL1LREG, periodic_count);
	rtc1_write(RTCL1HREG, periodic_count >> 16);

	spin_unlock_irq(&rtc_lock);

	return 0;
}

static int vr41xx_rtc_irq_set_state(struct device *dev, int enabled)
{
	if (enabled)
		enable_irq(pie_irq);
	else
		disable_irq(pie_irq);

	return 0;
}

static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
{
	switch (cmd) {
	case RTC_AIE_ON:
		spin_lock_irq(&rtc_lock);

		if (!alarm_enabled) {
			enable_irq(aie_irq);
			alarm_enabled = 1;
		}

		spin_unlock_irq(&rtc_lock);
		break;
	case RTC_AIE_OFF:
		spin_lock_irq(&rtc_lock);

		if (alarm_enabled) {
			disable_irq(aie_irq);
			alarm_enabled = 0;
		}