source: rtems/c/src/lib/libbsp/sparc/shared/pci/gr_rasta_adcdac.c @ 4a7d1026

4.115
Last change on this file since 4a7d1026 was 4a7d1026, checked in by Daniel Hellstrom <daniel@…>, on 04/13/15 at 08:25:52

sparc bsps: updated license to rtems.org

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