aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2007-02-06 14:49:31 -0500
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-03-09 16:02:51 -0500
commit72e318e07e1fa9840bfdd5788421fc6dc51a93de (patch)
treec25da30071102d2f72fea916ed6796177dc4ff73
parent32b46093a076986fa3c6e1dd484791624edf4585 (diff)
firewire: Reduce some redundant register definitions.
Signed-off-by: Kristian Høgsberg <krh@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r--drivers/firewire/fw-ohci.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/firewire/fw-ohci.c b/drivers/firewire/fw-ohci.c
index ec47ae9a2dd1..02b2b69c8741 100644
--- a/drivers/firewire/fw-ohci.c
+++ b/drivers/firewire/fw-ohci.c
@@ -55,6 +55,11 @@ struct descriptor {
55 __le16 transfer_status; 55 __le16 transfer_status;
56} __attribute__((aligned(16))); 56} __attribute__((aligned(16)));
57 57
58#define control_set(regs) (regs)
59#define control_clear(regs) ((regs) + 4)
60#define command_ptr(regs) ((regs) + 12)
61#define context_match(regs) ((regs) + 16)
62
58struct ar_buffer { 63struct ar_buffer {
59 struct descriptor descriptor; 64 struct descriptor descriptor;
60 struct ar_buffer *next; 65 struct ar_buffer *next;
@@ -66,9 +71,7 @@ struct ar_context {
66 struct ar_buffer *current_buffer; 71 struct ar_buffer *current_buffer;
67 struct ar_buffer *last_buffer; 72 struct ar_buffer *last_buffer;
68 void *pointer; 73 void *pointer;
69 u32 command_ptr; 74 u32 regs;
70 u32 control_set;
71 u32 control_clear;
72 struct tasklet_struct tasklet; 75 struct tasklet_struct tasklet;
73}; 76};
74 77
@@ -85,9 +88,7 @@ struct at_context {
85 struct descriptor last; 88 struct descriptor last;
86 } d; 89 } d;
87 90
88 u32 command_ptr; 91 u32 regs;
89 u32 control_set;
90 u32 control_clear;
91 92
92 struct tasklet_struct tasklet; 93 struct tasklet_struct tasklet;
93}; 94};
@@ -102,10 +103,7 @@ struct at_context {
102struct iso_context { 103struct iso_context {
103 struct fw_iso_context base; 104 struct fw_iso_context base;
104 struct tasklet_struct tasklet; 105 struct tasklet_struct tasklet;
105 u32 control_set; 106 u32 regs;
106 u32 control_clear;
107 u32 command_ptr;
108 u32 context_match;
109 107
110 struct descriptor *buffer; 108 struct descriptor *buffer;
111 dma_addr_t buffer_bus; 109 dma_addr_t buffer_bus;
@@ -248,7 +246,7 @@ static int ar_context_add_page(struct ar_context *ctx)
248 ctx->last_buffer->next = ab; 246 ctx->last_buffer->next = ab;
249 ctx->last_buffer = ab; 247 ctx->last_buffer = ab;
250 248
251 reg_write(ctx->ohci, ctx->control_set, CONTEXT_WAKE); 249 reg_write(ctx->ohci, control_set(ctx->regs), CONTEXT_WAKE);
252 flush_writes(ctx->ohci); 250 flush_writes(ctx->ohci);
253 251
254 return 0; 252 return 0;
@@ -375,15 +373,13 @@ static void ar_context_tasklet(unsigned long data)
375} 373}
376 374
377static int 375static int
378ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 control_set) 376ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 regs)
379{ 377{
380 struct ar_buffer ab; 378 struct ar_buffer ab;
381 379
382 ctx->control_set = control_set; 380 ctx->regs = regs;
383 ctx->control_clear = control_set + 4; 381 ctx->ohci = ohci;
384 ctx->command_ptr = control_set + 12; 382 ctx->last_buffer = &ab;
385 ctx->ohci = ohci;
386 ctx->last_buffer = &ab;
387 tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx); 383 tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx);
388 384
389 ar_context_add_page(ctx); 385 ar_context_add_page(ctx);
@@ -391,8 +387,8 @@ ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 control_set)
391 ctx->current_buffer = ab.next; 387 ctx->current_buffer = ab.next;
392 ctx->pointer = ctx->current_buffer->data; 388 ctx->pointer = ctx->current_buffer->data;
393 389
394 reg_write(ctx->ohci, ctx->command_ptr, ab.descriptor.branch_address); 390 reg_write(ctx->ohci, command_ptr(ctx->regs), ab.descriptor.branch_address);
395 reg_write(ctx->ohci, ctx->control_set, CONTEXT_RUN); 391 reg_write(ctx->ohci, control_set(ctx->regs), CONTEXT_RUN);
396 flush_writes(ctx->ohci); 392 flush_writes(ctx->ohci);
397 393
398 return 0; 394 return 0;
@@ -489,9 +485,9 @@ at_context_setup_packet(struct at_context *ctx, struct list_head *list)
489 485
490 /* FIXME: Document how the locking works. */ 486 /* FIXME: Document how the locking works. */
491 if (ohci->generation == packet->generation) { 487 if (ohci->generation == packet->generation) {
492 reg_write(ctx->ohci, ctx->command_ptr, 488 reg_write(ctx->ohci, command_ptr(ctx->regs),
493 ctx->descriptor_bus | z); 489 ctx->descriptor_bus | z);
494 reg_write(ctx->ohci, ctx->control_set, 490 reg_write(ctx->ohci, control_set(ctx->regs),
495 CONTEXT_RUN | CONTEXT_WAKE); 491 CONTEXT_RUN | CONTEXT_WAKE);
496 } else { 492 } else {
497 /* We dont return error codes from this function; all 493 /* We dont return error codes from this function; all
@@ -505,9 +501,9 @@ static void at_context_stop(struct at_context *ctx)
505{ 501{
506 u32 reg; 502 u32 reg;
507 503
508 reg_write(ctx->ohci, ctx->control_clear, CONTEXT_RUN); 504 reg_write(ctx->ohci, control_clear(ctx->regs), CONTEXT_RUN);
509 505
510 reg = reg_read(ctx->ohci, ctx->control_set); 506 reg = reg_read(ctx->ohci, control_set(ctx->regs));
511 if (reg & CONTEXT_ACTIVE) 507 if (reg & CONTEXT_ACTIVE)
512 fw_notify("Tried to stop context, but it is still active " 508 fw_notify("Tried to stop context, but it is still active "
513 "(0x%08x).\n", reg); 509 "(0x%08x).\n", reg);
@@ -578,7 +574,7 @@ static void at_context_tasklet(unsigned long data)
578} 574}
579 575
580static int 576static int
581at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 control_set) 577at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 regs)
582{ 578{
583 INIT_LIST_HEAD(&ctx->list); 579 INIT_LIST_HEAD(&ctx->list);
584 580
@@ -588,10 +584,8 @@ at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 control_set)
588 if (ctx->descriptor_bus == 0) 584 if (ctx->descriptor_bus == 0)
589 return -ENOMEM; 585 return -ENOMEM;
590 586
591 ctx->control_set = control_set; 587 ctx->regs = regs;
592 ctx->control_clear = control_set + 4; 588 ctx->ohci = ohci;
593 ctx->command_ptr = control_set + 12;
594 ctx->ohci = ohci;
595 589
596 tasklet_init(&ctx->tasklet, at_context_tasklet, (unsigned long)ctx); 590 tasklet_init(&ctx->tasklet, at_context_tasklet, (unsigned long)ctx);
597 591