ulcb.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * board/renesas/ulcb/ulcb.c
  4. * This file is ULCB board support.
  5. *
  6. * Copyright (C) 2017 Renesas Electronics Corporation
  7. */
  8. #include <common.h>
  9. #include <image.h>
  10. #include <init.h>
  11. #include <malloc.h>
  12. #include <netdev.h>
  13. #include <dm.h>
  14. #include <asm/global_data.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/bitops.h>
  20. #include <linux/errno.h>
  21. #include <asm/arch/sys_proto.h>
  22. #include <asm/gpio.h>
  23. #include <asm/arch/gpio.h>
  24. #include <asm/arch/rmobile.h>
  25. #include <asm/arch/rcar-mstp.h>
  26. #include <asm/arch/sh_sdhi.h>
  27. #include <i2c.h>
  28. #include <mmc.h>
  29. DECLARE_GLOBAL_DATA_PTR;
  30. #define DVFS_MSTP926 BIT(26)
  31. #define HSUSB_MSTP704 BIT(4) /* HSUSB */
  32. int board_early_init_f(void)
  33. {
  34. #if defined(CONFIG_SYS_I2C_LEGACY) && defined(CONFIG_SYS_I2C_SH)
  35. /* DVFS for reset */
  36. mstp_clrbits_le32(SMSTPCR9, SMSTPCR9, DVFS_MSTP926);
  37. #endif
  38. return 0;
  39. }
  40. /* HSUSB block registers */
  41. #define HSUSB_REG_LPSTS 0xE6590102
  42. #define HSUSB_REG_LPSTS_SUSPM_NORMAL BIT(14)
  43. #define HSUSB_REG_UGCTRL2 0xE6590184
  44. #define HSUSB_REG_UGCTRL2_USB0SEL 0x30
  45. #define HSUSB_REG_UGCTRL2_USB0SEL_EHCI 0x10
  46. int board_init(void)
  47. {
  48. /* adress of boot parameters */
  49. gd->bd->bi_boot_params = CONFIG_SYS_TEXT_BASE + 0x50000;
  50. /* USB1 pull-up */
  51. setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
  52. /* Configure the HSUSB block */
  53. mstp_clrbits_le32(SMSTPCR7, SMSTPCR7, HSUSB_MSTP704);
  54. /* Choice USB0SEL */
  55. clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
  56. HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
  57. /* low power status */
  58. setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
  59. return 0;
  60. }
  61. #ifdef CONFIG_MULTI_DTB_FIT
  62. int board_fit_config_name_match(const char *name)
  63. {
  64. /* PRR driver is not available yet */
  65. u32 cpu_type = rmobile_get_cpu_type();
  66. if ((cpu_type == RMOBILE_CPU_TYPE_R8A7795) &&
  67. !strcmp(name, "r8a77950-ulcb-u-boot"))
  68. return 0;
  69. if ((cpu_type == RMOBILE_CPU_TYPE_R8A7796) &&
  70. !strcmp(name, "r8a77960-ulcb-u-boot"))
  71. return 0;
  72. if ((cpu_type == RMOBILE_CPU_TYPE_R8A77965) &&
  73. !strcmp(name, "r8a77965-ulcb-u-boot"))
  74. return 0;
  75. return -1;
  76. }
  77. #endif