bf527-ezkit.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * U-boot - main board file
  3. *
  4. * Copyright (c) 2005-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <common.h>
  9. #include <config.h>
  10. #include <command.h>
  11. #include <net.h>
  12. #include <netdev.h>
  13. #include <asm/blackfin.h>
  14. #include <asm/gpio.h>
  15. #include <asm/net.h>
  16. #include <asm/mach-common/bits/otp.h>
  17. DECLARE_GLOBAL_DATA_PTR;
  18. int checkboard(void)
  19. {
  20. printf("Board: ADI BF527 EZ-Kit board\n");
  21. printf(" Support: http://blackfin.uclinux.org/\n");
  22. return 0;
  23. }
  24. #ifdef CONFIG_BFIN_MAC
  25. static void board_init_enetaddr(uchar *mac_addr)
  26. {
  27. bool valid_mac = false;
  28. /* the MAC is stored in OTP memory page 0xDF */
  29. uint32_t ret;
  30. uint64_t otp_mac;
  31. ret = bfrom_OtpRead(0xDF, OTP_LOWER_HALF, &otp_mac);
  32. if (!(ret & OTP_MASTER_ERROR)) {
  33. uchar *otp_mac_p = (uchar *)&otp_mac;
  34. for (ret = 0; ret < 6; ++ret)
  35. mac_addr[ret] = otp_mac_p[5 - ret];
  36. if (is_valid_ether_addr(mac_addr))
  37. valid_mac = true;
  38. }
  39. if (!valid_mac) {
  40. puts("Warning: Generating 'random' MAC address\n");
  41. bfin_gen_rand_mac(mac_addr);
  42. }
  43. eth_setenv_enetaddr("ethaddr", mac_addr);
  44. }
  45. int board_eth_init(bd_t *bis)
  46. {
  47. return bfin_EMAC_initialize(bis);
  48. }
  49. #endif
  50. int misc_init_r(void)
  51. {
  52. #ifdef CONFIG_BFIN_MAC
  53. uchar enetaddr[6];
  54. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  55. board_init_enetaddr(enetaddr);
  56. #endif
  57. return 0;
  58. }
  59. #ifdef CONFIG_USB_BLACKFIN
  60. void board_musb_init(void)
  61. {
  62. /*
  63. * BF527 EZ-KITs require PG13 to be high for HOST mode
  64. */
  65. gpio_request(GPIO_PG13, "musb-vbus");
  66. gpio_direction_output(GPIO_PG13, 1);
  67. }
  68. #endif