cpu_info-rcar.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/arm/cpu/armv7/rmobile/cpu_info-rcar.c
  4. *
  5. * Copyright (C) 2013,2014 Renesas Electronics Corporation
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #define PRR_MASK 0x7fff
  10. #define R8A7796_REV_1_0 0x5200
  11. #define R8A7796_REV_1_1 0x5210
  12. static u32 rmobile_get_prr(void);
  13. u32 rmobile_get_cpu_type(void)
  14. {
  15. return (rmobile_get_prr() & 0x00007F00) >> 8;
  16. }
  17. u32 rmobile_get_cpu_rev_integer(void)
  18. {
  19. const u32 prr = rmobile_get_prr();
  20. if ((prr & PRR_MASK) == R8A7796_REV_1_1)
  21. return 1;
  22. else
  23. return ((prr & 0x000000F0) >> 4) + 1;
  24. }
  25. u32 rmobile_get_cpu_rev_fraction(void)
  26. {
  27. const u32 prr = rmobile_get_prr();
  28. if ((prr & PRR_MASK) == R8A7796_REV_1_1)
  29. return 1;
  30. else
  31. return prr & 0x0000000F;
  32. }
  33. #if !CONFIG_IS_ENABLED(DM) || !CONFIG_IS_ENABLED(SYSCON)
  34. static u32 rmobile_get_prr(void)
  35. {
  36. /*
  37. * On RCar/RMobile Gen2 and older systems, the PRR is always
  38. * located at the address below. On newer systems, the PRR
  39. * may be located at different address, but that information
  40. * is obtained from DT. This code will be removed when all
  41. * of the older systems get converted to DM and OF control.
  42. */
  43. return readl(0xFF000044);
  44. }
  45. #else
  46. #include <dm.h>
  47. #include <syscon.h>
  48. #include <regmap.h>
  49. struct renesas_prr_priv {
  50. fdt_addr_t regs;
  51. };
  52. enum {
  53. PRR_RCAR,
  54. };
  55. static u32 rmobile_get_prr(void)
  56. {
  57. struct regmap *map;
  58. map = syscon_get_regmap_by_driver_data(PRR_RCAR);
  59. if (!map) {
  60. printf("PRR regmap failed!\n");
  61. hang();
  62. }
  63. return readl(map->ranges[0].start);
  64. }
  65. static const struct udevice_id renesas_prr_ids[] = {
  66. { .compatible = "renesas,prr", .data = PRR_RCAR },
  67. { }
  68. };
  69. U_BOOT_DRIVER(renesas_prr) = {
  70. .name = "renesas_prr",
  71. .id = UCLASS_SYSCON,
  72. .of_match = renesas_prr_ids,
  73. .flags = DM_FLAG_PRE_RELOC,
  74. };
  75. #endif