hc
2024-03-22 a0752693d998599af469473b8dc239ef973a012f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/** @Soc.c
  SoC specific Library containg functions to initialize various SoC components
 
  Copyright 2018-2020 NXP
 
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
**/
 
#include <Base.h>
#include <Library/ChassisLib.h>
#include <Library/DebugLib.h>
#include <Library/SocLib.h>
#include <Soc.h>
 
/**
  Return the input clock frequency to an IP Module.
  This function reads the RCW bits and calculates the  PLL multiplier/divider
  values to be applied to various IP modules.
  If a module is disabled or doesn't exist on platform, then return zero.
 
  @param[in]  BaseClock  Base clock to which PLL multiplier/divider values is
                         to be applied.
  @param[in]  ClockType  Variable of Type NXP_IP_CLOCK. Indicates which IP clock
                         is to be retrieved.
  @param[in]  Args       Variable argument list which is parsed based on
                         ClockType. e.g. if the ClockType is NXP_I2C_CLOCK, then
                         the second argument will be interpreted as controller
                         number. e.g. if there are four i2c controllers in SOC,
                         then this value can be 0, 1, 2, 3
                         e.g. if ClockType is NXP_CORE_CLOCK, then second
                         argument is interpreted as cluster number and third
                         argument is interpreted as core number (within the
                         cluster)
 
  @return                Actual Clock Frequency. Return value 0 should be
                         interpreted as clock not being provided to IP.
**/
UINT64
SocGetClock (
  IN  UINT64        BaseClock,
  IN  NXP_IP_CLOCK  ClockType,
  IN  VA_LIST       Args
  )
{
  LX2160A_DEVICE_CONFIG  *Dcfg;
  UINT32                 RcwSr;
  UINT64                 ReturnValue;
 
  ReturnValue = 0;
  Dcfg = (LX2160A_DEVICE_CONFIG  *)LX2160A_DCFG_ADDRESS;
 
  switch (ClockType) {
  case NXP_UART_CLOCK:
    RcwSr = DcfgRead32 ((UINTN)&Dcfg->RcwSr[0]);
    ReturnValue = (BaseClock * SYS_PLL_RAT (RcwSr)) >> 3;
    break;
  case NXP_I2C_CLOCK:
    RcwSr = DcfgRead32 ((UINTN)&Dcfg->RcwSr[0]);
    ReturnValue = (BaseClock * SYS_PLL_RAT (RcwSr)) >> 4;
    break;
  default:
    break;
  }
 
  return ReturnValue;
}
 
/**
  Function to get SoC's System Version Register(SVR)
 **/
UINT32
SocGetSvr (
  VOID
  )
{
  LX2160A_DEVICE_CONFIG  *DeviceConfig;
 
  DeviceConfig = (LX2160A_DEVICE_CONFIG  *)LX2160A_DCFG_ADDRESS;
  return DcfgRead32 ((UINTN)&DeviceConfig->Svr);
}
 
/**
  Function to initialize SoC specific constructs
 **/
VOID
SocInit (
  VOID
  )
{
  ChassisInit ();
 
  return;
}