summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mx6/mx6_fec.c
diff options
context:
space:
mode:
authorFugang Duan <B38611@freescale.com>2011-11-08 15:54:47 +0800
committerNitin Garg <nitin.garg@freescale.com>2014-06-03 21:45:51 -0500
commita59b7642baa65a06ce742c99b5f0b05db5ba0457 (patch)
treecfcee9c86083265b54bf50f70ffaa751adee9262 /arch/arm/mach-mx6/mx6_fec.c
parent640214dab7901045f8ba578d8ce3bec7c4adfddd (diff)
ENGR00161617 - [MX6] : FEC get MAC address from OCOTP.
- FEC get the default MAC address from OCOTP. - If the MAC address is all zero, get the random address. - But, if add para "fec_mac=xx:xx:xx:xx:xx:xx" in uboot, FEC will get the last MAC address from uboot para. Signed-off-by: Fugang Duan <B38611@freescale.com>
Diffstat (limited to 'arch/arm/mach-mx6/mx6_fec.c')
-rw-r--r--arch/arm/mach-mx6/mx6_fec.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/arm/mach-mx6/mx6_fec.c b/arch/arm/mach-mx6/mx6_fec.c
new file mode 100644
index 000000000000..9d3c82442ace
--- /dev/null
+++ b/arch/arm/mach-mx6/mx6_fec.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * 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-imx6q.h"
+
+#define HW_OCOTP_MACn(n) (0x00000250 + (n) * 0x10)
+
+static int fec_get_mac_addr(unsigned char *mac)
+{
+ unsigned int value;
+
+ value = readl(MX6_IO_ADDRESS(OCOTP_BASE_ADDR) + HW_OCOTP_MACn(0));
+ mac[5] = value & 0xff;
+ mac[4] = (value >> 8) & 0xff;
+ mac[3] = (value >> 16) & 0xff;
+ mac[2] = (value >> 24) & 0xff;
+ value = readl(MX6_IO_ADDRESS(OCOTP_BASE_ADDR) + HW_OCOTP_MACn(1));
+ mac[1] = value & 0xff;
+ mac[0] = (value >> 8) & 0xff;
+
+ return 0;
+}
+
+void imx6_init_fec(struct fec_platform_data fec_data)
+{
+ fec_get_mac_addr(fec_data.mac);
+ if (!is_valid_ether_addr(fec_data.mac))
+ random_ether_addr(fec_data.mac);
+
+ imx6q_add_fec(&fec_data);
+}