bcm28155_ap.c 2.6 KB

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