uboot_drv.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Driver for SysKonnect Gigabit Ethernet Server Adapters.
  3. *
  4. * (C) Copyright 2003
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #if defined(CONFIG_CMD_NET) && defined(CONFIG_NET_MULTI) && \
  27. defined(CONFIG_SK98)
  28. #include "h/skdrv1st.h"
  29. #include "h/skdrv2nd.h"
  30. #include "u-boot_compat.h"
  31. #define SKGE_MAX_CARDS 2
  32. extern int skge_probe(struct eth_device **);
  33. extern void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
  34. extern void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
  35. extern int SkGeOpen(struct eth_device *);
  36. extern int SkGeClose(struct eth_device *);
  37. extern int SkGeXmit(struct sk_buff *skb, struct eth_device *dev);
  38. extern void ReceiveIrq(SK_AC *pAC, RX_PORT *pRxPort, SK_BOOL SlowPathLock);
  39. static int skge_init(struct eth_device *dev, bd_t * bis);
  40. static int skge_send(struct eth_device *dev, volatile void *packet, int length);
  41. static int skge_recv(struct eth_device *dev);
  42. static void skge_halt(struct eth_device *dev);
  43. int skge_initialize(bd_t * bis)
  44. {
  45. int numdev, i;
  46. struct eth_device *dev[SKGE_MAX_CARDS];
  47. numdev = skge_probe(&dev[0]);
  48. if (numdev > SKGE_MAX_CARDS)
  49. {
  50. printf("ERROR: numdev > SKGE_MAX_CARDS\n");
  51. }
  52. for (i = 0; i < numdev; i++)
  53. {
  54. sprintf (dev[i]->name, "SK98#%d", i);
  55. dev[i]->init = skge_init;
  56. dev[i]->halt = skge_halt;
  57. dev[i]->send = skge_send;
  58. dev[i]->recv = skge_recv;
  59. eth_register(dev[i]);
  60. }
  61. return numdev;
  62. }
  63. static int skge_init(struct eth_device *dev, bd_t * bis)
  64. {
  65. int ret;
  66. SK_AC * pAC = ((DEV_NET*)dev->priv)->pAC;
  67. int i;
  68. ret = SkGeOpen(dev);
  69. while (pAC->Rlmt.Port[0].PortState != SK_RLMT_PS_GOING_UP)
  70. {
  71. SkGeIsrOnePort (0, pAC->dev[0], 0);
  72. }
  73. for (i = 0; i < 100; i ++)
  74. {
  75. udelay(1000);
  76. }
  77. return ret;
  78. }
  79. static void skge_halt(struct eth_device *dev)
  80. {
  81. SkGeClose(dev);
  82. }
  83. static int skge_send(struct eth_device *dev, volatile void *packet,
  84. int length)
  85. {
  86. int ret = -1;
  87. struct sk_buff * skb = alloc_skb(length, 0);
  88. if (! skb)
  89. {
  90. printf("skge_send: failed to alloc skb\n");
  91. goto Done;
  92. }
  93. memcpy(skb->data, (void*)packet, length);
  94. ret = SkGeXmit(skb, dev);
  95. Done:
  96. return ret;
  97. }
  98. static int skge_recv(struct eth_device *dev)
  99. {
  100. DEV_NET *pNet;
  101. SK_AC *pAC;
  102. int FromPort = 0;
  103. pNet = (DEV_NET*) dev->priv;
  104. pAC = pNet->pAC;
  105. ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE);
  106. return 0;
  107. }
  108. #endif /* CONFIG_SK98 */