/**************************************************************************
* I.MX6 MAC Address hacking
* 说明:
* 本文记录I.MX6驱动是如何获取MAC地址的。
*
* 2016-6-24 深圳 南山平山村 曾剑锋
**************************************************************************/
/*
* initialize __mach_desc_MX6Q_SABRESD data structure.
*/
MACHINE_START(MX6Q_SABRESD, "Freescale i.MX 6Quad/DualLite/Solo Sabre-SD Board")
/* Maintainer: Freescale Semiconductor, Inc. */
.boot_params = MX6_PHYS_OFFSET + 0x100,
.fixup = fixup_mxc_board,
.map_io = mx6_map_io,
.init_irq = mx6_init_irq,
.init_machine = mx6_sabresd_board_init, --------------+
.timer = &mx6_sabresd_timer, |
.reserve = mx6q_sabresd_reserve, |
MACHINE_END |
|
|
static void __init mx6_sabresd_board_init(void) <-------------+
{
......
imx6_init_fec(fec_data); --------------------+
...... |
} |
|
void __init 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); |
|
if (cpu_is_mx6sl()) |
imx6sl_add_fec(&fec_data); |
else |
imx6q_add_fec(&fec_data); |
} |
|
static int fec_get_mac_addr(unsigned char *mac) <----------+
{
unsigned int value;
value = readl(MX6_IO_ADDRESS(OCOTP_BASE_ADDR) + HW_OCOTP_MACn());
mac[] = value & 0xff;
mac[] = (value >> ) & 0xff;
mac[] = (value >> ) & 0xff;
mac[] = (value >> ) & 0xff;
value = readl(MX6_IO_ADDRESS(OCOTP_BASE_ADDR) + HW_OCOTP_MACn());
mac[] = value & 0xff;
mac[] = (value >> ) & 0xff;
return ;
}