1 // 2 // Copyright (c) 2010-2018 Antmicro 3 // Copyright (c) 2017 Bas Stottelaar <basstottelaar@gmail.com> 4 // 5 // This file is licensed under the MIT License. 6 // Full license text is available in 'licenses/MIT.txt'. 7 // 8 using Antmicro.Renode.Logging; 9 using Antmicro.Renode.Peripherals.Bus; 10 using Antmicro.Renode.Peripherals.Memory; 11 12 namespace Antmicro.Renode.Peripherals.Miscellaneous.SiLabs 13 { 14 [AllowedTranslations(AllowedTranslation.ByteToDoubleWord | AllowedTranslation.WordToDoubleWord)] 15 public class EFR32DeviceInformation : DeviceInformation, IDoubleWordPeripheral, IKnownSize 16 { EFR32DeviceInformation(DeviceFamily deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0)17 public EFR32DeviceInformation(DeviceFamily deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0) 18 : base(deviceFamily, deviceNumber, flashDevice, sramDevice, productRevision) 19 { 20 } 21 EFR32DeviceInformation(int deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0)22 public EFR32DeviceInformation(int deviceFamily, ushort deviceNumber, MappedMemory flashDevice, MappedMemory sramDevice, byte productRevision = 0) 23 : this((DeviceFamily)deviceFamily, deviceNumber, flashDevice, sramDevice, productRevision) 24 { 25 } 26 Reset()27 public void Reset() 28 { 29 } 30 ReadDoubleWord(long offset)31 public uint ReadDoubleWord(long offset) 32 { 33 switch((Registers)offset) 34 { 35 case Registers.EUI48L: 36 return (uint)(EUI >> 32); 37 case Registers.EUI48H: 38 return (uint)(EUI & 0xFFFFFFFF); 39 case Registers.UNIQUEL: 40 return (uint)(Unique >> 32); 41 case Registers.UNIQUEH: 42 return (uint)(Unique & 0xFFFFFFFF); 43 case Registers.MSIZE: 44 return (uint)((sramSize << 16) | (flashSize & 0xFFFF)); 45 case Registers.PART: 46 return (uint)((productRevision << 24) | ((byte)deviceFamily << 16) | deviceNumber); 47 case Registers.DEVINFOREV: 48 return 0x01; 49 default: 50 this.LogUnhandledRead(offset); 51 return 0; 52 } 53 } 54 WriteDoubleWord(long offset, uint value)55 public void WriteDoubleWord(long offset, uint value) 56 { 57 this.LogUnhandledWrite(offset, value); 58 } 59 60 public long Size 61 { 62 get 63 { 64 return 0x200; 65 } 66 } 67 68 public ulong EUI { get; set; } 69 70 // This enum contains only used registers. 71 // The rest is platform-dependent. 72 private enum Registers 73 { 74 EUI48L = 0x024, // EUI48 OUI and Unique identifier 75 EUI48H = 0x028, // OUI 76 UNIQUEL = 0x03c, // Low 32 bits of device unique number 77 UNIQUEH = 0x040, // High 32 bits of device unique number 78 MSIZE = 0x044, // Flash and SRAM Memory size in kB 79 PART = 0x048, // Part description 80 DEVINFOREV = 0x04c, // Device information page revision 81 } 82 } 83 } 84