source: rtems/c/src/lib/libbsp/sparc/shared/pci/gr_rasta_spw_router.c @ e67b2b8d

4.115
Last change on this file since e67b2b8d was e67b2b8d, checked in by Daniel Hellstrom <daniel@…>, on 12/20/11 at 14:58:05

LEON: updated and added PCI peripherals for LEON BSPs

The CCHIP driver is replaced with the GR_701 driver. The
RASTA driver is replaced by the GR-RASTA-IO driver.

All drivers are now compatible with both LEON2 and LEON3,
drivers were initialized directly by the PCI-board drivers
are now initialized by the driver manager and therefore
does not require the double code created by including for
example grcan.c into grcan_rasta.c. The other drivers needs
to be updated to the driver manager framework however.

Added support for:

  • GR-701 (only LEON2 before)
  • GR-RASTA-IO (only LEON2 before)
  • GR-RASTA-ADCDAC
  • GR-RASTA-TMTC
  • GR-RASTA-SPW-ROUTER
  • GR-TMTC-1553
  • Property mode set to 100644
File size: 18.2 KB
Line 
1/*  GR-RASTA-SPW-ROUTER PCI Target driver.
2 *
3 *  COPYRIGHT (c) 2011.
4 *  Cobham Gaisler AB.
5 *
6 *  The license and distribution terms for this file may be
7 *  found in found in the file LICENSE in this distribution or at
8 *  http://www.rtems.com/license/LICENSE.
9 *
10 *  Configures the GR-RASTA-SPW-ROUTER interface PCI board.
11 *  This driver provides a AMBA PnP bus by using the general part
12 *  of the AMBA PnP bus driver (ambapp_bus.c). Based on the
13 *  GR-RASTA-IO driver.
14 */
15
16#include <stdio.h>
17#include <stdlib.h>
18#include <string.h>
19#include <sys/types.h>
20#include <sys/stat.h>
21
22#include <bsp.h>
23#include <rtems/bspIo.h>
24#include <pci.h>
25
26#include <ambapp.h>
27#include <grlib.h>
28#include <drvmgr/drvmgr.h>
29#include <drvmgr/ambapp_bus.h>
30#include <drvmgr/pci_bus.h>
31#include <genirq.h>
32
33/*#include <gr_rasta_spw_router.h> */
34
35/* Determines which PCI address the AHB masters will access, it should be
36 * set so that the masters can access the CPU RAM. Default is base of CPU RAM,
37 * CPU RAM is mapped 1:1 to PCI space.
38 */
39extern unsigned int _RAM_START;
40#define AHBMST2PCIADR (((unsigned int)&_RAM_START) & 0xf0000000)
41
42/* Offset from 0x80000000 (dual bus version) */
43#define AHB1_BASE_ADDR 0x80000000
44#define AHB1_IOAREA_BASE_ADDR 0x80100000
45
46#define GRPCI2_BAR0_TO_AHB_MAP 0x04  /* Fixme */
47#define GRPCI2_PCI_CONFIG      0x20  /* Fixme */
48#define RASTA_SPW_ROUTER_OPTIONS_AMBA  0x01 /* Print AMBA bus devices */  /* Fixme */
49#define RASTA_SPW_ROUTER_OPTIONS_IRQ   0x02 /* Print current IRQ setup */ /* Fixme */
50
51
52/* #define DEBUG 1 */
53
54#ifdef DEBUG
55#define DBG(x...) printk(x)
56#else
57#define DBG(x...)
58#endif
59
60/* PCI ID */
61#define PCIID_VENDOR_GAISLER            0x1AC8
62
63int gr_rasta_spw_router_init1(struct drvmgr_dev *dev);
64int gr_rasta_spw_router_init2(struct drvmgr_dev *dev);
65
66struct grpci2_regs {
67        volatile unsigned int ctrl;
68        volatile unsigned int statcap;
69        volatile unsigned int pcimstprefetch;
70        volatile unsigned int ahbtopciiomap;
71        volatile unsigned int dmactrl;
72        volatile unsigned int dmadesc;
73        volatile unsigned int dmachanact;
74        volatile unsigned int reserved;
75        volatile unsigned int pcibartoahb[6];
76        volatile unsigned int reserved2[2];
77        volatile unsigned int ahbtopcimemmap[16];
78        volatile unsigned int trcctrl;
79        volatile unsigned int trccntmode;
80        volatile unsigned int trcadpat;
81        volatile unsigned int trcadmask;
82        volatile unsigned int trcctrlsigpat;
83        volatile unsigned int trcctrlsigmask;
84        volatile unsigned int trcadstate;
85        volatile unsigned int trcctrlsigstate;
86};
87
88struct gr_rasta_spw_router_ver {
89        const unsigned int      amba_freq_hz;   /* The frequency */
90        const unsigned int      amba_ioarea;    /* The address where the PnP IOAREA starts at */
91};
92
93/* Private data structure for driver */
94struct gr_rasta_spw_router_priv {
95        /* Driver management */
96        struct drvmgr_dev       *dev;
97        char                    prefix[20];
98
99        /* PCI */
100        pci_dev_t               pcidev;
101        struct pci_dev_info     *devinfo;
102        uint32_t                ahbmst2pci_map;
103
104        /* IRQ */
105        genirq_t                genirq;
106
107        /* GR-RASTA-SPW-ROUTER */
108        struct gr_rasta_spw_router_ver  *version;
109        struct irqmp_regs       *irq;
110        struct grpci2_regs      *grpci2;
111        struct drvmgr_map_entry bus_maps_up[2];
112        struct drvmgr_map_entry bus_maps_down[2];
113
114        /* AMBA Plug&Play information on GR-RASTA-SPW-ROUTER */
115        struct ambapp_bus       abus;
116        struct ambapp_mmap      amba_maps[3];
117        struct ambapp_config    config;
118};
119
120struct gr_rasta_spw_router_ver gr_rasta_spw_router_ver0 = {
121        .amba_freq_hz           = 50000000,
122        .amba_ioarea            = 0xfff00000,
123};
124
125int ambapp_rasta_spw_router_int_register(
126        struct drvmgr_dev *dev,
127        int irq,
128        const char *info,
129        drvmgr_isr handler,
130        void *arg);
131int ambapp_rasta_spw_router_int_unregister(
132        struct drvmgr_dev *dev,
133        int irq,
134        drvmgr_isr handler,
135        void *arg);
136int ambapp_rasta_spw_router_int_unmask(
137        struct drvmgr_dev *dev,
138        int irq);
139int ambapp_rasta_spw_router_int_mask(
140        struct drvmgr_dev *dev,
141        int irq);
142int ambapp_rasta_spw_router_int_clear(
143        struct drvmgr_dev *dev,
144        int irq);
145int ambapp_rasta_spw_router_get_params(
146        struct drvmgr_dev *dev,
147        struct drvmgr_bus_params *params);
148
149struct ambapp_ops ambapp_rasta_spw_router_ops = {
150        .int_register = ambapp_rasta_spw_router_int_register,
151        .int_unregister = ambapp_rasta_spw_router_int_unregister,
152        .int_unmask = ambapp_rasta_spw_router_int_unmask,
153        .int_mask = ambapp_rasta_spw_router_int_mask,
154        .int_clear = ambapp_rasta_spw_router_int_clear,
155        .get_params = ambapp_rasta_spw_router_get_params
156};
157
158struct drvmgr_drv_ops gr_rasta_spw_router_ops =
159{
160        .init = {gr_rasta_spw_router_init1, gr_rasta_spw_router_init2, NULL, NULL},
161        .remove = NULL,
162        .info = NULL
163};
164
165struct pci_dev_id_match gr_rasta_spw_router_ids[] =
166{
167        PCIID_DEVVEND(PCIID_VENDOR_GAISLER, PCIID_DEVICE_GR_RASTA_SPW_RTR),
168        PCIID_END_TABLE /* Mark end of table */
169};
170
171struct pci_drv_info gr_rasta_spw_router_info =
172{
173        {
174                DRVMGR_OBJ_DRV,                 /* Driver */
175                NULL,                           /* Next driver */
176                NULL,                           /* Device list */
177                DRIVER_PCI_GAISLER_RASTA_SPW_ROUTER_ID, /* Driver ID */
178                "GR-RASTA-SPW_ROUTER_DRV",      /* Driver Name */
179                DRVMGR_BUS_TYPE_PCI,            /* Bus Type */
180                &gr_rasta_spw_router_ops,
181                NULL,                           /* Funcs */
182                0,                              /* No devices yet */
183                sizeof(struct gr_rasta_spw_router_priv),
184        },
185        &gr_rasta_spw_router_ids[0]
186};
187
188/* Driver resources configuration for the AMBA bus on the GR-RASTA-SPW-ROUTER board.
189 * It is declared weak so that the user may override it from the project file,
190 * if the default settings are not enough.
191 *
192 * The configuration consists of an array of configuration pointers, each
193 * pointer determine the configuration of one GR-RASTA-SPW-ROUTER board. Pointer
194 * zero is for board0, pointer 1 for board1 and so on.
195 *
196 * The array must end with a NULL pointer.
197 */
198struct drvmgr_bus_res *gr_rasta_spw_router_resources[] __attribute__((weak)) =
199{
200        NULL
201};
202int gr_rasta_spw_router_resources_cnt = 0;
203
204void gr_rasta_spw_router_register_drv(void)
205{
206        DBG("Registering GR-RASTA-SPW-ROUTER PCI driver\n");
207        drvmgr_drv_register(&gr_rasta_spw_router_info.general);
208}
209
210void gr_rasta_spw_router_isr(void *arg)
211{
212        struct gr_rasta_spw_router_priv *priv = arg;
213        unsigned int status, tmp;
214        int irq;
215        tmp = status = priv->irq->ipend;
216
217        /* DBG("GR-RASTA-SPW-ROUTER: IRQ 0x%x\n",status); */
218
219        for(irq=0; irq<16; irq++) {
220                if ( status & (1<<irq) ) {
221                        genirq_doirq(priv->genirq, irq);
222                        priv->irq->iclear = (1<<irq);
223                        status &= ~(1<<irq);
224                        if ( status == 0 )
225                                break;
226                }
227        }
228
229        /* ACK interrupt, this is because PCI is Level, so the IRQ Controller
230         * still drives the IRQ
231         */
232        if ( tmp )
233                drvmgr_interrupt_clear(priv->dev, 0);
234
235        DBG("RASTA-SPW_ROUTER-IRQ: 0x%x\n", tmp);
236}
237
238int gr_rasta_spw_router_hw_init(struct gr_rasta_spw_router_priv *priv)
239{
240        int i;
241        uint32_t data;
242        unsigned int ctrl;
243        uint8_t tmp2;
244        struct ambapp_dev *tmp;
245        int status;
246        struct ambapp_ahb_info *ahb;
247        uint8_t cap_ptr;
248        pci_dev_t pcidev = priv->pcidev;
249        struct pci_dev_info *devinfo = priv->devinfo;
250
251        /* Select version of GR-RASTA-SPW-ROUTER board. Currently only one
252         * version
253         */
254        switch (devinfo->rev) {
255                case 0:
256                        priv->version = &gr_rasta_spw_router_ver0;
257                        break;
258                default:
259                        return -2;
260        }
261
262        /* Check capabilities list bit */
263        pci_cfg_r8(pcidev, PCI_STATUS, &tmp2);
264
265        if (!((tmp2 >> 4) & 1)) {
266                /* Capabilities list not available which it should be in the GRPCI2 */
267                return -3;
268        }
269
270        /* Read capabilities pointer */
271        pci_cfg_r8(pcidev, PCI_CAP_PTR, &cap_ptr);
272
273        /* Set AHB address mappings for target PCI bars */
274        pci_cfg_w32(pcidev, cap_ptr+GRPCI2_BAR0_TO_AHB_MAP, 0xffe00000);  /* APB bus, AHB I/O bus 2 MB */
275
276        /* Set PCI bus to be big endian */
277        pci_cfg_r32(pcidev, cap_ptr+GRPCI2_PCI_CONFIG, &data);
278        data = data & 0xFFFFFFFE;
279        pci_cfg_w32(pcidev, cap_ptr+GRPCI2_PCI_CONFIG, data);
280
281#if 0
282        /* set parity error response */
283        pci_cfg_r32(pcidev, PCI_COMMAND, &data);
284        pci_cfg_w32(pcidev, PCI_COMMAND, (data|PCI_COMMAND_PARITY));
285#endif
286
287        /* Scan AMBA Plug&Play */
288
289        /* AMBA MAP bar0 (in router) ==> 0xffe00000(remote amba address) */
290        priv->amba_maps[0].size = devinfo->resources[0].size;
291        priv->amba_maps[0].local_adr = devinfo->resources[0].address;
292        priv->amba_maps[0].remote_adr = 0xffe00000;
293
294        /* Addresses not matching with map be untouched */
295        priv->amba_maps[1].size = 0xfffffff0;
296        priv->amba_maps[1].local_adr = 0;
297        priv->amba_maps[1].remote_adr = 0;
298
299        /* Mark end of table */
300        priv->amba_maps[2].size=0;
301
302        /* Start AMBA PnP scan at first AHB bus */
303        ambapp_scan(
304                &priv->abus,
305                devinfo->resources[0].address + 0x100000,
306                NULL,
307                &priv->amba_maps[0]);
308
309        /* Initialize Frequency of AMBA bus */
310        ambapp_freq_init(&priv->abus, NULL, priv->version->amba_freq_hz);
311
312        /* Find IRQ controller, Clear all current IRQs */
313        tmp = ambapp_for_each(&priv->abus,
314                                (OPTIONS_ALL|OPTIONS_APB_SLVS),
315                                VENDOR_GAISLER, GAISLER_IRQMP,
316                                ambapp_find_by_idx, NULL);
317        if ( !tmp ) {
318                return -4;
319        }
320        priv->irq = (struct irqmp_regs *)DEV_TO_APB(tmp)->start;
321        /* Set up GR-RASTA-SPW-ROUTER irq controller */
322        priv->irq->mask[0] = 0;
323        priv->irq->iclear = 0xffff;
324        priv->irq->ilevel = 0;
325
326        priv->bus_maps_down[0].name = "PCI BAR0 -> AMBA";
327        priv->bus_maps_down[0].size = priv->amba_maps[0].size;
328        priv->bus_maps_down[0].from_adr = (void *)priv->amba_maps[0].local_adr;
329        priv->bus_maps_down[0].to_adr = (void *)priv->amba_maps[0].remote_adr;
330        priv->bus_maps_down[1].size = 0;
331
332        /* Find GRPCI2 controller AHB Slave interface */
333        tmp = (void *)ambapp_for_each(&priv->abus,
334                                        (OPTIONS_ALL|OPTIONS_AHB_SLVS),
335                                        VENDOR_GAISLER, GAISLER_GRPCI2,
336                                        ambapp_find_by_idx, NULL);
337        if ( !tmp ) {
338                return -5;
339        }
340        ahb = (struct ambapp_ahb_info *)tmp->devinfo;
341        priv->bus_maps_up[0].name = "AMBA GRPCI2 Window";
342        priv->bus_maps_up[0].size = ahb->mask[0]; /* AMBA->PCI Window on GR-RASTA-SPW-ROUTER board */
343        priv->bus_maps_up[0].from_adr = (void *)ahb->start[0];
344        priv->bus_maps_up[0].to_adr = (void *)
345                                (priv->ahbmst2pci_map & ~(ahb->mask[0]-1));
346        priv->bus_maps_up[1].size = 0;
347
348        /* Find GRPCI2 controller APB Slave interface */
349        tmp = (void *)ambapp_for_each(&priv->abus,
350                                        (OPTIONS_ALL|OPTIONS_APB_SLVS),
351                                        VENDOR_GAISLER, GAISLER_GRPCI2,
352                                        ambapp_find_by_idx, NULL);
353        if ( !tmp ) {
354                return -6;
355        }
356        priv->grpci2 = (struct grpci2_regs *)
357                ((struct ambapp_apb_info *)tmp->devinfo)->start;
358
359        /* Set AHB to PCI mapping for all AMBA AHB masters */
360        for(i = 0; i < 16; i++) {
361                priv->grpci2->ahbtopcimemmap[i] = priv->ahbmst2pci_map &
362                                                        ~(ahb->mask[0]-1);
363        }
364
365        /* Make sure dirq(0) sampling is enabled */
366        ctrl = priv->grpci2->ctrl;
367        ctrl = (ctrl & 0xFFFFFF0F) | (1 << 4);
368        printf("data: 0x%x\n", ctrl);
369        priv->grpci2->ctrl = ctrl;
370
371        /* Successfully registered the RASTA-SPW-ROUTER board */
372        return 0;
373}
374
375int gr_rasta_spw_router_hw_init2(struct gr_rasta_spw_router_priv *priv)
376{
377        /* Enable DMA by enabling PCI target as master */
378        pci_master_enable(priv->pcidev);
379
380        return DRVMGR_OK;
381}
382
383/* Called when a PCI target is found with the PCI device and vendor ID
384 * given in gr_rasta_spw_router_ids[].
385 */
386int gr_rasta_spw_router_init1(struct drvmgr_dev *dev)
387{
388        struct gr_rasta_spw_router_priv *priv;
389        struct pci_dev_info *devinfo;
390        int status;
391        uint32_t bar0, bar0_size;
392        union drvmgr_key_value *value;
393
394        priv = dev->priv;
395        if (!priv)
396                return DRVMGR_NOMEM;
397
398        memset(priv, 0, sizeof(*priv));
399        dev->priv = priv;
400        priv->dev = dev;
401
402        /* Determine number of configurations */
403        if ( gr_rasta_spw_router_resources_cnt == 0 ) {
404                while ( gr_rasta_spw_router_resources[gr_rasta_spw_router_resources_cnt] )
405                        gr_rasta_spw_router_resources_cnt++;
406        }
407
408        /* Generate Device prefix */
409
410        strcpy(priv->prefix, "/dev/spwrouter0");
411        priv->prefix[14] += dev->minor_drv;
412        mkdir(priv->prefix, S_IRWXU | S_IRWXG | S_IRWXO);
413        priv->prefix[15] = '/';
414        priv->prefix[16] = '\0';
415
416        priv->devinfo = devinfo = (struct pci_dev_info *)dev->businfo;
417        priv->pcidev = devinfo->pcidev;
418        bar0 = devinfo->resources[0].address;
419        bar0_size = devinfo->resources[0].size;
420        printf("\n\n--- GR-RASTA-SPW-ROUTER[%d] ---\n", dev->minor_drv);
421        printf(" PCI BUS: 0x%x, SLOT: 0x%x, FUNCTION: 0x%x\n",
422                PCI_DEV_EXPAND(priv->pcidev));
423        printf(" PCI VENDOR: 0x%04x, DEVICE: 0x%04x\n",
424                devinfo->id.vendor, devinfo->id.device);
425        printf(" PCI BAR[0]: 0x%08lx - 0x%08lx\n", bar0, bar0 + bar0_size - 1);
426        printf(" IRQ: %d\n\n\n", devinfo->irq);
427
428        /* all neccessary space assigned to GR-RASTA-SPW-ROUTER target? */
429        if (bar0_size == 0)
430                return DRVMGR_ENORES;
431
432        /* Let user override which PCI address the AHB masters of the
433         * GR-RASTA-SPW board access when doing DMA to CPU RAM. The AHB masters
434         * access the PCI Window of the AMBA bus, the MSB 4-bits of that address
435         * is translated according this config option before the address
436         * goes out on the PCI bus.
437         * Only the 4 MSB bits have an effect;
438         */
439        value = drvmgr_dev_key_get(priv->dev, "ahbmst2pci", KEY_TYPE_INT);
440        if (value)
441                priv->ahbmst2pci_map = value->i;
442        else
443                priv->ahbmst2pci_map = AHBMST2PCIADR; /* default */     
444
445        priv->genirq = genirq_init(16);
446        if ( priv->genirq == NULL )
447                return DRVMGR_FAIL;
448
449        if ((status = gr_rasta_spw_router_hw_init(priv)) != 0) {
450                genirq_destroy(priv->genirq);
451                printf(" Failed to initialize GR-RASTA-SPW-ROUTER HW: %d\n", status);
452                return DRVMGR_FAIL;
453        }
454
455        /* Init amba bus */
456        priv->config.abus = &priv->abus;
457        priv->config.ops = &ambapp_rasta_spw_router_ops;
458        priv->config.maps_up = &priv->bus_maps_up[0];
459        priv->config.maps_down = &priv->bus_maps_down[0];
460        if ( priv->dev->minor_drv < gr_rasta_spw_router_resources_cnt ) {
461                priv->config.resources = gr_rasta_spw_router_resources[priv->dev->minor_drv];
462        } else {
463                priv->config.resources = NULL;
464        }
465
466        /* Create and register AMBA PnP bus. */
467        return ambapp_bus_register(dev, &priv->config);
468}
469
470int gr_rasta_spw_router_init2(struct drvmgr_dev *dev)
471{
472        struct gr_rasta_spw_router_priv *priv = dev->priv;
473
474        /* Clear any old interrupt requests */
475        drvmgr_interrupt_clear(dev, 0);
476
477        /* Enable System IRQ so that GR-RASTA-SPW-ROUTER PCI target interrupt
478         * goes through.
479         *
480         * It is important to enable it in stage init2. If interrupts were
481         * enabled in init1 this might hang the system when more than one
482         * PCI board is connected, this is because PCI interrupts might
483         * be shared and PCI board 2 have not initialized and
484         * might therefore drive interrupt already when entering init1().
485         */
486        drvmgr_interrupt_register(
487                dev,
488                0,
489                "gr_rasta_spw_router",
490                gr_rasta_spw_router_isr,
491                (void *)priv);
492
493        return gr_rasta_spw_router_hw_init2(priv);
494}
495
496int ambapp_rasta_spw_router_int_register(
497        struct drvmgr_dev *dev,
498        int irq,
499        const char *info,
500        drvmgr_isr handler,
501        void *arg)
502{
503        struct gr_rasta_spw_router_priv *priv = dev->parent->dev->priv;
504        rtems_interrupt_level level;
505        int status;
506
507        rtems_interrupt_disable(level);
508
509        status = genirq_register(priv->genirq, irq, handler, arg);
510        if (status == 0) {
511                /* Clear IRQ for first registered handler */
512                priv->irq->iclear = (1<<irq);
513        } else if (status == 1)
514                status = 0;
515
516        if (status != 0) {
517                rtems_interrupt_enable(level);
518                return DRVMGR_FAIL;
519        }
520
521        status = genirq_enable(priv->genirq, irq, handler, arg);
522        if ( status == 0 ) {
523                /* Enable IRQ for first enabled handler only */
524                priv->irq->mask[0] |= (1<<irq); /* unmask interrupt source */
525        } else if ( status == 1 )
526                status = 0;
527
528        rtems_interrupt_enable(level);
529
530        return status;
531}
532
533int ambapp_rasta_spw_router_int_unregister(
534        struct drvmgr_dev *dev,
535        int irq,
536        drvmgr_isr isr,
537        void *arg)
538{
539        struct gr_rasta_spw_router_priv *priv = dev->parent->dev->priv;
540        rtems_interrupt_level level;
541        int status;
542
543        rtems_interrupt_disable(level);
544
545        status = genirq_disable(priv->genirq, irq, isr, arg);
546        if ( status == 0 ) {
547                /* Disable IRQ only when no enabled handler exists */
548                priv->irq->mask[0] &= ~(1<<irq); /* mask interrupt source */
549        }
550
551        status = genirq_unregister(priv->genirq, irq, isr, arg);
552        if ( status != 0 )
553                status = DRVMGR_FAIL;
554
555        rtems_interrupt_enable(level);
556
557        return status;
558}
559
560int ambapp_rasta_spw_router_int_unmask(
561        struct drvmgr_dev *dev,
562        int irq)
563{
564        struct gr_rasta_spw_router_priv *priv = dev->parent->dev->priv;
565        rtems_interrupt_level level;
566
567        DBG("RASTA-SPW-ROUTER IRQ %d: unmask\n", irq);
568
569        if ( genirq_check(priv->genirq, irq) )
570                return DRVMGR_EINVAL;
571
572        rtems_interrupt_disable(level);
573
574        /* Enable IRQ for first enabled handler only */
575        priv->irq->mask[0] |= (1<<irq); /* unmask interrupt source */
576
577        rtems_interrupt_enable(level);
578
579        return DRVMGR_OK;
580}
581
582int ambapp_rasta_spw_router_int_mask(
583        struct drvmgr_dev *dev,
584        int irq)
585{
586        struct gr_rasta_spw_router_priv *priv = dev->parent->dev->priv;
587        rtems_interrupt_level level;
588
589        DBG("RASTA-SPW-ROUTER IRQ %d: mask\n", irq);
590
591        if ( genirq_check(priv->genirq, irq) )
592                return DRVMGR_EINVAL;
593
594        rtems_interrupt_disable(level);
595
596        /* Disable/mask IRQ */
597        priv->irq->mask[0] &= ~(1<<irq); /* mask interrupt source */
598
599        rtems_interrupt_enable(level);
600
601        return DRVMGR_OK;
602}
603
604int ambapp_rasta_spw_router_int_clear(
605        struct drvmgr_dev *dev,
606        int irq)
607{
608        struct gr_rasta_spw_router_priv *priv = dev->parent->dev->priv;
609
610        if ( genirq_check(priv->genirq, irq) )
611                return DRVMGR_EINVAL;
612
613        priv->irq->iclear = (1<<irq);
614
615        return DRVMGR_OK;
616}
617
618int ambapp_rasta_spw_router_get_params(struct drvmgr_dev *dev, struct drvmgr_bus_params *params)
619{
620        struct gr_rasta_spw_router_priv *priv = dev->parent->dev->priv;
621
622        /* Device name prefix pointer, skip /dev */
623        params->dev_prefix = &priv->prefix[5];
624
625        return 0;
626}
627
628void gr_rasta_spw_router_print_dev(struct drvmgr_dev *dev, int options)
629{
630        struct gr_rasta_spw_router_priv *priv = dev->priv;
631        struct pci_dev_info *devinfo = priv->devinfo;
632        uint32_t bar0, bar0_size;
633
634        /* Print */
635        printf("--- GR-RASTA-SPW-ROUTER [bus 0x%x, dev 0x%x, fun 0x%x] ---\n",
636                PCI_DEV_EXPAND(priv->pcidev));
637
638        bar0 = devinfo->resources[0].address;
639        bar0_size = devinfo->resources[0].size;
640        printf(" PCI BAR[0]: 0x%lx - 0x%lx\n", bar0, bar0 + bar0_size - 1);
641        printf(" IRQ REGS:        0x%x\n", (unsigned int)priv->irq);
642        printf(" IRQ:             %d\n", devinfo->irq);
643        printf(" PCI REVISION:    %d\n", devinfo->rev);
644        printf(" FREQ:            %d Hz\n", priv->version->amba_freq_hz);
645        printf(" IMASK:           0x%08x\n", priv->irq->mask[0]);
646        printf(" IPEND:           0x%08x\n", priv->irq->ipend);
647
648        /* Print amba config */
649        if (options & RASTA_SPW_ROUTER_OPTIONS_AMBA)
650                ambapp_print(&priv->abus, 10);
651
652#if 0
653        /* Print IRQ handlers and their arguments */
654        if (options & RASTA_SPW_ROUTER_OPTIONS_IRQ) {
655                int i;
656                for(i = 0; i < 16; i++) {
657                        printf(" IRQ[%02d]:         0x%x, arg: 0x%x\n",
658                                i, (unsigned int)priv->isrs[i].handler,
659                                (unsigned int)priv->isrs[i].arg);
660                }
661        }
662#endif
663}
664
665void gr_rasta_spw_router_print(int options)
666{
667        struct pci_drv_info *drv = &gr_rasta_spw_router_info;
668        struct drvmgr_dev *dev;
669
670        dev = drv->general.dev;
671        while(dev) {
672                gr_rasta_spw_router_print_dev(dev, options);
673                dev = dev->next_in_drv;
674        }
675}
Note: See TracBrowser for help on using the repository browser.