nios2-generic.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * (C) Copyright 2005, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.com>
  4. * (C) Copyright 2010, Thomas Chou <thomas@wytron.com.tw>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <netdev.h>
  10. #if defined(CONFIG_CFI_FLASH_MTD)
  11. #include <mtd/cfi_flash.h>
  12. #endif
  13. #include <asm/io.h>
  14. #include <asm/gpio.h>
  15. #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
  16. defined(CONFIG_CFI_FLASH_MTD)
  17. static void __early_flash_cmd_reset(void)
  18. {
  19. /* reset flash before we read env */
  20. writeb(AMD_CMD_RESET, CONFIG_ENV_ADDR);
  21. writeb(FLASH_CMD_RESET, CONFIG_ENV_ADDR);
  22. }
  23. void early_flash_cmd_reset(void)
  24. __attribute__((weak,alias("__early_flash_cmd_reset")));
  25. #endif
  26. int board_early_init_f(void)
  27. {
  28. #ifdef CONFIG_ALTERA_PIO
  29. #ifdef LED_PIO_BASE
  30. altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
  31. LED_PIO_RSTVAL, (1 << LED_PIO_WIDTH) - 1,
  32. "led");
  33. #endif
  34. #endif
  35. #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR) && \
  36. defined(CONFIG_CFI_FLASH_MTD)
  37. early_flash_cmd_reset();
  38. #endif
  39. return 0;
  40. }
  41. int checkboard(void)
  42. {
  43. printf("BOARD : %s\n", CONFIG_BOARD_NAME);
  44. return 0;
  45. }
  46. phys_size_t initdram(int board_type)
  47. {
  48. return 0;
  49. }
  50. #ifdef CONFIG_CMD_NET
  51. int board_eth_init(bd_t *bis)
  52. {
  53. int rc = 0;
  54. #ifdef CONFIG_SMC91111
  55. rc += smc91111_initialize(0, CONFIG_SMC91111_BASE);
  56. #endif
  57. #ifdef CONFIG_DRIVER_DM9000
  58. rc += dm9000_initialize(bis);
  59. #endif
  60. #ifdef CONFIG_ALTERA_TSE
  61. rc += altera_tse_initialize(0,
  62. CONFIG_SYS_ALTERA_TSE_MAC_BASE,
  63. CONFIG_SYS_ALTERA_TSE_SGDMA_RX_BASE,
  64. CONFIG_SYS_ALTERA_TSE_SGDMA_TX_BASE,
  65. #if defined(CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_BASE) && \
  66. (CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_SIZE > 0)
  67. CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_BASE,
  68. CONFIG_SYS_ALTERA_TSE_SGDMA_DESC_SIZE);
  69. #else
  70. 0,
  71. 0);
  72. #endif
  73. #endif
  74. #ifdef CONFIG_ETHOC
  75. rc += ethoc_initialize(0, CONFIG_SYS_ETHOC_BASE);
  76. #endif
  77. return rc;
  78. }
  79. #endif