1 | /* Select PCI driver */ |
---|
2 | #define B1553BRM_NO_AMBA |
---|
3 | #define B1553BRM_PCI |
---|
4 | |
---|
5 | #undef B1553BRM_MAXDEVS |
---|
6 | |
---|
7 | /* Use only 16K memory */ |
---|
8 | #define DMA_MEM_128K |
---|
9 | |
---|
10 | /* Malloced memory or |
---|
11 | * Card local memory |
---|
12 | */ |
---|
13 | #define B1553BRM_LOCAL_MEM |
---|
14 | |
---|
15 | #define DONT_DEF_RAMON |
---|
16 | |
---|
17 | /* memory must be aligned to a 128k boundary */ |
---|
18 | unsigned int brmrasta_memarea_address; |
---|
19 | #define B1553BRM_LOCAL_MEM_ADR brmrasta_memarea_address |
---|
20 | |
---|
21 | /* We have custom address tranlation for HW addresses */ |
---|
22 | #define B1553BRM_ADR_TO |
---|
23 | |
---|
24 | /* No custom MEMAREA=>CPU used since BRM Core work with offsets |
---|
25 | * in it's descriptors. |
---|
26 | */ |
---|
27 | #undef B1553BRM_ADR_FROM |
---|
28 | |
---|
29 | /* Set registered device name */ |
---|
30 | #define B1553BRM_DEVNAME "/dev/brmrasta0" |
---|
31 | #define B1553BRM_DEVNAME_NO(devstr,no) ((devstr)[13]='0'+(no)) |
---|
32 | |
---|
33 | /* Any non-static function will begin with */ |
---|
34 | #define B1553BRM_PREFIX(name) b1553brmrasta##name |
---|
35 | |
---|
36 | /* do nothing, assume that the interrupt handler is called |
---|
37 | * setup externally calling b1553_interrupt_handler. |
---|
38 | */ |
---|
39 | #define B1553BRM_REG_INT(handler,irq,arg) \ |
---|
40 | if ( b1553brm_rasta_int_reg ) \ |
---|
41 | b1553brm_rasta_int_reg(handler,irq,arg); |
---|
42 | |
---|
43 | |
---|
44 | #ifdef B1553BRM_ADR_TO |
---|
45 | /* Translate a address within the Memory Region (memarea) into an Hardware |
---|
46 | * device address. This address is put into hardware registers or descriptors |
---|
47 | * so that the hardware can access the Memory Region. |
---|
48 | * Example: |
---|
49 | * An local AMBA access at 0xe0000000 will translate into PCI address 0x40000000, |
---|
50 | * the PCI address 0x40000000 will translate into CPU-AMBA address 0x40000000. |
---|
51 | */ |
---|
52 | unsigned int brmrasta_hw_address; |
---|
53 | static inline unsigned int memarea_to_hw(unsigned int addr) { |
---|
54 | /* don't translate? */ |
---|
55 | if ( brmrasta_hw_address == 0xffffffff ) |
---|
56 | return addr; |
---|
57 | return ((addr & 0x0fffffff) | brmrasta_hw_address); |
---|
58 | } |
---|
59 | #endif |
---|
60 | |
---|
61 | /* not used since BRM Core work with offsets */ |
---|
62 | #ifdef B1553BRM_ADR_FROM |
---|
63 | unsigned int brmrasta_cpu_access_address; |
---|
64 | static inline unsigned int hw_to_cpu(unsigned int addr) { |
---|
65 | /* don't translate? */ |
---|
66 | if ( brmrasta_cpu_address == 0xffffffff ) |
---|
67 | return addr; |
---|
68 | return ((addr & 0x0fffffff) | brmrasta_cpu_address); |
---|
69 | } |
---|
70 | #endif |
---|
71 | |
---|
72 | void (*b1553brm_rasta_int_reg)(void *handler, int irq, void *arg) = 0; |
---|
73 | |
---|
74 | static void b1553brmrasta_interrupt_handler(int irq, void *arg); |
---|
75 | |
---|
76 | #include "b1553brm.c" |
---|
77 | |
---|
78 | /* |
---|
79 | * |
---|
80 | * memarea = preallocated memory somewhere, pointer to start of memory. |
---|
81 | * hw_address = how to translate a memarea address into an HW device AMBA address. |
---|
82 | */ |
---|
83 | |
---|
84 | int b1553brm_rasta_register( |
---|
85 | amba_confarea_type *bus, |
---|
86 | unsigned int clksel, |
---|
87 | unsigned int clkdiv, |
---|
88 | unsigned int brm_freq, |
---|
89 | unsigned int memarea, |
---|
90 | unsigned int hw_address |
---|
91 | ) |
---|
92 | { |
---|
93 | /* Setup configuration */ |
---|
94 | |
---|
95 | /* if zero the malloc will be used */ |
---|
96 | brmrasta_memarea_address = memarea; |
---|
97 | |
---|
98 | brmrasta_hw_address = hw_address; |
---|
99 | |
---|
100 | #ifdef B1553BRM_ADR_FROM |
---|
101 | brmrasta_cpu_address = memarea & 0xf0000000; |
---|
102 | #endif |
---|
103 | |
---|
104 | /* Register the driver */ |
---|
105 | return B1553BRM_PREFIX(_register)(bus,clksel,clkdiv,brm_freq); |
---|
106 | } |
---|
107 | |
---|
108 | /* Call this from RASTA interrupt handler |
---|
109 | * irq = the irq number of the HW device local to that IRQMP controller |
---|
110 | * |
---|
111 | */ |
---|
112 | static void b1553brmrasta_interrupt_handler(int irq, void *arg){ |
---|
113 | brm_interrupt(arg); |
---|
114 | } |
---|
115 | |
---|