Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:42

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*  General part of a AMBA Plug & Play bus driver.
0004  *
0005  *  COPYRIGHT (c) 2008.
0006  *  Cobham Gaisler AB.
0007  *
0008  *  This is the general part of the different AMBA Plug & Play
0009  *  drivers. The drivers are wrappers around this driver, making
0010  *  the code size smaller for systems with multiple AMBA Plug & 
0011  *  Play buses.
0012  *
0013  * Redistribution and use in source and binary forms, with or without
0014  * modification, are permitted provided that the following conditions
0015  * are met:
0016  * 1. Redistributions of source code must retain the above copyright
0017  *    notice, this list of conditions and the following disclaimer.
0018  * 2. Redistributions in binary form must reproduce the above copyright
0019  *    notice, this list of conditions and the following disclaimer in the
0020  *    documentation and/or other materials provided with the distribution.
0021  *
0022  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0023  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0025  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0026  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0027  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0028  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0031  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0032  * POSSIBILITY OF SUCH DAMAGE.
0033  */
0034 
0035 #ifndef __AMBAPP_BUS_H__
0036 #define __AMBAPP_BUS_H__
0037 
0038 #include <drvmgr/drvmgr.h>
0039 #include "ambapp.h"
0040 
0041 #ifdef __cplusplus
0042 extern "C" {
0043 #endif
0044 
0045 /* GRLIB AMBA Plug&Play Driver ID generation */
0046 #define DRIVER_AMBAPP_ID(vendor, device) \
0047     DRIVER_ID(DRVMGR_BUS_TYPE_AMBAPP, ((((vendor) & 0xff) << 16) | ((device) & 0xfff)))
0048 
0049 /*** Gaisler Hardware Device Driver IDs ***/
0050 #define DRIVER_AMBAPP_GAISLER_AHBSTAT_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_AHBSTAT)
0051 #define DRIVER_AMBAPP_GAISLER_APBUART_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_APBUART)
0052 #define DRIVER_AMBAPP_GAISLER_B1553BRM_ID   DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_B1553BRM)
0053 #define DRIVER_AMBAPP_GAISLER_B1553RT_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_B1553RT)
0054 #define DRIVER_AMBAPP_GAISLER_GPTIMER_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPTIMER)
0055 #define DRIVER_AMBAPP_GAISLER_GR1553B_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GR1553B)
0056 #define DRIVER_AMBAPP_GAISLER_GRADCDAC_ID   DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRADCDAC)
0057 #define DRIVER_AMBAPP_GAISLER_GRAES_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRAESDMA)
0058 #define DRIVER_AMBAPP_GAISLER_GRCAN_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRCAN)
0059 #define DRIVER_AMBAPP_GAISLER_GRCTM_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRCTM)
0060 #define DRIVER_AMBAPP_GAISLER_GRETH_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_ETHMAC)
0061 #define DRIVER_AMBAPP_GAISLER_GRGPIO_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GPIO)
0062 #define DRIVER_AMBAPP_GAISLER_GRPCI2_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRPCI2)
0063 #define DRIVER_AMBAPP_GAISLER_GRIOMMU_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRIOMMU)
0064 #define DRIVER_AMBAPP_GAISLER_GRPCI_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCIFBRG)
0065 #define DRIVER_AMBAPP_GAISLER_GRPWM_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRPWM)
0066 #define DRIVER_AMBAPP_GAISLER_GRPWRX_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PW2APB)
0067 #define DRIVER_AMBAPP_GAISLER_GRSPW_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW)
0068 #define DRIVER_AMBAPP_GAISLER_GRSPW2_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW2)
0069 #define DRIVER_AMBAPP_GAISLER_GRTC_ID       DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRTC)
0070 #define DRIVER_AMBAPP_GAISLER_GRTM_ID       DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_GRTM)
0071 #define DRIVER_AMBAPP_GAISLER_I2CMST_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_I2CMST)
0072 #define DRIVER_AMBAPP_GAISLER_OCCAN_ID      DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_CANAHB)
0073 #define DRIVER_AMBAPP_GAISLER_PCIF_ID       DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCIF)
0074 #define DRIVER_AMBAPP_GAISLER_PCITRACE_ID   DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_PCITRACE)
0075 #define DRIVER_AMBAPP_GAISLER_SPICTRL_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPICTRL)
0076 #define DRIVER_AMBAPP_GAISLER_SPWCUC_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPWCUC)
0077 #define DRIVER_AMBAPP_GAISLER_SPW_ROUTER_ID DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPW_ROUTER)
0078 #define DRIVER_AMBAPP_GAISLER_L2CACHE_ID    DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_L2CACHE)
0079 #define DRIVER_AMBAPP_GAISLER_MEMSCRUB_ID   DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_MEMSCRUB)
0080 #define DRIVER_AMBAPP_GAISLER_L4STAT_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_L4STAT)
0081 #define DRIVER_AMBAPP_GAISLER_SPWTDP_ID     DRIVER_AMBAPP_ID(VENDOR_GAISLER, GAISLER_SPWTDP)
0082 
0083 /*** ESA Hardware Device Driver IDs ***/
0084 #define DRIVER_AMBAPP_ESA_MCTRL_ID      DRIVER_AMBAPP_ID(VENDOR_ESA, ESA_MCTRL)
0085 #define DRIVER_AMBAPP_MCTRL_ID          DRIVER_AMBAPP_ESA_MCTRL_ID
0086 
0087 struct amba_dev_id {
0088     unsigned short      vendor;
0089     unsigned short      device;
0090     /* Version ? */
0091 };
0092 
0093 struct amba_drv_info {
0094     struct drvmgr_drv   general;    /* General bus info */
0095     /* AMBA specific bus information */
0096     struct amba_dev_id      *ids;       /* Supported hardware */
0097 };
0098 
0099 struct amba_dev_info {
0100     struct amba_dev_id  id;
0101     struct ambapp_core  info;
0102 };
0103 
0104 struct ambapp_ops {
0105     int (*int_register)
0106         (struct drvmgr_dev *dev, int index, const char *info, drvmgr_isr isr, void *arg);
0107     int (*int_unregister)
0108         (struct drvmgr_dev *dev, int index, drvmgr_isr isr, void *arg);
0109     int (*int_clear)(struct drvmgr_dev *dev, int index);
0110     int (*int_mask)(struct drvmgr_dev *dev, int index);
0111     int (*int_unmask)(struct drvmgr_dev *dev, int index);
0112 #ifdef RTEMS_SMP
0113     int     (*int_set_affinity)(struct drvmgr_dev *dev, int index,
0114                 const Processor_mask *cpus);
0115 #endif
0116     int (*get_params)
0117         (struct drvmgr_dev *, struct drvmgr_bus_params *);
0118 };
0119 
0120 struct ambapp_config {
0121     struct ambapp_bus       *abus;      /* Prescanned AMBA PnP bus */
0122     struct ambapp_ops       *ops;       /* AMBA bus operations */
0123     struct drvmgr_map_entry     *maps_up;   /* Bus memory map up-stream towards CPU */
0124     struct drvmgr_map_entry     *maps_down; /* Bus memory map down-stream towards HW */
0125     struct drvmgr_bus_res       *resources; /* Driver Resources */
0126     int             bus_type;   /* Set DRVMGR_BUS_TYPE_AMBAPP_DIST if distributed AMBA Bus */
0127     struct drvmgr_func      *funcs;     /* Custom functions */
0128 };
0129 
0130 /*** Bus operations with READ/WRITE access operations ***
0131  *
0132  * The functions are implemented using the standard drvmgr RW interface
0133  */
0134 #define AMBAPP_R8        DRVMGR_RWFUNC(RW_SIZE_1|RW_READ|RW_REG)
0135 #define AMBAPP_R16       DRVMGR_RWFUNC(RW_SIZE_2|RW_READ|RW_REG)
0136 #define AMBAPP_R32       DRVMGR_RWFUNC(RW_SIZE_4|RW_READ|RW_REG)
0137 #define AMBAPP_R64       DRVMGR_RWFUNC(RW_SIZE_8|RW_READ|RW_REG)
0138 #define AMBAPP_W8        DRVMGR_RWFUNC(RW_SIZE_1|RW_WRITE|RW_REG)
0139 #define AMBAPP_W16       DRVMGR_RWFUNC(RW_SIZE_2|RW_WRITE|RW_REG)
0140 #define AMBAPP_W32       DRVMGR_RWFUNC(RW_SIZE_4|RW_WRITE|RW_REG)
0141 #define AMBAPP_W64       DRVMGR_RWFUNC(RW_SIZE_8|RW_WRITE|RW_REG)
0142 #define AMBAPP_RMEM      DRVMGR_RWFUNC(RW_SIZE_ANY|RW_READ|RW_MEM)
0143 #define AMBAPP_WMEM      DRVMGR_RWFUNC(RW_SIZE_ANY|RW_WRITE|RW_MEM)
0144 #define AMBAPP_MEMSET    DRVMGR_RWFUNC(RW_SIZE_ANY|RW_SET|RW_MEM)
0145 #define AMBAPP_RW_ARG    DRVMGR_RWFUNC(RW_ARG)
0146 
0147 /* Register an ambapp bus on-top of a device */
0148 extern int ambapp_bus_register(
0149     struct drvmgr_dev *dev,
0150     struct ambapp_config *config
0151     );
0152 
0153 extern void ambapp_bus_freq_register(
0154     struct drvmgr_dev *dev,
0155     int amba_interface,
0156     unsigned int freq_hz);
0157 
0158 #ifdef __cplusplus
0159 }
0160 #endif
0161 
0162 #endif