ax25-ae350.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 <asm/mach-types.h>
  7. #include <common.h>
  8. #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
  9. #include <netdev.h>
  10. #endif
  11. #include <linux/io.h>
  12. #include <faraday/ftsmc020.h>
  13. #include <fdtdec.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. /*
  16. * Miscellaneous platform dependent initializations
  17. */
  18. int board_init(void)
  19. {
  20. gd->bd->bi_arch_number = MACH_TYPE_AE350;
  21. gd->bd->bi_boot_params = PHYS_SDRAM_0 + 0x400;
  22. return 0;
  23. }
  24. int dram_init(void)
  25. {
  26. unsigned long sdram_base = PHYS_SDRAM_0;
  27. unsigned long expected_size = PHYS_SDRAM_0_SIZE + PHYS_SDRAM_1_SIZE;
  28. unsigned long actual_size;
  29. actual_size = get_ram_size((void *)sdram_base, expected_size);
  30. gd->ram_size = actual_size;
  31. if (expected_size != actual_size) {
  32. printf("Warning: Only %lu of %lu MiB SDRAM is working\n",
  33. actual_size >> 20, expected_size >> 20);
  34. }
  35. return 0;
  36. }
  37. int dram_init_banksize(void)
  38. {
  39. gd->bd->bi_dram[0].start = PHYS_SDRAM_0;
  40. gd->bd->bi_dram[0].size = PHYS_SDRAM_0_SIZE;
  41. gd->bd->bi_dram[1].start = PHYS_SDRAM_1;
  42. gd->bd->bi_dram[1].size = PHYS_SDRAM_1_SIZE;
  43. return 0;
  44. }
  45. #if defined(CONFIG_FTMAC100) && !defined(CONFIG_DM_ETH)
  46. int board_eth_init(bd_t *bd)
  47. {
  48. return ftmac100_initialize(bd);
  49. }
  50. #endif
  51. ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)
  52. {
  53. return 0;
  54. }
  55. void *board_fdt_blob_setup(void)
  56. {
  57. void **ptr = (void *)CONFIG_SYS_SDRAM_BASE;
  58. if (fdt_magic(*ptr) == FDT_MAGIC)
  59. return (void *)*ptr;
  60. return (void *)CONFIG_SYS_FDT_BASE;
  61. }
  62. int smc_init(void)
  63. {
  64. int node = -1;
  65. const char *compat = "andestech,atfsmc020";
  66. void *blob = (void *)gd->fdt_blob;
  67. fdt_addr_t addr;
  68. struct ftsmc020_bank *regs;
  69. node = fdt_node_offset_by_compatible(blob, -1, compat);
  70. if (node < 0)
  71. return -FDT_ERR_NOTFOUND;
  72. addr = fdtdec_get_addr(blob, node, "reg");
  73. if (addr == FDT_ADDR_T_NONE)
  74. return -EINVAL;
  75. regs = (struct ftsmc020_bank *)addr;
  76. regs->cr &= ~FTSMC020_BANK_WPROT;
  77. return 0;
  78. }
  79. #ifdef CONFIG_BOARD_EARLY_INIT_F
  80. int board_early_init_f(void)
  81. {
  82. smc_init();
  83. return 0;
  84. }
  85. #endif