cpu_info-rcar.c 1.7 KB

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