source: rtems/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c @ 226455f

4.104.114.84.95
Last change on this file since 226455f was 226455f, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/07 at 13:27:25

2007-09-06 Daniel Hellstrom <daniel@…>

New drivers: PCI, b1553BRM, SpaceWire?(GRSPW), CAN (GRCAN,OC_CAN),
Raw UART.

  • shared/1553/b1553brm.c, shared/1553/b1553brm_pci.c, shared/1553/b1553brm_rasta.c, shared/can/grcan.c, shared/can/grcan_rasta.c, shared/can/occan.c, shared/can/occan_pci.c, shared/spw/grspw.c, shared/spw/grspw_pci.c, shared/spw/grspw_rasta.c, shared/uart/apbuart.c, shared/uart/apbuart_pci.c, shared/uart/apbuart_rasta.c: New files missed in previous commit.
  • Property mode set to 100644
File size: 3.3 KB
Line 
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_16K
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 */
18unsigned int brmpci_memarea_address;
19#define B1553BRM_LOCAL_MEM_ADR brmpci_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/brmpci0"
31#define B1553BRM_DEVNAME_NO(devstr,no) ((devstr)[11]='0'+(no))
32
33/* Any non-static function will begin with */
34#define B1553BRM_PREFIX(name) b1553brmpci##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_pci_int_reg ) \
41   b1553brm_pci_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 */
52unsigned int brmpci_hw_address;
53static inline unsigned int memarea_to_hw(unsigned int addr) {
54                /* don't translate? */
55                if ( brmpci_hw_address == 0xffffffff )
56                        return addr;
57    return ((addr & 0x000fffff) | brmpci_hw_address);
58}
59#endif
60
61/* not used since BRM Core work with offsets */
62#ifdef B1553BRM_ADR_FROM
63unsigned int brmpci_cpu_access_address;
64static inline unsigned int hw_to_cpu(unsigned int addr) {
65                /* don't translate? */
66                if ( brmpci_cpu_address == 0xffffffff )
67                        return addr;
68    return ((addr & 0x0fffffff) | brmpci_cpu_address);
69}
70#endif
71
72void (*b1553brm_pci_int_reg)(void *handler, int irq, void *arg) = 0;
73
74static void b1553brmpci_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
84int b1553brm_pci_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 malloc will be used */
96        brmpci_memarea_address = memarea;
97
98        brmpci_hw_address = hw_address;
99
100#ifdef B1553BRM_ADR_FROM
101        brmpci_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 PCI interrupt handler
109 * irq = the irq number of the HW device local to that IRQMP controller
110 *
111 */
112static void b1553brmpci_interrupt_handler(int irq, void *arg){
113        brm_interrupt(arg);
114}
115
116#if 0
117int b1553brm_pci_interrupt_handler(int irqmask){
118        int i;
119        unsigned int mask=0;
120        /* find minor */
121        for(i=0; i<brm_cores; i++){
122                if ( (1<<brms[i].irqno) & irqmask ){
123                        mask |= 1<<brms[i].irqno;
124                        brm_interrupt(&brms[i]);
125                        /* more interrupts to scan for? */
126                        if ( irqmask & ~mask )
127                                return mask; /* handled */
128                }
129        }
130        return mask;
131}
132#endif
Note: See TracBrowser for help on using the repository browser.