summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mvf/mvf_fec.c
blob: 0ded64ebed136d4c4e58a218083ba31455018e64 (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
/*
 * Copyright 2012 Freescale Semiconductor, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
#include <linux/fec.h>
#include <linux/etherdevice.h>

#include <mach/common.h>
#include <mach/hardware.h>

#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include "devices-mvf.h"

#define ENET_PALR	0x0e4
#define ENET_PAUR	0x0e8
static unsigned char default_mac[ETH_ALEN] = {
			0x00, 0xe0, 0x0c, 0xbc, 0xe5, 0x60};
/* FEC mac registers set by bootloader */
static int fec_get_mac_addr(unsigned char *mac)
{
	unsigned int value;

	value = readl(MVF_IO_ADDRESS(MVF_FEC_BASE_ADDR) + ENET_PALR);
	mac[3] = value & 0xff;
	mac[2] = (value >> 8) & 0xff;
	mac[1] = (value >> 16) & 0xff;
	mac[0] = (value >> 24) & 0xff;
	value = readl(MVF_IO_ADDRESS(MVF_FEC_BASE_ADDR) + ENET_PAUR);
	mac[5] = (value >> 16) & 0xff;
	mac[4] = (value >> 24) & 0xff;

	return 0;
}

void __init mvf_init_fec(struct fec_platform_data fec_data)
{
	fec_get_mac_addr(fec_data.mac);
	if (!is_valid_ether_addr(fec_data.mac))
		memcpy(fec_data.mac, default_mac, ETH_ALEN);

#if !defined(CONFIG_COLIBRI_VF)
#ifdef CONFIG_FEC0
	mvf_add_fec(0, &mvf_fec_data[0], &fec_data);
#endif
#ifdef CONFIG_FEC1
	mvf_add_fec(1, &mvf_fec_data[1], &fec_data);
#endif
#else
	/* Inverse device ID */
#ifdef CONFIG_FEC1
	mvf_add_fec(0, &mvf_fec_data[1], &fec_data);
#endif
#ifdef CONFIG_FEC0
	mvf_add_fec(1, &mvf_fec_data[0], &fec_data);
#endif
#endif
}