00001 #ifndef TEMU_BUS_AMBA_H
00002 #define TEMU_BUS_AMBA_H
00003
00011 #include "temu-c/Support/Objsys.h"
00012 #include <stdint.h>
00013
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017
00018
00019
00020 static const uint32_t teAMBA_VendorGaisler = 0x01;
00021 static const uint32_t teAMBA_VendorPender = 0x02;
00022 static const uint32_t teAMBA_VendorEsa = 0x04;
00023 static const uint32_t teAMBA_VendorAstrium = 0x06;
00024 static const uint32_t teAMBA_VendorOpenChip = 0x07;
00025 static const uint32_t teAMBA_VendorOpenCores = 0x08;
00026 static const uint32_t teAMBA_VendorVarious = 0x09;
00027 static const uint32_t teAMBA_VendorDlr = 0x0a;
00028 static const uint32_t teAMBA_VendorEonic = 0x0b;
00029 static const uint32_t teAMBA_VendorParisTech = 0x0c;
00030 static const uint32_t teAMBA_VendorRadionor = 0x0f;
00031 static const uint32_t teAMBA_VendorGleichmann = 0x10;
00032 static const uint32_t teAMBA_VendorMenta = 0x11;
00033 static const uint32_t teAMBA_VendorSun = 0x13;
00034 static const uint32_t teAMBA_VendorMovidia = 0x14;
00035 static const uint32_t teAMBA_VendorOrbita = 0x17;
00036 static const uint32_t teAMBA_VendorSiemens = 0x1a;
00037 static const uint32_t teAMBA_VendorActel = 0xac;
00038 static const uint32_t teAMBA_VendorCaltech = 0xca;
00039 static const uint32_t teAMBA_VendorEmbeddit = 0xea;
00040
00041
00043 typedef struct {
00044 uint32_t IdentReg;
00045 uint32_t UserDef[3];
00046 uint32_t Bar[4];
00047 } temu_AhbPnpInfo;
00048
00056 typedef struct temu_AhbIface {
00057 temu_AhbPnpInfo* (*getAhbPnp)(void *Obj);
00058 } temu_AhbIface;
00059
00060 OBJSYS_OBJ_TYPE(temu_Ahb);
00061
00062
00064 typedef struct {
00065 uint32_t ConfigWord;
00066 uint32_t Bar;
00067 } temu_ApbPnpInfo;
00068
00069
00077 typedef struct temu_ApbIface {
00078 temu_ApbPnpInfo* (*getApbPnp)(void *Obj);
00079 } temu_ApbIface;
00080
00081 OBJSYS_OBJ_TYPE(temu_Apb);
00082
00083
00084
00085 static inline void
00086 temu_ahbSetVendor(temu_AhbPnpInfo *Ahb, uint32_t Vendor)
00087 {
00088 Ahb->IdentReg = (Ahb->IdentReg & 0x00ffffff) | (Vendor << 24);
00089 }
00090
00091
00092 static inline void
00093 temu_ahbSetDeviceId(temu_AhbPnpInfo *Ahb, uint32_t Device)
00094 {
00095 Ahb->IdentReg = (Ahb->IdentReg & 0xff000fff) | (Device << 12);
00096 }
00097
00098 static inline void
00099 temu_ahbSetVersion(temu_AhbPnpInfo *Ahb, uint32_t Version)
00100 {
00101 Ahb->IdentReg = (Ahb->IdentReg & 0xfffffc1f) | (Version << 5);
00102 }
00103
00104 static inline void
00105 temu_ahbSetIrq(temu_AhbPnpInfo *Ahb, uint32_t Irq)
00106 {
00107 Ahb->IdentReg = (Ahb->IdentReg & 0xffffffe0) | Irq;
00108 }
00109
00110 static inline uint32_t
00111 temu_ahbGetIrq(temu_AhbPnpInfo *Ahb)
00112 {
00113 return Ahb->IdentReg & 0x1f;
00114 }
00115
00116 static inline void
00117 temu_ahbSetUserDef(temu_AhbPnpInfo *Ahb, int Id, uint32_t User)
00118 {
00119 Ahb->UserDef[Id] = User;
00120 }
00121
00122 static inline void
00123 temu_ahbSetAddr(temu_AhbPnpInfo *Ahb, int Id, uint32_t Addr)
00124 {
00125 Ahb->Bar[Id] = (Ahb->Bar[Id] & 0x000fffff) | (Addr & 0xfff00000);
00126 }
00127
00128 static inline void
00129 temu_ahbSetCP(temu_AhbPnpInfo *Ahb, int Id, uint32_t CP)
00130 {
00131 Ahb->Bar[Id] = (Ahb->Bar[Id] & 0xfff0ffff) | (CP << 16);
00132 }
00133
00134 static inline void
00135 temu_ahbSetMask(temu_AhbPnpInfo *Ahb, int Id, uint32_t Mask)
00136 {
00137 Ahb->Bar[Id] = (Ahb->Bar[Id] & 0xffff000f) | (Mask << 4);
00138 }
00139
00140 static inline void
00141 temu_ahbSetType(temu_AhbPnpInfo *Ahb, int Id, uint32_t Type)
00142 {
00143 Ahb->Bar[Id] = (Ahb->Bar[Id] & 0xfffffff0) | Type;
00144 }
00145
00146
00147
00148 static inline void
00149 temu_apbSetVendorId(temu_ApbPnpInfo *Apb, uint32_t Vendor)
00150 {
00151 Apb->ConfigWord = (Apb->ConfigWord & 0x00ffffff) | (Vendor << 24);
00152 }
00153
00154
00155 static inline void
00156 temu_apbSetDeviceId(temu_ApbPnpInfo *Apb, uint32_t Device)
00157 {
00158 Apb->ConfigWord = (Apb->ConfigWord & 0xff000fff) | (Device << 12);
00159 }
00160
00161 static inline void
00162 temu_apbSetVersion(temu_ApbPnpInfo *Apb, uint32_t Version)
00163 {
00164 Apb->ConfigWord = (Apb->ConfigWord & 0xfffffc1f) | (Version << 5);
00165 }
00166
00167 static inline void
00168 temu_apbSetIrq(temu_ApbPnpInfo *Apb, uint32_t Irq)
00169 {
00170 Apb->ConfigWord = (Apb->ConfigWord & 0xffffffe0) | Irq;
00171 }
00172
00173 static inline uint32_t
00174 temu_apbGetIrq(temu_ApbPnpInfo *Apb)
00175 {
00176 return Apb->ConfigWord & 0x1f;
00177 }
00178
00179 static inline void
00180 temu_apbSetAddr(temu_ApbPnpInfo *Apb, uint32_t Addr)
00181 {
00182 Apb->Bar = (Apb->Bar & 0x000fffff) | ((Addr & 0x000fff00) << 12);
00183 }
00184
00185 static inline void
00186 temu_apbSetCP(temu_ApbPnpInfo *Apb, uint32_t CP)
00187 {
00188 Apb->Bar = (Apb->Bar & 0xfff0ffff) | (CP << 16);
00189 }
00190
00191 static inline void
00192 temu_apbSetMask(temu_ApbPnpInfo *Apb, uint32_t Mask)
00193 {
00194 Apb->Bar = (Apb->Bar & 0xffff000f) | (Mask << 4);
00195 }
00196
00197 static inline void
00198 temu_apbSetType(temu_ApbPnpInfo *Apb, uint32_t Type)
00199 {
00200 Apb->Bar = (Apb->Bar & 0xfffffff0) | Type;
00201 }
00202
00203 #ifdef __cplusplus
00204 }
00205 #endif
00206
00207 #endif