ulcb.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. /* USB1 pull-up */
  49. setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
  50. /* Configure the HSUSB block */
  51. mstp_clrbits_le32(SMSTPCR7, SMSTPCR7, HSUSB_MSTP704);
  52. /* Choice USB0SEL */
  53. clrsetbits_le32(HSUSB_REG_UGCTRL2, HSUSB_REG_UGCTRL2_USB0SEL,
  54. HSUSB_REG_UGCTRL2_USB0SEL_EHCI);
  55. /* low power status */
  56. setbits_le16(HSUSB_REG_LPSTS, HSUSB_REG_LPSTS_SUSPM_NORMAL);
  57. return 0;
  58. }
  59. #ifdef CONFIG_MULTI_DTB_FIT
  60. int board_fit_config_name_match(const char *name)
  61. {
  62. /* PRR driver is not available yet */
  63. u32 cpu_type = rmobile_get_cpu_type();
  64. if ((cpu_type == RMOBILE_CPU_TYPE_R8A7795) &&
  65. !strcmp(name, "r8a77950-ulcb-u-boot"))
  66. return 0;
  67. if ((cpu_type == RMOBILE_CPU_TYPE_R8A7796) &&
  68. !strcmp(name, "r8a77960-ulcb-u-boot"))
  69. return 0;
  70. if ((cpu_type == RMOBILE_CPU_TYPE_R8A77965) &&
  71. !strcmp(name, "r8a77965-ulcb-u-boot"))
  72. return 0;
  73. return -1;
  74. }
  75. #endif