diff options
author | Tomasz Figa <t.figa@samsung.com> | 2013-04-23 11:46:24 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2013-04-28 15:16:46 -0400 |
commit | 7aac482e6290ab7ad21809e0c7327be959a2203e (patch) | |
tree | 79f8c75ef9cac0446cd595a5482fe9d56cdbe9c8 /drivers/clocksource | |
parent | 77d844344952934baf2902cf6f1ac870dc1b4d7a (diff) |
clocksource: samsung_pwm_timer: Make PWM spinlock global
This patch makes the PWM spinlock global and exports it to allow using
it in Samsung PWM driver (will be reworked to use proper synchronization
in further patches).
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Kukjin Kim <kgene.kim@samsung.com>
Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers/clocksource')
-rw-r--r-- | drivers/clocksource/samsung_pwm_timer.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/clocksource/samsung_pwm_timer.c b/drivers/clocksource/samsung_pwm_timer.c index 1752457a4f76..d9048b843546 100644 --- a/drivers/clocksource/samsung_pwm_timer.c +++ b/drivers/clocksource/samsung_pwm_timer.c | |||
@@ -49,6 +49,9 @@ | |||
49 | #define TCON_INVERT(chan) (1 << (4 * (chan) + 2)) | 49 | #define TCON_INVERT(chan) (1 << (4 * (chan) + 2)) |
50 | #define TCON_AUTORELOAD(chan) (1 << (4 * (chan) + 3)) | 50 | #define TCON_AUTORELOAD(chan) (1 << (4 * (chan) + 3)) |
51 | 51 | ||
52 | DEFINE_SPINLOCK(samsung_pwm_lock); | ||
53 | EXPORT_SYMBOL(samsung_pwm_lock); | ||
54 | |||
52 | struct samsung_timer_source { | 55 | struct samsung_timer_source { |
53 | unsigned int event_id; | 56 | unsigned int event_id; |
54 | unsigned int source_id; | 57 | unsigned int source_id; |
@@ -72,14 +75,14 @@ static void samsung_timer_set_prescale(struct samsung_pwm *pwm, | |||
72 | if (channel >= 2) | 75 | if (channel >= 2) |
73 | shift = TCFG0_PRESCALER1_SHIFT; | 76 | shift = TCFG0_PRESCALER1_SHIFT; |
74 | 77 | ||
75 | spin_lock_irqsave(&pwm->slock, flags); | 78 | spin_lock_irqsave(&samsung_pwm_lock, flags); |
76 | 79 | ||
77 | reg = readl(pwm->base + REG_TCFG0); | 80 | reg = readl(pwm->base + REG_TCFG0); |
78 | reg &= ~(TCFG0_PRESCALER_MASK << shift); | 81 | reg &= ~(TCFG0_PRESCALER_MASK << shift); |
79 | reg |= (prescale - 1) << shift; | 82 | reg |= (prescale - 1) << shift; |
80 | writel(reg, pwm->base + REG_TCFG0); | 83 | writel(reg, pwm->base + REG_TCFG0); |
81 | 84 | ||
82 | spin_unlock_irqrestore(&pwm->slock, flags); | 85 | spin_unlock_irqrestore(&samsung_pwm_lock, flags); |
83 | } | 86 | } |
84 | 87 | ||
85 | static void samsung_timer_set_divisor(struct samsung_pwm *pwm, | 88 | static void samsung_timer_set_divisor(struct samsung_pwm *pwm, |
@@ -92,14 +95,14 @@ static void samsung_timer_set_divisor(struct samsung_pwm *pwm, | |||
92 | 95 | ||
93 | bits = (fls(divisor) - 1) - pwm->variant.div_base; | 96 | bits = (fls(divisor) - 1) - pwm->variant.div_base; |
94 | 97 | ||
95 | spin_lock_irqsave(&pwm->slock, flags); | 98 | spin_lock_irqsave(&samsung_pwm_lock, flags); |
96 | 99 | ||
97 | reg = readl(pwm->base + REG_TCFG1); | 100 | reg = readl(pwm->base + REG_TCFG1); |
98 | reg &= ~(TCFG1_MUX_MASK << shift); | 101 | reg &= ~(TCFG1_MUX_MASK << shift); |
99 | reg |= bits << shift; | 102 | reg |= bits << shift; |
100 | writel(reg, pwm->base + REG_TCFG1); | 103 | writel(reg, pwm->base + REG_TCFG1); |
101 | 104 | ||
102 | spin_unlock_irqrestore(&pwm->slock, flags); | 105 | spin_unlock_irqrestore(&samsung_pwm_lock, flags); |
103 | } | 106 | } |
104 | 107 | ||
105 | static void samsung_time_stop(unsigned int channel) | 108 | static void samsung_time_stop(unsigned int channel) |
@@ -110,13 +113,13 @@ static void samsung_time_stop(unsigned int channel) | |||
110 | if (channel > 0) | 113 | if (channel > 0) |
111 | ++channel; | 114 | ++channel; |
112 | 115 | ||
113 | spin_lock_irqsave(&pwm->slock, flags); | 116 | spin_lock_irqsave(&samsung_pwm_lock, flags); |
114 | 117 | ||
115 | tcon = __raw_readl(pwm->base + REG_TCON); | 118 | tcon = __raw_readl(pwm->base + REG_TCON); |
116 | tcon &= ~TCON_START(channel); | 119 | tcon &= ~TCON_START(channel); |
117 | __raw_writel(tcon, pwm->base + REG_TCON); | 120 | __raw_writel(tcon, pwm->base + REG_TCON); |
118 | 121 | ||
119 | spin_unlock_irqrestore(&pwm->slock, flags); | 122 | spin_unlock_irqrestore(&samsung_pwm_lock, flags); |
120 | } | 123 | } |
121 | 124 | ||
122 | static void samsung_time_setup(unsigned int channel, unsigned long tcnt) | 125 | static void samsung_time_setup(unsigned int channel, unsigned long tcnt) |
@@ -128,7 +131,7 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt) | |||
128 | if (tcon_chan > 0) | 131 | if (tcon_chan > 0) |
129 | ++tcon_chan; | 132 | ++tcon_chan; |
130 | 133 | ||
131 | spin_lock_irqsave(&pwm->slock, flags); | 134 | spin_lock_irqsave(&samsung_pwm_lock, flags); |
132 | 135 | ||
133 | tcon = __raw_readl(pwm->base + REG_TCON); | 136 | tcon = __raw_readl(pwm->base + REG_TCON); |
134 | 137 | ||
@@ -141,7 +144,7 @@ static void samsung_time_setup(unsigned int channel, unsigned long tcnt) | |||
141 | __raw_writel(tcnt, pwm->base + REG_TCMPB(channel)); | 144 | __raw_writel(tcnt, pwm->base + REG_TCMPB(channel)); |
142 | __raw_writel(tcon, pwm->base + REG_TCON); | 145 | __raw_writel(tcon, pwm->base + REG_TCON); |
143 | 146 | ||
144 | spin_unlock_irqrestore(&pwm->slock, flags); | 147 | spin_unlock_irqrestore(&samsung_pwm_lock, flags); |
145 | } | 148 | } |
146 | 149 | ||
147 | static void samsung_time_start(unsigned int channel, bool periodic) | 150 | static void samsung_time_start(unsigned int channel, bool periodic) |
@@ -152,7 +155,7 @@ static void samsung_time_start(unsigned int channel, bool periodic) | |||
152 | if (channel > 0) | 155 | if (channel > 0) |
153 | ++channel; | 156 | ++channel; |
154 | 157 | ||
155 | spin_lock_irqsave(&pwm->slock, flags); | 158 | spin_lock_irqsave(&samsung_pwm_lock, flags); |
156 | 159 | ||
157 | tcon = __raw_readl(pwm->base + REG_TCON); | 160 | tcon = __raw_readl(pwm->base + REG_TCON); |
158 | 161 | ||
@@ -166,7 +169,7 @@ static void samsung_time_start(unsigned int channel, bool periodic) | |||
166 | 169 | ||
167 | __raw_writel(tcon, pwm->base + REG_TCON); | 170 | __raw_writel(tcon, pwm->base + REG_TCON); |
168 | 171 | ||
169 | spin_unlock_irqrestore(&pwm->slock, flags); | 172 | spin_unlock_irqrestore(&samsung_pwm_lock, flags); |
170 | } | 173 | } |
171 | 174 | ||
172 | static int samsung_set_next_event(unsigned long cycles, | 175 | static int samsung_set_next_event(unsigned long cycles, |
@@ -394,7 +397,6 @@ static void __init samsung_pwm_alloc(struct device_node *np, | |||
394 | return; | 397 | return; |
395 | } | 398 | } |
396 | memcpy(&pwm->variant, variant, sizeof(pwm->variant)); | 399 | memcpy(&pwm->variant, variant, sizeof(pwm->variant)); |
397 | spin_lock_init(&pwm->slock); | ||
398 | for (i = 0; i < SAMSUNG_PWM_NUM; ++i) | 400 | for (i = 0; i < SAMSUNG_PWM_NUM; ++i) |
399 | pwm->irq[i] = irq_of_parse_and_map(np, i); | 401 | pwm->irq[i] = irq_of_parse_and_map(np, i); |
400 | 402 | ||