9
0
Fork 0

Merge branch 'for-next/imx'

Conflicts:
	arch/arm/Makefile
This commit is contained in:
Sascha Hauer 2013-06-02 12:36:29 +02:00
commit f56b064fa3
17 changed files with 2572 additions and 197 deletions

View File

@ -70,102 +70,102 @@ machine-$(CONFIG_ARCH_ZYNQ) := zynq
# Board directory name. This list is sorted alphanumerically
# by CONFIG_* macro name.
board-$(CONFIG_MACH_A9M2410) := a9m2410
board-$(CONFIG_MACH_A9M2440) := a9m2440
board-$(CONFIG_MACH_ANIMEO_IP) := animeo_ip
board-$(CONFIG_MACH_AT91RM9200EK) := at91rm9200ek
board-$(CONFIG_MACH_AT91SAM9260EK) := at91sam9260ek
board-$(CONFIG_MACH_AT91SAM9261EK) := at91sam9261ek
board-$(CONFIG_MACH_AT91SAM9263EK) := at91sam9263ek
board-$(CONFIG_MACH_AT91SAM9G10EK) := at91sam9261ek
board-$(CONFIG_MACH_AT91SAM9G20EK) := at91sam9260ek
board-$(CONFIG_MACH_AT91SAM9N12EK) := at91sam9n12ek
board-$(CONFIG_MACH_AT91SAM9X5EK) := at91sam9x5ek
board-$(CONFIG_MACH_AT91SAM9M10IHD) := at91sam9m10ihd
board-$(CONFIG_MACH_AT91SAM9M10G45EK) := at91sam9m10g45ek
board-$(CONFIG_MACH_SAMA5D3XEK) := sama5d3xek
board-$(CONFIG_MACH_CLEP7212) := clep7212
board-$(CONFIG_MACH_DSS11) := dss11
board-$(CONFIG_MACH_EDB9301) := edb93xx
board-$(CONFIG_MACH_EDB9302) := edb93xx
board-$(CONFIG_MACH_EDB9302A) := edb93xx
board-$(CONFIG_MACH_EDB9307) := edb93xx
board-$(CONFIG_MACH_EDB9307A) := edb93xx
board-$(CONFIG_MACH_EDB93012) := edb93xx
board-$(CONFIG_MACH_EDB9315) := edb93xx
board-$(CONFIG_MACH_EDB9315A) := edb93xx
board-$(CONFIG_MACH_EUKREA_CPUIMX25) := eukrea_cpuimx25
board-$(CONFIG_MACH_EUKREA_CPUIMX27) := eukrea_cpuimx27
board-$(CONFIG_MACH_EUKREA_CPUIMX35) := eukrea_cpuimx35
board-$(CONFIG_MACH_EUKREA_CPUIMX51SD) := eukrea_cpuimx51
board-$(CONFIG_MACH_FREESCALE_MX25_3STACK) := freescale-mx25-3-stack
board-$(CONFIG_MACH_FREESCALE_MX35_3STACK) := freescale-mx35-3-stack
board-$(CONFIG_MACH_GE863) := telit-evk-pro3
board-$(CONFIG_MACH_HIGHBANK) := highbank
board-$(CONFIG_MACH_IMX21ADS) := imx21ads
board-$(CONFIG_MACH_IMX27ADS) := imx27ads
board-$(CONFIG_MACH_IMX233_OLINUXINO) := imx233-olinuxino
board-$(CONFIG_MACH_MIOA701) := mioa701
board-$(CONFIG_MACH_MMCCPU) := mmccpu
board-$(CONFIG_MACH_NOMADIK_8815NHK) := nhk8815
board-$(CONFIG_MACH_NXDB500) := netx
board-$(CONFIG_MACH_OMAP343xSDP) := omap343xdsp
board-$(CONFIG_MACH_BEAGLE) := beagle
board-$(CONFIG_MACH_BEAGLEBONE) := beaglebone
board-$(CONFIG_MACH_OMAP3EVM) := omap3evm
board-$(CONFIG_MACH_PANDA) := panda
board-$(CONFIG_MACH_ARCHOSG9) := archosg9
board-$(CONFIG_MACH_PCM049) := pcm049
board-$(CONFIG_MACH_PCA100) := phycard-i.MX27
board-$(CONFIG_MACH_PCAAL1) := phycard-a-l1
board-$(CONFIG_MACH_PCAAXL2) := phycard-a-xl2
board-$(CONFIG_MACH_PCM027) := pcm027
board-$(CONFIG_MACH_PCM037) := pcm037
board-$(CONFIG_MACH_PCM038) := pcm038
board-$(CONFIG_MACH_PCM043) := pcm043
board-$(CONFIG_MACH_PCM051) := pcm051
board-$(CONFIG_MACH_PM9261) := pm9261
board-$(CONFIG_MACH_PM9263) := pm9263
board-$(CONFIG_MACH_PM9G45) := pm9g45
board-$(CONFIG_MACH_RPI) := raspberry-pi
board-$(CONFIG_MACH_SCB9328) := scb9328
board-$(CONFIG_MACH_NESO) := guf-neso
board-$(CONFIG_MACH_MX23EVK) := freescale-mx23-evk
board-$(CONFIG_MACH_CHUMBY) := chumby_falconwing
board-$(CONFIG_MACH_TX28) := karo-tx28
board-$(CONFIG_MACH_MX28EVK) := freescale-mx28-evk
board-$(CONFIG_MACH_CFA10036) := crystalfontz-cfa10036
board-$(CONFIG_MACH_FREESCALE_MX51_PDK) := freescale-mx51-pdk
board-$(CONFIG_MACH_FREESCALE_MX53_LOCO) := freescale-mx53-loco
board-$(CONFIG_MACH_FREESCALE_MX53_SMD) := freescale-mx53-smd
board-$(CONFIG_MACH_GUF_CUPID) := guf-cupid
board-$(CONFIG_MACH_MINI2440) := friendlyarm-mini2440
board-$(CONFIG_MACH_MINI6410) := friendlyarm-mini6410
board-$(CONFIG_MACH_TINY6410) := friendlyarm-tiny6410
board-$(CONFIG_MACH_QIL_A9260) := qil-a926x
board-$(CONFIG_MACH_QIL_A9G20) := qil-a926x
board-$(CONFIG_MACH_TNY_A9260) := tny-a926x
board-$(CONFIG_MACH_TNY_A9263) := tny-a926x
board-$(CONFIG_MACH_TNY_A9G20) := tny-a926x
board-$(CONFIG_MACH_USB_A9260) := usb-a926x
board-$(CONFIG_MACH_USB_A9263) := usb-a926x
board-$(CONFIG_MACH_USB_A9G20) := usb-a926x
board-$(CONFIG_MACH_VERSATILEPB) := versatile
board-$(CONFIG_MACH_VEXPRESS) := vexpress
board-$(CONFIG_MACH_TX25) := karo-tx25
board-$(CONFIG_MACH_TQMA53) := tqma53
board-$(CONFIG_MACH_TX51) := karo-tx51
board-$(CONFIG_MACH_MX6Q_ARM2) := freescale-mx6-arm2
board-$(CONFIG_MACH_TOSHIBA_AC100) := toshiba-ac100
board-$(CONFIG_MACH_CCMX51) := ccxmx51
board-$(CONFIG_MACH_TINY210) := friendlyarm-tiny210
board-$(CONFIG_MACH_SABRELITE) := freescale-mx6-sabrelite
board-$(CONFIG_MACH_TX53) := karo-tx53
board-$(CONFIG_MACH_GUF_VINCELL) := guf-vincell
board-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) := efika-mx-smartbook
board-$(CONFIG_MACH_SABRESD) := freescale-mx6-sabresd
board-$(CONFIG_MACH_REALQ7) := dmo-mx6-realq7
board-$(CONFIG_MACH_ZEDBOARD) := avnet-zedboard
board-$(CONFIG_MACH_A9M2410) += a9m2410
board-$(CONFIG_MACH_A9M2440) += a9m2440
board-$(CONFIG_MACH_ANIMEO_IP) += animeo_ip
board-$(CONFIG_MACH_ARCHOSG9) += archosg9
board-$(CONFIG_MACH_AT91RM9200EK) += at91rm9200ek
board-$(CONFIG_MACH_AT91SAM9260EK) += at91sam9260ek
board-$(CONFIG_MACH_AT91SAM9261EK) += at91sam9261ek
board-$(CONFIG_MACH_AT91SAM9263EK) += at91sam9263ek
board-$(CONFIG_MACH_AT91SAM9G10EK) += at91sam9261ek
board-$(CONFIG_MACH_AT91SAM9G20EK) += at91sam9260ek
board-$(CONFIG_MACH_AT91SAM9M10G45EK) += at91sam9m10g45ek
board-$(CONFIG_MACH_AT91SAM9M10IHD) += at91sam9m10ihd
board-$(CONFIG_MACH_AT91SAM9N12EK) += at91sam9n12ek
board-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek
board-$(CONFIG_MACH_BEAGLE) += beagle
board-$(CONFIG_MACH_BEAGLEBONE) += beaglebone
board-$(CONFIG_MACH_CCMX51) += ccxmx51
board-$(CONFIG_MACH_CFA10036) += crystalfontz-cfa10036
board-$(CONFIG_MACH_CHUMBY) += chumby_falconwing
board-$(CONFIG_MACH_CLEP7212) += clep7212
board-$(CONFIG_MACH_DSS11) += dss11
board-$(CONFIG_MACH_EDB93012) += edb93xx
board-$(CONFIG_MACH_EDB9301) += edb93xx
board-$(CONFIG_MACH_EDB9302A) += edb93xx
board-$(CONFIG_MACH_EDB9302) += edb93xx
board-$(CONFIG_MACH_EDB9307A) += edb93xx
board-$(CONFIG_MACH_EDB9307) += edb93xx
board-$(CONFIG_MACH_EDB9315A) += edb93xx
board-$(CONFIG_MACH_EDB9315) += edb93xx
board-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) += efika-mx-smartbook
board-$(CONFIG_MACH_EUKREA_CPUIMX25) += eukrea_cpuimx25
board-$(CONFIG_MACH_EUKREA_CPUIMX27) += eukrea_cpuimx27
board-$(CONFIG_MACH_EUKREA_CPUIMX35) += eukrea_cpuimx35
board-$(CONFIG_MACH_EUKREA_CPUIMX51SD) += eukrea_cpuimx51
board-$(CONFIG_MACH_FREESCALE_MX25_3STACK) += freescale-mx25-3-stack
board-$(CONFIG_MACH_FREESCALE_MX35_3STACK) += freescale-mx35-3-stack
board-$(CONFIG_MACH_FREESCALE_MX51_PDK) += freescale-mx51-pdk
board-$(CONFIG_MACH_FREESCALE_MX53_LOCO) += freescale-mx53-loco
board-$(CONFIG_MACH_FREESCALE_MX53_SMD) += freescale-mx53-smd
board-$(CONFIG_MACH_GE863) += telit-evk-pro3
board-$(CONFIG_MACH_GUF_CUPID) += guf-cupid
board-$(CONFIG_MACH_GUF_VINCELL) += guf-vincell
board-$(CONFIG_MACH_HIGHBANK) += highbank
board-$(CONFIG_MACH_IMX21ADS) += imx21ads
board-$(CONFIG_MACH_IMX233_OLINUXINO) += imx233-olinuxino
board-$(CONFIG_MACH_IMX27ADS) += imx27ads
board-$(CONFIG_MACH_MINI2440) += friendlyarm-mini2440
board-$(CONFIG_MACH_MINI6410) += friendlyarm-mini6410
board-$(CONFIG_MACH_MIOA701) += mioa701
board-$(CONFIG_MACH_MMCCPU) += mmccpu
board-$(CONFIG_MACH_MX23EVK) += freescale-mx23-evk
board-$(CONFIG_MACH_MX28EVK) += freescale-mx28-evk
board-$(CONFIG_MACH_MX6Q_ARM2) += freescale-mx6-arm2
board-$(CONFIG_MACH_NESO) += guf-neso
board-$(CONFIG_MACH_NOMADIK_8815NHK) += nhk8815
board-$(CONFIG_MACH_NXDB500) += netx
board-$(CONFIG_MACH_OMAP343xSDP) += omap343xdsp
board-$(CONFIG_MACH_OMAP3EVM) += omap3evm
board-$(CONFIG_MACH_PANDA) += panda
board-$(CONFIG_MACH_PCA100) += phycard-i.MX27
board-$(CONFIG_MACH_PCAAL1) += phycard-a-l1
board-$(CONFIG_MACH_PCAAXL2) += phycard-a-xl2
board-$(CONFIG_MACH_PCM027) += pcm027
board-$(CONFIG_MACH_PCM037) += pcm037
board-$(CONFIG_MACH_PCM038) += pcm038
board-$(CONFIG_MACH_PCM043) += pcm043
board-$(CONFIG_MACH_PCM049) += pcm049
board-$(CONFIG_MACH_PCM051) += pcm051
board-$(CONFIG_MACH_PM9261) += pm9261
board-$(CONFIG_MACH_PM9263) += pm9263
board-$(CONFIG_MACH_PM9G45) += pm9g45
board-$(CONFIG_MACH_QIL_A9260) += qil-a926x
board-$(CONFIG_MACH_QIL_A9G20) += qil-a926x
board-$(CONFIG_MACH_REALQ7) += dmo-mx6-realq7
board-$(CONFIG_MACH_RPI) += raspberry-pi
board-$(CONFIG_MACH_SABRELITE) += freescale-mx6-sabrelite
board-$(CONFIG_MACH_SABRESD) += freescale-mx6-sabresd
board-$(CONFIG_MACH_SAMA5D3XEK) += sama5d3xek
board-$(CONFIG_MACH_SCB9328) += scb9328
board-$(CONFIG_MACH_TINY210) += friendlyarm-tiny210
board-$(CONFIG_MACH_TINY6410) += friendlyarm-tiny6410
board-$(CONFIG_MACH_TNY_A9260) += tny-a926x
board-$(CONFIG_MACH_TNY_A9263) += tny-a926x
board-$(CONFIG_MACH_TNY_A9G20) += tny-a926x
board-$(CONFIG_MACH_TOSHIBA_AC100) += toshiba-ac100
board-$(CONFIG_MACH_TQMA53) += tqma53
board-$(CONFIG_MACH_TX25) += karo-tx25
board-$(CONFIG_MACH_TX28) += karo-tx28
board-$(CONFIG_MACH_TX51) += karo-tx51
board-$(CONFIG_MACH_TX53) += karo-tx53
board-$(CONFIG_MACH_USB_A9260) += usb-a926x
board-$(CONFIG_MACH_USB_A9263) += usb-a926x
board-$(CONFIG_MACH_USB_A9G20) += usb-a926x
board-$(CONFIG_MACH_VERSATILEPB) += versatile
board-$(CONFIG_MACH_VEXPRESS) += vexpress
board-$(CONFIG_MACH_ZEDBOARD) += avnet-zedboard
machdirs := $(patsubst %,arch/arm/mach-%/,$(machine-y))
@ -257,6 +257,14 @@ ifeq ($(machine-y),zynq)
KBUILD_IMAGE := barebox.zynq
endif
CFG_barebox.imx := $(src)/arch/arm/boards/$(board-y)/flash-header.imxcfg
barebox.imx: $(KBUILD_BINARY) FORCE
$(call if_changed,imx_image)
ifeq ($(CONFIG_ARCH_IMX_INTERNAL_BOOT_USE_IMXIMAGE),y)
KBUILD_IMAGE := barebox.imx
endif
pbl := arch/arm/pbl
$(pbl)/zbarebox.S $(pbl)/zbarebox.bin $(pbl)/zbarebox: barebox.bin FORCE
$(Q)$(MAKE) $(build)=$(pbl) $@
@ -301,4 +309,6 @@ common-$(CONFIG_BUILTIN_DTB) += arch/arm/dts/
lds-y := arch/arm/lib/barebox.lds
common- += $(patsubst %,arch/arm/boards/%/,$(board-))
CLEAN_FILES += include/generated/mach-types.h arch/arm/lib/barebox.lds barebox-flash-image

View File

@ -1,3 +1,3 @@
obj-y += board.o
lwl-y += flash_header.o
obj-y += board.o flash-header.o
extra-y += flash-header.S flash-header.dcd
lwl-y += lowlevel.o

View File

@ -229,9 +229,7 @@ static void babbage_power_init(void)
mdelay(50);
}
#define DCD_NAME static struct imx_dcd_entry dcd_entry
#include "dcd-data.h"
extern char flash_header_start[], flash_header_end[];
static int f3s_devices_init(void)
{
@ -254,7 +252,8 @@ static int f3s_devices_init(void)
armlinux_set_architecture(MACH_TYPE_MX51_BABBAGE);
imx51_bbu_internal_mmc_register_handler("mmc", "/dev/disk0",
BBU_HANDLER_FLAG_DEFAULT, dcd_entry, sizeof(dcd_entry), 0);
BBU_HANDLER_FLAG_DEFAULT, (void *)flash_header_start,
flash_header_end - flash_header_start, 0);
return 0;
}

View File

@ -1,60 +0,0 @@
DCD_NAME[] = {
{ .ptr_type = 4, .addr = 0x73fa88a0, .val = 0x00000200, },
{ .ptr_type = 4, .addr = 0x73fa850c, .val = 0x000020c5, },
{ .ptr_type = 4, .addr = 0x73fa8510, .val = 0x000020c5, },
{ .ptr_type = 4, .addr = 0x73fa883c, .val = 0x00000002, },
{ .ptr_type = 4, .addr = 0x73fa8848, .val = 0x00000002, },
{ .ptr_type = 4, .addr = 0x73fa84b8, .val = 0x000000e7, },
{ .ptr_type = 4, .addr = 0x73fa84bc, .val = 0x00000045, },
{ .ptr_type = 4, .addr = 0x73fa84c0, .val = 0x00000045, },
{ .ptr_type = 4, .addr = 0x73fa84c4, .val = 0x00000045, },
{ .ptr_type = 4, .addr = 0x73fa84c8, .val = 0x00000045, },
{ .ptr_type = 4, .addr = 0x73fa8820, .val = 0x00000000, },
{ .ptr_type = 4, .addr = 0x73fa84a4, .val = 0x00000003, },
{ .ptr_type = 4, .addr = 0x73fa84a8, .val = 0x00000003, },
{ .ptr_type = 4, .addr = 0x73fa84ac, .val = 0x000000e3, },
{ .ptr_type = 4, .addr = 0x73fa84b0, .val = 0x000000e3, },
{ .ptr_type = 4, .addr = 0x73fa84b4, .val = 0x000000e3, },
{ .ptr_type = 4, .addr = 0x73fa84cc, .val = 0x000000e3, },
{ .ptr_type = 4, .addr = 0x73fa84d0, .val = 0x000000e2, },
{ .ptr_type = 4, .addr = 0x73fa882c, .val = 0x00000004, },
{ .ptr_type = 4, .addr = 0x73fa88a4, .val = 0x00000004, },
{ .ptr_type = 4, .addr = 0x73fa88ac, .val = 0x00000004, },
{ .ptr_type = 4, .addr = 0x73fa88b8, .val = 0x00000004, },
{ .ptr_type = 4, .addr = 0x83fd9000, .val = 0x82a20000, },
{ .ptr_type = 4, .addr = 0x83fd9008, .val = 0x82a20000, },
{ .ptr_type = 4, .addr = 0x83fd9010, .val = 0x000ad0d0, },
{ .ptr_type = 4, .addr = 0x83fd9004, .val = 0x3f3584ab, },
{ .ptr_type = 4, .addr = 0x83fd900c, .val = 0x3f3584ab, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x04008008, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0000801a, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0000801b, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00448019, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x07328018, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x04008008, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00008010, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00008010, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x06328018, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x03808019, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00408019, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00008000, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0400800c, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0000801e, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0000801f, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0000801d, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0732801c, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0400800c, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00008014, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00008014, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0632801c, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0380801d, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x0040801d, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00008004, },
{ .ptr_type = 4, .addr = 0x83fd9000, .val = 0xb2a20000, },
{ .ptr_type = 4, .addr = 0x83fd9008, .val = 0xb2a20000, },
{ .ptr_type = 4, .addr = 0x83fd9010, .val = 0x000ad6d0, },
{ .ptr_type = 4, .addr = 0x83fd9034, .val = 0x90000000, },
{ .ptr_type = 4, .addr = 0x83fd9014, .val = 0x00000000, },
};

View File

@ -0,0 +1,59 @@
loadaddr 0x90000000
soc imx51
dcdofs 0x400
wm 32 0x73fa88a0 0x00000200
wm 32 0x73fa850c 0x000020c5
wm 32 0x73fa8510 0x000020c5
wm 32 0x73fa883c 0x00000002
wm 32 0x73fa8848 0x00000002
wm 32 0x73fa84b8 0x000000e7
wm 32 0x73fa84bc 0x00000045
wm 32 0x73fa84c0 0x00000045
wm 32 0x73fa84c4 0x00000045
wm 32 0x73fa84c8 0x00000045
wm 32 0x73fa8820 0x00000000
wm 32 0x73fa84a4 0x00000003
wm 32 0x73fa84a8 0x00000003
wm 32 0x73fa84ac 0x000000e3
wm 32 0x73fa84b0 0x000000e3
wm 32 0x73fa84b4 0x000000e3
wm 32 0x73fa84cc 0x000000e3
wm 32 0x73fa84d0 0x000000e2
wm 32 0x73fa882c 0x00000004
wm 32 0x73fa88a4 0x00000004
wm 32 0x73fa88ac 0x00000004
wm 32 0x73fa88b8 0x00000004
wm 32 0x83fd9000 0x82a20000
wm 32 0x83fd9008 0x82a20000
wm 32 0x83fd9010 0x000ad0d0
wm 32 0x83fd9004 0x3f3584ab
wm 32 0x83fd900c 0x3f3584ab
wm 32 0x83fd9014 0x04008008
wm 32 0x83fd9014 0x0000801a
wm 32 0x83fd9014 0x0000801b
wm 32 0x83fd9014 0x00448019
wm 32 0x83fd9014 0x07328018
wm 32 0x83fd9014 0x04008008
wm 32 0x83fd9014 0x00008010
wm 32 0x83fd9014 0x00008010
wm 32 0x83fd9014 0x06328018
wm 32 0x83fd9014 0x03808019
wm 32 0x83fd9014 0x00408019
wm 32 0x83fd9014 0x00008000
wm 32 0x83fd9014 0x0400800c
wm 32 0x83fd9014 0x0000801e
wm 32 0x83fd9014 0x0000801f
wm 32 0x83fd9014 0x0000801d
wm 32 0x83fd9014 0x0732801c
wm 32 0x83fd9014 0x0400800c
wm 32 0x83fd9014 0x00008014
wm 32 0x83fd9014 0x00008014
wm 32 0x83fd9014 0x0632801c
wm 32 0x83fd9014 0x0380801d
wm 32 0x83fd9014 0x0040801d
wm 32 0x83fd9014 0x00008004
wm 32 0x83fd9000 0xb2a20000
wm 32 0x83fd9008 0xb2a20000
wm 32 0x83fd9010 0x000ad6d0
wm 32 0x83fd9034 0x90000000
wm 32 0x83fd9014 0x00000000

View File

@ -1,29 +0,0 @@
#include <common.h>
#include <mach/imx-flash-header.h>
#include <asm/barebox-arm-head.h>
void __naked __flash_header_start go(void)
{
barebox_arm_head();
}
#define DCD_NAME struct imx_dcd_entry __dcd_entry_section dcd_entry
#include "dcd-data.h"
#define APP_DEST 0x90000000
struct imx_flash_header __flash_header_section flash_header = {
.app_code_jump_vector = APP_DEST + 0x1000,
.app_code_barker = APP_CODE_BARKER,
.app_code_csf = 0,
.dcd_ptr_ptr = APP_DEST + 0x400 + offsetof(struct imx_flash_header, dcd),
.super_root_key = 0,
.dcd = APP_DEST + 0x400 + offsetof(struct imx_flash_header, dcd_barker),
.app_dest = APP_DEST,
.dcd_barker = DCD_BARKER,
.dcd_block_len = sizeof (dcd_entry),
};
unsigned long __image_len_section barebox_len = DCD_BAREBOX_SIZE;

View File

@ -48,13 +48,20 @@
#define PCM038_GPIO_FEC_RST (GPIO_PORTC + 30)
#define PCM038_GPIO_SPI_CS0 (GPIO_PORTD + 28)
#define PCM970_GPIO_SPI_CS1 (GPIO_PORTD + 27)
#define PCM038_GPIO_OTG_STP (GPIO_PORTE + 1)
static struct fec_platform_data fec_info = {
.xcv_type = PHY_INTERFACE_MODE_MII,
.phy_addr = 1,
};
static int pcm038_spi_cs[] = { PCM038_GPIO_SPI_CS0 };
static int pcm038_spi_cs[] = {
PCM038_GPIO_SPI_CS0,
#ifdef CONFIG_MACH_PCM970_BASEBOARD
PCM970_GPIO_SPI_CS1,
#endif
};
static struct spi_imx_master pcm038_spi_0_data = {
.chipselect = pcm038_spi_cs,
@ -186,6 +193,11 @@ static int pcm038_power_init(void)
return 0;
}
struct imxusb_platformdata pcm038_otg_pdata = {
.mode = IMX_USB_MODE_DEVICE,
.flags = MXC_EHCI_MODE_ULPI | MXC_EHCI_INTERFACE_DIFF_UNI,
};
static int pcm038_devices_init(void)
{
int i;
@ -221,10 +233,13 @@ static int pcm038_devices_init(void)
PE15_PF_UART1_RTS,
/* CSPI1 */
PD25_PF_CSPI1_RDY,
PCM038_GPIO_SPI_CS0 | GPIO_GPIO | GPIO_OUT,
PD29_PF_CSPI1_SCLK,
PD30_PF_CSPI1_MISO,
PD31_PF_CSPI1_MOSI,
PCM038_GPIO_SPI_CS0 | GPIO_GPIO | GPIO_OUT,
#ifdef CONFIG_MACH_PCM970_BASEBOARD
PCM970_GPIO_SPI_CS1 | GPIO_GPIO | GPIO_OUT,
#endif
/* Display */
PA5_PF_LSCLK,
PA6_PF_LD0,
@ -253,7 +268,7 @@ static int pcm038_devices_init(void)
PA29_PF_VSYNC,
PA30_PF_CONTRAST,
PA31_PF_OE_ACD,
/* OTG host */
/* USB OTG */
PC7_PF_USBOTG_DATA5,
PC8_PF_USBOTG_DATA6,
PC9_PF_USBOTG_DATA0,
@ -262,7 +277,7 @@ static int pcm038_devices_init(void)
PC12_PF_USBOTG_DATA4,
PC13_PF_USBOTG_DATA3,
PE0_PF_USBOTG_NXT,
PE1_PF_USBOTG_STP,
PCM038_GPIO_OTG_STP | GPIO_GPIO | GPIO_OUT,
PE2_PF_USBOTG_DIR,
PE24_PF_USBOTG_CLK,
PE25_PF_USBOTG_DATA7,
@ -308,6 +323,13 @@ static int pcm038_devices_init(void)
gpio_set_value(PCM038_GPIO_FEC_RST, 1);
imx27_add_fec(&fec_info);
/* Apply delay for STP line to stop ULPI */
gpio_direction_output(PCM038_GPIO_OTG_STP, 1);
mdelay(1);
imx_gpio_mode(PE1_PF_USBOTG_STP);
imx27_add_usbotg(&pcm038_otg_pdata);
switch (bootsource_get()) {
case BOOTSOURCE_NAND:
devfs_add_partition("nand0", 0x00000, 0x80000,

View File

@ -66,6 +66,7 @@ config BOARDINFO
choice
prompt "Select boot mode"
depends on !ARCH_IMX_INTERNAL_BOOT_USE_IMXIMAGE
help
i.MX processors support two different boot modes. With the internal
boot mode the boot medium contains a header describing the image to
@ -93,6 +94,21 @@ config ARCH_IMX_EXTERNAL_BOOT
endchoice
config ARCH_IMX_IMXIMAGE
bool
help
if enabled the imx-image tool is compiled
config ARCH_IMX_INTERNAL_BOOT_USE_IMXIMAGE
select ARCH_IMX_IMXIMAGE
bool
help
Traditionally the i.MX specific format for internal bootmode
was generated using C structs inside the binary. Now there is
a tool available to generate the imx-image format. Boards using
this tool must select this option. This is recommended for new
boards.
choice
depends on ARCH_IMX_INTERNAL_BOOT
prompt "Internal boot source"
@ -407,6 +423,7 @@ choice
config MACH_FREESCALE_MX51_PDK
select HAVE_DEFAULT_ENVIRONMENT_NEW
select ARCH_IMX_INTERNAL_BOOT_USE_IMXIMAGE
bool "Freescale i.MX51 PDK"
config MACH_EUKREA_CPUIMX51SD
@ -596,6 +613,13 @@ endmenu
menu "i.MX specific settings"
config ARCH_IMX_USBLOADER
bool "compile imx-usb-loader"
help
imx-usb-loader is a tool to upload and start imximages to an i.MX SoC
in ROM boot mode. It requires libusb, so make sure you have the libusb
devel package installed on your machine.
config IMX_IIM
tristate "IIM fusebox device"
depends on !ARCH_IMX21 && !ARCH_IMX21

View File

@ -95,15 +95,63 @@ postcore_initcall(imx51_init);
* power up.
*/
#define DP_MFN_800_DIT 60 /* PL Dither mode */
/*
* Workaround for i.MX51 PLL errata. This is needed by all boards using the
* i.MX51 silicon version up until (including) 3.0 running at 800MHz.
* The PLL's in the i.MX51 processor can go out of lock due to a metastable
* condition in an analog flip-flop when used at high frequencies.
* This workaround implements an undocumented feature in the PLL (dither
* mode), which causes the effect of this failure to be much lower (in terms
* of frequency deviation), avoiding system failure, or at least decreasing
* the likelihood of system failure.
*/
static void imx51_setup_pll800_bug(void)
{
void __iomem *base = (void *)MX51_PLL1_BASE_ADDR;
u32 dp_config;
volatile int i;
imx5_setup_pll_864(base);
dp_config = readl(base + MX5_PLL_DP_CONFIG);
dp_config &= ~MX5_PLL_DP_CONFIG_AREN;
writel(dp_config, base + MX5_PLL_DP_CONFIG);
/* Restart PLL with PLM = 1 */
writel(0x00001236, base + MX5_PLL_DP_CTL);
/* Wait for lock */
while (!(readl(base + MX5_PLL_DP_CTL) & 1));
/* Modify MFN value */
writel(DP_MFN_800_DIT, base + MX5_PLL_DP_MFN);
writel(DP_MFN_800_DIT, base + MX5_PLL_DP_HFS_MFN);
/* Reload MFN value */
writel(0x1, base + MX5_PLL_DP_CONFIG);
while (readl(base + MX5_PLL_DP_CONFIG) & 1);
/* Wait at least 4 us */
for (i = 0; i < 100; i++);
/* Enable auto-restart AREN bit */
dp_config |= MX5_PLL_DP_CONFIG_AREN;
writel(dp_config, base + MX5_PLL_DP_CONFIG);
}
void imx51_init_lowlevel(unsigned int cpufreq_mhz)
{
void __iomem *ccm = (void __iomem *)MX51_CCM_BASE_ADDR;
u32 r;
int rev = imx_silicon_revision();
imx5_init_lowlevel();
/* disable write combine for TO 2 and lower revs */
if (imx_silicon_revision() < IMX_CHIP_REV_3_0) {
if (rev < IMX_CHIP_REV_3_0) {
__asm__ __volatile__("mrc 15, 1, %0, c9, c0, 1":"=r"(r));
r |= (1 << 25);
__asm__ __volatile__("mcr 15, 1, %0, c9, c0, 1" : : "r"(r));
@ -135,7 +183,10 @@ void imx51_init_lowlevel(unsigned int cpufreq_mhz)
break;
default:
/* Default maximum 800MHz */
imx5_setup_pll_800((void __iomem *)MX51_PLL1_BASE_ADDR);
if (rev <= IMX_CHIP_REV_3_0)
imx51_setup_pll800_bug();
else
imx5_setup_pll_800((void __iomem *)MX51_PLL1_BASE_ADDR);
break;
}

View File

@ -9,6 +9,7 @@ void imx5_init_lowlevel(void);
void imx5_setup_pll(void __iomem *base, int freq, u32 op, u32 mfd, u32 mfn);
#define imx5_setup_pll_1000(base) imx5_setup_pll((base), 1000, ((10 << 4) + ((1 - 1) << 0)), (12 - 1), 5)
#define imx5_setup_pll_864(base) imx5_setup_pll((base), 864, (( 8 << 4) + ((1 - 1) << 0)), (180 - 1), 180)
#define imx5_setup_pll_800(base) imx5_setup_pll((base), 800, (( 8 << 4) + ((1 - 1) << 0)), (3 - 1), 1)
#define imx5_setup_pll_665(base) imx5_setup_pll((base), 665, (( 6 << 4) + ((1 - 1) << 0)), (96 - 1), 89)
#define imx5_setup_pll_600(base) imx5_setup_pll((base), 600, (( 6 << 4) + ((1 - 1) << 0)), ( 4 - 1), 1)

View File

@ -13,6 +13,7 @@ hostprogs-$(CONFIG_ARCH_OMAP) += omap_signGP mk-am35xx-spi-image
hostprogs-$(CONFIG_ARCH_S5PCxx) += s5p_cksum
hostprogs-$(CONFIG_ARCH_DAVINCI) += mkublheader
hostprogs-$(CONFIG_ARCH_ZYNQ) += zynq_mkimage
subdir-$(CONFIG_ARCH_IMX) += imx
HOSTLOADLIBES_omap4_usbboot = -lpthread
omap4_usbboot-objs := usb_linux.o omap4_usbboot.o

View File

@ -308,3 +308,28 @@ quiet_cmd_check_file_size = CHKSIZE $@
echo "$@ size $$size > of the maximum size $$max_size" >&2; \
exit 1 ; \
fi;
quiet_cmd_imximage__S_dcd= DCD_S $@
cmd_imximage_S_dcd= \
( \
echo '\#include <asm-generic/barebox.lds.h>'; \
echo '.balign STRUCT_ALIGNMENT'; \
echo '.global $(subst -,_,$(*F))_start'; \
echo '$(subst -,_,$(*F))_start:'; \
echo '.incbin "$<" '; \
echo '$(subst -,_,$(*F))_end:'; \
echo '.global $(subst -,_,$(*F))_end'; \
echo '.balign STRUCT_ALIGNMENT'; \
) > $@
quiet_cmd_dcd = DCD $@
cmd_dcd = $(objtree)/scripts/imx/imx-image -d -o $@ -c $<
$(obj)/%.dcd: $(obj)/%.imxcfg FORCE
$(call if_changed,dcd)
$(obj)/%.S: $(obj)/%.dcd
$(call cmd,imximage_S_dcd)
quiet_cmd_imx_image = IMX-IMG $@
cmd_imx_image = $(obj)/scripts/imx/imx-image -b -c $(CFG_$(@F)) -f $< -o $@

2
scripts/imx/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
imx-usb-loader
imx-image

10
scripts/imx/Makefile Normal file
View File

@ -0,0 +1,10 @@
hostprogs-$(CONFIG_ARCH_IMX_IMXIMAGE) += imx-image
hostprogs-$(CONFIG_ARCH_IMX_USBLOADER) += imx-usb-loader
always := $(hostprogs-y)
HOSTCFLAGS_imx-usb-loader.o = `pkg-config --cflags libusb-1.0`
HOSTLOADLIBES_imx-usb-loader = `pkg-config --libs libusb-1.0`
imx-usb-loader-objs := imx-usb-loader.o
imx-image-objs := imx-image.o

89
scripts/imx/README Normal file
View File

@ -0,0 +1,89 @@
imx-usb-loader Tools
The Freescale i.MX SoCs support bootstrapping from USB. These are host
side utilities handling this bootstrap process.
The imx-usb-loader tool is used to upload and start i.MX images. These
are images containing a DCD (Device Configuration Data) table. To generate
these images from raw binaries use the imx-image tool.
imx-image
---------
The imx-image tool can be used to generate imximages from raw binaries.
It requires an configuration file describing how to setup the SDRAM on
a particular board. This mainly consists of a poke table. The recognized
options in this file are:
soc <soctype> soctype can be one of imx35, imx51, imx53, imx6
loadaddr <adr> The address the binary is uploaded to
dcdofs <ofs> The offset of the image header in the image. This should be:
0x400 - MMC/SD, NAND, serial ROM, PATA, SATA
0x1000 - NOR Flash
0x100 - OneNAND
wm 8 <adr> <value> do a byte memory write
wm 16 <adr> <value> do a short memory write
wm 32 <adr> <value> do a word memory write
check <width> <cond> <addr> <mask> Poll until condition becomes true.
with <cond> being one of:
while_all_bits_clear,
while_all_bits_set,
while_any_bit_clear,
while_any_bit_set
the i.MX SoCs support a wide range of fancy things doing with the flash header.
We limit ourselves to a very simple case, that is the flash header has a fixed
size of 0x1000 bytes. The application is expected right thereafter, so if you
specify a loadaddr of 0x80000000 in the config file, the first 0x1000 bytes
are occupied by the flash header. The raw image inside the imximage will then
end up at 0x80001000 from where it is then executed.
Example config file, suitable for an Eukra cpuimx35:
soc imx35
dcdofs 0x400
loadaddr 0x80000000
wm 32 0x53F80004 0x00821000
wm 32 0x53F80004 0x00821000
wm 32 0xb8001010 0x00000004
wm 32 0xB8001010 0x0000000C
wm 32 0xb8001004 0x0009572B
wm 32 0xb8001000 0x92220000
wm 8 0x80000400 0xda
wm 32 0xb8001000 0xa2220000
wm 32 0x80000000 0x12344321
wm 32 0x80000000 0x12344321
wm 32 0xb8001000 0xb2220000
wm 8 0x80000033 0xda
wm 8 0x82000000 0xda
wm 32 0xb8001000 0x82224080
wm 32 0xb8001010 0x00000004
example call:
imx-image -c cpuimx35.cfg -f raw.bin -o imximage.bin
imx-usb-loader
--------------
This utility is used to upload an imximage to a board. Some bootloaders directly
generate this file format, with others you can generate such an image with the
imx-image tool. The only required argument is the image file to upload. imx-usb-loader
will then look for a supported device, upload the file and execute it.
example usage:
imx-usb-loader imximage.bin
Some technical notes: The i.MX SoCs USB ROM boot mode supports doing register writes
and file uploads. The files are usually uploaded to SDRAM. For this to work the SDRAM
has to be initialized first. The information necessary to do this is contained in the
imximage itself, more exactly in the DCD table. The imx-usb-loader parses this table
and translates the DCD into register writes, basically it resembles what the i.MX would
do in ROM code when the same image would be loaded from another bootsource like SD/MMC
cards. Still the i.MX needs the DCD table to be uploaded. The i.MX would execute the DCD
data again, which would result in corrupting the just configured SDRAM. The imx-usb-loader
prevents this by setting the DCD length to 0x0 before uploading the image.
The i.MX Boot ROM supports different types of images to upload. The imx-usb-loader currently
only handles the simple case of uploading a single image which is executed right after
downloading.

744
scripts/imx/imx-image.c Normal file
View File

@ -0,0 +1,744 @@
/*
* (C) Copyright 2013 Sascha Hauer, Pengutronix
*
* See file CREDITS for list of people who contributed to this
* project.
*
* 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 <stdio.h>
#include <unistd.h>
#include <getopt.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <endian.h>
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
#define MAX_DCD 1024
static uint32_t image_load_addr;
static uint32_t image_dcd_offset;
static uint32_t dcdtable[MAX_DCD];
static int curdcd;
static int header_version;
static int add_barebox_header;
/*
* ============================================================================
* i.MX flash header v1 handling. Found on i.MX35 and i.MX51
* ============================================================================
*/
struct imx_flash_header {
uint32_t app_code_jump_vector;
uint32_t app_code_barker;
uint32_t app_code_csf;
uint32_t dcd_ptr_ptr;
uint32_t super_root_key;
uint32_t dcd;
uint32_t app_dest;
uint32_t dcd_barker;
uint32_t dcd_block_len;
} __attribute__((packed));
#define FLASH_HEADER_OFFSET 0x400
#define DCD_BARKER 0xb17219e9
static uint32_t bb_header[] = {
0xea0003fe, /* b 0x1000 */
0xeafffffe, /* 1: b 1b */
0xeafffffe, /* 1: b 1b */
0xeafffffe, /* 1: b 1b */
0xeafffffe, /* 1: b 1b */
0xeafffffe, /* 1: b 1b */
0xeafffffe, /* 1: b 1b */
0xeafffffe, /* 1: b 1b */
0x65726162, /* 'bare' */
0x00786f62, /* 'box\0' */
0x00000000,
0x00000000,
0x55555555,
0x55555555,
0x55555555,
0x55555555,
0x55555555,
0x55555555,
0x55555555,
0x55555555,
};
static int add_header_v1(void *buf, int offset, uint32_t loadaddr, uint32_t imagesize)
{
struct imx_flash_header *hdr;
int dcdsize = curdcd * sizeof(uint32_t);
if (add_barebox_header)
memcpy(buf, bb_header, sizeof(bb_header));
buf += offset;
hdr = buf;
hdr->app_code_jump_vector = loadaddr + 0x1000;
hdr->app_code_barker = 0x000000b1;
hdr->app_code_csf = 0x0;
hdr->dcd_ptr_ptr = loadaddr + offset + offsetof(struct imx_flash_header, dcd);
hdr->super_root_key = 0x0;
hdr->dcd = loadaddr + offset + offsetof(struct imx_flash_header, dcd_barker);
hdr->app_dest = loadaddr;
hdr->dcd_barker = DCD_BARKER;
hdr->dcd_block_len = dcdsize;
buf += sizeof(struct imx_flash_header);
memcpy(buf, dcdtable, dcdsize);
buf += dcdsize;
*(uint32_t *)buf = imagesize;
return 0;
}
static int write_mem_v1(uint32_t addr, uint32_t val, int width)
{
if (curdcd > MAX_DCD - 3) {
fprintf(stderr, "At maximum %d dcd entried are allowed\n", MAX_DCD);
return -ENOMEM;
}
dcdtable[curdcd++] = width;
dcdtable[curdcd++] = addr;
dcdtable[curdcd++] = val;
return 0;
}
/*
* ============================================================================
* i.MX flash header v2 handling. Found on i.MX53 and i.MX6
* ============================================================================
*/
struct imx_boot_data {
uint32_t start;
uint32_t size;
uint32_t plugin;
} __attribute__((packed));
#define TAG_IVT_HEADER 0xd1
#define IVT_VERSION 0x40
#define TAG_DCD_HEADER 0xd2
#define DCD_VERSION 0x40
#define TAG_WRITE 0xcc
#define TAG_CHECK 0xcf
struct imx_ivt_header {
uint8_t tag;
uint16_t length;
uint8_t version;
} __attribute__((packed));
struct imx_flash_header_v2 {
struct imx_ivt_header header;
uint32_t entry;
uint32_t reserved1;
uint32_t dcd_ptr;
uint32_t boot_data_ptr;
uint32_t self;
uint32_t csf;
uint32_t reserved2;
struct imx_boot_data boot_data;
struct imx_ivt_header dcd_header;
} __attribute__((packed));
static int add_header_v2(void *buf, int offset, uint32_t loadaddr, uint32_t imagesize)
{
struct imx_flash_header_v2 *hdr;
int dcdsize = curdcd * sizeof(uint32_t);
if (add_barebox_header)
memcpy(buf, bb_header, sizeof(bb_header));
buf += offset;
hdr = buf;
hdr->header.tag = TAG_IVT_HEADER;
hdr->header.length = htobe16(32);
hdr->header.version = IVT_VERSION;
hdr->entry = loadaddr + 0x1000;
hdr->dcd_ptr = loadaddr + 0x400 + offsetof(struct imx_flash_header_v2, dcd_header);
hdr->boot_data_ptr = loadaddr + 0x400 + offsetof(struct imx_flash_header_v2, boot_data);
hdr->self = loadaddr + 0x400;
hdr->boot_data.start = loadaddr;
hdr->boot_data.size = imagesize;
hdr->dcd_header.tag = TAG_DCD_HEADER;
hdr->dcd_header.length = htobe16(sizeof(uint32_t) + dcdsize);
hdr->dcd_header.version = DCD_VERSION;
buf += sizeof(*hdr);
memcpy(buf, dcdtable, dcdsize);
return 0;
}
static void usage(const char *prgname)
{
fprintf(stderr, "usage: %s [OPTIONS]\n\n"
"-c <config> specify configuration file\n"
"-f <input> input image file\n"
"-o <output> output file\n"
"-b add barebox header to image. If used, barebox recognizes\n"
" the image as regular barebox image which can be used as\n"
" second stage image\n"
"-h this help\n", prgname);
exit(1);
}
#define MAXARGS 5
static int parse_line(char *line, char *argv[])
{
int nargs = 0;
while (nargs < MAXARGS) {
/* skip any white space */
while ((*line == ' ') || (*line == '\t'))
++line;
if (*line == '\0') /* end of line, no more args */
argv[nargs] = NULL;
if (*line == '\0') { /* end of line, no more args */
argv[nargs] = NULL;
return nargs;
}
argv[nargs++] = line; /* begin of argument string */
/* find end of string */
while (*line && (*line != ' ') && (*line != '\t'))
++line;
if (*line == '\0') { /* end of line, no more args */
argv[nargs] = NULL;
return nargs;
}
*line++ = '\0'; /* terminate current arg */
}
printf("** Too many args (max. %d) **\n", MAXARGS);
return nargs;
}
struct command {
const char *name;
int (*parse)(int argc, char *argv[]);
};
static uint32_t last_cmd;
static int last_cmd_len;
static uint32_t *last_dcd;
static void check_last_dcd(uint32_t cmd)
{
if (last_dcd) {
if (last_cmd == cmd) {
return;
} else {
uint32_t l = be32toh(*last_dcd);
l |= last_cmd_len << 8;
*last_dcd = htobe32(l);
last_dcd = NULL;
}
}
if (!cmd)
return;
if (!last_dcd) {
last_dcd = &dcdtable[curdcd++];
*last_dcd = htobe32(cmd);
last_cmd_len = sizeof(uint32_t);
last_cmd = cmd;
}
}
static int write_mem_v2(uint32_t addr, uint32_t val, int width)
{
uint32_t cmd;
cmd = (TAG_WRITE << 24) | width;
if (curdcd > MAX_DCD - 3) {
fprintf(stderr, "At maximum %d dcd entried are allowed\n", MAX_DCD);
return -ENOMEM;
}
check_last_dcd(cmd);
last_cmd_len += sizeof(uint32_t) * 2;
dcdtable[curdcd++] = htobe32(addr);
dcdtable[curdcd++] = htobe32(val);
return 0;
}
static const char *check_cmds[] = {
"while_all_bits_clear", /* while ((*address & mask) == 0); */
"while_all_bits_set" , /* while ((*address & mask) == mask); */
"while_any_bit_clear", /* while ((*address & mask) != mask); */
"while_any_bit_set", /* while ((*address & mask) != 0); */
};
static void do_cmd_check_usage(void)
{
fprintf(stderr,
"usage: check <width> <cmd> <addr> <mask>\n"
"<width> access width in bytes [1|2|4]\n"
"with <cmd> one of:\n"
"while_all_bits_clear: while ((*addr & mask) == 0)\n"
"while_all_bits_set: while ((*addr & mask) == mask)\n"
"while_any_bit_clear: while ((*addr & mask) != mask)\n"
"while_any_bit_set: while ((*addr & mask) != 0)\n");
}
static int do_cmd_check(int argc, char *argv[])
{
uint32_t addr, mask, cmd;
int i, width;
const char *scmd;
if (argc < 5) {
do_cmd_check_usage();
return -EINVAL;
}
width = strtoul(argv[1], NULL, 0) >> 3;
scmd = argv[2];
addr = strtoul(argv[3], NULL, 0);
mask = strtoul(argv[4], NULL, 0);
switch (width) {
case 1:
case 2:
case 4:
break;
default:
fprintf(stderr, "illegal width %d\n", width);
return -EINVAL;
};
if (curdcd > MAX_DCD - 3) {
fprintf(stderr, "At maximum %d dcd entried are allowed\n", MAX_DCD);
return -ENOMEM;
}
for (i = 0; i < ARRAY_SIZE(check_cmds); i++) {
if (!strcmp(scmd, check_cmds[i]))
break;
}
if (i == ARRAY_SIZE(check_cmds)) {
do_cmd_check_usage();
return -EINVAL;
}
cmd = (TAG_CHECK << 24) | (i << 3) | width;
check_last_dcd(cmd);
last_cmd_len += sizeof(uint32_t) * 2;
dcdtable[curdcd++] = htobe32(addr);
dcdtable[curdcd++] = htobe32(mask);
return 0;
}
static int do_cmd_write_mem(int argc, char *argv[])
{
uint32_t addr, val, width;
if (argc != 4) {
fprintf(stderr, "usage: wm [8|16|32] <addr> <val>\n");
return -EINVAL;
}
width = strtoul(argv[1], NULL, 0);
addr = strtoul(argv[2], NULL, 0);
val = strtoul(argv[3], NULL, 0);
width >>= 3;
switch (width) {
case 1:
case 2:
case 4:
break;
default:
fprintf(stderr, "illegal width %d\n", width);
return -EINVAL;
};
switch (header_version) {
case 1:
return write_mem_v1(addr, val, width);
case 2:
return write_mem_v2(addr, val, width);
default:
return -EINVAL;
}
}
static int do_loadaddr(int argc, char *argv[])
{
if (argc < 2)
return -EINVAL;
image_load_addr = strtoul(argv[1], NULL, 0);
return 0;
}
static int do_dcd_offset(int argc, char *argv[])
{
if (argc < 2)
return -EINVAL;
image_dcd_offset = strtoul(argv[1], NULL, 0);
return 0;
}
struct soc_type {
char *name;
int header_version;
};
static struct soc_type socs[] = {
{ .name = "imx35", .header_version = 1, },
{ .name = "imx51", .header_version = 1, },
{ .name = "imx53", .header_version = 2, },
{ .name = "imx6", .header_version = 2, },
};
static int do_soc(int argc, char *argv[])
{
char *soc;
int i;
if (argc < 2)
return -EINVAL;
soc = argv[1];
for (i = 0; i < ARRAY_SIZE(socs); i++) {
if (!strcmp(socs[i].name, soc)) {
header_version = socs[i].header_version;
return 0;
}
}
fprintf(stderr, "unkown SoC type \"%s\". Known SoCs are:\n", soc);
for (i = 0; i < ARRAY_SIZE(socs); i++)
fprintf(stderr, "%s ", socs[i].name);
fprintf(stderr, "\n");
return -EINVAL;
}
struct command cmds[] = {
{
.name = "wm",
.parse = do_cmd_write_mem,
}, {
.name = "check",
.parse = do_cmd_check,
}, {
.name = "loadaddr",
.parse = do_loadaddr,
}, {
.name = "dcdofs",
.parse = do_dcd_offset,
}, {
.name = "soc",
.parse = do_soc,
},
};
static int parse_config(const char *filename)
{
FILE *f;
int lineno = 0;
char *line = NULL, *tmp;
size_t len;
char *argv[MAXARGS];
int nargs, i, ret;
f = fopen(filename, "r");
if (!f) {
fprintf(stderr, "Error: %s - Can't open DCD file\n", filename);
exit(1);
}
while ((getline(&line, &len, f)) > 0) {
lineno++;
tmp = strchr(line, '#');
if (tmp)
*tmp = 0;
tmp = strrchr(line, '\n');
if (tmp)
*tmp = 0;
nargs = parse_line(line, argv);
if (!nargs)
continue;
ret = -ENOENT;
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
if (!strcmp(cmds[i].name, argv[0])) {
ret = cmds[i].parse(nargs, argv);
if (ret) {
fprintf(stderr, "error in line %d: %s\n",
lineno, strerror(-ret));
return ret;
}
break;
}
}
if (ret == -ENOENT) {
fprintf(stderr, "no such command: %s\n", argv[0]);
return ret;
}
}
return 0;
}
static int xread(int fd, void *buf, int len)
{
int ret;
while (len) {
ret = read(fd, buf, len);
if (ret < 0)
return ret;
if (!ret)
return EOF;
buf += ret;
len -= ret;
}
return 0;
}
static int xwrite(int fd, void *buf, int len)
{
int ret;
while (len) {
ret = write(fd, buf, len);
if (ret < 0)
return ret;
buf += ret;
len -= ret;
}
return 0;
}
static int write_dcd(const char *outfile)
{
int outfd, ret;
int dcdsize = curdcd * sizeof(uint32_t);
outfd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (outfd < 0) {
perror("open");
exit(1);
}
ret = xwrite(outfd, dcdtable, dcdsize);
if (ret < 0) {
perror("write");
exit(1);
}
return 0;
}
int main(int argc, char *argv[])
{
int opt, ret;
char *configfile = NULL;
char *imagename = NULL;
char *outfile = NULL;
void *buf;
size_t image_size = 0;
struct stat s;
int infd, outfd;
int dcd_only = 0;
while ((opt = getopt(argc, argv, "c:hf:o:bd")) != -1) {
switch (opt) {
case 'c':
configfile = optarg;
break;
case 'f':
imagename = optarg;
break;
case 'o':
outfile = optarg;
break;
case 'b':
add_barebox_header = 1;
break;
case 'd':
dcd_only = 1;
break;
case 'h':
usage(argv[0]);
default:
exit(1);
}
}
if (!imagename && !dcd_only) {
fprintf(stderr, "image name not given\n");
exit(1);
}
if (!configfile) {
fprintf(stderr, "config file not given\n");
exit(1);
}
if (!outfile) {
fprintf(stderr, "output file not given\n");
exit(1);
}
if (!dcd_only) {
ret = stat(imagename, &s);
if (ret) {
perror("stat");
exit(1);
}
image_size = s.st_size;
}
ret = parse_config(configfile);
if (ret)
exit(1);
buf = calloc(4096, 1);
if (!buf)
exit(1);
if (!image_dcd_offset) {
fprintf(stderr, "no dcd offset given ('dcdofs'). Defaulting to 0x400\n");
image_dcd_offset = 0x400;
}
if (!header_version) {
fprintf(stderr, "no SoC given. (missing 'soc' in config)\n");
exit(1);
}
if (header_version == 2)
check_last_dcd(0);
if (dcd_only) {
ret = write_dcd(outfile);
if (ret)
exit(1);
exit (0);
}
switch (header_version) {
case 1:
add_header_v1(buf, image_dcd_offset, image_load_addr, image_size + 0x1000);
break;
case 2:
add_header_v2(buf, image_dcd_offset, image_load_addr, image_size + 0x1000);
break;
default:
fprintf(stderr, "Congratulations! You're welcome to implement header version %d\n",
header_version);
exit(1);
}
outfd = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (outfd < 0) {
perror("open");
exit(1);
}
ret = xwrite(outfd, buf, 4096);
if (ret < 0) {
perror("write");
exit(1);
}
infd = open(imagename, O_RDONLY);
if (infd < 0) {
perror("open");
exit(1);
}
while (image_size) {
int now = image_size < 4096 ? image_size : 4096;
ret = xread(infd, buf, now);
if (ret) {
perror("read");
exit(1);
}
ret = xwrite(outfd, buf, now);
if (ret) {
perror("write");
exit(1);
}
image_size -= now;
}
ret = close(outfd);
if (ret) {
perror("close");
exit(1);
}
exit(0);
}

1427
scripts/imx/imx-usb-loader.c Normal file

File diff suppressed because it is too large Load Diff