aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb/embedded.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-02-19 10:22:50 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-20 20:11:49 -0500
commit53521d8c90d366191b6c134f88a8ebe83de60614 (patch)
tree2d4b8bed0db743927586389ab035aab816d22f36 /drivers/ssb/embedded.c
parentc2bcbe65fc88d61f9a806367ff6eab76c9eabb3a (diff)
ssb: Make the GPIO API reentrancy safe
This fixes the GPIO API to be reentrancy safe. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/ssb/embedded.c')
-rw-r--r--drivers/ssb/embedded.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/drivers/ssb/embedded.c b/drivers/ssb/embedded.c
index 751f58ac612c..d3ade821555c 100644
--- a/drivers/ssb/embedded.c
+++ b/drivers/ssb/embedded.c
@@ -11,6 +11,8 @@
11#include <linux/ssb/ssb.h> 11#include <linux/ssb/ssb.h>
12#include <linux/ssb/ssb_embedded.h> 12#include <linux/ssb/ssb_embedded.h>
13 13
14#include "ssb_private.h"
15
14 16
15int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks) 17int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks)
16{ 18{
@@ -24,3 +26,107 @@ int ssb_watchdog_timer_set(struct ssb_bus *bus, u32 ticks)
24 } 26 }
25 return -ENODEV; 27 return -ENODEV;
26} 28}
29
30u32 ssb_gpio_in(struct ssb_bus *bus, u32 mask)
31{
32 unsigned long flags;
33 u32 res = 0;
34
35 spin_lock_irqsave(&bus->gpio_lock, flags);
36 if (ssb_chipco_available(&bus->chipco))
37 res = ssb_chipco_gpio_in(&bus->chipco, mask);
38 else if (ssb_extif_available(&bus->extif))
39 res = ssb_extif_gpio_in(&bus->extif, mask);
40 else
41 SSB_WARN_ON(1);
42 spin_unlock_irqrestore(&bus->gpio_lock, flags);
43
44 return res;
45}
46EXPORT_SYMBOL(ssb_gpio_in);
47
48u32 ssb_gpio_out(struct ssb_bus *bus, u32 mask, u32 value)
49{
50 unsigned long flags;
51 u32 res = 0;
52
53 spin_lock_irqsave(&bus->gpio_lock, flags);
54 if (ssb_chipco_available(&bus->chipco))
55 res = ssb_chipco_gpio_out(&bus->chipco, mask, value);
56 else if (ssb_extif_available(&bus->extif))
57 res = ssb_extif_gpio_out(&bus->extif, mask, value);
58 else
59 SSB_WARN_ON(1);
60 spin_unlock_irqrestore(&bus->gpio_lock, flags);
61
62 return res;
63}
64EXPORT_SYMBOL(ssb_gpio_out);
65
66u32 ssb_gpio_outen(struct ssb_bus *bus, u32 mask, u32 value)
67{
68 unsigned long flags;
69 u32 res = 0;
70
71 spin_lock_irqsave(&bus->gpio_lock, flags);
72 if (ssb_chipco_available(&bus->chipco))
73 res = ssb_chipco_gpio_outen(&bus->chipco, mask, value);
74 else if (ssb_extif_available(&bus->extif))
75 res = ssb_extif_gpio_outen(&bus->extif, mask, value);
76 else
77 SSB_WARN_ON(1);
78 spin_unlock_irqrestore(&bus->gpio_lock, flags);
79
80 return res;
81}
82EXPORT_SYMBOL(ssb_gpio_outen);
83
84u32 ssb_gpio_control(struct ssb_bus *bus, u32 mask, u32 value)
85{
86 unsigned long flags;
87 u32 res = 0;
88
89 spin_lock_irqsave(&bus->gpio_lock, flags);
90 if (ssb_chipco_available(&bus->chipco))
91 res = ssb_chipco_gpio_control(&bus->chipco, mask, value);
92 spin_unlock_irqrestore(&bus->gpio_lock, flags);
93
94 return res;
95}
96EXPORT_SYMBOL(ssb_gpio_control);
97
98u32 ssb_gpio_intmask(struct ssb_bus *bus, u32 mask, u32 value)
99{
100 unsigned long flags;
101 u32 res = 0;
102
103 spin_lock_irqsave(&bus->gpio_lock, flags);
104 if (ssb_chipco_available(&bus->chipco))
105 res = ssb_chipco_gpio_intmask(&bus->chipco, mask, value);
106 else if (ssb_extif_available(&bus->extif))
107 res = ssb_extif_gpio_intmask(&bus->extif, mask, value);
108 else
109 SSB_WARN_ON(1);
110 spin_unlock_irqrestore(&bus->gpio_lock, flags);
111
112 return res;
113}
114EXPORT_SYMBOL(ssb_gpio_intmask);
115
116u32 ssb_gpio_polarity(struct ssb_bus *bus, u32 mask, u32 value)
117{
118 unsigned long flags;
119 u32 res = 0;
120
121 spin_lock_irqsave(&bus->gpio_lock, flags);
122 if (ssb_chipco_available(&bus->chipco))
123 res = ssb_chipco_gpio_polarity(&bus->chipco, mask, value);
124 else if (ssb_extif_available(&bus->extif))
125 res = ssb_extif_gpio_polarity(&bus->extif, mask, value);
126 else
127 SSB_WARN_ON(1);
128 spin_unlock_irqrestore(&bus->gpio_lock, flags);
129
130 return res;
131}
132EXPORT_SYMBOL(ssb_gpio_polarity);