Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:08

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsSPARCLEON2
0007  *
0008  * @brief This header file provides interfaces of the
0009  *   LEON2 Hardcoded bus driver.
0010  */
0011 
0012 /*
0013  *  COPYRIGHT (c) 2008.
0014  *  Cobham Gaisler AB.
0015  *
0016  *  Bus driver for a hardcoded setup. LEON2 systems have some
0017  *  cores always present, here called "Standard Cores". In 
0018  *  addtion to the standard cores there are often extra cores
0019  *  that can be defined using the "Custom Cores" mechanism.
0020  *
0021  *  A Core is described by assigning a base register and 
0022  *  IRQ0..IRQ15 using the leon2_core structure.
0023  *
0024  * Redistribution and use in source and binary forms, with or without
0025  * modification, are permitted provided that the following conditions
0026  * are met:
0027  * 1. Redistributions of source code must retain the above copyright
0028  *    notice, this list of conditions and the following disclaimer.
0029  * 2. Redistributions in binary form must reproduce the above copyright
0030  *    notice, this list of conditions and the following disclaimer in the
0031  *    documentation and/or other materials provided with the distribution.
0032  *
0033  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0034  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0035  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0036  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0037  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0038  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0039  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0040  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0041  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0042  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0043  * POSSIBILITY OF SUCH DAMAGE.
0044  */
0045 
0046 #ifndef __LEON2_AMBA_BUS_H__
0047 #define __LEON2_AMBA_BUS_H__
0048 
0049 /*** Cores location and IRQs hardcoded ***/
0050 
0051 #include <drvmgr/drvmgr.h>
0052 #include <grlib/ambapp.h>
0053 
0054 #ifdef __cplusplus
0055 extern "C" {
0056 #endif
0057 
0058 /* LEON2 AMBA Driver ID generation */
0059 #define DRIVER_LEON2_AMBA(id)   DRIVER_ID(DRVMGR_BUS_TYPE_LEON2_AMBA, id)
0060 
0061 /* LEON2 Cores (any unique 48-bit number will do) */
0062 #define LEON2_AMBA_NONE_ID      0
0063 #define LEON2_AMBA_TIMER_ID     1
0064 #define LEON2_AMBA_UART_ID      2
0065 #define LEON2_AMBA_GPIO_ID      3
0066 #define LEON2_AMBA_IRQCTRL_ID       4
0067 
0068 #define LEON2_AMBA_AT697PCI_ID      100
0069 #define LEON2_AMBA_AMBAPP_ID        0xfff0
0070 
0071 /* LEON2 driver IDs */
0072 #define DRIVER_LEON2_AMBA_TIMER     DRIVER_LEON2_AMBA(LEON2_AMBA_TIMER_ID)
0073 #define DRIVER_LEON2_AMBA_UART      DRIVER_LEON2_AMBA(LEON2_AMBA_UART_ID)
0074 #define DRIVER_LEON2_AMBA_AT697PCI  DRIVER_LEON2_AMBA(LEON2_AMBA_AT697PCI_ID)
0075 #define DRIVER_LEON2_AMBA_AMBAPP    DRIVER_LEON2_AMBA(LEON2_AMBA_AMBAPP_ID)
0076 
0077 struct leon2_amba_dev_id {
0078     unsigned short      core_id;
0079 };
0080 
0081 #define EMPTY_LEON2_CORE {{LEON2_AMBA_NONE_ID}, NULL, NULL}
0082 struct leon2_core {
0083     struct leon2_amba_dev_id    id; /* Core ID */
0084     char                *name;  /* Name of Core */
0085     struct drvmgr_key       *keys;  /* Core setup (location, IRQs) */
0086 };
0087 
0088 struct leon2_bus {
0089     struct leon2_core       *std_cores; /* The LEON2 standard cores */
0090     struct leon2_core       *custom_cores;  /* Custom cores on the same bus */
0091     struct drvmgr_map_entry     *maps_up;   /* Memory map ip-stream */
0092     struct drvmgr_map_entry     *maps_down; /* Memory map down-stream */
0093 };
0094 
0095 extern struct leon2_core leon2_std_cores[];
0096 
0097 /* Data structure drivers can access */
0098 struct leon2_amba_dev_info {
0099     unsigned short      core_id;    /* Core ID */
0100     unsigned int        reg_base;   /* Register base */
0101     char            irqs[16];   /* 16 irqs */
0102 };
0103 
0104 struct leon2_amba_drv_info {
0105     struct drvmgr_drv   general;    /* General bus info */
0106     /* AMBA specific bus information */
0107     struct leon2_amba_dev_id    *ids;       /* Supported hardware */
0108 };
0109 
0110 /* Initialize LEON2 bus with a configuration 
0111  *  bus_config   -   What cores, their location and irqs
0112  *  resources    -   Driver configuration for the cores specified bus_config
0113  */
0114 int leon2_root_register(
0115     struct leon2_bus *bus_config,
0116     struct drvmgr_bus_res *resources);
0117 
0118 #ifdef __cplusplus
0119 }
0120 #endif
0121 
0122 #endif