eagle.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * board/renesas/eagle/eagle.c
  4. * This file is Eagle board support.
  5. *
  6. * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas@gmail.com>
  7. */
  8. #include <common.h>
  9. #include <malloc.h>
  10. #include <netdev.h>
  11. #include <dm.h>
  12. #include <dm/platform_data/serial_sh.h>
  13. #include <asm/processor.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/io.h>
  16. #include <linux/errno.h>
  17. #include <asm/arch/sys_proto.h>
  18. #include <asm/gpio.h>
  19. #include <asm/arch/gpio.h>
  20. #include <asm/arch/rmobile.h>
  21. #include <asm/arch/rcar-mstp.h>
  22. #include <asm/arch/sh_sdhi.h>
  23. #include <i2c.h>
  24. #include <mmc.h>
  25. DECLARE_GLOBAL_DATA_PTR;
  26. #define CPGWPR 0xE6150900
  27. #define CPGWPCR 0xE6150904
  28. /* PLL */
  29. #define PLL0CR 0xE61500D8
  30. #define PLL0_STC_MASK 0x7F000000
  31. #define PLL0_STC_OFFSET 24
  32. #define CLK2MHZ(clk) (clk / 1000 / 1000)
  33. void s_init(void)
  34. {
  35. struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE;
  36. struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE;
  37. u32 stc;
  38. /* Watchdog init */
  39. writel(0xA5A5A500, &rwdt->rwtcsra);
  40. writel(0xA5A5A500, &swdt->swtcsra);
  41. /* CPU frequency setting. Set to 0.8GHz */
  42. stc = ((800 / CLK2MHZ(CONFIG_SYS_CLK_FREQ)) - 1) << PLL0_STC_OFFSET;
  43. clrsetbits_le32(PLL0CR, PLL0_STC_MASK, stc);
  44. }
  45. #define TMU0_MSTP125 BIT(25) /* secure */
  46. int board_early_init_f(void)
  47. {
  48. /* Unlock CPG access */
  49. writel(0xA5A5FFFF, CPGWPR);
  50. writel(0x5A5A0000, CPGWPCR);
  51. /* TMU0 */
  52. mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125);
  53. return 0;
  54. }
  55. int board_init(void)
  56. {
  57. /* adress of boot parameters */
  58. gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
  59. return 0;
  60. }
  61. int dram_init(void)
  62. {
  63. if (fdtdec_setup_memory_size() != 0)
  64. return -EINVAL;
  65. return 0;
  66. }
  67. int dram_init_banksize(void)
  68. {
  69. fdtdec_setup_memory_banksize();
  70. return 0;
  71. }
  72. #define RST_BASE 0xE6160000
  73. #define RST_CA57RESCNT (RST_BASE + 0x40)
  74. #define RST_CA53RESCNT (RST_BASE + 0x44)
  75. #define RST_RSTOUTCR (RST_BASE + 0x58)
  76. #define RST_CA57_CODE 0xA5A5000F
  77. #define RST_CA53_CODE 0x5A5A000F
  78. void reset_cpu(ulong addr)
  79. {
  80. unsigned long midr, cputype;
  81. asm volatile("mrs %0, midr_el1" : "=r" (midr));
  82. cputype = (midr >> 4) & 0xfff;
  83. if (cputype == 0xd03)
  84. writel(RST_CA53_CODE, RST_CA53RESCNT);
  85. else if (cputype == 0xd07)
  86. writel(RST_CA57_CODE, RST_CA57RESCNT);
  87. else
  88. hang();
  89. }