| 1 | /*
|
|---|
| 2 | * Copyright (c) 2013 Jakub Klama
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 | /** @addtogroup sparc32boot
|
|---|
| 30 | * @{
|
|---|
| 31 | */
|
|---|
| 32 | /** @file
|
|---|
| 33 | * @brief Definitions of structures and addresses of AMBA Plug&Play interface
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | #ifndef BOOT_sparc32_AMBAPP_H
|
|---|
| 37 | #define BOOT_sparc32_AMBAPP_H
|
|---|
| 38 |
|
|---|
| 39 | #define AMBAPP_MAX_DEVICES 64
|
|---|
| 40 | #define AMBAPP_AHBMASTER_AREA 0xfffff000
|
|---|
| 41 | #define AMBAPP_AHBSLAVE_AREA 0xfffff800
|
|---|
| 42 | #define AMBAPP_CONF_AREA 0xff000
|
|---|
| 43 |
|
|---|
| 44 | typedef enum {
|
|---|
| 45 | GAISLER = 1,
|
|---|
| 46 | ESA = 4
|
|---|
| 47 | } amba_vendor_id_t;
|
|---|
| 48 |
|
|---|
| 49 | typedef enum {
|
|---|
| 50 | GAISLER_LEON3 = 0x003,
|
|---|
| 51 | GAISLER_LEON3DSU = 0x004,
|
|---|
| 52 | GAISLER_ETHAHB = 0x005,
|
|---|
| 53 | GAISLER_APBMST = 0x006,
|
|---|
| 54 | GAISLER_AHBUART = 0x007,
|
|---|
| 55 | GAISLER_SRCTRL = 0x008,
|
|---|
| 56 | GAISLER_SDCTRL = 0x009,
|
|---|
| 57 | GAISLER_APBUART = 0x00c,
|
|---|
| 58 | GAISLER_IRQMP = 0x00d,
|
|---|
| 59 | GAISLER_AHBRAM = 0x00e,
|
|---|
| 60 | GAISLER_GPTIMER = 0x011,
|
|---|
| 61 | GAISLER_PCITRG = 0x012,
|
|---|
| 62 | GAISLER_PCISBRG = 0x013,
|
|---|
| 63 | GAISLER_PCIFBRG = 0x014,
|
|---|
| 64 | GAISLER_PCITRACE = 0x015,
|
|---|
| 65 | GAISLER_PCIDMA = 0x016,
|
|---|
| 66 | GAISLER_AHBTRACE = 0x017,
|
|---|
| 67 | GAISLER_ETHDSU = 0x018,
|
|---|
| 68 | GAISLER_PIOPORT = 0x01a,
|
|---|
| 69 | GAISLER_AHBJTAG = 0x01c,
|
|---|
| 70 | GAISLER_SPW = 0x01f,
|
|---|
| 71 | GAISLER_ATACTRL = 0x024,
|
|---|
| 72 | GAISLER_VGA = 0x061,
|
|---|
| 73 | GAISLER_KBD = 0x060,
|
|---|
| 74 | GAISLER_ETHMAC = 0x01d,
|
|---|
| 75 | GAISLER_DDRSPA = 0x025,
|
|---|
| 76 | GAISLER_EHCI = 0x026,
|
|---|
| 77 | GAISLER_UHCI = 0x027,
|
|---|
| 78 | GAISLER_SPW2 = 0x029,
|
|---|
| 79 | GAISLER_DDR2SPA = 0x02e,
|
|---|
| 80 | GAISLER_AHBSTAT = 0x052,
|
|---|
| 81 | GAISLER_FTMCTRL = 0x054,
|
|---|
| 82 | ESA_MCTRL = 0x00f,
|
|---|
| 83 | } amba_device_id_t;
|
|---|
| 84 |
|
|---|
| 85 | typedef struct {
|
|---|
| 86 | /* Primary serial port location */
|
|---|
| 87 | uintptr_t uart_base;
|
|---|
| 88 | size_t uart_size;
|
|---|
| 89 | int uart_irq;
|
|---|
| 90 | /* Timers location */
|
|---|
| 91 | uintptr_t timer_base;
|
|---|
| 92 | size_t timer_size;
|
|---|
| 93 | int timer_irq;
|
|---|
| 94 | } amba_info_t;
|
|---|
| 95 |
|
|---|
| 96 | typedef struct {
|
|---|
| 97 | amba_vendor_id_t vendor_id;
|
|---|
| 98 | amba_device_id_t device_id;
|
|---|
| 99 | int irq;
|
|---|
| 100 | int version;
|
|---|
| 101 | uint32_t args[3];
|
|---|
| 102 | struct {
|
|---|
| 103 | uintptr_t start;
|
|---|
| 104 | uintptr_t size;
|
|---|
| 105 | bool prefetchable;
|
|---|
| 106 | bool cacheable;
|
|---|
| 107 | } bars[4];
|
|---|
| 108 | } amba_device_t;
|
|---|
| 109 |
|
|---|
| 110 | typedef struct {
|
|---|
| 111 | unsigned int addr : 12;
|
|---|
| 112 | unsigned int reserved : 2;
|
|---|
| 113 | unsigned int prefetchable : 1;
|
|---|
| 114 | unsigned int cacheable : 1;
|
|---|
| 115 | unsigned int mask : 12;
|
|---|
| 116 | unsigned int type : 4;
|
|---|
| 117 | } __attribute__((packed)) ambapp_bar_t;
|
|---|
| 118 |
|
|---|
| 119 | typedef struct {
|
|---|
| 120 | unsigned int vendor_id : 8;
|
|---|
| 121 | unsigned int device_id : 24;
|
|---|
| 122 | unsigned int reserved : 2;
|
|---|
| 123 | unsigned int version : 5;
|
|---|
| 124 | unsigned int irq : 5;
|
|---|
| 125 | uint32_t user_defined[3];
|
|---|
| 126 | ambapp_bar_t bar[4];
|
|---|
| 127 | } __attribute__((packed)) ambapp_entry_t;
|
|---|
| 128 |
|
|---|
| 129 | typedef struct {
|
|---|
| 130 | unsigned int ram_read_ws : 1;
|
|---|
| 131 | unsigned int ram_write_ws : 1;
|
|---|
| 132 | unsigned int ram_width : 2;
|
|---|
| 133 | unsigned int rmw : 1;
|
|---|
| 134 | unsigned int rbrdy : 1;
|
|---|
| 135 | unsigned int : 1;
|
|---|
| 136 | unsigned int bank_size : 4;
|
|---|
| 137 | unsigned int si : 1;
|
|---|
| 138 | unsigned int se : 1;
|
|---|
| 139 | unsigned int : 1;
|
|---|
| 140 | unsigned int ms : 1;
|
|---|
| 141 | unsigned int : 1;
|
|---|
| 142 | unsigned int d64 : 1;
|
|---|
| 143 | unsigned int sdram_cmd : 2;
|
|---|
| 144 | unsigned int sdram_colsz : 2;
|
|---|
| 145 | unsigned int sdram_banksz : 3;
|
|---|
| 146 | unsigned int tcas : 1;
|
|---|
| 147 | unsigned int trfc : 3;
|
|---|
| 148 | unsigned int trp : 1;
|
|---|
| 149 | unsigned int sdrf : 1;
|
|---|
| 150 | } __attribute__((packed)) mctrl_mcfg2_t;
|
|---|
| 151 |
|
|---|
| 152 | extern uintptr_t amba_uart_base;
|
|---|
| 153 |
|
|---|
| 154 | extern void ambapp_scan(void);
|
|---|
| 155 | extern bool ambapp_fake(void);
|
|---|
| 156 | extern void ambapp_qemu_fake_scan(void);
|
|---|
| 157 | extern void ambapp_print_devices(void);
|
|---|
| 158 | extern amba_device_t *ambapp_lookup_first(amba_vendor_id_t, amba_device_id_t);
|
|---|
| 159 |
|
|---|
| 160 | #endif
|
|---|
| 161 |
|
|---|
| 162 | /** @}
|
|---|
| 163 | */
|
|---|