summaryrefslogtreecommitdiff
path: root/drivers/net/fs_enet/mii-fixed.c
blob: ae4a9c3bb393abc82aacfbed4ceb50040de4476f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
 * Combined Ethernet driver for Motorola MPC8xx and MPC82xx.
 *
 * Copyright (c) 2003 Intracom S.A. 
 *  by Pantelis Antoniou <panto@intracom.gr>
 * 
 * 2005 (c) MontaVista Software, Inc. 
 * Vitaly Bordug <vbordug@ru.mvista.com>
 *
 * This file is licensed under the terms of the GNU General Public License 
 * version 2. This program is licensed "as is" without any warranty of any 
 * kind, whether express or implied.
 */


#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/ptrace.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/bitops.h>

#include <asm/pgtable.h>
#include <asm/irq.h>
#include <asm/uaccess.h>

#include "fs_enet.h"

static const u16 mii_regs[7] = {
	0x3100,
	0x786d,
	0x0fff,
	0x0fff,
	0x01e1,
	0x45e1,
	0x0003,
};

static int mii_read(struct fs_enet_mii_bus *bus, int phy_id, int location)
{
	int ret = 0;

	if ((unsigned int)location >= ARRAY_SIZE(mii_regs))
		return -1;

	if (location != 5)
		ret = mii_regs[location];
	else
		ret = bus->fixed.lpa;

	return ret;
}

static void mii_write(struct fs_enet_mii_bus *bus, int phy_id, int location, int val)
{
	/* do nothing */
}

int fs_mii_fixed_init(struct fs_enet_mii_bus *bus)
{
	const struct fs_mii_bus_info *bi = bus->bus_info;

	bus->fixed.lpa = 0x45e1;	/* default 100Mb, full duplex */

	/* if speed is fixed at 10Mb, remove 100Mb modes */
	if (bi->i.fixed.speed == 10)
		bus->fixed.lpa &= ~LPA_100;

	/* if duplex is half, remove full duplex modes */
	if (bi->i.fixed.duplex == 0)
		bus->fixed.lpa &= ~LPA_DUPLEX;

	bus->mii_read = mii_read;
	bus->mii_write = mii_write;

	return 0;
}