id.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. id.c
  5. Abstract:
  6. This module implements support for getting the OMAP4 chip revision.
  7. Author:
  8. Evan Green 1-Apr-2014
  9. Environment:
  10. Firmware
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include <uefifw.h>
  16. #include "init.h"
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. #define OMAP4_CONTROL_ID_REGISTER 0x4A002204
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. /*++
  25. Structure Description:
  26. This structure defines the mapping between an OMAP4 revision code and its
  27. register value.
  28. Members:
  29. Revision - Stores the revision number.
  30. Value - Stores the value found in the ID register for the revision number.
  31. --*/
  32. typedef struct _OMAP4_REVISION_VALUE {
  33. OMAP4_REVISION Revision;
  34. UINT32 Value;
  35. } OMAP4_REVISION_VALUE, *POMAP4_REVISION_VALUE;
  36. //
  37. // ----------------------------------------------- Internal Function Prototypes
  38. //
  39. //
  40. // -------------------------------------------------------------------- Globals
  41. //
  42. OMAP4_REVISION_VALUE EfiOmap4RevisionValues[] = {
  43. {Omap4430RevisionEs10, 0x0B85202F},
  44. {Omap4430RevisionEs20, 0x1B85202F},
  45. {Omap4430RevisionEs21, 0x3B95C02F},
  46. {Omap4430RevisionEs22, 0x4B95C02F},
  47. {Omap4430RevisionEs23, 0x6B95C02F},
  48. {Omap4460RevisionEs10, 0x0B94E02F},
  49. {Omap4460RevisionEs11, 0x2B94E02F}
  50. };
  51. //
  52. // ------------------------------------------------------------------ Functions
  53. //
  54. OMAP4_REVISION
  55. EfipOmap4GetRevision (
  56. VOID
  57. )
  58. /*++
  59. Routine Description:
  60. This routine returns the OMAP4 revision number.
  61. Arguments:
  62. None.
  63. Return Value:
  64. Returns the SoC revision value.
  65. --*/
  66. {
  67. UINT32 Code;
  68. UINTN CodeCount;
  69. UINTN Index;
  70. Code = OMAP4_READ32(OMAP4_CONTROL_ID_REGISTER);
  71. CodeCount = sizeof(EfiOmap4RevisionValues) /
  72. sizeof(EfiOmap4RevisionValues[0]);
  73. for (Index = 0; Index < CodeCount; Index += 1) {
  74. if (EfiOmap4RevisionValues[Index].Value == Code) {
  75. return EfiOmap4RevisionValues[Index].Revision;
  76. }
  77. }
  78. return Omap4RevisionInvalid;
  79. }
  80. //
  81. // --------------------------------------------------------- Internal Functions
  82. //