aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
diff options
context:
space:
mode:
authorKrzysztof Hałasa <khc@pm.waw.pl>2008-12-21 18:26:38 -0500
committerKrzysztof Hałasa <khc@pm.waw.pl>2008-12-21 18:48:00 -0500
commite6da96ace859dad966fe85cc9552b89f48bbc930 (patch)
treec022b49ee22b355eec92d627fd45160f89406cf0 /arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
parent9251ce959cab704eb0e4910860b06b18e7083474 (diff)
IXP4xx: move common debugging from network drivers to QMGR module.
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Diffstat (limited to 'arch/arm/mach-ixp4xx/ixp4xx_qmgr.c')
-rw-r--r--arch/arm/mach-ixp4xx/ixp4xx_qmgr.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
index 444c2ae21db..bfddc73d0a2 100644
--- a/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
+++ b/arch/arm/mach-ixp4xx/ixp4xx_qmgr.c
@@ -14,8 +14,6 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <mach/qmgr.h> 15#include <mach/qmgr.h>
16 16
17#define DEBUG 0
18
19struct qmgr_regs __iomem *qmgr_regs; 17struct qmgr_regs __iomem *qmgr_regs;
20static struct resource *mem_res; 18static struct resource *mem_res;
21static spinlock_t qmgr_lock; 19static spinlock_t qmgr_lock;
@@ -23,6 +21,10 @@ static u32 used_sram_bitmap[4]; /* 128 16-dword pages */
23static void (*irq_handlers[HALF_QUEUES])(void *pdev); 21static void (*irq_handlers[HALF_QUEUES])(void *pdev);
24static void *irq_pdevs[HALF_QUEUES]; 22static void *irq_pdevs[HALF_QUEUES];
25 23
24#if DEBUG_QMGR
25char qmgr_queue_descs[QUEUES][32];
26#endif
27
26void qmgr_set_irq(unsigned int queue, int src, 28void qmgr_set_irq(unsigned int queue, int src,
27 void (*handler)(void *pdev), void *pdev) 29 void (*handler)(void *pdev), void *pdev)
28{ 30{
@@ -82,9 +84,16 @@ static inline void shift_mask(u32 *mask)
82 mask[0] <<= 1; 84 mask[0] <<= 1;
83} 85}
84 86
87#if DEBUG_QMGR
85int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */, 88int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
86 unsigned int nearly_empty_watermark, 89 unsigned int nearly_empty_watermark,
87 unsigned int nearly_full_watermark) 90 unsigned int nearly_full_watermark,
91 const char *desc_format, const char* name)
92#else
93int __qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
94 unsigned int nearly_empty_watermark,
95 unsigned int nearly_full_watermark)
96#endif
88{ 97{
89 u32 cfg, addr = 0, mask[4]; /* in 16-dwords */ 98 u32 cfg, addr = 0, mask[4]; /* in 16-dwords */
90 int err; 99 int err;
@@ -152,12 +161,13 @@ int qmgr_request_queue(unsigned int queue, unsigned int len /* dwords */,
152 used_sram_bitmap[2] |= mask[2]; 161 used_sram_bitmap[2] |= mask[2];
153 used_sram_bitmap[3] |= mask[3]; 162 used_sram_bitmap[3] |= mask[3];
154 __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]); 163 __raw_writel(cfg | (addr << 14), &qmgr_regs->sram[queue]);
155 spin_unlock_irq(&qmgr_lock); 164#if DEBUG_QMGR
156 165 snprintf(qmgr_queue_descs[queue], sizeof(qmgr_queue_descs[0]),
157#if DEBUG 166 desc_format, name);
158 printk(KERN_DEBUG "qmgr: requested queue %i, addr = 0x%02X\n", 167 printk(KERN_DEBUG "qmgr: requested queue %s(%i) addr = 0x%02X\n",
159 queue, addr); 168 qmgr_queue_descs[queue], queue, addr);
160#endif 169#endif
170 spin_unlock_irq(&qmgr_lock);
161 return 0; 171 return 0;
162 172
163err: 173err:
@@ -190,6 +200,11 @@ void qmgr_release_queue(unsigned int queue)
190 while (addr--) 200 while (addr--)
191 shift_mask(mask); 201 shift_mask(mask);
192 202
203#if DEBUG_QMGR
204 printk(KERN_DEBUG "qmgr: releasing queue %s(%i)\n",
205 qmgr_queue_descs[queue], queue);
206 qmgr_queue_descs[queue][0] = '\x0';
207#endif
193 __raw_writel(0, &qmgr_regs->sram[queue]); 208 __raw_writel(0, &qmgr_regs->sram[queue]);
194 209
195 used_sram_bitmap[0] &= ~mask[0]; 210 used_sram_bitmap[0] &= ~mask[0];
@@ -202,11 +217,8 @@ void qmgr_release_queue(unsigned int queue)
202 module_put(THIS_MODULE); 217 module_put(THIS_MODULE);
203 218
204 while ((addr = qmgr_get_entry(queue))) 219 while ((addr = qmgr_get_entry(queue)))
205 printk(KERN_ERR "qmgr: released queue %d not empty: 0x%08X\n", 220 printk(KERN_ERR "qmgr: released queue %i not empty: 0x%08X\n",
206 queue, addr); 221 queue, addr);
207#if DEBUG
208 printk(KERN_DEBUG "qmgr: released queue %i\n", queue);
209#endif
210} 222}
211 223
212static int qmgr_init(void) 224static int qmgr_init(void)
@@ -277,5 +289,10 @@ EXPORT_SYMBOL(qmgr_regs);
277EXPORT_SYMBOL(qmgr_set_irq); 289EXPORT_SYMBOL(qmgr_set_irq);
278EXPORT_SYMBOL(qmgr_enable_irq); 290EXPORT_SYMBOL(qmgr_enable_irq);
279EXPORT_SYMBOL(qmgr_disable_irq); 291EXPORT_SYMBOL(qmgr_disable_irq);
292#if DEBUG_QMGR
293EXPORT_SYMBOL(qmgr_queue_descs);
280EXPORT_SYMBOL(qmgr_request_queue); 294EXPORT_SYMBOL(qmgr_request_queue);
295#else
296EXPORT_SYMBOL(__qmgr_request_queue);
297#endif
281EXPORT_SYMBOL(qmgr_release_queue); 298EXPORT_SYMBOL(qmgr_release_queue);