2012-07-31 12:08:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 Steffen Trumtrar, Pengutronix
|
|
|
|
*
|
|
|
|
* based on arch/arm/boards/freescale-mx6-arm2/board.c
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <environment.h>
|
2012-10-11 07:09:29 +00:00
|
|
|
#include <mach/imx6-regs.h>
|
2012-07-31 12:08:00 +00:00
|
|
|
#include <fec.h>
|
2013-08-16 10:26:17 +00:00
|
|
|
#include <gpio.h>
|
2013-11-18 11:06:37 +00:00
|
|
|
#include <mach/bbu.h>
|
2012-07-31 12:08:00 +00:00
|
|
|
#include <asm/armlinux.h>
|
|
|
|
#include <generated/mach-types.h>
|
|
|
|
#include <partition.h>
|
2012-08-09 07:49:51 +00:00
|
|
|
#include <linux/phy.h>
|
2012-07-31 12:08:00 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/mmu.h>
|
|
|
|
#include <mach/generic.h>
|
|
|
|
#include <sizes.h>
|
|
|
|
#include <net.h>
|
2013-05-27 09:54:57 +00:00
|
|
|
#include <linux/micrel_phy.h>
|
2012-07-31 12:08:00 +00:00
|
|
|
#include <mach/imx6.h>
|
|
|
|
#include <mach/devices-imx6.h>
|
|
|
|
#include <mach/iomux-mx6.h>
|
|
|
|
#include <spi/spi.h>
|
|
|
|
#include <mach/spi.h>
|
2012-09-15 13:56:25 +00:00
|
|
|
#include <mach/usb.h>
|
2012-07-31 12:08:00 +00:00
|
|
|
|
2013-05-27 09:54:57 +00:00
|
|
|
static iomux_v3_cfg_t sabrelite_enet_gpio_pads[] = {
|
2012-07-31 12:08:00 +00:00
|
|
|
/* Ethernet */
|
|
|
|
MX6Q_PAD_EIM_D23__GPIO_3_23, /* RGMII_nRST */
|
|
|
|
MX6Q_PAD_RGMII_RXC__GPIO_6_30, /* PHYAD */
|
|
|
|
MX6Q_PAD_RGMII_RD0__GPIO_6_25, /* MODE0 */
|
|
|
|
MX6Q_PAD_RGMII_RD1__GPIO_6_27, /* MODE1 */
|
|
|
|
MX6Q_PAD_RGMII_RD2__GPIO_6_28, /* MODE2 */
|
|
|
|
MX6Q_PAD_RGMII_RD3__GPIO_6_29, /* MODE3 */
|
|
|
|
MX6Q_PAD_RGMII_RX_CTL__GPIO_6_24,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int sabrelite_mem_init(void)
|
|
|
|
{
|
2014-01-21 12:55:18 +00:00
|
|
|
if (!of_machine_is_compatible("fsl,imx6q-sabrelite") &&
|
|
|
|
!of_machine_is_compatible("fsl,imx6dl-sabrelite"))
|
|
|
|
return 0;
|
|
|
|
|
2012-07-31 12:08:00 +00:00
|
|
|
arm_add_mem_device("ram0", 0x10000000, SZ_1G);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
mem_initcall(sabrelite_mem_init);
|
|
|
|
|
2013-05-27 09:54:57 +00:00
|
|
|
static int ksz9021rn_phy_fixup(struct phy_device *dev)
|
2012-07-31 12:08:00 +00:00
|
|
|
{
|
2012-08-09 07:49:51 +00:00
|
|
|
phy_write(dev, 0x09, 0x0f00);
|
2012-07-31 12:08:00 +00:00
|
|
|
|
|
|
|
/* do same as linux kernel */
|
|
|
|
/* min rx data delay */
|
2012-08-09 07:49:51 +00:00
|
|
|
phy_write(dev, 0x0b, 0x8105);
|
|
|
|
phy_write(dev, 0x0c, 0x0000);
|
2012-07-31 12:08:00 +00:00
|
|
|
|
|
|
|
/* max rx/tx clock delay, min rx/tx control delay */
|
2012-08-09 07:49:51 +00:00
|
|
|
phy_write(dev, 0x0b, 0x8104);
|
|
|
|
phy_write(dev, 0x0c, 0xf0f0);
|
|
|
|
phy_write(dev, 0x0b, 0x104);
|
2012-07-31 12:08:00 +00:00
|
|
|
|
2013-05-27 09:54:57 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2012-08-09 07:49:51 +00:00
|
|
|
|
2014-04-03 13:33:47 +00:00
|
|
|
static struct gpio fec_gpios[] = {
|
|
|
|
{
|
|
|
|
.gpio = 87,
|
|
|
|
.flags = GPIOF_OUT_INIT_LOW,
|
|
|
|
.label = "phy-rst",
|
|
|
|
}, {
|
|
|
|
.gpio = 190,
|
|
|
|
.flags = GPIOF_OUT_INIT_HIGH,
|
|
|
|
.label = "phy-addr2",
|
|
|
|
}, {
|
|
|
|
.gpio = 23,
|
|
|
|
.flags = GPIOF_OUT_INIT_LOW,
|
|
|
|
.label = "phy-led-mode",
|
|
|
|
}, {
|
|
|
|
/* MODE strap-in pins: advertise all capabilities */
|
|
|
|
.gpio = 185,
|
|
|
|
.flags = GPIOF_OUT_INIT_HIGH,
|
|
|
|
.label = "phy-adv1",
|
|
|
|
}, {
|
|
|
|
.gpio = 187,
|
|
|
|
.flags = GPIOF_OUT_INIT_HIGH,
|
|
|
|
.label = "phy-adv1",
|
|
|
|
}, {
|
|
|
|
.gpio = 188,
|
|
|
|
.flags = GPIOF_OUT_INIT_HIGH,
|
|
|
|
.label = "phy-adv1",
|
|
|
|
}, {
|
|
|
|
.gpio = 189,
|
|
|
|
.flags = GPIOF_OUT_INIT_HIGH,
|
|
|
|
.label = "phy-adv1",
|
|
|
|
}, {
|
|
|
|
/* Enable 125 MHz clock output */
|
|
|
|
.gpio = 184,
|
|
|
|
.flags = GPIOF_OUT_INIT_HIGH,
|
|
|
|
.label = "phy-125MHz",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2012-07-31 12:08:00 +00:00
|
|
|
static int sabrelite_ksz9021rn_setup(void)
|
|
|
|
{
|
2014-04-03 13:33:47 +00:00
|
|
|
int ret;
|
|
|
|
|
2014-01-21 12:55:18 +00:00
|
|
|
if (!of_machine_is_compatible("fsl,imx6q-sabrelite") &&
|
|
|
|
!of_machine_is_compatible("fsl,imx6dl-sabrelite"))
|
|
|
|
return 0;
|
|
|
|
|
2013-05-27 09:54:57 +00:00
|
|
|
mxc_iomux_v3_setup_multiple_pads(sabrelite_enet_gpio_pads,
|
|
|
|
ARRAY_SIZE(sabrelite_enet_gpio_pads));
|
2012-07-31 12:08:00 +00:00
|
|
|
|
2014-04-03 13:33:47 +00:00
|
|
|
ret = gpio_request_array(fec_gpios, ARRAY_SIZE(fec_gpios));
|
|
|
|
if (ret) {
|
|
|
|
pr_err("Failed to request fec gpios: %s\n", strerror(-ret));
|
|
|
|
return ret;
|
|
|
|
}
|
2012-07-31 12:08:00 +00:00
|
|
|
|
|
|
|
mdelay(10);
|
2014-04-03 13:33:47 +00:00
|
|
|
|
|
|
|
/* FEC driver picks up the reset gpio later and releases the phy reset */
|
|
|
|
gpio_free_array(fec_gpios, ARRAY_SIZE(fec_gpios));
|
2012-07-31 12:08:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2013-05-27 09:54:57 +00:00
|
|
|
/*
|
|
|
|
* Do this before the fec initializes but after our
|
|
|
|
* gpios are available.
|
|
|
|
*/
|
|
|
|
fs_initcall(sabrelite_ksz9021rn_setup);
|
2012-07-31 12:08:00 +00:00
|
|
|
|
2012-08-30 12:58:37 +00:00
|
|
|
static void sabrelite_ehci_init(void)
|
|
|
|
{
|
|
|
|
/* hub reset */
|
|
|
|
gpio_direction_output(204, 0);
|
|
|
|
udelay(2000);
|
|
|
|
gpio_set_value(204, 1);
|
|
|
|
}
|
|
|
|
|
2012-07-31 12:08:00 +00:00
|
|
|
static int sabrelite_devices_init(void)
|
|
|
|
{
|
2014-01-13 00:17:28 +00:00
|
|
|
if (!of_machine_is_compatible("fsl,imx6q-sabrelite") &&
|
|
|
|
!of_machine_is_compatible("fsl,imx6dl-sabrelite"))
|
2013-11-18 11:06:32 +00:00
|
|
|
return 0;
|
|
|
|
|
2012-08-30 12:58:37 +00:00
|
|
|
sabrelite_ehci_init();
|
|
|
|
|
2012-07-31 12:08:00 +00:00
|
|
|
armlinux_set_architecture(3769);
|
|
|
|
|
2013-11-18 11:06:37 +00:00
|
|
|
imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox",
|
2014-05-06 07:59:37 +00:00
|
|
|
BBU_HANDLER_FLAG_DEFAULT);
|
2012-07-31 12:08:00 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
device_initcall(sabrelite_devices_init);
|
|
|
|
|
2013-05-27 09:54:57 +00:00
|
|
|
static int sabrelite_coredevices_init(void)
|
2012-07-31 12:08:00 +00:00
|
|
|
{
|
2014-01-13 00:17:28 +00:00
|
|
|
if (!of_machine_is_compatible("fsl,imx6q-sabrelite") &&
|
|
|
|
!of_machine_is_compatible("fsl,imx6dl-sabrelite"))
|
2013-11-18 11:06:32 +00:00
|
|
|
return 0;
|
|
|
|
|
2013-05-27 09:54:57 +00:00
|
|
|
phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK,
|
|
|
|
ksz9021rn_phy_fixup);
|
2012-07-31 12:08:00 +00:00
|
|
|
|
2013-08-15 07:02:17 +00:00
|
|
|
barebox_set_hostname("sabrelite");
|
|
|
|
|
2012-07-31 12:08:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2014-06-24 06:33:14 +00:00
|
|
|
coredevice_initcall(sabrelite_coredevices_init);
|