nios2-generic.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. void text_base_hook(void); /* nop hook for text_base.S */
  16. #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
  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. text_base_hook();
  29. #ifdef CONFIG_ALTERA_PIO
  30. #ifdef LED_PIO_BASE
  31. altera_pio_init(LED_PIO_BASE, LED_PIO_WIDTH, 'o',
  32. LED_PIO_RSTVAL, (1 << LED_PIO_WIDTH) - 1,
  33. "led");
  34. #endif
  35. #endif
  36. #if defined(CONFIG_ENV_IS_IN_FLASH) && defined(CONFIG_ENV_ADDR)
  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