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