salvator-x.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * board/renesas/salvator-x/salvator-x.c
  4. * This file is Salvator-X/Salvator-XS board support.
  5. *
  6. * Copyright (C) 2015-2017 Renesas Electronics Corporation
  7. * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
  8. */
  9. #include <common.h>
  10. #include <malloc.h>
  11. #include <netdev.h>
  12. #include <dm.h>
  13. #include <dm/platform_data/serial_sh.h>
  14. #include <asm/processor.h>
  15. #include <asm/mach-types.h>
  16. #include <asm/io.h>
  17. #include <linux/errno.h>
  18. #include <asm/arch/sys_proto.h>
  19. #include <asm/gpio.h>
  20. #include <asm/arch/gpio.h>
  21. #include <asm/arch/rmobile.h>
  22. #include <asm/arch/rcar-mstp.h>
  23. #include <asm/arch/sh_sdhi.h>
  24. #include <i2c.h>
  25. #include <mmc.h>
  26. DECLARE_GLOBAL_DATA_PTR;
  27. #define CPGWPCR 0xE6150904
  28. #define CPGWPR 0xE615090C
  29. #define CLK2MHZ(clk) (clk / 1000 / 1000)
  30. void s_init(void)
  31. {
  32. struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE;
  33. struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE;
  34. /* Watchdog init */
  35. writel(0xA5A5A500, &rwdt->rwtcsra);
  36. writel(0xA5A5A500, &swdt->swtcsra);
  37. writel(0xA5A50000, CPGWPCR);
  38. writel(0xFFFFFFFF, CPGWPR);
  39. }
  40. #define GSX_MSTP112 BIT(12) /* 3DG */
  41. #define TMU0_MSTP125 BIT(25) /* secure */
  42. #define TMU1_MSTP124 BIT(24) /* non-secure */
  43. #define SCIF2_MSTP310 BIT(10) /* SCIF2 */
  44. #define DVFS_MSTP926 BIT(26)
  45. #define HSUSB_MSTP704 BIT(4) /* HSUSB */
  46. int board_early_init_f(void)
  47. {
  48. /* TMU0,1 */ /* which use ? */
  49. mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125 | TMU1_MSTP124);
  50. #if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_SH)
  51. /* DVFS for reset */
  52. mstp_clrbits_le32(MSTPSR9, SMSTPCR9, DVFS_MSTP926);
  53. #endif
  54. return 0;
  55. }
  56. /* SYSC */
  57. /* R/- 32 Power status register 2(3DG) */
  58. #define SYSC_PWRSR2 0xE6180100
  59. /* -/W 32 Power resume control register 2 (3DG) */
  60. #define SYSC_PWRONCR2 0xE618010C
  61. /* HSUSB block registers */
  62. #define HSUSB_REG_LPSTS 0xE6590102
  63. #define HSUSB_REG_LPSTS_SUSPM_NORMAL BIT(14)
  64. #define HSUSB_REG_UGCTRL2 0xE6590184
  65. #define HSUSB_REG_UGCTRL2_USB0SEL 0x30
  66. #define HSUSB_REG_UGCTRL2_USB0SEL_EHCI 0x10
  67. int board_init(void)
  68. {
  69. u32 cpu_type = rmobile_get_cpu_type();
  70. /* adress of boot parameters */
  71. gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
  72. if (cpu_type == RMOBILE_CPU_TYPE_R8A7795) {
  73. /* GSX: force power and clock supply */
  74. writel(0x0000001F, SYSC_PWRONCR2);
  75. while (readl(SYSC_PWRSR2) != 0x000003E0)
  76. mdelay(20);
  77. mstp_clrbits_le32(MSTPSR1, SMSTPCR1, GSX_MSTP112);
  78. }
  79. /* USB1 pull-up */
  80. setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
  81. /* Configure the HSUSB block */
  82. mstp_clrbits_le32(MSTPSR7, SMSTPCR7, HSUSB_MSTP704);
  83. /* Choice USB0SEL */
  84. clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
  85. HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
  86. /* low power status */
  87. setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
  88. return 0;
  89. }
  90. int dram_init(void)
  91. {
  92. if (fdtdec_setup_memory_size() != 0)
  93. return -EINVAL;
  94. return 0;
  95. }
  96. int dram_init_banksize(void)
  97. {
  98. fdtdec_setup_memory_banksize();
  99. return 0;
  100. }
  101. #define RST_BASE 0xE6160000
  102. #define RST_CA57RESCNT (RST_BASE + 0x40)
  103. #define RST_CA53RESCNT (RST_BASE + 0x44)
  104. #define RST_RSTOUTCR (RST_BASE + 0x58)
  105. #define RST_CODE 0xA5A5000F
  106. void reset_cpu(ulong addr)
  107. {
  108. #if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_SH)
  109. i2c_reg_write(CONFIG_SYS_I2C_POWERIC_ADDR, 0x20, 0x80);
  110. #else
  111. /* only CA57 ? */
  112. writel(RST_CODE, RST_CA57RESCNT);
  113. #endif
  114. }