salvator-x.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 <cpu_func.h>
  11. #include <image.h>
  12. #include <malloc.h>
  13. #include <netdev.h>
  14. #include <dm.h>
  15. #include <dm/platform_data/serial_sh.h>
  16. #include <asm/processor.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/io.h>
  19. #include <linux/errno.h>
  20. #include <asm/arch/sys_proto.h>
  21. #include <asm/gpio.h>
  22. #include <asm/arch/gpio.h>
  23. #include <asm/arch/rmobile.h>
  24. #include <asm/arch/rcar-mstp.h>
  25. #include <asm/arch/sh_sdhi.h>
  26. #include <i2c.h>
  27. #include <mmc.h>
  28. DECLARE_GLOBAL_DATA_PTR;
  29. void s_init(void)
  30. {
  31. }
  32. #define DVFS_MSTP926 BIT(26)
  33. #define HSUSB_MSTP704 BIT(4) /* HSUSB */
  34. int board_early_init_f(void)
  35. {
  36. #if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_SH)
  37. /* DVFS for reset */
  38. mstp_clrbits_le32(SMSTPCR9, SMSTPCR9, DVFS_MSTP926);
  39. #endif
  40. return 0;
  41. }
  42. /* HSUSB block registers */
  43. #define HSUSB_REG_LPSTS 0xE6590102
  44. #define HSUSB_REG_LPSTS_SUSPM_NORMAL BIT(14)
  45. #define HSUSB_REG_UGCTRL2 0xE6590184
  46. #define HSUSB_REG_UGCTRL2_USB0SEL 0x30
  47. #define HSUSB_REG_UGCTRL2_USB0SEL_EHCI 0x10
  48. int board_init(void)
  49. {
  50. /* adress of boot parameters */
  51. gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
  52. /* USB1 pull-up */
  53. setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
  54. /* Configure the HSUSB block */
  55. mstp_clrbits_le32(SMSTPCR7, SMSTPCR7, HSUSB_MSTP704);
  56. /* Choice USB0SEL */
  57. clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
  58. HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
  59. /* low power status */
  60. setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
  61. return 0;
  62. }
  63. #define RST_BASE 0xE6160000
  64. #define RST_CA57RESCNT (RST_BASE + 0x40)
  65. #define RST_CA53RESCNT (RST_BASE + 0x44)
  66. #define RST_RSTOUTCR (RST_BASE + 0x58)
  67. #define RST_CODE 0xA5A5000F
  68. void reset_cpu(ulong addr)
  69. {
  70. #if defined(CONFIG_SYS_I2C) && defined(CONFIG_SYS_I2C_SH)
  71. i2c_reg_write(CONFIG_SYS_I2C_POWERIC_ADDR, 0x20, 0x80);
  72. #else
  73. /* only CA57 ? */
  74. writel(RST_CODE, RST_CA57RESCNT);
  75. #endif
  76. }
  77. #ifdef CONFIG_MULTI_DTB_FIT
  78. int board_fit_config_name_match(const char *name)
  79. {
  80. /* PRR driver is not available yet */
  81. u32 cpu_type = rmobile_get_cpu_type();
  82. if ((cpu_type == RMOBILE_CPU_TYPE_R8A7795) &&
  83. !strcmp(name, "r8a77950-salvator-x-u-boot"))
  84. return 0;
  85. if ((cpu_type == RMOBILE_CPU_TYPE_R8A7796) &&
  86. !strcmp(name, "r8a77960-salvator-x-u-boot"))
  87. return 0;
  88. if ((cpu_type == RMOBILE_CPU_TYPE_R8A77965) &&
  89. !strcmp(name, "r8a77965-salvator-x-u-boot"))
  90. return 0;
  91. return -1;
  92. }
  93. #endif