openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

ibde.h (5946B)


      1 /*
      2  * Copyright 2017 Broadcom
      3  * 
      4  * This program is free software; you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License, version 2, as
      6  * published by the Free Software Foundation (the "GPL").
      7  * 
      8  * This program is distributed in the hope that it will be useful, but
      9  * WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     11  * General Public License version 2 (GPLv2) for more details.
     12  * 
     13  * You should have received a copy of the GNU General Public License
     14  * version 2 (GPLv2) along with this source code.
     15  */
     16 /*
     17  * $Id: ibde.h,v 1.27 Broadcom SDK $
     18  * $Copyright: (c) 2005 Broadcom Corp.
     19  * All Rights Reserved.$
     20  */
     21 
     22 #ifndef __IBDE_H__
     23 #define __IBDE_H__
     24 
     25 #include <sal/types.h>
     26 
     27 /*
     28  * Represents a collection of devices 
     29  */
     30 
     31 typedef struct ibde_dev_s {
     32     uint16 device;
     33     uint8  rev;
     34     sal_vaddr_t base_address;
     35     sal_vaddr_t base_address1;
     36     sal_vaddr_t base_address2;
     37 } ibde_dev_t;
     38 
     39 
     40 typedef struct ibde_s {
     41 
     42     const char *(*name)(void);
     43   
     44     /* Returns the number of devices available */
     45     /* Each device is is accessed through a handle */
     46     /* Handles are assumed to index the array of devices */
     47   
     48     /* Support SWITCH or ETHERNET or CPU devices */
     49     int     (*num_devices)(int type);
     50 #define BDE_ALL_DEVICES         0
     51 #define BDE_SWITCH_DEVICES      1
     52 #define BDE_ETHER_DEVICES       2
     53 #define BDE_CPU_DEVICES         3
     54 
     55     const   ibde_dev_t *(*get_dev)(int d);
     56 
     57     /* 
     58      * Get types of underlaying devices.
     59      * A combination of bus type and functional type is returned.
     60      * In case of bus type, support PCI and SPI device types.
     61      * In case of functional type, specify if underlaying device is
     62      * a switching or ethernet device.
     63      */
     64     uint32  (*get_dev_type)(int d);
     65 #define BDE_PCI_DEV_TYPE      SAL_PCI_DEV_TYPE    /* PCI device */
     66 #define BDE_SPI_DEV_TYPE      SAL_SPI_DEV_TYPE    /* SPI device */
     67 #define BDE_EB_DEV_TYPE       SAL_EB_DEV_TYPE     /* EB device */
     68 #define BDE_ICS_DEV_TYPE      SAL_ICS_DEV_TYPE    /* ICS device */
     69 #define BDE_MII_DEV_TYPE      SAL_MII_DEV_TYPE    /* MII device */
     70 #define BDE_I2C_DEV_TYPE      SAL_I2C_DEV_TYPE    /* I2C device */
     71 #define BDE_AXI_DEV_TYPE      SAL_AXI_DEV_TYPE    /* AXI device */
     72 #define BDE_EMMI_DEV_TYPE     SAL_EMMI_DEV_TYPE   /* EMMI device */
     73 #define BDE_DEV_BUS_ALT       SAL_DEV_BUS_ALT     /* Alternate Access */
     74 #define BDE_DEV_BUS_MSI       SAL_DEV_BUS_MSI     /* Message-signaled interrupts */
     75 
     76 #define BDE_DEV_BUS_TYPE_MASK SAL_DEV_BUS_TYPE_MASK
     77     
     78 #define BDE_SWITCH_DEV_TYPE   SAL_SWITCH_DEV_TYPE /* Switch device */
     79 #define BDE_ETHER_DEV_TYPE    SAL_ETHER_DEV_TYPE  /* Ethernet device */
     80 #define BDE_CPU_DEV_TYPE      SAL_CPU_DEV_TYPE    /* CPU device */
     81 
     82 #define BDE_BYTE_SWAP         0x01000000          /* SW byte swap */
     83 #define BDE_NO_IPROC          0x02000000          /* Device uses two BARs, but is not iProc */
     84 
     85 #define BDE_8MB_REG_SPACE     0x10000000          /* 8MB sized CMIC BAR */
     86 #define BDE_256K_REG_SPACE    0x20000000          /* Map 256K (v 64K) */
     87 #define BDE_128K_REG_SPACE    0x40000000          /* Map 128K (v 64K) */
     88 #define BDE_320K_REG_SPACE    0x80000000          /* Map 256K+64K */
     89 
     90 /* Bus supports only 16bit reads */
     91 #define BDE_DEV_BUS_RD_16BIT  SAL_DEV_BUS_RD_16BIT 
     92 
     93 /* Bus supports only 16bit writes */
     94 #define BDE_DEV_BUS_WR_16BIT  SAL_DEV_BUS_WR_16BIT
     95 
     96 /* Backward compatibility */
     97 #define BDE_ET_DEV_TYPE       BDE_MII_DEV_TYPE
     98 
     99 #define BDE_DEV_MEM_MAPPED(_d) \
    100     ((_d) & (BDE_PCI_DEV_TYPE | BDE_ICS_DEV_TYPE | BDE_EB_DEV_TYPE |\
    101              BDE_EMMI_DEV_TYPE | BDE_AXI_DEV_TYPE))
    102 
    103     /* 
    104      * PCI Bus Access
    105      */
    106     uint32  (*pci_conf_read)(int d, uint32 addr);
    107     int     (*pci_conf_write)(int d, uint32 addr, uint32 data);
    108     void    (*pci_bus_features)(int d, int *be_pio, int *be_packet,
    109                                 int *be_other);
    110 
    111     uint32  (*read)(int d, uint32 addr);
    112     int     (*write)(int d, uint32 addr, uint32 data);
    113 
    114     uint32* (*salloc)(int d, int size, const char *name);
    115     void    (*sfree)(int d, void *ptr);
    116     int     (*sflush)(int d, void *addr, int length);
    117     int     (*sinval)(int d, void *addr, int length);
    118 
    119     int     (*interrupt_connect)(int d, void (*)(void*), void *data);  
    120     int     (*interrupt_disconnect)(int d);
    121 
    122     sal_paddr_t  (*l2p)(int d, void *laddr);
    123     void* (*p2l)(int d, sal_paddr_t paddr);
    124 
    125     /* 
    126      * SPI Access via SMP
    127      */
    128     int  (*spi_read)(int d, uint32 addr, uint8 *buf, int len);
    129     int  (*spi_write)(int d, uint32 addr, uint8 *buf, int len);
    130     /* Special SPI access addresses */
    131 #define BDE_DEV_OP_EMMI_INIT    SAL_DEV_OP_EMMI_INIT
    132 
    133     /* 
    134      * iProc register access
    135      */
    136     uint32  (*iproc_read)(int d, uint32 addr);
    137     int     (*iproc_write)(int d, uint32 addr, uint32 data);
    138 
    139     /* 
    140      * Shared memory access
    141      */
    142     uint32  (*shmem_read)(int dev, uint32 addr, uint8 *buf, uint32 len);
    143     void    (*shmem_write)(int dev, uint32 addr, uint8 *buf, uint32 len);
    144     sal_vaddr_t (*shmem_map)(int dev, uint32 addr, uint32 size);
    145 
    146     /*
    147      *  cmic
    148      */
    149     int   (*get_cmic_ver)(int d,  uint32 *ver);
    150 
    151     /*
    152      * I2C operations on the Device, assuming it is connected by I2C to the CPU.
    153      */
    154     /* Read from the internal device Address space using I2C */
    155     int (*i2c_device_read)(
    156         int dev,       /* The device ID to access */
    157         uint32 addr,   /* The address to access in the internal device address space */
    158         uint32 *value);/* the value to be read. */
    159     /* Write to the internal device Address space using I2C */
    160     int (*i2c_device_write)(
    161         int dev,       /* The device ID to access */
    162         uint32 addr,   /* The address to access in the internal device address space */
    163         uint32 value); /* the value to be written. */
    164 
    165 } ibde_t;
    166 
    167 
    168 /* System BDE */
    169 extern ibde_t *bde;
    170 
    171 
    172 #endif /* __IBDE_H__ */