1 // 2 // Copyright (c) 2010-2023 Antmicro 3 // 4 // This file is licensed under the MIT License. 5 // Full license text is available in 'licenses/MIT.txt'. 6 // 7 using System; 8 using System.Collections.Generic; 9 using Antmicro.Renode.Core; 10 using Antmicro.Renode.Core.Structure.Registers; 11 using Antmicro.Renode.Peripherals.Bus; 12 13 namespace Antmicro.Renode.Peripherals.Miscellaneous 14 { 15 [AllowedTranslations(AllowedTranslation.ByteToWord | AllowedTranslation.WordToByte)] 16 public class NPCX_LFCG : BasicWordPeripheral, IKnownSize 17 { NPCX_LFCG(IMachine machine)18 public NPCX_LFCG(IMachine machine) : base(machine) 19 { 20 DefineRegisters(); 21 Reset(); 22 } 23 24 public long Size => 0x100; 25 DefineRegisters()26 private void DefineRegisters() 27 { 28 Registers.Control.Define(this) 29 .WithReservedBits(0, 2) 30 .WithTag("LREFEN (LPC Clock Reference Enable)", 2, 1) 31 .WithTag("LFLER (LFCG Locked on External Reference)", 3, 1) 32 .WithTag("UDCP (Update Calibration Parameters)", 4, 1) 33 .WithTag("LFLOC (LFCG Register Write Lock)", 5, 1) 34 .WithReservedBits(6, 1) 35 .WithTag("XTCLK_VAL (XTOSC Clock Valid)", 7, 1) 36 .WithReservedBits(8, 8); 37 38 Registers.HighFrequencyReferenceDivisorI.Define(this) 39 .WithTag("HFRDI (High-Frequency Reference Divisor I)", 0, 12). 40 WithReservedBits(12, 4); 41 42 Registers.HighFrequencyReferenceDivisorF.Define(this) 43 .WithTag("HFRDF (High-Frequency Reference Divisor F)", 0, 16); 44 45 Registers.ClockDivisor.Define(this) 46 .WithTag("FRCDIV (FRCLK Clock Divisor)", 0, 8) 47 .WithReservedBits(8, 8); 48 49 Registers.DivisorCorrectionValue1.Define(this) 50 .WithTag("DIVCOR1 (Divisor Correction Value 1)", 0, 8) 51 .WithReservedBits(8, 8); 52 53 Registers.DivisorCorrectionValue2.Define(this) 54 .WithTag("DIVCOR2 (Divisor Correction Value 2)", 0, 8) 55 .WithReservedBits(8, 8); 56 57 Registers.Control2.Define(this) 58 .WithReservedBits(0, 3) 59 .WithTag("AUDP_EN (Automatic Update Enable)", 3, 1) 60 .WithTag("STOPCAL (Stop Calibration to External Reference)", 4, 1) 61 .WithTag("FCLKRUN (Force PCI_CLK Running)", 5, 1) 62 .WithTag("XT_OSC_SL_EN (Crystal Oscillator Selection Enable)", 6, 1) 63 .WithReservedBits(7, 1) 64 .WithReservedBits(8, 8); 65 } 66 67 private enum Registers 68 { 69 Control = 0x0, 70 HighFrequencyReferenceDivisorI = 0x2, 71 HighFrequencyReferenceDivisorF = 0x4, 72 ClockDivisor = 0x6, 73 DivisorCorrectionValue1 = 0x8, 74 DivisorCorrectionValue2 = 0xA, 75 Control2 = 0x14 76 } 77 } 78 } 79