diff options
author | Daniel Mack <zonque@gmail.com> | 2013-08-12 04:37:18 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-14 14:54:30 -0400 |
commit | 6446221c14ef3bf58754cf1948631128dbe62700 (patch) | |
tree | 85b98c217d9528e1a1771f8599875c4814a3b1db | |
parent | 1c459de1e645b213a07b9492884a54f5861409f5 (diff) |
ARM: pxa: ssp: add pxa_ssp_request_of()
Add a function to lookup ssp devices from device tree. This way, users
can reference the ssp devices in order to register to them.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | arch/arm/plat-pxa/ssp.c | 25 | ||||
-rw-r--r-- | include/linux/pxa2xx_ssp.h | 11 |
2 files changed, 36 insertions, 0 deletions
diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c index f2661355fa4e..c83f27b6bdda 100644 --- a/arch/arm/plat-pxa/ssp.c +++ b/arch/arm/plat-pxa/ssp.c | |||
@@ -62,6 +62,30 @@ struct ssp_device *pxa_ssp_request(int port, const char *label) | |||
62 | } | 62 | } |
63 | EXPORT_SYMBOL(pxa_ssp_request); | 63 | EXPORT_SYMBOL(pxa_ssp_request); |
64 | 64 | ||
65 | struct ssp_device *pxa_ssp_request_of(const struct device_node *of_node, | ||
66 | const char *label) | ||
67 | { | ||
68 | struct ssp_device *ssp = NULL; | ||
69 | |||
70 | mutex_lock(&ssp_lock); | ||
71 | |||
72 | list_for_each_entry(ssp, &ssp_list, node) { | ||
73 | if (ssp->of_node == of_node && ssp->use_count == 0) { | ||
74 | ssp->use_count++; | ||
75 | ssp->label = label; | ||
76 | break; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | mutex_unlock(&ssp_lock); | ||
81 | |||
82 | if (&ssp->node == &ssp_list) | ||
83 | return NULL; | ||
84 | |||
85 | return ssp; | ||
86 | } | ||
87 | EXPORT_SYMBOL(pxa_ssp_request_of); | ||
88 | |||
65 | void pxa_ssp_free(struct ssp_device *ssp) | 89 | void pxa_ssp_free(struct ssp_device *ssp) |
66 | { | 90 | { |
67 | mutex_lock(&ssp_lock); | 91 | mutex_lock(&ssp_lock); |
@@ -185,6 +209,7 @@ static int pxa_ssp_probe(struct platform_device *pdev) | |||
185 | } | 209 | } |
186 | 210 | ||
187 | ssp->use_count = 0; | 211 | ssp->use_count = 0; |
212 | ssp->of_node = dev->of_node; | ||
188 | 213 | ||
189 | mutex_lock(&ssp_lock); | 214 | mutex_lock(&ssp_lock); |
190 | list_add(&ssp->node, &ssp_list); | 215 | list_add(&ssp->node, &ssp_list); |
diff --git a/include/linux/pxa2xx_ssp.h b/include/linux/pxa2xx_ssp.h index 467cc6307b62..49444203328a 100644 --- a/include/linux/pxa2xx_ssp.h +++ b/include/linux/pxa2xx_ssp.h | |||
@@ -21,6 +21,8 @@ | |||
21 | 21 | ||
22 | #include <linux/list.h> | 22 | #include <linux/list.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/of.h> | ||
25 | |||
24 | 26 | ||
25 | /* | 27 | /* |
26 | * SSP Serial Port Registers | 28 | * SSP Serial Port Registers |
@@ -190,6 +192,8 @@ struct ssp_device { | |||
190 | int irq; | 192 | int irq; |
191 | int drcmr_rx; | 193 | int drcmr_rx; |
192 | int drcmr_tx; | 194 | int drcmr_tx; |
195 | |||
196 | struct device_node *of_node; | ||
193 | }; | 197 | }; |
194 | 198 | ||
195 | /** | 199 | /** |
@@ -218,11 +222,18 @@ static inline u32 pxa_ssp_read_reg(struct ssp_device *dev, u32 reg) | |||
218 | #ifdef CONFIG_ARCH_PXA | 222 | #ifdef CONFIG_ARCH_PXA |
219 | struct ssp_device *pxa_ssp_request(int port, const char *label); | 223 | struct ssp_device *pxa_ssp_request(int port, const char *label); |
220 | void pxa_ssp_free(struct ssp_device *); | 224 | void pxa_ssp_free(struct ssp_device *); |
225 | struct ssp_device *pxa_ssp_request_of(const struct device_node *of_node, | ||
226 | const char *label); | ||
221 | #else | 227 | #else |
222 | static inline struct ssp_device *pxa_ssp_request(int port, const char *label) | 228 | static inline struct ssp_device *pxa_ssp_request(int port, const char *label) |
223 | { | 229 | { |
224 | return NULL; | 230 | return NULL; |
225 | } | 231 | } |
232 | static inline struct ssp_device *pxa_ssp_request_of(const struct device_node *n, | ||
233 | const char *name) | ||
234 | { | ||
235 | return NULL; | ||
236 | } | ||
226 | static inline void pxa_ssp_free(struct ssp_device *ssp) {} | 237 | static inline void pxa_ssp_free(struct ssp_device *ssp) {} |
227 | #endif | 238 | #endif |
228 | 239 | ||