Fork of the vendor (Boundary Devices) u-boot for Reform 2, with minor tweaks. The goal is to migrate to mainstream u-boot or barebox ASAP. The main impediment so far is the 4GB RAM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
2.0KB

  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2007 Semihalf
  4. *
  5. * Written by: Rafal Jaworowski <raj@semihalf.com>
  6. */
  7. #include <config.h>
  8. #include <common.h>
  9. #include <net.h>
  10. #include <linux/types.h>
  11. #include <api_public.h>
  12. #define DEBUG
  13. #undef DEBUG
  14. #ifdef DEBUG
  15. #define debugf(fmt, args...) do { printf("%s(): ", __func__); printf(fmt, ##args); } while (0)
  16. #else
  17. #define debugf(fmt, args...)
  18. #endif
  19. #define errf(fmt, args...) do { printf("ERROR @ %s(): ", __func__); printf(fmt, ##args); } while (0)
  20. #if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH)
  21. static int dev_valid_net(void *cookie)
  22. {
  23. return ((void *)eth_get_dev() == cookie) ? 1 : 0;
  24. }
  25. int dev_open_net(void *cookie)
  26. {
  27. if (!dev_valid_net(cookie))
  28. return API_ENODEV;
  29. if (eth_init() < 0)
  30. return API_EIO;
  31. return 0;
  32. }
  33. int dev_close_net(void *cookie)
  34. {
  35. if (!dev_valid_net(cookie))
  36. return API_ENODEV;
  37. eth_halt();
  38. return 0;
  39. }
  40. /*
  41. * There can only be one active eth interface at a time - use what is
  42. * currently set to eth_current
  43. */
  44. int dev_enum_net(struct device_info *di)
  45. {
  46. struct eth_device *eth_current = eth_get_dev();
  47. di->type = DEV_TYP_NET;
  48. di->cookie = (void *)eth_current;
  49. if (di->cookie == NULL)
  50. return 0;
  51. memcpy(di->di_net.hwaddr, eth_current->enetaddr, 6);
  52. debugf("device found, returning cookie 0x%08x\n",
  53. (u_int32_t)di->cookie);
  54. return 1;
  55. }
  56. int dev_write_net(void *cookie, void *buf, int len)
  57. {
  58. /* XXX verify that cookie points to a valid net device??? */
  59. return eth_send(buf, len);
  60. }
  61. int dev_read_net(void *cookie, void *buf, int len)
  62. {
  63. /* XXX verify that cookie points to a valid net device??? */
  64. return eth_receive(buf, len);
  65. }
  66. #else
  67. int dev_open_net(void *cookie)
  68. {
  69. return API_ENODEV;
  70. }
  71. int dev_close_net(void *cookie)
  72. {
  73. return API_ENODEV;
  74. }
  75. int dev_enum_net(struct device_info *di)
  76. {
  77. return 0;
  78. }
  79. int dev_write_net(void *cookie, void *buf, int len)
  80. {
  81. return API_ENODEV;
  82. }
  83. int dev_read_net(void *cookie, void *buf, int len)
  84. {
  85. return API_ENODEV;
  86. }
  87. #endif