bcm28155_ap.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright 2013 Broadcom Corporation.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <asm/io.h>
  8. #include <asm/mach-types.h>
  9. #include <mmc.h>
  10. #include <asm/kona-common/kona_sdhci.h>
  11. #include <asm/kona-common/clk.h>
  12. #include <asm/arch/sysmap.h>
  13. #include <usb.h>
  14. #include <usb/dwc2_udc.h>
  15. #include <g_dnl.h>
  16. #define SECWATCHDOG_SDOGCR_OFFSET 0x00000000
  17. #define SECWATCHDOG_SDOGCR_EN_SHIFT 27
  18. #define SECWATCHDOG_SDOGCR_SRSTEN_SHIFT 26
  19. #define SECWATCHDOG_SDOGCR_CLKS_SHIFT 20
  20. #define SECWATCHDOG_SDOGCR_LD_SHIFT 0
  21. #ifndef CONFIG_USB_SERIALNO
  22. #define CONFIG_USB_SERIALNO "1234567890"
  23. #endif
  24. DECLARE_GLOBAL_DATA_PTR;
  25. /*
  26. * board_init - early hardware init
  27. */
  28. int board_init(void)
  29. {
  30. printf("Relocation Offset is: %08lx\n", gd->reloc_off);
  31. /* adress of boot parameters */
  32. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  33. clk_init();
  34. return 0;
  35. }
  36. /*
  37. * misc_init_r - miscellaneous platform dependent initializations
  38. */
  39. int misc_init_r(void)
  40. {
  41. /* Disable watchdog reset - watchdog unused */
  42. writel((0 << SECWATCHDOG_SDOGCR_EN_SHIFT) |
  43. (0 << SECWATCHDOG_SDOGCR_SRSTEN_SHIFT) |
  44. (4 << SECWATCHDOG_SDOGCR_CLKS_SHIFT) |
  45. (0x5a0 << SECWATCHDOG_SDOGCR_LD_SHIFT),
  46. (SECWD_BASE_ADDR + SECWATCHDOG_SDOGCR_OFFSET));
  47. return 0;
  48. }
  49. /*
  50. * dram_init - sets uboots idea of sdram size
  51. */
  52. int dram_init(void)
  53. {
  54. gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
  55. CONFIG_SYS_SDRAM_SIZE);
  56. return 0;
  57. }
  58. /* This is called after dram_init() so use get_ram_size result */
  59. void dram_init_banksize(void)
  60. {
  61. gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  62. gd->bd->bi_dram[0].size = gd->ram_size;
  63. }
  64. #ifdef CONFIG_KONA_SDHCI
  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 (!getenv("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