Commit 72e318e0 authored by Kristian Høgsberg's avatar Kristian Høgsberg Committed by Stefan Richter

firewire: Reduce some redundant register definitions.

Signed-off-by: default avatarKristian Høgsberg <krh@redhat.com>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 32b46093
...@@ -55,6 +55,11 @@ struct descriptor { ...@@ -55,6 +55,11 @@ struct descriptor {
__le16 transfer_status; __le16 transfer_status;
} __attribute__((aligned(16))); } __attribute__((aligned(16)));
#define control_set(regs) (regs)
#define control_clear(regs) ((regs) + 4)
#define command_ptr(regs) ((regs) + 12)
#define context_match(regs) ((regs) + 16)
struct ar_buffer { struct ar_buffer {
struct descriptor descriptor; struct descriptor descriptor;
struct ar_buffer *next; struct ar_buffer *next;
...@@ -66,9 +71,7 @@ struct ar_context { ...@@ -66,9 +71,7 @@ struct ar_context {
struct ar_buffer *current_buffer; struct ar_buffer *current_buffer;
struct ar_buffer *last_buffer; struct ar_buffer *last_buffer;
void *pointer; void *pointer;
u32 command_ptr; u32 regs;
u32 control_set;
u32 control_clear;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
}; };
...@@ -85,9 +88,7 @@ struct at_context { ...@@ -85,9 +88,7 @@ struct at_context {
struct descriptor last; struct descriptor last;
} d; } d;
u32 command_ptr; u32 regs;
u32 control_set;
u32 control_clear;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
}; };
...@@ -102,10 +103,7 @@ struct at_context { ...@@ -102,10 +103,7 @@ struct at_context {
struct iso_context { struct iso_context {
struct fw_iso_context base; struct fw_iso_context base;
struct tasklet_struct tasklet; struct tasklet_struct tasklet;
u32 control_set; u32 regs;
u32 control_clear;
u32 command_ptr;
u32 context_match;
struct descriptor *buffer; struct descriptor *buffer;
dma_addr_t buffer_bus; dma_addr_t buffer_bus;
...@@ -248,7 +246,7 @@ static int ar_context_add_page(struct ar_context *ctx) ...@@ -248,7 +246,7 @@ static int ar_context_add_page(struct ar_context *ctx)
ctx->last_buffer->next = ab; ctx->last_buffer->next = ab;
ctx->last_buffer = ab; ctx->last_buffer = ab;
reg_write(ctx->ohci, ctx->control_set, CONTEXT_WAKE); reg_write(ctx->ohci, control_set(ctx->regs), CONTEXT_WAKE);
flush_writes(ctx->ohci); flush_writes(ctx->ohci);
return 0; return 0;
...@@ -375,13 +373,11 @@ static void ar_context_tasklet(unsigned long data) ...@@ -375,13 +373,11 @@ static void ar_context_tasklet(unsigned long data)
} }
static int static int
ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 control_set) ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 regs)
{ {
struct ar_buffer ab; struct ar_buffer ab;
ctx->control_set = control_set; ctx->regs = regs;
ctx->control_clear = control_set + 4;
ctx->command_ptr = control_set + 12;
ctx->ohci = ohci; ctx->ohci = ohci;
ctx->last_buffer = &ab; ctx->last_buffer = &ab;
tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx); tasklet_init(&ctx->tasklet, ar_context_tasklet, (unsigned long)ctx);
...@@ -391,8 +387,8 @@ ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 control_set) ...@@ -391,8 +387,8 @@ ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci, u32 control_set)
ctx->current_buffer = ab.next; ctx->current_buffer = ab.next;
ctx->pointer = ctx->current_buffer->data; ctx->pointer = ctx->current_buffer->data;
reg_write(ctx->ohci, ctx->command_ptr, ab.descriptor.branch_address); reg_write(ctx->ohci, command_ptr(ctx->regs), ab.descriptor.branch_address);
reg_write(ctx->ohci, ctx->control_set, CONTEXT_RUN); reg_write(ctx->ohci, control_set(ctx->regs), CONTEXT_RUN);
flush_writes(ctx->ohci); flush_writes(ctx->ohci);
return 0; return 0;
...@@ -489,9 +485,9 @@ at_context_setup_packet(struct at_context *ctx, struct list_head *list) ...@@ -489,9 +485,9 @@ at_context_setup_packet(struct at_context *ctx, struct list_head *list)
/* FIXME: Document how the locking works. */ /* FIXME: Document how the locking works. */
if (ohci->generation == packet->generation) { if (ohci->generation == packet->generation) {
reg_write(ctx->ohci, ctx->command_ptr, reg_write(ctx->ohci, command_ptr(ctx->regs),
ctx->descriptor_bus | z); ctx->descriptor_bus | z);
reg_write(ctx->ohci, ctx->control_set, reg_write(ctx->ohci, control_set(ctx->regs),
CONTEXT_RUN | CONTEXT_WAKE); CONTEXT_RUN | CONTEXT_WAKE);
} else { } else {
/* We dont return error codes from this function; all /* We dont return error codes from this function; all
...@@ -505,9 +501,9 @@ static void at_context_stop(struct at_context *ctx) ...@@ -505,9 +501,9 @@ static void at_context_stop(struct at_context *ctx)
{ {
u32 reg; u32 reg;
reg_write(ctx->ohci, ctx->control_clear, CONTEXT_RUN); reg_write(ctx->ohci, control_clear(ctx->regs), CONTEXT_RUN);
reg = reg_read(ctx->ohci, ctx->control_set); reg = reg_read(ctx->ohci, control_set(ctx->regs));
if (reg & CONTEXT_ACTIVE) if (reg & CONTEXT_ACTIVE)
fw_notify("Tried to stop context, but it is still active " fw_notify("Tried to stop context, but it is still active "
"(0x%08x).\n", reg); "(0x%08x).\n", reg);
...@@ -578,7 +574,7 @@ static void at_context_tasklet(unsigned long data) ...@@ -578,7 +574,7 @@ static void at_context_tasklet(unsigned long data)
} }
static int static int
at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 control_set) at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 regs)
{ {
INIT_LIST_HEAD(&ctx->list); INIT_LIST_HEAD(&ctx->list);
...@@ -588,9 +584,7 @@ at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 control_set) ...@@ -588,9 +584,7 @@ at_context_init(struct at_context *ctx, struct fw_ohci *ohci, u32 control_set)
if (ctx->descriptor_bus == 0) if (ctx->descriptor_bus == 0)
return -ENOMEM; return -ENOMEM;
ctx->control_set = control_set; ctx->regs = regs;
ctx->control_clear = control_set + 4;
ctx->command_ptr = control_set + 12;
ctx->ohci = ohci; ctx->ohci = ohci;
tasklet_init(&ctx->tasklet, at_context_tasklet, (unsigned long)ctx); tasklet_init(&ctx->tasklet, at_context_tasklet, (unsigned long)ctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment