r8169: the MMIO region of the 8167 stands behin BAR#1
[pandora-kernel.git] / drivers / net / fs_enet / mii-fixed.c
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/module.h>
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
20 #include <linux/string.h>
21 #include <linux/ptrace.h>
22 #include <linux/errno.h>
23 #include <linux/ioport.h>
24 #include <linux/slab.h>
25 #include <linux/interrupt.h>
26 #include <linux/pci.h>
27 #include <linux/init.h>
28 #include <linux/delay.h>
29 #include <linux/netdevice.h>
30 #include <linux/etherdevice.h>
31 #include <linux/skbuff.h>
32 #include <linux/spinlock.h>
33 #include <linux/mii.h>
34 #include <linux/ethtool.h>
35 #include <linux/bitops.h>
36
37 #include <asm/pgtable.h>
38 #include <asm/irq.h>
39 #include <asm/uaccess.h>
40
41 #include "fs_enet.h"
42
43 static const u16 mii_regs[7] = {
44         0x3100,
45         0x786d,
46         0x0fff,
47         0x0fff,
48         0x01e1,
49         0x45e1,
50         0x0003,
51 };
52
53 static int mii_read(struct fs_enet_mii_bus *bus, int phy_id, int location)
54 {
55         int ret = 0;
56
57         if ((unsigned int)location >= ARRAY_SIZE(mii_regs))
58                 return -1;
59
60         if (location != 5)
61                 ret = mii_regs[location];
62         else
63                 ret = bus->fixed.lpa;
64
65         return ret;
66 }
67
68 static void mii_write(struct fs_enet_mii_bus *bus, int phy_id, int location, int val)
69 {
70         /* do nothing */
71 }
72
73 int fs_mii_fixed_init(struct fs_enet_mii_bus *bus)
74 {
75         const struct fs_mii_bus_info *bi = bus->bus_info;
76
77         bus->fixed.lpa = 0x45e1;        /* default 100Mb, full duplex */
78
79         /* if speed is fixed at 10Mb, remove 100Mb modes */
80         if (bi->i.fixed.speed == 10)
81                 bus->fixed.lpa &= ~LPA_100;
82
83         /* if duplex is half, remove full duplex modes */
84         if (bi->i.fixed.duplex == 0)
85                 bus->fixed.lpa &= ~LPA_DUPLEX;
86
87         bus->mii_read = mii_read;
88         bus->mii_write = mii_write;
89
90         return 0;
91 }