9
0
Fork 0
barebox/arch/arm/boards/phytec-phyflex-imx6/board.c

85 lines
2.0 KiB
C

/*
* Copyright (C) 2013 Sascha Hauer, Pengutronix
*
* 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.
*
*/
#include <common.h>
#include <gpio.h>
#include <init.h>
#include <of.h>
#include <mach/bbu.h>
#include <fec.h>
#include <linux/micrel_phy.h>
#include <mach/imx6.h>
#define ETH_PHY_RST IMX_GPIO_NR(3, 23)
static int eth_phy_reset(void)
{
gpio_request(ETH_PHY_RST, "phy reset");
gpio_direction_output(ETH_PHY_RST, 0);
mdelay(1);
gpio_set_value(ETH_PHY_RST, 1);
return 0;
}
static void mmd_write_reg(struct phy_device *dev, int device, int reg, int val)
{
phy_write(dev, 0x0d, device);
phy_write(dev, 0x0e, reg);
phy_write(dev, 0x0d, (1 << 14) | device);
phy_write(dev, 0x0e, val);
}
static int ksz9031rn_phy_fixup(struct phy_device *dev)
{
mmd_write_reg(dev, 2, 8, 0x039F);
return 0;
}
static int phytec_pfla02_init(void)
{
if (!of_machine_is_compatible("phytec,imx6q-pfla02") &&
!of_machine_is_compatible("phytec,imx6dl-pfla02") &&
!of_machine_is_compatible("phytec,imx6s-pfla02"))
return 0;
eth_phy_reset();
phy_register_fixup_for_uid(PHY_ID_KSZ9031, MICREL_PHY_ID_MASK,
ksz9031rn_phy_fixup);
imx6_bbu_nand_register_handler("nand", BBU_HANDLER_FLAG_DEFAULT);
return 0;
}
device_initcall(phytec_pfla02_init);
static int phytec_pfla02_core_init(void)
{
if (!of_machine_is_compatible("phytec,imx6x-pbab01"))
return 0;
imx6_init_lowlevel();
return 0;
}
postcore_initcall(phytec_pfla02_core_init);