bcm28155_ap.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2013 Broadcom Corporation.
  4. */
  5. #include <common.h>
  6. #include <init.h>
  7. #include <log.h>
  8. #include <asm/io.h>
  9. #include <asm/mach-types.h>
  10. #include <env.h>
  11. #include <mmc.h>
  12. #include <asm/kona-common/kona_sdhci.h>
  13. #include <asm/kona-common/clk.h>
  14. #include <asm/arch/sysmap.h>
  15. #include <usb.h>
  16. #include <usb/dwc2_udc.h>
  17. #include <g_dnl.h>
  18. #define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
  19. #define SECWATCHDOG_SDOGCR_EN_SHIFT 27
  20. #define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
  21. #define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
  22. #define SECWATCHDOG_SDOGCR_LD_SHIFT 0
  23. #ifndef CONFIG_USB_SERIALNO
  24. #define CONFIG_USB_SERIALNO "1234567890"
  25. #endif
  26. DECLARE_GLOBAL_DATA_PTR;
  27. /*
  28. * board_init - early hardware init
  29. */
  30. int board_init(void)
  31. {
  32. printf("Relocation Offset is: %08lx\n", gd->reloc_off);
  33. /* adress of boot parameters */
  34. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  35. clk_init();
  36. return 0;
  37. }
  38. /*
  39. * misc_init_r - miscellaneous platform dependent initializations
  40. */
  41. int misc_init_r(void)
  42. {
  43. /* Disable watchdog reset - watchdog unused */
  44. writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
  45. (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
  46. (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
  47. (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
  48. (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
  49. return 0;
  50. }
  51. /*
  52. * dram_init - sets uboots idea of sdram size
  53. */
  54. int dram_init(void)
  55. {
  56. gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
  57. CONFIG_SYS_SDRAM_SIZE);
  58. return 0;
  59. }
  60. /* This is called after dram_init() so use get_ram_size result */
  61. int dram_init_banksize(void)
  62. {
  63. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  64. gd->bd->bi_dram[0].size = gd->ram_size;
  65. return 0;
  66. }
  67. #ifdef CONFIG_MMC_SDHCI_KONA
  68. /*
  69. * mmc_init - Initializes mmc
  70. */
  71. int board_mmc_init(struct bd_info *bis)
  72. {
  73. int ret = 0;
  74. /* Register eMMC - SDIO2 */
  75. ret = kona_sdhci_init(1, 400000, 0);
  76. if (ret)
  77. return ret;
  78. /* Register SD Card - SDIO4 kona_mmc_init assumes 0 based index */
  79. ret = kona_sdhci_init(3, 400000, 0);
  80. return ret;
  81. }
  82. #endif
  83. #ifdef CONFIG_USB_GADGET
  84. static struct dwc2_plat_otg_data bcm_otg_data = {
  85. .regs_otg = HSOTG_BASE_ADDR
  86. };
  87. int board_usb_init(int index, enum usb_init_type init)
  88. {
  89. debug("%s: performing dwc2_udc_probe\n", __func__);
  90. return dwc2_udc_probe(&bcm_otg_data);
  91. }
  92. int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
  93. {
  94. debug("%s\n", __func__);
  95. if (!env_get("serial#"))
  96. g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
  97. return 0;
  98. }
  99. int g_dnl_get_board_bcd_device_number(int gcnum)
  100. {
  101. debug("%s\n", __func__);
  102. return 1;
  103. }
  104. int board_usb_cleanup(int index, enum usb_init_type init)
  105. {
  106. debug("%s\n", __func__);
  107. return 0;
  108. }
  109. #endif