blob: 4d120ef911124d4bcda3306d838ebdfd5320fd1f (
plain) (
blame)
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
|
#include <linux/module.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/uaccess.h>
#include <linux/mm.h>
#include <linux/kfifo.h>
#include <linux/firmware.h>
#include <linux/syscalls.h>
#include <linux/uaccess.h>
#include <linux/platform_device.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/of.h>
#ifdef CONFIG_OF
#include <linux/of_fdt.h>
#endif
#include <asm/setup.h>
#include <asm/atomic.h>
#include <mach/mt_typedefs.h>
#include <mach/mt_boot_common.h>
#include <mach/mt_ccci_common.h>
static wait_queue_head_t time_update_notify_queue_head;
static spinlock_t wait_count_lock;
static volatile unsigned int wait_count;
static volatile unsigned int get_update;
static volatile unsigned int api_ready;
void ccci_timer_for_md_init(void)
{
init_waitqueue_head(&time_update_notify_queue_head);
spin_lock_init(&wait_count_lock);
wait_count = 0;
get_update = 0;
mb();
api_ready = 1;
}
int wait_time_update_notify(void) // Only support one wait currently
{
int ret = -1;
unsigned long flags;
if(api_ready) {
// Update wait count ++
spin_lock_irqsave(&wait_count_lock, flags);
wait_count++;
spin_unlock_irqrestore(&wait_count_lock, flags);
ret = wait_event_interruptible(time_update_notify_queue_head, get_update);
if(ret == -ERESTARTSYS) {
} else {
get_update = 0;
}
// Update wait count --
spin_lock_irqsave(&wait_count_lock, flags);
wait_count--;
spin_unlock_irqrestore(&wait_count_lock, flags);
}
return ret;
}
void notify_time_update(void)
{
unsigned long flags;
if(!api_ready)
return; // API not ready
get_update = 1;
spin_lock_irqsave(&wait_count_lock, flags);
if(wait_count) {
wake_up_all(&time_update_notify_queue_head);
}
spin_unlock_irqrestore(&wait_count_lock, flags);
}
|