diff options
Diffstat (limited to 'drivers/net/fs_enet/mii-fixed.c')
-rw-r--r-- | drivers/net/fs_enet/mii-fixed.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/drivers/net/fs_enet/mii-fixed.c b/drivers/net/fs_enet/mii-fixed.c new file mode 100644 index 000000000000..b3e192d612e5 --- /dev/null +++ b/drivers/net/fs_enet/mii-fixed.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * Combined Ethernet driver for Motorola MPC8xx and MPC82xx. | ||
3 | * | ||
4 | * Copyright (c) 2003 Intracom S.A. | ||
5 | * by Pantelis Antoniou <panto@intracom.gr> | ||
6 | * | ||
7 | * 2005 (c) MontaVista Software, Inc. | ||
8 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
9 | * | ||
10 | * This file is licensed under the terms of the GNU General Public License | ||
11 | * version 2. This program is licensed "as is" without any warranty of any | ||
12 | * kind, whether express or implied. | ||
13 | */ | ||
14 | |||
15 | |||
16 | #include <linux/config.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/types.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/sched.h> | ||
21 | #include <linux/string.h> | ||
22 | #include <linux/ptrace.h> | ||
23 | #include <linux/errno.h> | ||
24 | #include <linux/ioport.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/pci.h> | ||
28 | #include <linux/init.h> | ||
29 | #include <linux/delay.h> | ||
30 | #include <linux/netdevice.h> | ||
31 | #include <linux/etherdevice.h> | ||
32 | #include <linux/skbuff.h> | ||
33 | #include <linux/spinlock.h> | ||
34 | #include <linux/mii.h> | ||
35 | #include <linux/ethtool.h> | ||
36 | #include <linux/bitops.h> | ||
37 | |||
38 | #include <asm/pgtable.h> | ||
39 | #include <asm/irq.h> | ||
40 | #include <asm/uaccess.h> | ||
41 | |||
42 | #include "fs_enet.h" | ||
43 | |||
44 | static const u16 mii_regs[7] = { | ||
45 | 0x3100, | ||
46 | 0x786d, | ||
47 | 0x0fff, | ||
48 | 0x0fff, | ||
49 | 0x01e1, | ||
50 | 0x45e1, | ||
51 | 0x0003, | ||
52 | }; | ||
53 | |||
54 | static int mii_read(struct fs_enet_mii_bus *bus, int phy_id, int location) | ||
55 | { | ||
56 | int ret = 0; | ||
57 | |||
58 | if ((unsigned int)location >= ARRAY_SIZE(mii_regs)) | ||
59 | return -1; | ||
60 | |||
61 | if (location != 5) | ||
62 | ret = mii_regs[location]; | ||
63 | else | ||
64 | ret = bus->fixed.lpa; | ||
65 | |||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | static void mii_write(struct fs_enet_mii_bus *bus, int phy_id, int location, int val) | ||
70 | { | ||
71 | /* do nothing */ | ||
72 | } | ||
73 | |||
74 | int fs_mii_fixed_init(struct fs_enet_mii_bus *bus) | ||
75 | { | ||
76 | const struct fs_mii_bus_info *bi = bus->bus_info; | ||
77 | |||
78 | bus->fixed.lpa = 0x45e1; /* default 100Mb, full duplex */ | ||
79 | |||
80 | /* if speed is fixed at 10Mb, remove 100Mb modes */ | ||
81 | if (bi->i.fixed.speed == 10) | ||
82 | bus->fixed.lpa &= ~LPA_100; | ||
83 | |||
84 | /* if duplex is half, remove full duplex modes */ | ||
85 | if (bi->i.fixed.duplex == 0) | ||
86 | bus->fixed.lpa &= ~LPA_DUPLEX; | ||
87 | |||
88 | bus->mii_read = mii_read; | ||
89 | bus->mii_write = mii_write; | ||
90 | |||
91 | return 0; | ||
92 | } | ||