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