blob: 263dac810693fbab05fda2c266b583eb996a776d [file] [log] [blame]
wdenkeb20ad32003-09-05 23:19:14 +00001/*
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
26#include <common.h>
27
28#if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI) && \
29 defined(CONFIG_SK98)
30
31#include "h/skdrv1st.h"
32#include "h/skdrv2nd.h"
33#include "u-boot_compat.h"
34
35
36#define SKGE_MAX_CARDS 2
37
38
39extern int skge_probe(struct eth_device **);
40extern void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
41extern void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
42extern int SkGeOpen(struct eth_device *);
43extern int SkGeClose(struct eth_device *);
44extern int SkGeXmit(struct sk_buff *skb, struct eth_device *dev);
45extern void ReceiveIrq(SK_AC *pAC, RX_PORT *pRxPort, SK_BOOL SlowPathLock);
46
47static int skge_init(struct eth_device *dev, bd_t * bis);
48static int skge_send(struct eth_device *dev, volatile void *packet, int length);
49static int skge_recv(struct eth_device *dev);
50static void skge_halt(struct eth_device *dev);
51
52int skge_initialize(bd_t * bis)
53{
54 int numdev, i;
55 struct eth_device *dev[SKGE_MAX_CARDS];
56
57 numdev = skge_probe(&dev[0]);
58
59 if (numdev > SKGE_MAX_CARDS)
60 {
61 printf("ERROR: numdev > SKGE_MAX_CARDS\n");
62 }
63
64 for (i = 0; i < numdev; i++)
65 {
66 sprintf (dev[i]->name, "SK98#%d", i);
67
68 dev[i]->init = skge_init;
69 dev[i]->halt = skge_halt;
70 dev[i]->send = skge_send;
71 dev[i]->recv = skge_recv;
72
73 eth_register(dev[i]);
74 }
75
76 return numdev;
77}
78
79
80static int skge_init(struct eth_device *dev, bd_t * bis)
81{
82 int ret;
83 SK_AC * pAC = ((DEV_NET*)dev->priv)->pAC;
84 int i;
85
86 ret = SkGeOpen(dev);
87
88 while (pAC->Rlmt.Port[0].PortState != SK_RLMT_PS_GOING_UP)
89 {
90 SkGeIsrOnePort (0, pAC->dev[0], 0);
91 }
92
93 for (i = 0; i < 100; i ++)
94 {
95 udelay(1000);
96 }
97
98 return ret;
99}
100
101
102static void skge_halt(struct eth_device *dev)
103{
104 SkGeClose(dev);
105}
106
107
108static int skge_send(struct eth_device *dev, volatile void *packet,
wdenk9c53f402003-10-15 23:53:47 +0000109 int length)
wdenkeb20ad32003-09-05 23:19:14 +0000110{
111 int ret = -1;
112 struct sk_buff * skb = alloc_skb(length, 0);
113
114 if (! skb)
115 {
116 printf("skge_send: failed to alloc skb\n");
117 goto Done;
118 }
119
120 memcpy(skb->data, (void*)packet, length);
121 ret = SkGeXmit(skb, dev);
122
123Done:
124 return ret;
125}
126
127
128static int skge_recv(struct eth_device *dev)
129{
130 DEV_NET *pNet;
131 SK_AC *pAC;
132 int FromPort = 0;
133
134 pNet = (DEV_NET*) dev->priv;
135 pAC = pNet->pAC;
136
137 ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE);
138
139 return 0;
140}
141
142
143#endif /* CONFIG_SK98 */