code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
# # (C) Copyright 2009 DENX Software Engineering # # 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 Foundatio; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # CONFIG_NAND_SPL = y include $(TOPDIR)/config.mk include $(TOPDIR)/nand_spl/board/$(BOARDDIR)/config.mk nandobj := $(OBJTREE)/nand_spl/ LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \ $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL SOBJS = start.o lowlevel_init.o COBJS = nand_boot_fsl_nfc.o SRCS := $(SRCTREE)/nand_spl/nand_boot_fsl_nfc.c SRCS += $(SRCTREE)/arch/arm/cpu/arm926ejs/start.S SRCS += $(SRCTREE)/board/karo/tx25/lowlevel_init.S OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) __OBJS := $(SOBJS) $(COBJS) LNDIR := $(nandobj)board/$(BOARDDIR) ALL = $(nandobj)u-boot-spl $(nandobj)u-boot-spl.bin $(nandobj)u-boot-spl-16k.bin all: $(obj).depend $(ALL) $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $< $@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ -Map $(nandobj)u-boot-spl.map \ -o $@ $(nandobj)u-boot.lds: $(LDSCRIPT) $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ ######################################################################### $(obj)%.o: $(SRCTREE)/arch/arm/cpu/arm926ejs/%.S $(CC) $(AFLAGS) -c -o $@ $< $(obj)%.o: $(SRCTREE)/board/karo/tx25/%.S $(CC) $(AFLAGS) -c -o $@ $< $(obj)%.o: $(SRCTREE)/nand_spl/%.c $(CC) $(CFLAGS) -c -o $@ $< # defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend #########################################################################
1001-study-uboot
nand_spl/board/karo/tx25/Makefile
Makefile
gpl3
2,539
PAD_TO := 2048
1001-study-uboot
nand_spl/board/karo/tx25/config.mk
Makefile
gpl3
15
# # (C) Copyright 2006-2007 # Stefan Roese, DENX Software Engineering, sr@denx.de. # # (C) Copyright 2008 # Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de> # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # CONFIG_NAND_SPL = y include $(TOPDIR)/config.mk nandobj := $(OBJTREE)/nand_spl/ LDSCRIPT= $(TOPDIR)/nand_spl/board/$(BOARDDIR)/u-boot.lds LDFLAGS := -T $(nandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(LDFLAGS) \ $(LDFLAGS_FINAL) AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_NAND_SPL SOBJS = _divsi3.o \ _udivsi3.o \ start.o COBJS = cpu.o \ davinci_nand.o \ pinmux.o \ da850_pinmux.o \ div0.o \ hawkboard_nand_spl.o \ misc.o \ nand_boot.o \ ns16550.o \ psc.o SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c)) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) __OBJS := $(SOBJS) $(COBJS) LNDIR := $(nandobj)board/$(BOARDDIR) ALL = $(nandobj)u-boot-spl $(nandobj)u-boot-spl.bin \ $(nandobj)u-boot-spl-16k.bin all: $(ALL) $(nandobj)u-boot-spl-16k.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $< $@ $(nandobj)u-boot-spl.bin: $(nandobj)u-boot-spl $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ $(nandobj)u-boot-spl: $(OBJS) $(nandobj)u-boot.lds cd $(LNDIR) && $(LD) $(LDFLAGS) $(__OBJS) \ -Map $(nandobj)u-boot-spl.map \ -o $(nandobj)u-boot-spl $(nandobj)u-boot.lds: $(LDSCRIPT) $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ # create symbolic links for common files # from board directory $(obj)pinmux.c: @rm -f $@ @ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/davinci/pinmux.c $@ $(obj)da850_pinmux.c: @rm -f $@ @ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/davinci/da850_pinmux.c $@ # from drivers/mtd/nand directory $(obj)davinci_nand.c: @rm -f $@ @ln -s $(TOPDIR)/drivers/mtd/nand/davinci_nand.c $@ # from nand_spl directory $(obj)nand_boot.c: @rm -f $@ @ln -s $(TOPDIR)/nand_spl/nand_boot.c $@ # from drivers/serial directory $(obj)ns16550.c: @rm -f $@ @ln -sf $(TOPDIR)/drivers/serial/ns16550.c $@ # from cpu directory $(obj)start.S: @rm -f $@ ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/start.S $@ # from lib directory $(obj)_udivsi3.S: @rm -f $@ ln -s $(TOPDIR)/arch/arm/lib/_udivsi3.S $@ # from lib directory $(obj)_divsi3.S: @rm -f $@ ln -s $(TOPDIR)/arch/arm/lib/_divsi3.S $@ # from lib directory $(obj)div0.c: @rm -f $@ ln -s $(TOPDIR)/arch/arm/lib/div0.c $@ # from SoC directory $(obj)cpu.c: @rm -f $@ @ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/davinci/cpu.c $@ $(obj)misc.c: @rm -f $@ ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/davinci/misc.c $@ # from board directory $(obj)hawkboard_nand_spl.c: @rm -f $@ ln -s $(TOPDIR)/board/davinci/da8xxevm/hawkboard_nand_spl.c $@ $(obj)psc.c: @rm -f $@ ln -s $(TOPDIR)/arch/arm/cpu/arm926ejs/davinci/psc.c $@ ######################################################################### $(obj)%.o: $(obj)%.S $(CC) $(AFLAGS) -c -o $@ $< $(obj)%.o: $(obj)%.c $(CC) $(CFLAGS) -c -o $@ $< # defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend #########################################################################
1001-study-uboot
nand_spl/board/davinci/da8xxevm/Makefile
Makefile
gpl3
3,891
/* * (C) Copyright 2006-2008 * Stefan Roese, DENX Software Engineering, sr@denx.de. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <nand.h> #include <asm/io.h> static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS; #if (CONFIG_SYS_NAND_PAGE_SIZE <= 512) /* * NAND command for small page NAND devices (512) */ static int nand_command(struct mtd_info *mtd, int block, int page, int offs, u8 cmd) { struct nand_chip *this = mtd->priv; int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT; while (!this->dev_ready(mtd)) ; /* Begin command latch cycle */ this->cmd_ctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE); /* Set ALE and clear CLE to start address cycle */ /* Column address */ this->cmd_ctrl(mtd, offs, NAND_CTRL_ALE | NAND_CTRL_CHANGE); this->cmd_ctrl(mtd, page_addr & 0xff, NAND_CTRL_ALE); /* A[16:9] */ this->cmd_ctrl(mtd, (page_addr >> 8) & 0xff, NAND_CTRL_ALE); /* A[24:17] */ #ifdef CONFIG_SYS_NAND_4_ADDR_CYCLE /* One more address cycle for devices > 32MiB */ this->cmd_ctrl(mtd, (page_addr >> 16) & 0x0f, NAND_CTRL_ALE); /* A[28:25] */ #endif /* Latch in address */ this->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); /* * Wait a while for the data to be ready */ while (!this->dev_ready(mtd)) ; return 0; } #else /* * NAND command for large page NAND devices (2k) */ static int nand_command(struct mtd_info *mtd, int block, int page, int offs, u8 cmd) { struct nand_chip *this = mtd->priv; int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT; void (*hwctrl)(struct mtd_info *mtd, int cmd, unsigned int ctrl) = this->cmd_ctrl; while (!this->dev_ready(mtd)) ; /* Emulate NAND_CMD_READOOB */ if (cmd == NAND_CMD_READOOB) { offs += CONFIG_SYS_NAND_PAGE_SIZE; cmd = NAND_CMD_READ0; } /* Shift the offset from byte addressing to word addressing. */ if (this->options & NAND_BUSWIDTH_16) offs >>= 1; /* Begin command latch cycle */ hwctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE); /* Set ALE and clear CLE to start address cycle */ /* Column address */ hwctrl(mtd, offs & 0xff, NAND_CTRL_ALE | NAND_CTRL_CHANGE); /* A[7:0] */ hwctrl(mtd, (offs >> 8) & 0xff, NAND_CTRL_ALE); /* A[11:9] */ /* Row address */ hwctrl(mtd, (page_addr & 0xff), NAND_CTRL_ALE); /* A[19:12] */ hwctrl(mtd, ((page_addr >> 8) & 0xff), NAND_CTRL_ALE); /* A[27:20] */ #ifdef CONFIG_SYS_NAND_5_ADDR_CYCLE /* One more address cycle for devices > 128MiB */ hwctrl(mtd, (page_addr >> 16) & 0x0f, NAND_CTRL_ALE); /* A[31:28] */ #endif /* Latch in address */ hwctrl(mtd, NAND_CMD_READSTART, NAND_CTRL_CLE | NAND_CTRL_CHANGE); hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE); /* * Wait a while for the data to be ready */ while (!this->dev_ready(mtd)) ; return 0; } #endif static int nand_is_bad_block(struct mtd_info *mtd, int block) { struct nand_chip *this = mtd->priv; nand_command(mtd, block, 0, CONFIG_SYS_NAND_BAD_BLOCK_POS, NAND_CMD_READOOB); /* * Read one byte (or two if it's a 16 bit chip). */ if (this->options & NAND_BUSWIDTH_16) { if (readw(this->IO_ADDR_R) != 0xffff) return 1; } else { if (readb(this->IO_ADDR_R) != 0xff) return 1; } return 0; } #if defined(CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST) static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst) { struct nand_chip *this = mtd->priv; u_char *ecc_calc; u_char *ecc_code; u_char *oob_data; int i; int eccsize = CONFIG_SYS_NAND_ECCSIZE; int eccbytes = CONFIG_SYS_NAND_ECCBYTES; int eccsteps = CONFIG_SYS_NAND_ECCSTEPS; uint8_t *p = dst; /* * No malloc available for now, just use some temporary locations * in SDRAM */ ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000); ecc_code = ecc_calc + 0x100; oob_data = ecc_calc + 0x200; nand_command(mtd, block, page, 0, NAND_CMD_READOOB); this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE); nand_command(mtd, block, page, 0, NAND_CMD_READ0); /* Pick the ECC bytes out of the oob data */ for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++) ecc_code[i] = oob_data[nand_ecc_pos[i]]; for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { this->ecc.hwctl(mtd, NAND_ECC_READ); this->read_buf(mtd, p, eccsize); this->ecc.calculate(mtd, p, &ecc_calc[i]); this->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); } return 0; } #else static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst) { struct nand_chip *this = mtd->priv; u_char *ecc_calc; u_char *ecc_code; u_char *oob_data; int i; int eccsize = CONFIG_SYS_NAND_ECCSIZE; int eccbytes = CONFIG_SYS_NAND_ECCBYTES; int eccsteps = CONFIG_SYS_NAND_ECCSTEPS; uint8_t *p = dst; nand_command(mtd, block, page, 0, NAND_CMD_READ0); /* No malloc available for now, just use some temporary locations * in SDRAM */ ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000); ecc_code = ecc_calc + 0x100; oob_data = ecc_calc + 0x200; for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { this->ecc.hwctl(mtd, NAND_ECC_READ); this->read_buf(mtd, p, eccsize); this->ecc.calculate(mtd, p, &ecc_calc[i]); } this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE); /* Pick the ECC bytes out of the oob data */ for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++) ecc_code[i] = oob_data[nand_ecc_pos[i]]; eccsteps = CONFIG_SYS_NAND_ECCSTEPS; p = dst; for (i = 0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { /* No chance to do something with the possible error message * from correct_data(). We just hope that all possible errors * are corrected by this routine. */ this->ecc.correct(mtd, p, &ecc_code[i], &ecc_calc[i]); } return 0; } #endif /* #if defined(CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST) */ static int nand_load(struct mtd_info *mtd, unsigned int offs, unsigned int uboot_size, uchar *dst) { unsigned int block, lastblock; unsigned int page; /* * offs has to be aligned to a page address! */ block = offs / CONFIG_SYS_NAND_BLOCK_SIZE; lastblock = (offs + uboot_size - 1) / CONFIG_SYS_NAND_BLOCK_SIZE; page = (offs % CONFIG_SYS_NAND_BLOCK_SIZE) / CONFIG_SYS_NAND_PAGE_SIZE; while (block <= lastblock) { if (!nand_is_bad_block(mtd, block)) { /* * Skip bad blocks */ while (page < CONFIG_SYS_NAND_PAGE_COUNT) { nand_read_page(mtd, block, page, dst); dst += CONFIG_SYS_NAND_PAGE_SIZE; page++; } page = 0; } else { lastblock++; } block++; } return 0; } /* * The main entry for NAND booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image * from NAND into SDRAM and starts it from there. */ void nand_boot(void) { struct nand_chip nand_chip; nand_info_t nand_info; __attribute__((noreturn)) void (*uboot)(void); /* * Init board specific nand support */ nand_chip.select_chip = NULL; nand_info.priv = &nand_chip; nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W = (void __iomem *)CONFIG_SYS_NAND_BASE; nand_chip.dev_ready = NULL; /* preset to NULL */ nand_chip.options = 0; board_nand_init(&nand_chip); if (nand_chip.select_chip) nand_chip.select_chip(&nand_info, 0); /* * Load U-Boot image from NAND into RAM */ nand_load(&nand_info, CONFIG_SYS_NAND_U_BOOT_OFFS, CONFIG_SYS_NAND_U_BOOT_SIZE, (uchar *)CONFIG_SYS_NAND_U_BOOT_DST); #ifdef CONFIG_NAND_ENV_DST nand_load(&nand_info, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, (uchar *)CONFIG_NAND_ENV_DST); #ifdef CONFIG_ENV_OFFSET_REDUND nand_load(&nand_info, CONFIG_ENV_OFFSET_REDUND, CONFIG_ENV_SIZE, (uchar *)CONFIG_NAND_ENV_DST + CONFIG_ENV_SIZE); #endif #endif if (nand_chip.select_chip) nand_chip.select_chip(&nand_info, -1); /* * Jump to U-Boot image */ uboot = (void *)CONFIG_SYS_NAND_U_BOOT_START; (*uboot)(); }
1001-study-uboot
nand_spl/nand_boot.c
C
gpl3
8,527
# # (C) Copyright 2000-2011 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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 Foundatio; either version 2 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # VERSION = 2011 PATCHLEVEL = 12 SUBLEVEL = EXTRAVERSION = ifneq "$(SUBLEVEL)" "" U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) else U_BOOT_VERSION = $(VERSION).$(PATCHLEVEL)$(EXTRAVERSION) endif TIMESTAMP_FILE = $(obj)include/generated/timestamp_autogenerated.h VERSION_FILE = $(obj)include/generated/version_autogenerated.h HOSTARCH := $(shell uname -m | \ sed -e s/i.86/x86/ \ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ \ -e s/sa110/arm/ \ -e s/ppc64/powerpc/ \ -e s/ppc/powerpc/ \ -e s/macppc/powerpc/\ -e s/sh.*/sh/) HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \ sed -e 's/\(cygwin\).*/cygwin/') # Set shell to bash if possible, otherwise fall back to sh SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi; fi) export HOSTARCH HOSTOS SHELL # Deal with colliding definitions from tcsh etc. VENDOR= ######################################################################### # Allow for silent builds ifeq (,$(findstring s,$(MAKEFLAGS))) XECHO = echo else XECHO = : endif ######################################################################### # # U-boot build supports producing a object files to the separate external # directory. Two use cases are supported: # # 1) Add O= to the make command line # 'make O=/tmp/build all' # # 2) Set environement variable BUILD_DIR to point to the desired location # 'export BUILD_DIR=/tmp/build' # 'make' # # The second approach can also be used with a MAKEALL script # 'export BUILD_DIR=/tmp/build' # './MAKEALL' # # Command line 'O=' setting overrides BUILD_DIR environent variable. # # When none of the above methods is used the local build is performed and # the object files are placed in the source directory. # ifdef O ifeq ("$(origin O)", "command line") BUILD_DIR := $(O) endif endif ifneq ($(BUILD_DIR),) saved-output := $(BUILD_DIR) # Attempt to create a output directory. $(shell [ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}) # Verify if it was successful. BUILD_DIR := $(shell cd $(BUILD_DIR) && /bin/pwd) $(if $(BUILD_DIR),,$(error output directory "$(saved-output)" does not exist)) endif # ifneq ($(BUILD_DIR),) OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) SPLTREE := $(OBJTREE)/spl SRCTREE := $(CURDIR) TOPDIR := $(SRCTREE) LNDIR := $(OBJTREE) export TOPDIR SRCTREE OBJTREE SPLTREE MKCONFIG := $(SRCTREE)/mkconfig export MKCONFIG ifneq ($(OBJTREE),$(SRCTREE)) REMOTE_BUILD := 1 export REMOTE_BUILD endif # $(obj) and (src) are defined in config.mk but here in main Makefile # we also need them before config.mk is included which is the case for # some targets like unconfig, clean, clobber, distclean, etc. ifneq ($(OBJTREE),$(SRCTREE)) obj := $(OBJTREE)/ src := $(SRCTREE)/ else obj := src := endif export obj src # Make sure CDPATH settings don't interfere unexport CDPATH ######################################################################### # The "tools" are needed early, so put this first # Don't include stuff already done in $(LIBS) # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC # is "yes"), so compile examples after U-Boot is compiled. SUBDIR_TOOLS = tools SUBDIR_EXAMPLES = examples/standalone examples/api SUBDIRS = $(SUBDIR_TOOLS) .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE) ifeq ($(obj)include/config.mk,$(wildcard $(obj)include/config.mk)) # Include autoconf.mk before config.mk so that the config options are available # to all top level build files. We need the dummy all: target to prevent the # dependency target in autoconf.mk.dep from being the default. all: sinclude $(obj)include/autoconf.mk.dep sinclude $(obj)include/autoconf.mk ifndef CONFIG_SANDBOX SUBDIRS += $(SUBDIR_EXAMPLES) endif # load ARCH, BOARD, and CPU configuration include $(obj)include/config.mk export ARCH CPU BOARD VENDOR SOC # set default to nothing for native builds ifeq ($(HOSTARCH),$(ARCH)) CROSS_COMPILE ?= endif # load other configuration include $(TOPDIR)/config.mk # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a # standard location. ifndef LDSCRIPT #LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug ifdef CONFIG_SYS_LDSCRIPT # need to strip off double quotes LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT)) endif endif ifndef LDSCRIPT ifeq ($(CONFIG_NAND_U_BOOT),y) LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds ifeq ($(wildcard $(LDSCRIPT)),) LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds endif endif ifeq ($(wildcard $(LDSCRIPT)),) LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds endif ifeq ($(wildcard $(LDSCRIPT)),) LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot.lds endif ifeq ($(wildcard $(LDSCRIPT)),) $(error could not find linker script) endif endif ######################################################################### # U-Boot objects....order is important (i.e. start must be first) OBJS = $(CPUDIR)/start.o ifeq ($(CPU),x86) OBJS += $(CPUDIR)/start16.o OBJS += $(CPUDIR)/resetvec.o endif ifeq ($(CPU),ppc4xx) OBJS += $(CPUDIR)/resetvec.o endif ifeq ($(CPU),mpc85xx) OBJS += $(CPUDIR)/resetvec.o endif OBJS := $(addprefix $(obj),$(OBJS)) LIBS = lib/libgeneric.o LIBS += lib/lzma/liblzma.o LIBS += lib/lzo/liblzo.o LIBS += lib/zlib/libz.o LIBS += $(shell if [ -f board/$(VENDOR)/common/Makefile ]; then echo \ "board/$(VENDOR)/common/lib$(VENDOR).o"; fi) LIBS += $(CPUDIR)/lib$(CPU).o ifdef SOC LIBS += $(CPUDIR)/$(SOC)/lib$(SOC).o endif ifeq ($(CPU),ixp) LIBS += arch/arm/cpu/ixp/npe/libnpe.o endif ifeq ($(CONFIG_OF_EMBED),y) LIBS += dts/libdts.o endif LIBS += arch/$(ARCH)/lib/lib$(ARCH).o LIBS += fs/cramfs/libcramfs.o fs/fat/libfat.o fs/fdos/libfdos.o fs/jffs2/libjffs2.o \ fs/reiserfs/libreiserfs.o fs/ext2/libext2fs.o fs/yaffs2/libyaffs2.o \ fs/ubifs/libubifs.o LIBS += net/libnet.o LIBS += disk/libdisk.o LIBS += drivers/bios_emulator/libatibiosemu.o LIBS += drivers/block/libblock.o LIBS += drivers/dma/libdma.o LIBS += drivers/fpga/libfpga.o LIBS += drivers/gpio/libgpio.o LIBS += drivers/hwmon/libhwmon.o LIBS += drivers/i2c/libi2c.o LIBS += drivers/input/libinput.o LIBS += drivers/misc/libmisc.o LIBS += drivers/mmc/libmmc.o LIBS += drivers/mtd/libmtd.o LIBS += drivers/mtd/nand/libnand.o LIBS += drivers/mtd/onenand/libonenand.o LIBS += drivers/mtd/ubi/libubi.o LIBS += drivers/mtd/spi/libspi_flash.o LIBS += drivers/net/libnet.o LIBS += drivers/net/phy/libphy.o LIBS += drivers/pci/libpci.o LIBS += drivers/pcmcia/libpcmcia.o LIBS += drivers/power/libpower.o LIBS += drivers/spi/libspi.o ifeq ($(CPU),mpc83xx) LIBS += drivers/qe/libqe.o LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif ifeq ($(CPU),mpc85xx) LIBS += drivers/qe/libqe.o LIBS += drivers/net/fm/libfm.o LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif ifeq ($(CPU),mpc86xx) LIBS += arch/powerpc/cpu/mpc8xxx/ddr/libddr.o LIBS += arch/powerpc/cpu/mpc8xxx/lib8xxx.o endif LIBS += drivers/rtc/librtc.o LIBS += drivers/serial/libserial.o ifeq ($(CONFIG_GENERIC_LPC_TPM),y) LIBS += drivers/tpm/libtpm.o endif LIBS += drivers/twserial/libtws.o LIBS += drivers/usb/eth/libusb_eth.o LIBS += drivers/usb/gadget/libusb_gadget.o LIBS += drivers/usb/host/libusb_host.o LIBS += drivers/usb/musb/libusb_musb.o LIBS += drivers/usb/phy/libusb_phy.o LIBS += drivers/usb/ulpi/libusb_ulpi.o LIBS += drivers/video/libvideo.o LIBS += drivers/watchdog/libwatchdog.o LIBS += common/libcommon.o LIBS += lib/libfdt/libfdt.o LIBS += api/libapi.o LIBS += post/libpost.o ifneq ($(CONFIG_AM335X)$(CONFIG_OMAP34XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX),) LIBS += $(CPUDIR)/omap-common/libomap-common.o endif ifeq ($(SOC),mx5) LIBS += $(CPUDIR)/imx-common/libimx-common.o endif ifeq ($(SOC),mx6) LIBS += $(CPUDIR)/imx-common/libimx-common.o endif ifeq ($(SOC),s5pc1xx) LIBS += $(CPUDIR)/s5p-common/libs5p-common.o endif ifeq ($(SOC),exynos) LIBS += $(CPUDIR)/s5p-common/libs5p-common.o endif LIBS := $(addprefix $(obj),$(sort $(LIBS))) .PHONY : $(LIBS) LIBBOARD = board/$(BOARDDIR)/lib$(BOARD).o LIBBOARD := $(addprefix $(obj),$(LIBBOARD)) # Add GCC lib ifdef USE_PRIVATE_LIBGCC ifeq ("$(USE_PRIVATE_LIBGCC)", "yes") PLATFORM_LIBGCC = $(OBJTREE)/arch/$(ARCH)/lib/libgcc.o else PLATFORM_LIBGCC = -L $(USE_PRIVATE_LIBGCC) -lgcc endif else PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc endif PLATFORM_LIBS += $(PLATFORM_LIBGCC) export PLATFORM_LIBS # Special flags for CPP when processing the linker script. # Pass the version down so we can handle backwards compatibility # on the fly. LDPPFLAGS += \ -include $(TOPDIR)/include/u-boot/u-boot.lds.h \ $(shell $(LD) --version | \ sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') __OBJS := $(subst $(obj),,$(OBJS)) __LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD)) ######################################################################### ######################################################################### ifneq ($(CONFIG_BOARD_SIZE_LIMIT),) BOARD_SIZE_CHECK = \ @actual=`wc -c $@ | awk '{print $$1}'`; \ limit=$(CONFIG_BOARD_SIZE_LIMIT); \ if test $$actual -gt $$limit; then \ echo "$@ exceeds file size limit:"; \ echo " limit: $$limit bytes"; \ echo " actual: $$actual bytes"; \ echo " excess: $$((actual - limit)) bytes"; \ exit 1; \ fi else BOARD_SIZE_CHECK = endif # Always append ALL so that arch config.mk's can add custom ones ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map $(obj)u-boot.dis ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin ALL-$(CONFIG_MMC_U_BOOT) += $(obj)mmc_spl/u-boot-mmc-spl.bin ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin all: $(ALL-y) $(SUBDIR_EXAMPLES) cp -f u-boot.bin /media/sf_MyCodeDesign/ @echo wangxi mini2440 u-boot compile ok @pwd $(obj)u-boot.dtb: $(obj)u-boot $(MAKE) -C dts binary mv $(obj)dts/dt.dtb $@ $(obj)u-boot-dtb.bin: $(obj)u-boot.bin $(obj)u-boot.dtb cat $^ >$@ $(obj)u-boot.hex: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ $(obj)u-boot.srec: $(obj)u-boot $(OBJCOPY) -O srec $< $@ $(obj)u-boot.bin: $(obj)u-boot $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ $(BOARD_SIZE_CHECK) $(obj)u-boot.ldr: $(obj)u-boot $(CREATE_LDR_ENV) $(LDR) -T $(CONFIG_BFIN_CPU) -c $@ $< $(LDR_FLAGS) $(BOARD_SIZE_CHECK) $(obj)u-boot.ldr.hex: $(obj)u-boot.ldr $(OBJCOPY) ${OBJCFLAGS} -O ihex $< $@ -I binary $(obj)u-boot.ldr.srec: $(obj)u-boot.ldr $(OBJCOPY) ${OBJCFLAGS} -O srec $< $@ -I binary $(obj)u-boot.img: $(obj)u-boot.bin $(obj)tools/mkimage -A $(ARCH) -T firmware -C none \ -O u-boot -a $(CONFIG_SYS_TEXT_BASE) -e 0 \ -n $(shell sed -n -e 's/.*U_BOOT_VERSION//p' $(VERSION_FILE) | \ sed -e 's/"[ ]*$$/ for $(BOARD) board"/') \ -d $< $@ $(obj)u-boot.imx: $(obj)u-boot.bin $(obj)tools/mkimage -n $(CONFIG_IMX_CONFIG) -T imximage \ -e $(CONFIG_SYS_TEXT_BASE) -d $< $@ $(obj)u-boot.kwb: $(obj)u-boot.bin $(obj)tools/mkimage -n $(CONFIG_SYS_KWD_CONFIG) -T kwbimage \ -a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -d $< $@ $(obj)u-boot.sha1: $(obj)u-boot.bin $(obj)tools/ubsha1 $(obj)u-boot.bin $(obj)u-boot.dis: $(obj)u-boot $(OBJDUMP) -d $< > $@ $(obj)u-boot.ubl: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(PAD_TO) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $(obj)u-boot-ubl.bin $(obj)tools/mkimage -n $(UBL_CONFIG) -T ublimage \ -e $(CONFIG_SYS_TEXT_BASE) -d $(obj)u-boot-ubl.bin $(obj)u-boot.ubl rm $(obj)u-boot-ubl.bin rm $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.sb: $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin elftosb -zdf imx28 -c $(TOPDIR)/board/$(BOARDDIR)/u-boot.bd \ -o $(obj)u-boot.sb ifeq ($(CONFIG_SANDBOX),y) GEN_UBOOT = \ cd $(LNDIR) && $(CC) $(SYMS) -T $(obj)u-boot.lds \ -Wl,--start-group $(__LIBS) -Wl,--end-group \ $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -o u-boot else GEN_UBOOT = \ UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \ sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\ cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \ --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \ -Map u-boot.map -o u-boot endif $(obj)u-boot: depend \ $(SUBDIR_TOOLS) $(OBJS) $(LIBBOARD) $(LIBS) $(LDSCRIPT) $(obj)u-boot.lds $(GEN_UBOOT) ifeq ($(CONFIG_KALLSYMS),y) smap=`$(call SYSTEM_MAP,u-boot) | \ awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \ $(CC) $(CFLAGS) -DSYSTEM_MAP="\"$${smap}\"" \ -c common/system_map.c -o $(obj)common/system_map.o $(GEN_UBOOT) $(obj)common/system_map.o endif $(OBJS): depend $(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@)) $(LIBS): depend $(SUBDIR_TOOLS) $(MAKE) -C $(dir $(subst $(obj),,$@)) $(LIBBOARD): depend $(LIBS) $(MAKE) -C $(dir $(subst $(obj),,$@)) $(SUBDIRS): depend $(MAKE) -C $@ all $(SUBDIR_EXAMPLES): $(obj)u-boot $(LDSCRIPT): depend $(MAKE) -C $(dir $@) $(notdir $@) $(obj)u-boot.lds: $(LDSCRIPT) $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ nand_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend $(MAKE) -C nand_spl/board/$(BOARDDIR) all $(obj)u-boot-nand.bin: nand_spl $(obj)u-boot.bin cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > $(obj)u-boot-nand.bin onenand_ipl: $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk $(MAKE) -C onenand_ipl/board/$(BOARDDIR) all $(obj)u-boot-onenand.bin: onenand_ipl $(obj)u-boot.bin cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin mmc_spl: $(TIMESTAMP_FILE) $(VERSION_FILE) depend $(MAKE) -C mmc_spl/board/$(BOARDDIR) all $(obj)mmc_spl/u-boot-mmc-spl.bin: mmc_spl $(obj)spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend $(MAKE) -C spl all updater: $(MAKE) -C tools/updater all # Explicitly make _depend in subdirs containing multiple targets to prevent # parallel sub-makes creating .depend files simultaneously. depend dep: $(TIMESTAMP_FILE) $(VERSION_FILE) \ $(obj)include/autoconf.mk \ $(obj)include/generated/generic-asm-offsets.h \ $(obj)include/generated/asm-offsets.h for dir in $(SUBDIRS) $(CPUDIR) $(dir $(LDSCRIPT)) ; do \ $(MAKE) -C $$dir _depend ; done TAG_SUBDIRS = $(SUBDIRS) TAG_SUBDIRS += $(dir $(__LIBS)) TAG_SUBDIRS += include FIND := find FINDFLAGS := -L tags ctags: ctags -w -o $(obj)ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ -name '*.[chS]' -print` etags: etags -a -o $(obj)etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ -name '*.[chS]' -print` cscope: $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ cscope.files cscope -b -q -k SYSTEM_MAP = \ $(NM) $1 | \ grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ LC_ALL=C sort $(obj)System.map: $(obj)u-boot @$(call SYSTEM_MAP,$<) > $(obj)System.map # # Auto-generate the autoconf.mk file (which is included by all makefiles) # # This target actually generates 2 files; autoconf.mk and autoconf.mk.dep. # the dep file is only include in this top level makefile to determine when # to regenerate the autoconf.mk file. $(obj)include/autoconf.mk.dep: $(obj)include/config.h include/common.h @$(XECHO) Generating $@ ; \ set -e ; \ : Generate the dependancies ; \ $(CC) -x c -DDO_DEPS_ONLY -M $(CFLAGS) $(CPPFLAGS) \ -MQ $(obj)include/autoconf.mk include/common.h > $@ $(obj)include/autoconf.mk: $(obj)include/config.h @$(XECHO) Generating $@ ; \ set -e ; \ : Extract the config macros ; \ $(CPP) $(CFLAGS) -DDO_DEPS_ONLY -dM include/common.h | \ sed -n -f tools/scripts/define2mk.sed > $@.tmp && \ mv $@.tmp $@ $(obj)include/generated/generic-asm-offsets.h: $(obj)include/autoconf.mk.dep \ $(obj)lib/asm-offsets.s @$(XECHO) Generating $@ tools/scripts/make-asm-offsets $(obj)lib/asm-offsets.s $@ $(obj)lib/asm-offsets.s: $(obj)include/autoconf.mk.dep \ $(src)lib/asm-offsets.c @mkdir -p $(obj)lib $(CC) -DDO_DEPS_ONLY \ $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ -o $@ $(src)lib/asm-offsets.c -c -S $(obj)include/generated/asm-offsets.h: $(obj)include/autoconf.mk.dep \ $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s @echo Generating $@ tools/scripts/make-asm-offsets $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s $@ $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s: $(obj)include/autoconf.mk.dep @mkdir -p $(obj)$(CPUDIR)/$(SOC) if [ -f $(src)$(CPUDIR)/$(SOC)/asm-offsets.c ];then \ $(CC) -DDO_DEPS_ONLY \ $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) \ -o $@ $(src)$(CPUDIR)/$(SOC)/asm-offsets.c -c -S; \ else \ touch $@; \ fi ######################################################################### else # !config.mk all $(obj)u-boot.hex $(obj)u-boot.srec $(obj)u-boot.bin \ $(obj)u-boot.img $(obj)u-boot.dis $(obj)u-boot \ $(filter-out tools,$(SUBDIRS)) \ updater depend dep tags ctags etags cscope $(obj)System.map: @echo "System not configured - see README" >&2 @ exit 1 tools: $(VERSION_FILE) $(TIMESTAMP_FILE) $(MAKE) -C $@ all endif # config.mk $(VERSION_FILE): @mkdir -p $(dir $(VERSION_FILE)) @( localvers='$(shell $(TOPDIR)/tools/setlocalversion $(TOPDIR))' ; \ printf '#define PLAIN_VERSION "%s%s"\n' \ "$(U_BOOT_VERSION)" "$${localvers}" ; \ printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' \ "$(U_BOOT_VERSION)" "$${localvers}" ; \ ) > $@.tmp @( printf '#define CC_VERSION_STRING "%s"\n' \ '$(shell $(CC) --version | head -n 1)' )>> $@.tmp @( printf '#define LD_VERSION_STRING "%s"\n' \ '$(shell $(LD) -v | head -n 1)' )>> $@.tmp @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ $(TIMESTAMP_FILE): @mkdir -p $(dir $(TIMESTAMP_FILE)) @LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > $@.tmp @LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> $@.tmp @cmp -s $@ $@.tmp && rm -f $@.tmp || mv -f $@.tmp $@ easylogo env gdb: $(MAKE) -C tools/$@ all MTD_VERSION=${MTD_VERSION} gdbtools: gdb tools-all: easylogo env gdb $(VERSION_FILE) $(TIMESTAMP_FILE) $(MAKE) -C tools HOST_TOOLS_ALL=y .PHONY : CHANGELOG CHANGELOG: git log --no-merges U-Boot-1_1_5.. | \ unexpand -a | sed -e 's/\s\s*$$//' > $@ include/license.h: tools/bin2header COPYING cat COPYING | gzip -9 -c | ./tools/bin2header license_gzip > include/license.h ######################################################################### unconfig: @rm -f $(obj)include/config.h $(obj)include/config.mk \ $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \ $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep %_config:: unconfig @$(MKCONFIG) -A $(@:_config=) sinclude $(obj).boards.depend $(obj).boards.depend: boards.cfg @awk '(NF && $$1 !~ /^#/) { print $$1 ": " $$1 "_config; $$(MAKE)" }' $< > $@ # # Functions to generate common board directory names # lcname = $(shell echo $(1) | sed -e 's/\(.*\)_config/\L\1/') ucname = $(shell echo $(1) | sed -e 's/\(.*\)_config/\U\1/') #======================================================================== # ARM #======================================================================== spear300_config \ spear310_config \ spear320_config : unconfig @$(MKCONFIG) -n $@ -t $@ spear3xx arm arm926ejs $(@:_config=) spear spear spear600_config : unconfig @$(MKCONFIG) -n $@ -t $@ spear6xx arm arm926ejs $(@:_config=) spear spear SX1_stdout_serial_config \ SX1_config: unconfig @mkdir -p $(obj)include @if [ "$(findstring _stdout_serial_, $@)" ] ; then \ echo "#undef CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \ else \ echo "#define CONFIG_STDOUT_USBTTY" >> $(obj)include/config.h ; \ fi; @$(MKCONFIG) -n $@ SX1 arm arm925t sx1 ######################################################################### ## XScale Systems ######################################################################### pdnb3_config \ scpu_config: unconfig @mkdir -p $(obj)include @if [ "$(findstring scpu_,$@)" ] ; then \ echo "#define CONFIG_SCPU" >>$(obj)include/config.h ; \ fi @$(MKCONFIG) -n $@ -a pdnb3 arm ixp pdnb3 prodrive ######################################################################### ## ARM1176 Systems ######################################################################### smdk6400_noUSB_config \ smdk6400_config : unconfig @mkdir -p $(obj)include $(obj)board/samsung/smdk6400 @mkdir -p $(obj)nand_spl/board/samsung/smdk6400 @echo "#define CONFIG_NAND_U_BOOT" > $(obj)include/config.h @echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk @if [ -z "$(findstring smdk6400_noUSB_config,$@)" ]; then \ echo "RAM_TEXT = 0x57e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\ else \ echo "RAM_TEXT = 0xc7e00000" >> $(obj)board/samsung/smdk6400/config.tmp;\ fi @$(MKCONFIG) smdk6400 arm arm1176 smdk6400 samsung s3c64xx @echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk ######################################################################### ######################################################################### clean: @rm -f $(obj)examples/standalone/82559_eeprom \ $(obj)examples/standalone/atmel_df_pow2 \ $(obj)examples/standalone/eepro100_eeprom \ $(obj)examples/standalone/hello_world \ $(obj)examples/standalone/interrupt \ $(obj)examples/standalone/mem_to_mem_idma2intr \ $(obj)examples/standalone/sched \ $(obj)examples/standalone/smc911{11,x}_eeprom \ $(obj)examples/standalone/test_burst \ $(obj)examples/standalone/timer @rm -f $(obj)examples/api/demo{,.bin} @rm -f $(obj)tools/bmp_logo $(obj)tools/easylogo/easylogo \ $(obj)tools/env/{fw_printenv,fw_setenv} \ $(obj)tools/envcrc \ $(obj)tools/gdb/{astest,gdbcont,gdbsend} \ $(obj)tools/gen_eth_addr $(obj)tools/img2srec \ $(obj)tools/mk{env,}image $(obj)tools/mpc86x_clk \ $(obj)tools/ncb $(obj)tools/ubsha1 @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image} \ $(obj)board/matrix_vision/*/bootscript.img \ $(obj)board/voiceblue/eeprom \ $(obj)u-boot.lds \ $(obj)arch/blackfin/cpu/bootrom-asm-offsets.[chs] \ $(obj)arch/blackfin/cpu/init.{lds,elf} @rm -f $(obj)include/bmp_logo.h @rm -f $(obj)include/bmp_logo_data.h @rm -f $(obj)lib/asm-offsets.s @rm -f $(obj)include/generated/asm-offsets.h @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s @rm -f $(obj)nand_spl/{u-boot.lds,u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map,System.map} @rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map} @rm -f $(obj)mmc_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,u-boot-spl.bin,u-boot-mmc-spl.bin} @rm -f $(ONENAND_BIN) @rm -f $(obj)onenand_ipl/u-boot.lds @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.lds,u-boot-spl.map} @rm -f $(obj)MLO @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE) @find $(OBJTREE) -type f \ \( -name 'core' -o -name '*.bak' -o -name '*~' \ -o -name '*.o' -o -name '*.a' -o -name '*.exe' \) -print \ | xargs rm -f # Removes everything not needed for testing u-boot tidy: clean @find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f clobber: tidy @find $(OBJTREE) -type f \( -name '*.srec' \ -o -name '*.bin' -o -name u-boot.img \) \ -print0 | xargs -0 rm -f @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \ $(obj)cscope.* $(obj)*.*~ @rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y) @rm -f $(obj)u-boot.kwb @rm -f $(obj)u-boot.imx @rm -f $(obj)u-boot.ubl @rm -f $(obj)u-boot.dtb @rm -f $(obj)u-boot.sb @rm -f $(obj)tools/inca-swap-bytes @rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c @rm -f $(obj)arch/powerpc/cpu/mpc83xx/ddr-gen?.c @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm @rm -fr $(obj)include/generated @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f @[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f @[ ! -d $(obj)mmc_spl ] || find $(obj)mmc_spl -name "*" -type l -print | xargs rm -f @rm -f $(obj)dts/*.tmp mrproper \ distclean: clobber unconfig ifneq ($(OBJTREE),$(SRCTREE)) rm -rf $(obj)* endif backup: F=`basename $(TOPDIR)` ; cd .. ; \ gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F #########################################################################
1001-study-uboot
Makefile
Makefile
gpl3
25,570
#!/bin/sh -e # Script to create header files and links to configure # U-Boot for a specific board. # # Parameters: Target Architecture CPU Board [VENDOR] [SOC] # # (C) 2002-2010 DENX Software Engineering, Wolfgang Denk <wd@denx.de> # APPEND=no # Default: Create new config file BOARD_NAME="" # Name to print in make output TARGETS="" arch="" cpu="" board="" vendor="" soc="" options="" if [ \( $# -eq 2 \) -a \( "$1" = "-A" \) ] ; then # Automatic mode line=`egrep -i "^[[:space:]]*${2}[[:space:]]" boards.cfg` || { echo "make: *** No rule to make target \`$2_config'. Stop." >&2 exit 1 } set ${line} # add default board name if needed [ $# = 3 ] && set ${line} ${1} elif [ "${MAKEFLAGS+set}${MAKELEVEL+set}" = "setset" ] ; then # only warn when using a config target in the Makefile cat <<-EOF warning: Please migrate to boards.cfg. Failure to do so will mean removal of your board in the next release. EOF sleep 5 fi while [ $# -gt 0 ] ; do case "$1" in --) shift ; break ;; -a) shift ; APPEND=yes ;; -n) shift ; BOARD_NAME="${1%_config}" ; shift ;; -t) shift ; TARGETS="`echo $1 | sed 's:_: :g'` ${TARGETS}" ; shift ;; *) break ;; esac done [ $# -lt 4 ] && exit 1 [ $# -gt 7 ] && exit 1 # Strip all options and/or _config suffixes CONFIG_NAME="${1%_config}" [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}" arch="$2" cpu="$3" if [ "$4" = "-" ] ; then board=${BOARD_NAME} else board="$4" fi [ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5" [ $# -gt 5 ] && [ "$6" != "-" ] && soc="$6" [ $# -gt 6 ] && [ "$7" != "-" ] && { # check if we have a board config name in the options field # the options field mave have a board config name and a list # of options, both separated by a colon (':'); the options are # separated by commas (','). # # Check for board name tmp="${7%:*}" if [ "$tmp" ] ; then CONFIG_NAME="$tmp" fi # Check if we only have a colon... if [ "${tmp}" != "$7" ] ; then options=${7#*:} TARGETS="`echo ${options} | sed 's:,: :g'` ${TARGETS}" fi } if [ "${ARCH}" -a "${ARCH}" != "${arch}" ]; then echo "Failed: \$ARCH=${ARCH}, should be '${arch}' for ${BOARD_NAME}" 1>&2 exit 1 fi if [ "$options" ] ; then echo "Configuring for ${BOARD_NAME} - Board: ${CONFIG_NAME}, Options: ${options}" else echo "Configuring for ${BOARD_NAME} board..." fi # # Create link to architecture specific headers # if [ "$SRCTREE" != "$OBJTREE" ] ; then mkdir -p ${OBJTREE}/include mkdir -p ${OBJTREE}/include2 cd ${OBJTREE}/include2 rm -f asm ln -s ${SRCTREE}/arch/${arch}/include/asm asm LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/ cd ../include mkdir -p asm else cd ./include rm -f asm ln -s ../arch/${arch}/include/asm asm fi rm -f asm/arch if [ -z "${soc}" ] ; then ln -s ${LNPREFIX}arch-${cpu} asm/arch else ln -s ${LNPREFIX}arch-${soc} asm/arch fi if [ "${arch}" = "arm" ] ; then rm -f asm/proc ln -s ${LNPREFIX}proc-armv asm/proc fi # # Create include file for Make # echo "ARCH = ${arch}" > config.mk echo "CPU = ${cpu}" >> config.mk echo "BOARD = ${board}" >> config.mk [ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk [ "${soc}" ] && echo "SOC = ${soc}" >> config.mk # Assign board directory to BOARDIR variable if [ -z "${vendor}" ] ; then BOARDDIR=${board} else BOARDDIR=${vendor}/${board} fi # # Create board specific header file # if [ "$APPEND" = "yes" ] # Append to existing config file then echo >> config.h else > config.h # Create new config file fi echo "/* Automatically generated - do not edit */" >>config.h for i in ${TARGETS} ; do i="`echo ${i} | sed '/=/ {s/=/ /;q; } ; { s/$/ 1/; }'`" echo "#define CONFIG_${i}" >>config.h ; done cat << EOF >> config.h #define CONFIG_BOARDDIR board/$BOARDDIR #include <config_cmd_defaults.h> #include <config_defaults.h> #include <configs/${CONFIG_NAME}.h> #include <asm/config.h> EOF exit 0
1001-study-uboot
mkconfig
Shell
gpl3
3,889
# # (C) Copyright 2000-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # ######################################################################### ifeq ($(CURDIR),$(SRCTREE)) dir := else dir := $(subst $(SRCTREE)/,,$(CURDIR)) endif ifneq ($(OBJTREE),$(SRCTREE)) # Create object files for SPL in a separate directory ifeq ($(CONFIG_SPL_BUILD),y) obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/) else obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/) endif src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/) $(shell mkdir -p $(obj)) else # Create object files for SPL in a separate directory ifeq ($(CONFIG_SPL_BUILD),y) obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/) $(shell mkdir -p $(obj)) else obj := endif src := endif # clean the slate ... PLATFORM_RELFLAGS = PLATFORM_CPPFLAGS = PLATFORM_LDFLAGS = ######################################################################### HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ $(HOSTCPPFLAGS) HOSTSTRIP = strip # # Mac OS X / Darwin's C preprocessor is Apple specific. It # generates numerous errors and warnings. We want to bypass it # and use GNU C's cpp. To do this we pass the -traditional-cpp # option to the compiler. Note that the -traditional-cpp flag # DOES NOT have the same semantics as GNU C's flag, all it does # is invoke the GNU preprocessor in stock ANSI/ISO C fashion. # # Apple's linker is similar, thanks to the new 2 stage linking # multiple symbol definitions are treated as errors, hence the # -multiply_defined suppress option to turn off this error. # ifeq ($(HOSTOS),darwin) # get major and minor product version (e.g. '10' and '6' for Snow Leopard) DARWIN_MAJOR_VERSION = $(shell sw_vers -productVersion | cut -f 1 -d '.') DARWIN_MINOR_VERSION = $(shell sw_vers -productVersion | cut -f 2 -d '.') os_x_before = $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \ $(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;) # Snow Leopards build environment has no longer restrictions as described above HOSTCC = $(call os_x_before, 10, 5, "cc", "gcc") HOSTCFLAGS += $(call os_x_before, 10, 4, "-traditional-cpp") HOSTLDFLAGS += $(call os_x_before, 10, 5, "-multiply_defined suppress") else HOSTCC = gcc endif ifeq ($(HOSTOS),cygwin) HOSTCFLAGS += -ansi endif # We build some files with extra pedantic flags to try to minimize things # that won't build on some weird host compiler -- though there are lots of # exceptions for files that aren't complaint. HOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS)) HOSTCFLAGS += -pedantic ######################################################################### # # Option checker (courtesy linux kernel) to ensure # only supported compiler options are used # CC_OPTIONS_CACHE_FILE := $(OBJTREE)/include/generated/cc_options.mk $(if $(wildcard $(CC_OPTIONS_CACHE_FILE)),,\ $(shell mkdir -p $(dir $(CC_OPTIONS_CACHE_FILE)))) -include $(CC_OPTIONS_CACHE_FILE) cc-option-sys = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ > /dev/null 2>&1; then \ echo 'CC_OPTIONS += $(strip $1)' >> $(CC_OPTIONS_CACHE_FILE); \ echo "$(1)"; fi) ifeq ($(CONFIG_CC_OPT_CACHE_DISABLE),y) cc-option = $(strip $(if $(call cc-option-sys,$1),$1,$2)) else cc-option = $(strip $(if $(findstring $1,$(CC_OPTIONS)),$1,\ $(if $(call cc-option-sys,$1),$1,$2))) endif # # Include the make variables (CC, etc...) # AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld CC = $(CROSS_COMPILE)gcc CPP = $(CC) -E AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm LDR = $(CROSS_COMPILE)ldr STRIP = $(CROSS_COMPILE)strip OBJCOPY = $(CROSS_COMPILE)objcopy OBJDUMP = $(CROSS_COMPILE)objdump RANLIB = $(CROSS_COMPILE)RANLIB DTC = dtc ######################################################################### # Load generated board configuration sinclude $(OBJTREE)/include/autoconf.mk sinclude $(OBJTREE)/include/config.mk # Some architecture config.mk files need to know what CPUDIR is set to, # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files. # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains # CPU-specific code. CPUDIR=arch/$(ARCH)/cpu/$(CPU) ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR))) CPUDIR=arch/$(ARCH)/cpu endif sinclude $(TOPDIR)/arch/$(ARCH)/config.mk # include architecture dependend rules sinclude $(TOPDIR)/$(CPUDIR)/config.mk # include CPU specific rules ifdef SOC sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk # include SoC specific rules endif ifdef VENDOR BOARDDIR = $(VENDOR)/$(BOARD) else BOARDDIR = $(BOARD) endif ifdef BOARD sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules endif ######################################################################### # We don't actually use $(ARFLAGS) anywhere anymore, so catch people # who are porting old code to latest mainline but not updating $(AR). ARFLAGS = $(error update your Makefile to use cmd_link_o_target and not AR) RELFLAGS= $(PLATFORM_RELFLAGS) DBGFLAGS= -g # -DDEBUG OPTFLAGS= -Os #-fomit-frame-pointer OBJCFLAGS += --gap-fill=0xff gccincdir := $(shell $(CC) -print-file-name=include) CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS) \ -D__KERNEL__ # Enable garbage collection of un-used sections for SPL ifeq ($(CONFIG_SPL_BUILD),y) CPPFLAGS += -ffunction-sections -fdata-sections LDFLAGS_FINAL += --gc-sections endif ifneq ($(CONFIG_SYS_TEXT_BASE),) CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) endif ifneq ($(CONFIG_SPL_TEXT_BASE),) CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE) endif ifeq ($(CONFIG_SPL_BUILD),y) CPPFLAGS += -DCONFIG_SPL_BUILD endif ifneq ($(RESET_VECTOR_ADDRESS),) CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS) endif ifneq ($(OBJTREE),$(SRCTREE)) CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include endif CPPFLAGS += -I$(TOPDIR)/include CPPFLAGS += -fno-builtin -ffreestanding -nostdinc \ -isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS) ifdef BUILD_TAG CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \ -DBUILD_TAG='"$(BUILD_TAG)"' else CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes endif CFLAGS_SSP := $(call cc-option,-fno-stack-protector) CFLAGS += $(CFLAGS_SSP) # Some toolchains enable security related warning flags by default, # but they don't make much sense in the u-boot world, so disable them. CFLAGS_WARN := $(call cc-option,-Wno-format-nonliteral) \ $(call cc-option,-Wno-format-security) CFLAGS += $(CFLAGS_WARN) # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format> # option to the assembler. AFLAGS_DEBUG := # turn jbsr into jsr for m68k ifeq ($(ARCH),m68k) ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4) AFLAGS_DEBUG := -Wa,-gstabs,-S endif endif AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS) LDFLAGS += $(PLATFORM_LDFLAGS) LDFLAGS_FINAL += -Bstatic #wx:comment: set the linker mode with the lds(-T ldfilepath) and entry point(-Ttxt) LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL) ifneq ($(CONFIG_SYS_TEXT_BASE),) LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE) endif LDFLAGS_u-boot-spl += -T $(obj)u-boot-spl.lds $(LDFLAGS_FINAL) ifneq ($(CONFIG_SPL_TEXT_BASE),) LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE) endif # Location of a usable BFD library, where we define "usable" as # "built for ${HOST}, supports ${TARGET}". Sensible values are # - When cross-compiling: the root of the cross-environment # - Linux/ppc (native): /usr # - NetBSD/ppc (native): you lose ... (must extract these from the # binutils build directory, plus the native and U-Boot include # files don't like each other) # # So far, this is used only by tools/gdb/Makefile. ifeq ($(HOSTOS),darwin) BFD_ROOT_DIR = /usr/local/tools else ifeq ($(HOSTARCH),$(ARCH)) # native BFD_ROOT_DIR = /usr else #BFD_ROOT_DIR = /LinuxPPC/CDK # Linux/i386 #BFD_ROOT_DIR = /usr/pkg/cross # NetBSD/i386 BFD_ROOT_DIR = /opt/powerpc endif endif ######################################################################### export HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \ AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE export CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS ######################################################################### # Allow boards to use custom optimize flags on a per dir/file basis BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%)) ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR)) ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR)) EXTRA_CPPFLAGS = $(CPPFLAGS_$(BCURDIR)/$(@F)) $(CPPFLAGS_$(BCURDIR)) ALL_CFLAGS += $(EXTRA_CPPFLAGS) # The _DEP version uses the $< file target (for dependency generation) # See rules.mk EXTRA_CPPFLAGS_DEP = $(CPPFLAGS_$(BCURDIR)/$(addsuffix .o,$(basename $<))) \ $(CPPFLAGS_$(BCURDIR)) $(obj)%.s: %.S $(CPP) $(ALL_AFLAGS) -o $@ $< $(obj)%.o: %.S $(CC) $(ALL_AFLAGS) -o $@ $< -c $(obj)%.o: %.c $(CC) $(ALL_CFLAGS) -o $@ $< -c $(obj)%.i: %.c $(CPP) $(ALL_CFLAGS) -o $@ $< -c $(obj)%.s: %.c $(CC) $(ALL_CFLAGS) -o $@ $< -c -S ######################################################################### # If the list of objects to link is empty, just create an empty built-in.o cmd_link_o_target = $(if $(strip $1),\ $(LD) $(LDFLAGS) -r -o $@ $1,\ rm -f $@; $(AR) rcs $@ ) #########################################################################
1001-study-uboot
config.mk
Makefile
gpl3
10,208
# # (C) Copyright 2000-2002 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # CROSS_COMPILE ?= arm-linux- ifndef CONFIG_STANDALONE_LOAD_ADDR ifeq ($(SOC),omap3) CONFIG_STANDALONE_LOAD_ADDR = 0x80300000 else CONFIG_STANDALONE_LOAD_ADDR = 0xc100000 endif endif PLATFORM_CPPFLAGS += -DCONFIG_ARM -D__ARM__ # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb: PF_CPPFLAGS_ARM := $(call cc-option,-marm,) # Try if EABI is supported, else fall back to old API, # i. e. for example: # - with ELDK 4.2 (EABI supported), use: # -mabi=aapcs-linux -mno-thumb-interwork # - with ELDK 4.1 (gcc 4.x, no EABI), use: # -mabi=apcs-gnu -mno-thumb-interwork # - with ELDK 3.1 (gcc 3.x), use: # -mapcs-32 -mno-thumb-interwork PF_CPPFLAGS_ABI := $(call cc-option,\ -mabi=aapcs-linux -mno-thumb-interwork,\ $(call cc-option,\ -mapcs-32,\ $(call cc-option,\ -mabi=apcs-gnu,\ )\ ) $(call cc-option,-mno-thumb-interwork,)\ ) PLATFORM_CPPFLAGS += $(PF_CPPFLAGS_ARM) $(PF_CPPFLAGS_ABI) # For EABI, make sure to provide raise() ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS))) # This file is parsed many times, so the string may get added multiple # times. Also, the prefix needs to be different based on whether # CONFIG_SPL_BUILD is defined or not. 'filter-out' the existing entry # before adding the correct one. ifdef CONFIG_SPL_BUILD PLATFORM_LIBS := $(SPLTREE)/arch/arm/lib/eabi_compat.o \ $(filter-out %/arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS)) else PLATFORM_LIBS := $(OBJTREE)/arch/arm/lib/eabi_compat.o \ $(filter-out %/arch/arm/lib/eabi_compat.o, $(PLATFORM_LIBS)) endif endif ifdef CONFIG_SYS_LDSCRIPT # need to strip off double quotes LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT)) else LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds endif # needed for relocation ifndef CONFIG_NAND_SPL LDFLAGS_u-boot += -pie endif
1001-study-uboot
arch/arm/config.mk
Makefile
gpl3
2,662
/* * armboot - Startup Code for ARM920 CPU-core * * Copyright (c) 2001 Marius Gröger <mag@sysgo.de> * Copyright (c) 2002 Alex Züpke <azu@sysgo.de> * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <asm-offsets.h> #include <common.h> #include <config.h> /* ************************************************************************* * * Jump vector table as in table 3.1 in [1] * ************************************************************************* */ .globl _start _start: b start_code ldr pc, _undefined_instruction ldr pc, _software_interrupt ldr pc, _prefetch_abort ldr pc, _data_abort ldr pc, _not_used ldr pc, _irq ldr pc, _fiq _undefined_instruction: .word undefined_instruction _software_interrupt: .word software_interrupt _prefetch_abort: .word prefetch_abort _data_abort: .word data_abort _not_used: .word not_used _irq: .word irq _fiq: .word fiq .balignl 16,0xdeadbeef /* ************************************************************************* * * Startup Code (called from the ARM reset exception vector) * * do important init only if we don't start from memory! * relocate armboot to ram * setup stack * jump to second stage * ************************************************************************* */ .globl _TEXT_BASE _TEXT_BASE: .word CONFIG_SYS_TEXT_BASE /* * These are defined in the board-specific linker script. * Subtracting _start from them lets the linker put their * relative position in the executable instead of leaving * them null. */ /* wx:comment:layout of symbol load * |---------LOW------------- * | text * | data * |--------------------------- * | u-boot-cmd * |------------------__rel_dyn_start * | rel.dyn * |------------------__rel_dyn_end * |------------------__dynsym_start * | dynsym * |--------------------_end * |--------------------_bss_start * | bss * |--------------------__bss_end__ * | other * |--------------------------- */ .globl _bss_start_ofs _bss_start_ofs: .word __bss_start - _start .globl _bss_end_ofs _bss_end_ofs: .word __bss_end__ - _start .globl _end_ofs _end_ofs: .word _end - _start #ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START IRQ_STACK_START: .word 0x0badc0de /* IRQ stack memory (calculated at run-time) */ .globl FIQ_STACK_START FIQ_STACK_START: .word 0x0badc0de #endif /* IRQ stack memory (calculated at run-time) + 8 bytes */ .globl IRQ_STACK_START_IN IRQ_STACK_START_IN: .word 0x0badc0de /* * the actual start code */ start_code: /* * set the cpu to SVC32 mode */ mrs r0, cpsr bic r0, r0, #0x1f orr r0, r0, #0xd3 msr cpsr, r0 #if defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK) /* * relocate exception table */ ldr r0, =_start ldr r1, =0x0 mov r2, #16 copyex: subs r2, r2, #1 ldr r3, [r0], #4 str r3, [r1], #4 bne copyex #endif #ifdef CONFIG_S3C24X0 # if defined(CONFIG_S3C2400) # define pWTCON 0x15300000 # define INTMSK 0x14400008 /* Interrupt-Controller base addresses */ # define CLKDIVN 0x14800014 /* clock divisor register */ #else //wx:comment : blow register is same 2410 and 2440 # define pWTCON 0x53000000 # define INTMSK 0x4A000008 /* Interrupt-Controller base addresses */ # define INTSUBMSK 0x4A00001C # define CLKDIVN 0x4C000014 /* clock divisor register */ # endif /* turn off the watchdog */ ldr r0, =pWTCON mov r1, #0x0 str r1, [r0] /* * mask all IRQs by setting all bits in the INTMR - default */ mov r1, #0xffffffff ldr r0, =INTMSK str r1, [r0] # if defined(CONFIG_S3C2410) ldr r1, =0x3ff ldr r0, =INTSUBMSK str r1, [r0] # elif defined(CONFIG_S3C2440) ldr r1, =0x7fff ldr r0, =INTSUBMSK str r1, [r0] # endif # if defined(CONFIG_S3C2440) #define CLK_CTL_BASE (0x4C000000) #define MDIV_405 (0x7f << 12 ) #define PSDIV_405 (0x21) /* * FCLK:HCLK:PCLK = 1:4:8 * because we will set fclk, hclk, pclk, at different speed, * the CLKDIVEN should be changed, and the C15 should be set * please see Chapter 7 Page 9 */ ldr r0, =CLKDIVN mov r1, #5 str r1, [r0] /* * orr r0, r0, #R1_nF:OR:R1_iA * This strange thing comes from the C15 co-processor */ mrc p15, 0, r1, c1, c0, 0 orr r1, r1, #0xc0000000 mcr p15, 0, r1, c1, c0, 0 /* * set mpll to 405Mhz, see C7P21 */ mov r1, #CLK_CTL_BASE mov r2, #MDIV_405 add r2, r2, #PSDIV_405 str r2, [r1, #0x04] /* MPLLCON = CLK_BASE+4 */ # else /* FCLK:HCLK:PCLK = 1:2:4 */ /* default FCLK is 120 MHz ! */ ldr r0, =CLKDIVN mov r1, #3 str r1, [r0] #endif /*CONFIG_S3C2440*/ #endif /* CONFIG_S3C24X0 */ /* * we do sys-critical inits only at reboot, * not when booting from ram! */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT bl cpu_init_crit #endif #ifdef CONFIG_NAND_BOOT /*wx:temp stack, it will reset when load finished by other routines*/ ldr sp, =(CONFIG_SYS_TEXT_BASE + (2<<20)) @wx: this address must in dram valid area bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ @ load U-Boot to RAM ldr r0, =CONFIG_SYS_TEXT_BASE bl nandboot_load_img ldr pc, =call_board_init_f #endif /* Set stackpointer in internal RAM to call board_init_f */ /* wx:comment: start.s jump to c function need useed a stack(CONFIG_SYS_INIT_SP_ADDR) (this must inited before call any c function) the GENERATED_GBL_DATA_SIZE(global_data) is create by kbulid tools as in asm-offsets.c --------------------------------- | (4K)=0x30001000 | +sizeof(struct global_data) = gd | =INIT_SP_ADDR | // up is stack, down is system global data | +SP_SIZE ?(dymatic size, decide by gd size) |-------------------------------- | boot code |------=0x30000000 --------------------------------- */ call_board_init_f: ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ ldr r0,=0x00000000 bl board_init_f /*------------------------------------------------------------------------------*/ /* wx:comment:layout relocate |----high memery-------------- | bss | |------------- | sym talbe | |------------- | rel dyn | |--------------------- | text code | | |------------------- | ------ R6 (Dest Addr) ---- | | R9 | | |<---- | |------------ - | | R9 (offset) | bss | | |<------------------- |-------------? | | | sym talbe | | | |-------------R10 | | |-------------R3 | | | rel dyn | | | |-------------R2----- | | text code | | |------------- TEXT_BASE ----------------------- */ /* * void relocate_code (addr_sp, gd, addr_moni) * * This "function" does not return, instead it continues in RAM * after relocating the monitor code. * */ .globl relocate_code relocate_code: mov r4, r0 /* save addr_sp */ mov r5, r1 /* save addr of gd */ mov r6, r2 /* save addr of destination */ /* Set up the stack */ stack_setup: mov sp, r4 adr r0, _start /* from */ cmp r0, r6 /* if code is in ram */ beq clear_bss /* skip relocation */ mov r1, r6 /* r1 <- scratch for copy_loop */ ldr r3, _bss_start_ofs add r2, r0, r3 /* r2 <- source end address */ /*wx:comment:copy text+data to destination*/ copy_loop: ldmia r0!, {r9-r10} /* copy from source address [r0] */ stmia r1!, {r9-r10} /* copy to target address [r1] */ cmp r0, r2 /* until source end address [r2] */ blo copy_loop #ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */ ldr r0, _TEXT_BASE /* r0 <- Text base */ sub r9, r6, r0 /* r9 <- relocation offset */ ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ add r10, r10, r0 /* r10 <- sym table in FLASH */ ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ add r2, r2, r0 /* r2 <- rel dyn start in FLASH */ ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ add r3, r3, r0 /* r3 <- rel dyn end in FLASH */ fixloop: ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */ add r0, r0, r9 /* r0 <- location to fix up in RAM */ ldr r1, [r2, #4] and r7, r1, #0xff cmp r7, #23 /* relative fixup? */ beq fixrel cmp r7, #2 /* absolute fixup? */ beq fixabs /* ignore unknown type of fixup */ b fixnext fixabs: /* absolute fix: set location to (offset) symbol value */ mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */ add r1, r10, r1 /* r1 <- address of symbol in table */ ldr r1, [r1, #4] /* r1 <- symbol value */ add r1, r1, r9 /* r1 <- relocated sym addr */ b fixnext fixrel: /* relative fix: increase location by offset */ ldr r1, [r0] add r1, r1, r9 fixnext: str r1, [r0] add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop #endif clear_bss: #ifndef CONFIG_SPL_BUILD ldr r0, _bss_start_ofs ldr r1, _bss_end_ofs mov r4, r6 /* reloc addr */ add r0, r0, r4 add r1, r1, r4 mov r2, #0x00000000 /* clear */ clbss_l:str r2, [r0] /* clear loop... */ add r0, r0, #4 cmp r0, r1 bne clbss_l //bl coloured_LED_init //bl red_led_on #endif /* * We are done. Do not return, instead branch to second part of board * initialization, now running from RAM. */ /*wx:comment:if need second program load */ #ifdef CONFIG_NAND_SPL ldr r0, _nand_boot_ofs mov pc, r0 _nand_boot_ofs: .word nand_boot #else ldr r0, _board_init_r_ofs adr r1, _start add lr, r0, r1 add lr, lr, r9 /* setup parameters for board_init_r */ mov r0, r5 /* gd_t */ mov r1, r6 /* dest_addr */ /* jump to it ... */ mov pc, lr _board_init_r_ofs: .word board_init_r - _start #endif _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs: .word __rel_dyn_end - _start _dynsym_start_ofs: .word __dynsym_start - _start /* ************************************************************************* * * CPU_init_critical registers * * setup important registers * setup memory timing * ************************************************************************* */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT cpu_init_crit: /* * flush v4 I/D caches */ mov r0, #0 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ /* * disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) orr r0, r0, #0x00000002 @ set bit 2 (A) Align orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache mcr p15, 0, r0, c1, c0, 0 /* * before relocating, we have to setup RAM timing * because memory timing is board-dependend, you will * find a lowlevel_init.S in your board directory. */ mov ip, lr bl lowlevel_init mov lr, ip mov pc, lr #endif /* CONFIG_SKIP_LOWLEVEL_INIT */ /* ************************************************************************* * * Interrupt handling * ************************************************************************* */ @ @ IRQ stack frame. @ #define S_FRAME_SIZE 72 #define S_OLD_R0 68 #define S_PSR 64 #define S_PC 60 #define S_LR 56 #define S_SP 52 #define S_IP 48 #define S_FP 44 #define S_R10 40 #define S_R9 36 #define S_R8 32 #define S_R7 28 #define S_R6 24 #define S_R5 20 #define S_R4 16 #define S_R3 12 #define S_R2 8 #define S_R1 4 #define S_R0 0 #define MODE_SVC 0x13 #define I_BIT 0x80 /* * use bad_save_user_regs for abort/prefetch/undef/swi ... * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling */ /* wx:comment: current stack as bleow(SP not move any offset) | ------------ HIGH ------------------- | SPSR [caller(interupt break point)'s cpsr] | LR [caller(interupt break point)'s PC] == IRQ_STACK_START_IN <= current SP | -------- LOW ------------------------ */ .macro bad_save_user_regs sub sp, sp, #S_FRAME_SIZE stmia sp, {r0 - r12} @ Calling r0-r12 ldr r2, IRQ_STACK_START_IN ldmia r2, {r2 - r3} @ get pc, cpsr add r0, sp, #S_FRAME_SIZE @ restore sp_SVC /* wx:comment: current stack as bleow(SP not move any offset) |-----------------HIGH----------------------------- | SPSR [caller(interupt break point)'s cpsr] | | LR [caller(interupt break point)'s PC] == IRQ_STACK_START_IN | -------------- SPSR -(same as the hight spsr)- | -------------- LR ---(same as the hight LR)- | -------------- LR ---(same as the hight LR)- | -------------- SP Point To IRQ_STACK_START_IN | R12 | R11 | ... | R0 <= current SP */ add r5, sp, #S_SP mov r1, lr stmia r5, {r0 - r3} @ save sp_SVC, lr_SVC, pc, cpsr mov r0, sp .endm .macro irq_save_user_regs sub sp, sp, #S_FRAME_SIZE stmia sp, {r0 - r12} @ Calling r0-r12 add r7, sp, #S_PC stmdb r7, {sp, lr}^ @ Calling SP, LR str lr, [r7, #0] @ Save calling PC mrs r6, spsr str r6, [r7, #4] @ Save CPSR str r0, [r7, #8] @ Save OLD_R0 mov r0, sp .endm .macro irq_restore_user_regs ldmia sp, {r0 - lr}^ @ Calling r0 - lr mov r0, r0 ldr lr, [sp, #S_PC] @ Get PC add sp, sp, #S_FRAME_SIZE /* return & move spsr_svc into cpsr */ subs pc, lr, #4 .endm .macro get_bad_stack ldr r13, IRQ_STACK_START_IN @ setup our mode stack str lr, [r13] @ save caller lr / spsr mrs lr, spsr str lr, [r13, #4] /* wx:comment: the current stack as bleow(SP not move any offset) | ------------ HIGH ------------------- | SPSR [caller(interupt break point)'s cpsr] | | LR [caller(interupt break point)'s PC] <= current SP | | ------------- LOW ------------------- */ mov r13, #MODE_SVC @ prepare SVC-Mode @ msr spsr_c, r13 msr spsr, r13 mov lr, pc /*@ wx:comment:return exception and restore cpsr from spsr_mode(return and auto switch to svc mode)*/ movs pc, lr .endm .macro get_irq_stack @ setup IRQ stack ldr sp, IRQ_STACK_START .endm .macro get_fiq_stack @ setup FIQ stack ldr sp, FIQ_STACK_START .endm /* * exception handlers */ .align 5 undefined_instruction: get_bad_stack bad_save_user_regs bl do_undefined_instruction .align 5 software_interrupt: get_bad_stack bad_save_user_regs bl do_software_interrupt .align 5 prefetch_abort: get_bad_stack bad_save_user_regs bl do_prefetch_abort .align 5 data_abort: get_bad_stack bad_save_user_regs bl do_data_abort .align 5 not_used: get_bad_stack bad_save_user_regs bl do_not_used #ifdef CONFIG_USE_IRQ .align 5 irq: get_irq_stack irq_save_user_regs bl do_irq irq_restore_user_regs .align 5 fiq: get_fiq_stack /* someone ought to write a more effiction fiq_save_user_regs */ irq_save_user_regs bl do_fiq irq_restore_user_regs #else .align 5 irq: get_bad_stack bad_save_user_regs bl do_irq .align 5 fiq: get_bad_stack bad_save_user_regs bl do_fiq #endif
1001-study-uboot
arch/arm/cpu/arm920t/start.S
Unix Assembly
gpl3
15,586
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <asm/proc-armv/ptrace.h> #if defined (CONFIG_ARCH_INTEGRATOR) void do_irq (struct pt_regs *pt_regs) { /* ASSUMED to be a timer interrupt */ /* Just clear it - count handled in */ /* integratorap.c */ *(volatile ulong *)(CONFIG_SYS_TIMERBASE + 0x0C) = 0; } #endif
1001-study-uboot
arch/arm/cpu/arm920t/interrupts.c
C
gpl3
1,425
# # (C) Copyright 2000-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # include $(TOPDIR)/config.mk LIB = $(obj)lib$(CPU).o START = start.o COBJS-y += cpu.o COBJS-$(CONFIG_USE_IRQ) += interrupts.o SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y) $(SOBJS)) START := $(addprefix $(obj),$(START)) all: $(obj).depend $(START) $(LIB) $(LIB): $(OBJS) $(call cmd_link_o_target, $(OBJS)) ######################################################################### # defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend #########################################################################
1001-study-uboot
arch/arm/cpu/arm920t/Makefile
Makefile
gpl3
1,461
# # (C) Copyright 2002 # Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # PLATFORM_RELFLAGS += -fno-common -ffixed-r8 #-msoft-float PLATFORM_CPPFLAGS += -march=armv4 # ========================================================================= # # Supply options according to compiler version # # ========================================================================= PF_RELFLAGS_SLB_AT := $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) PLATFORM_RELFLAGS += $(PF_RELFLAGS_SLB_AT)
1001-study-uboot
arch/arm/cpu/arm920t/config.mk
Makefile
gpl3
1,300
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * CPU specific code */ #include <common.h> #include <command.h> #include <asm/system.h> static void cache_flush(void); int cleanup_before_linux (void) { /* * this function is called just before we call linux * it prepares the processor for linux * * we turn off caches etc ... */ disable_interrupts (); /* turn off I/D-cache */ icache_disable(); dcache_disable(); /* flush I/D-cache */ cache_flush(); return 0; } /* flush I/D-cache */ static void cache_flush (void) { unsigned long i = 0; asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i)); }
1001-study-uboot
arch/arm/cpu/arm920t/cpu.c
C
gpl3
1,571
/* * (C) Copyright 2010 * David Mueller <d.mueller@elsoft.ch> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <asm/io.h> #include <asm/arch/s3c24x0_cpu.h> typedef ulong (*getfreq)(void); static const getfreq freq_f[] = { get_FCLK, get_HCLK, get_PCLK, }; static const char freq_c[] = { 'F', 'H', 'P' }; int print_cpuinfo(void) { int i; char buf[32]; /* the S3C2400 seems to be lacking a CHIP ID register */ #ifndef CONFIG_S3C2400 ulong cpuid; struct s3c24x0_gpio * const gpio = s3c24x0_get_base_gpio(); cpuid = readl(&gpio->gstatus1); printf("CPUID: %8lX\n", cpuid); #endif for (i = 0; i < ARRAY_SIZE(freq_f); i++) printf("%cCLK: %8s MHz\n", freq_c[i], strmhz(buf, freq_f[i]())); return 0; }
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/cpu_info.c
C
gpl3
1,492
/* * (C) Copyright 2001-2004 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * (C) Copyright 2002 * David Mueller, ELSOFT AG, d.mueller@elsoft.ch * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* This code should work for both the S3C2400 and the S3C2410 * as they seem to have the same PLL and clock machinery inside. * The different address mapping is handled by the s3c24xx.h files below. */ #include <common.h> #ifdef CONFIG_S3C24X0 #include <asm/io.h> #include <asm/arch/s3c24x0_cpu.h> #define MPLL 0 #define UPLL 1 /* ------------------------------------------------------------------------- */ /* NOTE: This describes the proper use of this file. * * CONFIG_SYS_CLK_FREQ should be defined as the input frequency of the PLL. * * get_FCLK(), get_HCLK(), get_PCLK() and get_UCLK() return the clock of * the specified bus in HZ. */ /* ------------------------------------------------------------------------- */ static ulong get_PLLCLK(int pllreg) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); ulong r, m, p, s; if (pllreg == MPLL) r = readl(&clk_power->mpllcon); else if (pllreg == UPLL) r = readl(&clk_power->upllcon); else hang(); m = ((r & 0xFF000) >> 12) + 8; p = ((r & 0x003F0) >> 4) + 2; s = r & 0x3; #if defined(CONFIG_S3C2440) if (pllreg == MPLL) // wx:comment:ref spec: PLL=(2 X m X Fin)/(p X 2^s) return 2 * m * (CONFIG_SYS_CLK_FREQ / (p << s)); #endif return (CONFIG_SYS_CLK_FREQ * m) / (p << s); } /* return FCLK frequency */ ulong get_FCLK(void) { return get_PLLCLK(MPLL); } /* return HCLK frequency */ ulong get_HCLK(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); #ifdef CONFIG_S3C2440 switch (readl(&clk_power->clkdivn) & 0x6) { default: case 0: return get_FCLK(); case 2: return get_FCLK() / 2; case 4: return (readl(&clk_power->camdivn) & (1 << 9)) ? get_FCLK() / 8 : get_FCLK() / 4; case 6: return (readl(&clk_power->camdivn) & (1 << 8)) ? get_FCLK() / 6 : get_FCLK() / 3; } #else return (readl(&clk_power->clkdivn) & 2) ? get_FCLK() / 2 : get_FCLK(); #endif } /* return PCLK frequency */ ulong get_PCLK(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); return (readl(&clk_power->clkdivn) & 1) ? get_HCLK() / 2 : get_HCLK(); } /* return UCLK frequency */ ulong get_UCLK(void) { return get_PLLCLK(UPLL); } #endif /* CONFIG_S3C24X0 */
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/speed.c
C
gpl3
3,183
/* * URB OHCI HCD (Host Controller Driver) for USB. * * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> * (C) Copyright 2000-2001 David Brownell <dbrownell@users.sourceforge.net> * * usb-ohci.h */ static int cc_to_error[16] = { /* mapping of the OHCI CC status to error codes */ /* No Error */ 0, /* CRC Error */ USB_ST_CRC_ERR, /* Bit Stuff */ USB_ST_BIT_ERR, /* Data Togg */ USB_ST_CRC_ERR, /* Stall */ USB_ST_STALLED, /* DevNotResp */ -1, /* PIDCheck */ USB_ST_BIT_ERR, /* UnExpPID */ USB_ST_BIT_ERR, /* DataOver */ USB_ST_BUF_ERR, /* DataUnder */ USB_ST_BUF_ERR, /* reservd */ -1, /* reservd */ -1, /* BufferOver */ USB_ST_BUF_ERR, /* BuffUnder */ USB_ST_BUF_ERR, /* Not Access */ -1, /* Not Access */ -1 }; /* ED States */ #define ED_NEW 0x00 #define ED_UNLINK 0x01 #define ED_OPER 0x02 #define ED_DEL 0x04 #define ED_URB_DEL 0x08 /* usb_ohci_ed */ struct ed { __u32 hwINFO; __u32 hwTailP; __u32 hwHeadP; __u32 hwNextED; struct ed *ed_prev; __u8 int_period; __u8 int_branch; __u8 int_load; __u8 int_interval; __u8 state; __u8 type; __u16 last_iso; struct ed *ed_rm_list; struct usb_device *usb_dev; __u32 unused[3]; } __attribute__ ((aligned(16))); /* TD info field */ #define TD_CC 0xf0000000 #define TD_CC_GET(td_p) (((td_p) >> 28) & 0x0f) #define TD_CC_SET(td_p, cc) \ {(td_p) = ((td_p) & 0x0fffffff) | (((cc) & 0x0f) << 28)} #define TD_EC 0x0C000000 #define TD_T 0x03000000 #define TD_T_DATA0 0x02000000 #define TD_T_DATA1 0x03000000 #define TD_T_TOGGLE 0x00000000 #define TD_R 0x00040000 #define TD_DI 0x00E00000 #define TD_DI_SET(X) (((X) & 0x07)<< 21) #define TD_DP 0x00180000 #define TD_DP_SETUP 0x00000000 #define TD_DP_IN 0x00100000 #define TD_DP_OUT 0x00080000 #define TD_ISO 0x00010000 #define TD_DEL 0x00020000 /* CC Codes */ #define TD_CC_NOERROR 0x00 #define TD_CC_CRC 0x01 #define TD_CC_BITSTUFFING 0x02 #define TD_CC_DATATOGGLEM 0x03 #define TD_CC_STALL 0x04 #define TD_DEVNOTRESP 0x05 #define TD_PIDCHECKFAIL 0x06 #define TD_UNEXPECTEDPID 0x07 #define TD_DATAOVERRUN 0x08 #define TD_DATAUNDERRUN 0x09 #define TD_BUFFEROVERRUN 0x0C #define TD_BUFFERUNDERRUN 0x0D #define TD_NOTACCESSED 0x0F #define MAXPSW 1 struct td { __u32 hwINFO; __u32 hwCBP; /* Current Buffer Pointer */ __u32 hwNextTD; /* Next TD Pointer */ __u32 hwBE; /* Memory Buffer End Pointer */ __u8 unused; __u8 index; struct ed *ed; struct td *next_dl_td; struct usb_device *usb_dev; int transfer_len; __u32 data; __u32 unused2[2]; } __attribute__ ((aligned(32))); #define OHCI_ED_SKIP (1 << 14) /* * The HCCA (Host Controller Communications Area) is a 256 byte * structure defined in the OHCI spec. that the host controller is * told the base address of. It must be 256-byte aligned. */ #define NUM_INTS 32 /* part of the OHCI standard */ struct ohci_hcca { __u32 int_table[NUM_INTS]; /* Interrupt ED table */ __u16 frame_no; /* current frame number */ __u16 pad1; /* set to 0 on each frame_no change */ __u32 done_head; /* info returned for an interrupt */ u8 reserved_for_hc[116]; } __attribute__ ((aligned(256))); /* * Maximum number of root hub ports. */ #define MAX_ROOT_PORTS 15 /* maximum OHCI root hub ports */ /* * This is the structure of the OHCI controller's memory mapped I/O * region. This is Memory Mapped I/O. You must use the readl() and * writel() macros defined in asm/io.h to access these!! */ struct ohci_regs { /* control and status registers */ __u32 revision; __u32 control; __u32 cmdstatus; __u32 intrstatus; __u32 intrenable; __u32 intrdisable; /* memory pointers */ __u32 hcca; __u32 ed_periodcurrent; __u32 ed_controlhead; __u32 ed_controlcurrent; __u32 ed_bulkhead; __u32 ed_bulkcurrent; __u32 donehead; /* frame counters */ __u32 fminterval; __u32 fmremaining; __u32 fmnumber; __u32 periodicstart; __u32 lsthresh; /* Root hub ports */ struct ohci_roothub_regs { __u32 a; __u32 b; __u32 status; __u32 portstatus[MAX_ROOT_PORTS]; } roothub; } __attribute__ ((aligned(32))); /* OHCI CONTROL AND STATUS REGISTER MASKS */ /* * HcControl (control) register masks */ #define OHCI_CTRL_CBSR (3 << 0) /* control/bulk service ratio */ #define OHCI_CTRL_PLE (1 << 2) /* periodic list enable */ #define OHCI_CTRL_IE (1 << 3) /* isochronous enable */ #define OHCI_CTRL_CLE (1 << 4) /* control list enable */ #define OHCI_CTRL_BLE (1 << 5) /* bulk list enable */ #define OHCI_CTRL_HCFS (3 << 6) /* host controller functional state */ #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */ #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ #define OHCI_CTRL_RWE (1 << 10) /* remote wakeup enable */ /* pre-shifted values for HCFS */ # define OHCI_USB_RESET (0 << 6) # define OHCI_USB_RESUME (1 << 6) # define OHCI_USB_OPER (2 << 6) # define OHCI_USB_SUSPEND (3 << 6) /* * HcCommandStatus (cmdstatus) register masks */ #define OHCI_HCR (1 << 0) /* host controller reset */ #define OHCI_CLF (1 << 1) /* control list filled */ #define OHCI_BLF (1 << 2) /* bulk list filled */ #define OHCI_OCR (1 << 3) /* ownership change request */ #define OHCI_SOC (3 << 16) /* scheduling overrun count */ /* * masks used with interrupt registers: * HcInterruptStatus (intrstatus) * HcInterruptEnable (intrenable) * HcInterruptDisable (intrdisable) */ #define OHCI_INTR_SO (1 << 0) /* scheduling overrun */ #define OHCI_INTR_WDH (1 << 1) /* writeback of done_head */ #define OHCI_INTR_SF (1 << 2) /* start frame */ #define OHCI_INTR_RD (1 << 3) /* resume detect */ #define OHCI_INTR_UE (1 << 4) /* unrecoverable error */ #define OHCI_INTR_FNO (1 << 5) /* frame number overflow */ #define OHCI_INTR_RHSC (1 << 6) /* root hub status change */ #define OHCI_INTR_OC (1 << 30) /* ownership change */ #define OHCI_INTR_MIE (1 << 31) /* master interrupt enable */ /* Virtual Root HUB */ struct virt_root_hub { int devnum; /* Address of Root Hub endpoint */ void *dev; /* was urb */ void *int_addr; int send; int interval; }; /* USB HUB CONSTANTS (not OHCI-specific; see hub.h) */ /* destination of request */ #define RH_INTERFACE 0x01 #define RH_ENDPOINT 0x02 #define RH_OTHER 0x03 #define RH_CLASS 0x20 #define RH_VENDOR 0x40 /* Requests: bRequest << 8 | bmRequestType */ #define RH_GET_STATUS 0x0080 #define RH_CLEAR_FEATURE 0x0100 #define RH_SET_FEATURE 0x0300 #define RH_SET_ADDRESS 0x0500 #define RH_GET_DESCRIPTOR 0x0680 #define RH_SET_DESCRIPTOR 0x0700 #define RH_GET_CONFIGURATION 0x0880 #define RH_SET_CONFIGURATION 0x0900 #define RH_GET_STATE 0x0280 #define RH_GET_INTERFACE 0x0A80 #define RH_SET_INTERFACE 0x0B00 #define RH_SYNC_FRAME 0x0C80 /* Our Vendor Specific Request */ #define RH_SET_EP 0x2000 /* Hub port features */ #define RH_PORT_CONNECTION 0x00 #define RH_PORT_ENABLE 0x01 #define RH_PORT_SUSPEND 0x02 #define RH_PORT_OVER_CURRENT 0x03 #define RH_PORT_RESET 0x04 #define RH_PORT_POWER 0x08 #define RH_PORT_LOW_SPEED 0x09 #define RH_C_PORT_CONNECTION 0x10 #define RH_C_PORT_ENABLE 0x11 #define RH_C_PORT_SUSPEND 0x12 #define RH_C_PORT_OVER_CURRENT 0x13 #define RH_C_PORT_RESET 0x14 /* Hub features */ #define RH_C_HUB_LOCAL_POWER 0x00 #define RH_C_HUB_OVER_CURRENT 0x01 #define RH_DEVICE_REMOTE_WAKEUP 0x00 #define RH_ENDPOINT_STALL 0x01 #define RH_ACK 0x01 #define RH_REQ_ERR -1 #define RH_NACK 0x00 /* OHCI ROOT HUB REGISTER MASKS */ /* roothub.portstatus [i] bits */ #define RH_PS_CCS 0x00000001 /* current connect status */ #define RH_PS_PES 0x00000002 /* port enable status */ #define RH_PS_PSS 0x00000004 /* port suspend status */ #define RH_PS_POCI 0x00000008 /* port over current indicator */ #define RH_PS_PRS 0x00000010 /* port reset status */ #define RH_PS_PPS 0x00000100 /* port power status */ #define RH_PS_LSDA 0x00000200 /* low speed device attached */ #define RH_PS_CSC 0x00010000 /* connect status change */ #define RH_PS_PESC 0x00020000 /* port enable status change */ #define RH_PS_PSSC 0x00040000 /* port suspend status change */ #define RH_PS_OCIC 0x00080000 /* over current indicator change */ #define RH_PS_PRSC 0x00100000 /* port reset status change */ /* roothub.status bits */ #define RH_HS_LPS 0x00000001 /* local power status */ #define RH_HS_OCI 0x00000002 /* over current indicator */ #define RH_HS_DRWE 0x00008000 /* device remote wakeup enable */ #define RH_HS_LPSC 0x00010000 /* local power status change */ #define RH_HS_OCIC 0x00020000 /* over current indicator change */ #define RH_HS_CRWE 0x80000000 /* clear remote wakeup enable */ /* roothub.b masks */ #define RH_B_DR 0x0000ffff /* device removable flags */ #define RH_B_PPCM 0xffff0000 /* port power control mask */ /* roothub.a masks */ #define RH_A_NDP (0xff << 0) /* number of downstream ports */ #define RH_A_PSM (1 << 8) /* power switching mode */ #define RH_A_NPS (1 << 9) /* no power switching */ #define RH_A_DT (1 << 10) /* device type (mbz) */ #define RH_A_OCPM (1 << 11) /* over current protection mode */ #define RH_A_NOCP (1 << 12) /* no over current protection */ #define RH_A_POTPGT (0xff << 24) /* power on to power good time */ /* urb */ #define N_URB_TD 48 struct urb_priv { struct ed *ed; __u16 length; /* number of tds associated with this request */ __u16 td_cnt; /* number of tds already serviced */ int state; unsigned long pipe; int actual_length; struct td *td[N_URB_TD]; /* list pointer to all corresponding TDs associated with this request */ }; #define URB_DEL 1 /* * This is the full ohci controller description * * Note how the "proper" USB information is just * a subset of what the full implementation needs. (Linus) */ struct ohci { struct ohci_hcca *hcca; /* hcca */ /*dma_addr_t hcca_dma; */ int irq; int disabled; /* e.g. got a UE, we're hung */ int sleeping; unsigned long flags; /* for HC bugs */ struct ohci_regs *regs; /* OHCI controller's memory */ struct ed *ed_rm_list[2]; /* lists of all endpoints to be removed */ struct ed *ed_bulktail; /* last endpoint of bulk list */ struct ed *ed_controltail; /* last endpoint of control list */ int intrstatus; __u32 hc_control; /* copy of the hc control reg */ struct usb_device *dev[32]; struct virt_root_hub rh; const char *slot_name; }; #define NUM_EDS 8 /* num of preallocated endpoint descriptors */ struct ohci_device { struct ed ed[NUM_EDS]; int ed_cnt; }; /* hcd */ /* endpoint */ static int ep_link(struct ohci *ohci, struct ed *ed); static int ep_unlink(struct ohci *ohci, struct ed *ed); static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe); /*-------------------------------------------------------------------------*/ /* we need more TDs than EDs */ #define NUM_TD 64 /* +1 so we can align the storage */ struct td gtd[NUM_TD + 1]; /* pointers to aligned storage */ struct td *ptd; /* TDs ... */ static inline struct td *td_alloc(struct usb_device *usb_dev) { int i; struct td *td; td = NULL; for (i = 0; i < NUM_TD; i++) { if (ptd[i].usb_dev == NULL) { td = &ptd[i]; td->usb_dev = usb_dev; break; } } return td; } static inline void ed_free(struct ed *ed) { ed->usb_dev = NULL; }
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/usb_ohci.h
C
gpl3
11,186
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <gj@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <asm/arch/s3c24x0_cpu.h> #include <asm/proc-armv/ptrace.h> void do_irq (struct pt_regs *pt_regs) { struct s3c24x0_interrupt *irq = s3c24x0_get_base_interrupt(); u_int32_t intpnd = readl(&irq->INTPND); }
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/interrupts.c
C
gpl3
1,343
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #ifdef CONFIG_S3C24X0 #include <asm/io.h> #include <asm/arch/s3c24x0_cpu.h> #if 0 //wx:delete int timer_load_val = 0; static ulong timer_clk; #else //wx:replace to this block DECLARE_GLOBAL_DATA_PTR; #define timer_load_val (gd->timer_rate_hz) #define timer_clk (gd->tbl) #endif /* macro to read the 16 bit timer */ static inline ulong READ_TIMER(void) { struct s3c24x0_timers *timers = s3c24x0_get_base_timers(); return readl(&timers->tcnto4) & 0xffff; } #if 0 /** static ulong timestamp; static ulong lastdec; */ #else #define timestamp (gd->timer_reset_value) #define lastdec (gd->lastinc) #endif int timer_init(void) { struct s3c24x0_timers *timers = s3c24x0_get_base_timers(); ulong tmr; /* use PWM Timer 4 because it has no output */ /* prescaler for Timer 4 is 16 */ writel(0x0f00, &timers->tcfg0); if (timer_load_val == 0) { /* * for 10 ms clock period @ PCLK with 4 bit divider = 1/2 * (default) and prescaler = 16. Should be 10390 * @33.25MHz and 15625 @ 50 MHz */ timer_load_val = get_PCLK() / (2 * 16 * 100); timer_clk = get_PCLK() / (2 * 16); } /* load value for 10 ms timeout */ lastdec = timer_load_val; writel(timer_load_val, &timers->tcntb4); /* auto load, manual update of timer 4 */ tmr = (readl(&timers->tcon) & ~0x0700000) | 0x0600000; writel(tmr, &timers->tcon); /* auto load, start timer 4 */ tmr = (tmr & ~0x0700000) | 0x0500000; writel(tmr, &timers->tcon); timestamp = 0; return (0); } /* * timer without interrupts */ ulong get_timer(ulong base) { return get_timer_masked() - base; } void __udelay (unsigned long usec) { ulong tmo; ulong start = get_ticks(); tmo = usec / 1000; tmo *= (timer_load_val * 100); tmo /= 1000; while ((ulong) (get_ticks() - start) < tmo) /*NOP*/; } ulong get_timer_masked(void) { ulong tmr = get_ticks(); return tmr / (timer_clk / CONFIG_SYS_HZ); } void udelay_masked(unsigned long usec) { ulong tmo; ulong endtime; signed long diff; if (usec >= 1000) { tmo = usec / 1000; tmo *= (timer_load_val * 100); tmo /= 1000; } else { tmo = usec * (timer_load_val * 100); tmo /= (1000 * 1000); } endtime = get_ticks() + tmo; do { ulong now = get_ticks(); diff = endtime - now; } while (diff >= 0); } /* * This function is derived from PowerPC code (read timebase as long long). * On ARM it just returns the timer value. */ unsigned long long get_ticks(void) { ulong now = READ_TIMER(); if (lastdec >= now) { /* normal mode */ timestamp += lastdec - now; } else { /* we have an overflow ... */ timestamp += lastdec + timer_load_val - now; } lastdec = now; return timestamp; } /* * This function is derived from PowerPC code (timebase clock frequency). * On ARM it returns the number of timer ticks per second. */ ulong get_tbclk(void) { ulong tbclk; #if defined(CONFIG_SMDK2400) tbclk = timer_load_val * 100; #elif defined(CONFIG_SBC2410X) || \ defined(CONFIG_SMDK2410) || \ defined(CONFIG_S3C2440) || \ defined(CONFIG_VCMA9) tbclk = CONFIG_SYS_HZ; #else # error "tbclk not configured" #endif return tbclk; } /* * reset the cpu by setting up the watchdog timer and let him time out */ void reset_cpu(ulong ignored) { struct s3c24x0_watchdog *watchdog; watchdog = s3c24x0_get_base_watchdog(); /* Disable watchdog */ writel(0x0000, &watchdog->wtcon); /* Initialize watchdog timer count register */ writel(0x0001, &watchdog->wtcnt); /* Enable watchdog timer; assert reset at timer timeout */ writel(0x0021, &watchdog->wtcon); while (1) /* loop forever and wait for reset to happen */; /*NOTREACHED*/ } #endif /* CONFIG_S3C24X0 */
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/timer.c
C
gpl3
4,775
# # (C) Copyright 2000-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # include $(TOPDIR)/config.mk LIB = $(obj)lib$(SOC).o COBJS-$(CONFIG_USE_IRQ) += interrupts.o COBJS-$(CONFIG_DISPLAY_CPUINFO) += cpu_info.o COBJS-y += speed.o COBJS-y += timer.o COBJS-y += usb.o COBJS-y += usb_ohci.o SRCS := $(SOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS-y)) all: $(obj).depend $(LIB) $(LIB): $(OBJS) $(call cmd_link_o_target, $(OBJS)) ######################################################################### # defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend #########################################################################
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/Makefile
Makefile
gpl3
1,485
/* * (C) Copyright 2006 * DENX Software Engineering <mk@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #if defined(CONFIG_USB_OHCI_NEW) && \ defined(CONFIG_SYS_USB_OHCI_CPU_INIT) && \ defined(CONFIG_S3C24X0) #include <asm/arch/s3c24x0_cpu.h> #include <asm/io.h> int usb_cpu_init(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio(); /* * Set the 48 MHz UPLL clocking. Values are taken from * "PLL value selection guide", 6-23, s3c2400_UM.pdf. */ writel((40 << 12) + (1 << 4) + 2, &clk_power->upllcon); /* 1 = use pads related USB for USB host */ writel(readl(&gpio->misccr) | 0x8, &gpio->misccr); /* * Enable USB host clock. */ writel(readl(&clk_power->clkcon) | (1 << 4), &clk_power->clkcon); return 0; } int usb_cpu_stop(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); /* may not want to do this */ writel(readl(&clk_power->clkcon) & ~(1 << 4), &clk_power->clkcon); return 0; } int usb_cpu_init_fail(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); writel(readl(&clk_power->clkcon) & ~(1 << 4), &clk_power->clkcon); return 0; } #endif /* defined(CONFIG_USB_OHCI_NEW) && \ defined(CONFIG_SYS_USB_OHCI_CPU_INIT) && \ defined(CONFIG_S3C24X0) */
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/usb.c
C
gpl3
2,121
/* * URB OHCI HCD (Host Controller Driver) for USB on the S3C2400. * * (C) Copyright 2003 * Gary Jennejohn, DENX Software Engineering <garyj@denx.de> * * Note: Much of this code has been derived from Linux 2.4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> * (C) Copyright 2000-2002 David Brownell * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * */ /* * IMPORTANT NOTES * 1 - this driver is intended for use with USB Mass Storage Devices * (BBB) ONLY. There is NO support for Interrupt or Isochronous pipes! */ #include <common.h> /* #include <pci.h> no PCI on the S3C24X0 */ #if defined(CONFIG_USB_OHCI) && defined(CONFIG_S3C24X0) #include <asm/arch/s3c24x0_cpu.h> #include <asm/io.h> #include <malloc.h> #include <usb.h> #include "usb_ohci.h" #define OHCI_USE_NPS /* force NoPowerSwitching mode */ #undef OHCI_VERBOSE_DEBUG /* not always helpful */ /* For initializing controller (mask in an HCFS mode too) */ #define OHCI_CONTROL_INIT \ (OHCI_CTRL_CBSR & 0x3) | OHCI_CTRL_IE | OHCI_CTRL_PLE #define min_t(type, x, y) \ ({ type __x = (x); type __y = (y); __x < __y ? __x : __y; }) #undef DEBUG #ifdef DEBUG #define dbg(format, arg...) printf("DEBUG: " format "\n", ## arg) #else #define dbg(format, arg...) do {} while(0) #endif /* DEBUG */ #define err(format, arg...) printf("ERROR: " format "\n", ## arg) #undef SHOW_INFO #ifdef SHOW_INFO #define info(format, arg...) printf("INFO: " format "\n", ## arg) #else #define info(format, arg...) do {} while(0) #endif #define m16_swap(x) swap_16(x) #define m32_swap(x) swap_32(x) /* global struct ohci */ static struct ohci gohci; /* this must be aligned to a 256 byte boundary */ struct ohci_hcca ghcca[1]; /* a pointer to the aligned storage */ struct ohci_hcca *phcca; /* this allocates EDs for all possible endpoints */ struct ohci_device ohci_dev; /* urb_priv */ struct urb_priv urb_priv; /* RHSC flag */ int got_rhsc; /* device which was disconnected */ struct usb_device *devgone; /* flag guarding URB transation */ int urb_finished = 0; /*-------------------------------------------------------------------------*/ /* AMD-756 (D2 rev) reports corrupt register contents in some cases. * The erratum (#4) description is incorrect. AMD's workaround waits * till some bits (mostly reserved) are clear; ok for all revs. */ #define OHCI_QUIRK_AMD756 0xabcd #define read_roothub(hc, register, mask) ({ \ u32 temp = readl (&hc->regs->roothub.register); \ if (hc->flags & OHCI_QUIRK_AMD756) \ while (temp & mask) \ temp = readl (&hc->regs->roothub.register); \ temp; }) static u32 roothub_a(struct ohci *hc) { return read_roothub(hc, a, 0xfc0fe000); } static inline u32 roothub_b(struct ohci *hc) { return readl(&hc->regs->roothub.b); } static inline u32 roothub_status(struct ohci *hc) { return readl(&hc->regs->roothub.status); } static u32 roothub_portstatus(struct ohci *hc, int i) { return read_roothub(hc, portstatus[i], 0xffe0fce0); } /* forward declaration */ static int hc_interrupt(void); static void td_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup, struct urb_priv *urb, int interval); /*-------------------------------------------------------------------------* * URB support functions *-------------------------------------------------------------------------*/ /* free HCD-private data associated with this URB */ static void urb_free_priv(struct urb_priv *urb) { int i; int last; struct td *td; last = urb->length - 1; if (last >= 0) { for (i = 0; i <= last; i++) { td = urb->td[i]; if (td) { td->usb_dev = NULL; urb->td[i] = NULL; } } } } /*-------------------------------------------------------------------------*/ #ifdef DEBUG static int sohci_get_current_frame_number(struct usb_device *dev); /* debug| print the main components of an URB * small: 0) header + data packets 1) just header */ static void pkt_print(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup, char *str, int small) { struct urb_priv *purb = &urb_priv; dbg("%s URB:[%4x] dev:%2d,ep:%2d-%c,type:%s,len:%d/%d stat:%#lx", str, sohci_get_current_frame_number(dev), usb_pipedevice(pipe), usb_pipeendpoint(pipe), usb_pipeout(pipe) ? 'O' : 'I', usb_pipetype(pipe) < 2 ? (usb_pipeint(pipe) ? "INTR" : "ISOC") : (usb_pipecontrol(pipe) ? "CTRL" : "BULK"), purb->actual_length, transfer_len, dev->status); #ifdef OHCI_VERBOSE_DEBUG if (!small) { int i, len; if (usb_pipecontrol(pipe)) { printf(__FILE__ ": cmd(8):"); for (i = 0; i < 8; i++) printf(" %02x", ((__u8 *) setup)[i]); printf("\n"); } if (transfer_len > 0 && buffer) { printf(__FILE__ ": data(%d/%d):", purb->actual_length, transfer_len); len = usb_pipeout(pipe) ? transfer_len : purb->actual_length; for (i = 0; i < 16 && i < len; i++) printf(" %02x", ((__u8 *) buffer)[i]); printf("%s\n", i < len ? "..." : ""); } } #endif } /* just for debugging; prints non-empty branches of the int ed tree inclusive iso eds*/ void ep_print_int_eds(struct ohci *ohci, char *str) { int i, j; __u32 *ed_p; for (i = 0; i < 32; i++) { j = 5; ed_p = &(ohci->hcca->int_table[i]); if (*ed_p == 0) continue; printf(__FILE__ ": %s branch int %2d(%2x):", str, i, i); while (*ed_p != 0 && j--) { struct ed *ed = (struct ed *) m32_swap(ed_p); printf(" ed: %4x;", ed->hwINFO); ed_p = &ed->hwNextED; } printf("\n"); } } static void ohci_dump_intr_mask(char *label, __u32 mask) { dbg("%s: 0x%08x%s%s%s%s%s%s%s%s%s", label, mask, (mask & OHCI_INTR_MIE) ? " MIE" : "", (mask & OHCI_INTR_OC) ? " OC" : "", (mask & OHCI_INTR_RHSC) ? " RHSC" : "", (mask & OHCI_INTR_FNO) ? " FNO" : "", (mask & OHCI_INTR_UE) ? " UE" : "", (mask & OHCI_INTR_RD) ? " RD" : "", (mask & OHCI_INTR_SF) ? " SF" : "", (mask & OHCI_INTR_WDH) ? " WDH" : "", (mask & OHCI_INTR_SO) ? " SO" : ""); } static void maybe_print_eds(char *label, __u32 value) { struct ed *edp = (struct ed *) value; if (value) { dbg("%s %08x", label, value); dbg("%08x", edp->hwINFO); dbg("%08x", edp->hwTailP); dbg("%08x", edp->hwHeadP); dbg("%08x", edp->hwNextED); } } static char *hcfs2string(int state) { switch (state) { case OHCI_USB_RESET: return "reset"; case OHCI_USB_RESUME: return "resume"; case OHCI_USB_OPER: return "operational"; case OHCI_USB_SUSPEND: return "suspend"; } return "?"; } /* dump control and status registers */ static void ohci_dump_status(struct ohci *controller) { struct ohci_regs *regs = controller->regs; __u32 temp; temp = readl(&regs->revision) & 0xff; if (temp != 0x10) dbg("spec %d.%d", (temp >> 4), (temp & 0x0f)); temp = readl(&regs->control); dbg("control: 0x%08x%s%s%s HCFS=%s%s%s%s%s CBSR=%d", temp, (temp & OHCI_CTRL_RWE) ? " RWE" : "", (temp & OHCI_CTRL_RWC) ? " RWC" : "", (temp & OHCI_CTRL_IR) ? " IR" : "", hcfs2string(temp & OHCI_CTRL_HCFS), (temp & OHCI_CTRL_BLE) ? " BLE" : "", (temp & OHCI_CTRL_CLE) ? " CLE" : "", (temp & OHCI_CTRL_IE) ? " IE" : "", (temp & OHCI_CTRL_PLE) ? " PLE" : "", temp & OHCI_CTRL_CBSR); temp = readl(&regs->cmdstatus); dbg("cmdstatus: 0x%08x SOC=%d%s%s%s%s", temp, (temp & OHCI_SOC) >> 16, (temp & OHCI_OCR) ? " OCR" : "", (temp & OHCI_BLF) ? " BLF" : "", (temp & OHCI_CLF) ? " CLF" : "", (temp & OHCI_HCR) ? " HCR" : ""); ohci_dump_intr_mask("intrstatus", readl(&regs->intrstatus)); ohci_dump_intr_mask("intrenable", readl(&regs->intrenable)); maybe_print_eds("ed_periodcurrent", readl(&regs->ed_periodcurrent)); maybe_print_eds("ed_controlhead", readl(&regs->ed_controlhead)); maybe_print_eds("ed_controlcurrent", readl(&regs->ed_controlcurrent)); maybe_print_eds("ed_bulkhead", readl(&regs->ed_bulkhead)); maybe_print_eds("ed_bulkcurrent", readl(&regs->ed_bulkcurrent)); maybe_print_eds("donehead", readl(&regs->donehead)); } static void ohci_dump_roothub(struct ohci *controller, int verbose) { __u32 temp, ndp, i; temp = roothub_a(controller); ndp = (temp & RH_A_NDP); if (verbose) { dbg("roothub.a: %08x POTPGT=%d%s%s%s%s%s NDP=%d", temp, ((temp & RH_A_POTPGT) >> 24) & 0xff, (temp & RH_A_NOCP) ? " NOCP" : "", (temp & RH_A_OCPM) ? " OCPM" : "", (temp & RH_A_DT) ? " DT" : "", (temp & RH_A_NPS) ? " NPS" : "", (temp & RH_A_PSM) ? " PSM" : "", ndp); temp = roothub_b(controller); dbg("roothub.b: %08x PPCM=%04x DR=%04x", temp, (temp & RH_B_PPCM) >> 16, (temp & RH_B_DR) ); temp = roothub_status(controller); dbg("roothub.status: %08x%s%s%s%s%s%s", temp, (temp & RH_HS_CRWE) ? " CRWE" : "", (temp & RH_HS_OCIC) ? " OCIC" : "", (temp & RH_HS_LPSC) ? " LPSC" : "", (temp & RH_HS_DRWE) ? " DRWE" : "", (temp & RH_HS_OCI) ? " OCI" : "", (temp & RH_HS_LPS) ? " LPS" : ""); } for (i = 0; i < ndp; i++) { temp = roothub_portstatus(controller, i); dbg("roothub.portstatus [%d] = 0x%08x%s%s%s%s%s%s%s%s%s%s%s%s", i, temp, (temp & RH_PS_PRSC) ? " PRSC" : "", (temp & RH_PS_OCIC) ? " OCIC" : "", (temp & RH_PS_PSSC) ? " PSSC" : "", (temp & RH_PS_PESC) ? " PESC" : "", (temp & RH_PS_CSC) ? " CSC" : "", (temp & RH_PS_LSDA) ? " LSDA" : "", (temp & RH_PS_PPS) ? " PPS" : "", (temp & RH_PS_PRS) ? " PRS" : "", (temp & RH_PS_POCI) ? " POCI" : "", (temp & RH_PS_PSS) ? " PSS" : "", (temp & RH_PS_PES) ? " PES" : "", (temp & RH_PS_CCS) ? " CCS" : ""); } } static void ohci_dump(struct ohci *controller, int verbose) { dbg("OHCI controller usb-%s state", controller->slot_name); /* dumps some of the state we know about */ ohci_dump_status(controller); if (verbose) ep_print_int_eds(controller, "hcca"); dbg("hcca frame #%04x", controller->hcca->frame_no); ohci_dump_roothub(controller, 1); } #endif /* DEBUG */ /*-------------------------------------------------------------------------* * Interface functions (URB) *-------------------------------------------------------------------------*/ /* get a transfer request */ int sohci_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup, int interval) { struct ohci *ohci; struct ed *ed; struct urb_priv *purb_priv; int i, size = 0; ohci = &gohci; /* when controller's hung, permit only roothub cleanup attempts * such as powering down ports */ if (ohci->disabled) { err("sohci_submit_job: EPIPE"); return -1; } /* if we have an unfinished URB from previous transaction let's * fail and scream as quickly as possible so as not to corrupt * further communication */ if (!urb_finished) { err("sohci_submit_job: URB NOT FINISHED"); return -1; } /* we're about to begin a new transaction here so mark the URB unfinished */ urb_finished = 0; /* every endpoint has a ed, locate and fill it */ ed = ep_add_ed(dev, pipe); if (!ed) { err("sohci_submit_job: ENOMEM"); return -1; } /* for the private part of the URB we need the number of TDs (size) */ switch (usb_pipetype(pipe)) { case PIPE_BULK: /* one TD for every 4096 Byte */ size = (transfer_len - 1) / 4096 + 1; break; case PIPE_CONTROL: /* 1 TD for setup, 1 for ACK and 1 for every 4096 B */ size = (transfer_len == 0) ? 2 : (transfer_len - 1) / 4096 + 3; break; } if (size >= (N_URB_TD - 1)) { err("need %d TDs, only have %d", size, N_URB_TD); return -1; } purb_priv = &urb_priv; purb_priv->pipe = pipe; /* fill the private part of the URB */ purb_priv->length = size; purb_priv->ed = ed; purb_priv->actual_length = 0; /* allocate the TDs */ /* note that td[0] was allocated in ep_add_ed */ for (i = 0; i < size; i++) { purb_priv->td[i] = td_alloc(dev); if (!purb_priv->td[i]) { purb_priv->length = i; urb_free_priv(purb_priv); err("sohci_submit_job: ENOMEM"); return -1; } } if (ed->state == ED_NEW || (ed->state & ED_DEL)) { urb_free_priv(purb_priv); err("sohci_submit_job: EINVAL"); return -1; } /* link the ed into a chain if is not already */ if (ed->state != ED_OPER) ep_link(ohci, ed); /* fill the TDs and link it to the ed */ td_submit_job(dev, pipe, buffer, transfer_len, setup, purb_priv, interval); return 0; } /*-------------------------------------------------------------------------*/ #ifdef DEBUG /* tell us the current USB frame number */ static int sohci_get_current_frame_number(struct usb_device *usb_dev) { struct ohci *ohci = &gohci; return m16_swap(ohci->hcca->frame_no); } #endif /*-------------------------------------------------------------------------* * ED handling functions *-------------------------------------------------------------------------*/ /* link an ed into one of the HC chains */ static int ep_link(struct ohci *ohci, struct ed *edi) { struct ed *ed = edi; ed->state = ED_OPER; switch (ed->type) { case PIPE_CONTROL: ed->hwNextED = 0; if (ohci->ed_controltail == NULL) { writel((u32)ed, &ohci->regs->ed_controlhead); } else { ohci->ed_controltail->hwNextED = (__u32) m32_swap(ed); } ed->ed_prev = ohci->ed_controltail; if (!ohci->ed_controltail && !ohci->ed_rm_list[0] && !ohci->ed_rm_list[1] && !ohci->sleeping) { ohci->hc_control |= OHCI_CTRL_CLE; writel(ohci->hc_control, &ohci->regs->control); } ohci->ed_controltail = edi; break; case PIPE_BULK: ed->hwNextED = 0; if (ohci->ed_bulktail == NULL) { writel((u32)ed, &ohci->regs->ed_bulkhead); } else { ohci->ed_bulktail->hwNextED = (__u32) m32_swap(ed); } ed->ed_prev = ohci->ed_bulktail; if (!ohci->ed_bulktail && !ohci->ed_rm_list[0] && !ohci->ed_rm_list[1] && !ohci->sleeping) { ohci->hc_control |= OHCI_CTRL_BLE; writel(ohci->hc_control, &ohci->regs->control); } ohci->ed_bulktail = edi; break; } return 0; } /*-------------------------------------------------------------------------*/ /* unlink an ed from one of the HC chains. * just the link to the ed is unlinked. * the link from the ed still points to another operational ed or 0 * so the HC can eventually finish the processing of the unlinked ed */ static int ep_unlink(struct ohci *ohci, struct ed *ed) { struct ed *next; ed->hwINFO |= m32_swap(OHCI_ED_SKIP); switch (ed->type) { case PIPE_CONTROL: if (ed->ed_prev == NULL) { if (!ed->hwNextED) { ohci->hc_control &= ~OHCI_CTRL_CLE; writel(ohci->hc_control, &ohci->regs->control); } writel(m32_swap(*((__u32 *) &ed->hwNextED)), &ohci->regs->ed_controlhead); } else { ed->ed_prev->hwNextED = ed->hwNextED; } if (ohci->ed_controltail == ed) { ohci->ed_controltail = ed->ed_prev; } else { next = (struct ed *)m32_swap(*((__u32 *)&ed->hwNextED)); next->ed_prev = ed->ed_prev; } break; case PIPE_BULK: if (ed->ed_prev == NULL) { if (!ed->hwNextED) { ohci->hc_control &= ~OHCI_CTRL_BLE; writel(ohci->hc_control, &ohci->regs->control); } writel(m32_swap(*((__u32 *) &ed->hwNextED)), &ohci->regs->ed_bulkhead); } else { ed->ed_prev->hwNextED = ed->hwNextED; } if (ohci->ed_bulktail == ed) { ohci->ed_bulktail = ed->ed_prev; } else { next = (struct ed *)m32_swap(*((__u32 *)&ed->hwNextED)); next->ed_prev = ed->ed_prev; } break; } ed->state = ED_UNLINK; return 0; } /*-------------------------------------------------------------------------*/ /* add/reinit an endpoint; this should be done once at the usb_set_configuration * command, but the USB stack is a little bit stateless so we do it at every * transaction. If the state of the ed is ED_NEW then a dummy td is added and * the state is changed to ED_UNLINK. In all other cases the state is left * unchanged. The ed info fields are setted anyway even though most of them * should not change */ static struct ed *ep_add_ed(struct usb_device *usb_dev, unsigned long pipe) { struct td *td; struct ed *ed_ret; struct ed *ed; ed = ed_ret = &ohci_dev.ed[(usb_pipeendpoint(pipe) << 1) | (usb_pipecontrol(pipe) ? 0 : usb_pipeout(pipe))]; if ((ed->state & ED_DEL) || (ed->state & ED_URB_DEL)) { err("ep_add_ed: pending delete"); /* pending delete request */ return NULL; } if (ed->state == ED_NEW) { ed->hwINFO = m32_swap(OHCI_ED_SKIP); /* skip ed */ /* dummy td; end of td list for ed */ td = td_alloc(usb_dev); ed->hwTailP = (__u32) m32_swap(td); ed->hwHeadP = ed->hwTailP; ed->state = ED_UNLINK; ed->type = usb_pipetype(pipe); ohci_dev.ed_cnt++; } ed->hwINFO = m32_swap(usb_pipedevice(pipe) | usb_pipeendpoint(pipe) << 7 | (usb_pipeisoc(pipe) ? 0x8000 : 0) | (usb_pipecontrol(pipe) ? 0 : (usb_pipeout(pipe) ? 0x800 : 0x1000)) | usb_pipeslow(pipe) << 13 | usb_maxpacket(usb_dev, pipe) << 16); return ed_ret; } /*-------------------------------------------------------------------------* * TD handling functions *-------------------------------------------------------------------------*/ /* enqueue next TD for this URB (OHCI spec 5.2.8.2) */ static void td_fill(struct ohci *ohci, unsigned int info, void *data, int len, struct usb_device *dev, int index, struct urb_priv *urb_priv) { struct td *td, *td_pt; #ifdef OHCI_FILL_TRACE int i; #endif if (index > urb_priv->length) { err("index > length"); return; } /* use this td as the next dummy */ td_pt = urb_priv->td[index]; td_pt->hwNextTD = 0; /* fill the old dummy TD */ td = urb_priv->td[index] = (struct td *) (m32_swap(urb_priv->ed->hwTailP) & ~0xf); td->ed = urb_priv->ed; td->next_dl_td = NULL; td->index = index; td->data = (__u32) data; #ifdef OHCI_FILL_TRACE if (usb_pipebulk(urb_priv->pipe) && usb_pipeout(urb_priv->pipe)) { for (i = 0; i < len; i++) printf("td->data[%d] %#2x ", i, ((unsigned char *)td->data)[i]); printf("\n"); } #endif if (!len) data = 0; td->hwINFO = (__u32) m32_swap(info); td->hwCBP = (__u32) m32_swap(data); if (data) td->hwBE = (__u32) m32_swap(data + len - 1); else td->hwBE = 0; td->hwNextTD = (__u32) m32_swap(td_pt); /* append to queue */ td->ed->hwTailP = td->hwNextTD; } /*-------------------------------------------------------------------------*/ /* prepare all TDs of a transfer */ static void td_submit_job(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup, struct urb_priv *urb, int interval) { struct ohci *ohci = &gohci; int data_len = transfer_len; void *data; int cnt = 0; __u32 info = 0; unsigned int toggle = 0; /* OHCI handles the DATA-toggles itself, we just use the USB-toggle bits for reseting */ if (usb_gettoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe))) { toggle = TD_T_TOGGLE; } else { toggle = TD_T_DATA0; usb_settoggle(dev, usb_pipeendpoint(pipe), usb_pipeout(pipe), 1); } urb->td_cnt = 0; if (data_len) data = buffer; else data = 0; switch (usb_pipetype(pipe)) { case PIPE_BULK: info = usb_pipeout(pipe) ? TD_CC | TD_DP_OUT : TD_CC | TD_DP_IN; while (data_len > 4096) { td_fill(ohci, info | (cnt ? TD_T_TOGGLE : toggle), data, 4096, dev, cnt, urb); data += 4096; data_len -= 4096; cnt++; } info = usb_pipeout(pipe) ? TD_CC | TD_DP_OUT : TD_CC | TD_R | TD_DP_IN; td_fill(ohci, info | (cnt ? TD_T_TOGGLE : toggle), data, data_len, dev, cnt, urb); cnt++; if (!ohci->sleeping) /* start bulk list */ writel(OHCI_BLF, &ohci->regs->cmdstatus); break; case PIPE_CONTROL: info = TD_CC | TD_DP_SETUP | TD_T_DATA0; td_fill(ohci, info, setup, 8, dev, cnt++, urb); if (data_len > 0) { info = usb_pipeout(pipe) ? TD_CC | TD_R | TD_DP_OUT | TD_T_DATA1 : TD_CC | TD_R | TD_DP_IN | TD_T_DATA1; /* NOTE: mishandles transfers >8K, some >4K */ td_fill(ohci, info, data, data_len, dev, cnt++, urb); } info = usb_pipeout(pipe) ? TD_CC | TD_DP_IN | TD_T_DATA1 : TD_CC | TD_DP_OUT | TD_T_DATA1; td_fill(ohci, info, data, 0, dev, cnt++, urb); if (!ohci->sleeping) /* start Control list */ writel(OHCI_CLF, &ohci->regs->cmdstatus); break; } if (urb->length != cnt) dbg("TD LENGTH %d != CNT %d", urb->length, cnt); } /*-------------------------------------------------------------------------* * Done List handling functions *-------------------------------------------------------------------------*/ /* calculate the transfer length and update the urb */ static void dl_transfer_length(struct td *td) { __u32 tdBE, tdCBP; struct urb_priv *lurb_priv = &urb_priv; tdBE = m32_swap(td->hwBE); tdCBP = m32_swap(td->hwCBP); if (!(usb_pipecontrol(lurb_priv->pipe) && ((td->index == 0) || (td->index == lurb_priv->length - 1)))) { if (tdBE != 0) { if (td->hwCBP == 0) lurb_priv->actual_length += tdBE - td->data + 1; else lurb_priv->actual_length += tdCBP - td->data; } } } /*-------------------------------------------------------------------------*/ /* replies to the request have to be on a FIFO basis so * we reverse the reversed done-list */ static struct td *dl_reverse_done_list(struct ohci *ohci) { __u32 td_list_hc; __u32 tmp; struct td *td_rev = NULL; struct td *td_list = NULL; struct urb_priv *lurb_priv = NULL; td_list_hc = m32_swap(ohci->hcca->done_head) & 0xfffffff0; ohci->hcca->done_head = 0; while (td_list_hc) { td_list = (struct td *) td_list_hc; if (TD_CC_GET(m32_swap(td_list->hwINFO))) { lurb_priv = &urb_priv; dbg(" USB-error/status: %x : %p", TD_CC_GET(m32_swap(td_list->hwINFO)), td_list); if (td_list->ed->hwHeadP & m32_swap(0x1)) { if (lurb_priv && ((td_list->index+1) < lurb_priv->length)) { tmp = lurb_priv->length - 1; td_list->ed->hwHeadP = (lurb_priv->td[tmp]->hwNextTD & m32_swap(0xfffffff0)) | (td_list->ed->hwHeadP & m32_swap(0x2)); lurb_priv->td_cnt += lurb_priv->length - td_list->index - 1; } else td_list->ed->hwHeadP &= m32_swap(0xfffffff2); } } td_list->next_dl_td = td_rev; td_rev = td_list; td_list_hc = m32_swap(td_list->hwNextTD) & 0xfffffff0; } return td_list; } /*-------------------------------------------------------------------------*/ /* td done list */ static int dl_done_list(struct ohci *ohci, struct td *td_list) { struct td *td_list_next = NULL; struct ed *ed; int cc = 0; int stat = 0; /* urb_t *urb; */ struct urb_priv *lurb_priv; __u32 tdINFO, edHeadP, edTailP; while (td_list) { td_list_next = td_list->next_dl_td; lurb_priv = &urb_priv; tdINFO = m32_swap(td_list->hwINFO); ed = td_list->ed; dl_transfer_length(td_list); /* error code of transfer */ cc = TD_CC_GET(tdINFO); if (cc != 0) { dbg("ConditionCode %#x", cc); stat = cc_to_error[cc]; } /* see if this done list makes for all TD's of current URB, * and mark the URB finished if so */ if (++(lurb_priv->td_cnt) == lurb_priv->length) { if ((ed->state & (ED_OPER | ED_UNLINK))) urb_finished = 1; else dbg("dl_done_list: strange.., ED state %x, " "ed->state\n"); } else dbg("dl_done_list: processing TD %x, len %x\n", lurb_priv->td_cnt, lurb_priv->length); if (ed->state != ED_NEW) { edHeadP = m32_swap(ed->hwHeadP) & 0xfffffff0; edTailP = m32_swap(ed->hwTailP); /* unlink eds if they are not busy */ if ((edHeadP == edTailP) && (ed->state == ED_OPER)) ep_unlink(ohci, ed); } td_list = td_list_next; } return stat; } /*-------------------------------------------------------------------------* * Virtual Root Hub *-------------------------------------------------------------------------*/ /* Device descriptor */ static __u8 root_hub_dev_des[] = { 0x12, /* __u8 bLength; */ 0x01, /* __u8 bDescriptorType; Device */ 0x10, /* __u16 bcdUSB; v1.1 */ 0x01, 0x09, /* __u8 bDeviceClass; HUB_CLASSCODE */ 0x00, /* __u8 bDeviceSubClass; */ 0x00, /* __u8 bDeviceProtocol; */ 0x08, /* __u8 bMaxPacketSize0; 8 Bytes */ 0x00, /* __u16 idVendor; */ 0x00, 0x00, /* __u16 idProduct; */ 0x00, 0x00, /* __u16 bcdDevice; */ 0x00, 0x00, /* __u8 iManufacturer; */ 0x01, /* __u8 iProduct; */ 0x00, /* __u8 iSerialNumber; */ 0x01 /* __u8 bNumConfigurations; */ }; /* Configuration descriptor */ static __u8 root_hub_config_des[] = { 0x09, /* __u8 bLength; */ 0x02, /* __u8 bDescriptorType; Configuration */ 0x19, /* __u16 wTotalLength; */ 0x00, 0x01, /* __u8 bNumInterfaces; */ 0x01, /* __u8 bConfigurationValue; */ 0x00, /* __u8 iConfiguration; */ 0x40, /* __u8 bmAttributes; Bit 7: Bus-powered, 6: Self-powered, 5 Remote-wakwup, 4..0: resvd */ 0x00, /* __u8 MaxPower; */ /* interface */ 0x09, /* __u8 if_bLength; */ 0x04, /* __u8 if_bDescriptorType; Interface */ 0x00, /* __u8 if_bInterfaceNumber; */ 0x00, /* __u8 if_bAlternateSetting; */ 0x01, /* __u8 if_bNumEndpoints; */ 0x09, /* __u8 if_bInterfaceClass; HUB_CLASSCODE */ 0x00, /* __u8 if_bInterfaceSubClass; */ 0x00, /* __u8 if_bInterfaceProtocol; */ 0x00, /* __u8 if_iInterface; */ /* endpoint */ 0x07, /* __u8 ep_bLength; */ 0x05, /* __u8 ep_bDescriptorType; Endpoint */ 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x03, /* __u8 ep_bmAttributes; Interrupt */ 0x02, /* __u16 ep_wMaxPacketSize; ((MAX_ROOT_PORTS + 1) / 8 */ 0x00, 0xff /* __u8 ep_bInterval; 255 ms */ }; static unsigned char root_hub_str_index0[] = { 0x04, /* __u8 bLength; */ 0x03, /* __u8 bDescriptorType; String-descriptor */ 0x09, /* __u8 lang ID */ 0x04, /* __u8 lang ID */ }; static unsigned char root_hub_str_index1[] = { 28, /* __u8 bLength; */ 0x03, /* __u8 bDescriptorType; String-descriptor */ 'O', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'H', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'C', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'I', /* __u8 Unicode */ 0, /* __u8 Unicode */ ' ', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'R', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'o', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'o', /* __u8 Unicode */ 0, /* __u8 Unicode */ 't', /* __u8 Unicode */ 0, /* __u8 Unicode */ ' ', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'H', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'u', /* __u8 Unicode */ 0, /* __u8 Unicode */ 'b', /* __u8 Unicode */ 0, /* __u8 Unicode */ }; /* Hub class-specific descriptor is constructed dynamically */ /*-------------------------------------------------------------------------*/ #define OK(x) len = (x); break #ifdef DEBUG #define WR_RH_STAT(x) \ { \ info("WR:status %#8x", (x)); \ writel((x), &gohci.regs->roothub.status); \ } #define WR_RH_PORTSTAT(x) \ { \ info("WR:portstatus[%d] %#8x", wIndex-1, (x)); \ writel((x), &gohci.regs->roothub.portstatus[wIndex-1]); \ } #else #define WR_RH_STAT(x) \ writel((x), &gohci.regs->roothub.status) #define WR_RH_PORTSTAT(x)\ writel((x), &gohci.regs->roothub.portstatus[wIndex-1]) #endif #define RD_RH_STAT roothub_status(&gohci) #define RD_RH_PORTSTAT roothub_portstatus(&gohci, wIndex-1) /* request to virtual root hub */ int rh_check_port_status(struct ohci *controller) { __u32 temp, ndp, i; int res; res = -1; temp = roothub_a(controller); ndp = (temp & RH_A_NDP); for (i = 0; i < ndp; i++) { temp = roothub_portstatus(controller, i); /* check for a device disconnect */ if (((temp & (RH_PS_PESC | RH_PS_CSC)) == (RH_PS_PESC | RH_PS_CSC)) && ((temp & RH_PS_CCS) == 0)) { res = i; break; } } return res; } static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *cmd) { void *data = buffer; int leni = transfer_len; int len = 0; int stat = 0; union { __u32 word[4]; __u16 hword[8]; __u8 byte[16]; } datab; __u8 *data_buf = datab.byte; __u16 bmRType_bReq; __u16 wValue; __u16 wIndex; __u16 wLength; #ifdef DEBUG urb_priv.actual_length = 0; pkt_print(dev, pipe, buffer, transfer_len, cmd, "SUB(rh)", usb_pipein(pipe)); #else wait_ms(1); #endif if (usb_pipeint(pipe)) { info("Root-Hub submit IRQ: NOT implemented"); return 0; } bmRType_bReq = cmd->requesttype | (cmd->request << 8); wValue = m16_swap(cmd->value); wIndex = m16_swap(cmd->index); wLength = m16_swap(cmd->length); info("Root-Hub: adr: %2x cmd(%1x): %08x %04x %04x %04x", dev->devnum, 8, bmRType_bReq, wValue, wIndex, wLength); switch (bmRType_bReq) { /* Request Destination: without flags: Device, RH_INTERFACE: interface, RH_ENDPOINT: endpoint, RH_CLASS means HUB here, RH_OTHER | RH_CLASS almost ever means HUB_PORT here */ case RH_GET_STATUS: datab.hword[0] = m16_swap(1); OK(2); case RH_GET_STATUS | RH_INTERFACE: datab.hword[0] = m16_swap(0); OK(2); case RH_GET_STATUS | RH_ENDPOINT: datab.hword[0] = m16_swap(0); OK(2); case RH_GET_STATUS | RH_CLASS: datab.word[0] = m32_swap(RD_RH_STAT & ~(RH_HS_CRWE | RH_HS_DRWE)); OK(4); case RH_GET_STATUS | RH_OTHER | RH_CLASS: datab.word[0] = m32_swap(RD_RH_PORTSTAT); OK(4); case RH_CLEAR_FEATURE | RH_ENDPOINT: switch (wValue) { case (RH_ENDPOINT_STALL): OK(0); } break; case RH_CLEAR_FEATURE | RH_CLASS: switch (wValue) { case RH_C_HUB_LOCAL_POWER: OK(0); case (RH_C_HUB_OVER_CURRENT): WR_RH_STAT(RH_HS_OCIC); OK(0); } break; case RH_CLEAR_FEATURE | RH_OTHER | RH_CLASS: switch (wValue) { case (RH_PORT_ENABLE): WR_RH_PORTSTAT(RH_PS_CCS); OK(0); case (RH_PORT_SUSPEND): WR_RH_PORTSTAT(RH_PS_POCI); OK(0); case (RH_PORT_POWER): WR_RH_PORTSTAT(RH_PS_LSDA); OK(0); case (RH_C_PORT_CONNECTION): WR_RH_PORTSTAT(RH_PS_CSC); OK(0); case (RH_C_PORT_ENABLE): WR_RH_PORTSTAT(RH_PS_PESC); OK(0); case (RH_C_PORT_SUSPEND): WR_RH_PORTSTAT(RH_PS_PSSC); OK(0); case (RH_C_PORT_OVER_CURRENT): WR_RH_PORTSTAT(RH_PS_OCIC); OK(0); case (RH_C_PORT_RESET): WR_RH_PORTSTAT(RH_PS_PRSC); OK(0); } break; case RH_SET_FEATURE | RH_OTHER | RH_CLASS: switch (wValue) { case (RH_PORT_SUSPEND): WR_RH_PORTSTAT(RH_PS_PSS); OK(0); case (RH_PORT_RESET): /* BUG IN HUP CODE ******** */ if (RD_RH_PORTSTAT & RH_PS_CCS) WR_RH_PORTSTAT(RH_PS_PRS); OK(0); case (RH_PORT_POWER): WR_RH_PORTSTAT(RH_PS_PPS); OK(0); case (RH_PORT_ENABLE): /* BUG IN HUP CODE ******** */ if (RD_RH_PORTSTAT & RH_PS_CCS) WR_RH_PORTSTAT(RH_PS_PES); OK(0); } break; case RH_SET_ADDRESS: gohci.rh.devnum = wValue; OK(0); case RH_GET_DESCRIPTOR: switch ((wValue & 0xff00) >> 8) { case (0x01): /* device descriptor */ len = min_t(unsigned int, leni, min_t(unsigned int, sizeof(root_hub_dev_des), wLength)); data_buf = root_hub_dev_des; OK(len); case (0x02): /* configuration descriptor */ len = min_t(unsigned int, leni, min_t(unsigned int, sizeof(root_hub_config_des), wLength)); data_buf = root_hub_config_des; OK(len); case (0x03): /* string descriptors */ if (wValue == 0x0300) { len = min_t(unsigned int, leni, min_t(unsigned int, sizeof(root_hub_str_index0), wLength)); data_buf = root_hub_str_index0; OK(len); } if (wValue == 0x0301) { len = min_t(unsigned int, leni, min_t(unsigned int, sizeof(root_hub_str_index1), wLength)); data_buf = root_hub_str_index1; OK(len); } default: stat = USB_ST_STALLED; } break; case RH_GET_DESCRIPTOR | RH_CLASS: { __u32 temp = roothub_a(&gohci); data_buf[0] = 9; /* min length; */ data_buf[1] = 0x29; data_buf[2] = temp & RH_A_NDP; data_buf[3] = 0; if (temp & RH_A_PSM) /* per-port power switching? */ data_buf[3] |= 0x1; if (temp & RH_A_NOCP) /* no overcurrent reporting? */ data_buf[3] |= 0x10; else if (temp & RH_A_OCPM) /* per-port overcurrent reporting? */ data_buf[3] |= 0x8; /* corresponds to data_buf[4-7] */ datab.word[1] = 0; data_buf[5] = (temp & RH_A_POTPGT) >> 24; temp = roothub_b(&gohci); data_buf[7] = temp & RH_B_DR; if (data_buf[2] < 7) { data_buf[8] = 0xff; } else { data_buf[0] += 2; data_buf[8] = (temp & RH_B_DR) >> 8; data_buf[10] = data_buf[9] = 0xff; } len = min_t(unsigned int, leni, min_t(unsigned int, data_buf[0], wLength)); OK(len); } case RH_GET_CONFIGURATION: *(__u8 *) data_buf = 0x01; OK(1); case RH_SET_CONFIGURATION: WR_RH_STAT(0x10000); OK(0); default: dbg("unsupported root hub command"); stat = USB_ST_STALLED; } #ifdef DEBUG ohci_dump_roothub(&gohci, 1); #else wait_ms(1); #endif len = min_t(int, len, leni); if (data != data_buf) memcpy(data, data_buf, len); dev->act_len = len; dev->status = stat; #ifdef DEBUG if (transfer_len) urb_priv.actual_length = transfer_len; pkt_print(dev, pipe, buffer, transfer_len, cmd, "RET(rh)", 0 /*usb_pipein(pipe) */); #else wait_ms(1); #endif return stat; } /*-------------------------------------------------------------------------*/ /* common code for handling submit messages - used for all but root hub */ /* accesses. */ int submit_common_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup, int interval) { int stat = 0; int maxsize = usb_maxpacket(dev, pipe); int timeout; /* device pulled? Shortcut the action. */ if (devgone == dev) { dev->status = USB_ST_CRC_ERR; return 0; } #ifdef DEBUG urb_priv.actual_length = 0; pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe)); #else wait_ms(1); #endif if (!maxsize) { err("submit_common_message: pipesize for pipe %lx is zero", pipe); return -1; } if (sohci_submit_job(dev, pipe, buffer, transfer_len, setup, interval) < 0) { err("sohci_submit_job failed"); return -1; } wait_ms(10); /* ohci_dump_status(&gohci); */ /* allow more time for a BULK device to react - some are slow */ #define BULK_TO 5000 /* timeout in milliseconds */ if (usb_pipebulk(pipe)) timeout = BULK_TO; else timeout = 100; /* wait for it to complete */ for (;;) { /* check whether the controller is done */ stat = hc_interrupt(); if (stat < 0) { stat = USB_ST_CRC_ERR; break; } /* NOTE: since we are not interrupt driven in U-Boot and always * handle only one URB at a time, we cannot assume the * transaction finished on the first successful return from * hc_interrupt().. unless the flag for current URB is set, * meaning that all TD's to/from device got actually * transferred and processed. If the current URB is not * finished we need to re-iterate this loop so as * hc_interrupt() gets called again as there needs to be some * more TD's to process still */ if ((stat >= 0) && (stat != 0xff) && (urb_finished)) { /* 0xff is returned for an SF-interrupt */ break; } if (--timeout) { wait_ms(1); if (!urb_finished) dbg("\%"); } else { err("CTL:TIMEOUT "); dbg("submit_common_msg: TO status %x\n", stat); stat = USB_ST_CRC_ERR; urb_finished = 1; break; } } #if 0 /* we got an Root Hub Status Change interrupt */ if (got_rhsc) { #ifdef DEBUG ohci_dump_roothub(&gohci, 1); #endif got_rhsc = 0; /* abuse timeout */ timeout = rh_check_port_status(&gohci); if (timeout >= 0) { #if 0 /* this does nothing useful, but leave it here in case that changes */ /* the called routine adds 1 to the passed value */ usb_hub_port_connect_change(gohci.rh.dev, timeout - 1); #endif /* * XXX * This is potentially dangerous because it assumes * that only one device is ever plugged in! */ devgone = dev; } } #endif dev->status = stat; dev->act_len = transfer_len; #ifdef DEBUG pkt_print(dev, pipe, buffer, transfer_len, setup, "RET(ctlr)", usb_pipein(pipe)); #else wait_ms(1); #endif /* free TDs in urb_priv */ urb_free_priv(&urb_priv); return 0; } /* submit routines called from usb.c */ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len) { info("submit_bulk_msg"); return submit_common_msg(dev, pipe, buffer, transfer_len, NULL, 0); } int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup) { int maxsize = usb_maxpacket(dev, pipe); info("submit_control_msg"); #ifdef DEBUG urb_priv.actual_length = 0; pkt_print(dev, pipe, buffer, transfer_len, setup, "SUB", usb_pipein(pipe)); #else wait_ms(1); #endif if (!maxsize) { err("submit_control_message: pipesize for pipe %lx is zero", pipe); return -1; } if (((pipe >> 8) & 0x7f) == gohci.rh.devnum) { gohci.rh.dev = dev; /* root hub - redirect */ return ohci_submit_rh_msg(dev, pipe, buffer, transfer_len, setup); } return submit_common_msg(dev, pipe, buffer, transfer_len, setup, 0); } int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, int interval) { info("submit_int_msg"); return -1; } /*-------------------------------------------------------------------------* * HC functions *-------------------------------------------------------------------------*/ /* reset the HC and BUS */ static int hc_reset(struct ohci *ohci) { int timeout = 30; int smm_timeout = 50; /* 0,5 sec */ if (readl(&ohci->regs->control) & OHCI_CTRL_IR) { /* SMM owns the HC - request ownership */ writel(OHCI_OCR, &ohci->regs->cmdstatus); info("USB HC TakeOver from SMM"); while (readl(&ohci->regs->control) & OHCI_CTRL_IR) { wait_ms(10); if (--smm_timeout == 0) { err("USB HC TakeOver failed!"); return -1; } } } /* Disable HC interrupts */ writel(OHCI_INTR_MIE, &ohci->regs->intrdisable); dbg("USB HC reset_hc usb-%s: ctrl = 0x%X ;", ohci->slot_name, readl(&ohci->regs->control)); /* Reset USB (needed by some controllers) */ writel(0, &ohci->regs->control); /* HC Reset requires max 10 us delay */ writel(OHCI_HCR, &ohci->regs->cmdstatus); while ((readl(&ohci->regs->cmdstatus) & OHCI_HCR) != 0) { if (--timeout == 0) { err("USB HC reset timed out!"); return -1; } udelay(1); } return 0; } /*-------------------------------------------------------------------------*/ /* Start an OHCI controller, set the BUS operational * enable interrupts * connect the virtual root hub */ static int hc_start(struct ohci *ohci) { __u32 mask; unsigned int fminterval; ohci->disabled = 1; /* Tell the controller where the control and bulk lists are * The lists are empty now. */ writel(0, &ohci->regs->ed_controlhead); writel(0, &ohci->regs->ed_bulkhead); /* a reset clears this */ writel((__u32) ohci->hcca, &ohci->regs->hcca); fminterval = 0x2edf; writel((fminterval * 9) / 10, &ohci->regs->periodicstart); fminterval |= ((((fminterval - 210) * 6) / 7) << 16); writel(fminterval, &ohci->regs->fminterval); writel(0x628, &ohci->regs->lsthresh); /* start controller operations */ ohci->hc_control = OHCI_CONTROL_INIT | OHCI_USB_OPER; ohci->disabled = 0; writel(ohci->hc_control, &ohci->regs->control); /* disable all interrupts */ mask = (OHCI_INTR_SO | OHCI_INTR_WDH | OHCI_INTR_SF | OHCI_INTR_RD | OHCI_INTR_UE | OHCI_INTR_FNO | OHCI_INTR_RHSC | OHCI_INTR_OC | OHCI_INTR_MIE); writel(mask, &ohci->regs->intrdisable); /* clear all interrupts */ mask &= ~OHCI_INTR_MIE; writel(mask, &ohci->regs->intrstatus); /* Choose the interrupts we care about now - but w/o MIE */ mask = OHCI_INTR_RHSC | OHCI_INTR_UE | OHCI_INTR_WDH | OHCI_INTR_SO; writel(mask, &ohci->regs->intrenable); #ifdef OHCI_USE_NPS /* required for AMD-756 and some Mac platforms */ writel((roothub_a(ohci) | RH_A_NPS) & ~RH_A_PSM, &ohci->regs->roothub.a); writel(RH_HS_LPSC, &ohci->regs->roothub.status); #endif /* OHCI_USE_NPS */ /* POTPGT delay is bits 24-31, in 2 ms units. */ mdelay((roothub_a(ohci) >> 23) & 0x1fe); /* connect the virtual root hub */ ohci->rh.devnum = 0; return 0; } /*-------------------------------------------------------------------------*/ /* an interrupt happens */ static int hc_interrupt(void) { struct ohci *ohci = &gohci; struct ohci_regs *regs = ohci->regs; int ints; int stat = -1; if ((ohci->hcca->done_head != 0) && !(m32_swap(ohci->hcca->done_head) & 0x01)) { ints = OHCI_INTR_WDH; } else { ints = readl(&regs->intrstatus); if (ints == ~(u32) 0) { ohci->disabled++; err("%s device removed!", ohci->slot_name); return -1; } ints &= readl(&regs->intrenable); if (ints == 0) { dbg("hc_interrupt: returning..\n"); return 0xff; } } /* dbg("Interrupt: %x frame: %x", ints, le16_to_cpu(ohci->hcca->frame_no)); */ if (ints & OHCI_INTR_RHSC) { got_rhsc = 1; stat = 0xff; } if (ints & OHCI_INTR_UE) { ohci->disabled++; err("OHCI Unrecoverable Error, controller usb-%s disabled", ohci->slot_name); /* e.g. due to PCI Master/Target Abort */ #ifdef DEBUG ohci_dump(ohci, 1); #else wait_ms(1); #endif /* FIXME: be optimistic, hope that bug won't repeat often. */ /* Make some non-interrupt context restart the controller. */ /* Count and limit the retries though; either hardware or */ /* software errors can go forever... */ hc_reset(ohci); return -1; } if (ints & OHCI_INTR_WDH) { wait_ms(1); writel(OHCI_INTR_WDH, &regs->intrdisable); stat = dl_done_list(&gohci, dl_reverse_done_list(&gohci)); writel(OHCI_INTR_WDH, &regs->intrenable); } if (ints & OHCI_INTR_SO) { dbg("USB Schedule overrun\n"); writel(OHCI_INTR_SO, &regs->intrenable); stat = -1; } /* FIXME: this assumes SOF (1/ms) interrupts don't get lost... */ if (ints & OHCI_INTR_SF) { unsigned int frame = m16_swap(ohci->hcca->frame_no) & 1; wait_ms(1); writel(OHCI_INTR_SF, &regs->intrdisable); if (ohci->ed_rm_list[frame] != NULL) writel(OHCI_INTR_SF, &regs->intrenable); stat = 0xff; } writel(ints, &regs->intrstatus); return stat; } /*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/ /* De-allocate all resources.. */ static void hc_release_ohci(struct ohci *ohci) { dbg("USB HC release ohci usb-%s", ohci->slot_name); if (!ohci->disabled) hc_reset(ohci); } /*-------------------------------------------------------------------------*/ /* * low level initalisation routine, called from usb.c */ static char ohci_inited = 0; int usb_lowlevel_init(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); struct s3c24x0_gpio *gpio = s3c24x0_get_base_gpio(); /* * Set the 48 MHz UPLL clocking. Values are taken from * "PLL value selection guide", 6-23, s3c2400_UM.pdf. */ clk_power->upllcon = ((40 << 12) + (1 << 4) + 2); gpio->misccr |= 0x8; /* 1 = use pads related USB for USB host */ /* * Enable USB host clock. */ clk_power->clkcon |= (1 << 4); memset(&gohci, 0, sizeof(struct ohci)); memset(&urb_priv, 0, sizeof(struct urb_priv)); /* align the storage */ if ((__u32) &ghcca[0] & 0xff) { err("HCCA not aligned!!"); return -1; } phcca = &ghcca[0]; info("aligned ghcca %p", phcca); memset(&ohci_dev, 0, sizeof(struct ohci_device)); if ((__u32) &ohci_dev.ed[0] & 0x7) { err("EDs not aligned!!"); return -1; } memset(gtd, 0, sizeof(struct td) * (NUM_TD + 1)); if ((__u32) gtd & 0x7) { err("TDs not aligned!!"); return -1; } ptd = gtd; gohci.hcca = phcca; memset(phcca, 0, sizeof(struct ohci_hcca)); gohci.disabled = 1; gohci.sleeping = 0; gohci.irq = -1; gohci.regs = (struct ohci_regs *)S3C24X0_USB_HOST_BASE; gohci.flags = 0; gohci.slot_name = "s3c2400"; if (hc_reset(&gohci) < 0) { hc_release_ohci(&gohci); /* Initialization failed */ clk_power->clkcon &= ~(1 << 4); return -1; } /* FIXME this is a second HC reset; why?? */ gohci.hc_control = OHCI_USB_RESET; writel(gohci.hc_control, &gohci.regs->control); wait_ms(10); if (hc_start(&gohci) < 0) { err("can't start usb-%s", gohci.slot_name); hc_release_ohci(&gohci); /* Initialization failed */ clk_power->clkcon &= ~(1 << 4); return -1; } #ifdef DEBUG ohci_dump(&gohci, 1); #else wait_ms(1); #endif ohci_inited = 1; urb_finished = 1; return 0; } int usb_lowlevel_stop(void) { struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power(); /* this gets called really early - before the controller has */ /* even been initialized! */ if (!ohci_inited) return 0; /* TODO release any interrupts, etc. */ /* call hc_release_ohci() here ? */ hc_reset(&gohci); /* may not want to do this */ clk_power->clkcon &= ~(1 << 4); return 0; } #endif /* defined(CONFIG_USB_OHCI) && defined(CONFIG_S3C24X0) */
1001-study-uboot
arch/arm/cpu/arm920t/s3c24x0/usb_ohci.c
C
gpl3
45,868
/* * (C) Copyright 2010 * Texas Instruments, <www.ti.com> * Aneesh V <aneesh@ti.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef _UTILS_H_ #define _UTILS_H_ static inline s32 log_2_n_round_up(u32 n) { s32 log2n = -1; u32 temp = n; while (temp) { log2n++; temp >>= 1; } if (n & (n - 1)) return log2n + 1; /* not power of 2 - round up */ else return log2n; /* power of 2 */ } static inline s32 log_2_n_round_down(u32 n) { s32 log2n = -1; u32 temp = n; while (temp) { log2n++; temp >>= 1; } return log2n; } #endif
1001-study-uboot
arch/arm/include/asm/utils.h
C
gpl3
1,306
#include <asm-generic/errno.h>
1001-study-uboot
arch/arm/include/asm/errno.h
C
gpl3
31
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef _U_BOOT_ARM_H_ #define _U_BOOT_ARM_H_ 1 /* for the following variables, see start.S */ extern ulong _bss_start_ofs; /* BSS start relative to _start */ extern ulong _bss_end_ofs; /* BSS end relative to _start */ extern ulong _end_ofs; /* end of image relative to _start */ extern ulong IRQ_STACK_START; /* top of IRQ stack */ extern ulong FIQ_STACK_START; /* top of FIQ stack */ extern ulong _TEXT_BASE; /* code start */ extern ulong _datarel_start_ofs; extern ulong _datarelrolocal_start_ofs; extern ulong _datarellocal_start_ofs; extern ulong _datarelro_start_ofs; extern ulong IRQ_STACK_START_IN; /* 8 bytes in IRQ stack */ /* cpu/.../cpu.c */ int cpu_init(void); int cleanup_before_linux(void); /* Set up ARMv7 MMU, caches and TLBs */ void cpu_init_cp15(void); /* cpu/.../arch/cpu.c */ int arch_cpu_init(void); int arch_misc_init(void); /* board/.../... */ int board_init(void); int dram_init (void); void dram_init_banksize (void); void setup_serial_tag (struct tag **params); void setup_revision_tag (struct tag **params); /* cpu/.../interrupt.c */ int arch_interrupt_init (void); void reset_timer_masked (void); ulong get_timer_masked (void); void udelay_masked (unsigned long usec); #endif /* _U_BOOT_ARM_H_ */
1001-study-uboot
arch/arm/include/asm/u-boot-arm.h
C
gpl3
2,258
/* * linux/include/asm-arm/memory.h * * Copyright (C) 2000-2002 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Note: this file should not be included by non-asm/.h files */ #ifndef __ASM_ARM_MEMORY_H #define __ASM_ARM_MEMORY_H #if 0 /* XXX###XXX */ #include <linux/config.h> #include <asm/arch/memory.h> /* * PFNs are used to describe any physical page; this means * PFN 0 == physical address 0. * * This is the PFN of the first RAM page in the kernel * direct-mapped view. We assume this is the first page * of RAM in the mem_map as well. */ #define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) /* * These are *only* valid on the kernel direct mapped RAM memory. */ static inline unsigned long virt_to_phys(void *x) { return __virt_to_phys((unsigned long)(x)); } static inline void *phys_to_virt(unsigned long x) { return (void *)(__phys_to_virt((unsigned long)(x))); } #define __pa(x) __virt_to_phys((unsigned long)(x)) #define __va(x) ((void *)__phys_to_virt((unsigned long)(x))) /* * Virtual <-> DMA view memory address translations * Again, these are *only* valid on the kernel direct mapped RAM * memory. Use of these is *depreciated*. */ #define virt_to_bus(x) (__virt_to_bus((unsigned long)(x))) #define bus_to_virt(x) ((void *)(__bus_to_virt((unsigned long)(x)))) /* * Conversion between a struct page and a physical address. * * Note: when converting an unknown physical address to a * struct page, the resulting pointer must be validated * using VALID_PAGE(). It must return an invalid struct page * for any physical address not corresponding to a system * RAM address. * * page_to_pfn(page) convert a struct page * to a PFN number * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * * pfn_valid(pfn) indicates whether a PFN number is valid * * virt_to_page(k) convert a _valid_ virtual address to struct page * * virt_addr_valid(k) indicates whether a virtual address is valid */ #ifndef CONFIG_DISCONTIGMEM #define page_to_pfn(page) (((page) - mem_map) + PHYS_PFN_OFFSET) #define pfn_to_page(pfn) ((mem_map + (pfn)) - PHYS_PFN_OFFSET) #define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr)) #define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)) #define virt_addr_valid(kaddr) ((kaddr) >= PAGE_OFFSET && (kaddr) < (unsigned long)high_memory) #define PHYS_TO_NID(addr) (0) #define VALID_PAGE(page) ((page - mem_map) < max_mapnr) #else /* * This is more complex. We have a set of mem_map arrays spread * around in memory. */ #define page_to_pfn(page) \ (((page) - page_zone(page)->zone_mem_map) \ + (page_zone(page)->zone_start_paddr >> PAGE_SHIFT)) #define pfn_to_page(pfn) \ (PFN_TO_MAPBASE(pfn) + LOCAL_MAP_NR((pfn) << PAGE_SHIFT)) #define pfn_valid(pfn) \ ({ \ unsigned int node = PFN_TO_NID(pfn); \ struct pglist_data *nd = NODE_DATA(node); \ ((node < NR_NODES) && \ ((pfn - (nd->node_start_paddr >> PAGE_SHIFT)) < nd->node_size));\ }) #define virt_to_page(kaddr) \ (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) #define virt_addr_valid(kaddr) (KVADDR_TO_NID(kaddr) < NR_NODES) /* * Common discontigmem stuff. * PHYS_TO_NID is used by the ARM kernel/setup.c */ #define PHYS_TO_NID(addr) PFN_TO_NID((addr) >> PAGE_SHIFT) /* * 2.4 compatibility * * VALID_PAGE returns a non-zero value if given page pointer is valid. * This assumes all node's mem_maps are stored within the node they * refer to. This is actually inherently buggy. */ #define VALID_PAGE(page) \ ({ unsigned int node = KVADDR_TO_NID(page); \ ((node < NR_NODES) && \ ((unsigned)((page) - NODE_MEM_MAP(node)) < NODE_DATA(node)->node_size)); \ }) #endif /* * We should really eliminate virt_to_bus() here - it's depreciated. */ #define page_to_bus(page) (virt_to_bus(page_address(page))) #endif /* XXX###XXX */ #endif /* __ASM_ARM_MEMORY_H */
1001-study-uboot
arch/arm/include/asm/memory.h
C
gpl3
4,091
#ifndef __ASM_ARM_STRING_H #define __ASM_ARM_STRING_H #include <config.h> /* * We don't do inline string functions, since the * optimised inline asm versions are not small. */ #undef __HAVE_ARCH_STRRCHR extern char * strrchr(const char * s, int c); #undef __HAVE_ARCH_STRCHR extern char * strchr(const char * s, int c); #ifdef CONFIG_USE_ARCH_MEMCPY #define __HAVE_ARCH_MEMCPY #endif extern void * memcpy(void *, const void *, __kernel_size_t); #undef __HAVE_ARCH_MEMMOVE extern void * memmove(void *, const void *, __kernel_size_t); #undef __HAVE_ARCH_MEMCHR extern void * memchr(const void *, int, __kernel_size_t); #undef __HAVE_ARCH_MEMZERO #ifdef CONFIG_USE_ARCH_MEMSET #define __HAVE_ARCH_MEMSET #endif extern void * memset(void *, int, __kernel_size_t); #if 0 extern void __memzero(void *ptr, __kernel_size_t n); #define memset(p,v,n) \ ({ \ if ((n) != 0) { \ if (__builtin_constant_p((v)) && (v) == 0) \ __memzero((p),(n)); \ else \ memset((p),(v),(n)); \ } \ (p); \ }) #define memzero(p,n) ({ if ((n) != 0) __memzero((p),(n)); (p); }) #else extern void memzero(void *ptr, __kernel_size_t n); #endif #endif
1001-study-uboot
arch/arm/include/asm/string.h
C
gpl3
1,191
/* * linux/include/asm-arm/arch-s3c2400/memory.h by garyj@denx.de * based on * linux/include/asm-arm/arch-sa1100/memory.h * * Copyright (c) 1999 Nicolas Pitre <nico@visuaide.com> */ #ifndef __ASM_ARCH_MEMORY_H #define __ASM_ARCH_MEMORY_H /* * Task size: 3GB */ #define TASK_SIZE (0xc0000000UL) #define TASK_SIZE_26 (0x04000000UL) /* * This decides where the kernel will search for a free chunk of vm * space during mmap's. */ #define TASK_UNMAPPED_BASE (TASK_SIZE / 3) /* * Page offset: 3GB */ #define PAGE_OFFSET (0xc0000000UL) /* * Physical DRAM offset is 0x0c000000 on the S3C2400 */ #define PHYS_OFFSET (0x0c000000UL) #include <linux/config.h> /* Modified for S3C2400, by chc, 20010509 */ #define RAM_IN_BANK_0 32*1024*1024 #define RAM_IN_BANK_1 0 #define RAM_IN_BANK_2 0 #define RAM_IN_BANK_3 0 #define MEM_SIZE (RAM_IN_BANK_0+RAM_IN_BANK_1+RAM_IN_BANK_2+RAM_IN_BANK_3) /* translation macros */ #define __virt_to_phys__is_a_macro #define __phys_to_virt__is_a_macro #if (RAM_IN_BANK_1 + RAM_IN_BANK_2 + RAM_IN_BANK_3 == 0) #define __virt_to_phys(x) ( (x) - PAGE_OFFSET + 0x0c000000 ) #define __phys_to_virt(x) ( (x) - 0x0c000000 + PAGE_OFFSET ) #elif (RAM_IN_BANK_0 == RAM_IN_BANK_1) && \ (RAM_IN_BANK_2 + RAM_IN_BANK_3 == 0) /* Two identical banks */ #define __virt_to_phys(x) \ ( ((x) < PAGE_OFFSET+RAM_IN_BANK_0) ? \ ((x) - PAGE_OFFSET + _DRAMBnk0) : \ ((x) - PAGE_OFFSET - RAM_IN_BANK_0 + _DRAMBnk1) ) #define __phys_to_virt(x) \ ( ((x)&0x07ffffff) + \ (((x)&0x08000000) ? PAGE_OFFSET+RAM_IN_BANK_0 : PAGE_OFFSET) ) #else /* It's more efficient for all other cases to use the function call */ #undef __virt_to_phys__is_a_macro #undef __phys_to_virt__is_a_macro extern unsigned long __virt_to_phys(unsigned long vpage); extern unsigned long __phys_to_virt(unsigned long ppage); #endif /* * Virtual view <-> DMA view memory address translations * virt_to_bus: Used to translate the virtual address to an * address suitable to be passed to set_dma_addr * bus_to_virt: Used to convert an address for DMA operations * to an address that the kernel can use. * * On the SA1100, bus addresses are equivalent to physical addresses. */ #define __virt_to_bus__is_a_macro #define __virt_to_bus(x) __virt_to_phys(x) #define __bus_to_virt__is_a_macro #define __bus_to_virt(x) __phys_to_virt(x) #ifdef CONFIG_DISCONTIGMEM #error "CONFIG_DISCONTIGMEM will not work on S3C2400" /* * Because of the wide memory address space between physical RAM banks on the * SA1100, it's much more convenient to use Linux's NUMA support to implement * our memory map representation. Assuming all memory nodes have equal access * characteristics, we then have generic discontiguous memory support. * * Of course, all this isn't mandatory for SA1100 implementations with only * one used memory bank. For those, simply undefine CONFIG_DISCONTIGMEM. * * The nodes are matched with the physical memory bank addresses which are * incidentally the same as virtual addresses. * * node 0: 0xc0000000 - 0xc7ffffff * node 1: 0xc8000000 - 0xcfffffff * node 2: 0xd0000000 - 0xd7ffffff * node 3: 0xd8000000 - 0xdfffffff */ #define NR_NODES 4 /* * Given a kernel address, find the home node of the underlying memory. */ #define KVADDR_TO_NID(addr) \ (((unsigned long)(addr) - 0xc0000000) >> 27) /* * Given a physical address, convert it to a node id. */ #define PHYS_TO_NID(addr) KVADDR_TO_NID(__phys_to_virt(addr)) /* * Given a kaddr, ADDR_TO_MAPBASE finds the owning node of the memory * and returns the mem_map of that node. */ #define ADDR_TO_MAPBASE(kaddr) \ NODE_MEM_MAP(KVADDR_TO_NID((unsigned long)(kaddr))) /* * Given a kaddr, LOCAL_MEM_MAP finds the owning node of the memory * and returns the index corresponding to the appropriate page in the * node's mem_map. */ #define LOCAL_MAP_NR(kvaddr) \ (((unsigned long)(kvaddr) & 0x07ffffff) >> PAGE_SHIFT) /* * Given a kaddr, virt_to_page returns a pointer to the corresponding * mem_map entry. */ #define virt_to_page(kaddr) \ (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) /* * VALID_PAGE returns a non-zero value if given page pointer is valid. * This assumes all node's mem_maps are stored within the node they refer to. */ #define VALID_PAGE(page) \ ({ unsigned int node = KVADDR_TO_NID(page); \ ( (node < NR_NODES) && \ ((unsigned)((page) - NODE_MEM_MAP(node)) < NODE_DATA(node)->node_size) ); \ }) #else #define PHYS_TO_NID(addr) (0) #endif #endif /* __ASM_ARCH_MEMORY_H */
1001-study-uboot
arch/arm/include/asm/arch-s3c24x0/memory.h
C
gpl3
4,588
/* * (C) Copyright 2003 * David Müller ELSOFT AG Switzerland. d.mueller@elsoft.ch * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /************************************************ * NAME : s3c2400.h * Version : 31.3.2003 * * Based on S3C2400X User's manual Rev 1.1 ************************************************/ #ifndef __S3C2400_H__ #define __S3C2400_H__ #define S3C24X0_UART_CHANNELS 2 #define S3C24X0_SPI_CHANNELS 1 #define PALETTE (0x14A00400) /* SJS */ enum s3c24x0_uarts_nr { S3C24X0_UART0, S3C24X0_UART1, }; /*S3C2400 device base addresses */ #define S3C24X0_MEMCTL_BASE 0x14000000 #define S3C24X0_USB_HOST_BASE 0x14200000 #define S3C24X0_INTERRUPT_BASE 0x14400000 #define S3C24X0_DMA_BASE 0x14600000 #define S3C24X0_CLOCK_POWER_BASE 0x14800000 #define S3C24X0_LCD_BASE 0x14A00000 #define S3C24X0_UART_BASE 0x15000000 #define S3C24X0_TIMER_BASE 0x15100000 #define S3C24X0_USB_DEVICE_BASE 0x15200140 #define S3C24X0_WATCHDOG_BASE 0x15300000 #define S3C24X0_I2C_BASE 0x15400000 #define S3C24X0_I2S_BASE 0x15508000 #define S3C24X0_GPIO_BASE 0x15600000 #define S3C24X0_RTC_BASE 0x15700000 #define S3C24X0_ADC_BASE 0x15800000 #define S3C24X0_SPI_BASE 0x15900000 #define S3C2400_MMC_BASE 0x15A00000 /* include common stuff */ #include <asm/arch/s3c24x0.h> static inline struct s3c24x0_memctl *s3c24x0_get_base_memctl(void) { return (struct s3c24x0_memctl *)S3C24X0_MEMCTL_BASE; } static inline struct s3c24x0_usb_host *s3c24x0_get_base_usb_host(void) { return (struct s3c24x0_usb_host *)S3C24X0_USB_HOST_BASE; } static inline struct s3c24x0_interrupt *s3c24x0_get_base_interrupt(void) { return (struct s3c24x0_interrupt *)S3C24X0_INTERRUPT_BASE; } static inline struct s3c24x0_dmas *s3c24x0_get_base_dmas(void) { return (struct s3c24x0_dmas *)S3C24X0_DMA_BASE; } static inline struct s3c24x0_clock_power *s3c24x0_get_base_clock_power(void) { return (struct s3c24x0_clock_power *)S3C24X0_CLOCK_POWER_BASE; } static inline struct s3c24x0_lcd *s3c24x0_get_base_lcd(void) { return (struct s3c24x0_lcd *)S3C24X0_LCD_BASE; } static inline struct s3c24x0_uart *s3c24x0_get_base_uart(enum s3c24x0_uarts_nr n) { return (struct s3c24x0_uart *)(S3C24X0_UART_BASE + (n * 0x4000)); } static inline struct s3c24x0_timers *s3c24x0_get_base_timers(void) { return (struct s3c24x0_timers *)S3C24X0_TIMER_BASE; } static inline struct s3c24x0_usb_device *s3c24x0_get_base_usb_device(void) { return (struct s3c24x0_usb_device *)S3C24X0_USB_DEVICE_BASE; } static inline struct s3c24x0_watchdog *s3c24x0_get_base_watchdog(void) { return (struct s3c24x0_watchdog *)S3C24X0_WATCHDOG_BASE; } static inline struct s3c24x0_i2c *s3c24x0_get_base_i2c(void) { return (struct s3c24x0_i2c *)S3C24X0_I2C_BASE; } static inline struct s3c24x0_i2s *s3c24x0_get_base_i2s(void) { return (struct s3c24x0_i2s *)S3C24X0_I2S_BASE; } static inline struct s3c24x0_gpio *s3c24x0_get_base_gpio(void) { return (struct s3c24x0_gpio *)S3C24X0_GPIO_BASE; } static inline struct s3c24x0_rtc *s3c24x0_get_base_rtc(void) { return (struct s3c24x0_rtc *)S3C24X0_RTC_BASE; } static inline struct s3c2400_adc *s3c2400_get_base_adc(void) { return (struct s3c2400_adc *)S3C24X0_ADC_BASE; } static inline struct s3c24x0_spi *s3c24x0_get_base_spi(void) { return (struct s3c24x0_spi *)S3C24X0_SPI_BASE; } static inline struct s3c2400_mmc *s3c2400_get_base_mmc(void) { return (struct s3c2400_mmc *)S3C2400_MMC_BASE; } #endif /*__S3C2400_H__*/
1001-study-uboot
arch/arm/include/asm/arch-s3c24x0/s3c2400.h
C
gpl3
4,210
/* * (C) Copyright 2003 * David Mueller ELSOFT AG Switzerland. d.mueller@elsoft.ch * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /************************************************ * NAME : s3c2440.h * Version : 31.3.2003 * * Based on S3C2440 User's manual Rev x.x ************************************************/ #ifndef __S3C2440_H__ #define __S3C2440_H__ #define S3C24X0_UART_CHANNELS 3 #define S3C24X0_SPI_CHANNELS 2 /* S3C2440 only supports 512 Byte HW ECC */ #define S3C2440_ECCSIZE 512 #define S3C2440_ECCBYTES 3 enum s3c24x0_uarts_nr { S3C24X0_UART0, S3C24X0_UART1, S3C24X0_UART2 }; /* S3C2440 device base addresses */ #define S3C24X0_MEMCTL_BASE 0x48000000 #define S3C24X0_USB_HOST_BASE 0x49000000 #define S3C24X0_INTERRUPT_BASE 0x4A000000 #define S3C24X0_DMA_BASE 0x4B000000 #define S3C24X0_CLOCK_POWER_BASE 0x4C000000 #define S3C24X0_LCD_BASE 0x4D000000 #define S3C2440_NAND_BASE 0x4E000000 #define S3C24X0_UART_BASE 0x50000000 #define S3C24X0_TIMER_BASE 0x51000000 #define S3C24X0_USB_DEVICE_BASE 0x52000140 #define S3C24X0_WATCHDOG_BASE 0x53000000 #define S3C24X0_I2C_BASE 0x54000000 #define S3C24X0_I2S_BASE 0x55000000 #define S3C24X0_GPIO_BASE 0x56000000 #define S3C24X0_RTC_BASE 0x57000000 #define S3C2440_ADC_BASE 0x58000000 #define S3C24X0_SPI_BASE 0x59000000 #define S3C2440_SDI_BASE 0x5A000000 /* include common stuff */ #include <asm/arch/s3c24x0.h> static inline struct s3c24x0_memctl *s3c24x0_get_base_memctl(void) { return (struct s3c24x0_memctl *)S3C24X0_MEMCTL_BASE; } static inline struct s3c24x0_usb_host *s3c24x0_get_base_usb_host(void) { return (struct s3c24x0_usb_host *)S3C24X0_USB_HOST_BASE; } static inline struct s3c24x0_interrupt *s3c24x0_get_base_interrupt(void) { return (struct s3c24x0_interrupt *)S3C24X0_INTERRUPT_BASE; } static inline struct s3c24x0_dmas *s3c24x0_get_base_dmas(void) { return (struct s3c24x0_dmas *)S3C24X0_DMA_BASE; } static inline struct s3c24x0_clock_power *s3c24x0_get_base_clock_power(void) { return (struct s3c24x0_clock_power *)S3C24X0_CLOCK_POWER_BASE; } static inline struct s3c24x0_lcd *s3c24x0_get_base_lcd(void) { return (struct s3c24x0_lcd *)S3C24X0_LCD_BASE; } static inline struct s3c2440_nand *s3c2440_get_base_nand(void) { return (struct s3c2440_nand *)S3C2440_NAND_BASE; } static inline struct s3c24x0_uart *s3c24x0_get_base_uart(enum s3c24x0_uarts_nr n) { return (struct s3c24x0_uart *)(S3C24X0_UART_BASE + (n * 0x4000)); } static inline struct s3c24x0_timers *s3c24x0_get_base_timers(void) { return (struct s3c24x0_timers *)S3C24X0_TIMER_BASE; } static inline struct s3c24x0_usb_device *s3c24x0_get_base_usb_device(void) { return (struct s3c24x0_usb_device *)S3C24X0_USB_DEVICE_BASE; } static inline struct s3c24x0_watchdog *s3c24x0_get_base_watchdog(void) { return (struct s3c24x0_watchdog *)S3C24X0_WATCHDOG_BASE; } static inline struct s3c24x0_i2c *s3c24x0_get_base_i2c(void) { return (struct s3c24x0_i2c *)S3C24X0_I2C_BASE; } static inline struct s3c24x0_i2s *s3c24x0_get_base_i2s(void) { return (struct s3c24x0_i2s *)S3C24X0_I2S_BASE; } static inline struct s3c24x0_gpio *s3c24x0_get_base_gpio(void) { return (struct s3c24x0_gpio *)S3C24X0_GPIO_BASE; } static inline struct s3c24x0_rtc *s3c24x0_get_base_rtc(void) { return (struct s3c24x0_rtc *)S3C24X0_RTC_BASE; } static inline struct s3c2440_adc *s3c2440_get_base_adc(void) { return (struct s3c2440_adc *)S3C2440_ADC_BASE; } static inline struct s3c24x0_spi *s3c24x0_get_base_spi(void) { return (struct s3c24x0_spi *)S3C24X0_SPI_BASE; } static inline struct s3c2440_sdi *s3c2440_get_base_sdi(void) { return (struct s3c2440_sdi *)S3C2440_SDI_BASE; } #endif /*__S3C2440_H__*/
1001-study-uboot
arch/arm/include/asm/arch-s3c24x0/s3c2440.h
C
gpl3
4,440
/* * (C) Copyright 2003 * David Müller ELSOFT AG Switzerland. d.mueller@elsoft.ch * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /************************************************ * NAME : s3c24x0.h * Version : 31.3.2003 * * common stuff for SAMSUNG S3C24X0 SoC ************************************************/ #ifndef __S3C24X0_H__ #define __S3C24X0_H__ /* Memory controller (see manual chapter 5) */ struct s3c24x0_memctl { u32 bwscon; u32 bankcon[8]; u32 refresh; u32 banksize; u32 mrsrb6; u32 mrsrb7; }; /* USB HOST (see manual chapter 12) */ struct s3c24x0_usb_host { u32 HcRevision; u32 HcControl; u32 HcCommonStatus; u32 HcInterruptStatus; u32 HcInterruptEnable; u32 HcInterruptDisable; u32 HcHCCA; u32 HcPeriodCuttendED; u32 HcControlHeadED; u32 HcControlCurrentED; u32 HcBulkHeadED; u32 HcBuldCurrentED; u32 HcDoneHead; u32 HcRmInterval; u32 HcFmRemaining; u32 HcFmNumber; u32 HcPeriodicStart; u32 HcLSThreshold; u32 HcRhDescriptorA; u32 HcRhDescriptorB; u32 HcRhStatus; u32 HcRhPortStatus1; u32 HcRhPortStatus2; }; /* INTERRUPT (see manual chapter 14) */ struct s3c24x0_interrupt { u32 srcpnd; u32 intmod; u32 intmsk; u32 priority; u32 intpnd; u32 intoffset; #if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) u32 subsrcpnd; u32 intsubmsk; #endif }; /* DMAS (see manual chapter 8) */ struct s3c24x0_dma { u32 disrc; #if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) u32 disrcc; #endif u32 didst; #if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) u32 didstc; #endif u32 dcon; u32 dstat; u32 dcsrc; u32 dcdst; u32 dmasktrig; #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) \ || defined(CONFIG_S3C2440) u32 res[1]; #endif }; struct s3c24x0_dmas { struct s3c24x0_dma dma[4]; }; /* CLOCK & POWER MANAGEMENT (see S3C2400 manual chapter 6) */ /* (see S3C2410 manual chapter 7) */ struct s3c24x0_clock_power { u32 locktime; u32 mpllcon; u32 upllcon; u32 clkcon; u32 clkslow; u32 clkdivn; #if defined(CONFIG_S3C2440) u32 camdivn; #endif }; /* LCD CONTROLLER (see manual chapter 15) */ struct s3c24x0_lcd { u32 lcdcon1; u32 lcdcon2; u32 lcdcon3; u32 lcdcon4; u32 lcdcon5; u32 lcdsaddr1; u32 lcdsaddr2; u32 lcdsaddr3; u32 redlut; u32 greenlut; u32 bluelut; u32 res[8]; u32 dithmode; u32 tpal; #if defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440) u32 lcdintpnd; u32 lcdsrcpnd; u32 lcdintmsk; u32 lpcsel; #endif }; #ifdef CONFIG_S3C2410 /* NAND FLASH (see S3C2410 manual chapter 6) */ struct s3c2410_nand { u32 nfconf; u32 nfcmd; u32 nfaddr; u32 nfdata; u32 nfstat; u32 nfecc; }; #endif #ifdef CONFIG_S3C2440 /* NAND FLASH (see S3C2440 manual chapter 6) */ struct s3c2440_nand { u32 nfconf; u32 nfcont; u32 nfcmd; u32 nfaddr; u32 nfdata; u32 nfmeccd0; u32 nfmeccd1; u32 nfseccd; u32 nfstat; u32 nfestat0; u32 nfestat1; u32 nfmecc0; u32 nfmecc1; u32 nfsecc; u32 nfsblk; u32 nfeblk; }; #endif /* UART (see manual chapter 11) */ struct s3c24x0_uart { u32 ulcon; u32 ucon; u32 ufcon; u32 umcon; u32 utrstat; u32 uerstat; u32 ufstat; u32 umstat; #ifdef __BIG_ENDIAN u8 res1[3]; u8 utxh; u8 res2[3]; u8 urxh; #else /* Little Endian */ u8 utxh; u8 res1[3]; u8 urxh; u8 res2[3]; #endif u32 ubrdiv; }; /* PWM TIMER (see manual chapter 10) */ struct s3c24x0_timer { u32 tcntb; u32 tcmpb; u32 tcnto; }; struct s3c24x0_timers { u32 tcfg0; u32 tcfg1; u32 tcon; struct s3c24x0_timer ch[4]; u32 tcntb4; u32 tcnto4; }; /* USB DEVICE (see manual chapter 13) */ struct s3c24x0_usb_dev_fifos { #ifdef __BIG_ENDIAN u8 res[3]; u8 ep_fifo_reg; #else /* little endian */ u8 ep_fifo_reg; u8 res[3]; #endif }; struct s3c24x0_usb_dev_dmas { #ifdef __BIG_ENDIAN u8 res1[3]; u8 ep_dma_con; u8 res2[3]; u8 ep_dma_unit; u8 res3[3]; u8 ep_dma_fifo; u8 res4[3]; u8 ep_dma_ttc_l; u8 res5[3]; u8 ep_dma_ttc_m; u8 res6[3]; u8 ep_dma_ttc_h; #else /* little endian */ u8 ep_dma_con; u8 res1[3]; u8 ep_dma_unit; u8 res2[3]; u8 ep_dma_fifo; u8 res3[3]; u8 ep_dma_ttc_l; u8 res4[3]; u8 ep_dma_ttc_m; u8 res5[3]; u8 ep_dma_ttc_h; u8 res6[3]; #endif }; struct s3c24x0_usb_device { #ifdef __BIG_ENDIAN u8 res1[3]; u8 func_addr_reg; u8 res2[3]; u8 pwr_reg; u8 res3[3]; u8 ep_int_reg; u8 res4[15]; u8 usb_int_reg; u8 res5[3]; u8 ep_int_en_reg; u8 res6[15]; u8 usb_int_en_reg; u8 res7[3]; u8 frame_num1_reg; u8 res8[3]; u8 frame_num2_reg; u8 res9[3]; u8 index_reg; u8 res10[7]; u8 maxp_reg; u8 res11[3]; u8 ep0_csr_in_csr1_reg; u8 res12[3]; u8 in_csr2_reg; u8 res13[7]; u8 out_csr1_reg; u8 res14[3]; u8 out_csr2_reg; u8 res15[3]; u8 out_fifo_cnt1_reg; u8 res16[3]; u8 out_fifo_cnt2_reg; #else /* little endian */ u8 func_addr_reg; u8 res1[3]; u8 pwr_reg; u8 res2[3]; u8 ep_int_reg; u8 res3[15]; u8 usb_int_reg; u8 res4[3]; u8 ep_int_en_reg; u8 res5[15]; u8 usb_int_en_reg; u8 res6[3]; u8 frame_num1_reg; u8 res7[3]; u8 frame_num2_reg; u8 res8[3]; u8 index_reg; u8 res9[7]; u8 maxp_reg; u8 res10[7]; u8 ep0_csr_in_csr1_reg; u8 res11[3]; u8 in_csr2_reg; u8 res12[3]; u8 out_csr1_reg; u8 res13[7]; u8 out_csr2_reg; u8 res14[3]; u8 out_fifo_cnt1_reg; u8 res15[3]; u8 out_fifo_cnt2_reg; u8 res16[3]; #endif /* __BIG_ENDIAN */ struct s3c24x0_usb_dev_fifos fifo[5]; struct s3c24x0_usb_dev_dmas dma[5]; }; /* WATCH DOG TIMER (see manual chapter 18) */ struct s3c24x0_watchdog { u32 wtcon; u32 wtdat; u32 wtcnt; }; /* IIC (see manual chapter 20) */ struct s3c24x0_i2c { u32 iiccon; u32 iicstat; u32 iicadd; u32 iicds; }; /* IIS (see manual chapter 21) */ struct s3c24x0_i2s { #ifdef __BIG_ENDIAN u16 res1; u16 iiscon; u16 res2; u16 iismod; u16 res3; u16 iispsr; u16 res4; u16 iisfcon; u16 res5; u16 iisfifo; #else /* little endian */ u16 iiscon; u16 res1; u16 iismod; u16 res2; u16 iispsr; u16 res3; u16 iisfcon; u16 res4; u16 iisfifo; u16 res5; #endif }; /* I/O PORT (see manual chapter 9) */ struct s3c24x0_gpio { #ifdef CONFIG_S3C2400 u32 pacon; u32 padat; u32 pbcon; u32 pbdat; u32 pbup; u32 pccon; u32 pcdat; u32 pcup; u32 pdcon; u32 pddat; u32 pdup; u32 pecon; u32 pedat; u32 peup; u32 pfcon; u32 pfdat; u32 pfup; u32 pgcon; u32 pgdat; u32 pgup; u32 opencr; u32 misccr; u32 extint; #endif #ifdef CONFIG_S3C2410 u32 gpacon; u32 gpadat; u32 res1[2]; u32 gpbcon; u32 gpbdat; u32 gpbup; u32 res2; u32 gpccon; u32 gpcdat; u32 gpcup; u32 res3; u32 gpdcon; u32 gpddat; u32 gpdup; u32 res4; u32 gpecon; u32 gpedat; u32 gpeup; u32 res5; u32 gpfcon; u32 gpfdat; u32 gpfup; u32 res6; u32 gpgcon; u32 gpgdat; u32 gpgup; u32 res7; u32 gphcon; u32 gphdat; u32 gphup; u32 res8; u32 misccr; u32 dclkcon; u32 extint0; u32 extint1; u32 extint2; u32 eintflt0; u32 eintflt1; u32 eintflt2; u32 eintflt3; u32 eintmask; u32 eintpend; u32 gstatus0; u32 gstatus1; u32 gstatus2; u32 gstatus3; u32 gstatus4; #endif #if defined(CONFIG_S3C2440) u32 gpacon; u32 gpadat; u32 res1[2]; u32 gpbcon; u32 gpbdat; u32 gpbup; u32 res2; u32 gpccon; u32 gpcdat; u32 gpcup; u32 res3; u32 gpdcon; u32 gpddat; u32 gpdup; u32 res4; u32 gpecon; u32 gpedat; u32 gpeup; u32 res5; u32 gpfcon; u32 gpfdat; u32 gpfup; u32 res6; u32 gpgcon; u32 gpgdat; u32 gpgup; u32 res7; u32 gphcon; u32 gphdat; u32 gphup; u32 res8; u32 misccr; u32 dclkcon; u32 extint0; u32 extint1; u32 extint2; u32 eintflt0; u32 eintflt1; u32 eintflt2; u32 eintflt3; u32 eintmask; u32 eintpend; u32 gstatus0; u32 gstatus1; u32 gstatus2; u32 gstatus3; u32 gstatus4; u32 res9; u32 dsc0; u32 dsc1; u32 mslcon; u32 gpjcon; u32 gpjdat; u32 gpjup; u32 res10; #endif }; /* RTC (see manual chapter 17) */ struct s3c24x0_rtc { #ifdef __BIG_ENDIAN u8 res1[67]; u8 rtccon; u8 res2[3]; u8 ticnt; u8 res3[11]; u8 rtcalm; u8 res4[3]; u8 almsec; u8 res5[3]; u8 almmin; u8 res6[3]; u8 almhour; u8 res7[3]; u8 almdate; u8 res8[3]; u8 almmon; u8 res9[3]; u8 almyear; u8 res10[3]; u8 rtcrst; u8 res11[3]; u8 bcdsec; u8 res12[3]; u8 bcdmin; u8 res13[3]; u8 bcdhour; u8 res14[3]; u8 bcddate; u8 res15[3]; u8 bcdday; u8 res16[3]; u8 bcdmon; u8 res17[3]; u8 bcdyear; #else /* little endian */ u8 res0[64]; u8 rtccon; u8 res1[3]; u8 ticnt; u8 res2[11]; u8 rtcalm; u8 res3[3]; u8 almsec; u8 res4[3]; u8 almmin; u8 res5[3]; u8 almhour; u8 res6[3]; u8 almdate; u8 res7[3]; u8 almmon; u8 res8[3]; u8 almyear; u8 res9[3]; u8 rtcrst; u8 res10[3]; u8 bcdsec; u8 res11[3]; u8 bcdmin; u8 res12[3]; u8 bcdhour; u8 res13[3]; u8 bcddate; u8 res14[3]; u8 bcdday; u8 res15[3]; u8 bcdmon; u8 res16[3]; u8 bcdyear; u8 res17[3]; #endif }; /* ADC (see manual chapter 16) */ struct s3c2400_adc { u32 adccon; u32 adcdat; }; /* ADC (see manual chapter 16) */ struct s3c2410_adc { u32 adccon; u32 adctsc; u32 adcdly; u32 adcdat0; u32 adcdat1; }; /* SPI (see manual chapter 22) */ struct s3c24x0_spi_channel { u8 spcon; u8 res1[3]; u8 spsta; u8 res2[3]; u8 sppin; u8 res3[3]; u8 sppre; u8 res4[3]; u8 sptdat; u8 res5[3]; u8 sprdat; u8 res6[3]; u8 res7[16]; }; struct s3c24x0_spi { struct s3c24x0_spi_channel ch[S3C24X0_SPI_CHANNELS]; }; /* MMC INTERFACE (see S3C2400 manual chapter 19) */ struct s3c2400_mmc { #ifdef __BIG_ENDIAN u8 res1[3]; u8 mmcon; u8 res2[3]; u8 mmcrr; u8 res3[3]; u8 mmfcon; u8 res4[3]; u8 mmsta; u16 res5; u16 mmfsta; u8 res6[3]; u8 mmpre; u16 res7; u16 mmlen; u8 res8[3]; u8 mmcr7; u32 mmrsp[4]; u8 res9[3]; u8 mmcmd0; u32 mmcmd1; u16 res10; u16 mmcr16; u8 res11[3]; u8 mmdat; #else u8 mmcon; u8 res1[3]; u8 mmcrr; u8 res2[3]; u8 mmfcon; u8 res3[3]; u8 mmsta; u8 res4[3]; u16 mmfsta; u16 res5; u8 mmpre; u8 res6[3]; u16 mmlen; u16 res7; u8 mmcr7; u8 res8[3]; u32 mmrsp[4]; u8 mmcmd0; u8 res9[3]; u32 mmcmd1; u16 mmcr16; u16 res10; u8 mmdat; u8 res11[3]; #endif }; /* SD INTERFACE (see S3C2410 manual chapter 19) */ struct s3c2410_sdi { u32 sdicon; u32 sdipre; u32 sdicarg; u32 sdiccon; u32 sdicsta; u32 sdirsp0; u32 sdirsp1; u32 sdirsp2; u32 sdirsp3; u32 sdidtimer; u32 sdibsize; u32 sdidcon; u32 sdidcnt; u32 sdidsta; u32 sdifsta; #ifdef __BIG_ENDIAN u8 res[3]; u8 sdidat; #else u8 sdidat; u8 res[3]; #endif u32 sdiimsk; }; #endif /*__S3C24X0_H__*/
1001-study-uboot
arch/arm/include/asm/arch-s3c24x0/s3c24x0.h
C
gpl3
11,131
/* * (C) Copyright 2009 * Kevin Morfitt, Fearnside Systems Ltd, <kevin.morfitt@fearnside-systems.co.uk> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifdef CONFIG_S3C2400 #include <asm/arch/s3c2400.h> #elif defined CONFIG_S3C2410 #include <asm/arch/s3c2410.h> #elif defined CONFIG_S3C2440 #include <asm/arch/s3c2440.h> #else #error Please define the s3c24x0 cpu type #endif
1001-study-uboot
arch/arm/include/asm/arch-s3c24x0/s3c24x0_cpu.h
C
gpl3
1,057
/* * (C) Copyright 2003 * David Müller ELSOFT AG Switzerland. d.mueller@elsoft.ch * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /************************************************ * NAME : s3c2410.h * Version : 31.3.2003 * * Based on S3C2410X User's manual Rev 1.1 ************************************************/ #ifndef __S3C2410_H__ #define __S3C2410_H__ #define S3C24X0_UART_CHANNELS 3 #define S3C24X0_SPI_CHANNELS 2 /* S3C2410 only supports 512 Byte HW ECC */ #define S3C2410_ECCSIZE 512 #define S3C2410_ECCBYTES 3 enum s3c24x0_uarts_nr { S3C24X0_UART0, S3C24X0_UART1, S3C24X0_UART2 }; /* S3C2410 device base addresses */ #define S3C24X0_MEMCTL_BASE 0x48000000 #define S3C24X0_USB_HOST_BASE 0x49000000 #define S3C24X0_INTERRUPT_BASE 0x4A000000 #define S3C24X0_DMA_BASE 0x4B000000 #define S3C24X0_CLOCK_POWER_BASE 0x4C000000 #define S3C24X0_LCD_BASE 0x4D000000 #define S3C2410_NAND_BASE 0x4E000000 #define S3C24X0_UART_BASE 0x50000000 #define S3C24X0_TIMER_BASE 0x51000000 #define S3C24X0_USB_DEVICE_BASE 0x52000140 #define S3C24X0_WATCHDOG_BASE 0x53000000 #define S3C24X0_I2C_BASE 0x54000000 #define S3C24X0_I2S_BASE 0x55000000 #define S3C24X0_GPIO_BASE 0x56000000 #define S3C24X0_RTC_BASE 0x57000000 #define S3C2410_ADC_BASE 0x58000000 #define S3C24X0_SPI_BASE 0x59000000 #define S3C2410_SDI_BASE 0x5A000000 /* include common stuff */ #include <asm/arch/s3c24x0.h> static inline struct s3c24x0_memctl *s3c24x0_get_base_memctl(void) { return (struct s3c24x0_memctl *)S3C24X0_MEMCTL_BASE; } static inline struct s3c24x0_usb_host *s3c24x0_get_base_usb_host(void) { return (struct s3c24x0_usb_host *)S3C24X0_USB_HOST_BASE; } static inline struct s3c24x0_interrupt *s3c24x0_get_base_interrupt(void) { return (struct s3c24x0_interrupt *)S3C24X0_INTERRUPT_BASE; } static inline struct s3c24x0_dmas *s3c24x0_get_base_dmas(void) { return (struct s3c24x0_dmas *)S3C24X0_DMA_BASE; } static inline struct s3c24x0_clock_power *s3c24x0_get_base_clock_power(void) { return (struct s3c24x0_clock_power *)S3C24X0_CLOCK_POWER_BASE; } static inline struct s3c24x0_lcd *s3c24x0_get_base_lcd(void) { return (struct s3c24x0_lcd *)S3C24X0_LCD_BASE; } static inline struct s3c2410_nand *s3c2410_get_base_nand(void) { return (struct s3c2410_nand *)S3C2410_NAND_BASE; } static inline struct s3c24x0_uart *s3c24x0_get_base_uart(enum s3c24x0_uarts_nr n) { return (struct s3c24x0_uart *)(S3C24X0_UART_BASE + (n * 0x4000)); } static inline struct s3c24x0_timers *s3c24x0_get_base_timers(void) { return (struct s3c24x0_timers *)S3C24X0_TIMER_BASE; } static inline struct s3c24x0_usb_device *s3c24x0_get_base_usb_device(void) { return (struct s3c24x0_usb_device *)S3C24X0_USB_DEVICE_BASE; } static inline struct s3c24x0_watchdog *s3c24x0_get_base_watchdog(void) { return (struct s3c24x0_watchdog *)S3C24X0_WATCHDOG_BASE; } static inline struct s3c24x0_i2c *s3c24x0_get_base_i2c(void) { return (struct s3c24x0_i2c *)S3C24X0_I2C_BASE; } static inline struct s3c24x0_i2s *s3c24x0_get_base_i2s(void) { return (struct s3c24x0_i2s *)S3C24X0_I2S_BASE; } static inline struct s3c24x0_gpio *s3c24x0_get_base_gpio(void) { return (struct s3c24x0_gpio *)S3C24X0_GPIO_BASE; } static inline struct s3c24x0_rtc *s3c24x0_get_base_rtc(void) { return (struct s3c24x0_rtc *)S3C24X0_RTC_BASE; } static inline struct s3c2410_adc *s3c2410_get_base_adc(void) { return (struct s3c2410_adc *)S3C2410_ADC_BASE; } static inline struct s3c24x0_spi *s3c24x0_get_base_spi(void) { return (struct s3c24x0_spi *)S3C24X0_SPI_BASE; } static inline struct s3c2410_sdi *s3c2410_get_base_sdi(void) { return (struct s3c2410_sdi *)S3C2410_SDI_BASE; } #endif /*__S3C2410_H__*/
1001-study-uboot
arch/arm/include/asm/arch-s3c24x0/s3c2410.h
C
gpl3
4,443
#ifndef __ASM_ARM_TYPES_H #define __ASM_ARM_TYPES_H typedef unsigned short umode_t; /* * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the * header files exported to user space */ typedef __signed__ char __s8; typedef unsigned char __u8; typedef __signed__ short __s16; typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; #if defined(__GNUC__) __extension__ typedef __signed__ long long __s64; __extension__ typedef unsigned long long __u64; #endif /* * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ typedef signed char s8; typedef unsigned char u8; typedef signed short s16; typedef unsigned short u16; typedef signed int s32; typedef unsigned int u32; typedef signed long long s64; typedef unsigned long long u64; #define BITS_PER_LONG 32 /* Dma addresses are 32-bits wide. */ typedef u32 dma_addr_t; typedef unsigned long phys_addr_t; typedef unsigned long phys_size_t; #endif /* __KERNEL__ */ #endif
1001-study-uboot
arch/arm/include/asm/types.h
C
gpl3
1,026
/* * linux/include/asm-arm/posix_types.h * * Copyright (C) 1996-1998 Russell King. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Changelog: * 27-06-1996 RMK Created */ #ifndef __ARCH_ARM_POSIX_TYPES_H #define __ARCH_ARM_POSIX_TYPES_H /* * This file is generally used by user-level software, so you need to * be a little careful about namespace pollution etc. Also, we cannot * assume GCC is being used. */ typedef unsigned short __kernel_dev_t; typedef unsigned long __kernel_ino_t; typedef unsigned short __kernel_mode_t; typedef unsigned short __kernel_nlink_t; typedef long __kernel_off_t; typedef int __kernel_pid_t; typedef unsigned short __kernel_ipc_pid_t; typedef unsigned short __kernel_uid_t; typedef unsigned short __kernel_gid_t; typedef unsigned int __kernel_size_t; typedef int __kernel_ssize_t; typedef int __kernel_ptrdiff_t; typedef long __kernel_time_t; typedef long __kernel_suseconds_t; typedef long __kernel_clock_t; typedef int __kernel_daddr_t; typedef char * __kernel_caddr_t; typedef unsigned short __kernel_uid16_t; typedef unsigned short __kernel_gid16_t; typedef unsigned int __kernel_uid32_t; typedef unsigned int __kernel_gid32_t; typedef unsigned short __kernel_old_uid_t; typedef unsigned short __kernel_old_gid_t; #ifdef __GNUC__ typedef long long __kernel_loff_t; #endif typedef struct { #if defined(__KERNEL__) || defined(__USE_ALL) int val[2]; #else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ int __val[2]; #endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ } __kernel_fsid_t; #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) #undef __FD_SET #define __FD_SET(fd, fdsetp) \ (((fd_set *)fdsetp)->fds_bits[fd >> 5] |= (1<<(fd & 31))) #undef __FD_CLR #define __FD_CLR(fd, fdsetp) \ (((fd_set *)fdsetp)->fds_bits[fd >> 5] &= ~(1<<(fd & 31))) #undef __FD_ISSET #define __FD_ISSET(fd, fdsetp) \ ((((fd_set *)fdsetp)->fds_bits[fd >> 5] & (1<<(fd & 31))) != 0) #undef __FD_ZERO #define __FD_ZERO(fdsetp) \ (memset (fdsetp, 0, sizeof (*(fd_set *)fdsetp))) #endif #endif
1001-study-uboot
arch/arm/include/asm/posix_types.h
C
gpl3
2,246
/* * linux/include/asm-arm/byteorder.h * * ARM Endian-ness. In little endian mode, the data bus is connected such * that byte accesses appear as: * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 * and word accesses (data or instruction) appear as: * d0...d31 * * When in big endian mode, byte accesses appear as: * 0 = d24...d31, 1 = d16...d23, 2 = d8...d15, 3 = d0...d7 * and word accesses (data or instruction) appear as: * d0...d31 */ #ifndef __ASM_ARM_BYTEORDER_H #define __ASM_ARM_BYTEORDER_H #include <asm/types.h> #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) # define __BYTEORDER_HAS_U64__ # define __SWAB_64_THRU_32__ #endif #ifdef __ARMEB__ #include <linux/byteorder/big_endian.h> #else #include <linux/byteorder/little_endian.h> #endif #endif
1001-study-uboot
arch/arm/include/asm/byteorder.h
C
gpl3
796
#ifndef _ASM_ARM_UNALIGNED_H #define _ASM_ARM_UNALIGNED_H #include <linux/unaligned/le_byteshift.h> #include <linux/unaligned/be_byteshift.h> #include <linux/unaligned/generic.h> /* * Select endianness */ #ifndef __ARMEB__ #define get_unaligned __get_unaligned_le #define put_unaligned __put_unaligned_le #else #define get_unaligned __get_unaligned_be #define put_unaligned __put_unaligned_be #endif #endif /* _ASM_ARM_UNALIGNED_H */
1001-study-uboot
arch/arm/include/asm/unaligned.h
C
gpl3
439
/* * linux/include/asm-arm/proc-armv/domain.h * * Copyright (C) 1999 Russell King. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef __ASM_PROC_DOMAIN_H #define __ASM_PROC_DOMAIN_H /* * Domain numbers * * DOMAIN_IO - domain 2 includes all IO only * DOMAIN_KERNEL - domain 1 includes all kernel memory only * DOMAIN_USER - domain 0 includes all user memory only */ #define DOMAIN_USER 0 #define DOMAIN_KERNEL 1 #define DOMAIN_TABLE 1 #define DOMAIN_IO 2 /* * Domain types */ #define DOMAIN_NOACCESS 0 #define DOMAIN_CLIENT 1 #define DOMAIN_MANAGER 3 #define domain_val(dom,type) ((type) << 2*(dom)) #define set_domain(x) \ do { \ __asm__ __volatile__( \ "mcr p15, 0, %0, c3, c0 @ set domain" \ : : "r" (x)); \ } while (0) #define modify_domain(dom,type) \ do { \ unsigned int domain = current->thread.domain; \ domain &= ~domain_val(dom, DOMAIN_MANAGER); \ domain |= domain_val(dom, type); \ current->thread.domain = domain; \ set_domain(current->thread.domain); \ } while (0) #endif
1001-study-uboot
arch/arm/include/asm/proc-armv/domain.h
C
gpl3
1,204
/* * linux/include/asm-arm/proc-armv/system.h * * Copyright (C) 1996 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef __ASM_PROC_SYSTEM_H #define __ASM_PROC_SYSTEM_H #include <linux/config.h> /* * Save the current interrupt enable state & disable IRQs */ #define local_irq_save(x) \ ({ \ unsigned long temp; \ __asm__ __volatile__( \ "mrs %0, cpsr @ local_irq_save\n" \ " orr %1, %0, #128\n" \ " msr cpsr_c, %1" \ : "=r" (x), "=r" (temp) \ : \ : "memory"); \ }) /* * Enable IRQs */ #define local_irq_enable() \ ({ \ unsigned long temp; \ __asm__ __volatile__( \ "mrs %0, cpsr @ local_irq_enable\n" \ " bic %0, %0, #128\n" \ " msr cpsr_c, %0" \ : "=r" (temp) \ : \ : "memory"); \ }) /* * Disable IRQs */ #define local_irq_disable() \ ({ \ unsigned long temp; \ __asm__ __volatile__( \ "mrs %0, cpsr @ local_irq_disable\n" \ " orr %0, %0, #128\n" \ " msr cpsr_c, %0" \ : "=r" (temp) \ : \ : "memory"); \ }) /* * Enable FIQs */ #define __stf() \ ({ \ unsigned long temp; \ __asm__ __volatile__( \ "mrs %0, cpsr @ stf\n" \ " bic %0, %0, #64\n" \ " msr cpsr_c, %0" \ : "=r" (temp) \ : \ : "memory"); \ }) /* * Disable FIQs */ #define __clf() \ ({ \ unsigned long temp; \ __asm__ __volatile__( \ "mrs %0, cpsr @ clf\n" \ " orr %0, %0, #64\n" \ " msr cpsr_c, %0" \ : "=r" (temp) \ : \ : "memory"); \ }) /* * Save the current interrupt enable state. */ #define local_save_flags(x) \ ({ \ __asm__ __volatile__( \ "mrs %0, cpsr @ local_save_flags\n" \ : "=r" (x) \ : \ : "memory"); \ }) /* * restore saved IRQ & FIQ state */ #define local_irq_restore(x) \ __asm__ __volatile__( \ "msr cpsr_c, %0 @ local_irq_restore\n" \ : \ : "r" (x) \ : "memory") #if defined(CONFIG_CPU_SA1100) || defined(CONFIG_CPU_SA110) /* * On the StrongARM, "swp" is terminally broken since it bypasses the * cache totally. This means that the cache becomes inconsistent, and, * since we use normal loads/stores as well, this is really bad. * Typically, this causes oopsen in filp_close, but could have other, * more disasterous effects. There are two work-arounds: * 1. Disable interrupts and emulate the atomic swap * 2. Clean the cache, perform atomic swap, flush the cache * * We choose (1) since its the "easiest" to achieve here and is not * dependent on the processor type. */ #define swp_is_buggy #endif static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size) { extern void __bad_xchg(volatile void *, int); unsigned long ret; #ifdef swp_is_buggy unsigned long flags; #endif switch (size) { #ifdef swp_is_buggy case 1: local_irq_save(flags); ret = *(volatile unsigned char *)ptr; *(volatile unsigned char *)ptr = x; local_irq_restore(flags); break; case 4: local_irq_save(flags); ret = *(volatile unsigned long *)ptr; *(volatile unsigned long *)ptr = x; local_irq_restore(flags); break; #else case 1: __asm__ __volatile__ ("swpb %0, %1, [%2]" : "=&r" (ret) : "r" (x), "r" (ptr) : "memory"); break; case 4: __asm__ __volatile__ ("swp %0, %1, [%2]" : "=&r" (ret) : "r" (x), "r" (ptr) : "memory"); break; #endif default: __bad_xchg(ptr, size), ret = 0; } return ret; } #endif
1001-study-uboot
arch/arm/include/asm/proc-armv/system.h
C
gpl3
3,696
/* * linux/include/asm-arm/proc-armv/processor.h * * Copyright (C) 1996-1999 Russell King. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Changelog: * 20-09-1996 RMK Created * 26-09-1996 RMK Added 'EXTRA_THREAD_STRUCT*' * 28-09-1996 RMK Moved start_thread into the processor dependencies * 09-09-1998 PJB Delete redundant `wp_works_ok' * 30-05-1999 PJB Save sl across context switches * 31-07-1999 RMK Added 'domain' stuff */ #ifndef __ASM_PROC_PROCESSOR_H #define __ASM_PROC_PROCESSOR_H #include <asm/proc/domain.h> #define KERNEL_STACK_SIZE PAGE_SIZE struct context_save_struct { unsigned long cpsr; unsigned long r4; unsigned long r5; unsigned long r6; unsigned long r7; unsigned long r8; unsigned long r9; unsigned long sl; unsigned long fp; unsigned long pc; }; #define INIT_CSS (struct context_save_struct){ SVC_MODE, 0, 0, 0, 0, 0, 0, 0, 0, 0 } #define EXTRA_THREAD_STRUCT \ unsigned int domain; #define EXTRA_THREAD_STRUCT_INIT \ domain: domain_val(DOMAIN_USER, DOMAIN_CLIENT) | \ domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \ domain_val(DOMAIN_IO, DOMAIN_CLIENT) #define start_thread(regs,pc,sp) \ ({ \ unsigned long *stack = (unsigned long *)sp; \ set_fs(USER_DS); \ memzero(regs->uregs, sizeof(regs->uregs)); \ if (current->personality & ADDR_LIMIT_32BIT) \ regs->ARM_cpsr = USR_MODE; \ else \ regs->ARM_cpsr = USR26_MODE; \ regs->ARM_pc = pc; /* pc */ \ regs->ARM_sp = sp; /* sp */ \ regs->ARM_r2 = stack[2]; /* r2 (envp) */ \ regs->ARM_r1 = stack[1]; /* r1 (argv) */ \ regs->ARM_r0 = stack[0]; /* r0 (argc) */ \ }) #define KSTK_EIP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1019]) #define KSTK_ESP(tsk) (((unsigned long *)(4096+(unsigned long)(tsk)))[1017]) /* Allocation and freeing of basic task resources. */ /* * NOTE! The task struct and the stack go together */ #define ll_alloc_task_struct() ((struct task_struct *) __get_free_pages(GFP_KERNEL,1)) #define ll_free_task_struct(p) free_pages((unsigned long)(p),1) #endif
1001-study-uboot
arch/arm/include/asm/proc-armv/processor.h
C
gpl3
2,231
/* * linux/include/asm-arm/proc-armv/ptrace.h * * Copyright (C) 1996-1999 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef __ASM_PROC_PTRACE_H #define __ASM_PROC_PTRACE_H #include <linux/config.h> #define USR26_MODE 0x00 #define FIQ26_MODE 0x01 #define IRQ26_MODE 0x02 #define SVC26_MODE 0x03 #define USR_MODE 0x10 #define FIQ_MODE 0x11 #define IRQ_MODE 0x12 #define SVC_MODE 0x13 #define ABT_MODE 0x17 #define UND_MODE 0x1b #define SYSTEM_MODE 0x1f #define MODE_MASK 0x1f #define T_BIT 0x20 #define F_BIT 0x40 #define I_BIT 0x80 #define CC_V_BIT (1 << 28) #define CC_C_BIT (1 << 29) #define CC_Z_BIT (1 << 30) #define CC_N_BIT (1 << 31) #define PCMASK 0 #ifndef __ASSEMBLY__ /* this struct defines the way the registers are stored on the stack during a system call. */ struct pt_regs { long uregs[18]; }; #define ARM_cpsr uregs[16] #define ARM_pc uregs[15] #define ARM_lr uregs[14] #define ARM_sp uregs[13] #define ARM_ip uregs[12] #define ARM_fp uregs[11] #define ARM_r10 uregs[10] #define ARM_r9 uregs[9] #define ARM_r8 uregs[8] #define ARM_r7 uregs[7] #define ARM_r6 uregs[6] #define ARM_r5 uregs[5] #define ARM_r4 uregs[4] #define ARM_r3 uregs[3] #define ARM_r2 uregs[2] #define ARM_r1 uregs[1] #define ARM_r0 uregs[0] #define ARM_ORIG_r0 uregs[17] #ifdef __KERNEL__ #define user_mode(regs) \ (((regs)->ARM_cpsr & 0xf) == 0) #ifdef CONFIG_ARM_THUMB #define thumb_mode(regs) \ (((regs)->ARM_cpsr & T_BIT)) #else #define thumb_mode(regs) (0) #endif #define processor_mode(regs) \ ((regs)->ARM_cpsr & MODE_MASK) #define interrupts_enabled(regs) \ (!((regs)->ARM_cpsr & I_BIT)) #define fast_interrupts_enabled(regs) \ (!((regs)->ARM_cpsr & F_BIT)) #define condition_codes(regs) \ ((regs)->ARM_cpsr & (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT)) /* Are the current registers suitable for user mode? * (used to maintain security in signal handlers) */ static inline int valid_user_regs(struct pt_regs *regs) { if ((regs->ARM_cpsr & 0xf) == 0 && (regs->ARM_cpsr & (F_BIT|I_BIT)) == 0) return 1; /* * Force CPSR to something logical... */ regs->ARM_cpsr &= (CC_V_BIT|CC_C_BIT|CC_Z_BIT|CC_N_BIT|0x10); return 0; } #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ #endif
1001-study-uboot
arch/arm/include/asm/proc-armv/ptrace.h
C
gpl3
2,398
/* * include/asm-arm/macro.h * * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef __ASM_ARM_MACRO_H__ #define __ASM_ARM_MACRO_H__ #ifdef __ASSEMBLY__ /* * These macros provide a convenient way to write 8, 16 and 32 bit data * to any address. * Registers r4 and r5 are used, any data in these registers are * overwritten by the macros. * The macros are valid for any ARM architecture, they do not implement * any memory barriers so caution is recommended when using these when the * caches are enabled or on a multi-core system. */ .macro write32, addr, data ldr r4, =\addr ldr r5, =\data str r5, [r4] .endm .macro write16, addr, data ldr r4, =\addr ldrh r5, =\data strh r5, [r4] .endm .macro write8, addr, data ldr r4, =\addr ldrb r5, =\data strb r5, [r4] .endm /* * This macro generates a loop that can be used for delays in the code. * Register r4 is used, any data in this register is overwritten by the * macro. * The macro is valid for any ARM architeture. The actual time spent in the * loop will vary from CPU to CPU though. */ .macro wait_timer, time ldr r4, =\time 1: nop subs r4, r4, #1 bcs 1b .endm #endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_MACRO_H__ */
1001-study-uboot
arch/arm/include/asm/macro.h
C
gpl3
2,041
/* * (C) Copyright 2010 * Texas Instruments, <www.ti.com> * Aneesh V <aneesh@ti.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef _PL310_H_ #define _PL310_H_ #include <linux/types.h> /* Register bit fields */ #define PL310_AUX_CTRL_ASSOCIATIVITY_MASK (1 << 16) struct pl310_regs { u32 pl310_cache_id; u32 pl310_cache_type; u32 pad1[62]; u32 pl310_ctrl; u32 pl310_aux_ctrl; u32 pl310_tag_latency_ctrl; u32 pl310_data_latency_ctrl; u32 pad2[60]; u32 pl310_event_cnt_ctrl; u32 pl310_event_cnt1_cfg; u32 pl310_event_cnt0_cfg; u32 pl310_event_cnt1_val; u32 pl310_event_cnt0_val; u32 pl310_intr_mask; u32 pl310_masked_intr_stat; u32 pl310_raw_intr_stat; u32 pl310_intr_clear; u32 pad3[323]; u32 pl310_cache_sync; u32 pad4[15]; u32 pl310_inv_line_pa; u32 pad5[2]; u32 pl310_inv_way; u32 pad6[12]; u32 pl310_clean_line_pa; u32 pad7[1]; u32 pl310_clean_line_idx; u32 pl310_clean_way; u32 pad8[12]; u32 pl310_clean_inv_line_pa; u32 pad9[1]; u32 pl310_clean_inv_line_idx; u32 pl310_clean_inv_way; }; void pl310_inval_all(void); void pl310_clean_inval_all(void); void pl310_inval_range(u32 start, u32 end); void pl310_clean_inval_range(u32 start, u32 end); #endif
1001-study-uboot
arch/arm/include/asm/pl310.h
C
gpl3
1,955
/* * (C) Copyright 2010 * Texas Instruments, <www.ti.com> * * Aneesh V <aneesh@ti.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef _OMAP_COMMON_H_ #define _OMAP_COMMON_H_ /* Max value for DPLL multiplier M */ #define OMAP_DPLL_MAX_N 127 /* HW Init Context */ #define OMAP_INIT_CONTEXT_SPL 0 #define OMAP_INIT_CONTEXT_UBOOT_FROM_NOR 1 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_SPL 2 #define OMAP_INIT_CONTEXT_UBOOT_AFTER_CH 3 void preloader_console_init(void); /* Boot device */ #ifdef CONFIG_OMAP54XX #define BOOT_DEVICE_NONE 0 #define BOOT_DEVICE_XIP 1 #define BOOT_DEVICE_XIPWAIT 2 #define BOOT_DEVICE_NAND 3 #define BOOT_DEVICE_ONE_NAND 4 #define BOOT_DEVICE_MMC1 5 #define BOOT_DEVICE_MMC2 6 #define BOOT_DEVICE_MMC3 7 #elif defined(CONFIG_OMAP44XX) /* OMAP4 */ #define BOOT_DEVICE_NONE 0 #define BOOT_DEVICE_XIP 1 #define BOOT_DEVICE_XIPWAIT 2 #define BOOT_DEVICE_NAND 3 #define BOOT_DEVICE_ONE_NAND 4 #define BOOT_DEVICE_MMC1 5 #define BOOT_DEVICE_MMC2 6 #elif defined(CONFIG_OMAP34XX) /* OMAP3 */ #define BOOT_DEVICE_NONE 0 #define BOOT_DEVICE_XIP 1 #define BOOT_DEVICE_NAND 2 #define BOOT_DEVICE_ONE_NAND 3 #define BOOT_DEVICE_MMC2 5 /*emmc*/ #define BOOT_DEVICE_MMC1 6 #define BOOT_DEVICE_XIPWAIT 7 #endif /* Boot type */ #define MMCSD_MODE_UNDEFINED 0 #define MMCSD_MODE_RAW 1 #define MMCSD_MODE_FAT 2 #define NAND_MODE_HW_ECC 3 struct spl_image_info { const char *name; u8 os; u32 load_addr; u32 entry_point; u32 size; }; extern struct spl_image_info spl_image; extern u32* boot_params_ptr; u32 omap_boot_device(void); u32 omap_boot_mode(void); /* SPL common function s*/ void spl_parse_image_header(const struct image_header *header); void omap_rev_string(char *omap_rev_string); /* NAND SPL functions */ void spl_nand_load_image(void); /* MMC SPL functions */ void spl_mmc_load_image(void); #ifdef CONFIG_SPL_BOARD_INIT void spl_board_init(void); #endif /* * silicon revisions. * Moving this to common, so that most of code can be moved to common, * directories. */ /* omap4 */ #define OMAP4430_SILICON_ID_INVALID 0xFFFFFFFF #define OMAP4430_ES1_0 0x44300100 #define OMAP4430_ES2_0 0x44300200 #define OMAP4430_ES2_1 0x44300210 #define OMAP4430_ES2_2 0x44300220 #define OMAP4430_ES2_3 0x44300230 #define OMAP4460_ES1_0 0x44600100 #define OMAP4460_ES1_1 0x44600110 /* omap5 */ #define OMAP5430_SILICON_ID_INVALID 0 #define OMAP5430_ES1_0 0x54300100 #endif /* _OMAP_COMMON_H_ */
1001-study-uboot
arch/arm/include/asm/omap_common.h
C
gpl3
3,224
/* * linux/include/asm-arm/io.h * * Copyright (C) 1996-2000 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Modifications: * 16-Sep-1996 RMK Inlined the inx/outx functions & optimised for both * constant addresses and variable addresses. * 04-Dec-1997 RMK Moved a lot of this stuff to the new architecture * specific IO header files. * 27-Mar-1999 PJB Second parameter of memcpy_toio is const.. * 04-Apr-1999 PJB Added check_signature. * 12-Dec-1999 RMK More cleanups * 18-Jun-2000 RMK Removed virt_to_* and friends definitions */ #ifndef __ASM_ARM_IO_H #define __ASM_ARM_IO_H #ifdef __KERNEL__ #include <linux/types.h> #include <asm/byteorder.h> #include <asm/memory.h> #if 0 /* XXX###XXX */ #include <asm/arch/hardware.h> #endif /* XXX###XXX */ static inline void sync(void) { } /* * Given a physical address and a length, return a virtual address * that can be used to access the memory range with the caching * properties specified by "flags". */ #define MAP_NOCACHE (0) #define MAP_WRCOMBINE (0) #define MAP_WRBACK (0) #define MAP_WRTHROUGH (0) static inline void * map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags) { return (void *)paddr; } /* * Take down a mapping set up by map_physmem(). */ static inline void unmap_physmem(void *vaddr, unsigned long flags) { } static inline phys_addr_t virt_to_phys(void * vaddr) { return (phys_addr_t)(vaddr); } /* * Generic virtual read/write. Note that we don't support half-word * read/writes. We define __arch_*[bl] here, and leave __arch_*w * to the architecture specific code. */ #define __arch_getb(a) (*(volatile unsigned char *)(a)) #define __arch_getw(a) (*(volatile unsigned short *)(a)) #define __arch_getl(a) (*(volatile unsigned int *)(a)) #define __arch_putb(v,a) (*(volatile unsigned char *)(a) = (v)) #define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v)) #define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v)) extern inline void __raw_writesb(unsigned int addr, const void *data, int bytelen) { uint8_t *buf = (uint8_t *)data; while(bytelen--) __arch_putb(*buf++, addr); } extern inline void __raw_writesw(unsigned int addr, const void *data, int wordlen) { uint16_t *buf = (uint16_t *)data; while(wordlen--) __arch_putw(*buf++, addr); } extern inline void __raw_writesl(unsigned int addr, const void *data, int longlen) { uint32_t *buf = (uint32_t *)data; while(longlen--) __arch_putl(*buf++, addr); } extern inline void __raw_readsb(unsigned int addr, void *data, int bytelen) { uint8_t *buf = (uint8_t *)data; while(bytelen--) *buf++ = __arch_getb(addr); } extern inline void __raw_readsw(unsigned int addr, void *data, int wordlen) { uint16_t *buf = (uint16_t *)data; while(wordlen--) *buf++ = __arch_getw(addr); } extern inline void __raw_readsl(unsigned int addr, void *data, int longlen) { uint32_t *buf = (uint32_t *)data; while(longlen--) *buf++ = __arch_getl(addr); } #define __raw_writeb(v,a) __arch_putb(v,a) #define __raw_writew(v,a) __arch_putw(v,a) #define __raw_writel(v,a) __arch_putl(v,a) #define __raw_readb(a) __arch_getb(a) #define __raw_readw(a) __arch_getw(a) #define __raw_readl(a) __arch_getl(a) /* * TODO: The kernel offers some more advanced versions of barriers, it might * have some advantages to use them instead of the simple one here. */ #define dmb() __asm__ __volatile__ ("" : : : "memory") #define __iormb() dmb() #define __iowmb() dmb() #define writeb(v,c) ({ u8 __v = v; __iowmb(); __arch_putb(__v,c); __v; }) #define writew(v,c) ({ u16 __v = v; __iowmb(); __arch_putw(__v,c); __v; }) #define writel(v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; }) #define readb(c) ({ u8 __v = __arch_getb(c); __iormb(); __v; }) #define readw(c) ({ u16 __v = __arch_getw(c); __iormb(); __v; }) #define readl(c) ({ u32 __v = __arch_getl(c); __iormb(); __v; }) /* * The compiler seems to be incapable of optimising constants * properly. Spell it out to the compiler in some cases. * These are only valid for small values of "off" (< 1<<12) */ #define __raw_base_writeb(val,base,off) __arch_base_putb(val,base,off) #define __raw_base_writew(val,base,off) __arch_base_putw(val,base,off) #define __raw_base_writel(val,base,off) __arch_base_putl(val,base,off) #define __raw_base_readb(base,off) __arch_base_getb(base,off) #define __raw_base_readw(base,off) __arch_base_getw(base,off) #define __raw_base_readl(base,off) __arch_base_getl(base,off) /* * Clear and set bits in one shot. These macros can be used to clear and * set multiple bits in a register using a single call. These macros can * also be used to set a multiple-bit bit pattern using a mask, by * specifying the mask in the 'clear' parameter and the new bit pattern * in the 'set' parameter. */ #define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a) #define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a)) #define out_le32(a,v) out_arch(l,le32,a,v) #define out_le16(a,v) out_arch(w,le16,a,v) #define in_le32(a) in_arch(l,le32,a) #define in_le16(a) in_arch(w,le16,a) #define out_be32(a,v) out_arch(l,be32,a,v) #define out_be16(a,v) out_arch(w,be16,a,v) #define in_be32(a) in_arch(l,be32,a) #define in_be16(a) in_arch(w,be16,a) #define out_8(a,v) __raw_writeb(v,a) #define in_8(a) __raw_readb(a) #define clrbits(type, addr, clear) \ out_##type((addr), in_##type(addr) & ~(clear)) #define setbits(type, addr, set) \ out_##type((addr), in_##type(addr) | (set)) #define clrsetbits(type, addr, clear, set) \ out_##type((addr), (in_##type(addr) & ~(clear)) | (set)) #define clrbits_be32(addr, clear) clrbits(be32, addr, clear) #define setbits_be32(addr, set) setbits(be32, addr, set) #define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set) #define clrbits_le32(addr, clear) clrbits(le32, addr, clear) #define setbits_le32(addr, set) setbits(le32, addr, set) #define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set) #define clrbits_be16(addr, clear) clrbits(be16, addr, clear) #define setbits_be16(addr, set) setbits(be16, addr, set) #define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set) #define clrbits_le16(addr, clear) clrbits(le16, addr, clear) #define setbits_le16(addr, set) setbits(le16, addr, set) #define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set) #define clrbits_8(addr, clear) clrbits(8, addr, clear) #define setbits_8(addr, set) setbits(8, addr, set) #define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) /* * Now, pick up the machine-defined IO definitions */ #if 0 /* XXX###XXX */ #include <asm/arch/io.h> #endif /* XXX###XXX */ /* * IO port access primitives * ------------------------- * * The ARM doesn't have special IO access instructions; all IO is memory * mapped. Note that these are defined to perform little endian accesses * only. Their primary purpose is to access PCI and ISA peripherals. * * Note that for a big endian machine, this implies that the following * big endian mode connectivity is in place, as described by numerous * ARM documents: * * PCI: D0-D7 D8-D15 D16-D23 D24-D31 * ARM: D24-D31 D16-D23 D8-D15 D0-D7 * * The machine specific io.h include defines __io to translate an "IO" * address to a memory address. * * Note that we prevent GCC re-ordering or caching values in expressions * by introducing sequence points into the in*() definitions. Note that * __raw_* do not guarantee this behaviour. * * The {in,out}[bwl] macros are for emulating x86-style PCI/ISA IO space. */ #ifdef __io #define outb(v,p) __raw_writeb(v,__io(p)) #define outw(v,p) __raw_writew(cpu_to_le16(v),__io(p)) #define outl(v,p) __raw_writel(cpu_to_le32(v),__io(p)) #define inb(p) ({ unsigned int __v = __raw_readb(__io(p)); __v; }) #define inw(p) ({ unsigned int __v = le16_to_cpu(__raw_readw(__io(p))); __v; }) #define inl(p) ({ unsigned int __v = le32_to_cpu(__raw_readl(__io(p))); __v; }) #define outsb(p,d,l) __raw_writesb(__io(p),d,l) #define outsw(p,d,l) __raw_writesw(__io(p),d,l) #define outsl(p,d,l) __raw_writesl(__io(p),d,l) #define insb(p,d,l) __raw_readsb(__io(p),d,l) #define insw(p,d,l) __raw_readsw(__io(p),d,l) #define insl(p,d,l) __raw_readsl(__io(p),d,l) #endif #define outb_p(val,port) outb((val),(port)) #define outw_p(val,port) outw((val),(port)) #define outl_p(val,port) outl((val),(port)) #define inb_p(port) inb((port)) #define inw_p(port) inw((port)) #define inl_p(port) inl((port)) #define outsb_p(port,from,len) outsb(port,from,len) #define outsw_p(port,from,len) outsw(port,from,len) #define outsl_p(port,from,len) outsl(port,from,len) #define insb_p(port,to,len) insb(port,to,len) #define insw_p(port,to,len) insw(port,to,len) #define insl_p(port,to,len) insl(port,to,len) /* * ioremap and friends. * * ioremap takes a PCI memory address, as specified in * linux/Documentation/IO-mapping.txt. If you want a * physical address, use __ioremap instead. */ extern void * __ioremap(unsigned long offset, size_t size, unsigned long flags); extern void __iounmap(void *addr); /* * Generic ioremap support. * * Define: * iomem_valid_addr(off,size) * iomem_to_phys(off) */ #ifdef iomem_valid_addr #define __arch_ioremap(off,sz,nocache) \ ({ \ unsigned long _off = (off), _size = (sz); \ void *_ret = (void *)0; \ if (iomem_valid_addr(_off, _size)) \ _ret = __ioremap(iomem_to_phys(_off),_size,nocache); \ _ret; \ }) #define __arch_iounmap __iounmap #endif #define ioremap(off,sz) __arch_ioremap((off),(sz),0) #define ioremap_nocache(off,sz) __arch_ioremap((off),(sz),1) #define iounmap(_addr) __arch_iounmap(_addr) /* * DMA-consistent mapping functions. These allocate/free a region of * uncached, unwrite-buffered mapped memory space for use with DMA * devices. This is the "generic" version. The PCI specific version * is in pci.h */ extern void *consistent_alloc(int gfp, size_t size, dma_addr_t *handle); extern void consistent_free(void *vaddr, size_t size, dma_addr_t handle); extern void consistent_sync(void *vaddr, size_t size, int rw); /* * String version of IO memory access ops: */ extern void _memcpy_fromio(void *, unsigned long, size_t); extern void _memcpy_toio(unsigned long, const void *, size_t); extern void _memset_io(unsigned long, int, size_t); extern void __readwrite_bug(const char *fn); /* * If this architecture has PCI memory IO, then define the read/write * macros. These should only be used with the cookie passed from * ioremap. */ #ifdef __mem_pci #define readb(c) ({ unsigned int __v = __raw_readb(__mem_pci(c)); __v; }) #define readw(c) ({ unsigned int __v = le16_to_cpu(__raw_readw(__mem_pci(c))); __v; }) #define readl(c) ({ unsigned int __v = le32_to_cpu(__raw_readl(__mem_pci(c))); __v; }) #define writeb(v,c) __raw_writeb(v,__mem_pci(c)) #define writew(v,c) __raw_writew(cpu_to_le16(v),__mem_pci(c)) #define writel(v,c) __raw_writel(cpu_to_le32(v),__mem_pci(c)) #define memset_io(c,v,l) _memset_io(__mem_pci(c),(v),(l)) #define memcpy_fromio(a,c,l) _memcpy_fromio((a),__mem_pci(c),(l)) #define memcpy_toio(c,a,l) _memcpy_toio(__mem_pci(c),(a),(l)) #define eth_io_copy_and_sum(s,c,l,b) \ eth_copy_and_sum((s),__mem_pci(c),(l),(b)) static inline int check_signature(unsigned long io_addr, const unsigned char *signature, int length) { int retval = 0; do { if (readb(io_addr) != *signature) goto out; io_addr++; signature++; length--; } while (length); retval = 1; out: return retval; } #elif !defined(readb) #define readb(addr) (__readwrite_bug("readb"),0) #define readw(addr) (__readwrite_bug("readw"),0) #define readl(addr) (__readwrite_bug("readl"),0) #define writeb(v,addr) __readwrite_bug("writeb") #define writew(v,addr) __readwrite_bug("writew") #define writel(v,addr) __readwrite_bug("writel") #define eth_io_copy_and_sum(a,b,c,d) __readwrite_bug("eth_io_copy_and_sum") #define check_signature(io,sig,len) (0) #endif /* __mem_pci */ /* * If this architecture has ISA IO, then define the isa_read/isa_write * macros. */ #ifdef __mem_isa #define isa_readb(addr) __raw_readb(__mem_isa(addr)) #define isa_readw(addr) __raw_readw(__mem_isa(addr)) #define isa_readl(addr) __raw_readl(__mem_isa(addr)) #define isa_writeb(val,addr) __raw_writeb(val,__mem_isa(addr)) #define isa_writew(val,addr) __raw_writew(val,__mem_isa(addr)) #define isa_writel(val,addr) __raw_writel(val,__mem_isa(addr)) #define isa_memset_io(a,b,c) _memset_io(__mem_isa(a),(b),(c)) #define isa_memcpy_fromio(a,b,c) _memcpy_fromio((a),__mem_isa(b),(c)) #define isa_memcpy_toio(a,b,c) _memcpy_toio(__mem_isa((a)),(b),(c)) #define isa_eth_io_copy_and_sum(a,b,c,d) \ eth_copy_and_sum((a),__mem_isa(b),(c),(d)) static inline int isa_check_signature(unsigned long io_addr, const unsigned char *signature, int length) { int retval = 0; do { if (isa_readb(io_addr) != *signature) goto out; io_addr++; signature++; length--; } while (length); retval = 1; out: return retval; } #else /* __mem_isa */ #define isa_readb(addr) (__readwrite_bug("isa_readb"),0) #define isa_readw(addr) (__readwrite_bug("isa_readw"),0) #define isa_readl(addr) (__readwrite_bug("isa_readl"),0) #define isa_writeb(val,addr) __readwrite_bug("isa_writeb") #define isa_writew(val,addr) __readwrite_bug("isa_writew") #define isa_writel(val,addr) __readwrite_bug("isa_writel") #define isa_memset_io(a,b,c) __readwrite_bug("isa_memset_io") #define isa_memcpy_fromio(a,b,c) __readwrite_bug("isa_memcpy_fromio") #define isa_memcpy_toio(a,b,c) __readwrite_bug("isa_memcpy_toio") #define isa_eth_io_copy_and_sum(a,b,c,d) \ __readwrite_bug("isa_eth_io_copy_and_sum") #define isa_check_signature(io,sig,len) (0) #endif /* __mem_isa */ #endif /* __KERNEL__ */ #endif /* __ASM_ARM_IO_H */
1001-study-uboot
arch/arm/include/asm/io.h
C
gpl3
14,079
/* * OMAP44xx EMIF header * * Copyright (C) 2009-2010 Texas Instruments, Inc. * * Aneesh V <aneesh@ti.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _EMIF_H_ #define _EMIF_H_ #include <asm/types.h> #include <common.h> /* Base address */ #define EMIF1_BASE 0x4c000000 #define EMIF2_BASE 0x4d000000 /* Registers shifts and masks */ /* EMIF_MOD_ID_REV */ #define EMIF_REG_SCHEME_SHIFT 30 #define EMIF_REG_SCHEME_MASK (0x3 << 30) #define EMIF_REG_MODULE_ID_SHIFT 16 #define EMIF_REG_MODULE_ID_MASK (0xfff << 16) #define EMIF_REG_RTL_VERSION_SHIFT 11 #define EMIF_REG_RTL_VERSION_MASK (0x1f << 11) #define EMIF_REG_MAJOR_REVISION_SHIFT 8 #define EMIF_REG_MAJOR_REVISION_MASK (0x7 << 8) #define EMIF_REG_MINOR_REVISION_SHIFT 0 #define EMIF_REG_MINOR_REVISION_MASK (0x3f << 0) /* STATUS */ #define EMIF_REG_BE_SHIFT 31 #define EMIF_REG_BE_MASK (1 << 31) #define EMIF_REG_DUAL_CLK_MODE_SHIFT 30 #define EMIF_REG_DUAL_CLK_MODE_MASK (1 << 30) #define EMIF_REG_FAST_INIT_SHIFT 29 #define EMIF_REG_FAST_INIT_MASK (1 << 29) #define EMIF_REG_PHY_DLL_READY_SHIFT 2 #define EMIF_REG_PHY_DLL_READY_MASK (1 << 2) /* SDRAM_CONFIG */ #define EMIF_REG_SDRAM_TYPE_SHIFT 29 #define EMIF_REG_SDRAM_TYPE_MASK (0x7 << 29) #define EMIF_REG_IBANK_POS_SHIFT 27 #define EMIF_REG_IBANK_POS_MASK (0x3 << 27) #define EMIF_REG_DDR_TERM_SHIFT 24 #define EMIF_REG_DDR_TERM_MASK (0x7 << 24) #define EMIF_REG_DDR2_DDQS_SHIFT 23 #define EMIF_REG_DDR2_DDQS_MASK (1 << 23) #define EMIF_REG_DYN_ODT_SHIFT 21 #define EMIF_REG_DYN_ODT_MASK (0x3 << 21) #define EMIF_REG_DDR_DISABLE_DLL_SHIFT 20 #define EMIF_REG_DDR_DISABLE_DLL_MASK (1 << 20) #define EMIF_REG_SDRAM_DRIVE_SHIFT 18 #define EMIF_REG_SDRAM_DRIVE_MASK (0x3 << 18) #define EMIF_REG_CWL_SHIFT 16 #define EMIF_REG_CWL_MASK (0x3 << 16) #define EMIF_REG_NARROW_MODE_SHIFT 14 #define EMIF_REG_NARROW_MODE_MASK (0x3 << 14) #define EMIF_REG_CL_SHIFT 10 #define EMIF_REG_CL_MASK (0xf << 10) #define EMIF_REG_ROWSIZE_SHIFT 7 #define EMIF_REG_ROWSIZE_MASK (0x7 << 7) #define EMIF_REG_IBANK_SHIFT 4 #define EMIF_REG_IBANK_MASK (0x7 << 4) #define EMIF_REG_EBANK_SHIFT 3 #define EMIF_REG_EBANK_MASK (1 << 3) #define EMIF_REG_PAGESIZE_SHIFT 0 #define EMIF_REG_PAGESIZE_MASK (0x7 << 0) /* SDRAM_CONFIG_2 */ #define EMIF_REG_CS1NVMEN_SHIFT 30 #define EMIF_REG_CS1NVMEN_MASK (1 << 30) #define EMIF_REG_EBANK_POS_SHIFT 27 #define EMIF_REG_EBANK_POS_MASK (1 << 27) #define EMIF_REG_RDBNUM_SHIFT 4 #define EMIF_REG_RDBNUM_MASK (0x3 << 4) #define EMIF_REG_RDBSIZE_SHIFT 0 #define EMIF_REG_RDBSIZE_MASK (0x7 << 0) /* SDRAM_REF_CTRL */ #define EMIF_REG_INITREF_DIS_SHIFT 31 #define EMIF_REG_INITREF_DIS_MASK (1 << 31) #define EMIF_REG_SRT_SHIFT 29 #define EMIF_REG_SRT_MASK (1 << 29) #define EMIF_REG_ASR_SHIFT 28 #define EMIF_REG_ASR_MASK (1 << 28) #define EMIF_REG_PASR_SHIFT 24 #define EMIF_REG_PASR_MASK (0x7 << 24) #define EMIF_REG_REFRESH_RATE_SHIFT 0 #define EMIF_REG_REFRESH_RATE_MASK (0xffff << 0) /* SDRAM_REF_CTRL_SHDW */ #define EMIF_REG_REFRESH_RATE_SHDW_SHIFT 0 #define EMIF_REG_REFRESH_RATE_SHDW_MASK (0xffff << 0) /* SDRAM_TIM_1 */ #define EMIF_REG_T_RP_SHIFT 25 #define EMIF_REG_T_RP_MASK (0xf << 25) #define EMIF_REG_T_RCD_SHIFT 21 #define EMIF_REG_T_RCD_MASK (0xf << 21) #define EMIF_REG_T_WR_SHIFT 17 #define EMIF_REG_T_WR_MASK (0xf << 17) #define EMIF_REG_T_RAS_SHIFT 12 #define EMIF_REG_T_RAS_MASK (0x1f << 12) #define EMIF_REG_T_RC_SHIFT 6 #define EMIF_REG_T_RC_MASK (0x3f << 6) #define EMIF_REG_T_RRD_SHIFT 3 #define EMIF_REG_T_RRD_MASK (0x7 << 3) #define EMIF_REG_T_WTR_SHIFT 0 #define EMIF_REG_T_WTR_MASK (0x7 << 0) /* SDRAM_TIM_1_SHDW */ #define EMIF_REG_T_RP_SHDW_SHIFT 25 #define EMIF_REG_T_RP_SHDW_MASK (0xf << 25) #define EMIF_REG_T_RCD_SHDW_SHIFT 21 #define EMIF_REG_T_RCD_SHDW_MASK (0xf << 21) #define EMIF_REG_T_WR_SHDW_SHIFT 17 #define EMIF_REG_T_WR_SHDW_MASK (0xf << 17) #define EMIF_REG_T_RAS_SHDW_SHIFT 12 #define EMIF_REG_T_RAS_SHDW_MASK (0x1f << 12) #define EMIF_REG_T_RC_SHDW_SHIFT 6 #define EMIF_REG_T_RC_SHDW_MASK (0x3f << 6) #define EMIF_REG_T_RRD_SHDW_SHIFT 3 #define EMIF_REG_T_RRD_SHDW_MASK (0x7 << 3) #define EMIF_REG_T_WTR_SHDW_SHIFT 0 #define EMIF_REG_T_WTR_SHDW_MASK (0x7 << 0) /* SDRAM_TIM_2 */ #define EMIF_REG_T_XP_SHIFT 28 #define EMIF_REG_T_XP_MASK (0x7 << 28) #define EMIF_REG_T_ODT_SHIFT 25 #define EMIF_REG_T_ODT_MASK (0x7 << 25) #define EMIF_REG_T_XSNR_SHIFT 16 #define EMIF_REG_T_XSNR_MASK (0x1ff << 16) #define EMIF_REG_T_XSRD_SHIFT 6 #define EMIF_REG_T_XSRD_MASK (0x3ff << 6) #define EMIF_REG_T_RTP_SHIFT 3 #define EMIF_REG_T_RTP_MASK (0x7 << 3) #define EMIF_REG_T_CKE_SHIFT 0 #define EMIF_REG_T_CKE_MASK (0x7 << 0) /* SDRAM_TIM_2_SHDW */ #define EMIF_REG_T_XP_SHDW_SHIFT 28 #define EMIF_REG_T_XP_SHDW_MASK (0x7 << 28) #define EMIF_REG_T_ODT_SHDW_SHIFT 25 #define EMIF_REG_T_ODT_SHDW_MASK (0x7 << 25) #define EMIF_REG_T_XSNR_SHDW_SHIFT 16 #define EMIF_REG_T_XSNR_SHDW_MASK (0x1ff << 16) #define EMIF_REG_T_XSRD_SHDW_SHIFT 6 #define EMIF_REG_T_XSRD_SHDW_MASK (0x3ff << 6) #define EMIF_REG_T_RTP_SHDW_SHIFT 3 #define EMIF_REG_T_RTP_SHDW_MASK (0x7 << 3) #define EMIF_REG_T_CKE_SHDW_SHIFT 0 #define EMIF_REG_T_CKE_SHDW_MASK (0x7 << 0) /* SDRAM_TIM_3 */ #define EMIF_REG_T_CKESR_SHIFT 21 #define EMIF_REG_T_CKESR_MASK (0x7 << 21) #define EMIF_REG_ZQ_ZQCS_SHIFT 15 #define EMIF_REG_ZQ_ZQCS_MASK (0x3f << 15) #define EMIF_REG_T_TDQSCKMAX_SHIFT 13 #define EMIF_REG_T_TDQSCKMAX_MASK (0x3 << 13) #define EMIF_REG_T_RFC_SHIFT 4 #define EMIF_REG_T_RFC_MASK (0x1ff << 4) #define EMIF_REG_T_RAS_MAX_SHIFT 0 #define EMIF_REG_T_RAS_MAX_MASK (0xf << 0) /* SDRAM_TIM_3_SHDW */ #define EMIF_REG_T_CKESR_SHDW_SHIFT 21 #define EMIF_REG_T_CKESR_SHDW_MASK (0x7 << 21) #define EMIF_REG_ZQ_ZQCS_SHDW_SHIFT 15 #define EMIF_REG_ZQ_ZQCS_SHDW_MASK (0x3f << 15) #define EMIF_REG_T_TDQSCKMAX_SHDW_SHIFT 13 #define EMIF_REG_T_TDQSCKMAX_SHDW_MASK (0x3 << 13) #define EMIF_REG_T_RFC_SHDW_SHIFT 4 #define EMIF_REG_T_RFC_SHDW_MASK (0x1ff << 4) #define EMIF_REG_T_RAS_MAX_SHDW_SHIFT 0 #define EMIF_REG_T_RAS_MAX_SHDW_MASK (0xf << 0) /* LPDDR2_NVM_TIM */ #define EMIF_REG_NVM_T_XP_SHIFT 28 #define EMIF_REG_NVM_T_XP_MASK (0x7 << 28) #define EMIF_REG_NVM_T_WTR_SHIFT 24 #define EMIF_REG_NVM_T_WTR_MASK (0x7 << 24) #define EMIF_REG_NVM_T_RP_SHIFT 20 #define EMIF_REG_NVM_T_RP_MASK (0xf << 20) #define EMIF_REG_NVM_T_WRA_SHIFT 16 #define EMIF_REG_NVM_T_WRA_MASK (0xf << 16) #define EMIF_REG_NVM_T_RRD_SHIFT 8 #define EMIF_REG_NVM_T_RRD_MASK (0xff << 8) #define EMIF_REG_NVM_T_RCDMIN_SHIFT 0 #define EMIF_REG_NVM_T_RCDMIN_MASK (0xff << 0) /* LPDDR2_NVM_TIM_SHDW */ #define EMIF_REG_NVM_T_XP_SHDW_SHIFT 28 #define EMIF_REG_NVM_T_XP_SHDW_MASK (0x7 << 28) #define EMIF_REG_NVM_T_WTR_SHDW_SHIFT 24 #define EMIF_REG_NVM_T_WTR_SHDW_MASK (0x7 << 24) #define EMIF_REG_NVM_T_RP_SHDW_SHIFT 20 #define EMIF_REG_NVM_T_RP_SHDW_MASK (0xf << 20) #define EMIF_REG_NVM_T_WRA_SHDW_SHIFT 16 #define EMIF_REG_NVM_T_WRA_SHDW_MASK (0xf << 16) #define EMIF_REG_NVM_T_RRD_SHDW_SHIFT 8 #define EMIF_REG_NVM_T_RRD_SHDW_MASK (0xff << 8) #define EMIF_REG_NVM_T_RCDMIN_SHDW_SHIFT 0 #define EMIF_REG_NVM_T_RCDMIN_SHDW_MASK (0xff << 0) /* PWR_MGMT_CTRL */ #define EMIF_REG_IDLEMODE_SHIFT 30 #define EMIF_REG_IDLEMODE_MASK (0x3 << 30) #define EMIF_REG_PD_TIM_SHIFT 12 #define EMIF_REG_PD_TIM_MASK (0xf << 12) #define EMIF_REG_DPD_EN_SHIFT 11 #define EMIF_REG_DPD_EN_MASK (1 << 11) #define EMIF_REG_LP_MODE_SHIFT 8 #define EMIF_REG_LP_MODE_MASK (0x7 << 8) #define EMIF_REG_SR_TIM_SHIFT 4 #define EMIF_REG_SR_TIM_MASK (0xf << 4) #define EMIF_REG_CS_TIM_SHIFT 0 #define EMIF_REG_CS_TIM_MASK (0xf << 0) /* PWR_MGMT_CTRL_SHDW */ #define EMIF_REG_PD_TIM_SHDW_SHIFT 8 #define EMIF_REG_PD_TIM_SHDW_MASK (0xf << 8) #define EMIF_REG_SR_TIM_SHDW_SHIFT 4 #define EMIF_REG_SR_TIM_SHDW_MASK (0xf << 4) #define EMIF_REG_CS_TIM_SHDW_SHIFT 0 #define EMIF_REG_CS_TIM_SHDW_MASK (0xf << 0) /* LPDDR2_MODE_REG_DATA */ #define EMIF_REG_VALUE_0_SHIFT 0 #define EMIF_REG_VALUE_0_MASK (0x7f << 0) /* LPDDR2_MODE_REG_CFG */ #define EMIF_REG_CS_SHIFT 31 #define EMIF_REG_CS_MASK (1 << 31) #define EMIF_REG_REFRESH_EN_SHIFT 30 #define EMIF_REG_REFRESH_EN_MASK (1 << 30) #define EMIF_REG_ADDRESS_SHIFT 0 #define EMIF_REG_ADDRESS_MASK (0xff << 0) /* OCP_CONFIG */ #define EMIF_REG_SYS_THRESH_MAX_SHIFT 24 #define EMIF_REG_SYS_THRESH_MAX_MASK (0xf << 24) #define EMIF_REG_MPU_THRESH_MAX_SHIFT 20 #define EMIF_REG_MPU_THRESH_MAX_MASK (0xf << 20) #define EMIF_REG_LL_THRESH_MAX_SHIFT 16 #define EMIF_REG_LL_THRESH_MAX_MASK (0xf << 16) #define EMIF_REG_PR_OLD_COUNT_SHIFT 0 #define EMIF_REG_PR_OLD_COUNT_MASK (0xff << 0) /* OCP_CFG_VAL_1 */ #define EMIF_REG_SYS_BUS_WIDTH_SHIFT 30 #define EMIF_REG_SYS_BUS_WIDTH_MASK (0x3 << 30) #define EMIF_REG_LL_BUS_WIDTH_SHIFT 28 #define EMIF_REG_LL_BUS_WIDTH_MASK (0x3 << 28) #define EMIF_REG_WR_FIFO_DEPTH_SHIFT 8 #define EMIF_REG_WR_FIFO_DEPTH_MASK (0xff << 8) #define EMIF_REG_CMD_FIFO_DEPTH_SHIFT 0 #define EMIF_REG_CMD_FIFO_DEPTH_MASK (0xff << 0) /* OCP_CFG_VAL_2 */ #define EMIF_REG_RREG_FIFO_DEPTH_SHIFT 16 #define EMIF_REG_RREG_FIFO_DEPTH_MASK (0xff << 16) #define EMIF_REG_RSD_FIFO_DEPTH_SHIFT 8 #define EMIF_REG_RSD_FIFO_DEPTH_MASK (0xff << 8) #define EMIF_REG_RCMD_FIFO_DEPTH_SHIFT 0 #define EMIF_REG_RCMD_FIFO_DEPTH_MASK (0xff << 0) /* IODFT_TLGC */ #define EMIF_REG_TLEC_SHIFT 16 #define EMIF_REG_TLEC_MASK (0xffff << 16) #define EMIF_REG_MT_SHIFT 14 #define EMIF_REG_MT_MASK (1 << 14) #define EMIF_REG_ACT_CAP_EN_SHIFT 13 #define EMIF_REG_ACT_CAP_EN_MASK (1 << 13) #define EMIF_REG_OPG_LD_SHIFT 12 #define EMIF_REG_OPG_LD_MASK (1 << 12) #define EMIF_REG_RESET_PHY_SHIFT 10 #define EMIF_REG_RESET_PHY_MASK (1 << 10) #define EMIF_REG_MMS_SHIFT 8 #define EMIF_REG_MMS_MASK (1 << 8) #define EMIF_REG_MC_SHIFT 4 #define EMIF_REG_MC_MASK (0x3 << 4) #define EMIF_REG_PC_SHIFT 1 #define EMIF_REG_PC_MASK (0x7 << 1) #define EMIF_REG_TM_SHIFT 0 #define EMIF_REG_TM_MASK (1 << 0) /* IODFT_CTRL_MISR_RSLT */ #define EMIF_REG_DQM_TLMR_SHIFT 16 #define EMIF_REG_DQM_TLMR_MASK (0x3ff << 16) #define EMIF_REG_CTL_TLMR_SHIFT 0 #define EMIF_REG_CTL_TLMR_MASK (0x7ff << 0) /* IODFT_ADDR_MISR_RSLT */ #define EMIF_REG_ADDR_TLMR_SHIFT 0 #define EMIF_REG_ADDR_TLMR_MASK (0x1fffff << 0) /* IODFT_DATA_MISR_RSLT_1 */ #define EMIF_REG_DATA_TLMR_31_0_SHIFT 0 #define EMIF_REG_DATA_TLMR_31_0_MASK (0xffffffff << 0) /* IODFT_DATA_MISR_RSLT_2 */ #define EMIF_REG_DATA_TLMR_63_32_SHIFT 0 #define EMIF_REG_DATA_TLMR_63_32_MASK (0xffffffff << 0) /* IODFT_DATA_MISR_RSLT_3 */ #define EMIF_REG_DATA_TLMR_66_64_SHIFT 0 #define EMIF_REG_DATA_TLMR_66_64_MASK (0x7 << 0) /* PERF_CNT_1 */ #define EMIF_REG_COUNTER1_SHIFT 0 #define EMIF_REG_COUNTER1_MASK (0xffffffff << 0) /* PERF_CNT_2 */ #define EMIF_REG_COUNTER2_SHIFT 0 #define EMIF_REG_COUNTER2_MASK (0xffffffff << 0) /* PERF_CNT_CFG */ #define EMIF_REG_CNTR2_MCONNID_EN_SHIFT 31 #define EMIF_REG_CNTR2_MCONNID_EN_MASK (1 << 31) #define EMIF_REG_CNTR2_REGION_EN_SHIFT 30 #define EMIF_REG_CNTR2_REGION_EN_MASK (1 << 30) #define EMIF_REG_CNTR2_CFG_SHIFT 16 #define EMIF_REG_CNTR2_CFG_MASK (0xf << 16) #define EMIF_REG_CNTR1_MCONNID_EN_SHIFT 15 #define EMIF_REG_CNTR1_MCONNID_EN_MASK (1 << 15) #define EMIF_REG_CNTR1_REGION_EN_SHIFT 14 #define EMIF_REG_CNTR1_REGION_EN_MASK (1 << 14) #define EMIF_REG_CNTR1_CFG_SHIFT 0 #define EMIF_REG_CNTR1_CFG_MASK (0xf << 0) /* PERF_CNT_SEL */ #define EMIF_REG_MCONNID2_SHIFT 24 #define EMIF_REG_MCONNID2_MASK (0xff << 24) #define EMIF_REG_REGION_SEL2_SHIFT 16 #define EMIF_REG_REGION_SEL2_MASK (0x3 << 16) #define EMIF_REG_MCONNID1_SHIFT 8 #define EMIF_REG_MCONNID1_MASK (0xff << 8) #define EMIF_REG_REGION_SEL1_SHIFT 0 #define EMIF_REG_REGION_SEL1_MASK (0x3 << 0) /* PERF_CNT_TIM */ #define EMIF_REG_TOTAL_TIME_SHIFT 0 #define EMIF_REG_TOTAL_TIME_MASK (0xffffffff << 0) /* READ_IDLE_CTRL */ #define EMIF_REG_READ_IDLE_LEN_SHIFT 16 #define EMIF_REG_READ_IDLE_LEN_MASK (0xf << 16) #define EMIF_REG_READ_IDLE_INTERVAL_SHIFT 0 #define EMIF_REG_READ_IDLE_INTERVAL_MASK (0x1ff << 0) /* READ_IDLE_CTRL_SHDW */ #define EMIF_REG_READ_IDLE_LEN_SHDW_SHIFT 16 #define EMIF_REG_READ_IDLE_LEN_SHDW_MASK (0xf << 16) #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_SHIFT 0 #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_MASK (0x1ff << 0) /* IRQ_EOI */ #define EMIF_REG_EOI_SHIFT 0 #define EMIF_REG_EOI_MASK (1 << 0) /* IRQSTATUS_RAW_SYS */ #define EMIF_REG_DNV_SYS_SHIFT 2 #define EMIF_REG_DNV_SYS_MASK (1 << 2) #define EMIF_REG_TA_SYS_SHIFT 1 #define EMIF_REG_TA_SYS_MASK (1 << 1) #define EMIF_REG_ERR_SYS_SHIFT 0 #define EMIF_REG_ERR_SYS_MASK (1 << 0) /* IRQSTATUS_RAW_LL */ #define EMIF_REG_DNV_LL_SHIFT 2 #define EMIF_REG_DNV_LL_MASK (1 << 2) #define EMIF_REG_TA_LL_SHIFT 1 #define EMIF_REG_TA_LL_MASK (1 << 1) #define EMIF_REG_ERR_LL_SHIFT 0 #define EMIF_REG_ERR_LL_MASK (1 << 0) /* IRQSTATUS_SYS */ /* IRQSTATUS_LL */ /* IRQENABLE_SET_SYS */ #define EMIF_REG_EN_DNV_SYS_SHIFT 2 #define EMIF_REG_EN_DNV_SYS_MASK (1 << 2) #define EMIF_REG_EN_TA_SYS_SHIFT 1 #define EMIF_REG_EN_TA_SYS_MASK (1 << 1) #define EMIF_REG_EN_ERR_SYS_SHIFT 0 #define EMIF_REG_EN_ERR_SYS_MASK (1 << 0) /* IRQENABLE_SET_LL */ #define EMIF_REG_EN_DNV_LL_SHIFT 2 #define EMIF_REG_EN_DNV_LL_MASK (1 << 2) #define EMIF_REG_EN_TA_LL_SHIFT 1 #define EMIF_REG_EN_TA_LL_MASK (1 << 1) #define EMIF_REG_EN_ERR_LL_SHIFT 0 #define EMIF_REG_EN_ERR_LL_MASK (1 << 0) /* IRQENABLE_CLR_SYS */ /* IRQENABLE_CLR_LL */ /* ZQ_CONFIG */ #define EMIF_REG_ZQ_CS1EN_SHIFT 31 #define EMIF_REG_ZQ_CS1EN_MASK (1 << 31) #define EMIF_REG_ZQ_CS0EN_SHIFT 30 #define EMIF_REG_ZQ_CS0EN_MASK (1 << 30) #define EMIF_REG_ZQ_DUALCALEN_SHIFT 29 #define EMIF_REG_ZQ_DUALCALEN_MASK (1 << 29) #define EMIF_REG_ZQ_SFEXITEN_SHIFT 28 #define EMIF_REG_ZQ_SFEXITEN_MASK (1 << 28) #define EMIF_REG_ZQ_ZQINIT_MULT_SHIFT 18 #define EMIF_REG_ZQ_ZQINIT_MULT_MASK (0x3 << 18) #define EMIF_REG_ZQ_ZQCL_MULT_SHIFT 16 #define EMIF_REG_ZQ_ZQCL_MULT_MASK (0x3 << 16) #define EMIF_REG_ZQ_REFINTERVAL_SHIFT 0 #define EMIF_REG_ZQ_REFINTERVAL_MASK (0xffff << 0) /* TEMP_ALERT_CONFIG */ #define EMIF_REG_TA_CS1EN_SHIFT 31 #define EMIF_REG_TA_CS1EN_MASK (1 << 31) #define EMIF_REG_TA_CS0EN_SHIFT 30 #define EMIF_REG_TA_CS0EN_MASK (1 << 30) #define EMIF_REG_TA_SFEXITEN_SHIFT 28 #define EMIF_REG_TA_SFEXITEN_MASK (1 << 28) #define EMIF_REG_TA_DEVWDT_SHIFT 26 #define EMIF_REG_TA_DEVWDT_MASK (0x3 << 26) #define EMIF_REG_TA_DEVCNT_SHIFT 24 #define EMIF_REG_TA_DEVCNT_MASK (0x3 << 24) #define EMIF_REG_TA_REFINTERVAL_SHIFT 0 #define EMIF_REG_TA_REFINTERVAL_MASK (0x3fffff << 0) /* OCP_ERR_LOG */ #define EMIF_REG_MADDRSPACE_SHIFT 14 #define EMIF_REG_MADDRSPACE_MASK (0x3 << 14) #define EMIF_REG_MBURSTSEQ_SHIFT 11 #define EMIF_REG_MBURSTSEQ_MASK (0x7 << 11) #define EMIF_REG_MCMD_SHIFT 8 #define EMIF_REG_MCMD_MASK (0x7 << 8) #define EMIF_REG_MCONNID_SHIFT 0 #define EMIF_REG_MCONNID_MASK (0xff << 0) /* DDR_PHY_CTRL_1 */ #define EMIF_REG_DDR_PHY_CTRL_1_SHIFT 4 #define EMIF_REG_DDR_PHY_CTRL_1_MASK (0xfffffff << 4) #define EMIF_REG_READ_LATENCY_SHIFT 0 #define EMIF_REG_READ_LATENCY_MASK (0xf << 0) #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHIFT 4 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_MASK (0xFF << 4) #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHIFT 12 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_MASK (0xFFFFF << 12) /* DDR_PHY_CTRL_1_SHDW */ #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_SHIFT 4 #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_MASK (0xfffffff << 4) #define EMIF_REG_READ_LATENCY_SHDW_SHIFT 0 #define EMIF_REG_READ_LATENCY_SHDW_MASK (0xf << 0) #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_SHIFT 4 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK (0xFF << 4) #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK (0xFFFFF << 12) /* DDR_PHY_CTRL_2 */ #define EMIF_REG_DDR_PHY_CTRL_2_SHIFT 0 #define EMIF_REG_DDR_PHY_CTRL_2_MASK (0xffffffff << 0) /* DMM */ #define DMM_BASE 0x4E000040 /* Memory Adapter */ #define MA_BASE 0x482AF040 /* DMM_LISA_MAP */ #define EMIF_SYS_ADDR_SHIFT 24 #define EMIF_SYS_ADDR_MASK (0xff << 24) #define EMIF_SYS_SIZE_SHIFT 20 #define EMIF_SYS_SIZE_MASK (0x7 << 20) #define EMIF_SDRC_INTL_SHIFT 18 #define EMIF_SDRC_INTL_MASK (0x3 << 18) #define EMIF_SDRC_ADDRSPC_SHIFT 16 #define EMIF_SDRC_ADDRSPC_MASK (0x3 << 16) #define EMIF_SDRC_MAP_SHIFT 8 #define EMIF_SDRC_MAP_MASK (0x3 << 8) #define EMIF_SDRC_ADDR_SHIFT 0 #define EMIF_SDRC_ADDR_MASK (0xff << 0) /* DMM_LISA_MAP fields */ #define DMM_SDRC_MAP_UNMAPPED 0 #define DMM_SDRC_MAP_EMIF1_ONLY 1 #define DMM_SDRC_MAP_EMIF2_ONLY 2 #define DMM_SDRC_MAP_EMIF1_AND_EMIF2 3 #define DMM_SDRC_INTL_NONE 0 #define DMM_SDRC_INTL_128B 1 #define DMM_SDRC_INTL_256B 2 #define DMM_SDRC_INTL_512 3 #define DMM_SDRC_ADDR_SPC_SDRAM 0 #define DMM_SDRC_ADDR_SPC_NVM 1 #define DMM_SDRC_ADDR_SPC_INVALID 2 #define DMM_LISA_MAP_INTERLEAVED_BASE_VAL (\ (DMM_SDRC_MAP_EMIF1_AND_EMIF2 << EMIF_SDRC_MAP_SHIFT) |\ (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT) |\ (DMM_SDRC_INTL_128B << EMIF_SDRC_INTL_SHIFT) |\ (CONFIG_SYS_SDRAM_BASE << EMIF_SYS_ADDR_SHIFT)) #define DMM_LISA_MAP_EMIF1_ONLY_BASE_VAL (\ (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\ (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\ (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)) #define DMM_LISA_MAP_EMIF2_ONLY_BASE_VAL (\ (DMM_SDRC_MAP_EMIF2_ONLY << EMIF_SDRC_MAP_SHIFT)|\ (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\ (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)) /* Trap for invalid TILER PAT entries */ #define DMM_LISA_MAP_0_INVAL_ADDR_TRAP (\ (0 << EMIF_SDRC_ADDR_SHIFT) |\ (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\ (DMM_SDRC_ADDR_SPC_INVALID << EMIF_SDRC_ADDRSPC_SHIFT)|\ (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)|\ (0xFF << EMIF_SYS_ADDR_SHIFT)) /* Reg mapping structure */ struct emif_reg_struct { u32 emif_mod_id_rev; u32 emif_status; u32 emif_sdram_config; u32 emif_lpddr2_nvm_config; u32 emif_sdram_ref_ctrl; u32 emif_sdram_ref_ctrl_shdw; u32 emif_sdram_tim_1; u32 emif_sdram_tim_1_shdw; u32 emif_sdram_tim_2; u32 emif_sdram_tim_2_shdw; u32 emif_sdram_tim_3; u32 emif_sdram_tim_3_shdw; u32 emif_lpddr2_nvm_tim; u32 emif_lpddr2_nvm_tim_shdw; u32 emif_pwr_mgmt_ctrl; u32 emif_pwr_mgmt_ctrl_shdw; u32 emif_lpddr2_mode_reg_data; u32 padding1[1]; u32 emif_lpddr2_mode_reg_data_es2; u32 padding11[1]; u32 emif_lpddr2_mode_reg_cfg; u32 emif_l3_config; u32 emif_l3_cfg_val_1; u32 emif_l3_cfg_val_2; u32 emif_iodft_tlgc; u32 padding2[7]; u32 emif_perf_cnt_1; u32 emif_perf_cnt_2; u32 emif_perf_cnt_cfg; u32 emif_perf_cnt_sel; u32 emif_perf_cnt_tim; u32 padding3; u32 emif_read_idlectrl; u32 emif_read_idlectrl_shdw; u32 padding4; u32 emif_irqstatus_raw_sys; u32 emif_irqstatus_raw_ll; u32 emif_irqstatus_sys; u32 emif_irqstatus_ll; u32 emif_irqenable_set_sys; u32 emif_irqenable_set_ll; u32 emif_irqenable_clr_sys; u32 emif_irqenable_clr_ll; u32 padding5; u32 emif_zq_config; u32 emif_temp_alert_config; u32 emif_l3_err_log; u32 padding6[4]; u32 emif_ddr_phy_ctrl_1; u32 emif_ddr_phy_ctrl_1_shdw; u32 emif_ddr_phy_ctrl_2; }; struct dmm_lisa_map_regs { u32 dmm_lisa_map_0; u32 dmm_lisa_map_1; u32 dmm_lisa_map_2; u32 dmm_lisa_map_3; }; #define CS0 0 #define CS1 1 /* The maximum frequency at which the LPDDR2 interface can operate in Hz*/ #define MAX_LPDDR2_FREQ 400000000 /* 400 MHz */ /* * The period of DDR clk is represented as numerator and denominator for * better accuracy in integer based calculations. However, if the numerator * and denominator are very huge there may be chances of overflow in * calculations. So, as a trade-off keep denominator(and consequently * numerator) within a limit sacrificing some accuracy - but not much * If denominator and numerator are already small (such as at 400 MHz) * no adjustment is needed */ #define EMIF_PERIOD_DEN_LIMIT 1000 /* * Maximum number of different frequencies supported by EMIF driver * Determines the number of entries in the pointer array for register * cache */ #define EMIF_MAX_NUM_FREQUENCIES 6 /* * Indices into the Addressing Table array. * One entry each for all the different types of devices with different * addressing schemes */ #define ADDR_TABLE_INDEX64M 0 #define ADDR_TABLE_INDEX128M 1 #define ADDR_TABLE_INDEX256M 2 #define ADDR_TABLE_INDEX512M 3 #define ADDR_TABLE_INDEX1GS4 4 #define ADDR_TABLE_INDEX2GS4 5 #define ADDR_TABLE_INDEX4G 6 #define ADDR_TABLE_INDEX8G 7 #define ADDR_TABLE_INDEX1GS2 8 #define ADDR_TABLE_INDEX2GS2 9 #define ADDR_TABLE_INDEXMAX 10 /* Number of Row bits */ #define ROW_9 0 #define ROW_10 1 #define ROW_11 2 #define ROW_12 3 #define ROW_13 4 #define ROW_14 5 #define ROW_15 6 #define ROW_16 7 /* Number of Column bits */ #define COL_8 0 #define COL_9 1 #define COL_10 2 #define COL_11 3 #define COL_7 4 /*Not supported by OMAP included for completeness */ /* Number of Banks*/ #define BANKS1 0 #define BANKS2 1 #define BANKS4 2 #define BANKS8 3 /* Refresh rate in micro seconds x 10 */ #define T_REFI_15_6 156 #define T_REFI_7_8 78 #define T_REFI_3_9 39 #define EBANK_CS1_DIS 0 #define EBANK_CS1_EN 1 /* Read Latency used by the device at reset */ #define RL_BOOT 3 /* Read Latency for the highest frequency you want to use */ #ifdef CONFIG_OMAP54XX #define RL_FINAL 8 #else #define RL_FINAL 6 #endif /* Interleaving policies at EMIF level- between banks and Chip Selects */ #define EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING 0 #define EMIF_INTERLEAVING_POLICY_NO_BANK_INTERLEAVING 3 /* * Interleaving policy to be used * Currently set to MAX interleaving for better performance */ #define EMIF_INTERLEAVING_POLICY EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING /* State of the core voltage: * This is important for some parameters such as read idle control and * ZQ calibration timings. Timings are much stricter when voltage ramp * is happening compared to when the voltage is stable. * We need to calculate two sets of values for these parameters and use * them accordingly */ #define LPDDR2_VOLTAGE_STABLE 0 #define LPDDR2_VOLTAGE_RAMPING 1 /* Length of the forced read idle period in terms of cycles */ #define EMIF_REG_READ_IDLE_LEN_VAL 5 /* Interval between forced 'read idles' */ /* To be used when voltage is changed for DPS/DVFS - 1us */ #define READ_IDLE_INTERVAL_DVFS (1*1000) /* * To be used when voltage is not scaled except by Smart Reflex * 50us - or maximum value will do */ #define READ_IDLE_INTERVAL_NORMAL (50*1000) /* * Unless voltage is changing due to DVFS one ZQCS command every 50ms should * be enough. This shoule be enough also in the case when voltage is changing * due to smart-reflex. */ #define EMIF_ZQCS_INTERVAL_NORMAL_IN_US (50*1000) /* * If voltage is changing due to DVFS ZQCS should be performed more * often(every 50us) */ #define EMIF_ZQCS_INTERVAL_DVFS_IN_US 50 /* The interval between ZQCL commands as a multiple of ZQCS interval */ #define REG_ZQ_ZQCL_MULT 4 /* The interval between ZQINIT commands as a multiple of ZQCL interval */ #define REG_ZQ_ZQINIT_MULT 3 /* Enable ZQ Calibration on exiting Self-refresh */ #define REG_ZQ_SFEXITEN_ENABLE 1 /* * ZQ Calibration simultaneously on both chip-selects: * Needs one calibration resistor per CS * None of the boards that we know of have this capability * So disabled by default */ #define REG_ZQ_DUALCALEN_DISABLE 0 /* * Enable ZQ Calibration by default on CS0. If we are asked to program * the EMIF there will be something connected to CS0 for sure */ #define REG_ZQ_CS0EN_ENABLE 1 /* EMIF_PWR_MGMT_CTRL register */ /* Low power modes */ #define LP_MODE_DISABLE 0 #define LP_MODE_CLOCK_STOP 1 #define LP_MODE_SELF_REFRESH 2 #define LP_MODE_PWR_DN 3 /* REG_DPD_EN */ #define DPD_DISABLE 0 #define DPD_ENABLE 1 /* Maximum delay before Low Power Modes */ #define REG_CS_TIM 0xF #define REG_SR_TIM 0xF #define REG_PD_TIM 0xF /* EMIF_PWR_MGMT_CTRL register */ #define EMIF_PWR_MGMT_CTRL (\ ((REG_CS_TIM << EMIF_REG_CS_TIM_SHIFT) & EMIF_REG_CS_TIM_MASK)|\ ((REG_SR_TIM << EMIF_REG_SR_TIM_SHIFT) & EMIF_REG_SR_TIM_MASK)|\ ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\ ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\ ((LP_MODE_DISABLE << EMIF_REG_LP_MODE_SHIFT)\ & EMIF_REG_LP_MODE_MASK) |\ ((DPD_DISABLE << EMIF_REG_DPD_EN_SHIFT)\ & EMIF_REG_DPD_EN_MASK))\ #define EMIF_PWR_MGMT_CTRL_SHDW (\ ((REG_CS_TIM << EMIF_REG_CS_TIM_SHDW_SHIFT)\ & EMIF_REG_CS_TIM_SHDW_MASK) |\ ((REG_SR_TIM << EMIF_REG_SR_TIM_SHDW_SHIFT)\ & EMIF_REG_SR_TIM_SHDW_MASK) |\ ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\ & EMIF_REG_PD_TIM_SHDW_MASK) |\ ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\ & EMIF_REG_PD_TIM_SHDW_MASK)) /* EMIF_L3_CONFIG register value */ #define EMIF_L3_CONFIG_VAL_SYS_10_LL_0 0x0A0000FF #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_3_LL_0 0x0A300000 #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_5_LL_0 0x0A300000 /* * Value of bits 12:31 of DDR_PHY_CTRL_1 register: * All these fields have magic values dependent on frequency and * determined by PHY and DLL integration with EMIF. Setting the magic * values suggested by hw team. */ #define EMIF_DDR_PHY_CTRL_1_BASE_VAL 0x049FF #define EMIF_DLL_SLAVE_DLY_CTRL_400_MHZ 0x41 #define EMIF_DLL_SLAVE_DLY_CTRL_200_MHZ 0x80 #define EMIF_DLL_SLAVE_DLY_CTRL_100_MHZ_AND_LESS 0xFF /* * MR1 value: * Burst length : 8 * Burst type : sequential * Wrap : enabled * nWR : 3(default). EMIF does not do pre-charge. * : So nWR is don't care */ #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 0x23 /* MR2 */ #define MR2_RL3_WL1 1 #define MR2_RL4_WL2 2 #define MR2_RL5_WL2 3 #define MR2_RL6_WL3 4 /* MR10: ZQ calibration codes */ #define MR10_ZQ_ZQCS 0x56 #define MR10_ZQ_ZQCL 0xAB #define MR10_ZQ_ZQINIT 0xFF #define MR10_ZQ_ZQRESET 0xC3 /* TEMP_ALERT_CONFIG */ #define TEMP_ALERT_POLL_INTERVAL_MS 360 /* for temp gradient - 5 C/s */ #define TEMP_ALERT_CONFIG_DEVCT_1 0 #define TEMP_ALERT_CONFIG_DEVWDT_32 2 /* MR16 value: refresh full array(no partial array self refresh) */ #define MR16_REF_FULL_ARRAY 0 /* * Maximum number of entries we keep in our array of timing tables * We need not keep all the speed bins supported by the device * We need to keep timing tables for only the speed bins that we * are interested in */ #define MAX_NUM_SPEEDBINS 4 /* LPDDR2 Densities */ #define LPDDR2_DENSITY_64Mb 0 #define LPDDR2_DENSITY_128Mb 1 #define LPDDR2_DENSITY_256Mb 2 #define LPDDR2_DENSITY_512Mb 3 #define LPDDR2_DENSITY_1Gb 4 #define LPDDR2_DENSITY_2Gb 5 #define LPDDR2_DENSITY_4Gb 6 #define LPDDR2_DENSITY_8Gb 7 #define LPDDR2_DENSITY_16Gb 8 #define LPDDR2_DENSITY_32Gb 9 /* LPDDR2 type */ #define LPDDR2_TYPE_S4 0 #define LPDDR2_TYPE_S2 1 #define LPDDR2_TYPE_NVM 2 /* LPDDR2 IO width */ #define LPDDR2_IO_WIDTH_32 0 #define LPDDR2_IO_WIDTH_16 1 #define LPDDR2_IO_WIDTH_8 2 /* Mode register numbers */ #define LPDDR2_MR0 0 #define LPDDR2_MR1 1 #define LPDDR2_MR2 2 #define LPDDR2_MR3 3 #define LPDDR2_MR4 4 #define LPDDR2_MR5 5 #define LPDDR2_MR6 6 #define LPDDR2_MR7 7 #define LPDDR2_MR8 8 #define LPDDR2_MR9 9 #define LPDDR2_MR10 10 #define LPDDR2_MR11 11 #define LPDDR2_MR16 16 #define LPDDR2_MR17 17 #define LPDDR2_MR18 18 /* MR0 */ #define LPDDR2_MR0_DAI_SHIFT 0 #define LPDDR2_MR0_DAI_MASK 1 #define LPDDR2_MR0_DI_SHIFT 1 #define LPDDR2_MR0_DI_MASK (1 << 1) #define LPDDR2_MR0_DNVI_SHIFT 2 #define LPDDR2_MR0_DNVI_MASK (1 << 2) /* MR4 */ #define MR4_SDRAM_REF_RATE_SHIFT 0 #define MR4_SDRAM_REF_RATE_MASK 7 #define MR4_TUF_SHIFT 7 #define MR4_TUF_MASK (1 << 7) /* MR4 SDRAM Refresh Rate field values */ #define SDRAM_TEMP_LESS_LOW_SHUTDOWN 0x0 #define SDRAM_TEMP_LESS_4X_REFRESH_AND_TIMINGS 0x1 #define SDRAM_TEMP_LESS_2X_REFRESH_AND_TIMINGS 0x2 #define SDRAM_TEMP_NOMINAL 0x3 #define SDRAM_TEMP_RESERVED_4 0x4 #define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5 #define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6 #define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7 #define LPDDR2_MANUFACTURER_SAMSUNG 1 #define LPDDR2_MANUFACTURER_QIMONDA 2 #define LPDDR2_MANUFACTURER_ELPIDA 3 #define LPDDR2_MANUFACTURER_ETRON 4 #define LPDDR2_MANUFACTURER_NANYA 5 #define LPDDR2_MANUFACTURER_HYNIX 6 #define LPDDR2_MANUFACTURER_MOSEL 7 #define LPDDR2_MANUFACTURER_WINBOND 8 #define LPDDR2_MANUFACTURER_ESMT 9 #define LPDDR2_MANUFACTURER_SPANSION 11 #define LPDDR2_MANUFACTURER_SST 12 #define LPDDR2_MANUFACTURER_ZMOS 13 #define LPDDR2_MANUFACTURER_INTEL 14 #define LPDDR2_MANUFACTURER_NUMONYX 254 #define LPDDR2_MANUFACTURER_MICRON 255 /* MR8 register fields */ #define MR8_TYPE_SHIFT 0x0 #define MR8_TYPE_MASK 0x3 #define MR8_DENSITY_SHIFT 0x2 #define MR8_DENSITY_MASK (0xF << 0x2) #define MR8_IO_WIDTH_SHIFT 0x6 #define MR8_IO_WIDTH_MASK (0x3 << 0x6) struct lpddr2_addressing { u8 num_banks; u8 t_REFI_us_x10; u8 row_sz[2]; /* One entry each for x32 and x16 */ u8 col_sz[2]; /* One entry each for x32 and x16 */ }; /* Structure for timings from the DDR datasheet */ struct lpddr2_ac_timings { u32 max_freq; u8 RL; u8 tRPab; u8 tRCD; u8 tWR; u8 tRASmin; u8 tRRD; u8 tWTRx2; u8 tXSR; u8 tXPx2; u8 tRFCab; u8 tRTPx2; u8 tCKE; u8 tCKESR; u8 tZQCS; u32 tZQCL; u32 tZQINIT; u8 tDQSCKMAXx2; u8 tRASmax; u8 tFAW; }; /* * Min tCK values for some of the parameters: * If the calculated clock cycles for the respective parameter is * less than the corresponding min tCK value, we need to set the min * tCK value. This may happen at lower frequencies. */ struct lpddr2_min_tck { u32 tRL; u32 tRP_AB; u32 tRCD; u32 tWR; u32 tRAS_MIN; u32 tRRD; u32 tWTR; u32 tXP; u32 tRTP; u8 tCKE; u32 tCKESR; u32 tFAW; }; struct lpddr2_device_details { u8 type; u8 density; u8 io_width; u8 manufacturer; }; struct lpddr2_device_timings { const struct lpddr2_ac_timings **ac_timings; const struct lpddr2_min_tck *min_tck; }; /* Details of the devices connected to each chip-select of an EMIF instance */ struct emif_device_details { const struct lpddr2_device_details *cs0_device_details; const struct lpddr2_device_details *cs1_device_details; const struct lpddr2_device_timings *cs0_device_timings; const struct lpddr2_device_timings *cs1_device_timings; }; /* * Structure containing shadow of important registers in EMIF * The calculation function fills in this structure to be later used for * initialization and DVFS */ struct emif_regs { u32 freq; u32 sdram_config_init; u32 sdram_config; u32 ref_ctrl; u32 sdram_tim1; u32 sdram_tim2; u32 sdram_tim3; u32 read_idle_ctrl; u32 zq_config; u32 temp_alert_config; u32 emif_ddr_phy_ctlr_1_init; u32 emif_ddr_phy_ctlr_1; }; /* assert macros */ #if defined(DEBUG) #define emif_assert(c) ({ if (!(c)) for (;;); }) #else #define emif_assert(c) ({ if (0) hang(); }) #endif #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs); void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs); #else struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs, struct lpddr2_device_details *lpddr2_dev_details); void emif_get_device_timings(u32 emif_nr, const struct lpddr2_device_timings **cs0_device_timings, const struct lpddr2_device_timings **cs1_device_timings); #endif #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS extern u32 *const T_num; extern u32 *const T_den; extern u32 *const emif_sizes; #endif #endif
1001-study-uboot
arch/arm/include/asm/emif.h
C
gpl3
32,017
/* * (C) Copyright 2010 * Texas Instruments, <www.ti.com> * Aneesh V <aneesh@ti.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef ARMV7_H #define ARMV7_H #include <linux/types.h> /* Cortex-A9 revisions */ #define MIDR_CORTEX_A9_R0P1 0x410FC091 #define MIDR_CORTEX_A9_R1P2 0x411FC092 #define MIDR_CORTEX_A9_R1P3 0x411FC093 #define MIDR_CORTEX_A9_R2P10 0x412FC09A /* Cortex-A15 revisions */ #define MIDR_CORTEX_A15_R0P0 0x410FC0F0 /* CCSIDR */ #define CCSIDR_LINE_SIZE_OFFSET 0 #define CCSIDR_LINE_SIZE_MASK 0x7 #define CCSIDR_ASSOCIATIVITY_OFFSET 3 #define CCSIDR_ASSOCIATIVITY_MASK (0x3FF << 3) #define CCSIDR_NUM_SETS_OFFSET 13 #define CCSIDR_NUM_SETS_MASK (0x7FFF << 13) /* * Values for InD field in CSSELR * Selects the type of cache */ #define ARMV7_CSSELR_IND_DATA_UNIFIED 0 #define ARMV7_CSSELR_IND_INSTRUCTION 1 /* Values for Ctype fields in CLIDR */ #define ARMV7_CLIDR_CTYPE_NO_CACHE 0 #define ARMV7_CLIDR_CTYPE_INSTRUCTION_ONLY 1 #define ARMV7_CLIDR_CTYPE_DATA_ONLY 2 #define ARMV7_CLIDR_CTYPE_INSTRUCTION_DATA 3 #define ARMV7_CLIDR_CTYPE_UNIFIED 4 /* * CP15 Barrier instructions * Please note that we have separate barrier instructions in ARMv7 * However, we use the CP15 based instructtions because we use * -march=armv5 in U-Boot */ #define CP15ISB asm volatile ("mcr p15, 0, %0, c7, c5, 4" : : "r" (0)) #define CP15DSB asm volatile ("mcr p15, 0, %0, c7, c10, 4" : : "r" (0)) #define CP15DMB asm volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0)) void v7_outer_cache_enable(void); void v7_outer_cache_disable(void); void v7_outer_cache_flush_all(void); void v7_outer_cache_inval_all(void); void v7_outer_cache_flush_range(u32 start, u32 end); void v7_outer_cache_inval_range(u32 start, u32 end); #endif
1001-study-uboot
arch/arm/include/asm/armv7.h
C
gpl3
2,517
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* Size defintions * Copyright (C) ARM Limited 1998. All rights reserved. */ #ifndef __sizes_h #define __sizes_h 1 /* handy sizes */ #define SZ_1K 0x00000400 #define SZ_4K 0x00001000 #define SZ_8K 0x00002000 #define SZ_16K 0x00004000 #define SZ_32K 0x00008000 #define SZ_64K 0x00010000 #define SZ_128K 0x00020000 #define SZ_256K 0x00040000 #define SZ_512K 0x00080000 #define SZ_1M 0x00100000 #define SZ_2M 0x00200000 #define SZ_4M 0x00400000 #define SZ_8M 0x00800000 #define SZ_16M 0x01000000 #define SZ_31M 0x01F00000 #define SZ_32M 0x02000000 #define SZ_64M 0x04000000 #define SZ_128M 0x08000000 #define SZ_256M 0x10000000 #define SZ_512M 0x20000000 #define SZ_1G 0x40000000 #define SZ_2G 0x80000000 #endif /* END */
1001-study-uboot
arch/arm/include/asm/sizes.h
C
gpl3
2,032
/* * linux/include/asm/setup.h * * Copyright (C) 1997-1999 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Structure passed to kernel to tell it about the * hardware it's running on. See linux/Documentation/arm/Setup * for more info. * * NOTE: * This file contains two ways to pass information from the boot * loader to the kernel. The old struct param_struct is deprecated, * but it will be kept in the kernel for 5 years from now * (2001). This will allow boot loaders to convert to the new struct * tag way. */ #ifndef __ASMARM_SETUP_H #define __ASMARM_SETUP_H /* * Usage: * - do not go blindly adding fields, add them at the end * - when adding fields, don't rely on the address until * a patch from me has been released * - unused fields should be zero (for future expansion) * - this structure is relatively short-lived - only * guaranteed to contain useful data in setup_arch() */ #define COMMAND_LINE_SIZE 1024 /* This is the old deprecated way to pass parameters to the kernel */ struct param_struct { union { struct { unsigned long page_size; /* 0 */ unsigned long nr_pages; /* 4 */ unsigned long ramdisk_size; /* 8 */ unsigned long flags; /* 12 */ #define FLAG_READONLY 1 #define FLAG_RDLOAD 4 #define FLAG_RDPROMPT 8 unsigned long rootdev; /* 16 */ unsigned long video_num_cols; /* 20 */ unsigned long video_num_rows; /* 24 */ unsigned long video_x; /* 28 */ unsigned long video_y; /* 32 */ unsigned long memc_control_reg; /* 36 */ unsigned char sounddefault; /* 40 */ unsigned char adfsdrives; /* 41 */ unsigned char bytes_per_char_h; /* 42 */ unsigned char bytes_per_char_v; /* 43 */ unsigned long pages_in_bank[4]; /* 44 */ unsigned long pages_in_vram; /* 60 */ unsigned long initrd_start; /* 64 */ unsigned long initrd_size; /* 68 */ unsigned long rd_start; /* 72 */ unsigned long system_rev; /* 76 */ unsigned long system_serial_low; /* 80 */ unsigned long system_serial_high; /* 84 */ unsigned long mem_fclk_21285; /* 88 */ } s; char unused[256]; } u1; union { char paths[8][128]; struct { unsigned long magic; char n[1024 - sizeof(unsigned long)]; } s; } u2; char commandline[COMMAND_LINE_SIZE]; }; /* * The new way of passing information: a list of tagged entries */ /* The list ends with an ATAG_NONE node. */ #define ATAG_NONE 0x00000000 struct tag_header { u32 size; u32 tag; }; /* The list must start with an ATAG_CORE node */ #define ATAG_CORE 0x54410001 struct tag_core { u32 flags; /* bit 0 = read-only */ u32 pagesize; u32 rootdev; }; /* it is allowed to have multiple ATAG_MEM nodes */ #define ATAG_MEM 0x54410002 struct tag_mem32 { u32 size; u32 start; /* physical start address */ }; /* VGA text type displays */ #define ATAG_VIDEOTEXT 0x54410003 struct tag_videotext { u8 x; u8 y; u16 video_page; u8 video_mode; u8 video_cols; u16 video_ega_bx; u8 video_lines; u8 video_isvga; u16 video_points; }; /* describes how the ramdisk will be used in kernel */ #define ATAG_RAMDISK 0x54410004 struct tag_ramdisk { u32 flags; /* bit 0 = load, bit 1 = prompt */ u32 size; /* decompressed ramdisk size in _kilo_ bytes */ u32 start; /* starting block of floppy-based RAM disk image */ }; /* describes where the compressed ramdisk image lives (virtual address) */ /* * this one accidentally used virtual addresses - as such, * its depreciated. */ #define ATAG_INITRD 0x54410005 /* describes where the compressed ramdisk image lives (physical address) */ #define ATAG_INITRD2 0x54420005 struct tag_initrd { u32 start; /* physical start address */ u32 size; /* size of compressed ramdisk image in bytes */ }; /* board serial number. "64 bits should be enough for everybody" */ #define ATAG_SERIAL 0x54410006 struct tag_serialnr { u32 low; u32 high; }; /* board revision */ #define ATAG_REVISION 0x54410007 struct tag_revision { u32 rev; }; /* initial values for vesafb-type framebuffers. see struct screen_info * in include/linux/tty.h */ #define ATAG_VIDEOLFB 0x54410008 struct tag_videolfb { u16 lfb_width; u16 lfb_height; u16 lfb_depth; u16 lfb_linelength; u32 lfb_base; u32 lfb_size; u8 red_size; u8 red_pos; u8 green_size; u8 green_pos; u8 blue_size; u8 blue_pos; u8 rsvd_size; u8 rsvd_pos; }; /* command line: \0 terminated string */ #define ATAG_CMDLINE 0x54410009 struct tag_cmdline { char cmdline[1]; /* this is the minimum size */ }; /* acorn RiscPC specific information */ #define ATAG_ACORN 0x41000101 struct tag_acorn { u32 memc_control_reg; u32 vram_pages; u8 sounddefault; u8 adfsdrives; }; /* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ #define ATAG_MEMCLK 0x41000402 struct tag_memclk { u32 fmemclk; }; struct tag { struct tag_header hdr; union { struct tag_core core; struct tag_mem32 mem; struct tag_videotext videotext; struct tag_ramdisk ramdisk; struct tag_initrd initrd; struct tag_serialnr serialnr; struct tag_revision revision; struct tag_videolfb videolfb; struct tag_cmdline cmdline; /* * Acorn specific */ struct tag_acorn acorn; /* * DC21285 specific */ struct tag_memclk memclk; } u; }; struct tagtable { u32 tag; int (*parse)(const struct tag *); }; #define __tag __attribute__((unused, __section__(".taglist"))) #define __tagtable(tag, fn) \ static struct tagtable __tagtable_##fn __tag = { tag, fn } #define tag_member_present(tag,member) \ ((unsigned long)(&((struct tag *)0L)->member + 1) \ <= (tag)->hdr.size * 4) #define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) #define for_each_tag(t,base) \ for (t = base; t->hdr.size; t = tag_next(t)) /* * Memory map description */ #define NR_BANKS 8 struct meminfo { int nr_banks; unsigned long end; struct { unsigned long start; unsigned long size; int node; } bank[NR_BANKS]; }; extern struct meminfo meminfo; #endif
1001-study-uboot
arch/arm/include/asm/setup.h
C
gpl3
6,294
/* * (C) Copyright 2007 * Stelian Pop <stelian@popies.net> * Lead Tech Design <www.leadtechdesign.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef __ASM_ARM_DMA_MAPPING_H #define __ASM_ARM_DMA_MAPPING_H enum dma_data_direction { DMA_BIDIRECTIONAL = 0, DMA_TO_DEVICE = 1, DMA_FROM_DEVICE = 2, }; static void *dma_alloc_coherent(size_t len, unsigned long *handle) { *handle = (unsigned long)malloc(len); return (void *)*handle; } static inline unsigned long dma_map_single(volatile void *vaddr, size_t len, enum dma_data_direction dir) { return (unsigned long)vaddr; } static inline void dma_unmap_single(volatile void *vaddr, size_t len, unsigned long paddr) { } #endif /* __ASM_ARM_DMA_MAPPING_H */
1001-study-uboot
arch/arm/include/asm/dma-mapping.h
C
gpl3
1,493
/* * (C) Copyright 2002-2010 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef __ASM_GBL_DATA_H #define __ASM_GBL_DATA_H /* * The following data structure is placed in some memory which is * available very early after boot (like DPRAM on MPC8xx/MPC82xx, or * some locked parts of the data cache) to allow for a minimum set of * global variables during system initialization (until we have set * up the memory controller so that we can use RAM). * * Keep it *SMALL* and remember to set GENERATED_GBL_DATA_SIZE > sizeof(gd_t) */ typedef struct global_data { bd_t *bd; unsigned long flags; unsigned long baudrate; unsigned long have_console; /* serial_init() was called */ #ifdef CONFIG_PRE_CONSOLE_BUFFER unsigned long precon_buf_idx; /* Pre-Console buffer index */ #endif unsigned long env_addr; /* Address of Environment struct */ unsigned long env_valid; /* Checksum of Environment valid? */ unsigned long fb_base; /* base address of frame buffer */ #ifdef CONFIG_FSL_ESDHC unsigned long sdhc_clk; #endif #ifdef CONFIG_AT91FAMILY /* "static data" needed by at91's clock.c */ unsigned long cpu_clk_rate_hz; unsigned long main_clk_rate_hz; unsigned long mck_rate_hz; unsigned long plla_rate_hz; unsigned long pllb_rate_hz; unsigned long at91_pllb_usb_init; #endif #ifdef CONFIG_ARM /* "static data" needed by most of timer.c on ARM platforms */ unsigned long timer_rate_hz; unsigned long tbl; unsigned long tbu; unsigned long long timer_reset_value; unsigned long lastinc; #endif #ifdef CONFIG_IXP425 unsigned long timestamp; #endif unsigned long relocaddr; /* Start address of U-Boot in RAM */ phys_size_t ram_size; /* RAM size */ unsigned long mon_len; /* monitor len */ unsigned long irq_sp; /* irq stack pointer */ unsigned long start_addr_sp; /* start_addr_stackpointer */ unsigned long reloc_off; #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) unsigned long tlb_addr; #endif const void *fdt_blob; /* Our device tree, NULL if none */ void **jt; /* jump table */ char env_buf[32]; /* buffer for getenv() before reloc. */ #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER) unsigned long post_log_word; /* Record POST activities */ unsigned long post_log_res; /* success of POST test */ unsigned long post_init_f_time; /* When post_init_f started */ #endif } gd_t; /* * Global Data Flags */ #define GD_FLG_RELOC 0x00001 /* Code was relocated to RAM */ #define GD_FLG_DEVINIT 0x00002 /* Devices have been initialized */ #define GD_FLG_SILENT 0x00004 /* Silent mode */ #define GD_FLG_POSTFAIL 0x00008 /* Critical POST test failed */ #define GD_FLG_POSTSTOP 0x00010 /* POST seqeunce aborted */ #define GD_FLG_LOGINIT 0x00020 /* Log Buffer has been initialized */ #define GD_FLG_DISABLE_CONSOLE 0x00040 /* Disable console (in & out) */ #define GD_FLG_ENV_READY 0x00080 /* Environment imported into hash table */ #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r8") #endif /* __ASM_GBL_DATA_H */
1001-study-uboot
arch/arm/include/asm/global_data.h
C
gpl3
3,826
/* * linux/include/asm-arm/atomic.h * * Copyright (c) 1996 Russell King. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Changelog: * 27-06-1996 RMK Created * 13-04-1997 RMK Made functions atomic! * 07-12-1997 RMK Upgraded for v2.1. * 26-08-1998 PJB Added #ifdef __KERNEL__ */ #ifndef __ASM_ARM_ATOMIC_H #define __ASM_ARM_ATOMIC_H #include <linux/config.h> #ifdef CONFIG_SMP #error SMP not supported #endif typedef struct { volatile int counter; } atomic_t; #define ATOMIC_INIT(i) { (i) } #ifdef __KERNEL__ #include <asm/proc/system.h> #define atomic_read(v) ((v)->counter) #define atomic_set(v,i) (((v)->counter) = (i)) static inline void atomic_add(int i, volatile atomic_t *v) { unsigned long flags; local_irq_save(flags); v->counter += i; local_irq_restore(flags); } static inline void atomic_sub(int i, volatile atomic_t *v) { unsigned long flags; local_irq_save(flags); v->counter -= i; local_irq_restore(flags); } static inline void atomic_inc(volatile atomic_t *v) { unsigned long flags; local_irq_save(flags); v->counter += 1; local_irq_restore(flags); } static inline void atomic_dec(volatile atomic_t *v) { unsigned long flags; local_irq_save(flags); v->counter -= 1; local_irq_restore(flags); } static inline int atomic_dec_and_test(volatile atomic_t *v) { unsigned long flags; int val; local_irq_save(flags); val = v->counter; v->counter = val -= 1; local_irq_restore(flags); return val == 0; } static inline int atomic_add_negative(int i, volatile atomic_t *v) { unsigned long flags; int val; local_irq_save(flags); val = v->counter; v->counter = val += i; local_irq_restore(flags); return val < 0; } static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr) { unsigned long flags; local_irq_save(flags); *addr &= ~mask; local_irq_restore(flags); } /* Atomic operations are already serializing on ARM */ #define smp_mb__before_atomic_dec() barrier() #define smp_mb__after_atomic_dec() barrier() #define smp_mb__before_atomic_inc() barrier() #define smp_mb__after_atomic_inc() barrier() #endif #endif
1001-study-uboot
arch/arm/include/asm/atomic.h
C
gpl3
2,259
/* * Copyright (c) 2009 Wind River Systems, Inc. * Tom Rix <Tom.Rix@windriver.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * This work is derived from the linux 2.6.27 kernel source * To fetch, use the kernel repository * git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git * Use the v2.6.27 tag. * * Below is the original's header including its copyright * * linux/arch/arm/plat-omap/gpio.c * * Support functions for OMAP GPIO * * Copyright (C) 2003-2005 Nokia Corporation * Written by Juha Yrjölä <juha.yrjola@nokia.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef _GPIO_H #define _GPIO_H #include <asm/arch/cpu.h> struct gpio_bank { void *base; int method; }; extern const struct gpio_bank *const omap_gpio_bank; #define METHOD_GPIO_24XX 4 #endif /* _GPIO_H_ */
1001-study-uboot
arch/arm/include/asm/omap_gpio.h
C
gpl3
1,645
/* * arch/arm/include/asm/assembler.h * * Copyright (C) 1996-2000 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This file contains arm architecture specific defines * for the different processors. * * Do not include any C declarations in this file - it is included by * assembler source. */ /* * Endian independent macros for shifting bytes within registers. */ #ifndef __ARMEB__ #define pull lsr #define push lsl #define get_byte_0 lsl #0 #define get_byte_1 lsr #8 #define get_byte_2 lsr #16 #define get_byte_3 lsr #24 #define put_byte_0 lsl #0 #define put_byte_1 lsl #8 #define put_byte_2 lsl #16 #define put_byte_3 lsl #24 #else #define pull lsl #define push lsr #define get_byte_0 lsr #24 #define get_byte_1 lsr #16 #define get_byte_2 lsr #8 #define get_byte_3 lsl #0 #define put_byte_0 lsl #24 #define put_byte_1 lsl #16 #define put_byte_2 lsl #8 #define put_byte_3 lsl #0 #endif /* * Data preload for architectures that support it */ #if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || \ defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \ defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || \ defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_7A__) || \ defined(__ARM_ARCH_7R__) #define PLD(code...) code #else #define PLD(code...) #endif /* * Cache alligned */ #define CALGN(code...) code
1001-study-uboot
arch/arm/include/asm/assembler.h
C
gpl3
1,518
#ifndef __ASM_ARM_SYSTEM_H #define __ASM_ARM_SYSTEM_H #ifdef __KERNEL__ #define CPU_ARCH_UNKNOWN 0 #define CPU_ARCH_ARMv3 1 #define CPU_ARCH_ARMv4 2 #define CPU_ARCH_ARMv4T 3 #define CPU_ARCH_ARMv5 4 #define CPU_ARCH_ARMv5T 5 #define CPU_ARCH_ARMv5TE 6 #define CPU_ARCH_ARMv5TEJ 7 #define CPU_ARCH_ARMv6 8 #define CPU_ARCH_ARMv7 9 /* * CR1 bits (CP#15 CR1) */ #define CR_M (1 << 0) /* MMU enable */ #define CR_A (1 << 1) /* Alignment abort enable */ #define CR_C (1 << 2) /* Dcache enable */ #define CR_W (1 << 3) /* Write buffer enable */ #define CR_P (1 << 4) /* 32-bit exception handler */ #define CR_D (1 << 5) /* 32-bit data address range */ #define CR_L (1 << 6) /* Implementation defined */ #define CR_B (1 << 7) /* Big endian */ #define CR_S (1 << 8) /* System MMU protection */ #define CR_R (1 << 9) /* ROM MMU protection */ #define CR_F (1 << 10) /* Implementation defined */ #define CR_Z (1 << 11) /* Implementation defined */ #define CR_I (1 << 12) /* Icache enable */ #define CR_V (1 << 13) /* Vectors relocated to 0xffff0000 */ #define CR_RR (1 << 14) /* Round Robin cache replacement */ #define CR_L4 (1 << 15) /* LDR pc can set T bit */ #define CR_DT (1 << 16) #define CR_IT (1 << 18) #define CR_ST (1 << 19) #define CR_FI (1 << 21) /* Fast interrupt (lower latency mode) */ #define CR_U (1 << 22) /* Unaligned access operation */ #define CR_XP (1 << 23) /* Extended page tables */ #define CR_VE (1 << 24) /* Vectored interrupts */ #define CR_EE (1 << 25) /* Exception (Big) Endian */ #define CR_TRE (1 << 28) /* TEX remap enable */ #define CR_AFE (1 << 29) /* Access flag enable */ #define CR_TE (1 << 30) /* Thumb exception enable */ /* * This is used to ensure the compiler did actually allocate the register we * asked it for some inline assembly sequences. Apparently we can't trust * the compiler from one version to another so a bit of paranoia won't hurt. * This string is meant to be concatenated with the inline asm string and * will cause compilation to stop on mismatch. * (for details, see gcc PR 15089) */ #define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t" #ifndef __ASSEMBLY__ #define isb() __asm__ __volatile__ ("" : : : "memory") #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t"); static inline unsigned int get_cr(void) { unsigned int val; asm("mrc p15, 0, %0, c1, c0, 0 @ get CR" : "=r" (val) : : "cc"); return val; } static inline void set_cr(unsigned int val) { asm volatile("mcr p15, 0, %0, c1, c0, 0 @ set CR" : : "r" (val) : "cc"); isb(); } #endif /* __ASSEMBLY__ */ #define arch_align_stack(x) (x) #endif /* __KERNEL__ */ #endif
1001-study-uboot
arch/arm/include/asm/system.h
C
gpl3
2,664
/* * linux/include/asm-arm/processor.h * * Copyright (C) 1995-2002 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef __ASM_ARM_PROCESSOR_H #define __ASM_ARM_PROCESSOR_H /* * Default implementation of macro that returns current * instruction pointer ("program counter"). */ #define current_text_addr() ({ __label__ _l; _l: &&_l;}) #define FP_SIZE 35 struct fp_hard_struct { unsigned int save[FP_SIZE]; /* as yet undefined */ }; struct fp_soft_struct { unsigned int save[FP_SIZE]; /* undefined information */ }; union fp_state { struct fp_hard_struct hard; struct fp_soft_struct soft; }; typedef unsigned long mm_segment_t; /* domain register */ #ifdef __KERNEL__ #define EISA_bus 0 #define MCA_bus 0 #define MCA_bus__is_a_macro #include <asm/atomic.h> #include <asm/ptrace.h> #if 0 /* XXX###XXX */ #include <asm/arch/memory.h> #endif /* XXX###XXX */ #include <asm/proc/processor.h> #include <asm/types.h> union debug_insn { u32 arm; u16 thumb; }; struct debug_entry { u32 address; union debug_insn insn; }; struct debug_info { int nsaved; struct debug_entry bp[2]; }; struct thread_struct { atomic_t refcount; /* fault info */ unsigned long address; unsigned long trap_no; unsigned long error_code; /* floating point */ union fp_state fpstate; /* debugging */ struct debug_info debug; /* context info */ struct context_save_struct *save; EXTRA_THREAD_STRUCT }; #define INIT_THREAD { \ refcount: ATOMIC_INIT(1), \ EXTRA_THREAD_STRUCT_INIT \ } /* * Return saved PC of a blocked thread. */ static inline unsigned long thread_saved_pc(struct thread_struct *t) { return t->save ? pc_pointer(t->save->pc) : 0; } static inline unsigned long thread_saved_fp(struct thread_struct *t) { return t->save ? t->save->fp : 0; } /* Forward declaration, a strange C thing */ struct task_struct; /* Free all resources held by a thread. */ extern void release_thread(struct task_struct *); /* Copy and release all segment info associated with a VM */ #define copy_segments(tsk, mm) do { } while (0) #define release_segments(mm) do { } while (0) unsigned long get_wchan(struct task_struct *p); #define THREAD_SIZE (8192) extern struct task_struct *alloc_task_struct(void); extern void __free_task_struct(struct task_struct *); #define get_task_struct(p) atomic_inc(&(p)->thread.refcount) #define free_task_struct(p) \ do { \ if (atomic_dec_and_test(&(p)->thread.refcount)) \ __free_task_struct((p)); \ } while (0) #define init_task (init_task_union.task) #define init_stack (init_task_union.stack) #define cpu_relax() barrier() /* * Create a new kernel thread */ extern int arch_kernel_thread(int (*fn)(void *), void *arg, unsigned long flags); #endif #endif /* __ASM_ARM_PROCESSOR_H */
1001-study-uboot
arch/arm/include/asm/processor.h
C
gpl3
2,975
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * ******************************************************************** * NOTE: This header file defines an interface to U-Boot. Including * this (unmodified) header file in another file is considered normal * use of U-Boot, and does *not* fall under the heading of "derived * work". ******************************************************************** */ #ifndef _U_BOOT_H_ #define _U_BOOT_H_ 1 typedef struct bd_info { int bi_baudrate; /* serial console baudrate */ unsigned long bi_ip_addr; /* IP Address */ ulong bi_arch_number; /* unique id for this board */ ulong bi_boot_params; /* where this board expects params */ struct /* RAM configuration */ { ulong start; ulong size; } bi_dram[CONFIG_NR_DRAM_BANKS]; } bd_t; /* For image.h:image_check_target_arch() */ #define IH_ARCH_DEFAULT IH_ARCH_ARM #endif /* _U_BOOT_H_ */
1001-study-uboot
arch/arm/include/asm/u-boot.h
C
gpl3
1,908
/* * Copyright (c) 2011, NVIDIA Corp. All rights reserved. * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #ifndef _GPIO_H_ #define _GPIO_H_ #include <asm/arch/gpio.h> /* * Generic GPIO API */ int gpio_request(int gp, const char *label); void gpio_free(int gp); void gpio_toggle_value(int gp); int gpio_direction_input(int gp); int gpio_direction_output(int gp, int value); int gpio_get_value(int gp); void gpio_set_value(int gp, int value); #endif /* _GPIO_H_ */
1001-study-uboot
arch/arm/include/asm/gpio.h
C
gpl3
1,219
/* * Copyright 1995, Russell King. * Various bits and pieces copyrights include: * Linus Torvalds (test_bit). * * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1). * * Please note that the code in this file should never be included * from user space. Many of these are not implemented in assembler * since they would be too costly. Also, they require priviledged * instructions (which are not available from user mode) to ensure * that they are atomic. */ #ifndef __ASM_ARM_BITOPS_H #define __ASM_ARM_BITOPS_H #ifdef __KERNEL__ #include <asm/proc/system.h> #define smp_mb__before_clear_bit() do { } while (0) #define smp_mb__after_clear_bit() do { } while (0) /* * Function prototypes to keep gcc -Wall happy. */ extern void set_bit(int nr, volatile void * addr); extern void clear_bit(int nr, volatile void * addr); extern void change_bit(int nr, volatile void * addr); static inline void __change_bit(int nr, volatile void *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); *p ^= mask; } static inline int __test_and_set_bit(int nr, volatile void *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long old = *p; *p = old | mask; return (old & mask) != 0; } static inline int test_and_set_bit(int nr, volatile void * addr) { unsigned long flags; int out; local_irq_save(flags); out = __test_and_set_bit(nr, addr); local_irq_restore(flags); return out; } static inline int __test_and_clear_bit(int nr, volatile void *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long old = *p; *p = old & ~mask; return (old & mask) != 0; } static inline int test_and_clear_bit(int nr, volatile void * addr) { unsigned long flags; int out; local_irq_save(flags); out = __test_and_clear_bit(nr, addr); local_irq_restore(flags); return out; } extern int test_and_change_bit(int nr, volatile void * addr); static inline int __test_and_change_bit(int nr, volatile void *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long old = *p; *p = old ^ mask; return (old & mask) != 0; } extern int find_first_zero_bit(void * addr, unsigned size); extern int find_next_zero_bit(void * addr, int size, int offset); /* * This routine doesn't need to be atomic. */ static inline int test_bit(int nr, const void * addr) { return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); } static inline int __ilog2(unsigned int x) { return generic_fls(x) - 1; } /* * ffz = Find First Zero in word. Undefined if no zero exists, * so code should check against ~0UL first.. */ static inline unsigned long ffz(unsigned long word) { int k; word = ~word; k = 31; if (word & 0x0000ffff) { k -= 16; word <<= 16; } if (word & 0x00ff0000) { k -= 8; word <<= 8; } if (word & 0x0f000000) { k -= 4; word <<= 4; } if (word & 0x30000000) { k -= 2; word <<= 2; } if (word & 0x40000000) { k -= 1; } return k; } /* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word */ #define hweight32(x) generic_hweight32(x) #define hweight16(x) generic_hweight16(x) #define hweight8(x) generic_hweight8(x) #define ext2_set_bit test_and_set_bit #define ext2_clear_bit test_and_clear_bit #define ext2_test_bit test_bit #define ext2_find_first_zero_bit find_first_zero_bit #define ext2_find_next_zero_bit find_next_zero_bit /* Bitmap functions for the minix filesystem. */ #define minix_test_and_set_bit(nr,addr) test_and_set_bit(nr,addr) #define minix_set_bit(nr,addr) set_bit(nr,addr) #define minix_test_and_clear_bit(nr,addr) test_and_clear_bit(nr,addr) #define minix_test_bit(nr,addr) test_bit(nr,addr) #define minix_find_first_zero_bit(addr,size) find_first_zero_bit(addr,size) #endif /* __KERNEL__ */ #endif /* _ARM_BITOPS_H */
1001-study-uboot
arch/arm/include/asm/bitops.h
C
gpl3
3,963
#ifndef __ASM_ARM_PTRACE_H #define __ASM_ARM_PTRACE_H #define PTRACE_GETREGS 12 #define PTRACE_SETREGS 13 #define PTRACE_GETFPREGS 14 #define PTRACE_SETFPREGS 15 #define PTRACE_SETOPTIONS 21 /* options set using PTRACE_SETOPTIONS */ #define PTRACE_O_TRACESYSGOOD 0x00000001 #include <asm/proc/ptrace.h> #ifndef __ASSEMBLY__ #define pc_pointer(v) \ ((v) & ~PCMASK) #define instruction_pointer(regs) \ (pc_pointer((regs)->ARM_pc)) #ifdef __KERNEL__ extern void show_regs(struct pt_regs *); #define predicate(x) (x & 0xf0000000) #define PREDICATE_ALWAYS 0xe0000000 #endif #endif /* __ASSEMBLY__ */ #endif
1001-study-uboot
arch/arm/include/asm/ptrace.h
C
gpl3
617
/* * linux/include/asm-arm/hardware.h * * Copyright (C) 1996 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Common hardware definitions */ #ifndef __ASM_HARDWARE_H #define __ASM_HARDWARE_H #include <asm/arch/hardware.h> #endif
1001-study-uboot
arch/arm/include/asm/hardware.h
C
gpl3
399
/* * Copyright 2009 Freescale Semiconductor, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * */ #ifndef _ASM_CONFIG_H_ #define _ASM_CONFIG_H_ #define CONFIG_LMB #define CONFIG_SYS_BOOT_RAMDISK_HIGH #endif
1001-study-uboot
arch/arm/include/asm/config.h
C
gpl3
886
/* * (C) Copyright 2009 * Marvell Semiconductor <www.marvell.com> * Written-by: Prafulla Wadaskar <prafulla@marvell.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #ifndef _ASM_CACHE_H #define _ASM_CACHE_H #include <asm/system.h> /* * Invalidate L2 Cache using co-proc instruction */ static inline void invalidate_l2_cache(void) { unsigned int val=0; asm volatile("mcr p15, 1, %0, c15, c11, 0 @ invl l2 cache" : : "r" (val) : "cc"); isb(); } void l2_cache_enable(void); void l2_cache_disable(void); /* * The current upper bound for ARM L1 data cache line sizes is 64 bytes. We * use that value for aligning DMA buffers unless the board config has specified * an alternate cache line size. */ #ifdef CONFIG_SYS_CACHELINE_SIZE #define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE #else #define ARCH_DMA_MINALIGN 64 #endif #endif /* _ASM_CACHE_H */
1001-study-uboot
arch/arm/include/asm/cache.h
C
gpl3
1,627
/* * (C) Copyright 2002-2006 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * To match the U-Boot user interface on ARM platforms to the U-Boot * standard (as on PPC platforms), some messages with debug character * are removed from the default U-Boot build. * * Define DEBUG here if you want additional info as shown below * printed upon startup: * * U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274 * IRQ Stack: 00ebff7c * FIQ Stack: 00ebef7c */ #include <common.h> #include <command.h> #include <malloc.h> #include <stdio_dev.h> #include <version.h> #include <net.h> #include <serial.h> #include <nand.h> #include <onenand_uboot.h> #include <mmc.h> #include <libfdt.h> #include <fdtdec.h> #include <post.h> #include <logbuff.h> #ifdef CONFIG_BITBANGMII #include <miiphy.h> #endif #ifdef CONFIG_DRIVER_SMC91111 #include "../drivers/net/smc91111.h" #endif #ifdef CONFIG_DRIVER_LAN91C96 #include "../drivers/net/lan91c96.h" #endif DECLARE_GLOBAL_DATA_PTR; ulong monitor_flash_len; #ifdef CONFIG_HAS_DATAFLASH extern int AT91F_DataflashInit(void); extern void dataflash_print_info(void); #endif #if defined(CONFIG_HARD_I2C) || \ defined(CONFIG_SOFT_I2C) #include <i2c.h> #endif #if 0 /************************************************************************ * Coloured LED functionality ************************************************************************ * May be supplied by boards if desired */ inline void __coloured_LED_init(void) {} void coloured_LED_init(void) __attribute__((weak, alias("__coloured_LED_init"))); inline void __red_led_on(void) {} void red_led_on(void) __attribute__((weak, alias("__red_led_on"))); inline void __red_led_off(void) {} void red_led_off(void) __attribute__((weak, alias("__red_led_off"))); inline void __green_led_on(void) {} void green_led_on(void) __attribute__((weak, alias("__green_led_on"))); inline void __green_led_off(void) {} void green_led_off(void) __attribute__((weak, alias("__green_led_off"))); inline void __yellow_led_on(void) {} void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on"))); inline void __yellow_led_off(void) {} void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off"))); inline void __blue_led_on(void) {} void blue_led_on(void) __attribute__((weak, alias("__blue_led_on"))); inline void __blue_led_off(void) {} void blue_led_off(void) __attribute__((weak, alias("__blue_led_off"))); #endif /* ************************************************************************ * Init Utilities * ************************************************************************ * Some of this code should be moved into the core functions, * or dropped completely, * but let's get it working (again) first... */ #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE) #define CONFIG_BAUDRATE 115200 #endif static int init_baudrate(void) { gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); return 0; } static int display_banner(void) { printf("\n\n%s\n\n", version_string); debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n", _TEXT_BASE, _bss_start_ofs + _TEXT_BASE, _bss_end_ofs + _TEXT_BASE); #ifdef CONFIG_MODEM_SUPPORT debug("Modem Support enabled\n"); #endif #ifdef CONFIG_USE_IRQ debug("IRQ Stack: %08lx\n", IRQ_STACK_START); debug("FIQ Stack: %08lx\n", FIQ_STACK_START); #endif return (0); } /* * WARNING: this code looks "cleaner" than the PowerPC version, but * has the disadvantage that you either get nothing, or everything. * On PowerPC, you might see "DRAM: " before the system hangs - which * gives a simple yet clear indication which part of the * initialization if failing. */ static int display_dram_config(void) { int i; #ifdef DEBUG puts("RAM Configuration:\n"); for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start); print_size(gd->bd->bi_dram[i].size, "\n"); } #else ulong size = 0; for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) size += gd->bd->bi_dram[i].size; puts("DRAM: "); print_size(size, "\n"); #endif return (0); } #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) static int init_func_i2c(void) { puts("I2C: "); i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); puts("ready\n"); return (0); } #endif #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI) #include <pci.h> static int arm_pci_init(void) { pci_init(); return 0; } #endif /* CONFIG_CMD_PCI || CONFIG_PCI */ /* * Breathe some life into the board... * * Initialize a serial port as console, and carry out some hardware * tests. * * The first part of initialization is running from Flash memory; * its main purpose is to initialize the RAM so that we * can relocate the monitor code to RAM. */ /* * All attempts to come up with a "common" initialization sequence * that works for all boards and architectures failed: some of the * requirements are just _too_ different. To get rid of the resulting * mess of board dependent #ifdef'ed code we now make the whole * initialization sequence configurable to the user. * * The requirements for any new initalization function is simple: it * receives a pointer to the "global data" structure as it's only * argument, and returns an integer return code, where 0 means * "continue" and != 0 means "fatal error, hang the system". */ typedef int (init_fnc_t) (void); int print_cpuinfo(void); void __dram_init_banksize(void) { gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; gd->bd->bi_dram[0].size = gd->ram_size; } void dram_init_banksize(void) __attribute__((weak, alias("__dram_init_banksize"))); init_fnc_t *init_sequence[] = { #if defined(CONFIG_ARCH_CPU_INIT) arch_cpu_init, /* basic arch cpu dependent setup */ #endif #if defined(CONFIG_BOARD_EARLY_INIT_F) board_early_init_f, #endif #ifdef CONFIG_OF_CONTROL fdtdec_check_fdt, #endif timer_init, /* initialize timer */ #ifdef CONFIG_FSL_ESDHC get_clocks, #endif env_init, /* initialize environment */ init_baudrate, /* initialze baudrate settings */ serial_init, /* serial communications setup */ console_init_f, /* stage 1 init of console */ display_banner, /* say that we are here */ #if defined(CONFIG_DISPLAY_CPUINFO) print_cpuinfo, /* display cpu info (and speed) */ #endif #if defined(CONFIG_DISPLAY_BOARDINFO) checkboard, /* display board info */ #endif #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) init_func_i2c, #endif dram_init, /* configure available RAM banks */ NULL, }; //wx:comment this is the asm code run jump to first C function // and the C stack pointer is CONFIG_SYS_INIT_SP_ADDR //-------wx----------------------- //|low=? (dymatic address, decide by high top size) //| - <Start STACK ADDR:start_addr_sp> //| [ - SPL // if not support second program loader //| - ABORT STACK (12 Byte) //| - IRQ_SIZE + FIQ SIZE (by user configure) //| - IRQ_SP_ADDR | // up is stack, down is system global data //| - sizeof (gd_t) = gd //| - sizeof (bd_t) //| - Malloc Buffer (by user configure) //| ] //| ->>>>> Relocate address start >>>>>>>>>>>>>>>> //| - U-BOOT bssEnd - start (this code run space size) //| -<<<<< Relocate address end <<<<<<<<<<<<<<<<< //| - Frame Buffer //| - MMU TLB //| - Protected Ram //| - Log Buffer //| - Top Hide Buffer (CONFIG_SYS_MEM_TOP_HIDE) //|high (2M)=0x30200000 //--------------------------------- void board_init_f(ulong bootflag) { bd_t *bd; init_fnc_t **init_fnc_ptr; gd_t *id; ulong addr, addr_sp; #ifdef CONFIG_PRAM ulong reg; #endif /* Pointer is writable since we allocated a register for it */ // wx: align to 8 byte gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07); /* compiler optimization barrier needed for GCC >= 3.4 */ __asm__ __volatile__("": : :"memory"); memset((void *)gd, 0, sizeof(gd_t)); gd->mon_len = _bss_end_ofs;/* monitor size */ #ifdef CONFIG_OF_EMBED /* Get a pointer to the FDT */ gd->fdt_blob = _binary_dt_dtb_start; #elif defined CONFIG_OF_SEPARATE /* FDT is at end of image */ gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE); #endif /* Allow the early environment to override the fdt address */ gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16, (uintptr_t)gd->fdt_blob); for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { hang (); } } debug("monitor len: %08lX\n", gd->mon_len); /* * Ram is setup, size stored in gd !! */ debug("ramsize: %08lX\n", gd->ram_size); #if defined(CONFIG_SYS_MEM_TOP_HIDE) /* * Subtract specified amount of memory to hide so that it won't * get "touched" at all by U-Boot. By fixing up gd->ram_size * the Linux kernel should now get passed the now "corrected" * memory size and won't touch it either. This should work * for arch/ppc and arch/powerpc. Only Linux board ports in * arch/powerpc with bootwrapper support, that recalculate the * memory size from the SDRAM controller setup will have to * get fixed. */ gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE; #endif //wx:point the high top address, this routine run on low 4K address // and the resource memery is allocal form high top. addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size; #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR /* reserve kernel log buffer */ addr -= (LOGBUFF_RESERVE); debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); #endif #endif #ifdef CONFIG_PRAM /* * reserve protected RAM */ reg = getenv_ulong("pram", 10, CONFIG_PRAM); addr -= (reg << 10); /* size is in kB */ debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr); #endif /* CONFIG_PRAM */ #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) /* reserve TLB table */ addr -= (4096 * 4); /* round down to next 64 kB limit */ addr &= ~(0x10000 - 1); gd->tlb_addr = addr; debug("TLB table at: %08lx\n", addr); #endif /* round down to next 4 kB limit */ addr &= ~(4096 - 1); debug("Top of RAM usable for U-Boot at: %08lx\n", addr); #ifdef CONFIG_LCD #ifdef CONFIG_FB_ADDR //wx:comment:frame buffer gd->fb_base = CONFIG_FB_ADDR; #else /* reserve memory for LCD display (always full pages) */ addr = lcd_setmem(addr); gd->fb_base = addr; #endif /* CONFIG_FB_ADDR */ #endif /* CONFIG_LCD */ /* * reserve memory for U-Boot code, data & bss * round down to next 4 kB limit */ addr -= gd->mon_len; addr &= ~(4096 - 1); debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr); //wx:comment: Second Program Loader, useed for load the os image and // provid some function, likely as the BIOS.s // here is no used for SPL, hence, must has itself runtime space, // include heap, stack .. #ifndef CONFIG_SPL_BUILD /* * reserve memory for malloc() arena */ addr_sp = addr - TOTAL_MALLOC_LEN; debug("Reserving %dk for malloc() at: %08lx\n", TOTAL_MALLOC_LEN >> 10, addr_sp); /* * (permanently) allocate a Board Info struct * and a permanent copy of the "global" data */ addr_sp -= sizeof (bd_t); bd = (bd_t *) addr_sp; gd->bd = bd; debug("Reserving %zu Bytes for Board Info at: %08lx\n", sizeof (bd_t), addr_sp); #ifdef CONFIG_MACH_TYPE gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */ #endif addr_sp -= sizeof (gd_t); id = (gd_t *) addr_sp; debug("Reserving %zu Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp); /* setup stackpointer for exeptions */ gd->irq_sp = addr_sp; #ifdef CONFIG_USE_IRQ addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ); debug("Reserving %zu Bytes for IRQ stack at: %08lx\n", CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp); #endif /* leave 3 words for abort-stack */ addr_sp -= 12; /* 8-byte alignment for ABI compliance */ addr_sp &= ~0x07; #else addr_sp += 128; /* leave 32 words for abort-stack */ gd->irq_sp = addr_sp; #endif debug("New Stack Pointer is: %08lx\n", addr_sp); #ifdef CONFIG_POST post_bootmode_init(); post_run(NULL, POST_ROM | post_bootmode_get(0)); #endif gd->bd->bi_baudrate = gd->baudrate; /* Ram ist board specific, so move it to board code ... */ dram_init_banksize(); display_dram_config(); /* and display it */ gd->relocaddr = addr; /* U-BOOT relocate addr */ gd->start_addr_sp = addr_sp; gd->reloc_off = addr - _TEXT_BASE; debug("relocation Offset is: %08lx\n", gd->reloc_off); memcpy(id, (void *)gd, sizeof(gd_t)); relocate_code(addr_sp, id, addr); /* NOTREACHED - relocate_code() does not return */ } #if !defined(CONFIG_SYS_NO_FLASH) static char *failed = "*** failed ***\n"; #endif /* ************************************************************************ * * This is the next part if the initialization sequence: we are now * running from RAM and have a "normal" C environment, i. e. global * data can be written, BSS has been cleared, the stack size in not * that critical any more, etc. * ************************************************************************ */ void board_init_r(gd_t *id, ulong dest_addr) { ulong malloc_start; #if !defined(CONFIG_SYS_NO_FLASH) ulong flash_size; #endif gd = id; gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ monitor_flash_len = _end_ofs; /* Enable caches */ enable_caches(); debug("monitor flash len: %08lX\n", monitor_flash_len); board_init(); /* Setup chipselects */ #ifdef CONFIG_SERIAL_MULTI serial_initialize(); #endif debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); #ifdef CONFIG_LOGBUFFER logbuff_init_ptrs(); #endif #ifdef CONFIG_POST post_output_backlog(); #endif /* The Malloc area is immediately below the monitor copy in DRAM */ malloc_start = dest_addr - TOTAL_MALLOC_LEN; mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); #if !defined(CONFIG_SYS_NO_FLASH) puts("Flash: "); #ifdef CONFIG_NAND_BOOT //wx: norflash will init error when nandboot, resolve it later.~_~ flash_size = (2<<20); #else flash_size = flash_init(); #endif if (flash_size > 0) { # ifdef CONFIG_SYS_FLASH_CHECKSUM char *s = getenv("flashchecksum"); print_size(flash_size, ""); /* * Compute and print flash CRC if flashchecksum is set to 'y' * * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX */ if (s && (*s == 'y')) { printf(" CRC: %08X", crc32(0, (const unsigned char *) CONFIG_SYS_FLASH_BASE, flash_size)); } putc('\n'); # else /* !CONFIG_SYS_FLASH_CHECKSUM */ print_size(flash_size, "\n"); # endif /* CONFIG_SYS_FLASH_CHECKSUM */ } else { puts(failed); hang(); } #endif #if defined(CONFIG_CMD_NAND) puts("NAND: "); nand_init(); /* go init the NAND */ #endif #if defined(CONFIG_CMD_ONENAND) onenand_init(); #endif #ifdef CONFIG_GENERIC_MMC puts("MMC: "); mmc_initialize(gd->bd); #endif #ifdef CONFIG_HAS_DATAFLASH AT91F_DataflashInit(); dataflash_print_info(); #endif /* initialize environment */ env_relocate(); #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI) arm_pci_init(); #endif /* IP Address */ gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr"); stdio_init(); /* get the devices list going. */ jumptable_init(); #if defined(CONFIG_API) /* Initialize API */ api_init(); #endif console_init_r(); /* fully init console as a device */ #if defined(CONFIG_ARCH_MISC_INIT) /* miscellaneous arch dependent initialisations */ arch_misc_init(); #endif #if defined(CONFIG_MISC_INIT_R) /* miscellaneous platform dependent initialisations */ misc_init_r(); #endif /* set up exceptions */ interrupt_init(); /* enable exceptions */ enable_interrupts(); /* Perform network card initialisation if necessary */ #if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96) /* XXX: this needs to be moved to board init */ if (getenv("ethaddr")) { uchar enetaddr[6]; eth_getenv_enetaddr("ethaddr", enetaddr); smc_set_mac_addr(enetaddr); } #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */ /* Initialize from environment */ load_addr = getenv_ulong("loadaddr", 16, load_addr); #if defined(CONFIG_CMD_NET) { char *s = getenv("bootfile"); if (s != NULL) copy_filename(BootFile, s, sizeof(BootFile)); } #endif #ifdef CONFIG_BOARD_LATE_INIT board_late_init(); #endif #ifdef CONFIG_BITBANGMII bb_miiphy_init(); #endif #if defined(CONFIG_CMD_NET) puts("Net: "); eth_initialize(gd->bd); #if defined(CONFIG_RESET_PHY_R) debug("Reset Ethernet PHY\n"); reset_phy(); #endif #endif #ifdef CONFIG_POST post_run(NULL, POST_RAM | post_bootmode_get(0)); #endif #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) /* * Export available size of memory for Linux, * taking into account the protected RAM at top of memory */ { ulong pram = 0; uchar memsz[32]; #ifdef CONFIG_PRAM pram = getenv_ulong("pram", 10, CONFIG_PRAM); #endif #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR /* Also take the logbuffer into account (pram is in kB) */ pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; #endif #endif sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram); setenv("mem", (char *)memsz); } #endif /* main_loop() can return to retry autoboot, if so just run it again. */ for (;;) { main_loop(); } /* NOTREACHED - no way out of command loop except booting */ } void hang(void) { puts("### ERROR ### Please RESET the board ###\n"); for (;;); }
1001-study-uboot
arch/arm/lib/board.c
C
gpl3
18,264
.macro ARM_MOD_BODY dividend, divisor, order, spare #if __LINUX_ARM_ARCH__ >= 5 clz \order, \divisor clz \spare, \dividend sub \order, \order, \spare mov \divisor, \divisor, lsl \order #else mov \order, #0 @ Unless the divisor is very big, shift it up in multiples of @ four bits, since this is the amount of unwinding in the main @ division loop. Continue shifting until the divisor is @ larger than the dividend. 1: cmp \divisor, #0x10000000 cmplo \divisor, \dividend movlo \divisor, \divisor, lsl #4 addlo \order, \order, #4 blo 1b @ For very big divisors, we must shift it a bit at a time, or @ we will be in danger of overflowing. 1: cmp \divisor, #0x80000000 cmplo \divisor, \dividend movlo \divisor, \divisor, lsl #1 addlo \order, \order, #1 blo 1b #endif @ Perform all needed substractions to keep only the reminder. @ Do comparisons in batch of 4 first. subs \order, \order, #3 @ yes, 3 is intended here blt 2f 1: cmp \dividend, \divisor subhs \dividend, \dividend, \divisor cmp \dividend, \divisor, lsr #1 subhs \dividend, \dividend, \divisor, lsr #1 cmp \dividend, \divisor, lsr #2 subhs \dividend, \dividend, \divisor, lsr #2 cmp \dividend, \divisor, lsr #3 subhs \dividend, \dividend, \divisor, lsr #3 cmp \dividend, #1 mov \divisor, \divisor, lsr #4 subges \order, \order, #4 bge 1b tst \order, #3 teqne \dividend, #0 beq 5f @ Either 1, 2 or 3 comparison/substractions are left. 2: cmn \order, #2 blt 4f beq 3f cmp \dividend, \divisor subhs \dividend, \dividend, \divisor mov \divisor, \divisor, lsr #1 3: cmp \dividend, \divisor subhs \dividend, \dividend, \divisor mov \divisor, \divisor, lsr #1 4: cmp \dividend, \divisor subhs \dividend, \dividend, \divisor 5: .endm .align 5 .globl __modsi3 __modsi3: cmp r1, #0 beq Ldiv0 rsbmi r1, r1, #0 @ loops below use unsigned. movs ip, r0 @ preserve sign of dividend rsbmi r0, r0, #0 @ if negative make positive subs r2, r1, #1 @ compare divisor with 1 cmpne r0, r1 @ compare dividend with divisor moveq r0, #0 tsthi r1, r2 @ see if divisor is power of 2 andeq r0, r0, r2 bls 10f ARM_MOD_BODY r0, r1, r2, r3 10: cmp ip, #0 rsbmi r0, r0, #0 mov pc, lr Ldiv0: str lr, [sp, #-4]! bl __div0 mov r0, #0 @ About as wrong as it could be. ldr pc, [sp], #4
1001-study-uboot
arch/arm/lib/_modsi3.S
Unix Assembly
gpl3
2,316
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * (C) Copyright 2002 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> * * (C) Copyright 2004 * DAVE Srl * http://www.dave-tech.it * http://www.wawnet.biz * mailto:info@wawnet.biz * * (C) Copyright 2004 Texas Insturments * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { puts ("resetting ...\n"); udelay (50000); /* wait 50 ms */ disable_interrupts(); reset_cpu(0); /*NOTREACHED*/ return 0; }
1001-study-uboot
arch/arm/lib/reset.c
C
gpl3
1,496
/* * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <common.h> #include <command.h> #include <image.h> #include <u-boot/zlib.h> #include <asm/byteorder.h> #include <fdt.h> #include <libfdt.h> #include <fdt_support.h> DECLARE_GLOBAL_DATA_PTR; #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) static void setup_start_tag (bd_t *bd); # ifdef CONFIG_SETUP_MEMORY_TAGS static void setup_memory_tags (bd_t *bd); # endif static void setup_commandline_tag (bd_t *bd, char *commandline); # ifdef CONFIG_INITRD_TAG static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end); # endif static void setup_end_tag (bd_t *bd); static struct tag *params; #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ static ulong get_sp(void); #if defined(CONFIG_OF_LIBFDT) static int bootm_linux_fdt(int machid, bootm_headers_t *images); #endif void arch_lmb_reserve(struct lmb *lmb) { ulong sp; /* * Booting a (Linux) kernel image * * Allocate space for command line and board info - the * address should be as high as possible within the reach of * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused * memory, which means far enough below the current stack * pointer. */ sp = get_sp(); debug("## Current stack ends at 0x%08lx ", sp); /* adjust sp by 1K to be safe */ sp -= 1024; lmb_reserve(lmb, sp, gd->bd->bi_dram[0].start + gd->bd->bi_dram[0].size - sp); } static void announce_and_cleanup(void) { printf("\nStarting kernel ...\n\n"); #ifdef CONFIG_USB_DEVICE { extern void udc_disconnect(void); udc_disconnect(); } #endif cleanup_before_linux(); } int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) { bd_t *bd = gd->bd; char *s; int machid = bd->bi_arch_number; void (*kernel_entry)(int zero, int arch, uint params); #ifdef CONFIG_CMDLINE_TAG char *commandline = getenv ("bootargs"); #endif if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) return 1; s = getenv ("machid"); if (s) { machid = simple_strtoul (s, NULL, 16); printf ("Using machid 0x%x from environment\n", machid); } show_boot_progress (15); #ifdef CONFIG_OF_LIBFDT if (images->ft_len) return bootm_linux_fdt(machid, images); #endif kernel_entry = (void (*)(int, int, uint))images->ep; debug ("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel_entry); #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) setup_start_tag (bd); #ifdef CONFIG_SERIAL_TAG setup_serial_tag (&params); #endif #ifdef CONFIG_REVISION_TAG setup_revision_tag (&params); #endif #ifdef CONFIG_SETUP_MEMORY_TAGS setup_memory_tags (bd); #endif #ifdef CONFIG_CMDLINE_TAG setup_commandline_tag (bd, commandline); #endif #ifdef CONFIG_INITRD_TAG if (images->rd_start && images->rd_end) setup_initrd_tag (bd, images->rd_start, images->rd_end); #endif setup_end_tag(bd); #endif announce_and_cleanup(); kernel_entry(0, machid, bd->bi_boot_params); /* does not return */ return 1; } #if defined(CONFIG_OF_LIBFDT) static int fixup_memory_node(void *blob) { bd_t *bd = gd->bd; int bank; u64 start[CONFIG_NR_DRAM_BANKS]; u64 size[CONFIG_NR_DRAM_BANKS]; for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { start[bank] = bd->bi_dram[bank].start; size[bank] = bd->bi_dram[bank].size; } return fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS); } static int bootm_linux_fdt(int machid, bootm_headers_t *images) { ulong rd_len; void (*kernel_entry)(int zero, int dt_machid, void *dtblob); ulong of_size = images->ft_len; char **of_flat_tree = &images->ft_addr; ulong *initrd_start = &images->initrd_start; ulong *initrd_end = &images->initrd_end; struct lmb *lmb = &images->lmb; int ret; kernel_entry = (void (*)(int, int, void *))images->ep; boot_fdt_add_mem_rsv_regions(lmb, *of_flat_tree); rd_len = images->rd_end - images->rd_start; ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, initrd_start, initrd_end); if (ret) return ret; ret = boot_relocate_fdt(lmb, of_flat_tree, &of_size); if (ret) return ret; debug("## Transferring control to Linux (at address %08lx) ...\n", (ulong) kernel_entry); fdt_chosen(*of_flat_tree, 1); fixup_memory_node(*of_flat_tree); fdt_fixup_ethernet(*of_flat_tree); fdt_initrd(*of_flat_tree, *initrd_start, *initrd_end, 1); announce_and_cleanup(); kernel_entry(0, machid, *of_flat_tree); /* does not return */ return 1; } #endif #if defined (CONFIG_SETUP_MEMORY_TAGS) || \ defined (CONFIG_CMDLINE_TAG) || \ defined (CONFIG_INITRD_TAG) || \ defined (CONFIG_SERIAL_TAG) || \ defined (CONFIG_REVISION_TAG) static void setup_start_tag (bd_t *bd) { params = (struct tag *) bd->bi_boot_params; params->hdr.tag = ATAG_CORE; params->hdr.size = tag_size (tag_core); params->u.core.flags = 0; params->u.core.pagesize = 0; params->u.core.rootdev = 0; params = tag_next (params); } #ifdef CONFIG_SETUP_MEMORY_TAGS static void setup_memory_tags (bd_t *bd) { int i; for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { params->hdr.tag = ATAG_MEM; params->hdr.size = tag_size (tag_mem32); params->u.mem.start = bd->bi_dram[i].start; params->u.mem.size = bd->bi_dram[i].size; params = tag_next (params); } } #endif /* CONFIG_SETUP_MEMORY_TAGS */ static void setup_commandline_tag (bd_t *bd, char *commandline) { char *p; if (!commandline) return; /* eat leading white space */ for (p = commandline; *p == ' '; p++); /* skip non-existent command lines so the kernel will still * use its default command line. */ if (*p == '\0') return; params->hdr.tag = ATAG_CMDLINE; params->hdr.size = (sizeof (struct tag_header) + strlen (p) + 1 + 4) >> 2; strcpy (params->u.cmdline.cmdline, p); params = tag_next (params); } #ifdef CONFIG_INITRD_TAG static void setup_initrd_tag (bd_t *bd, ulong initrd_start, ulong initrd_end) { /* an ATAG_INITRD node tells the kernel where the compressed * ramdisk can be found. ATAG_RDIMG is a better name, actually. */ params->hdr.tag = ATAG_INITRD2; params->hdr.size = tag_size (tag_initrd); params->u.initrd.start = initrd_start; params->u.initrd.size = initrd_end - initrd_start; params = tag_next (params); } #endif /* CONFIG_INITRD_TAG */ #ifdef CONFIG_SERIAL_TAG void setup_serial_tag (struct tag **tmp) { struct tag *params = *tmp; struct tag_serialnr serialnr; void get_board_serial(struct tag_serialnr *serialnr); get_board_serial(&serialnr); params->hdr.tag = ATAG_SERIAL; params->hdr.size = tag_size (tag_serialnr); params->u.serialnr.low = serialnr.low; params->u.serialnr.high= serialnr.high; params = tag_next (params); *tmp = params; } #endif #ifdef CONFIG_REVISION_TAG void setup_revision_tag(struct tag **in_params) { u32 rev = 0; u32 get_board_rev(void); rev = get_board_rev(); params->hdr.tag = ATAG_REVISION; params->hdr.size = tag_size (tag_revision); params->u.revision.rev = rev; params = tag_next (params); } #endif /* CONFIG_REVISION_TAG */ static void setup_end_tag (bd_t *bd) { params->hdr.tag = ATAG_NONE; params->hdr.size = 0; } #endif /* CONFIG_SETUP_MEMORY_TAGS || CONFIG_CMDLINE_TAG || CONFIG_INITRD_TAG */ static ulong get_sp(void) { ulong ret; asm("mov %0, sp" : "=r"(ret) : ); return ret; }
1001-study-uboot
arch/arm/lib/bootm.c
C
gpl3
8,421
/* * linux/arch/arm/lib/memcpy.S * * Author: Nicolas Pitre * Created: Sep 28, 2005 * Copyright: MontaVista Software, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #include <asm/assembler.h> #define W(instr) instr #define LDR1W_SHIFT 0 #define STR1W_SHIFT 0 .macro ldr1w ptr reg abort W(ldr) \reg, [\ptr], #4 .endm .macro ldr4w ptr reg1 reg2 reg3 reg4 abort ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4} .endm .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8} .endm .macro ldr1b ptr reg cond=al abort ldr\cond\()b \reg, [\ptr], #1 .endm .macro str1w ptr reg abort W(str) \reg, [\ptr], #4 .endm .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort stmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8} .endm .macro str1b ptr reg cond=al abort str\cond\()b \reg, [\ptr], #1 .endm .macro enter reg1 reg2 stmdb sp!, {r0, \reg1, \reg2} .endm .macro exit reg1 reg2 ldmfd sp!, {r0, \reg1, \reg2} .endm .text /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ .globl memcpy memcpy: cmp r0, r1 moveq pc, lr enter r4, lr subs r2, r2, #4 blt 8f ands ip, r0, #3 PLD( pld [r1, #0] ) bne 9f ands ip, r1, #3 bne 10f 1: subs r2, r2, #(28) stmfd sp!, {r5 - r8} blt 5f CALGN( ands ip, r0, #31 ) CALGN( rsb r3, ip, #32 ) CALGN( sbcnes r4, r3, r2 ) @ C is always set here CALGN( bcs 2f ) CALGN( adr r4, 6f ) CALGN( subs r2, r2, r3 ) @ C gets set CALGN( add pc, r4, ip ) PLD( pld [r1, #0] ) 2: PLD( subs r2, r2, #96 ) PLD( pld [r1, #28] ) PLD( blt 4f ) PLD( pld [r1, #60] ) PLD( pld [r1, #92] ) 3: PLD( pld [r1, #124] ) 4: ldr8w r1, r3, r4, r5, r6, r7, r8, ip, lr, abort=20f subs r2, r2, #32 str8w r0, r3, r4, r5, r6, r7, r8, ip, lr, abort=20f bge 3b PLD( cmn r2, #96 ) PLD( bge 4b ) 5: ands ip, r2, #28 rsb ip, ip, #32 #if LDR1W_SHIFT > 0 lsl ip, ip, #LDR1W_SHIFT #endif addne pc, pc, ip @ C is always clear here b 7f 6: .rept (1 << LDR1W_SHIFT) W(nop) .endr ldr1w r1, r3, abort=20f ldr1w r1, r4, abort=20f ldr1w r1, r5, abort=20f ldr1w r1, r6, abort=20f ldr1w r1, r7, abort=20f ldr1w r1, r8, abort=20f ldr1w r1, lr, abort=20f #if LDR1W_SHIFT < STR1W_SHIFT lsl ip, ip, #STR1W_SHIFT - LDR1W_SHIFT #elif LDR1W_SHIFT > STR1W_SHIFT lsr ip, ip, #LDR1W_SHIFT - STR1W_SHIFT #endif add pc, pc, ip nop .rept (1 << STR1W_SHIFT) W(nop) .endr str1w r0, r3, abort=20f str1w r0, r4, abort=20f str1w r0, r5, abort=20f str1w r0, r6, abort=20f str1w r0, r7, abort=20f str1w r0, r8, abort=20f str1w r0, lr, abort=20f CALGN( bcs 2b ) 7: ldmfd sp!, {r5 - r8} 8: movs r2, r2, lsl #31 ldr1b r1, r3, ne, abort=21f ldr1b r1, r4, cs, abort=21f ldr1b r1, ip, cs, abort=21f str1b r0, r3, ne, abort=21f str1b r0, r4, cs, abort=21f str1b r0, ip, cs, abort=21f exit r4, pc 9: rsb ip, ip, #4 cmp ip, #2 ldr1b r1, r3, gt, abort=21f ldr1b r1, r4, ge, abort=21f ldr1b r1, lr, abort=21f str1b r0, r3, gt, abort=21f str1b r0, r4, ge, abort=21f subs r2, r2, ip str1b r0, lr, abort=21f blt 8b ands ip, r1, #3 beq 1b 10: bic r1, r1, #3 cmp ip, #2 ldr1w r1, lr, abort=21f beq 17f bgt 18f .macro forward_copy_shift pull push subs r2, r2, #28 blt 14f CALGN( ands ip, r0, #31 ) CALGN( rsb ip, ip, #32 ) CALGN( sbcnes r4, ip, r2 ) @ C is always set here CALGN( subcc r2, r2, ip ) CALGN( bcc 15f ) 11: stmfd sp!, {r5 - r9} PLD( pld [r1, #0] ) PLD( subs r2, r2, #96 ) PLD( pld [r1, #28] ) PLD( blt 13f ) PLD( pld [r1, #60] ) PLD( pld [r1, #92] ) 12: PLD( pld [r1, #124] ) 13: ldr4w r1, r4, r5, r6, r7, abort=19f mov r3, lr, pull #\pull subs r2, r2, #32 ldr4w r1, r8, r9, ip, lr, abort=19f orr r3, r3, r4, push #\push mov r4, r4, pull #\pull orr r4, r4, r5, push #\push mov r5, r5, pull #\pull orr r5, r5, r6, push #\push mov r6, r6, pull #\pull orr r6, r6, r7, push #\push mov r7, r7, pull #\pull orr r7, r7, r8, push #\push mov r8, r8, pull #\pull orr r8, r8, r9, push #\push mov r9, r9, pull #\pull orr r9, r9, ip, push #\push mov ip, ip, pull #\pull orr ip, ip, lr, push #\push str8w r0, r3, r4, r5, r6, r7, r8, r9, ip, , abort=19f bge 12b PLD( cmn r2, #96 ) PLD( bge 13b ) ldmfd sp!, {r5 - r9} 14: ands ip, r2, #28 beq 16f 15: mov r3, lr, pull #\pull ldr1w r1, lr, abort=21f subs ip, ip, #4 orr r3, r3, lr, push #\push str1w r0, r3, abort=21f bgt 15b CALGN( cmp r2, #0 ) CALGN( bge 11b ) 16: sub r1, r1, #(\push / 8) b 8b .endm forward_copy_shift pull=8 push=24 17: forward_copy_shift pull=16 push=16 18: forward_copy_shift pull=24 push=8
1001-study-uboot
arch/arm/lib/memcpy.S
Unix Assembly
gpl3
4,928
/* * (C) Copyright 2003 * Texas Instruments <www.ti.com> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Marius Groeger <mgroeger@sysgo.de> * * (C) Copyright 2002 * Sysgo Real-Time Solutions, GmbH <www.elinos.com> * Alex Zuepke <azu@sysgo.de> * * (C) Copyright 2002-2004 * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de> * * (C) Copyright 2004 * Philippe Robin, ARM Ltd. <philippe.robin@arm.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <asm/proc-armv/ptrace.h> DECLARE_GLOBAL_DATA_PTR; #ifdef CONFIG_USE_IRQ int interrupt_init (void) { /* * setup up stacks if necessary */ IRQ_STACK_START = gd->irq_sp - 4; IRQ_STACK_START_IN = gd->irq_sp + 8; FIQ_STACK_START = IRQ_STACK_START - CONFIG_STACKSIZE_IRQ; return arch_interrupt_init(); } /* enable IRQ interrupts */ void enable_interrupts (void) { unsigned long temp; __asm__ __volatile__("mrs %0, cpsr\n" "bic %0, %0, #0x80\n" "msr cpsr_c, %0" : "=r" (temp) : : "memory"); } /* * disable IRQ/FIQ interrupts * returns true if interrupts had been enabled before we disabled them */ int disable_interrupts (void) { unsigned long old,temp; __asm__ __volatile__("mrs %0, cpsr\n" "orr %1, %0, #0xc0\n" "msr cpsr_c, %1" : "=r" (old), "=r" (temp) : : "memory"); return (old & 0x80) == 0; } #else int interrupt_init (void) { /* * setup up stacks if necessary */ IRQ_STACK_START_IN = gd->irq_sp + 8; return 0; } void enable_interrupts (void) { return; } int disable_interrupts (void) { return 0; } #endif void bad_mode (void) { panic ("Resetting CPU ...\n"); reset_cpu (0); } void show_regs (struct pt_regs *regs) { unsigned long flags; const char *processor_modes[] = { "USER_26", "FIQ_26", "IRQ_26", "SVC_26", "UK4_26", "UK5_26", "UK6_26", "UK7_26", "UK8_26", "UK9_26", "UK10_26", "UK11_26", "UK12_26", "UK13_26", "UK14_26", "UK15_26", "USER_32", "FIQ_32", "IRQ_32", "SVC_32", "UK4_32", "UK5_32", "UK6_32", "ABT_32", "UK8_32", "UK9_32", "UK10_32", "UND_32", "UK12_32", "UK13_32", "UK14_32", "SYS_32", }; flags = condition_codes (regs); printf ("pc : [<%08lx>] lr : [<%08lx>]\n" "sp : %08lx ip : %08lx fp : %08lx\n", instruction_pointer (regs), regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp); printf ("r10: %08lx r9 : %08lx r8 : %08lx\n", regs->ARM_r10, regs->ARM_r9, regs->ARM_r8); printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n", regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4); printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n", regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0); printf ("Flags: %c%c%c%c", flags & CC_N_BIT ? 'N' : 'n', flags & CC_Z_BIT ? 'Z' : 'z', flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v'); printf (" IRQs %s FIQs %s Mode %s%s\n", interrupts_enabled (regs) ? "on" : "off", fast_interrupts_enabled (regs) ? "on" : "off", processor_modes[processor_mode (regs)], thumb_mode (regs) ? " (T)" : ""); } void do_undefined_instruction (struct pt_regs *pt_regs) { printf ("undefined instruction\n"); show_regs (pt_regs); bad_mode (); } void do_software_interrupt (struct pt_regs *pt_regs) { printf ("software interrupt\n"); show_regs (pt_regs); bad_mode (); } void do_prefetch_abort (struct pt_regs *pt_regs) { printf ("prefetch abort\n"); show_regs (pt_regs); bad_mode (); } void do_data_abort (struct pt_regs *pt_regs) { printf ("data abort\n"); show_regs (pt_regs); bad_mode (); } void do_not_used (struct pt_regs *pt_regs) { printf ("not used\n"); show_regs (pt_regs); bad_mode (); } void do_fiq (struct pt_regs *pt_regs) { printf ("fast interrupt request\n"); show_regs (pt_regs); bad_mode (); } #ifndef CONFIG_USE_IRQ void do_irq (struct pt_regs *pt_regs) { printf ("interrupt request\n"); show_regs (pt_regs); bad_mode (); } #endif
1001-study-uboot
arch/arm/lib/interrupts.c
C
gpl3
4,697
/* * linux/arch/arm/lib/memset.S * * Copyright (C) 1995-2000 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * ASM optimised string functions */ #include <asm/assembler.h> .text .align 5 .word 0 1: subs r2, r2, #4 @ 1 do we have enough blt 5f @ 1 bytes to align with? cmp r3, #2 @ 1 strltb r1, [r0], #1 @ 1 strleb r1, [r0], #1 @ 1 strb r1, [r0], #1 @ 1 add r2, r2, r3 @ 1 (r2 = r2 - (4 - r3)) /* * The pointer is now aligned and the length is adjusted. Try doing the * memset again. */ .globl memset memset: ands r3, r0, #3 @ 1 unaligned? bne 1b @ 1 /* * we know that the pointer in r0 is aligned to a word boundary. */ orr r1, r1, r1, lsl #8 orr r1, r1, r1, lsl #16 mov r3, r1 cmp r2, #16 blt 4f #if ! CALGN(1)+0 /* * We need an extra register for this loop - save the return address and * use the LR */ str lr, [sp, #-4]! mov ip, r1 mov lr, r1 2: subs r2, r2, #64 stmgeia r0!, {r1, r3, ip, lr} @ 64 bytes at a time. stmgeia r0!, {r1, r3, ip, lr} stmgeia r0!, {r1, r3, ip, lr} stmgeia r0!, {r1, r3, ip, lr} bgt 2b ldmeqfd sp!, {pc} @ Now <64 bytes to go. /* * No need to correct the count; we're only testing bits from now on */ tst r2, #32 stmneia r0!, {r1, r3, ip, lr} stmneia r0!, {r1, r3, ip, lr} tst r2, #16 stmneia r0!, {r1, r3, ip, lr} ldr lr, [sp], #4 #else /* * This version aligns the destination pointer in order to write * whole cache lines at once. */ stmfd sp!, {r4-r7, lr} mov r4, r1 mov r5, r1 mov r6, r1 mov r7, r1 mov ip, r1 mov lr, r1 cmp r2, #96 tstgt r0, #31 ble 3f and ip, r0, #31 rsb ip, ip, #32 sub r2, r2, ip movs ip, ip, lsl #(32 - 4) stmcsia r0!, {r4, r5, r6, r7} stmmiia r0!, {r4, r5} tst ip, #(1 << 30) mov ip, r1 strne r1, [r0], #4 3: subs r2, r2, #64 stmgeia r0!, {r1, r3-r7, ip, lr} stmgeia r0!, {r1, r3-r7, ip, lr} bgt 3b ldmeqfd sp!, {r4-r7, pc} tst r2, #32 stmneia r0!, {r1, r3-r7, ip, lr} tst r2, #16 stmneia r0!, {r4-r7} ldmfd sp!, {r4-r7, lr} #endif 4: tst r2, #8 stmneia r0!, {r1, r3} tst r2, #4 strne r1, [r0], #4 /* * When we get here, we've got less than 4 bytes to zero. We * may have an unaligned pointer as well. */ 5: tst r2, #2 strneb r1, [r0], #1 strneb r1, [r0], #1 tst r2, #1 strneb r1, [r0], #1 mov pc, lr
1001-study-uboot
arch/arm/lib/memset.S
Unix Assembly
gpl3
2,437
# # (C) Copyright 2002-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # include $(TOPDIR)/config.mk LIB = $(obj)lib$(ARCH).o LIBGCC = $(obj)libgcc.o ifndef CONFIG_SPL_BUILD GLSOBJS += _ashldi3.o GLSOBJS += _ashrdi3.o GLSOBJS += _divsi3.o GLSOBJS += _lshrdi3.o GLSOBJS += _modsi3.o GLSOBJS += _udivsi3.o GLSOBJS += _umodsi3.o GLCOBJS += div0.o COBJS-y += board.o COBJS-y += bootm.o COBJS-y += cache.o COBJS-y += cache-cp15.o COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o COBJS-y += interrupts.o COBJS-y += reset.o SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o endif SRCS := $(GLSOBJS:.o=.S) $(GLCOBJS:.o=.c) \ $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y)) LGOBJS := $(addprefix $(obj),$(GLSOBJS)) \ $(addprefix $(obj),$(GLCOBJS)) # Always build libarm.o TARGETS := $(LIB) # Build private libgcc only when asked for ifdef USE_PRIVATE_LIBGCC TARGETS += $(LIBGCC) endif # For EABI conformant tool chains, provide eabi_compat() ifneq (,$(findstring -mabi=aapcs-linux,$(PLATFORM_CPPFLAGS))) TARGETS += $(obj)eabi_compat.o endif all: $(TARGETS) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) $(LIBGCC): $(obj).depend $(LGOBJS) $(call cmd_link_o_target, $(LGOBJS)) ######################################################################### # defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend #########################################################################
1001-study-uboot
arch/arm/lib/Makefile
Makefile
gpl3
2,302
/* # 1 "libgcc1.S" */ @ libgcc1 routines for ARM cpu. @ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk) /* # 145 "libgcc1.S" */ dividend .req r0 divisor .req r1 overdone .req r2 curbit .req r3 /* ip .req r12 */ /* sp .req r13 */ /* lr .req r14 */ /* pc .req r15 */ .text .globl __umodsi3 .type __umodsi3 ,function .align 0 __umodsi3 : cmp divisor, #0 beq Ldiv0 mov curbit, #1 cmp dividend, divisor movcc pc, lr Loop1: @ Unless the divisor is very big, shift it up in multiples of @ four bits, since this is the amount of unwinding in the main @ division loop. Continue shifting until the divisor is @ larger than the dividend. cmp divisor, #0x10000000 cmpcc divisor, dividend movcc divisor, divisor, lsl #4 movcc curbit, curbit, lsl #4 bcc Loop1 Lbignum: @ For very big divisors, we must shift it a bit at a time, or @ we will be in danger of overflowing. cmp divisor, #0x80000000 cmpcc divisor, dividend movcc divisor, divisor, lsl #1 movcc curbit, curbit, lsl #1 bcc Lbignum Loop3: @ Test for possible subtractions. On the final pass, this may @ subtract too much from the dividend, so keep track of which @ subtractions are done, we can fix them up afterwards... mov overdone, #0 cmp dividend, divisor subcs dividend, dividend, divisor cmp dividend, divisor, lsr #1 subcs dividend, dividend, divisor, lsr #1 orrcs overdone, overdone, curbit, ror #1 cmp dividend, divisor, lsr #2 subcs dividend, dividend, divisor, lsr #2 orrcs overdone, overdone, curbit, ror #2 cmp dividend, divisor, lsr #3 subcs dividend, dividend, divisor, lsr #3 orrcs overdone, overdone, curbit, ror #3 mov ip, curbit cmp dividend, #0 @ Early termination? movnes curbit, curbit, lsr #4 @ No, any more bits to do? movne divisor, divisor, lsr #4 bne Loop3 @ Any subtractions that we should not have done will be recorded in @ the top three bits of "overdone". Exactly which were not needed @ are governed by the position of the bit, stored in ip. @ If we terminated early, because dividend became zero, @ then none of the below will match, since the bit in ip will not be @ in the bottom nibble. ands overdone, overdone, #0xe0000000 moveq pc, lr @ No fixups needed tst overdone, ip, ror #3 addne dividend, dividend, divisor, lsr #3 tst overdone, ip, ror #2 addne dividend, dividend, divisor, lsr #2 tst overdone, ip, ror #1 addne dividend, dividend, divisor, lsr #1 mov pc, lr Ldiv0: str lr, [sp, #-4]! bl __div0 (PLT) mov r0, #0 @ about as wrong as it could be ldmia sp!, {pc} .size __umodsi3 , . - __umodsi3 /* # 320 "libgcc1.S" */ /* # 421 "libgcc1.S" */ /* # 433 "libgcc1.S" */ /* # 456 "libgcc1.S" */ /* # 500 "libgcc1.S" */ /* # 580 "libgcc1.S" */
1001-study-uboot
arch/arm/lib/_umodsi3.S
Motorola 68K Assembly
gpl3
2,762
/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 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, or (at your option) any later version. In addition to the permissions in the GNU General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combine executable.) 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. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef __ARMEB__ #define al r1 #define ah r0 #else #define al r0 #define ah r1 #endif .globl __ashrdi3 .globl __aeabi_lasr __ashrdi3: __aeabi_lasr: subs r3, r2, #32 rsb ip, r2, #32 movmi al, al, lsr r2 movpl al, ah, asr r3 orrmi al, al, ah, lsl ip mov ah, ah, asr r2 mov pc, lr
1001-study-uboot
arch/arm/lib/_ashrdi3.S
Unix Assembly
gpl3
1,549
/* * Utility functions needed for (some) EABI conformant tool chains. * * (C) Copyright 2009 Wolfgang Denk <wd@denx.de> * * 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. */ #include <common.h> int raise (int signum) { #if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf("raise: Signal # %d caught\n", signum); #endif return 0; } /* Dummy function to avoid linker complaints */ void __aeabi_unwind_cpp_pr0(void) { }; void __aeabi_unwind_cpp_pr1(void) { };
1001-study-uboot
arch/arm/lib/eabi_compat.c
C
gpl3
697
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> #include <asm/system.h> #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) #if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH) #define CACHE_SETUP 0x1a #else #define CACHE_SETUP 0x1e #endif DECLARE_GLOBAL_DATA_PTR; void __arm_init_before_mmu(void) { } void arm_init_before_mmu(void) __attribute__((weak, alias("__arm_init_before_mmu"))); static void cp_delay (void) { volatile int i; /* copro seems to need some delay between reading and writing */ for (i = 0; i < 100; i++) nop(); asm volatile("" : : : "memory"); } static inline void dram_bank_mmu_setup(int bank) { u32 *page_table = (u32 *)gd->tlb_addr; bd_t *bd = gd->bd; int i; debug("%s: bank: %d\n", __func__, bank); for (i = bd->bi_dram[bank].start >> 20; i < (bd->bi_dram[bank].start + bd->bi_dram[bank].size) >> 20; i++) { page_table[i] = i << 20 | (3 << 10) | CACHE_SETUP; } } /* to activate the MMU we need to set up virtual memory: use 1M areas */ static inline void mmu_setup(void) { u32 *page_table = (u32 *)gd->tlb_addr; int i; u32 reg; arm_init_before_mmu(); /* Set up an identity-mapping for all 4GB, rw for everyone */ for (i = 0; i < 4096; i++) page_table[i] = i << 20 | (3 << 10) | 0x12; for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { dram_bank_mmu_setup(i); } /* Copy the page table address to cp15 */ asm volatile("mcr p15, 0, %0, c2, c0, 0" : : "r" (page_table) : "memory"); /* Set the access control to all-supervisor */ asm volatile("mcr p15, 0, %0, c3, c0, 0" : : "r" (~0)); /* and enable the mmu */ reg = get_cr(); /* get control reg. */ cp_delay(); set_cr(reg | CR_M); } static int mmu_enabled(void) { return get_cr() & CR_M; } /* cache_bit must be either CR_I or CR_C */ static void cache_enable(uint32_t cache_bit) { uint32_t reg; /* The data cache is not active unless the mmu is enabled too */ if ((cache_bit == CR_C) && !mmu_enabled()) mmu_setup(); reg = get_cr(); /* get control reg. */ cp_delay(); set_cr(reg | cache_bit); } /* cache_bit must be either CR_I or CR_C */ static void cache_disable(uint32_t cache_bit) { uint32_t reg; if (cache_bit == CR_C) { /* if cache isn;t enabled no need to disable */ reg = get_cr(); if ((reg & CR_C) != CR_C) return; /* if disabling data cache, disable mmu too */ cache_bit |= CR_M; flush_dcache_all(); } reg = get_cr(); cp_delay(); set_cr(reg & ~cache_bit); } #endif #ifdef CONFIG_SYS_ICACHE_OFF void icache_enable (void) { return; } void icache_disable (void) { return; } int icache_status (void) { return 0; /* always off */ } #else void icache_enable(void) { cache_enable(CR_I); } void icache_disable(void) { cache_disable(CR_I); } int icache_status(void) { return (get_cr() & CR_I) != 0; } #endif #ifdef CONFIG_SYS_DCACHE_OFF void dcache_enable (void) { return; } void dcache_disable (void) { return; } int dcache_status (void) { return 0; /* always off */ } #else void dcache_enable(void) { cache_enable(CR_C); } void dcache_disable(void) { cache_disable(CR_C); } int dcache_status(void) { return (get_cr() & CR_C) != 0; } #endif
1001-study-uboot
arch/arm/lib/cache-cp15.c
C
gpl3
4,013
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* for now: just dummy functions to satisfy the linker */ #include <common.h> void __flush_cache(unsigned long start, unsigned long size) { #if defined(CONFIG_OMAP2420) || defined(CONFIG_ARM1136) void arm1136_cache_flush(void); arm1136_cache_flush(); #endif #ifdef CONFIG_ARM926EJS /* test and clean, page 2-23 of arm926ejs manual */ asm("0: mrc p15, 0, r15, c7, c10, 3\n\t" "bne 0b\n" : : : "memory"); /* disable write buffer as well (page 2-22) */ asm("mcr p15, 0, %0, c7, c10, 4" : : "r" (0)); #endif return; } void flush_cache(unsigned long start, unsigned long size) __attribute__((weak, alias("__flush_cache"))); /* * Default implementation: * do a range flush for the entire range */ void __flush_dcache_all(void) { flush_cache(0, ~0); } void flush_dcache_all(void) __attribute__((weak, alias("__flush_dcache_all"))); /* * Default implementation of enable_caches() * Real implementation should be in platform code */ void __enable_caches(void) { puts("WARNING: Caches not enabled\n"); } void enable_caches(void) __attribute__((weak, alias("__enable_caches")));
1001-study-uboot
arch/arm/lib/cache.c
C
gpl3
1,976
/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 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, or (at your option) any later version. In addition to the permissions in the GNU General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combine executable.) 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. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef __ARMEB__ #define al r1 #define ah r0 #else #define al r0 #define ah r1 #endif .globl __ashldi3 .globl __aeabi_llsl __ashldi3: __aeabi_llsl: subs r3, r2, #32 rsb ip, r2, #32 movmi ah, ah, lsl r2 movpl ah, al, lsl r3 orrmi ah, ah, al, lsr ip mov al, al, lsl r2 mov pc, lr
1001-study-uboot
arch/arm/lib/_ashldi3.S
Unix Assembly
gpl3
1,549
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* Replacement (=dummy) for GNU/Linux division-by zero handler */ void __div0 (void) { extern void hang (void); hang(); }
1001-study-uboot
arch/arm/lib/div0.c
C
gpl3
1,007
/* Copyright 1995, 1996, 1998, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. 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, or (at your option) any later version. In addition to the permissions in the GNU General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combine executable.) 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. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifdef __ARMEB__ #define al r1 #define ah r0 #else #define al r0 #define ah r1 #endif .globl __lshrdi3 .globl __aeabi_llsr __lshrdi3: __aeabi_llsr: subs r3, r2, #32 rsb ip, r2, #32 movmi al, al, lsr r2 movpl al, ah, lsr r3 orrmi al, al, ah, lsl ip mov ah, ah, lsr r2 mov pc, lr
1001-study-uboot
arch/arm/lib/_lshrdi3.S
Unix Assembly
gpl3
1,549
/* # 1 "libgcc1.S" */ @ libgcc1 routines for ARM cpu. @ Division routines, written by Richard Earnshaw, (rearnsha@armltd.co.uk) dividend .req r0 divisor .req r1 result .req r2 curbit .req r3 /* ip .req r12 */ /* sp .req r13 */ /* lr .req r14 */ /* pc .req r15 */ .text .globl __udivsi3 .type __udivsi3 ,function .globl __aeabi_uidiv .type __aeabi_uidiv ,function .align 0 __udivsi3: __aeabi_uidiv: cmp divisor, #0 beq Ldiv0 mov curbit, #1 mov result, #0 cmp dividend, divisor bcc Lgot_result Loop1: @ Unless the divisor is very big, shift it up in multiples of @ four bits, since this is the amount of unwinding in the main @ division loop. Continue shifting until the divisor is @ larger than the dividend. cmp divisor, #0x10000000 cmpcc divisor, dividend movcc divisor, divisor, lsl #4 movcc curbit, curbit, lsl #4 bcc Loop1 Lbignum: @ For very big divisors, we must shift it a bit at a time, or @ we will be in danger of overflowing. cmp divisor, #0x80000000 cmpcc divisor, dividend movcc divisor, divisor, lsl #1 movcc curbit, curbit, lsl #1 bcc Lbignum Loop3: @ Test for possible subtractions, and note which bits @ are done in the result. On the final pass, this may subtract @ too much from the dividend, but the result will be ok, since the @ "bit" will have been shifted out at the bottom. cmp dividend, divisor subcs dividend, dividend, divisor orrcs result, result, curbit cmp dividend, divisor, lsr #1 subcs dividend, dividend, divisor, lsr #1 orrcs result, result, curbit, lsr #1 cmp dividend, divisor, lsr #2 subcs dividend, dividend, divisor, lsr #2 orrcs result, result, curbit, lsr #2 cmp dividend, divisor, lsr #3 subcs dividend, dividend, divisor, lsr #3 orrcs result, result, curbit, lsr #3 cmp dividend, #0 @ Early termination? movnes curbit, curbit, lsr #4 @ No, any more bits to do? movne divisor, divisor, lsr #4 bne Loop3 Lgot_result: mov r0, result mov pc, lr Ldiv0: str lr, [sp, #-4]! bl __div0 (PLT) mov r0, #0 @ about as wrong as it could be ldmia sp!, {pc} .size __udivsi3 , . - __udivsi3 .globl __aeabi_uidivmod __aeabi_uidivmod: stmfd sp!, {r0, r1, ip, lr} bl __aeabi_uidiv ldmfd sp!, {r1, r2, ip, lr} mul r3, r0, r2 sub r1, r1, r3 mov pc, lr .globl __aeabi_idivmod __aeabi_idivmod: stmfd sp!, {r0, r1, ip, lr} bl __aeabi_idiv ldmfd sp!, {r1, r2, ip, lr} mul r3, r0, r2 sub r1, r1, r3 mov pc, lr
1001-study-uboot
arch/arm/lib/_udivsi3.S
Motorola 68K Assembly
gpl3
2,431
/* * (C) Copyright 2010 * Texas Instruments, <www.ti.com> * Aneesh V <aneesh@ti.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <linux/types.h> #include <asm/io.h> #include <asm/armv7.h> #include <asm/pl310.h> #include <config.h> #include <common.h> struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE; static void pl310_cache_sync(void) { writel(0, &pl310->pl310_cache_sync); } static void pl310_background_op_all_ways(u32 *op_reg) { u32 assoc_16, associativity, way_mask; assoc_16 = readl(&pl310->pl310_aux_ctrl) & PL310_AUX_CTRL_ASSOCIATIVITY_MASK; if (assoc_16) associativity = 16; else associativity = 8; way_mask = (1 << associativity) - 1; /* Invalidate all ways */ writel(way_mask, op_reg); /* Wait for all ways to be invalidated */ while (readl(op_reg) && way_mask) ; pl310_cache_sync(); } void v7_outer_cache_inval_all(void) { pl310_background_op_all_ways(&pl310->pl310_inv_way); } void v7_outer_cache_flush_all(void) { pl310_background_op_all_ways(&pl310->pl310_clean_inv_way); } /* Flush(clean invalidate) memory from start to stop-1 */ void v7_outer_cache_flush_range(u32 start, u32 stop) { /* PL310 currently supports only 32 bytes cache line */ u32 pa, line_size = 32; /* * Align to the beginning of cache-line - this ensures that * the first 5 bits are 0 as required by PL310 TRM */ start &= ~(line_size - 1); for (pa = start; pa < stop; pa = pa + line_size) writel(pa, &pl310->pl310_clean_inv_line_pa); pl310_cache_sync(); } /* invalidate memory from start to stop-1 */ void v7_outer_cache_inval_range(u32 start, u32 stop) { /* PL310 currently supports only 32 bytes cache line */ u32 pa, line_size = 32; /* * If start address is not aligned to cache-line do not * invalidate the first cache-line */ if (start & (line_size - 1)) { printf("ERROR: %s - start address is not aligned - 0x%08x\n", __func__, start); /* move to next cache line */ start = (start + line_size - 1) & ~(line_size - 1); } /* * If stop address is not aligned to cache-line do not * invalidate the last cache-line */ if (stop & (line_size - 1)) { printf("ERROR: %s - stop address is not aligned - 0x%08x\n", __func__, stop); /* align to the beginning of this cache line */ stop &= ~(line_size - 1); } for (pa = start; pa < stop; pa = pa + line_size) writel(pa, &pl310->pl310_inv_line_pa); pl310_cache_sync(); }
1001-study-uboot
arch/arm/lib/cache-pl310.c
C
gpl3
3,185
.macro ARM_DIV_BODY dividend, divisor, result, curbit #if __LINUX_ARM_ARCH__ >= 5 clz \curbit, \divisor clz \result, \dividend sub \result, \curbit, \result mov \curbit, #1 mov \divisor, \divisor, lsl \result mov \curbit, \curbit, lsl \result mov \result, #0 #else @ Initially shift the divisor left 3 bits if possible, @ set curbit accordingly. This allows for curbit to be located @ at the left end of each 4 bit nibbles in the division loop @ to save one loop in most cases. tst \divisor, #0xe0000000 moveq \divisor, \divisor, lsl #3 moveq \curbit, #8 movne \curbit, #1 @ Unless the divisor is very big, shift it up in multiples of @ four bits, since this is the amount of unwinding in the main @ division loop. Continue shifting until the divisor is @ larger than the dividend. 1: cmp \divisor, #0x10000000 cmplo \divisor, \dividend movlo \divisor, \divisor, lsl #4 movlo \curbit, \curbit, lsl #4 blo 1b @ For very big divisors, we must shift it a bit at a time, or @ we will be in danger of overflowing. 1: cmp \divisor, #0x80000000 cmplo \divisor, \dividend movlo \divisor, \divisor, lsl #1 movlo \curbit, \curbit, lsl #1 blo 1b mov \result, #0 #endif @ Division loop 1: cmp \dividend, \divisor subhs \dividend, \dividend, \divisor orrhs \result, \result, \curbit cmp \dividend, \divisor, lsr #1 subhs \dividend, \dividend, \divisor, lsr #1 orrhs \result, \result, \curbit, lsr #1 cmp \dividend, \divisor, lsr #2 subhs \dividend, \dividend, \divisor, lsr #2 orrhs \result, \result, \curbit, lsr #2 cmp \dividend, \divisor, lsr #3 subhs \dividend, \dividend, \divisor, lsr #3 orrhs \result, \result, \curbit, lsr #3 cmp \dividend, #0 @ Early termination? movnes \curbit, \curbit, lsr #4 @ No, any more bits to do? movne \divisor, \divisor, lsr #4 bne 1b .endm .macro ARM_DIV2_ORDER divisor, order #if __LINUX_ARM_ARCH__ >= 5 clz \order, \divisor rsb \order, \order, #31 #else cmp \divisor, #(1 << 16) movhs \divisor, \divisor, lsr #16 movhs \order, #16 movlo \order, #0 cmp \divisor, #(1 << 8) movhs \divisor, \divisor, lsr #8 addhs \order, \order, #8 cmp \divisor, #(1 << 4) movhs \divisor, \divisor, lsr #4 addhs \order, \order, #4 cmp \divisor, #(1 << 2) addhi \order, \order, #3 addls \order, \order, \divisor, lsr #1 #endif .endm .align 5 .globl __divsi3 .globl __aeabi_idiv __divsi3: __aeabi_idiv: cmp r1, #0 eor ip, r0, r1 @ save the sign of the result. beq Ldiv0 rsbmi r1, r1, #0 @ loops below use unsigned. subs r2, r1, #1 @ division by 1 or -1 ? beq 10f movs r3, r0 rsbmi r3, r0, #0 @ positive dividend value cmp r3, r1 bls 11f tst r1, r2 @ divisor is power of 2 ? beq 12f ARM_DIV_BODY r3, r1, r0, r2 cmp ip, #0 rsbmi r0, r0, #0 mov pc, lr 10: teq ip, r0 @ same sign ? rsbmi r0, r0, #0 mov pc, lr 11: movlo r0, #0 moveq r0, ip, asr #31 orreq r0, r0, #1 mov pc, lr 12: ARM_DIV2_ORDER r1, r2 cmp ip, #0 mov r0, r3, lsr r2 rsbmi r0, r0, #0 mov pc, lr Ldiv0: str lr, [sp, #-4]! bl __div0 mov r0, #0 @ About as wrong as it could be. ldr pc, [sp], #4
1001-study-uboot
arch/arm/lib/_divsi3.S
Unix Assembly
gpl3
3,127
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * Be sure to mark tests to be run before relocation as such with the * CONFIG_SYS_POST_PREREL flag so that logging is done correctly if the * logbuffer support is enabled. */ #include <common.h> #include <post.h> extern int ocm_post_test (int flags); extern int cache_post_test (int flags); extern int watchdog_post_test (int flags); extern int i2c_post_test (int flags); extern int rtc_post_test (int flags); extern int memory_post_test (int flags); extern int cpu_post_test (int flags); extern int fpu_post_test (int flags); extern int uart_post_test (int flags); extern int ether_post_test (int flags); extern int spi_post_test (int flags); extern int usb_post_test (int flags); extern int spr_post_test (int flags); extern int sysmon_post_test (int flags); extern int dsp_post_test (int flags); extern int codec_post_test (int flags); extern int ecc_post_test (int flags); extern int flash_post_test(int flags); extern int dspic_init_post_test (int flags); extern int dspic_post_test (int flags); extern int gdc_post_test (int flags); extern int fpga_post_test (int flags); extern int lwmon5_watchdog_post_test(int flags); extern int sysmon1_post_test(int flags); extern int coprocessor_post_test(int flags); extern int led_post_test(int flags); extern int button_post_test(int flags); extern int memory_regions_post_test(int flags); extern int sysmon_init_f (void); extern void sysmon_reloc (void); struct post_test post_list[] = { #if CONFIG_POST & CONFIG_SYS_POST_OCM { "OCM test", "ocm", "This test checks on chip memory (OCM).", POST_ROM | POST_ALWAYS | POST_PREREL | POST_CRITICAL | POST_STOP, &ocm_post_test, NULL, NULL, CONFIG_SYS_POST_OCM }, #endif #if CONFIG_POST & CONFIG_SYS_POST_CACHE { "Cache test", "cache", "This test verifies the CPU cache operation.", POST_RAM | POST_ALWAYS, &cache_post_test, NULL, NULL, CONFIG_SYS_POST_CACHE }, #endif #if CONFIG_POST & CONFIG_SYS_POST_WATCHDOG #if defined(CONFIG_POST_WATCHDOG) CONFIG_POST_WATCHDOG, #else { "Watchdog timer test", "watchdog", "This test checks the watchdog timer.", POST_RAM | POST_POWERON | POST_SLOWTEST | POST_MANUAL | POST_REBOOT, &watchdog_post_test, NULL, NULL, CONFIG_SYS_POST_WATCHDOG }, #endif #endif #if CONFIG_POST & CONFIG_SYS_POST_I2C { "I2C test", "i2c", "This test verifies the I2C operation.", POST_RAM | POST_ALWAYS, &i2c_post_test, NULL, NULL, CONFIG_SYS_POST_I2C }, #endif #if CONFIG_POST & CONFIG_SYS_POST_RTC { "RTC test", "rtc", "This test verifies the RTC operation.", POST_RAM | POST_SLOWTEST | POST_MANUAL, &rtc_post_test, NULL, NULL, CONFIG_SYS_POST_RTC }, #endif #if CONFIG_POST & CONFIG_SYS_POST_MEMORY { "Memory test", "memory", "This test checks RAM.", POST_ROM | POST_POWERON | POST_SLOWTEST | POST_PREREL, &memory_post_test, NULL, NULL, CONFIG_SYS_POST_MEMORY }, #endif #if CONFIG_POST & CONFIG_SYS_POST_CPU { "CPU test", "cpu", "This test verifies the arithmetic logic unit of" " CPU.", POST_RAM | POST_ALWAYS, &cpu_post_test, NULL, NULL, CONFIG_SYS_POST_CPU }, #endif #if CONFIG_POST & CONFIG_SYS_POST_FPU { "FPU test", "fpu", "This test verifies the arithmetic logic unit of" " FPU.", POST_RAM | POST_ALWAYS, &fpu_post_test, NULL, NULL, CONFIG_SYS_POST_FPU }, #endif #if CONFIG_POST & CONFIG_SYS_POST_UART #if defined(CONFIG_POST_UART) CONFIG_POST_UART, #else { "UART test", "uart", "This test verifies the UART operation.", POST_RAM | POST_SLOWTEST | POST_MANUAL, &uart_post_test, NULL, NULL, CONFIG_SYS_POST_UART }, #endif /* CONFIG_POST_UART */ #endif #if CONFIG_POST & CONFIG_SYS_POST_ETHER { "ETHERNET test", "ethernet", "This test verifies the ETHERNET operation.", POST_RAM | POST_ALWAYS | POST_MANUAL, &ether_post_test, NULL, NULL, CONFIG_SYS_POST_ETHER }, #endif #if CONFIG_POST & CONFIG_SYS_POST_SPI { "SPI test", "spi", "This test verifies the SPI operation.", POST_RAM | POST_ALWAYS | POST_MANUAL, &spi_post_test, NULL, NULL, CONFIG_SYS_POST_SPI }, #endif #if CONFIG_POST & CONFIG_SYS_POST_USB { "USB test", "usb", "This test verifies the USB operation.", POST_RAM | POST_ALWAYS | POST_MANUAL, &usb_post_test, NULL, NULL, CONFIG_SYS_POST_USB }, #endif #if CONFIG_POST & CONFIG_SYS_POST_SPR { "SPR test", "spr", "This test checks SPR contents.", POST_RAM | POST_ALWAYS, &spr_post_test, NULL, NULL, CONFIG_SYS_POST_SPR }, #endif #if CONFIG_POST & CONFIG_SYS_POST_SYSMON { "SYSMON test", "sysmon", "This test monitors system hardware.", POST_RAM | POST_ALWAYS, &sysmon_post_test, &sysmon_init_f, &sysmon_reloc, CONFIG_SYS_POST_SYSMON }, #endif #if CONFIG_POST & CONFIG_SYS_POST_DSP { "DSP test", "dsp", "This test checks any connected DSP(s).", POST_RAM | POST_ALWAYS | POST_MANUAL, &dsp_post_test, NULL, NULL, CONFIG_SYS_POST_DSP }, #endif #if CONFIG_POST & CONFIG_SYS_POST_CODEC { "CODEC test", "codec", "This test checks any connected codec(s).", POST_RAM | POST_MANUAL, &codec_post_test, NULL, NULL, CONFIG_SYS_POST_CODEC }, #endif #if CONFIG_POST & CONFIG_SYS_POST_ECC { "ECC test", "ecc", "This test checks the ECC facility of memory.", POST_ROM | POST_ALWAYS | POST_PREREL, &ecc_post_test, NULL, NULL, CONFIG_SYS_POST_ECC }, #endif #if CONFIG_POST & CONFIG_SYS_POST_BSPEC1 CONFIG_POST_BSPEC1, #endif #if CONFIG_POST & CONFIG_SYS_POST_BSPEC2 CONFIG_POST_BSPEC2, #endif #if CONFIG_POST & CONFIG_SYS_POST_BSPEC3 CONFIG_POST_BSPEC3, #endif #if CONFIG_POST & CONFIG_SYS_POST_BSPEC4 CONFIG_POST_BSPEC4, #endif #if CONFIG_POST & CONFIG_SYS_POST_BSPEC5 CONFIG_POST_BSPEC5, #endif #if CONFIG_POST & CONFIG_SYS_POST_COPROC { "Coprocessors communication test", "coproc_com", "This test checks communication with coprocessors.", POST_RAM | POST_ALWAYS | POST_CRITICAL, &coprocessor_post_test, NULL, NULL, CONFIG_SYS_POST_COPROC }, #endif #if CONFIG_POST & CONFIG_SYS_POST_FLASH { "Parallel NOR flash test", "flash", "This test verifies parallel flash operations.", POST_RAM | POST_SLOWTEST | POST_MANUAL, &flash_post_test, NULL, NULL, CONFIG_SYS_POST_FLASH }, #endif #if CONFIG_POST & CONFIG_SYS_POST_MEM_REGIONS { "Memory regions test", "mem_regions", "This test checks regularly placed regions of the RAM.", POST_ROM | POST_SLOWTEST | POST_PREREL, &memory_regions_post_test, NULL, NULL, CONFIG_SYS_POST_MEM_REGIONS }, #endif }; unsigned int post_list_size = ARRAY_SIZE(post_list);
1001-study-uboot
post/tests.c
C
gpl3
7,420
# # (C) Copyright 2002-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # include $(TOPDIR)/config.mk COBJS := $(COBJS-y) AOBJS := $(AOBJS-y) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS)) LIB := $(obj)$(LIB) CPPFLAGS += -I$(TOPDIR) all: $(LIB) $(LIB): $(obj).depend $(OBJS) $(call cmd_link_o_target, $(OBJS)) ######################################################################### # defines $(obj).depend target include $(SRCTREE)/rules.mk sinclude $(obj).depend #########################################################################
1001-study-uboot
post/rules.mk
Makefile
gpl3
1,376
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Condition register istructions: mtcr, mfcr, mcrxr, * crand, crandc, cror, crorc, crxor, * crnand, crnor, creqv, mcrf * * The mtcrf/mfcr instructions is tested by loading different * values into the condition register (mtcrf), moving its value * to a general-purpose register (mfcr) and comparing this value * with the expected one. * The mcrxr instruction is tested by loading a fixed value * into the XER register (mtspr), moving XER value to the * condition register (mcrxr), moving it to a general-purpose * register (mfcr) and comparing the value of this register with * the expected one. * The rest of instructions is tested by loading a fixed * value into the condition register (mtcrf), executing each * instruction several times to modify all 4-bit condition * fields, moving the value of the conditional register to a * general-purpose register (mfcr) and comparing it with the * expected one. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); extern void cpu_post_exec_21x (ulong *code, ulong *op1, ulong *op2, ulong op3); static ulong cpu_post_cr_table1[] = { 0xaaaaaaaa, 0x55555555, }; static unsigned int cpu_post_cr_size1 = ARRAY_SIZE(cpu_post_cr_table1); static struct cpu_post_cr_s2 { ulong xer; ulong cr; } cpu_post_cr_table2[] = { { 0xa0000000, 1 }, { 0x40000000, 5 }, }; static unsigned int cpu_post_cr_size2 = ARRAY_SIZE(cpu_post_cr_table2); static struct cpu_post_cr_s3 { ulong cr; ulong cs; ulong cd; ulong res; } cpu_post_cr_table3[] = { { 0x01234567, 0, 4, 0x01230567 }, { 0x01234567, 7, 0, 0x71234567 }, }; static unsigned int cpu_post_cr_size3 = ARRAY_SIZE(cpu_post_cr_table3); static struct cpu_post_cr_s4 { ulong cmd; ulong cr; ulong op1; ulong op2; ulong op3; ulong res; } cpu_post_cr_table4[] = { { OP_CRAND, 0x0000ffff, 0, 16, 0, 0x0000ffff }, { OP_CRAND, 0x0000ffff, 16, 17, 0, 0x8000ffff }, { OP_CRANDC, 0x0000ffff, 0, 16, 0, 0x0000ffff }, { OP_CRANDC, 0x0000ffff, 16, 0, 0, 0x8000ffff }, { OP_CROR, 0x0000ffff, 0, 16, 0, 0x8000ffff }, { OP_CROR, 0x0000ffff, 0, 1, 0, 0x0000ffff }, { OP_CRORC, 0x0000ffff, 0, 16, 0, 0x0000ffff }, { OP_CRORC, 0x0000ffff, 0, 0, 0, 0x8000ffff }, { OP_CRXOR, 0x0000ffff, 0, 0, 0, 0x0000ffff }, { OP_CRXOR, 0x0000ffff, 0, 16, 0, 0x8000ffff }, { OP_CRNAND, 0x0000ffff, 0, 16, 0, 0x8000ffff }, { OP_CRNAND, 0x0000ffff, 16, 17, 0, 0x0000ffff }, { OP_CRNOR, 0x0000ffff, 0, 16, 0, 0x0000ffff }, { OP_CRNOR, 0x0000ffff, 0, 1, 0, 0x8000ffff }, { OP_CREQV, 0x0000ffff, 0, 0, 0, 0x8000ffff }, { OP_CREQV, 0x0000ffff, 0, 16, 0, 0x0000ffff }, }; static unsigned int cpu_post_cr_size4 = ARRAY_SIZE(cpu_post_cr_table4); int cpu_post_test_cr (void) { int ret = 0; unsigned int i; unsigned long cr_sav; int flag = disable_interrupts(); asm ( "mfcr %0" : "=r" (cr_sav) : ); for (i = 0; i < cpu_post_cr_size1 && ret == 0; i++) { ulong cr = cpu_post_cr_table1[i]; ulong res; unsigned long code[] = { ASM_MTCR(3), ASM_MFCR(3), ASM_BLR, }; cpu_post_exec_11 (code, &res, cr); ret = res == cr ? 0 : -1; if (ret != 0) { post_log ("Error at cr1 test %d !\n", i); } } for (i = 0; i < cpu_post_cr_size2 && ret == 0; i++) { struct cpu_post_cr_s2 *test = cpu_post_cr_table2 + i; ulong res; ulong xer; unsigned long code[] = { ASM_MTXER(3), ASM_MCRXR(test->cr), ASM_MFCR(3), ASM_MFXER(4), ASM_BLR, }; cpu_post_exec_21x (code, &res, &xer, test->xer); ret = xer == 0 && ((res << (4 * test->cr)) & 0xe0000000) == test->xer ? 0 : -1; if (ret != 0) { post_log ("Error at cr2 test %d !\n", i); } } for (i = 0; i < cpu_post_cr_size3 && ret == 0; i++) { struct cpu_post_cr_s3 *test = cpu_post_cr_table3 + i; ulong res; unsigned long code[] = { ASM_MTCR(3), ASM_MCRF(test->cd, test->cs), ASM_MFCR(3), ASM_BLR, }; cpu_post_exec_11 (code, &res, test->cr); ret = res == test->res ? 0 : -1; if (ret != 0) { post_log ("Error at cr3 test %d !\n", i); } } for (i = 0; i < cpu_post_cr_size4 && ret == 0; i++) { struct cpu_post_cr_s4 *test = cpu_post_cr_table4 + i; ulong res; unsigned long code[] = { ASM_MTCR(3), ASM_12F(test->cmd, test->op3, test->op1, test->op2), ASM_MFCR(3), ASM_BLR, }; cpu_post_exec_11 (code, &res, test->cr); ret = res == test->res ? 0 : -1; if (ret != 0) { post_log ("Error at cr4 test %d !\n", i); } } asm ( "mtcr %0" : : "r" (cr_sav)); if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/cr.c
C
gpl3
5,862
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Load/store string instructions: lswi, stswi, lswx, stswx * * Several consecutive bytes from a source memory buffer are loaded * left to right into GPRs. After that, the bytes are stored * from the GPRs into a target memory buffer. The contents * of the source and target buffers are then compared. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_02 (ulong *code, ulong op1, ulong op2); extern void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, ulong op4); #include <bedbug/regs.h> int cpu_post_test_string (void) { int ret = 0; unsigned int i; int flag = disable_interrupts(); if (ret == 0) { char src [31], dst [31]; ulong code[] = { ASM_LSWI(5, 3, 31), ASM_STSWI(5, 4, 31), ASM_BLR, }; for (i = 0; i < sizeof(src); i ++) { src[i] = (char) i; dst[i] = 0; } cpu_post_exec_02(code, (ulong)src, (ulong)dst); ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1; } if (ret == 0) { char src [95], dst [95]; ulong code[] = { ASM_LSWX(8, 3, 5), ASM_STSWX(8, 4, 5), ASM_BLR, }; for (i = 0; i < sizeof(src); i ++) { src[i] = (char) i; dst[i] = 0; } cpu_post_exec_04(code, (ulong)src, (ulong)dst, 0, sizeof(src)); ret = memcmp(src, dst, sizeof(dst)) == 0 ? 0 : -1; } if (ret != 0) { post_log ("Error at string test !\n"); } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/string.c
C
gpl3
2,415
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Load instructions: lbz(x)(u), lhz(x)(u), lha(x)(u), lwz(x)(u) * * All operations are performed on a 16-byte array. The array * is 4-byte aligned. The base register points to offset 8. * The immediate offset (index register) ranges in [-8 ... +7]. * The test cases are composed so that they do not * cause alignment exceptions. * The test contains a pre-built table describing all test cases. * The table entry contains: * the instruction opcode, the array contents, the value of the index * register and the expected value of the destination register. * After executing the instruction, the test verifies the * value of the destination register and the value of the base * register (it must change for "load with update" instructions). */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_22w (ulong *code, ulong *op1, ulong op2, ulong *op3); extern void cpu_post_exec_21w (ulong *code, ulong *op1, ulong *op2); static struct cpu_post_load_s { ulong cmd; uint width; int update; int index; ulong offset; } cpu_post_load_table[] = { { OP_LWZ, 4, 0, 0, 4 }, { OP_LHA, 3, 0, 0, 2 }, { OP_LHZ, 2, 0, 0, 2 }, { OP_LBZ, 1, 0, 0, 1 }, { OP_LWZU, 4, 1, 0, 4 }, { OP_LHAU, 3, 1, 0, 2 }, { OP_LHZU, 2, 1, 0, 2 }, { OP_LBZU, 1, 1, 0, 1 }, { OP_LWZX, 4, 0, 1, 4 }, { OP_LHAX, 3, 0, 1, 2 }, { OP_LHZX, 2, 0, 1, 2 }, { OP_LBZX, 1, 0, 1, 1 }, { OP_LWZUX, 4, 1, 1, 4 }, { OP_LHAUX, 3, 1, 1, 2 }, { OP_LHZUX, 2, 1, 1, 2 }, { OP_LBZUX, 1, 1, 1, 1 }, }; static unsigned int cpu_post_load_size = ARRAY_SIZE(cpu_post_load_table); int cpu_post_test_load (void) { int ret = 0; unsigned int i; int flag = disable_interrupts(); for (i = 0; i < cpu_post_load_size && ret == 0; i++) { struct cpu_post_load_s *test = cpu_post_load_table + i; uchar data[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; ulong base0 = (ulong) (data + 8); ulong base = base0; ulong value; if (test->index) { ulong code[] = { ASM_12(test->cmd, 5, 3, 4), ASM_BLR, }; cpu_post_exec_22w (code, &base, test->offset, &value); } else { ulong code[] = { ASM_11I(test->cmd, 4, 3, test->offset), ASM_BLR, }; cpu_post_exec_21w (code, &base, &value); } if (ret == 0) { if (test->update) ret = base == base0 + test->offset ? 0 : -1; else ret = base == base0 ? 0 : -1; } if (ret == 0) { switch (test->width) { case 1: ret = *(uchar *)(base0 + test->offset) == value ? 0 : -1; break; case 2: ret = *(ushort *)(base0 + test->offset) == value ? 0 : -1; break; case 3: ret = *(short *)(base0 + test->offset) == value ? 0 : -1; break; case 4: ret = *(ulong *)(base0 + test->offset) == value ? 0 : -1; break; } } if (ret != 0) { post_log ("Error at load test %d !\n", i); } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/load.c
C
gpl3
4,121
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Branch instructions: b, bl, bc * * The first 2 instructions (b, bl) are verified by jumping * to a fixed address and checking whether control was transfered * to that very point. For the bl instruction the value of the * link register is checked as well (using mfspr). * To verify the bc instruction various combinations of the BI/BO * fields, the CTR and the condition register values are * checked. The list of such combinations is pre-built and * linked in U-Boot at build time. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); extern void cpu_post_exec_31 (ulong *code, ulong *ctr, ulong *lr, ulong *jump, ulong cr); static int cpu_post_test_bc (ulong cmd, ulong bo, ulong bi, int pjump, int decr, int link, ulong pctr, ulong cr) { int ret = 0; ulong lr = 0; ulong ctr = pctr; ulong jump; unsigned long code[] = { ASM_MTCR(6), ASM_MFLR(6), ASM_MTCTR(3), ASM_MTLR(4), ASM_LI(5, 1), ASM_3O(cmd, bo, bi, 8), ASM_LI(5, 0), ASM_MFCTR(3), ASM_MFLR(4), ASM_MTLR(6), ASM_BLR, }; cpu_post_exec_31 (code, &ctr, &lr, &jump, cr); if (ret == 0) ret = pjump == jump ? 0 : -1; if (ret == 0) { if (decr) ret = pctr == ctr + 1 ? 0 : -1; else ret = pctr == ctr ? 0 : -1; } if (ret == 0) { if (link) ret = lr == (ulong) code + 24 ? 0 : -1; else ret = lr == 0 ? 0 : -1; } return ret; } int cpu_post_test_b (void) { int ret = 0; unsigned int i; int flag = disable_interrupts(); if (ret == 0) { ulong code[] = { ASM_MFLR(4), ASM_MTLR(3), ASM_B(4), ASM_MFLR(3), ASM_MTLR(4), ASM_BLR, }; ulong res; cpu_post_exec_11 (code, &res, 0); ret = res == 0 ? 0 : -1; if (ret != 0) { post_log ("Error at b1 test !\n"); } } if (ret == 0) { ulong code[] = { ASM_MFLR(4), ASM_MTLR(3), ASM_BL(4), ASM_MFLR(3), ASM_MTLR(4), ASM_BLR, }; ulong res; cpu_post_exec_11 (code, &res, 0); ret = res == (ulong)code + 12 ? 0 : -1; if (ret != 0) { post_log ("Error at b2 test !\n"); } } if (ret == 0) { ulong cc, cd; int cond; ulong ctr; int link; i = 0; for (cc = 0; cc < 4 && ret == 0; cc++) { for (cd = 0; cd < 4 && ret == 0; cd++) { for (link = 0; link <= 1 && ret == 0; link++) { for (cond = 0; cond <= 1 && ret == 0; cond++) { for (ctr = 1; ctr <= 2 && ret == 0; ctr++) { int decr = cd < 2; int cr = cond ? 0x80000000 : 0x00000000; int jumpc = cc >= 2 || (cc == 0 && !cond) || (cc == 1 && cond); int jumpd = cd >= 2 || (cd == 0 && ctr != 1) || (cd == 1 && ctr == 1); int jump = jumpc && jumpd; ret = cpu_post_test_bc (link ? OP_BCL : OP_BC, (cc << 3) + (cd << 1), 0, jump, decr, link, ctr, cr); if (ret != 0) { post_log ("Error at b3 test %d !\n", i); } i++; } } } } } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/b.c
C
gpl3
4,038
/* * Copyright (C) 2002 Wolfgang Denk <wd@denx.de> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <config.h> #include <post.h> #include <ppc_asm.tmpl> #include <ppc_defs.h> #include <asm/cache.h> #if CONFIG_POST & CONFIG_SYS_POST_CPU /* void cpu_post_exec_02 (ulong *code, ulong op1, ulong op2); */ .global cpu_post_exec_02 cpu_post_exec_02: isync mflr r0 stwu r0, -4(r1) subi r1, r1, 104 stmw r6, 0(r1) mtlr r3 mr r3, r4 mr r4, r5 blrl lmw r6, 0(r1) addi r1, r1, 104 lwz r0, 0(r1) addi r1, r1, 4 mtlr r0 blr /* void cpu_post_exec_04 (ulong *code, ulong op1, ulong op2, ulong op3, ulong op4); */ .global cpu_post_exec_04 cpu_post_exec_04: isync mflr r0 stwu r0, -4(r1) subi r1, r1, 96 stmw r8, 0(r1) mtlr r3 mr r3, r4 mr r4, r5 mr r5, r6 mtxer r7 blrl lmw r8, 0(r1) addi r1, r1, 96 lwz r0, 0(r1) addi r1, r1, 4 mtlr r0 blr /* void cpu_post_exec_12 (ulong *code, ulong *res, ulong op1, ulong op2); */ .global cpu_post_exec_12 cpu_post_exec_12: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) mtlr r3 mr r3, r5 mr r4, r6 blrl lwz r4, 0(r1) stw r3, 0(r4) lwz r0, 4(r1) addi r1, r1, 8 mtlr r0 blr /* void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); */ .global cpu_post_exec_11 cpu_post_exec_11: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) mtlr r3 mr r3, r5 blrl lwz r4, 0(r1) stw r3, 0(r4) lwz r0, 4(r1) addi r1, r1, 8 mtlr r0 blr /* void cpu_post_exec_21 (ulong *code, ulong *cr, ulong *res, ulong op1); */ .global cpu_post_exec_21 cpu_post_exec_21: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) stwu r5, -4(r1) li r0, 0 mtxer r0 lwz r0, 0(r4) mtcr r0 mtlr r3 mr r3, r6 blrl mfcr r0 lwz r4, 4(r1) stw r0, 0(r4) lwz r4, 0(r1) stw r3, 0(r4) lwz r0, 8(r1) addi r1, r1, 12 mtlr r0 blr /* void cpu_post_exec_22 (ulong *code, ulong *cr, ulong *res, ulong op1, ulong op2); */ .global cpu_post_exec_22 cpu_post_exec_22: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) stwu r5, -4(r1) li r0, 0 mtxer r0 lwz r0, 0(r4) mtcr r0 mtlr r3 mr r3, r6 mr r4, r7 blrl mfcr r0 lwz r4, 4(r1) stw r0, 0(r4) lwz r4, 0(r1) stw r3, 0(r4) lwz r0, 8(r1) addi r1, r1, 12 mtlr r0 blr /* void cpu_post_exec_12w (ulong *code, ulong *op1, ulong op2, ulong op3); */ .global cpu_post_exec_12w cpu_post_exec_12w: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) mtlr r3 lwz r3, 0(r4) mr r4, r5 mr r5, r6 blrl lwz r4, 0(r1) stw r3, 0(r4) lwz r0, 4(r1) addi r1, r1, 8 mtlr r0 blr /* void cpu_post_exec_11w (ulong *code, ulong *op1, ulong op2); */ .global cpu_post_exec_11w cpu_post_exec_11w: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) mtlr r3 lwz r3, 0(r4) mr r4, r5 blrl lwz r4, 0(r1) stw r3, 0(r4) lwz r0, 4(r1) addi r1, r1, 8 mtlr r0 blr /* void cpu_post_exec_22w (ulong *code, ulong *op1, ulong op2, ulong *op3); */ .global cpu_post_exec_22w cpu_post_exec_22w: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) stwu r6, -4(r1) mtlr r3 lwz r3, 0(r4) mr r4, r5 blrl lwz r4, 4(r1) stw r3, 0(r4) lwz r4, 0(r1) stw r5, 0(r4) lwz r0, 8(r1) addi r1, r1, 12 mtlr r0 blr /* void cpu_post_exec_21w (ulong *code, ulong *op1, ulong *op2); */ .global cpu_post_exec_21w cpu_post_exec_21w: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) stwu r5, -4(r1) mtlr r3 lwz r3, 0(r4) blrl lwz r5, 4(r1) stw r3, 0(r5) lwz r5, 0(r1) stw r4, 0(r5) lwz r0, 8(r1) addi r1, r1, 12 mtlr r0 blr /* void cpu_post_exec_21x (ulong *code, ulong *op1, ulong *op2, ulong op3); */ .global cpu_post_exec_21x cpu_post_exec_21x: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) stwu r5, -4(r1) mtlr r3 mr r3, r6 blrl lwz r5, 4(r1) stw r3, 0(r5) lwz r5, 0(r1) stw r4, 0(r5) lwz r0, 8(r1) addi r1, r1, 12 mtlr r0 blr /* void cpu_post_exec_31 (ulong *code, ulong *ctr, ulong *lr, ulong *jump, ulong cr); */ .global cpu_post_exec_31 cpu_post_exec_31: isync mflr r0 stwu r0, -4(r1) stwu r4, -4(r1) stwu r5, -4(r1) stwu r6, -4(r1) mtlr r3 lwz r3, 0(r4) lwz r4, 0(r5) mr r6, r7 mfcr r7 blrl mtcr r7 lwz r7, 8(r1) stw r3, 0(r7) lwz r7, 4(r1) stw r4, 0(r7) lwz r7, 0(r1) stw r5, 0(r7) lwz r0, 12(r1) addi r1, r1, 16 mtlr r0 blr /* int cpu_post_complex_1_asm (int a1, int a2, int a3, int a4, int n); */ .global cpu_post_complex_1_asm cpu_post_complex_1_asm: li r9,0 cmpw r9,r7 bge cpu_post_complex_1_done mtctr r7 cpu_post_complex_1_loop: mullw r0,r3,r4 subf r0,r5,r0 divw r0,r0,r6 add r9,r9,r0 bdnz cpu_post_complex_1_loop cpu_post_complex_1_done: mr r3,r9 blr /* int cpu_post_complex_2_asm (int x, int n); */ .global cpu_post_complex_2_asm cpu_post_complex_2_asm: mr. r0,r4 mtctr r0 mr r0,r3 li r3,1 li r4,1 blelr cpu_post_complex_2_loop: mullw r3,r3,r0 add r3,r3,r4 bdnz cpu_post_complex_2_loop blr #endif
1001-study-uboot
post/lib_powerpc/asm.S
Unix Assembly
gpl3
5,589
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Shift instructions: srawi * * The test contains a pre-built table of instructions, operands and * expected results. For each table entry, the test will cyclically use * different sets of operand registers and result registers. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_21 (ulong *code, ulong *cr, ulong *res, ulong op); extern ulong cpu_post_makecr (long v); static struct cpu_post_srawi_s { ulong cmd; ulong op1; uchar op2; ulong res; } cpu_post_srawi_table[] = { { OP_SRAWI, 0x8000, 3, 0x1000 }, { OP_SRAWI, 0x80000000, 3, 0xf0000000 }, }; static unsigned int cpu_post_srawi_size = ARRAY_SIZE(cpu_post_srawi_table); int cpu_post_test_srawi (void) { int ret = 0; unsigned int i, reg; int flag = disable_interrupts(); for (i = 0; i < cpu_post_srawi_size && ret == 0; i++) { struct cpu_post_srawi_s *test = cpu_post_srawi_table + i; for (reg = 0; reg < 32 && ret == 0; reg++) { unsigned int reg0 = (reg + 0) % 32; unsigned int reg1 = (reg + 1) % 32; unsigned int stk = reg < 16 ? 31 : 15; unsigned long code[] = { ASM_STW(stk, 1, -4), ASM_ADDI(stk, 1, -16), ASM_STW(3, stk, 8), ASM_STW(reg0, stk, 4), ASM_STW(reg1, stk, 0), ASM_LWZ(reg0, stk, 8), ASM_11S(test->cmd, reg1, reg0, test->op2), ASM_STW(reg1, stk, 8), ASM_LWZ(reg1, stk, 0), ASM_LWZ(reg0, stk, 4), ASM_LWZ(3, stk, 8), ASM_ADDI(1, stk, 16), ASM_LWZ(stk, 1, -4), ASM_BLR, }; unsigned long codecr[] = { ASM_STW(stk, 1, -4), ASM_ADDI(stk, 1, -16), ASM_STW(3, stk, 8), ASM_STW(reg0, stk, 4), ASM_STW(reg1, stk, 0), ASM_LWZ(reg0, stk, 8), ASM_11S(test->cmd, reg1, reg0, test->op2) | BIT_C, ASM_STW(reg1, stk, 8), ASM_LWZ(reg1, stk, 0), ASM_LWZ(reg0, stk, 4), ASM_LWZ(3, stk, 8), ASM_ADDI(1, stk, 16), ASM_LWZ(stk, 1, -4), ASM_BLR, }; ulong res; ulong cr; if (ret == 0) { cr = 0; cpu_post_exec_21 (code, & cr, & res, test->op1); ret = res == test->res && cr == 0 ? 0 : -1; if (ret != 0) { post_log ("Error at srawi test %d !\n", i); } } if (ret == 0) { cpu_post_exec_21 (codecr, & cr, & res, test->op1); ret = res == test->res && (cr & 0xe0000000) == cpu_post_makecr (res) ? 0 : -1; if (ret != 0) { post_log ("Error at srawi test %d !\n", i); } } } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/srawi.c
C
gpl3
3,444
# # (C) Copyright 2002-2006 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. # # 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. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA # include $(TOPDIR)/config.mk LIB = libpost$(ARCH).o AOBJS-$(CONFIG_HAS_POST) += asm.o COBJS-$(CONFIG_HAS_POST) += cpu.o cmp.o cmpi.o two.o twox.o three.o threex.o COBJS-$(CONFIG_HAS_POST) += threei.o andi.o srawi.o rlwnm.o rlwinm.o rlwimi.o COBJS-$(CONFIG_HAS_POST) += store.o load.o cr.o b.o multi.o string.o complex.o include $(TOPDIR)/post/rules.mk
1001-study-uboot
post/lib_powerpc/Makefile
Makefile
gpl3
1,219
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * * This test checks the arithmetic logic unit (ALU) of CPU. * It tests independently various groups of instructions using * run-time modification of the code to reduce the memory footprint. * For more details refer to post/cpu/ *.c files. */ #include <watchdog.h> #include <post.h> #include <asm/mmu.h> #if CONFIG_POST & CONFIG_SYS_POST_CPU extern int cpu_post_test_cmp (void); extern int cpu_post_test_cmpi (void); extern int cpu_post_test_two (void); extern int cpu_post_test_twox (void); extern int cpu_post_test_three (void); extern int cpu_post_test_threex (void); extern int cpu_post_test_threei (void); extern int cpu_post_test_andi (void); extern int cpu_post_test_srawi (void); extern int cpu_post_test_rlwnm (void); extern int cpu_post_test_rlwinm (void); extern int cpu_post_test_rlwimi (void); extern int cpu_post_test_store (void); extern int cpu_post_test_load (void); extern int cpu_post_test_cr (void); extern int cpu_post_test_b (void); extern int cpu_post_test_multi (void); extern int cpu_post_test_string (void); extern int cpu_post_test_complex (void); DECLARE_GLOBAL_DATA_PTR; ulong cpu_post_makecr (long v) { ulong cr = 0; if (v < 0) cr |= 0x80000000; if (v > 0) cr |= 0x40000000; if (v == 0) cr |= 0x20000000; return cr; } int cpu_post_test (int flags) { int ic = icache_status (); int ret = 0; WATCHDOG_RESET(); if (ic) icache_disable (); #ifdef CONFIG_4xx_DCACHE /* disable cache */ change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, TLB_WORD2_I_ENABLE); #endif if (ret == 0) ret = cpu_post_test_cmp (); if (ret == 0) ret = cpu_post_test_cmpi (); if (ret == 0) ret = cpu_post_test_two (); if (ret == 0) ret = cpu_post_test_twox (); WATCHDOG_RESET(); if (ret == 0) ret = cpu_post_test_three (); if (ret == 0) ret = cpu_post_test_threex (); if (ret == 0) ret = cpu_post_test_threei (); if (ret == 0) ret = cpu_post_test_andi (); WATCHDOG_RESET(); if (ret == 0) ret = cpu_post_test_srawi (); if (ret == 0) ret = cpu_post_test_rlwnm (); if (ret == 0) ret = cpu_post_test_rlwinm (); if (ret == 0) ret = cpu_post_test_rlwimi (); WATCHDOG_RESET(); if (ret == 0) ret = cpu_post_test_store (); if (ret == 0) ret = cpu_post_test_load (); if (ret == 0) ret = cpu_post_test_cr (); if (ret == 0) ret = cpu_post_test_b (); WATCHDOG_RESET(); if (ret == 0) ret = cpu_post_test_multi (); WATCHDOG_RESET(); if (ret == 0) ret = cpu_post_test_string (); if (ret == 0) ret = cpu_post_test_complex (); WATCHDOG_RESET(); if (ic) icache_enable (); #ifdef CONFIG_4xx_DCACHE /* enable cache */ change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, 0); #endif WATCHDOG_RESET(); return ret; } #endif /* CONFIG_POST & CONFIG_SYS_POST_CPU */
1001-study-uboot
post/lib_powerpc/cpu.c
C
gpl3
3,665
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Ternary instructions instr rD,rA,rB * * Arithmetic instructions: add, addc, adde, subf, subfc, subfe, * mullw, mulhw, mulhwu, divw, divwu * * The test contains a pre-built table of instructions, operands and * expected results. For each table entry, the test will cyclically use * different sets of operand registers and result registers. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_22 (ulong *code, ulong *cr, ulong *res, ulong op1, ulong op2); extern ulong cpu_post_makecr (long v); static struct cpu_post_three_s { ulong cmd; ulong op1; ulong op2; ulong res; } cpu_post_three_table[] = { { OP_ADD, 100, 200, 300 }, { OP_ADD, 100, -200, -100 }, { OP_ADDC, 100, 200, 300 }, { OP_ADDC, 100, -200, -100 }, { OP_ADDE, 100, 200, 300 }, { OP_ADDE, 100, -200, -100 }, { OP_SUBF, 100, 200, 100 }, { OP_SUBF, 300, 200, -100 }, { OP_SUBFC, 100, 200, 100 }, { OP_SUBFC, 300, 200, -100 }, { OP_SUBFE, 100, 200, 200 + ~100 }, { OP_SUBFE, 300, 200, 200 + ~300 }, { OP_MULLW, 200, 300, 200 * 300 }, { OP_MULHW, 0x10000000, 0x10000000, 0x1000000 }, { OP_MULHWU, 0x80000000, 0x80000000, 0x40000000 }, { OP_DIVW, -20, 5, -4 }, { OP_DIVWU, 0x8000, 0x200, 0x40 }, }; static unsigned int cpu_post_three_size = ARRAY_SIZE(cpu_post_three_table); int cpu_post_test_three (void) { int ret = 0; unsigned int i, reg; int flag = disable_interrupts(); for (i = 0; i < cpu_post_three_size && ret == 0; i++) { struct cpu_post_three_s *test = cpu_post_three_table + i; for (reg = 0; reg < 32 && ret == 0; reg++) { unsigned int reg0 = (reg + 0) % 32; unsigned int reg1 = (reg + 1) % 32; unsigned int reg2 = (reg + 2) % 32; unsigned int stk = reg < 16 ? 31 : 15; unsigned long code[] = { ASM_STW(stk, 1, -4), ASM_ADDI(stk, 1, -24), ASM_STW(3, stk, 12), ASM_STW(4, stk, 16), ASM_STW(reg0, stk, 8), ASM_STW(reg1, stk, 4), ASM_STW(reg2, stk, 0), ASM_LWZ(reg1, stk, 12), ASM_LWZ(reg0, stk, 16), ASM_12(test->cmd, reg2, reg1, reg0), ASM_STW(reg2, stk, 12), ASM_LWZ(reg2, stk, 0), ASM_LWZ(reg1, stk, 4), ASM_LWZ(reg0, stk, 8), ASM_LWZ(3, stk, 12), ASM_ADDI(1, stk, 24), ASM_LWZ(stk, 1, -4), ASM_BLR, }; unsigned long codecr[] = { ASM_STW(stk, 1, -4), ASM_ADDI(stk, 1, -24), ASM_STW(3, stk, 12), ASM_STW(4, stk, 16), ASM_STW(reg0, stk, 8), ASM_STW(reg1, stk, 4), ASM_STW(reg2, stk, 0), ASM_LWZ(reg1, stk, 12), ASM_LWZ(reg0, stk, 16), ASM_12(test->cmd, reg2, reg1, reg0) | BIT_C, ASM_STW(reg2, stk, 12), ASM_LWZ(reg2, stk, 0), ASM_LWZ(reg1, stk, 4), ASM_LWZ(reg0, stk, 8), ASM_LWZ(3, stk, 12), ASM_ADDI(1, stk, 24), ASM_LWZ(stk, 1, -4), ASM_BLR, }; ulong res; ulong cr; if (ret == 0) { cr = 0; cpu_post_exec_22 (code, & cr, & res, test->op1, test->op2); ret = res == test->res && cr == 0 ? 0 : -1; if (ret != 0) { post_log ("Error at three test %d !\n", i); } } if (ret == 0) { cpu_post_exec_22 (codecr, & cr, & res, test->op1, test->op2); ret = res == test->res && (cr & 0xe0000000) == cpu_post_makecr (res) ? 0 : -1; if (ret != 0) { post_log ("Error at three test %d !\n", i); } } } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/three.c
C
gpl3
4,496
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Integer compare instructions: cmpw, cmplw * * To verify these instructions the test runs them with * different combinations of operands, reads the condition * register value and compares it with the expected one. * The test contains a pre-built table * containing the description of each test case: the instruction, * the values of the operands, the condition field to save * the result in and the expected result. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_12 (ulong *code, ulong *res, ulong op1, ulong op2); static struct cpu_post_cmp_s { ulong cmd; ulong op1; ulong op2; ulong cr; ulong res; } cpu_post_cmp_table[] = { { OP_CMPW, 123, 123, 2, 0x02 }, { OP_CMPW, 123, 133, 3, 0x08 }, { OP_CMPW, 123, -133, 4, 0x04 }, { OP_CMPLW, 123, 123, 2, 0x02 }, { OP_CMPLW, 123, -133, 3, 0x08 }, { OP_CMPLW, 123, 113, 4, 0x04 }, }; static unsigned int cpu_post_cmp_size = ARRAY_SIZE(cpu_post_cmp_table); int cpu_post_test_cmp (void) { int ret = 0; unsigned int i; int flag = disable_interrupts(); for (i = 0; i < cpu_post_cmp_size && ret == 0; i++) { struct cpu_post_cmp_s *test = cpu_post_cmp_table + i; unsigned long code[] = { ASM_2C(test->cmd, test->cr, 3, 4), ASM_MFCR(3), ASM_BLR }; ulong res; cpu_post_exec_12 (code, & res, test->op1, test->op2); ret = ((res >> (28 - 4 * test->cr)) & 0xe) == test->res ? 0 : -1; if (ret != 0) { post_log ("Error at cmp test %d !\n", i); } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/cmp.c
C
gpl3
2,590
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Ternary instructions instr rA,rS,UIMM * * Logic instructions: ori, oris, xori, xoris * * The test contains a pre-built table of instructions, operands and * expected results. For each table entry, the test will cyclically use * different sets of operand registers and result registers. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_21 (ulong *code, ulong *cr, ulong *res, ulong op); extern ulong cpu_post_makecr (long v); static struct cpu_post_threei_s { ulong cmd; ulong op1; ushort op2; ulong res; } cpu_post_threei_table[] = { { OP_ORI, 0x80000000, 0xffff, 0x8000ffff }, { OP_ORIS, 0x00008000, 0xffff, 0xffff8000 }, { OP_XORI, 0x8000ffff, 0xffff, 0x80000000 }, { OP_XORIS, 0x00008000, 0xffff, 0xffff8000 }, }; static unsigned int cpu_post_threei_size = ARRAY_SIZE(cpu_post_threei_table); int cpu_post_test_threei (void) { int ret = 0; unsigned int i, reg; int flag = disable_interrupts(); for (i = 0; i < cpu_post_threei_size && ret == 0; i++) { struct cpu_post_threei_s *test = cpu_post_threei_table + i; for (reg = 0; reg < 32 && ret == 0; reg++) { unsigned int reg0 = (reg + 0) % 32; unsigned int reg1 = (reg + 1) % 32; unsigned int stk = reg < 16 ? 31 : 15; unsigned long code[] = { ASM_STW(stk, 1, -4), ASM_ADDI(stk, 1, -16), ASM_STW(3, stk, 8), ASM_STW(reg0, stk, 4), ASM_STW(reg1, stk, 0), ASM_LWZ(reg0, stk, 8), ASM_11IX(test->cmd, reg1, reg0, test->op2), ASM_STW(reg1, stk, 8), ASM_LWZ(reg1, stk, 0), ASM_LWZ(reg0, stk, 4), ASM_LWZ(3, stk, 8), ASM_ADDI(1, stk, 16), ASM_LWZ(stk, 1, -4), ASM_BLR, }; ulong res; ulong cr; cr = 0; cpu_post_exec_21 (code, & cr, & res, test->op1); ret = res == test->res && cr == 0 ? 0 : -1; if (ret != 0) { post_log ("Error at threei test %d !\n", i); } } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/threei.c
C
gpl3
2,964
/* * (C) Copyright 2002 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * CPU test * Integer compare instructions: cmpwi, cmplwi * * To verify these instructions the test runs them with * different combinations of operands, reads the condition * register value and compares it with the expected one. * The test contains a pre-built table * containing the description of each test case: the instruction, * the values of the operands, the condition field to save * the result in and the expected result. */ #include <post.h> #include "cpu_asm.h" #if CONFIG_POST & CONFIG_SYS_POST_CPU extern void cpu_post_exec_11 (ulong *code, ulong *res, ulong op1); static struct cpu_post_cmpi_s { ulong cmd; ulong op1; ushort op2; ulong cr; ulong res; } cpu_post_cmpi_table[] = { { OP_CMPWI, 123, 123, 2, 0x02 }, { OP_CMPWI, 123, 133, 3, 0x08 }, { OP_CMPWI, 123, -133, 4, 0x04 }, { OP_CMPLWI, 123, 123, 2, 0x02 }, { OP_CMPLWI, 123, -133, 3, 0x08 }, { OP_CMPLWI, 123, 113, 4, 0x04 }, }; static unsigned int cpu_post_cmpi_size = ARRAY_SIZE(cpu_post_cmpi_table); int cpu_post_test_cmpi (void) { int ret = 0; unsigned int i; int flag = disable_interrupts(); for (i = 0; i < cpu_post_cmpi_size && ret == 0; i++) { struct cpu_post_cmpi_s *test = cpu_post_cmpi_table + i; unsigned long code[] = { ASM_1IC(test->cmd, test->cr, 3, test->op2), ASM_MFCR(3), ASM_BLR }; ulong res; cpu_post_exec_11 (code, & res, test->op1); ret = ((res >> (28 - 4 * test->cr)) & 0xe) == test->res ? 0 : -1; if (ret != 0) { post_log ("Error at cmpi test %d !\n", i); } } if (flag) enable_interrupts(); return ret; } #endif
1001-study-uboot
post/lib_powerpc/cmpi.c
C
gpl3
2,595
/* * Copyright (C) 2007 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * This file is originally a part of the GCC testsuite. * Check that certain subnormal numbers (formerly known as denormalized * numbers) are rounded to within 0.5 ulp. PR other/14354. */ #include <common.h> #include <post.h> GNU_FPOST_ATTR #if CONFIG_POST & CONFIG_SYS_POST_FPU union uf { unsigned int u; float f; }; static float u2f (unsigned int v) { union uf u; u.u = v; return u.f; } static unsigned int f2u (float v) { union uf u; u.f = v; return u.u; } static int ok = 1; static void tstmul (unsigned int ux, unsigned int uy, unsigned int ur) { float x = u2f (ux); float y = u2f (uy); if (f2u (x * y) != ur) /* Set a variable rather than aborting here, to simplify tracing when several computations are wrong. */ ok = 0; } /* We don't want to make this const and static, or else we risk inlining causing the test to fold as constants at compile-time. */ struct { unsigned int p1, p2, res; } static volatile expected[] = { {0xfff, 0x3f800400, 0xfff}, {0xf, 0x3fc88888, 0x17}, {0xf, 0x3f844444, 0xf} }; int fpu_post_test_math7 (void) { unsigned int i; for (i = 0; i < ARRAY_SIZE(expected); i++) { tstmul (expected[i].p1, expected[i].p2, expected[i].res); tstmul (expected[i].p2, expected[i].p1, expected[i].res); } if (!ok) { post_log ("Error in FPU math7 test\n"); return -1; } return 0; } #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
1001-study-uboot
post/lib_powerpc/fpu/mul-subnormal-single-1.c
C
gpl3
2,289
/* * Copyright (C) 2007 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * This file is originally a part of the GCC testsuite. */ #include <common.h> #include <post.h> GNU_FPOST_ATTR #if CONFIG_POST & CONFIG_SYS_POST_FPU int fpu_post_test_math4 (void) { volatile float reale = 1.0f; volatile float oneplus; int i; if (sizeof (float) != 4) return 0; for (i = 0; ; i++) { oneplus = 1.0f + reale; if (oneplus == 1.0f) break; reale = reale / 2.0f; } /* Assumes ieee754 accurate arithmetic above. */ if (i != 24) { post_log ("Error in FPU math4 test\n"); return -1; } return 0; } #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
1001-study-uboot
post/lib_powerpc/fpu/980619-1.c
C
gpl3
1,471
/* * Copyright (C) 2007 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * Author: Sergei Poselenov <sposelenov@emcraft.com> * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ #include <common.h> /* * FPU test * * This test checks the arithmetic logic unit (ALU) of CPU. * It tests independently various groups of instructions using * run-time modification of the code to reduce the memory footprint. * For more details refer to post/cpu/ *.c files. */ #include <post.h> GNU_FPOST_ATTR #if CONFIG_POST & CONFIG_SYS_POST_FPU #include <watchdog.h> extern int fpu_status (void); extern void fpu_enable (void); extern void fpu_disable (void); extern int fpu_post_test_math1 (void); extern int fpu_post_test_math2 (void); extern int fpu_post_test_math3 (void); extern int fpu_post_test_math4 (void); extern int fpu_post_test_math5 (void); extern int fpu_post_test_math6 (void); extern int fpu_post_test_math7 (void); int fpu_post_test (int flags) { int fpu = fpu_status (); int ret = 0; WATCHDOG_RESET (); if (!fpu) fpu_enable (); if (ret == 0) ret = fpu_post_test_math1 (); if (ret == 0) ret = fpu_post_test_math2 (); if (ret == 0) ret = fpu_post_test_math3 (); if (ret == 0) ret = fpu_post_test_math4 (); if (ret == 0) ret = fpu_post_test_math5 (); if (ret == 0) ret = fpu_post_test_math6 (); if (ret == 0) ret = fpu_post_test_math7 (); if (!fpu) fpu_disable (); WATCHDOG_RESET (); return ret; } #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
1001-study-uboot
post/lib_powerpc/fpu/fpu.c
C
gpl3
2,257
/* * Copyright (C) 2007 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * This file is originally a part of the GCC testsuite. */ #include <common.h> #include <post.h> GNU_FPOST_ATTR #if CONFIG_POST & CONFIG_SYS_POST_FPU static float rintf (float x) { volatile float TWO23 = 8388608.0; if (__builtin_fabs (x) < TWO23) { if (x > 0.0) { x += TWO23; x -= TWO23; } else if (x < 0.0) { x = TWO23 - x; x = -(x - TWO23); } } return x; } int fpu_post_test_math2 (void) { if (rintf (-1.5) != -2.0) { post_log ("Error in FPU math2 test\n"); return -1; } return 0; } #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
1001-study-uboot
post/lib_powerpc/fpu/20010114-2.c
C
gpl3
1,462
/* * Copyright (C) 2007 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ /* * This file is originally a part of the GCC testsuite. */ #include <common.h> #include <post.h> GNU_FPOST_ATTR #if CONFIG_POST & CONFIG_SYS_POST_FPU int fpu_post_test_math3 (void) { volatile long double dfrom = 1.1; volatile long double m1; volatile long double m2; volatile unsigned long mant_long; m1 = dfrom / 2.0; m2 = m1 * 4294967296.0; mant_long = ((unsigned long) m2) & 0xffffffff; if (mant_long != 0x8ccccccc) { post_log ("Error in FPU math3 test\n"); return -1; } return 0; } #endif /* CONFIG_POST & CONFIG_SYS_POST_FPU */
1001-study-uboot
post/lib_powerpc/fpu/20010226-1.c
C
gpl3
1,440