diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2016-08-03 08:08:23 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-08-03 08:08:23 +0200 |
commit | 14e04d019b70cb8711b005bc316ac6a52d61db39 (patch) | |
tree | 0ea694070006e8de3ab372a67cf7c51b6ce9b259 | |
parent | 6a86c6d40468a04c94b859b8b497e6dcff6dcc83 (diff) | |
parent | 74102fdf730b89cbc6dd0fe34c0d9b5f86ed7d8c (diff) | |
download | barebox-14e04d019b70cb8711b005bc316ac6a52d61db39.tar.gz barebox-14e04d019b70cb8711b005bc316ac6a52d61db39.tar.xz |
Merge branch 'for-next/imx'
42 files changed, 524 insertions, 652 deletions
diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 9fc3cd3deb..768c50379f 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -252,6 +252,7 @@ imxcfg-$(CONFIG_MACH_FREESCALE_MX35_3STACK) += $(boarddir)/freescale-mx35-3ds/fl imxcfg-$(CONFIG_MACH_TQMA53) += $(boarddir)/tqma53/flash-header.imxcfg imxcfg-$(CONFIG_MACH_EUKREA_CPUIMX25) += $(boarddir)/eukrea_cpuimx25/flash-header.imxcfg imxcfg-$(CONFIG_MACH_EUKREA_CPUIMX35) += $(boarddir)/eukrea_cpuimx35/flash-header.imxcfg +imxcfg-$(CONFIG_MACH_PCM043) += $(boarddir)/phytec-phycore-imx35/flash-header.imxcfg imxcfg-$(CONFIG_MACH_KINDLE3) += $(boarddir)/kindle3/flash-header.imxcfg imxcfg-$(CONFIG_TX53_REV_1011) += $(boarddir)/karo-tx53/flash-header-tx53-rev1011.imxcfg imxcfg-$(CONFIG_TX53_REV_XX30) += $(boarddir)/karo-tx53/flash-header-tx53-revxx30.imxcfg diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index e3dcc6a615..35b636f0cf 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -15,7 +15,7 @@ obj-$(CONFIG_MACH_BEAGLE) += beagle/ obj-$(CONFIG_MACH_BEAGLEBONE) += beaglebone/ obj-$(CONFIG_MACH_CANON_A1100) += canon-a1100/ obj-$(CONFIG_MACH_CM_FX6) += cm-fx6/ -obj-$(CONFIG_MACH_NITROGEN6X) += boundarydevices-nitrogen6x/ +obj-$(CONFIG_MACH_NITROGEN6) += boundarydevices-nitrogen6/ obj-$(CONFIG_MACH_CCMX51) += ccxmx51/ obj-$(CONFIG_MACH_CCMX53) += ccxmx53/ obj-$(CONFIG_MACH_CFA10036) += crystalfontz-cfa10036/ diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/1066mhz_4x128mx16.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x128mx16.imxcfg index c5a286b4e0..c5a286b4e0 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/1066mhz_4x128mx16.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x128mx16.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/1066mhz_4x256mx16.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x256mx16.imxcfg index 4d8a715150..4d8a715150 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/1066mhz_4x256mx16.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x256mx16.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x512mx16-qp.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x512mx16-qp.imxcfg new file mode 100644 index 0000000000..6409b745d7 --- /dev/null +++ b/arch/arm/boards/boundarydevices-nitrogen6/1066mhz_4x512mx16-qp.imxcfg @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2016 Boundary Devices + * + * 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. + */ + +/* NOC setup */ +wm 32 0x00bb0008 0x00000004 +wm 32 0x00bb000c 0x2891E41A +wm 32 0x00bb0038 0x00000564 +wm 32 0x00bb0014 0x00000040 +wm 32 0x00bb0028 0x00000020 +wm 32 0x00bb002c 0x00000020 + +/* Disable all MMDC arbitration and reordering controls */ +wm 32 0x021b0400 0x14420000 + +wm 32 MX6_MMDC_P0_MDPDC 0x00020036 +wm 32 MX6_MMDC_P0_MDSCR 0x00008000 +wm 32 MX6_MMDC_P0_MDCFG0 0x898E79A4 +wm 32 MX6_MMDC_P0_MDCFG1 0xDB538F64 +wm 32 MX6_MMDC_P0_MDCFG2 0x01FF00DD +wm 32 MX6_MMDC_P0_MDRWD 0x0f9f26d2 +wm 32 MX6_MMDC_P0_MDOR 0x008E1023 +wm 32 MX6_MMDC_P0_MDOTC 0x09444040 +wm 32 MX6_MMDC_P0_MDPDC 0x00025576 +wm 32 MX6_MMDC_P0_MDASP 0x00000047 +wm 32 MX6_MMDC_P0_MDCTL 0xC41A0000 +wm 32 MX6_MMDC_P0_MDSCR 0x04088032 +wm 32 MX6_MMDC_P0_MDSCR 0x0408803a +wm 32 MX6_MMDC_P0_MDSCR 0x00008033 +wm 32 MX6_MMDC_P0_MDSCR 0x0000803b +wm 32 MX6_MMDC_P0_MDSCR 0x00428031 +wm 32 MX6_MMDC_P0_MDSCR 0x00428039 +wm 32 MX6_MMDC_P0_MDSCR 0x19308030 +wm 32 MX6_MMDC_P0_MDSCR 0x19308038 +wm 32 MX6_MMDC_P0_MDSCR 0x04008040 +wm 32 MX6_MMDC_P0_MDSCR 0x04008048 +wm 32 MX6_MMDC_P0_MPZQHWCTRL 0xA1390003 +wm 32 MX6_MMDC_P1_MPZQHWCTRL 0xA1390003 +wm 32 MX6_MMDC_P0_MDREF 0x00007800 +wm 32 MX6_MMDC_P0_MPODTCTRL 0x00022227 +wm 32 MX6_MMDC_P1_MPODTCTRL 0x00022227 +wm 32 MX6_MMDC_P0_MPDGCTRL0 0x4327033b +wm 32 MX6_MMDC_P0_MPDGCTRL1 0x0324031a +wm 32 MX6_MMDC_P1_MPDGCTRL0 0x43240337 +wm 32 MX6_MMDC_P1_MPDGCTRL1 0x03210269 +wm 32 MX6_MMDC_P0_MPRDDLCTL 0x483c3e4a +wm 32 MX6_MMDC_P1_MPRDDLCTL 0x423a3848 +wm 32 MX6_MMDC_P0_MPWRDLCTL 0x33363a2c +wm 32 MX6_MMDC_P1_MPWRDLCTL 0x3e314137 +wm 32 MX6_MMDC_P0_MPWLDECTRL0 0x00200026 +wm 32 MX6_MMDC_P0_MPWLDECTRL1 0x00260021 +wm 32 MX6_MMDC_P1_MPWLDECTRL0 0x00180028 +wm 32 MX6_MMDC_P1_MPWLDECTRL1 0x000f001e +wm 32 MX6_MMDC_P0_MPMUR0 0x00000800 +wm 32 MX6_MMDC_P1_MPMUR0 0x00000800 +wm 32 MX6_MMDC_P0_MDSCR 0x00000000 +wm 32 MX6_MMDC_P0_MAPSR 0x00011006 diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/800mhz_4x128mx16.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/800mhz_4x128mx16.imxcfg index 936a2f54bf..936a2f54bf 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/800mhz_4x128mx16.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/800mhz_4x128mx16.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/800mhz_4x256mx16.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/800mhz_4x256mx16.imxcfg index 09c855544d..09c855544d 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/800mhz_4x256mx16.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/800mhz_4x256mx16.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/Makefile b/arch/arm/boards/boundarydevices-nitrogen6/Makefile index 0ec04ce898..0ec04ce898 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/Makefile +++ b/arch/arm/boards/boundarydevices-nitrogen6/Makefile diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/board.c b/arch/arm/boards/boundarydevices-nitrogen6/board.c index 347fd9128b..d9514d9d48 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/board.c +++ b/arch/arm/boards/boundarydevices-nitrogen6/board.c @@ -22,14 +22,18 @@ static int nitrogen6x_devices_init(void) { - if (!of_machine_is_compatible("fsl,imx6dl-nitrogen6x") && - !of_machine_is_compatible("fsl,imx6q-nitrogen6x")) + if (!of_machine_is_compatible("boundary,imx6dl-nitrogen6x") && + !of_machine_is_compatible("boundary,imx6q-nitrogen6x") && + !of_machine_is_compatible("boundary,imx6qp-nitrogen6_max")) return 0; imx6_bbu_internal_spi_i2c_register_handler("spiflash", "/dev/m25p0.barebox", BBU_HANDLER_FLAG_DEFAULT); - barebox_set_hostname("nitrogen6x"); + if (of_machine_is_compatible("boundary,imx6qp-nitrogen6_max")) + barebox_set_hostname("nitrogen6max"); + else + barebox_set_hostname("nitrogen6x"); return 0; } @@ -54,8 +58,9 @@ static int ksz9021rn_phy_fixup(struct phy_device *dev) static int nitrogen6x_coredevices_init(void) { - if (!of_machine_is_compatible("fsl,imx6dl-nitrogen6x") && - !of_machine_is_compatible("fsl,imx6q-nitrogen6x")) + if (!of_machine_is_compatible("boundary,imx6dl-nitrogen6x") && + !of_machine_is_compatible("boundary,imx6q-nitrogen6x") && + !of_machine_is_compatible("boundary,imx6qp-nitrogen6_max")) return 0; phy_register_fixup_for_uid(PHY_ID_KSZ9021, MICREL_PHY_ID_MASK, diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6dl-1g.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6dl-1g.imxcfg index 0773f4d276..0773f4d276 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6dl-1g.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6dl-1g.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6dl-2g.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6dl-2g.imxcfg index 6622c517fa..6622c517fa 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6dl-2g.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6dl-2g.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6q-1g.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6q-1g.imxcfg index bd4134f8a9..bd4134f8a9 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6q-1g.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6q-1g.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6q-2g.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6q-2g.imxcfg index 89aa21c300..89aa21c300 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/flash-header-nitrogen6q-2g.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6q-2g.imxcfg diff --git a/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6qp-max.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6qp-max.imxcfg new file mode 100644 index 0000000000..66f0e1a860 --- /dev/null +++ b/arch/arm/boards/boundarydevices-nitrogen6/flash-header-nitrogen6qp-max.imxcfg @@ -0,0 +1,10 @@ +soc imx6 +loadaddr 0x20000000 +dcdofs 0x400 + +#include <mach/imx6-ddr-regs.h> +#include <mach/imx6q-ddr-regs.h> +#include <mach/imx6-ccm-regs.h> + +#include "ram-base.imxcfg" +#include "1066mhz_4x512mx16-qp.imxcfg" diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/lowlevel.c b/arch/arm/boards/boundarydevices-nitrogen6/lowlevel.c index 7d859330f9..bee70a5af4 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/lowlevel.c +++ b/arch/arm/boards/boundarydevices-nitrogen6/lowlevel.c @@ -1,7 +1,6 @@ #include <common.h> -#include <linux/sizes.h> #include <mach/generic.h> -#include <asm/barebox-arm-head.h> +#include <mach/esdctl.h> #include <asm/barebox-arm.h> extern char __dtb_imx6q_nitrogen6x_start[]; @@ -14,7 +13,7 @@ ENTRY_FUNCTION(start_imx6q_nitrogen6x_1g, r0, r1, r2) fdt = __dtb_imx6q_nitrogen6x_start - get_runtime_offset(); - barebox_arm_entry(0x10000000, SZ_1G, fdt); + imx6q_barebox_entry(fdt); } ENTRY_FUNCTION(start_imx6q_nitrogen6x_2g, r0, r1, r2) @@ -25,7 +24,7 @@ ENTRY_FUNCTION(start_imx6q_nitrogen6x_2g, r0, r1, r2) fdt = __dtb_imx6q_nitrogen6x_start - get_runtime_offset(); - barebox_arm_entry(0x10000000, SZ_2G, fdt); + imx6q_barebox_entry(fdt); } extern char __dtb_imx6dl_nitrogen6x_start[]; @@ -38,7 +37,7 @@ ENTRY_FUNCTION(start_imx6dl_nitrogen6x_1g, r0, r1, r2) fdt = __dtb_imx6dl_nitrogen6x_start - get_runtime_offset(); - barebox_arm_entry(0x10000000, SZ_1G, fdt); + imx6q_barebox_entry(fdt); } ENTRY_FUNCTION(start_imx6dl_nitrogen6x_2g, r0, r1, r2) @@ -49,5 +48,18 @@ ENTRY_FUNCTION(start_imx6dl_nitrogen6x_2g, r0, r1, r2) fdt = __dtb_imx6dl_nitrogen6x_start - get_runtime_offset(); - barebox_arm_entry(0x10000000, SZ_2G, fdt); + imx6q_barebox_entry(fdt); +} + +extern char __dtb_imx6qp_nitrogen6_max_start[]; + +ENTRY_FUNCTION(start_imx6qp_nitrogen6_max, r0, r1, r2) +{ + void *fdt; + + imx6_cpu_lowlevel_init(); + + fdt = __dtb_imx6qp_nitrogen6_max_start - get_runtime_offset(); + + imx6q_barebox_entry(fdt); } diff --git a/arch/arm/boards/boundarydevices-nitrogen6x/ram-base.imxcfg b/arch/arm/boards/boundarydevices-nitrogen6/ram-base.imxcfg index 60c8fa2b51..5d675883fd 100644 --- a/arch/arm/boards/boundarydevices-nitrogen6x/ram-base.imxcfg +++ b/arch/arm/boards/boundarydevices-nitrogen6/ram-base.imxcfg @@ -60,8 +60,8 @@ wm 32 MX6_MMDC_P1_MPRDDQBY1DL 0x33333333 wm 32 MX6_MMDC_P1_MPRDDQBY2DL 0x33333333 wm 32 MX6_MMDC_P1_MPRDDQBY3DL 0x33333333 -/* MDMISC mirroring interleaved (row/bank/col) */ -wm 32 MX6_MMDC_P0_MDMISC 0x00081740 +/* MDMISC mirroring-off interleaved (row/bank/col) */ +wm 32 MX6_MMDC_P0_MDMISC 0x00001740 /* MDSCR con_req */ wm 32 MX6_MMDC_P0_MDSCR 0x00008000 diff --git a/arch/arm/boards/embest-riotboard/board.c b/arch/arm/boards/embest-riotboard/board.c index a885a08a70..eb956f1f50 100644 --- a/arch/arm/boards/embest-riotboard/board.c +++ b/arch/arm/boards/embest-riotboard/board.c @@ -64,7 +64,7 @@ static int ar8035_phy_fixup(struct phy_device *dev) static int riotboard_device_init(void) { - if (!of_machine_is_compatible("embest,riotboard")) + if (!of_machine_is_compatible("riot,imx6s-riotboard")) return 0; phy_register_fixup_for_uid(0x004dd072, 0xffffffef, ar8035_phy_fixup); diff --git a/arch/arm/boards/phytec-phycore-imx35/flash-header.imxcfg b/arch/arm/boards/phytec-phycore-imx35/flash-header.imxcfg new file mode 100644 index 0000000000..36b68cd7ee --- /dev/null +++ b/arch/arm/boards/phytec-phycore-imx35/flash-header.imxcfg @@ -0,0 +1,37 @@ +soc imx35 +dcdofs 0x400 +loadaddr 0x80000000 +wm 32 0x53f80004 0x00821000 +wm 32 0x53f80004 0x00821000 + +wm 32 0x43fac794 0x00000800 +wm 32 0x43fac798 0x00000800 +wm 32 0x43fac79c 0x00000800 +wm 32 0x43fac7a0 0x00000800 +wm 32 0x43fac7a4 0x00000800 + +wm 32 0xb8001010 0x00000304 +wm 32 0xb8001004 0x0025541f +wm 32 0xb8001000 0x92220000 +wm 32 0x80000400 0x12345678 + +wm 32 0xb8001000 0xb8001000 +wm 8 0x84000000 0xda +wm 8 0x86000000 0xda +wm 8 0x82000400 0xda +wm 8 0x80000333 0xda + +wm 32 0xb8001000 0x92220000 +wm 32 0x80000400 0x12345678 + +wm 32 0xb8001000 0xa2220000 +wm 32 0x80000000 0x12344321 +wm 32 0x80000000 0x12344321 +wm 32 0xb8001000 0xb2220000 +wm 8 0x80000233 0xda +wm 8 0x82000780 0xda +wm 8 0x82000400 0xda +wm 32 0xb8001000 0x82220080 +wm 32 0xb8001000 0x82228080 +wm 32 0xb8001008 0x00002000 + diff --git a/arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/nand b/arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/nand index b9b1bc6c38..ece44b70dc 100644 --- a/arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/nand +++ b/arch/arm/boards/phytec-som-am335x/defaultenv-physom-am335x/boot/nand @@ -1,6 +1,8 @@ #!/bin/sh -global.bootm.image="/dev/nand0.kernel.bb" -global.bootm.oftree="/dev/nand0.oftree.bb" +[ ! -e /dev/nand0.root.ubi ] && ubiattach /dev/nand0.root + +global.bootm.image="/dev/nand0.root.ubi.kernel" +global.bootm.oftree="/dev/nand0.root.ubi.oftree" global.linux.bootargs.dyn.root="root=ubi0:root ubi.mtd=root rw rootfstype=ubifs" diff --git a/arch/arm/configs/imx_v7_defconfig b/arch/arm/configs/imx_v7_defconfig index 8594965b54..e3a8f478d2 100644 --- a/arch/arm/configs/imx_v7_defconfig +++ b/arch/arm/configs/imx_v7_defconfig @@ -18,7 +18,7 @@ CONFIG_MACH_TX6X=y CONFIG_MACH_SABRELITE=y CONFIG_MACH_SABRESD=y CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB=y -CONFIG_MACH_NITROGEN6X=y +CONFIG_MACH_NITROGEN6=y CONFIG_MACH_SOLIDRUN_MICROSOM=y CONFIG_MACH_TECHNEXION_WANDBOARD=y CONFIG_MACH_EMBEST_RIOTBOARD=y diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 813e098145..09bf68ea2b 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -29,7 +29,7 @@ pbl-dtb-$(CONFIG_MACH_GW_VENTANA) += imx6q-gw54xx.dtb.o pbl-dtb-$(CONFIG_MACH_LENOVO_IX4_300D) += armada-xp-lenovo-ix4-300d-bb.dtb.o pbl-dtb-$(CONFIG_MACH_MARVELL_ARMADA_XP_GP) += armada-xp-gp-bb.dtb.o pbl-dtb-$(CONFIG_MACH_NETGEAR_RN104) += armada-370-rn104-bb.dtb.o -pbl-dtb-$(CONFIG_MACH_NITROGEN6X) += imx6q-nitrogen6x.dtb.o imx6dl-nitrogen6x.dtb.o +pbl-dtb-$(CONFIG_MACH_NITROGEN6) += imx6q-nitrogen6x.dtb.o imx6dl-nitrogen6x.dtb.o imx6qp-nitrogen6_max.dtb.o pbl-dtb-$(CONFIG_MACH_NVIDIA_BEAVER) += tegra30-beaver.dtb.o pbl-dtb-$(CONFIG_MACH_NVIDIA_JETSON) += tegra124-jetson-tk1.dtb.o pbl-dtb-$(CONFIG_MACH_PCA100) += imx27-phytec-phycard-s-rdk-bb.dtb.o diff --git a/arch/arm/dts/am335x-phytec-phycard-som.dtsi b/arch/arm/dts/am335x-phytec-phycard-som.dtsi index 3dd9cade43..d608f63e12 100644 --- a/arch/arm/dts/am335x-phytec-phycard-som.dtsi +++ b/arch/arm/dts/am335x-phytec-phycard-som.dtsi @@ -216,22 +216,12 @@ }; partition@1C0000 { - label = "oftree"; - reg = <0x1C0000 0x40000>; - }; - - partition@200000 { - label = "kernel"; - reg = <0x200000 0x800000>; - }; - - partition@A00000 { label = "root"; /* * Size 0x0 extends partition to * end of nand flash. */ - reg = <0xA00000 0x0>; + reg = <0x1C0000 0x0>; }; }; }; diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi b/arch/arm/dts/am335x-phytec-phycore-som.dtsi index 0fc3c96baa..0b8c454143 100644 --- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi +++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi @@ -300,22 +300,12 @@ }; partition@1C0000 { - label = "oftree"; - reg = <0x1C0000 0x40000>; - }; - - partition@200000 { - label = "kernel"; - reg = <0x200000 0x800000>; - }; - - partition@A00000 { label = "root"; /* * Size 0x0 extends partition to * end of nand flash. */ - reg = <0xA00000 0x0>; + reg = <0x1C0000 0x0>; }; }; }; diff --git a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi index db78cb10fd..5b8bb5dda9 100644 --- a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi +++ b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi @@ -314,22 +314,12 @@ }; partition@1C0000 { - label = "oftree"; - reg = <0x1C0000 0x40000>; - }; - - partition@200000 { - label = "kernel"; - reg = <0x200000 0x800000>; - }; - - partition@A00000 { label = "root"; /* * Size 0x0 extends partition to * end of nand flash. */ - reg = <0xA00000 0x0>; + reg = <0x1C0000 0x0>; }; }; }; diff --git a/arch/arm/dts/imx6dl-nitrogen6x.dts b/arch/arm/dts/imx6dl-nitrogen6x.dts index 50267b1038..bc199c3167 100644 --- a/arch/arm/dts/imx6dl-nitrogen6x.dts +++ b/arch/arm/dts/imx6dl-nitrogen6x.dts @@ -11,12 +11,6 @@ * http://www.gnu.org/copyleft/gpl.html */ -/dts-v1/; -#include <arm/imx6dl.dtsi> +#include <arm/imx6dl-nitrogen6x.dts> #include "imx6dl.dtsi" #include "imx6qdl-nitrogen6x.dtsi" - -/ { - model = "Freescale i.MX6 DualLite Nitrogen6x Board"; - compatible = "fsl,imx6dl-nitrogen6x", "fsl,imx6dl"; -}; diff --git a/arch/arm/dts/imx6q-nitrogen6x.dts b/arch/arm/dts/imx6q-nitrogen6x.dts index d8906e6063..e4a6a6c29e 100644 --- a/arch/arm/dts/imx6q-nitrogen6x.dts +++ b/arch/arm/dts/imx6q-nitrogen6x.dts @@ -11,16 +11,6 @@ * http://www.gnu.org/copyleft/gpl.html */ -/dts-v1/; -#include <arm/imx6q.dtsi> +#include <arm/imx6q-nitrogen6x.dts> #include "imx6q.dtsi" #include "imx6qdl-nitrogen6x.dtsi" - -/ { - model = "Freescale i.MX6 Quad Nitrogen6x Board"; - compatible = "fsl,imx6q-nitrogen6x", "fsl,imx6q"; -}; - -&sata { - status = "okay"; -}; diff --git a/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi b/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi new file mode 100644 index 0000000000..26c685c529 --- /dev/null +++ b/arch/arm/dts/imx6qdl-nitrogen6_max.dtsi @@ -0,0 +1,69 @@ +/* + * Copyright 2016 Pengutronix, Lucas Stach + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file 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 file 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. + * + * Or, alternatively, + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/ { + chosen { + environment@0 { + compatible = "barebox,environment"; + device-path = &flash, "partname:barebox-environment"; + }; + }; +}; + +&flash { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "barebox"; + reg = <0x0 0xe0000>; + }; + + partition@e0000 { + label = "barebox-environment"; + reg = <0xe0000 0x20000>; + }; +}; + +&ocotp { + barebox,provide-mac-address = <&fec 0x620>; +};
\ No newline at end of file diff --git a/arch/arm/dts/imx6qdl-nitrogen6x.dtsi b/arch/arm/dts/imx6qdl-nitrogen6x.dtsi index 9ff7395f45..76e55e057c 100644 --- a/arch/arm/dts/imx6qdl-nitrogen6x.dtsi +++ b/arch/arm/dts/imx6qdl-nitrogen6x.dtsi @@ -16,8 +16,6 @@ / { chosen { - linux,stdout-path = &uart2; - environment@0 { compatible = "barebox,environment"; device-path = &flash, "partname:barebox-environment"; diff --git a/arch/arm/dts/imx6qp-nitrogen6_max.dts b/arch/arm/dts/imx6qp-nitrogen6_max.dts new file mode 100644 index 0000000000..93f0741062 --- /dev/null +++ b/arch/arm/dts/imx6qp-nitrogen6_max.dts @@ -0,0 +1,44 @@ +/* + * Copyright 2016 Boundary Devices, Inc. + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file 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 file 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. + * + * Or, alternatively, + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <arm/imx6qp-nitrogen6_max.dts> +#include "imx6qdl-nitrogen6_max.dtsi" diff --git a/arch/arm/dts/imx6s-riotboard.dts b/arch/arm/dts/imx6s-riotboard.dts index 09ac534625..7193f28b76 100644 --- a/arch/arm/dts/imx6s-riotboard.dts +++ b/arch/arm/dts/imx6s-riotboard.dts @@ -4,15 +4,11 @@ * The code contained herein is licensed under the GNU General Public * License version 2. */ -/dts-v1/; -#include <arm/imx6dl.dtsi> -#include "imx6dl.dtsi" +#include <arm/imx6dl-riotboard.dts> +#include "imx6qdl.dtsi" / { - model = "RIoTboard Solo"; - compatible = "embest,riotboard", "fsl,imx6dl"; - chosen { linux,stdout-path = &uart2; @@ -21,210 +17,13 @@ device-path = &environment_usdhc4; }; }; - - memory { - reg = <0x10000000 0x40000000>; - }; - - gpio-leds { - compatible = "gpio-leds"; - - d45 { - label = "d45"; - gpios = <&gpio5 2 1>; - linux,default-trigger = "heartbeat"; - }; - - d46 { - label = "d46"; - gpios = <&gpio3 28 1>; - linux,default-trigger = "default-on"; - }; - }; - - - regulators { - compatible = "simple-bus"; - #address-cells = <1>; - #size-cells = <0>; - - reg_3p3v: regulator@1 { - compatible = "regulator-fixed"; - reg = <1>; - regulator-name = "3P3V"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - }; -}; - -&iomuxc { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_hog>; - - imx6s-riotboard { - pinctrl_hog: hoggrp { - fsl,pins = < - MX6QDL_PAD_EIM_A25__GPIO5_IO02 0x80000000 /* LED D45 */ - MX6QDL_PAD_EIM_D28__GPIO3_IO28 0x80000000 /* LED D46 */ - MX6QDL_PAD_DISP0_DAT22__GPIO5_IO16 0x80000000 /* PMIC_INT_B */ - MX6QDL_PAD_GPIO_0__CCM_CLKO1 0x030b0 /* CAM_MCLK + SGTL_MCLK */ - >; - }; - pinctrl_uart2: uart2grp { - fsl,pins = < - MX6QDL_PAD_EIM_D26__UART2_TX_DATA 0x1b0b1 - MX6QDL_PAD_EIM_D27__UART2_RX_DATA 0x1b0b1 - >; - }; - pinctrl_rgmii_ar8035: rgmii_ar8035 { - fsl,pins = < - MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0 - MX6QDL_PAD_ENET_MDC__ENET_MDC 0x1b0b0 - /* AR8035 reset */ - MX6QDL_PAD_EIM_D31__GPIO3_IO31 0x130b0 - /* AR8035 interrupt */ - MX6QDL_PAD_ENET_TX_EN__GPIO1_IO28 0x80000000 - /* GPIO16 -> AR8035 25MHz */ - MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0xc0000000 - MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x80000000 - MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b0b0 - MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b0b0 - MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b0b0 - MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b0b0 - MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL 0x1b0b0 - /* AR8035 CLK_25M --> ENET_REF_CLK (V22) */ - MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK 0x0a0b1 - /* AR8035 pin strapping: IO voltage: pull up */ - MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b0b0 - /* AR8035 pin strapping: PHYADDR#0: pull down */ - MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x130b0 - /* AR8035 pin strapping: PHYADDR#1: pull down */ - MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x130b0 - /* AR8035 pin strapping: MODE#1: pull up */ - MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b0b0 - /* AR8035 pin strapping: MODE#3: pull up */ - MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b0b0 - /* AR8035 pin strapping: MODE#0: pull down */ - MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL 0x130b0 - >; - }; - pinctrl_usdhc4: usdhc4grp { - fsl,pins = < - MX6QDL_PAD_SD4_CLK__SD4_CLK 0x80000000 - MX6QDL_PAD_SD4_CMD__SD4_CMD 0x80000000 - MX6QDL_PAD_SD4_DAT0__SD4_DATA0 0x80000000 - MX6QDL_PAD_SD4_DAT1__SD4_DATA1 0x80000000 - MX6QDL_PAD_SD4_DAT2__SD4_DATA2 0x80000000 - MX6QDL_PAD_SD4_DAT3__SD4_DATA3 0x80000000 - >; - }; - pinctrl_usdhc2: usdhc2grp { - fsl,pins = < - MX6QDL_PAD_SD2_CLK__SD2_CLK 0x80000000 - MX6QDL_PAD_SD2_CMD__SD2_CMD 0x80000000 - MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x80000000 - MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x80000000 - MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x80000000 - MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x80000000 - MX6QDL_PAD_GPIO_2__GPIO1_IO02 0x80000000 - MX6QDL_PAD_GPIO_4__GPIO1_IO04 0x80000000 - >; - }; - pinctrl_usdhc3: usdhc3grp { - fsl,pins = < - MX6QDL_PAD_SD3_CMD__SD3_CMD 0x80000000 - MX6QDL_PAD_SD3_CLK__SD3_CLK 0x80000000 - MX6QDL_PAD_SD3_DAT0__SD3_DATA0 0x80000000 - MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x80000000 - MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x80000000 - MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x80000000 - MX6QDL_PAD_SD3_DAT4__GPIO7_IO01 0x80000000 - MX6QDL_PAD_SD3_DAT5__GPIO7_IO00 0x80000000 - >; - }; - pinctrl_usbotg: usbotggrp { - fsl,pins = < - MX6QDL_PAD_ENET_RX_ER__USB_OTG_ID 0x80000000 - MX6QDL_PAD_EIM_D22__USB_OTG_PWR 0x80000000 - MX6QDL_PAD_EIM_D21__USB_OTG_OC 0x80000000 - >; - }; - pinctrl_i2c1_2: i2c1grp-2 { - fsl,pins = < - MX6QDL_PAD_CSI0_DAT9__I2C1_SCL 0x4001b8b1 - MX6QDL_PAD_CSI0_DAT8__I2C1_SDA 0x4001b8b1 - >; - }; - pinctrl_i2c2_2: i2c2grp-2 { - fsl,pins = < - MX6QDL_PAD_KEY_COL3__I2C2_SCL 0x4001b8b1 - MX6QDL_PAD_KEY_ROW3__I2C2_SDA 0x4001b8b1 - >; - }; - pinctrl_i2c3_2: i2c3grp-2 { - fsl,pins = < - MX6QDL_PAD_GPIO_5__I2C3_SCL 0x4001b8b1 - MX6QDL_PAD_GPIO_6__I2C3_SDA 0x4001b8b1 - >; - }; - pinctrl_i2c4_2: i2c4grp-2 { - fsl,pins = < - MX6QDL_PAD_GPIO_7__I2C4_SCL 0x4001b8b1 - MX6QDL_PAD_GPIO_8__I2C4_SDA 0x4001b8b1 - >; - }; - }; -}; - -&uart2 { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_uart2>; - status = "okay"; }; &fec { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_rgmii_ar8035>; - phy-mode = "rgmii"; phy-reset-duration = <2>; - phy-reset-gpios = <&gpio3 31 0>; - status = "okay"; -}; - -&usdhc2 { - /* SD card socket - bottom */ - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usdhc2>; - bus-width = <4>; - cd-gpios = <&gpio1 4 0>; - wp-gpios = <&gpio1 2 0>; - status = "okay"; - #address-cells = <1>; - #size-cells = <1>; -}; - -&usdhc3 { - /* uSD card socket - top */ - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usdhc3>; - bus-width = <4>; - cd-gpios = <&gpio7 0 0>; - wp-gpios = <&gpio7 1 0>; - status = "okay"; - #address-cells = <1>; - #size-cells = <1>; }; &usdhc4 { - /* eMMC */ - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usdhc4>; - bus-width = <4>; - non-removable; - status = "okay"; - #address-cells = <1>; #size-cells = <1>; @@ -239,156 +38,6 @@ }; }; -&usbh1 { - status = "okay"; - phy_type = "utmi"; - disable-over-current; -}; - -&usbotg { - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_usbotg>; - phy_type = "utmi"; - dr_mode = "peripheral"; - otg_id_pin_select_change; - status = "okay"; -}; - -&i2c1 { - status = "okay"; - clock-frequency = <100000>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_i2c1_2>; - - pmic: pf0100@08 { - compatible = "pf0100-regulator"; - reg = <0x08>; - interrupt-parent = <&gpio5>; - interrupts = <16 8>; - - regulators { - reg_vddcore: sw1ab { - regulator-min-microvolt = <300000>; - regulator-max-microvolt = <1875000>; - regulator-always-on; - }; - - reg_vddsoc: sw1c { - regulator-min-microvolt = <300000>; - regulator-max-microvolt = <1875000>; - regulator-always-on; - }; - - reg_gen_3v3: sw2 { - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - reg_ddr_1v5a: sw3a { - regulator-min-microvolt = <400000>; - regulator-max-microvolt = <1975000>; - regulator-always-on; - }; - - reg_ddr_1v5b: sw3b { - regulator-min-microvolt = <400000>; - regulator-max-microvolt = <1975000>; - regulator-always-on; - }; - - reg_ddr_vtt: sw4 { - regulator-min-microvolt = <400000>; - regulator-max-microvolt = <1975000>; - regulator-always-on; - }; - - reg_5v_600mA: swbst { - regulator-min-microvolt = <5000000>; - regulator-max-microvolt = <5150000>; - regulator-always-on; - }; - - reg_snvs_3v: vsnvs { - regulator-min-microvolt = <1500000>; - regulator-max-microvolt = <3000000>; - regulator-always-on; - }; - - reg_vrefddr: vrefddr { - regulator-min-microvolt = <750000>; - regulator-max-microvolt = <750000>; - regulator-always-on; - }; - - reg_vgen1_1v5: vgen1 { - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <1550000>; - /* not used */ - }; - - reg_vgen2_1v2_eth: vgen2 { - regulator-min-microvolt = <800000>; - regulator-max-microvolt = <1550000>; - regulator-always-on; - }; - - reg_vgen3_2v8: vgen3 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - reg_vgen4_1v8: vgen4 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - reg_vgen5_2v5_sgtl: vgen5 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - reg_vgen6_3v3: vgen6 { - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - }; - }; - - codec: sgtl5000@0a { - compatible = "fsl,sgtl5000"; - reg = <0x0a>; - clocks = <&clks 201>; - VDDA-supply = <®_vgen5_2v5_sgtl>; - VDDIO-supply = <®_3p3v>; - }; -}; - -&i2c2 { - status = "okay"; - clock-frequency = <100000>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_i2c2_2>; -}; - -&i2c3 { - status = "okay"; - clock-frequency = <100000>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_i2c3_2>; -}; - -&i2c4 { - status = "okay"; - clock-frequency = <100000>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_i2c4_2>; -}; - &ocotp { barebox,provide-mac-address = <&fec 0x620>; }; diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 80f8fd80ae..82fc945d5b 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -279,8 +279,8 @@ config MACH_FREESCALE_IMX6SX_SABRESDB select I2C select I2C_IMX -config MACH_NITROGEN6X - bool "BoundaryDevices Nitrogen6x" +config MACH_NITROGEN6 + bool "BoundaryDevices Nitrogen6 boards" select ARCH_IMX6 config MACH_SOLIDRUN_MICROSOM diff --git a/arch/arm/mach-imx/imx.c b/arch/arm/mach-imx/imx.c index 374ee35df1..2e33325c9f 100644 --- a/arch/arm/mach-imx/imx.c +++ b/arch/arm/mach-imx/imx.c @@ -59,6 +59,8 @@ static int imx_soc_from_dt(void) return IMX_CPU_IMX6; if (of_machine_is_compatible("fsl,imx6sx")) return IMX_CPU_IMX6; + if (of_machine_is_compatible("fsl,imx6qp")) + return IMX_CPU_IMX6; return 0; } diff --git a/arch/arm/mach-imx/include/mach/devices-imx31.h b/arch/arm/mach-imx/include/mach/devices-imx31.h index 63319fea37..51125d1bca 100644 --- a/arch/arm/mach-imx/include/mach/devices-imx31.h +++ b/arch/arm/mach-imx/include/mach/devices-imx31.h @@ -2,19 +2,34 @@ #include <mach/imx31-regs.h> #include <mach/devices.h> +static inline struct device_d *imx31_add_i2c0(void *pdata) +{ + return imx_add_i2c((void *)MX31_I2C1_BASE_ADDR, 0, pdata); +} + +static inline struct device_d *imx31_add_i2c1(void *pdata) +{ + return imx_add_i2c((void *)MX31_I2C2_BASE_ADDR, 1, pdata); +} + +static inline struct device_d *imx31_add_i2c2(void *pdata) +{ + return imx_add_i2c((void *)MX31_I2C3_BASE_ADDR, 2, pdata); +} + static inline struct device_d *imx31_add_spi0(struct spi_imx_master *pdata) { - return imx_add_spi_imx27((void *)MX31_CSPI1_BASE_ADDR, 0, pdata); + return imx_add_spi_imx35((void *)MX31_CSPI1_BASE_ADDR, 0, pdata); } static inline struct device_d *imx31_add_spi1(struct spi_imx_master *pdata) { - return imx_add_spi_imx27((void *)MX31_CSPI2_BASE_ADDR, 1, pdata); + return imx_add_spi_imx35((void *)MX31_CSPI2_BASE_ADDR, 1, pdata); } static inline struct device_d *imx31_add_spi2(struct spi_imx_master *pdata) { - return imx_add_spi_imx27((void *)MX31_CSPI3_BASE_ADDR, 2, pdata); + return imx_add_spi_imx35((void *)MX31_CSPI3_BASE_ADDR, 2, pdata); } static inline struct device_d *imx31_add_uart0(void) diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c index 1dc9108a2b..17b944be14 100644 --- a/arch/arm/mach-imx/ocotp.c +++ b/arch/arm/mach-imx/ocotp.c @@ -404,7 +404,7 @@ static int imx_ocotp_probe(struct device_d *dev) priv->map_config.reg_stride = 4; priv->map_config.max_register = data->num_regs - 1; - priv->map = regmap_init(&priv->dev, &imx_ocotp_regmap_bus, priv, &priv->map_config); + priv->map = regmap_init(dev, &imx_ocotp_regmap_bus, priv, &priv->map_config); if (IS_ERR(priv->map)) return PTR_ERR(priv->map); diff --git a/drivers/mfd/mc13xxx.c b/drivers/mfd/mc13xxx.c index 68d70c53d5..b2fcd95516 100644 --- a/drivers/mfd/mc13xxx.c +++ b/drivers/mfd/mc13xxx.c @@ -330,7 +330,8 @@ static int __init mc13xxx_probe(struct device_d *dev) mc_dev->spi = dev->type_data; mc_dev->spi->mode = SPI_MODE_0 | SPI_CS_HIGH; mc_dev->spi->bits_per_word = 32; - mc_dev->spi->max_speed_hz = 20000000; + mc_dev->spi->max_speed_hz = mc_dev->spi->max_speed_hz ? + mc_dev->spi->max_speed_hz : 20000000; mc_dev->map = regmap_init(dev, ®map_mc13xxx_spi_bus, mc_dev, &mc13xxx_regmap_spi_config); } diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index 738b88ea5e..9a71b3bc25 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -33,7 +33,7 @@ config DRIVER_SPI_IMX_0_0 config DRIVER_SPI_IMX_0_7 bool - depends on ARCH_IMX25 || ARCH_IMX35 || ARCH_IMX53 + depends on ARCH_IMX25 || ARCH_IMX31 || ARCH_IMX35 || ARCH_IMX53 default y config DRIVER_SPI_IMX_2_3 diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c index dc7a8c89f3..806ca67bda 100644 --- a/drivers/spi/imx_spi.c +++ b/drivers/spi/imx_spi.c @@ -206,7 +206,12 @@ static void cspi_0_7_chipselect(struct spi_device *spi, int is_active) reg |= spi_imx_clkdiv_2(clk_get_rate(imx->clk), spi->max_speed_hz) << CSPI_0_7_CTRL_DR_SHIFT; - reg |= (spi->bits_per_word - 1) << CSPI_0_7_CTRL_BL_SHIFT; + if (cpu_is_mx31()) + reg |= ((spi->bits_per_word - 1) & CSPI_0_4_CTRL_BL_MASK) + << CSPI_0_4_CTRL_BL_SHIFT; + else + reg |= (spi->bits_per_word - 1) << CSPI_0_7_CTRL_BL_SHIFT; + reg |= CSPI_0_7_CTRL_SSCTL; if (spi->mode & SPI_CPHA) @@ -215,8 +220,12 @@ static void cspi_0_7_chipselect(struct spi_device *spi, int is_active) reg |= CSPI_0_7_CTRL_POL; if (spi->mode & SPI_CS_HIGH) reg |= CSPI_0_7_CTRL_SSPOL; - if (gpio < 0) - reg |= (gpio + 32) << CSPI_0_7_CTRL_CS_SHIFT; + if (gpio < 0) { + if (cpu_is_mx31()) + reg |= (gpio + 32) << CSPI_0_4_CTRL_CS_SHIFT; + else + reg |= (gpio + 32) << CSPI_0_7_CTRL_CS_SHIFT; + } writel(reg, base + CSPI_0_7_CTRL); diff --git a/images/Makefile.imx b/images/Makefile.imx index effa5edc0f..b02fdff4b1 100644 --- a/images/Makefile.imx +++ b/images/Makefile.imx @@ -268,25 +268,30 @@ CFG_start_hummingboard_microsom_i4.pblx.imximg = $(board)/solidrun-microsom/flas FILE_barebox-solidrun-hummingboard-microsom-i4.img = start_hummingboard_microsom_i4.pblx.imximg image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard-microsom-i4.img -pblx-$(CONFIG_MACH_NITROGEN6X) += start_imx6q_nitrogen6x_1g -CFG_start_imx6q_nitrogen6x_1g.pblx.imximg = $(board)/boundarydevices-nitrogen6x/flash-header-nitrogen6q-1g.imxcfg +pblx-$(CONFIG_MACH_NITROGEN6) += start_imx6q_nitrogen6x_1g +CFG_start_imx6q_nitrogen6x_1g.pblx.imximg = $(board)/boundarydevices-nitrogen6/flash-header-nitrogen6q-1g.imxcfg FILE_barebox-boundarydevices-imx6q-nitrogen6x-1g.img = start_imx6q_nitrogen6x_1g.pblx.imximg -image-$(CONFIG_MACH_NITROGEN6X) += barebox-boundarydevices-imx6q-nitrogen6x-1g.img +image-$(CONFIG_MACH_NITROGEN6) += barebox-boundarydevices-imx6q-nitrogen6x-1g.img -pblx-$(CONFIG_MACH_NITROGEN6X) += start_imx6q_nitrogen6x_2g -CFG_start_imx6q_nitrogen6x_2g.pblx.imximg = $(board)/boundarydevices-nitrogen6x/flash-header-nitrogen6q-2g.imxcfg +pblx-$(CONFIG_MACH_NITROGEN6) += start_imx6q_nitrogen6x_2g +CFG_start_imx6q_nitrogen6x_2g.pblx.imximg = $(board)/boundarydevices-nitrogen6/flash-header-nitrogen6q-2g.imxcfg FILE_barebox-boundarydevices-imx6q-nitrogen6x-2g.img = start_imx6q_nitrogen6x_2g.pblx.imximg -image-$(CONFIG_MACH_NITROGEN6X) += barebox-boundarydevices-imx6q-nitrogen6x-2g.img +image-$(CONFIG_MACH_NITROGEN6) += barebox-boundarydevices-imx6q-nitrogen6x-2g.img -pblx-$(CONFIG_MACH_NITROGEN6X) += start_imx6dl_nitrogen6x_1g -CFG_start_imx6dl_nitrogen6x_1g.pblx.imximg = $(board)/boundarydevices-nitrogen6x/flash-header-nitrogen6dl-1g.imxcfg +pblx-$(CONFIG_MACH_NITROGEN6) += start_imx6dl_nitrogen6x_1g +CFG_start_imx6dl_nitrogen6x_1g.pblx.imximg = $(board)/boundarydevices-nitrogen6/flash-header-nitrogen6dl-1g.imxcfg FILE_barebox-boundarydevices-imx6dl-nitrogen6x-1g.img = start_imx6dl_nitrogen6x_1g.pblx.imximg -image-$(CONFIG_MACH_NITROGEN6X) += barebox-boundarydevices-imx6dl-nitrogen6x-1g.img +image-$(CONFIG_MACH_NITROGEN6) += barebox-boundarydevices-imx6dl-nitrogen6x-1g.img -pblx-$(CONFIG_MACH_NITROGEN6X) += start_imx6dl_nitrogen6x_2g -CFG_start_imx6dl_nitrogen6x_2g.pblx.imximg = $(board)/boundarydevices-nitrogen6x/flash-header-nitrogen6dl-2g.imxcfg +pblx-$(CONFIG_MACH_NITROGEN6) += start_imx6dl_nitrogen6x_2g +CFG_start_imx6dl_nitrogen6x_2g.pblx.imximg = $(board)/boundarydevices-nitrogen6/flash-header-nitrogen6dl-2g.imxcfg FILE_barebox-boundarydevices-imx6dl-nitrogen6x-2g.img = start_imx6dl_nitrogen6x_2g.pblx.imximg -image-$(CONFIG_MACH_NITROGEN6X) += barebox-boundarydevices-imx6dl-nitrogen6x-2g.img +image-$(CONFIG_MACH_NITROGEN6) += barebox-boundarydevices-imx6dl-nitrogen6x-2g.img + +pblx-$(CONFIG_MACH_NITROGEN6) += start_imx6qp_nitrogen6_max +CFG_start_imx6qp_nitrogen6_max.pblx.imximg = $(board)/boundarydevices-nitrogen6/flash-header-nitrogen6qp-max.imxcfg +FILE_barebox-boundarydevices-imx6qp-nitrogen6_max.img = start_imx6qp_nitrogen6_max.pblx.imximg +image-$(CONFIG_MACH_NITROGEN6) += barebox-boundarydevices-imx6qp-nitrogen6_max.img pblx-$(CONFIG_MACH_TX6X) += start_imx6dl_tx6x_512m CFG_start_imx6dl_tx6x_512m.pblx.imximg = $(board)/karo-tx6x/flash-header-tx6dl-512m.imxcfg diff --git a/include/spi/imx-spi.h b/include/spi/imx-spi.h index 221c66502f..a592573e62 100644 --- a/include/spi/imx-spi.h +++ b/include/spi/imx-spi.h @@ -40,6 +40,12 @@ #define CSPI_0_0_RESET_START (1 << 0) +#define CSPI_0_4_CTRL 0x08 +#define CSPI_0_4_CTRL_BL_SHIFT 8 +#define CSPI_0_4_CTRL_BL_MASK 0x1f +#define CSPI_0_4_CTRL_DRCTL_SHIFT 20 +#define CSPI_0_4_CTRL_CS_SHIFT 24 + #define CSPI_0_7_RXDATA 0x00 #define CSPI_0_7_TXDATA 0x04 #define CSPI_0_7_CTRL 0x08 @@ -50,6 +56,7 @@ #define CSPI_0_7_CTRL_PHA (1 << 5) #define CSPI_0_7_CTRL_SSCTL (1 << 6) #define CSPI_0_7_CTRL_SSPOL (1 << 7) +#define CSPI_0_7_CTRL_DRCTL_SHIFT 8 #define CSPI_0_7_CTRL_CS_SHIFT 12 #define CSPI_0_7_CTRL_DR_SHIFT 16 #define CSPI_0_7_CTRL_BL_SHIFT 20 diff --git a/scripts/imx/imx-image.c b/scripts/imx/imx-image.c index 3f62228ab1..c0bf9c004f 100644 --- a/scripts/imx/imx-image.c +++ b/scripts/imx/imx-image.c @@ -278,7 +278,7 @@ static int write_mem_v1(uint32_t addr, uint32_t val, int width, int set_bits, in * ============================================================================ */ -static int add_header_v2(struct config_data *data, void *buf) +static int add_header_v2(const struct config_data *data, void *buf) { struct imx_flash_header_v2 *hdr; int dcdsize = curdcd * sizeof(uint32_t); @@ -447,7 +447,8 @@ static int write_dcd(const char *outfile) return 0; } -static int check(struct config_data *data, uint32_t cmd, uint32_t addr, uint32_t mask) +static int check(const struct config_data *data, uint32_t cmd, uint32_t addr, + uint32_t mask) { if (curdcd > MAX_DCD - 3) { fprintf(stderr, "At maximum %d dcd entried are allowed\n", MAX_DCD); @@ -463,8 +464,8 @@ static int check(struct config_data *data, uint32_t cmd, uint32_t addr, uint32_t return 0; } -static int write_mem(struct config_data *data, uint32_t addr, uint32_t val, int width, - int set_bits, int clear_bits) +static int write_mem(const struct config_data *data, uint32_t addr, + uint32_t val, int width, int set_bits, int clear_bits) { switch (data->header_version) { case 1: diff --git a/scripts/imx/imx-usb-loader.c b/scripts/imx/imx-usb-loader.c index cf9d610823..17324972bf 100644 --- a/scripts/imx/imx-usb-loader.c +++ b/scripts/imx/imx-usb-loader.c @@ -32,6 +32,7 @@ #include <stdlib.h> #include <libusb.h> #include <getopt.h> +#include <arpa/inet.h> #include <linux/kernel.h> #include "imx.h" @@ -67,13 +68,7 @@ struct mach_id { struct usb_work { char filename[256]; unsigned char dcd; - unsigned char clear_dcd; unsigned char plug; -#define J_ADDR 1 -#define J_HEADER 2 -#define J_HEADER2 3 - unsigned char jump_mode; - unsigned jump_addr; }; struct usb_id { @@ -154,6 +149,21 @@ struct mach_id imx_ids[] = { }, }; +#define SDP_READ_REG 0x0101 +#define SDP_WRITE_REG 0x0202 +#define SDP_WRITE_FILE 0x0404 +#define SDP_ERROR_STATUS 0x0505 +#define SDP_JUMP_ADDRESS 0x0b0b + +struct sdp_command { + uint16_t cmd; + uint32_t addr; + uint8_t format; + uint32_t cnt; + uint32_t data; + uint8_t rsvd; +} __attribute__((packed)); + static struct mach_id *imx_device(unsigned short vid, unsigned short pid) { int i; @@ -264,6 +274,51 @@ static long get_file_size(FILE *xfile) return size; } +static int read_file(const char *name, unsigned char **buffer, unsigned *size) +{ + FILE *xfile; + unsigned fsize; + int cnt; + unsigned char *buf; + xfile = fopen(name, "rb"); + if (!xfile) { + printf("error, can not open input file: %s\n", name); + return -5; + } + + fsize = get_file_size(xfile); + if (fsize < 0x20) { + printf("error, file: %s is too small\n", name); + fclose(xfile); + return -2; + } + + buf = malloc(fsize); + if (!buf) { + printf("error, out of memory\n"); + fclose(xfile); + return -2; + } + + cnt = fread(buf, 1 , fsize, xfile); + if (cnt < fsize) { + printf("error, cannot read %s\n", name); + fclose(xfile); + free(buf); + return -1; + } + + if (size) + *size = fsize; + + if (buffer) + *buffer = buf; + else + free(buf); + + return 0; +} + /* * HID Class-Specific Requests values. See section 7.2 of the HID specifications */ @@ -368,16 +423,18 @@ int do_status(void) unsigned char tmp[64]; int retry = 0; int err; - const unsigned char status_command[] = { - 5, 5, 0, 0, 0, 0, - 0, - 0, 0, 0, 0, - 0, 0, 0, 0, - 0 + static const struct sdp_command status_command = { + .cmd = SDP_ERROR_STATUS, + .addr = 0, + .format = 0, + .cnt = 0, + .data = 0, + .rsvd = 0, }; for (;;) { - err = transfer(1, (unsigned char*)status_command, 16, &last_trans); + err = transfer(1, (unsigned char *) &status_command, 16, + &last_trans); if (verbose > 2) printf("report 1, wrote %i bytes, err=%i\n", last_trans, err); @@ -410,18 +467,15 @@ int do_status(void) return err; } -#define V(a) (((a) >> 24) & 0xff), (((a) >> 16) & 0xff), (((a) >> 8) & 0xff), ((a) & 0xff) - static int read_memory(unsigned addr, void *dest, unsigned cnt) { - static unsigned char read_reg_command[] = { - 1, - 1, - V(0), /* address */ - 0x20, /* format */ - V(0x00000004), /* data count */ - V(0), /* data */ - 0x00, /* type */ + static struct sdp_command read_reg_command = { + .cmd = SDP_READ_REG, + .addr = 0, + .format = 0x20, + .cnt = 0, + .data = 0, + .rsvd = 0, }; int retry = 0; @@ -429,18 +483,12 @@ static int read_memory(unsigned addr, void *dest, unsigned cnt) int err; int rem; unsigned char tmp[64]; - read_reg_command[2] = (unsigned char)(addr >> 24); - read_reg_command[3] = (unsigned char)(addr >> 16); - read_reg_command[4] = (unsigned char)(addr >> 8); - read_reg_command[5] = (unsigned char)(addr); - - read_reg_command[7] = (unsigned char)(cnt >> 24); - read_reg_command[8] = (unsigned char)(cnt >> 16); - read_reg_command[9] = (unsigned char)(cnt >> 8); - read_reg_command[10] = (unsigned char)(cnt); + read_reg_command.addr = htonl(addr); + read_reg_command.cnt = htonl(cnt); for (;;) { - err = transfer(1, read_reg_command, 16, &last_trans); + err = transfer(1, (unsigned char *) &read_reg_command, 16, + &last_trans); if (!err) break; printf("read_reg_command err=%i, last_trans=%i\n", err, last_trans); @@ -491,47 +539,40 @@ static int write_memory(unsigned addr, unsigned val, int width) int last_trans; int err = 0; unsigned char tmp[64]; - unsigned char ds; - unsigned char write_reg_command[] = { - 2, - 2, - V(0), /* address */ - 0x0, /* format */ - V(0x00000004), /* data count */ - V(0), /* data */ - 0x00, /* type */ + static struct sdp_command write_reg_command = { + .cmd = SDP_WRITE_REG, + .addr = 0, + .format = 0, + .cnt = 0, + .data = 0, + .rsvd = 0, }; - write_reg_command[2] = (unsigned char)(addr >> 24); - write_reg_command[3] = (unsigned char)(addr >> 16); - write_reg_command[4] = (unsigned char)(addr >> 8); - write_reg_command[5] = (unsigned char)(addr); + + write_reg_command.addr = htonl(addr); + write_reg_command.cnt = htonl(4); if (verbose > 1) printf("write memory reg: 0x%08x val: 0x%08x width: %d\n", addr, val, width); switch (width) { case 1: - ds = 0x8; + write_reg_command.format = 0x8; break; case 2: - ds = 0x10; + write_reg_command.format = 0x10; break; case 4: - ds = 0x20; + write_reg_command.format = 0x20; break; default: return -1; } - write_reg_command[6] = ds; - - write_reg_command[11] = (unsigned char)(val >> 24); - write_reg_command[12] = (unsigned char)(val >> 16); - write_reg_command[13] = (unsigned char)(val >> 8); - write_reg_command[14] = (unsigned char)(val); + write_reg_command.data = htonl(val); for (;;) { - err = transfer(1, write_reg_command, 16, &last_trans); + err = transfer(1, (unsigned char *) &write_reg_command, 16, + &last_trans); if (!err) break; printf("write_reg_command err=%i, last_trans=%i\n", err, last_trans); @@ -586,15 +627,15 @@ static int modify_memory(unsigned addr, unsigned val, int width, int set_bits, i static int load_file(void *buf, unsigned len, unsigned dladdr, unsigned char type) { - static unsigned char dl_command[] = { - 0x04, - 0x04, - V(0), /* address */ - 0x00, /* format */ - V(0x00000020), /* data count */ - V(0), /* data */ - 0xaa, /* type */ + static struct sdp_command dl_command = { + .cmd = SDP_WRITE_FILE, + .addr = 0, + .format = 0, + .cnt = 0, + .data = 0, + .rsvd = 0, }; + int last_trans, err; int retry = 0; unsigned transfer_size = 0; @@ -602,19 +643,13 @@ static int load_file(void *buf, unsigned len, unsigned dladdr, unsigned char typ void *p; int cnt; - dl_command[2] = (unsigned char)(dladdr >> 24); - dl_command[3] = (unsigned char)(dladdr >> 16); - dl_command[4] = (unsigned char)(dladdr >> 8); - dl_command[5] = (unsigned char)(dladdr); - - dl_command[7] = (unsigned char)(len >> 24); - dl_command[8] = (unsigned char)(len >> 16); - dl_command[9] = (unsigned char)(len >> 8); - dl_command[10] = (unsigned char)(len); - dl_command[15] = type; + dl_command.addr = htonl(dladdr); + dl_command.cnt = htonl(len); + dl_command.rsvd = type; for (;;) { - err = transfer(1, dl_command, 16, &last_trans); + err = transfer(1, (unsigned char *) &dl_command, 16, + &last_trans); if (!err) break; @@ -669,13 +704,53 @@ static int load_file(void *buf, unsigned len, unsigned dladdr, unsigned char typ return transfer_size; } -static int write_dcd_table_ivt(struct imx_flash_header_v2 *hdr, unsigned char *file_start, unsigned cnt) +static int sdp_jump_address(unsigned addr) +{ + unsigned char tmp[64]; + static struct sdp_command jump_command = { + .cmd = SDP_JUMP_ADDRESS, + .addr = 0, + .format = 0, + .cnt = 0, + .data = 0, + .rsvd = 0, + }; + int last_trans, err; + int retry = 0; + + jump_command.addr = htonl(addr); + + for (;;) { + err = transfer(1, (unsigned char *) &jump_command, 16, + &last_trans); + if (!err) + break; + + printf("jump_command err=%i, last_trans=%i\n", err, last_trans); + + if (retry > 5) + return -4; + + retry++; + } + + memset(tmp, 0, sizeof(tmp)); + err = transfer(3, tmp, sizeof(tmp), &last_trans); + + if (err) + printf("j3 in err=%i, last_trans=%i %02x %02x %02x %02x\n", + err, last_trans, tmp[0], tmp[1], tmp[2], tmp[3]); + return 0; +} + +static int write_dcd_table_ivt(const struct imx_flash_header_v2 *hdr, + const unsigned char *file_start, unsigned cnt) { unsigned char *dcd_end; unsigned m_length; #define cvt_dest_to_src (((unsigned char *)hdr) - hdr->self) unsigned char* dcd; - unsigned char* file_end = file_start + cnt; + const unsigned char *file_end = file_start + cnt; int err = 0; if (!hdr->dcd_ptr) { @@ -747,8 +822,8 @@ static int write_dcd_table_ivt(struct imx_flash_header_v2 *hdr, unsigned char *f return err; } -static int get_dcd_range_old(struct imx_flash_header *hdr, - unsigned char *file_start, unsigned cnt, +static int get_dcd_range_old(const struct imx_flash_header *hdr, + const unsigned char *file_start, unsigned cnt, unsigned char **pstart, unsigned char **pend) { unsigned char *dcd_end; @@ -756,7 +831,7 @@ static int get_dcd_range_old(struct imx_flash_header *hdr, #define cvt_dest_to_src_old (((unsigned char *)&hdr->dcd) - hdr->dcd_ptr_ptr) unsigned char* dcd; unsigned val; - unsigned char* file_end = file_start + cnt; + const unsigned char *file_end = file_start + cnt; if (!hdr->dcd) { printf("No dcd table, barker=%x\n", hdr->app_code_barker); @@ -794,7 +869,8 @@ static int get_dcd_range_old(struct imx_flash_header *hdr, return 0; } -static int write_dcd_table_old(struct imx_flash_header *hdr, unsigned char *file_start, unsigned cnt) +static int write_dcd_table_old(const struct imx_flash_header *hdr, + const unsigned char *file_start, unsigned cnt) { unsigned val; unsigned char *dcd_end; @@ -877,10 +953,12 @@ err: return ret; } -static int is_header(unsigned char *p) +static int is_header(const unsigned char *p) { - struct imx_flash_header *ohdr = (struct imx_flash_header *)p; - struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p; + const struct imx_flash_header *ohdr = + (const struct imx_flash_header *)p; + const struct imx_flash_header_v2 *hdr = + (const struct imx_flash_header_v2 *)p; switch (usb_id->mach_id->header_type) { case HDR_MX51: @@ -895,7 +973,8 @@ static int is_header(unsigned char *p) return 0; } -static int perform_dcd(unsigned char *p, unsigned char *file_start, unsigned cnt) +static int perform_dcd(unsigned char *p, const unsigned char *file_start, + unsigned cnt) { struct imx_flash_header *ohdr = (struct imx_flash_header *)p; struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p; @@ -920,29 +999,11 @@ static int perform_dcd(unsigned char *p, unsigned char *file_start, unsigned cnt return ret; } -static int clear_dcd_ptr(unsigned char *p, unsigned char *file_start, unsigned cnt) -{ - struct imx_flash_header *ohdr = (struct imx_flash_header *)p; - struct imx_flash_header_v2 *hdr = (struct imx_flash_header_v2 *)p; - - switch (usb_id->mach_id->header_type) { - case HDR_MX51: - printf("clear dcd_ptr=0x%08x\n", ohdr->dcd); - ohdr->dcd = 0; - break; - case HDR_MX53: - printf("clear dcd_ptr=0x%08x\n", hdr->dcd_ptr); - hdr->dcd_ptr = 0; - break; - } - return 0; -} - -static int get_dl_start(unsigned char *p, unsigned char *file_start, +static int get_dl_start(const unsigned char *p, const unsigned char *file_start, unsigned cnt, unsigned *dladdr, unsigned *max_length, unsigned *plugin, unsigned *header_addr) { - unsigned char* file_end = file_start + cnt; + const unsigned char *file_end = file_start + cnt; switch (usb_id->mach_id->header_type) { case HDR_MX51: { @@ -1012,18 +1073,6 @@ static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, return ret; } curr->dcd = 0; - if ((!curr->jump_mode) && (!curr->plug)) { - printf("!!dcd done, nothing else requested\n"); - return 0; - } - } - - if (curr->clear_dcd) { - ret = clear_dcd_ptr(p, buf, cnt); - if (ret < 0) { - printf("!!clear_dcd returned %i\n", ret); - return ret; - } } if (*p_plugin && (!curr->plug) && (!header_cnt)) { @@ -1047,70 +1096,33 @@ static int process_header(struct usb_work *curr, unsigned char *buf, int cnt, static int do_irom_download(struct usb_work *curr, int verify) { - static unsigned char jump_command[] = {0x0b,0x0b, V(0), 0x00, V(0x00000000), V(0), 0x00}; - int ret; - FILE* xfile; unsigned char type; - unsigned fsize; + unsigned fsize = 0; unsigned header_offset; - int cnt; unsigned file_base; - int last_trans, err; unsigned char *buf = NULL; unsigned char *image; unsigned char *verify_buffer = NULL; - unsigned char *p; - unsigned char tmp[64]; unsigned dladdr = 0; unsigned max_length; unsigned plugin = 0; unsigned header_addr = 0; - unsigned skip = 0; - int retry = 0; - - xfile = fopen(curr->filename, "rb" ); - if (!xfile) { - printf("error, can not open input file: %s\n", curr->filename); - return -5; - } - - fsize = get_file_size(xfile); - if (fsize < 0x20) { - printf("error, file: %s is too small\n", curr->filename); - ret = -2; - goto cleanup; - } - - buf = malloc(fsize); - if (!buf) { - printf("error, out of memory\n"); - ret = -2; - goto cleanup; - } - cnt = fread(buf, 1 , fsize, xfile); - if (cnt < fsize) { - printf("error, cannot read %s\n", curr->filename); - return -1; - } + ret = read_file(curr->filename, &buf, &fsize); + if (ret < 0) + return ret; max_length = fsize; - ret = process_header(curr, buf, cnt, + ret = process_header(curr, buf, fsize, &dladdr, &max_length, &plugin, &header_addr); if (ret < 0) goto cleanup; header_offset = ret; - if ((!curr->jump_mode) && (!curr->plug)) { - /* nothing else requested */ - ret = 0; - goto cleanup; - } - if (plugin && (!curr->plug)) { printf("Only plugin header found\n"); ret = -1; @@ -1125,9 +1137,7 @@ static int do_irom_download(struct usb_work *curr, int verify) file_base = header_addr - header_offset; - type = (curr->plug || curr->jump_mode) ? FT_APP : FT_LOAD_ONLY; - - if (usb_id->mach_id->mode == MODE_BULK && type == FT_APP) { + if (usb_id->mach_id->mode == MODE_BULK) { /* No jump command, dladdr should point to header */ dladdr = header_addr; } @@ -1140,14 +1150,13 @@ static int do_irom_download(struct usb_work *curr, int verify) skip = dladdr - file_base; image = buf + skip; - - p = image; - cnt -= skip; fsize -= skip; if (fsize > max_length) fsize = max_length; + type = FT_APP; + if (verify) { verify_buffer = malloc(64); @@ -1157,7 +1166,7 @@ static int do_irom_download(struct usb_work *curr, int verify) goto cleanup; } - memcpy(verify_buffer, p, 64); + memcpy(verify_buffer, image, 64); if ((type == FT_APP) && (usb_id->mach_id->mode != MODE_HID)) { type = FT_LOAD_ONLY; @@ -1201,46 +1210,21 @@ static int do_irom_download(struct usb_work *curr, int verify) if (usb_id->mach_id->mode == MODE_HID && type == FT_APP) { printf("jumping to 0x%08x\n", header_addr); - jump_command[2] = (unsigned char)(header_addr >> 24); - jump_command[3] = (unsigned char)(header_addr >> 16); - jump_command[4] = (unsigned char)(header_addr >> 8); - jump_command[5] = (unsigned char)(header_addr); - - /* Any command will initiate jump for mx51, jump address is ignored by mx51 */ - retry = 0; - - for (;;) { - err = transfer(1, jump_command, 16, &last_trans); - if (!err) - break; - - printf("jump_command err=%i, last_trans=%i\n", err, last_trans); - - if (retry > 5) - return -4; - - retry++; - } - - memset(tmp, 0, sizeof(tmp)); - err = transfer(3, tmp, sizeof(tmp), &last_trans); - - if (err) - printf("j3 in err=%i, last_trans=%i %02x %02x %02x %02x\n", - err, last_trans, tmp[0], tmp[1], tmp[2], tmp[3]); + ret = sdp_jump_address(header_addr); + if (ret < 0) + return ret; } ret = 0; cleanup: - fclose(xfile); free(verify_buffer); free(buf); return ret; } -static int write_mem(struct config_data *data, uint32_t addr, uint32_t val, int width, - int set_bits, int clear_bits) +static int write_mem(const struct config_data *data, uint32_t addr, + uint32_t val, int width, int set_bits, int clear_bits) { return modify_memory(addr, val, width, set_bits, clear_bits); } @@ -1309,7 +1293,6 @@ int main(int argc, char *argv[]) w.plug = 1; w.dcd = 1; - w.jump_mode = J_HEADER; strncpy(w.filename, argv[optind], sizeof(w.filename) - 1); r = libusb_init(NULL); diff --git a/scripts/imx/imx.h b/scripts/imx/imx.h index a1369586a9..8db7e7b46c 100644 --- a/scripts/imx/imx.h +++ b/scripts/imx/imx.h @@ -65,9 +65,10 @@ struct config_data { char *srkfile; int header_version; int cpu_type; - int (*check)(struct config_data *data, uint32_t cmd, uint32_t addr, uint32_t mask); - int (*write_mem)(struct config_data *data, uint32_t addr, uint32_t val, int width, - int set_bits, int clear_bits); + int (*check)(const struct config_data *data, uint32_t cmd, + uint32_t addr, uint32_t mask); + int (*write_mem)(const struct config_data *data, uint32_t addr, + uint32_t val, int width, int set_bits, int clear_bits); int csf_space; char *csf; }; |