dnp5370.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * U-boot - main board file
  3. *
  4. * (C) Copyright 2010 3ality Digital Systems
  5. *
  6. * Copyright (c) 2005-2008 Analog Devices Inc.
  7. *
  8. * (C) Copyright 2000-2004
  9. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  27. * MA 02110-1301 USA
  28. */
  29. #include <common.h>
  30. #include <config.h>
  31. #include <asm/blackfin.h>
  32. #include <asm/net.h>
  33. #include <net.h>
  34. #include <netdev.h>
  35. #include <asm/gpio.h>
  36. static void disable_external_watchdog(void)
  37. {
  38. #ifdef CONFIG_DNP5370_EXT_WD_DISABLE
  39. /* disable external HW watchdog with PH13 = WD1 = 1 */
  40. gpio_request(GPIO_PH13, "ext_wd");
  41. gpio_direction_output(GPIO_PH13, 1);
  42. #endif
  43. }
  44. int checkboard(void)
  45. {
  46. printf("Board: SSV DilNet DNP5370\n");
  47. return 0;
  48. }
  49. #ifdef CONFIG_BFIN_MAC
  50. static void board_init_enetaddr(uchar *mac_addr)
  51. {
  52. #ifdef CONFIG_SYS_NO_FLASH
  53. # define USE_MAC_IN_FLASH 0
  54. #else
  55. # define USE_MAC_IN_FLASH 1
  56. #endif
  57. bool valid_mac = false;
  58. if (USE_MAC_IN_FLASH) {
  59. /* we cram the MAC in the last flash sector */
  60. uchar *board_mac_addr = (uchar *)0x202F0000;
  61. if (is_valid_ether_addr(board_mac_addr)) {
  62. memcpy(mac_addr, board_mac_addr, 6);
  63. valid_mac = true;
  64. }
  65. }
  66. if (!valid_mac) {
  67. puts("Warning: Generating 'random' MAC address\n");
  68. bfin_gen_rand_mac(mac_addr);
  69. }
  70. eth_setenv_enetaddr("ethaddr", mac_addr);
  71. }
  72. int board_eth_init(bd_t *bis)
  73. {
  74. return bfin_EMAC_initialize(bis);
  75. }
  76. #endif
  77. /* miscellaneous platform dependent initialisations */
  78. int misc_init_r(void)
  79. {
  80. disable_external_watchdog();
  81. #ifdef CONFIG_BFIN_MAC
  82. uchar enetaddr[6];
  83. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  84. board_init_enetaddr(enetaddr);
  85. #endif
  86. #ifndef CONFIG_SYS_NO_FLASH
  87. /* we use the last sector for the MAC address / POST LDR */
  88. extern flash_info_t flash_info[];
  89. flash_protect(FLAG_PROTECT_SET, 0x202F0000, 0x202FFFFF, &flash_info[0]);
  90. #endif
  91. return 0;
  92. }