On Mon, Apr 09, 2018 at 01:53:59PM +0200, Christoph Fritz wrote:
> Add support for Advantech i.MX6 SOM named ROM-7421.
>
> Signed-off-by: Christoph Fritz
> ---
> Changes since v0:
> - distinguish between MMC environment names in pr_notice() board.c
> - rework eMMC partition layout and don't use its hw-bootpartition for now
> - purge writing clock registers
> - rework and simplify lowlevel.c init and use imx6q_barebox_entry(fdt)
> - s/linux,stdout-path/stdout-path in dts
> - rework and simplify spi nor partition layout
> - remove additional pinctrl subnode from dts
> - remove setting of explicit ARCH_TEXT_BASE in Kconfig
> - use bitop Macro for ar8035_phy_fixup()
> - use imx_setup_pad() for early debug uart
> ---
Applied, thanks
Sascha
> arch/arm/boards/Makefile | 1 +
> arch/arm/boards/advantech-mx6/Makefile | 2 +
> arch/arm/boards/advantech-mx6/board.c | 101 +
> .../flash-header-advantech-rom-7421.imxcfg | 66 ++
> arch/arm/boards/advantech-mx6/lowlevel.c | 56 +
> arch/arm/configs/imx_v7_defconfig | 1 +
> arch/arm/dts/Makefile | 1 +
> arch/arm/dts/imx6dl-advantech-rom-7421.dts | 225
> +
> arch/arm/mach-imx/Kconfig | 5 +
> images/Makefile.imx| 5 +
> 10 files changed, 463 insertions(+)
> create mode 100644 arch/arm/boards/advantech-mx6/Makefile
> create mode 100644 arch/arm/boards/advantech-mx6/board.c
> create mode 100644
> arch/arm/boards/advantech-mx6/flash-header-advantech-rom-7421.imxcfg
> create mode 100644 arch/arm/boards/advantech-mx6/lowlevel.c
> create mode 100755 arch/arm/dts/imx6dl-advantech-rom-7421.dts
>
> diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
> index ca187cc..521f37d 100644
> --- a/arch/arm/boards/Makefile
> +++ b/arch/arm/boards/Makefile
> @@ -1,4 +1,5 @@
> # keep sorted by CONFIG_* macro name.
> +obj-$(CONFIG_MACH_ADVANTECH_ROM_742X)+= advantech-mx6/
> obj-$(CONFIG_MACH_AFI_GF)+= afi-gf/
> obj-$(CONFIG_MACH_ANIMEO_IP) += animeo_ip/
> obj-$(CONFIG_MACH_ARCHOSG9) += archosg9/
> diff --git a/arch/arm/boards/advantech-mx6/Makefile
> b/arch/arm/boards/advantech-mx6/Makefile
> new file mode 100644
> index 000..01c7a25
> --- /dev/null
> +++ b/arch/arm/boards/advantech-mx6/Makefile
> @@ -0,0 +1,2 @@
> +obj-y += board.o
> +lwl-y += lowlevel.o
> diff --git a/arch/arm/boards/advantech-mx6/board.c
> b/arch/arm/boards/advantech-mx6/board.c
> new file mode 100644
> index 000..4a30a84
> --- /dev/null
> +++ b/arch/arm/boards/advantech-mx6/board.c
> @@ -0,0 +1,101 @@
> +/*
> + * Copyright (C) 2018 Christoph Fritz
> + *
> + * 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
> +#include
> +#include
> +#include
> +#include
> +
> +static int ar8035_phy_fixup(struct phy_device *dev)
> +{
> + u16 val;
> +
> + /* Ar803x phy SmartEEE feature cause link status generates glitch,
> + * which cause ethernet link down/up issue, so disable SmartEEE
> + */
> + phy_write(dev, 0xd, 0x3);
> + phy_write(dev, 0xe, 0x805d);
> + phy_write(dev, 0xd, 0x4003);
> +
> + val = phy_read(dev, 0xe);
> + phy_write(dev, 0xe, val & ~BIT(8));
> +
> + /* To enable AR8031 ouput a 125MHz clk from CLK_25M */
> + phy_write(dev, 0xd, 0x7);
> + phy_write(dev, 0xe, 0x8016);
> + phy_write(dev, 0xd, 0x4007);
> +
> + val = phy_read(dev, 0xe);
> + val &= 0xffe3;
> + val |= 0x18;
> + phy_write(dev, 0xe, val);
> +
> + /* introduce tx clock delay */
> + phy_write(dev, 0x1d, 0x5);
> + val = phy_read(dev, 0x1e);
> + val |= 0x0100;
> + phy_write(dev, 0x1e, val);
> +
> + return 0;
> +}
> +
> +static int advantech_mx6_devices_init(void)
> +{
> + int ret;
> + char *environment_path, *envdev;
> +
> + if (!of_machine_is_compatible("advantech,imx6dl-rom-7421"))
> + return 0;
> +
> + phy_register_fixup_for_uid(0x004dd072, 0xffef, ar8035_phy_fixup);
> +
> + switch (bootsource_get()) {
> + case BOOTSOURCE_MMC:
> + environment_path = basprintf("/chosen/environment-sd%d",
> + bootsource_get_instance() + 1);
> + if (bootsource_get_instance() + 1 == 4)
> +