draak.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * board/renesas/draak/draak.c
  4. * This file is Draak 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 CPGWPCR 0xE6150904
  27. #define CPGWPR 0xE615090C
  28. #define CLK2MHZ(clk) (clk / 1000 / 1000)
  29. void s_init(void)
  30. {
  31. struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE;
  32. struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE;
  33. /* Watchdog init */
  34. writel(0xA5A5A500, &rwdt->rwtcsra);
  35. writel(0xA5A5A500, &swdt->swtcsra);
  36. writel(0xA5A50000, CPGWPCR);
  37. writel(0xFFFFFFFF, CPGWPR);
  38. }
  39. #define GSX_MSTP112 BIT(12) /* 3DG */
  40. #define TMU0_MSTP125 BIT(25) /* secure */
  41. #define TMU1_MSTP124 BIT(24) /* non-secure */
  42. #define SCIF2_MSTP310 BIT(10) /* SCIF2 */
  43. #define DVFS_MSTP926 BIT(26)
  44. #define HSUSB_MSTP704 BIT(4) /* HSUSB */
  45. int board_early_init_f(void)
  46. {
  47. /* TMU0,1 */ /* which use ? */
  48. mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125 | TMU1_MSTP124);
  49. #if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_SH)
  50. /* DVFS for reset */
  51. mstp_clrbits_le32(MSTPSR9, SMSTPCR9, DVFS_MSTP926);
  52. #endif
  53. return 0;
  54. }
  55. /* SYSC */
  56. /* R/- 32 Power status register 2(3DG) */
  57. #define SYSC_PWRSR2 0xE6180100
  58. /* -/W 32 Power resume control register 2 (3DG) */
  59. #define SYSC_PWRONCR2 0xE618010C
  60. /* HSUSB block registers */
  61. #define HSUSB_REG_LPSTS 0xE6590102
  62. #define HSUSB_REG_LPSTS_SUSPM_NORMAL BIT(14)
  63. #define HSUSB_REG_UGCTRL2 0xE6590184
  64. #define HSUSB_REG_UGCTRL2_USB0SEL 0x30
  65. #define HSUSB_REG_UGCTRL2_USB0SEL_EHCI 0x10
  66. int board_init(void)
  67. {
  68. /* adress of boot parameters */
  69. gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
  70. /* USB1 pull-up */
  71. setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
  72. /* Configure the HSUSB block */
  73. mstp_clrbits_le32(MSTPSR7, SMSTPCR7, HSUSB_MSTP704);
  74. /* Choice USB0SEL */
  75. clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
  76. HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
  77. /* low power status */
  78. setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
  79. return 0;
  80. }
  81. int dram_init(void)
  82. {
  83. if (fdtdec_setup_memory_size() != 0)
  84. return -EINVAL;
  85. return 0;
  86. }
  87. int dram_init_banksize(void)
  88. {
  89. fdtdec_setup_memory_banksize();
  90. return 0;
  91. }
  92. #define RST_BASE 0xE6160000
  93. #define RST_CA57RESCNT (RST_BASE + 0x40)
  94. #define RST_CA53RESCNT (RST_BASE + 0x44)
  95. #define RST_RSTOUTCR (RST_BASE + 0x58)
  96. #define RST_CA57_CODE 0xA5A5000F
  97. #define RST_CA53_CODE 0x5A5A000F
  98. void reset_cpu(ulong addr)
  99. {
  100. unsigned long midr, cputype;
  101. asm volatile("mrs %0, midr_el1" : "=r" (midr));
  102. cputype = (midr >> 4) & 0xfff;
  103. if (cputype == 0xd03)
  104. writel(RST_CA53_CODE, RST_CA53RESCNT);
  105. else if (cputype == 0xd07)
  106. writel(RST_CA57_CODE, RST_CA57RESCNT);
  107. else
  108. hang();
  109. }