ax25-ae350.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2017 Andes Technology Corporation
  4. * Rick Chen, Andes Technology Corporation <rick@andestech.com>
  5. */
  6. #include <common.h>
  7. #include <flash.h>
  8. #include <init.h>
  9. #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
  10. #include <netdev.h>
  11. #endif
  12. #include <linux/io.h>
  13. #include <faraday/ftsmc020.h>
  14. #include <fdtdec.h>
  15. #include <dm.h>
  16. #include <spl.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. extern phys_addr_t prior_stage_fdt_address;
  19. /*
  20. * Miscellaneous platform dependent initializations
  21. */
  22. int board_init(void)
  23. {
  24. gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
  25. return 0;
  26. }
  27. int dram_init(void)
  28. {
  29. return fdtdec_setup_mem_size_base();
  30. }
  31. int dram_init_banksize(void)
  32. {
  33. return fdtdec_setup_memory_banksize();
  34. }
  35. #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
  36. int board_eth_init(bd_t *bd)
  37. {
  38. return ftmac100_initialize(bd);
  39. }
  40. #endif
  41. ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
  42. {
  43. return 0;
  44. }
  45. void *board_fdt_blob_setup(void)
  46. {
  47. return (void *)CONFIG_SYS_FDT_BASE;
  48. }
  49. int smc_init(void)
  50. {
  51. int node = -1;
  52. const char *compat = "andestech,atfsmc020";
  53. void *blob = (void *)gd->fdt_blob;
  54. fdt_addr_t addr;
  55. struct ftsmc020_bank *regs;
  56. node = fdt_node_offset_by_compatible(blob, -1, compat);
  57. if (node < 0)
  58. return -FDT_ERR_NOTFOUND;
  59. addr = fdtdec_get_addr(blob, node, "reg");
  60. if (addr == FDT_ADDR_T_NONE)
  61. return -EINVAL;
  62. regs = (struct ftsmc020_bank *)addr;
  63. regs->cr &= ~FTSMC020_BANK_WPROT;
  64. return 0;
  65. }
  66. static void v5l2_init(void)
  67. {
  68. struct udevice *dev;
  69. uclass_get_device(UCLASS_CACHE, 0, &dev);
  70. }
  71. #ifdef CONFIG_BOARD_EARLY_INIT_F
  72. int board_early_init_f(void)
  73. {
  74. smc_init();
  75. v5l2_init();
  76. return 0;
  77. }
  78. #endif
  79. #ifdef CONFIG_SPL
  80. void board_boot_order(u32 *spl_boot_list)
  81. {
  82. u8 i;
  83. u32 boot_devices[] = {
  84. #ifdef CONFIG_SPL_RAM_SUPPORT
  85. BOOT_DEVICE_RAM,
  86. #endif
  87. #ifdef CONFIG_SPL_MMC_SUPPORT
  88. BOOT_DEVICE_MMC1,
  89. #endif
  90. };
  91. for (i = 0; i < ARRAY_SIZE(boot_devices); i++)
  92. spl_boot_list[i] = boot_devices[i];
  93. }
  94. #endif
  95. #ifdef CONFIG_SPL_LOAD_FIT
  96. int board_fit_config_name_match(const char *name)
  97. {
  98. /* boot using first FIT config */
  99. return 0;
  100. }
  101. #endif