1 | /* Select PCI driver */ |
---|
2 | #define GRSPW_PCI |
---|
3 | |
---|
4 | #undef GRSPW_MAXDEVS |
---|
5 | #undef DEBUG_SPACEWIRE_ONOFF |
---|
6 | |
---|
7 | /* Only Malloced memory supported |
---|
8 | */ |
---|
9 | #undef GRSPW_LOCAL_MEM |
---|
10 | |
---|
11 | /* memory must be aligned to a 128k boundary */ |
---|
12 | unsigned int grspwpci_memarea_address; |
---|
13 | #define GRSPW_LOCAL_MEM_ADR grspwpci_memarea_address |
---|
14 | |
---|
15 | /* We have custom address tranlation for HW addresses */ |
---|
16 | #define GRSPW_ADR_TO |
---|
17 | |
---|
18 | /* MEMAREA=>CPU used when reading descriptor buffer pointers, |
---|
19 | * they need to be translated from adresses used by GRSPW HW |
---|
20 | * into CPU readable addresses. |
---|
21 | * |
---|
22 | * NOT NEEDED AS GRSPW DRIVER USES INDEXES TO GET DESCRIPTOR |
---|
23 | * DATA POINTER ADDRESSES. |
---|
24 | */ |
---|
25 | #undef GRSPW_ADR_FROM |
---|
26 | |
---|
27 | /* Set registered device name */ |
---|
28 | #define GRSPW_DEVNAME "/dev/grspwpci0" |
---|
29 | #define GRSPW_DEVNAME_NO(devstr,no) ((devstr)[13]='0'+(no)) |
---|
30 | |
---|
31 | /* Any non-static function will begin with */ |
---|
32 | #define GRSPW_PREFIX(name) grspwpci##name |
---|
33 | |
---|
34 | /* do nothing, assume that the interrupt handler is called |
---|
35 | * setup externally calling b1553_interrupt_handler. |
---|
36 | */ |
---|
37 | #define GRSPW_REG_INT(handler,irq,arg) \ |
---|
38 | if ( grspw_pci_int_reg ) \ |
---|
39 | grspw_pci_int_reg(handler,irq,arg); |
---|
40 | |
---|
41 | void (*grspw_pci_int_reg)(void *handler, int irq, void *arg) = 0; |
---|
42 | |
---|
43 | |
---|
44 | #ifdef GRSPW_ADR_TO |
---|
45 | /* Translate an 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 | * A local AMBA access at 0xe0000000 will translate into PCI address 0x40000000, |
---|
50 | * the PCI address 0x40000000 will translate into LEON-AMBA address 0x40000000. |
---|
51 | */ |
---|
52 | unsigned int grspwpci_hw_address; |
---|
53 | static inline unsigned int memarea_to_hw(unsigned int addr) { |
---|
54 | /* don't translate? */ |
---|
55 | if ( grspwpci_hw_address == 0xffffffff ) |
---|
56 | return addr; |
---|
57 | return ((addr & 0x0fffffff) | grspwpci_hw_address); |
---|
58 | } |
---|
59 | #endif |
---|
60 | |
---|
61 | /* not used since BRM Core work with offsets */ |
---|
62 | #ifdef GRSPW_ADR_FROM |
---|
63 | unsigned int grspwpci_cpu_access_address; |
---|
64 | static inline unsigned int hw_to_cpu(unsigned int addr) { |
---|
65 | /* don't translate? */ |
---|
66 | if ( grspwpci_cpu_address == 0xffffffff ) |
---|
67 | return addr; |
---|
68 | return ((addr & 0x0fffffff) | grspwpci_cpu_address); |
---|
69 | } |
---|
70 | #endif |
---|
71 | |
---|
72 | int grspwpci_interrupt_handler(int irq, void *arg); |
---|
73 | #include "grspw.c" |
---|
74 | |
---|
75 | /* |
---|
76 | * |
---|
77 | * memarea = preallocated memory somewhere, pointer to start of memory. |
---|
78 | * hw_address = how to translate a memarea address into an HW device AMBA address. |
---|
79 | */ |
---|
80 | |
---|
81 | int grspw_pci_register( |
---|
82 | amba_confarea_type *bus, |
---|
83 | unsigned int memarea, |
---|
84 | unsigned int hw_address |
---|
85 | ) |
---|
86 | { |
---|
87 | /* Setup configuration */ |
---|
88 | |
---|
89 | /* if zero the malloc will be used */ |
---|
90 | grspwpci_memarea_address = memarea; |
---|
91 | |
---|
92 | grspwpci_hw_address = hw_address; |
---|
93 | |
---|
94 | #ifdef GRSPW_ADR_FROM |
---|
95 | grspwpci_cpu_address = memarea & 0xf0000000; |
---|
96 | #endif |
---|
97 | |
---|
98 | /* Register the driver */ |
---|
99 | return GRSPW_PREFIX(_register)(bus); |
---|
100 | } |
---|
101 | |
---|
102 | /* Call this from PCI interrupt handler |
---|
103 | * irq = the irq number of the HW device local to that IRQMP controller |
---|
104 | * |
---|
105 | */ |
---|
106 | int grspwpci_interrupt_handler(int irq, void *arg){ |
---|
107 | grspw_interrupt( (GRSPW_DEV *)arg ); |
---|
108 | return 0; |
---|
109 | } |
---|
110 | |
---|
111 | #if 0 |
---|
112 | int grspw_pci_interrupt_handler(int irqmask){ |
---|
113 | int i; |
---|
114 | unsigned int mask=0; |
---|
115 | /* find minor */ |
---|
116 | for(i=0; i<spw_cores; i++){ |
---|
117 | if ( (1<<SPW_PARAM(i).irq) & irqmask ){ |
---|
118 | mask |= 1<<SPW_PARAM(i).irq; |
---|
119 | grspw_interrupt(i); |
---|
120 | /* more interrupts to scan for? */ |
---|
121 | if ( irqmask & ~mask ) |
---|
122 | return mask; /* handled */ |
---|
123 | } |
---|
124 | } |
---|
125 | return mask; |
---|
126 | } |
---|
127 | #endif |
---|