diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 50f3095..d836f66 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -158,6 +158,7 @@ select GPIOLIB select PINCTRL select PINCTRL_ROCKCHIP + select OFTREE select HAVE_PBL_MULTI_IMAGES select HAS_DEBUG_LL select ARCH_HAS_L2X0 @@ -278,7 +279,7 @@ config THUMB2_BAREBOX select ARM_ASM_UNIFIED select AEABI - depends on !ARCH_TEGRA + depends on !ARCH_TEGRA && !ARCH_AT91 depends on CPU_V7 && !CPU_32v4T && !CPU_32v5 && !CPU_32v6 bool "Compile barebox in thumb-2 mode (read help)" help diff --git a/arch/arm/configs/mainstone_defconfig b/arch/arm/configs/mainstone_defconfig index 946902d..1e735d4 100644 --- a/arch/arm/configs/mainstone_defconfig +++ b/arch/arm/configs/mainstone_defconfig @@ -7,7 +7,6 @@ CONFIG_ARM_UNWIND=y # CONFIG_BANNER is not set CONFIG_MMU=y -CONFIG_TEXT_BASE=0xa3d00000 CONFIG_BAREBOX_MAX_BARE_INIT_SIZE=0x80000 CONFIG_MALLOC_SIZE=0x1000000 CONFIG_EXPERIMENTAL=y diff --git a/arch/arm/configs/rockchip_defconfig b/arch/arm/configs/rockchip_defconfig index e08699d..b738620 100644 --- a/arch/arm/configs/rockchip_defconfig +++ b/arch/arm/configs/rockchip_defconfig @@ -80,14 +80,12 @@ CONFIG_DRIVER_SERIAL_NS16550=y CONFIG_DRIVER_NET_ARC_EMAC=y CONFIG_SMSC_PHY=y -CONFIG_I2C=y CONFIG_I2C_GPIO=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y CONFIG_MCI_MMC_BOOT_PARTITIONS=y CONFIG_MCI_DW=y CONFIG_MCI_DW_PIO=y -CONFIG_MFD_ACT8846=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_LED_GPIO_OF=y diff --git a/arch/arm/dts/am335x-phytec-phycard-som.dtsi b/arch/arm/dts/am335x-phytec-phycard-som.dtsi index 1f1036f..c0b2456 100644 --- a/arch/arm/dts/am335x-phytec-phycard-som.dtsi +++ b/arch/arm/dts/am335x-phytec-phycard-som.dtsi @@ -144,9 +144,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&nandflash_pins_s0>; - ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */ + ranges = <0 0 0x08000000 0x1000000>; /* CS0: 16MB for NAND */ nand: nand@0,0 { - reg = <0 0 0>; /* CS0, offset 0 */ + reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ nand-bus-width = <8>; ti,nand-ecc-opt = "bch8"; gpmc,device-nand = "true"; diff --git a/arch/arm/dts/am335x-phytec-phycore-som.dtsi b/arch/arm/dts/am335x-phytec-phycore-som.dtsi index 59816d0..ba0589c 100644 --- a/arch/arm/dts/am335x-phytec-phycore-som.dtsi +++ b/arch/arm/dts/am335x-phytec-phycore-som.dtsi @@ -228,9 +228,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&nandflash_pins_s0>; - ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */ + ranges = <0 0 0x08000000 0x1000000>; /* CS0: 16MB for NAND */ nand: nand@0,0 { - reg = <0 0 0>; /* CS0, offset 0 */ + reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ nand-bus-width = <8>; ti,nand-ecc-opt = "bch8"; gpmc,device-nand = "true"; diff --git a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi index 81ecf9d..6d488fa 100644 --- a/arch/arm/dts/am335x-phytec-phyflex-som.dtsi +++ b/arch/arm/dts/am335x-phytec-phyflex-som.dtsi @@ -241,9 +241,9 @@ status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&nandflash_pins_s0>; - ranges = <0 0 0x08000000 0x10000000>; /* CS0: NAND */ + ranges = <0 0 0x08000000 0x1000000>; /* CS0: 16MB for NAND */ nand: nand@0,0 { - reg = <0 0 0>; /* CS0, offset 0 */ + reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ nand-bus-width = <8>; ti,nand-ecc-opt = "bch8"; gpmc,device-nand = "true"; diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index f643948..9afc666 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -680,8 +680,10 @@ prompt "Enable write support of i.MX6 CPUs OTP fuses" depends on IMX_OCOTP help - This adds write support to IMX6 On-Chip OTP registers. - Example of set MAC to 12:34:56:78:9A:BC (2 words with offset 0x22 * 4): + This adds write support to IMX6 On-Chip OTP registers. Example of set + MAC to 12:34:56:78:9A:BC (2 words with address 0x22 (OCOTP_MAC0) and + address 0x23 (OCOTP_MAC1)). To calculate the file offset multiply + the value of the address by 4. mw -l -d /dev/imx-ocotp 0x8C 0x00001234 mw -l -d /dev/imx-ocotp 0x88 0x56789ABC diff --git a/arch/arm/mach-omap/Kconfig b/arch/arm/mach-omap/Kconfig index 87e8d44..0b59afc 100644 --- a/arch/arm/mach-omap/Kconfig +++ b/arch/arm/mach-omap/Kconfig @@ -106,6 +106,7 @@ bool "enable AM335x network boot" select ENVIRONMENT_VARIABLES select NET_DHCP + select FS_RAMFS select FS_TFTP select DRIVER_NET_CPSW default n diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c index 3cf7ff4..ebcbcbc 100644 --- a/arch/arm/mach-omap/xload.c +++ b/arch/arm/mach-omap/xload.c @@ -230,13 +230,16 @@ return buf; } +#define TFTP_MOUNT "/.tftp" + static void *am33xx_net_boot(void) { void *buf = NULL; int err; int len; struct dhcp_req_param dhcp_param; - const char *bootfile; + const char *bootfile, *ip; + char *file; am33xx_register_ethaddr(0, 0); @@ -248,7 +251,22 @@ return NULL; } - err = mount(ip_to_string(net_get_serverip()), "tftp", "/", NULL); + /* + * Older tftp server don't send the file size. + * Then tftpfs needs temporary place to store the file. + */ + err = mount("none", "ramfs", "/", NULL); + if (err < 0) { + printf("failed to mount ramfs\n"); + return NULL; + } + + err = make_directory(TFTP_MOUNT); + if (err) + return NULL; + + ip = ip_to_string(net_get_serverip()); + err = mount(ip, "tftp", TFTP_MOUNT, NULL); if (err < 0) { printf("Unable to mount.\n"); return NULL; @@ -260,11 +278,15 @@ return NULL; } - buf = read_file(bootfile, &len); + file = asprintf("%s/%s", TFTP_MOUNT, bootfile); + + buf = read_file(file, &len); if (!buf) printf("could not read %s.\n", bootfile); - umount("/"); + free(file); + + umount(TFTP_MOUNT); return buf; } diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig index 2b7f631..54094f4 100644 --- a/arch/arm/mach-pxa/Kconfig +++ b/arch/arm/mach-pxa/Kconfig @@ -5,6 +5,7 @@ default 0xa0000000 if MACH_MIOA701 default 0xa3f00000 if MACH_PCM027 default 0xa3d00000 if MACH_LUBBOCK + default 0xa3d00000 if MACH_MAINSTONE default 0x83f00000 if MACH_ZYLONITE # ---------------------------------------------------------- diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig index ec045f7..d82579b 100644 --- a/arch/sandbox/configs/sandbox_defconfig +++ b/arch/sandbox/configs/sandbox_defconfig @@ -1,40 +1,103 @@ CONFIG_HUSH_FANCY_PROMPT=y CONFIG_CMDLINE_EDITING=y CONFIG_AUTO_COMPLETE=y +CONFIG_MENU=y CONFIG_PARTITION=y +CONFIG_DEFAULT_COMPRESSION_GZIP=y CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/sandbox/board/env" CONFIG_DEBUG_INFO=y +CONFIG_CMD_DMESG=y CONFIG_LONGHELP=y +CONFIG_CMD_IMD=y CONFIG_CMD_MEMINFO=y # CONFIG_CMD_BOOTM is not set CONFIG_CMD_GO=y CONFIG_CMD_RESET=y +CONFIG_CMD_UIMAGE=y CONFIG_CMD_PARTITION=y CONFIG_CMD_EXPORT=y +CONFIG_CMD_DEFAULTENV=y CONFIG_CMD_PRINTENV=y CONFIG_CMD_MAGICVAR=y CONFIG_CMD_MAGICVAR_HELP=y CONFIG_CMD_SAVEENV=y +CONFIG_CMD_CMP=y +CONFIG_CMD_FILETYPE=y +CONFIG_CMD_LN=y +CONFIG_CMD_MD5SUM=y +CONFIG_CMD_SHA1SUM=y +CONFIG_CMD_SHA224SUM=y +CONFIG_CMD_SHA256SUM=y +CONFIG_CMD_SHA384SUM=y +CONFIG_CMD_SHA512SUM=y +CONFIG_CMD_UNCOMPRESS=y +CONFIG_CMD_LET=y +CONFIG_CMD_MSLEEP=y +CONFIG_CMD_READF=y CONFIG_CMD_SLEEP=y CONFIG_CMD_DHCP=y +CONFIG_CMD_HOST=y CONFIG_CMD_PING=y CONFIG_CMD_TFTP=y +CONFIG_CMD_ECHO_E=y CONFIG_CMD_EDIT=y +CONFIG_CMD_MENU=y +CONFIG_CMD_MENU_MANAGEMENT=y +CONFIG_CMD_MENUTREE=y +CONFIG_CMD_SPLASH=y CONFIG_CMD_READLINE=y CONFIG_CMD_TIMEOUT=y CONFIG_CMD_CRC=y +CONFIG_CMD_CRC_CMP=y +CONFIG_CMD_MM=y +CONFIG_CMD_DETECT=y CONFIG_CMD_FLASH=y CONFIG_CMD_2048=y CONFIG_CMD_OF_NODE=y CONFIG_CMD_OF_PROPERTY=y CONFIG_CMD_OF_DISPLAY_TIMINGS=y CONFIG_CMD_OFTREE=y +CONFIG_CMD_TIME=y +CONFIG_CMD_SPD_DECODE=y CONFIG_NET=y +CONFIG_NET_NFS=y +CONFIG_NET_NETCONSOLE=y CONFIG_OFDEVICE=y CONFIG_OF_BAREBOX_DRIVERS=y CONFIG_DRIVER_NET_TAP=y # CONFIG_SPI is not set +CONFIG_VIDEO=y +CONFIG_FRAMEBUFFER_CONSOLE=y # CONFIG_PINCTRL is not set CONFIG_FS_CRAMFS=y +CONFIG_FS_EXT4=y CONFIG_FS_TFTP=y +CONFIG_FS_NFS=y +CONFIG_FS_FAT=y +CONFIG_FS_FAT_WRITE=y +CONFIG_FS_FAT_LFN=y +CONFIG_FS_BPKFS=y +CONFIG_FS_UIMAGEFS=y +CONFIG_BZLIB=y +CONFIG_LZ4_DECOMPRESS=y +CONFIG_XZ_DECOMPRESS=y +CONFIG_LZO_DECOMPRESS=y +CONFIG_BMP=y +CONFIG_PNG=y +CONFIG_FONT_8x16=y +CONFIG_FONT_7x14=y +CONFIG_FONT_MINI_4x6=y +CONFIG_BAREBOX_LOGO=y +CONFIG_BAREBOX_LOGO_64=y +CONFIG_BAREBOX_LOGO_240=y +CONFIG_BAREBOX_LOGO_320=y +CONFIG_BAREBOX_LOGO_400=y +CONFIG_BAREBOX_LOGO_640=y +CONFIG_DIGEST_MD5_GENERIC=y +CONFIG_DIGEST_SHA1_GENERIC=y +CONFIG_DIGEST_SHA224_GENERIC=y +CONFIG_DIGEST_SHA256_GENERIC=y +CONFIG_DIGEST_SHA384_GENERIC=y +CONFIG_DIGEST_SHA512_GENERIC=y +CONFIG_DIGEST_HMAC_GENERIC=y diff --git a/commands/Kconfig b/commands/Kconfig index bb6674e..30485c0 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -2102,6 +2102,12 @@ depends on STATE prompt "state" +config CMD_DHRYSTONE + bool + prompt "dhrystone" + help + CPU benchmark tool + # end Miscellaneous commands endmenu diff --git a/commands/Makefile b/commands/Makefile index 3698347..879caec 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -112,3 +112,4 @@ obj-$(CONFIG_CMD_DEFAULTENV) += defaultenv.o obj-$(CONFIG_CMD_STATE) += state.o obj-$(CONFIG_CMD_DHCP) += dhcp.o +obj-$(CONFIG_CMD_DHRYSTONE) += dhrystone.o diff --git a/commands/dhrystone.c b/commands/dhrystone.c new file mode 100644 index 0000000..203acce --- /dev/null +++ b/commands/dhrystone.c @@ -0,0 +1,445 @@ +/* + * (C) Copyright 2014 - 2015 Phytec Messtechnik GmbH + * Author: Stefan Müller-Klieser + * Author: Daniel Schultz + * + * based on "DHRYSTONE" Benchmark Program + * Version: C, Version 2.1 + * Date: May 25, 1988 + * Author: Reinhold P. Weicker + * + * 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 program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include /* for strcpy, strcmp */ + +enum idents {ident_1, ident_2, ident_3, ident_4, ident_5}; + +/* General definitions: */ + +struct record { + struct record *ptr_comp; + enum idents discr; + union { + struct { + enum idents enum_comp; + int int_comp; + char str_comp[31]; + } var_1; + struct { + enum idents enum_comp_2; + char str_2_comp[31]; + } var_2; + struct { + char char_1_Comp; + char char_2_Comp; + } var_3; + } variant; +}; + +/* Global Variables: */ +static struct record *record_glob; +static struct record *next_record_glob; +static int int_glob; +static bool bool_glob; +static char char_1_glob; +static char char_2_glob; +static int arr_1_glob[50]; +static int arr_2_glob[50][50]; + +/* Cycle Variables: */ +static int int_1; +static int int_2; +static int int_3; +static char char_i; +static enum idents ident; +static char str_1[31]; +static char str_2[31]; +static int i; + + +#define TOO_SMALL_TIME (50 * MSECOND) +/* Measurements should last at least 50mseconds */ +#define TOO_LARGE_TIME (2 * SECOND) + + +static enum idents compare_chars(char char_1, char char_2) +{ + if (char_1 != char_2) + return ident_1; + char_1_glob = char_1; + return ident_2; +} + +static bool compare_strs(char str_1[31], char str_2[31]) +{ + int offset; + + offset = 2; + while (offset <= 2) + if (compare_chars(str_1[offset], str_2[offset+1]) == ident_1) + ++offset; + if (strcmp(str_1, str_2) > 0) { + int_glob = offset + 7; + return true; + } + return false; +} + +static bool check_ident(enum idents ident) +{ + if (ident == ident_3) + return true; + return false; +} + +static void proc_7(int input_1, int input_2, int *out) +{ + *out = input_2 + input_1 + 2; +} + +static void proc_6(enum idents ident, enum idents *ident_out) +{ + *ident_out = ident; + if (!check_ident(ident)) + *ident_out = ident_4; + switch (ident) { + case ident_1: + *ident_out = ident_1; + break; + case ident_2: + if (int_glob > 100) + *ident_out = ident_1; + else + *ident_out = ident_4; + break; + case ident_3: + *ident_out = ident_2; + break; + case ident_4: + break; + case ident_5: + *ident_out = ident_3; + break; + } +} + +static void fill_record(struct record *record) +{ + struct record *next_record = record->ptr_comp; + + *record->ptr_comp = *record_glob; + record->variant.var_1.int_comp = 5; + next_record->variant.var_1.int_comp = record->variant.var_1.int_comp; + next_record->ptr_comp = record->ptr_comp; + proc_7(10, int_glob, &record_glob->variant.var_1.int_comp); + /* Ptr_Val_Par->ptr_comp->ptr_comp == record_glob->ptr_comp */ + if (next_record->discr == ident_1) { /* then, executed */ + next_record->variant.var_1.int_comp = 6; + proc_6(record->variant.var_1.enum_comp, + &next_record->variant.var_1.enum_comp); + next_record->ptr_comp = record_glob->ptr_comp; + proc_7(next_record->variant.var_1.int_comp, 10, + &next_record->variant.var_1.int_comp); + } else { /* not executed */ + *record = *record->ptr_comp; + } +} + +static void proc_2(int *out) +{ + if (char_1_glob == 'A') + *out = *out + 9 - int_glob; +} + +static void proc_4(void) +{ + bool_glob = (char_1_glob == 'A') | bool_glob; + char_2_glob = 'B'; +} + +static void proc_5(void) +{ + char_1_glob = 'A'; + bool_glob = false; +} + +/* dhry_2.c */ + +static void fill_array(int arr_1[50], int arr_2[50][50], int val_1, int val_2) +{ + int i; + int offset; + + offset = val_1 + 5; + arr_1[offset] = val_2; + arr_1[offset+1] = arr_1[offset]; + arr_1[offset+30] = offset; + for (i = offset; i <= offset+1; ++i) + arr_2[offset][i] = offset; + arr_2[offset][offset-1] += 1; + arr_2[offset+20][offset] = arr_1[offset]; + int_glob = 5; +} + +static void one_dhrystone_cycle(void) +{ + proc_5(); + proc_4(); + /* char_1_glob == 'A', char_2_glob == 'B', bool_glob == true */ + int_1 = 2; + int_2 = 3; + strcpy(str_2, "DHRYSTONE PROGRAM, 2'ND STRING"); + ident = ident_2; + bool_glob = !compare_strs(str_1, str_2); + /* bool_glob == 1 */ + while (int_1 < int_2) { + int_3 = 5 * int_1 - int_2; + /* int_3 == 7 */ + proc_7(int_1, int_2, &int_3); + /* int_3 == 7 */ + int_1 += 1; + } + /* int_1 == 3, int_2 == 3, int_3 == 7 */ + fill_array(arr_1_glob, arr_2_glob, int_1, int_3); + /* int_glob == 5 */ + fill_record(record_glob); + for (char_i = 'A'; char_i <= char_2_glob; ++char_i) { + if (ident == compare_chars(char_i, 'C')) { + proc_6(ident_1, &ident); + strcpy(str_2, + "DHRYSTONE PROGRAM, 3'RD STRING"); + int_2 = i; + int_glob = i; + } + } + /* int_1 == 3, int_2 == 3, int_3 == 7 */ + int_2 = int_2 * int_1; + int_1 = int_2 / int_3; + int_2 = 7 * (int_2 - int_3) - int_1; + /* int_1 == 1, int_2 == 13, int_3 == 7 */ + proc_2(&int_1); + /* int_1 == 5 */ +} + +static int do_dhrystone(int argc, char *argv[]) +{ + int number_of_runs; + int actually_number_of_runs = 0; + /* variables for time measurement */ + u64 begin_time; + u64 end_time; + u64 user_time; + u64 nanoseconds; + + /* barebox cmd */ + if (argc == 2) { + number_of_runs = simple_strtoul(argv[1], NULL, 10); + if (number_of_runs == 0) + number_of_runs = 1; + } else { + number_of_runs = 10000; + } + + /* Initializations */ + next_record_glob = xmalloc(sizeof(*next_record_glob)); + record_glob = xmalloc(sizeof(*record_glob)); + + printf("\n"); + printf("Dhrystone Benchmark, Version 2.1 (Language: C)\n"); + printf("\n"); + printf("Program compiled without 'register' attribute\n"); + printf("\n"); + + ident = ident_2; /* prevent compiler warning */ + int_2 = 0; /* prevent compiler warning */ + int_3 = 0; /* prevent compiler warning */ + + record_glob->ptr_comp = next_record_glob; + record_glob->discr = ident_1; + record_glob->variant.var_1.enum_comp = ident_3; + record_glob->variant.var_1.int_comp = 40; + strcpy(record_glob->variant.var_1.str_comp, + "DHRYSTONE PROGRAM, SOME STRING"); + strcpy(str_1, "DHRYSTONE PROGRAM, 1'ST STRING"); + + arr_2_glob[8][7] = 10; + /* Was missing in published program. Without this statement, */ + /* arr_2_glob [8][7] would have an undefined value. */ + /* Warning: With 16-Bit processors and number_of_runs > 32000, */ + /* overflow may occur for this array element. */ + + /***************/ + /* Start timer */ + /***************/ + begin_time = get_time_ns(); + +again: + for (i = 0; i < number_of_runs; i++) + one_dhrystone_cycle(); + + actually_number_of_runs += number_of_runs; + end_time = get_time_ns(); + user_time = end_time - begin_time; + + if (user_time < TOO_SMALL_TIME) + goto again; + + printf("Execution finished with %d runs through Dhrystone\n", + actually_number_of_runs); + printf("\n"); + printf("Failed variables:\n"); + if (int_glob != 5) { + printf("int_glob: %d\n", int_glob); + printf(" should be: %d\n", 5); + } + if (bool_glob != 1) { + printf("bool_glob: %d\n", bool_glob); + printf(" should be: %d\n", 1); + } + if (char_1_glob != 'A') { + printf("char_1_glob: %c\n", char_1_glob); + printf(" should be: %c\n", 'A'); + } + if (char_2_glob != 'B') { + printf("char_2_glob: %c\n", char_2_glob); + printf(" should be: %c\n", 'B'); + } + if (arr_1_glob[8] != 7) { + printf("arr_1_glob[8]: %d\n", arr_1_glob[8]); + printf(" should be: %d\n", 7); + } + if (arr_2_glob[8][7] != (actually_number_of_runs + 10)) { + printf("arr_2_glob[8][7]: %d\n", arr_2_glob[8][7]); + printf(" should be: %d\n", + actually_number_of_runs + 10); + } + + if (record_glob->ptr_comp != next_record_glob) { + printf("record_glob->ptr_comp: 0x%p\n", + record_glob->ptr_comp); + printf(" should be: 0x%p\n", next_record_glob); + } + if (record_glob->discr != 0) { + printf("record_glob->discr: %d\n", record_glob->discr); + printf(" should be: %d\n", 0); + } + if (record_glob->variant.var_1.enum_comp != 2) { + printf("record_glob->enum_comp: %d\n", + record_glob->variant.var_1.enum_comp); + printf(" should be: %d\n", 2); + } + if (record_glob->variant.var_1.int_comp != 17) { + printf("record_glob->int_comp: %d\n", + record_glob->variant.var_1.int_comp); + printf(" should be: %d\n", 17); + } + if (strcmp(record_glob->variant.var_1.str_comp, + "DHRYSTONE PROGRAM, SOME STRING") != 0) { + printf("record_glob->str_comp: %s\n", + record_glob->variant.var_1.str_comp); + printf(" should be: DHRYSTONE PROGRAM, SOME STRING\n"); + } + + if (next_record_glob->ptr_comp != next_record_glob) { + printf("next_record_glob->ptr_comp: 0x%p\n", + next_record_glob->ptr_comp); + printf(" should be: 0x%p\n", + next_record_glob); + } + if (next_record_glob->discr != 0) { + printf(" next_record_glob->discr: %d\n", + next_record_glob->discr); + printf(" should be: %d\n", 0); + } + if (next_record_glob->variant.var_1.enum_comp != 1) { + printf("next_record_glob->enum_comp: %d\n", + next_record_glob->variant.var_1.enum_comp); + printf(" should be: %d\n", 1); + } + if (next_record_glob->variant.var_1.int_comp != 18) { + printf("next_record_glob->int_comp: %d\n", + next_record_glob->variant.var_1.int_comp); + printf(" should be: %d\n", 18); + } + if (strcmp(next_record_glob->variant.var_1.str_comp, + "DHRYSTONE PROGRAM, SOME STRING") != 0) { + printf("next_record_glob->str_comp: %s\n", + next_record_glob->variant.var_1.str_comp); + printf(" should be: DHRYSTONE PROGRAM, SOME STRING\n"); + } + if (int_1 != 5) { + printf("int_1: %d\n", int_1); + printf(" should be: %d\n", 5); + } + if (int_2 != 13) { + printf("int_2: %d\n", int_2); + printf(" should be: %d\n", 13); + } + if (int_3 != 7) { + printf("int_3: %d\n", int_3); + printf(" should be: %d\n", 7); + } + if (ident != 1) { + printf("ident: %d\n", ident); + printf(" should be: %d\n", 1); + } + if (strcmp(str_1, "DHRYSTONE PROGRAM, 1'ST STRING") != 0) { + printf("str_1: %s\n", str_1); + printf(" should be: DHRYSTONE PROGRAM, 1'ST STRING\n"); + } + if (strcmp(str_2, "DHRYSTONE PROGRAM, 2'ND STRING") != 0) { + printf("str_2: %s\n", str_2); + printf(" should be: DHRYSTONE PROGRAM, 2'ND STRING\n"); + } + printf("\n"); + + if (user_time > TOO_LARGE_TIME) + printf("Measured time too large to obtain meaningful results or a timer wrap happend.\n"); + else if (end_time < begin_time) + printf("Timer overflow occured.\n"); + + printf("user_time: %llu ns\n", user_time); + + nanoseconds = user_time; + do_div(nanoseconds, actually_number_of_runs); + + printf("Nanoseconds for one run through Dhrystone: %llu\n", + nanoseconds); + printf("Dhrystones per Second:\n "); + printf("(%d / %llu) * 10^9\n", actually_number_of_runs, user_time); + printf("DMIPS:\n "); + printf("((%d / %llu) * 10^9) / 1757\n", actually_number_of_runs, + user_time); + printf("\n"); + + return 0; +} + +BAREBOX_CMD_HELP_START(dhrystone) +BAREBOX_CMD_HELP_TEXT( +"this command runs the dhrystone benchmark to get an estimation of the CPU freq") +BAREBOX_CMD_HELP_END + +BAREBOX_CMD_START(dhrystone) + .cmd = do_dhrystone, + BAREBOX_CMD_DESC("run dhrystone test, specify number of runs") + BAREBOX_CMD_OPTS("[number_of_runs]") + BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_HELP(cmd_dhrystone_help) +BAREBOX_CMD_END diff --git a/common/console.c b/common/console.c index 0a6fc3e..bf64c08 100644 --- a/common/console.c +++ b/common/console.c @@ -73,6 +73,9 @@ cdev->setbrg(cdev, cdev->baudrate); } + if (!flag && cdev->f_active && cdev->flush) + cdev->flush(cdev); + if (cdev->set_active) { ret = cdev->set_active(cdev, flag); if (ret) diff --git a/common/state.c b/common/state.c index 1243320..aa436fc 100644 --- a/common/state.c +++ b/common/state.c @@ -1279,7 +1279,7 @@ max_len -= sizeof(header); if (ret < 0) { dev_err(&state->dev, - "cannot read header from backend device"); + "cannot read header from backend device\n"); return ret; } @@ -1377,6 +1377,8 @@ if (ret < 0) return ret; + protect(fd, backend_raw->stride, offset, false); + if (backend_raw->need_erase) { ret = erase(fd, backend_raw->stride, offset); if (ret) @@ -1387,6 +1389,8 @@ if (ret < 0) return ret; + protect(fd, backend_raw->stride, offset, true); + return 0; } diff --git a/drivers/i2c/i2c.c b/drivers/i2c/i2c.c index 5d0fa06..f0df666 100644 --- a/drivers/i2c/i2c.c +++ b/drivers/i2c/i2c.c @@ -278,7 +278,7 @@ if (!IS_ENABLED(CONFIG_OFDEVICE) || !adap->dev.device_node) return; - for_each_child_of_node(adap->dev.device_node, n) { + for_each_available_child_of_node(adap->dev.device_node, n) { struct i2c_board_info info = {}; struct i2c_client *result; const __be32 *addr; diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index fda9034..d873369 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -386,6 +386,9 @@ struct mtd_info *mtdpart, *tmp; int ret; + if (!val) + return -EINVAL; + list_for_each_entry_safe(mtdpart, tmp, &mtd->partitions, partitions_entry) { ret = mtd_del_partition(mtdpart); if (ret) @@ -488,7 +491,7 @@ { struct mtd_info *mtd = ctx, *partmtd; struct device_node *np, *part, *tmp; - int ret, i = 0; + int ret; np = of_find_node_by_path_from(root, mtd->of_path); if (!np) { @@ -505,7 +508,7 @@ list_for_each_entry(partmtd, &mtd->partitions, partitions_entry) { int na, ns, len = 0; - char *name = asprintf("partition@%d", i++); + char *name = asprintf("partition@%0llx", partmtd->master_offset); void *p; u8 tmp[16 * 16]; /* Up to 64-bit address + 64-bit size */ diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 2b3f9a9..bf4110a 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -445,15 +445,15 @@ { struct nand_chip *chip = mtd->priv; -#ifdef CONFIG_NAND_BBT - if (!chip->bbt) - return chip->block_bad(mtd, ofs, getchip); + if (IS_ENABLED(CONFIG_NAND_BBT)) { + if (!chip->bbt) + return chip->block_bad(mtd, ofs, getchip); - /* Return info from the table */ - return nand_isbad_bbt(mtd, ofs, allowbbt); -#else + /* Return info from the table */ + return nand_isbad_bbt(mtd, ofs, allowbbt); + } + return chip->block_bad(mtd, ofs, getchip); -#endif } /* Wait for the ready pin, after a command. The timeout is caught later. */ diff --git a/drivers/of/base.c b/drivers/of/base.c index 3e40a48..7f35ee5 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2000,7 +2000,7 @@ } /** - * of_device_enable - disable a devicenode device + * of_device_disable - disable a devicenode device * @node - the node to disable * * This sets the status of a devicenode to "disabled" diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a3c9e41..73f5c6e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -43,9 +43,53 @@ struct device_d *dev; }; +static int regulator_enable_internal(struct regulator_internal *ri) +{ + int ret; + + if (ri->enable_count) { + ri->enable_count++; + return 0; + } + + if (!ri->rdev->ops->enable) + return -ENOSYS; + + ret = ri->rdev->ops->enable(ri->rdev); + if (ret) + return ret; + + if (ri->enable_time_us) + udelay(ri->enable_time_us); + + ri->enable_count++; + + return 0; +} + +static int regulator_disable_internal(struct regulator_internal *ri) +{ + int ret; + + if (!ri->enable_count) + return -EINVAL; + + if (!ri->rdev->ops->disable) + return -ENOSYS; + + ret = ri->rdev->ops->disable(ri->rdev); + if (ret) + return ret; + + ri->enable_count--; + + return 0; +} + static struct regulator_internal * __regulator_register(struct regulator_dev *rd, const char *name) { struct regulator_internal *ri; + int ret; ri = xzalloc(sizeof(*ri)); ri->rdev = rd; @@ -57,7 +101,19 @@ if (name) ri->name = xstrdup(name); + if (rd->boot_on) { + ret = regulator_enable_internal(ri); + if (ret && ret != -ENOSYS) + goto err; + } + return ri; +err: + list_del(&ri->list); + free(ri->name); + free(ri); + + return ERR_PTR(ret); } @@ -74,6 +130,8 @@ struct regulator_internal *ri; const char *name; + rd->boot_on = of_property_read_bool(node, "regulator-boot-on"); + name = of_get_property(node, "regulator-name", NULL); ri = __regulator_register(rd, name); @@ -239,32 +297,10 @@ */ int regulator_enable(struct regulator *r) { - struct regulator_internal *ri; - int ret; - if (!r) return 0; - ri = r->ri; - - if (ri->enable_count) { - ri->enable_count++; - return 0; - } - - if (!ri->rdev->ops->enable) - return -ENOSYS; - - ret = ri->rdev->ops->enable(ri->rdev); - if (ret) - return ret; - - if (ri->enable_time_us) - udelay(ri->enable_time_us); - - ri->enable_count++; - - return 0; + return regulator_enable_internal(r->ri); } /* @@ -278,27 +314,10 @@ */ int regulator_disable(struct regulator *r) { - struct regulator_internal *ri; - int ret; - if (!r) return 0; - ri = r->ri; - - if (!ri->enable_count) - return -EINVAL; - - if (!ri->rdev->ops->disable) - return -ENOSYS; - - ret = ri->rdev->ops->disable(ri->rdev); - if (ret) - return ret; - - ri->enable_count--; - - return 0; + return regulator_disable_internal(r->ri); } static void regulator_print_one(struct regulator_internal *ri) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index ba23cf7..99412b0 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -113,7 +113,7 @@ if (!node) return; - for_each_child_of_node(node, n) { + for_each_available_child_of_node(node, n) { memset(&chip, 0, sizeof(chip)); chip.name = xstrdup(n->name); chip.bus_num = master->bus_num; diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c index 2b0faf3..140346e 100644 --- a/drivers/usb/gadget/u_serial.c +++ b/drivers/usb/gadget/u_serial.c @@ -536,8 +536,9 @@ if (status) goto fail_out; - console_set_active(cdev, CONSOLE_STDIN | CONSOLE_STDOUT | - CONSOLE_STDERR); + if (IS_ENABLED(CONFIG_CONSOLE_FULL)) + console_set_active(cdev, CONSOLE_STDIN | CONSOLE_STDOUT | + CONSOLE_STDERR); /* REVISIT if waiting on "carrier detect", signal. */ diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 7f7b02e..582c615 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -10,6 +10,12 @@ if WATCHDOG +config WATCHDOG_DAVINCI + bool "TI Davinci" + depends on ARCH_DAVINCI + help + Add support for watchdog on the TI Davinci SoC. + config WATCHDOG_MXS28 bool "i.MX28" depends on ARCH_IMX28 diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 865fc47..1e63c49 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_WATCHDOG) += wd_core.o +obj-$(CONFIG_WATCHDOG_DAVINCI) += davinci_wdt.o obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c new file mode 100644 index 0000000..ecf6e89 --- /dev/null +++ b/drivers/watchdog/davinci_wdt.c @@ -0,0 +1,172 @@ +/* + * drivers/char/watchdog/davinci_wdt.c + * + * Watchdog driver for DaVinci DM644x/DM646x processors + * + * Copyright (C) 2006-2013 Texas Instruments. + * Copyright (C) 2015 Jan Luebbe + * + * 2007 (c) MontaVista Software, Inc. This file is licensed under + * the terms of the GNU General Public License version 2. This program + * is licensed "as is" without any warranty of any kind, whether express + * or implied. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Timer register set definition */ +#define PID12 (0x0) +#define EMUMGT (0x4) +#define TIM12 (0x10) +#define TIM34 (0x14) +#define PRD12 (0x18) +#define PRD34 (0x1C) +#define TCR (0x20) +#define TGCR (0x24) +#define WDTCR (0x28) + +/* TCR bit definitions */ +#define ENAMODE12_DISABLED (0 << 6) +#define ENAMODE12_ONESHOT (1 << 6) +#define ENAMODE12_PERIODIC (2 << 6) + +/* TGCR bit definitions */ +#define TIM12RS_UNRESET (1 << 0) +#define TIM34RS_UNRESET (1 << 1) +#define TIMMODE_64BIT_WDOG (2 << 2) + +/* WDTCR bit definitions */ +#define WDEN (1 << 14) +#define WDFLAG (1 << 15) +#define WDKEY_SEQ0 (0xa5c6 << 16) +#define WDKEY_SEQ1 (0xda7e << 16) + +/* + * struct to hold data for each WDT device + * @wd - hold watchdog device as is in WDT core + * @base - base io address of WD device + * @clk - source clock of WDT + * @timeout - previously configured timeout + */ +struct davinci_wdt { + struct watchdog wd; + void __iomem *base; + struct clk *clk; + unsigned timeout; +}; + +#define to_davinci_wdt(h) container_of(h, struct davinci_wdt, wd) + +static int davinci_wdt_start(struct watchdog *wd) +{ + u32 tgcr; + u32 timer_margin; + unsigned long wdt_freq; + struct davinci_wdt *davinci_wdt = to_davinci_wdt(wd); + + wdt_freq = clk_get_rate(davinci_wdt->clk); + + /* disable, internal clock source */ + iowrite32(0, davinci_wdt->base + TCR); + /* reset timer, set mode to 64-bit watchdog, and unreset */ + iowrite32(0, davinci_wdt->base + TGCR); + tgcr = TIMMODE_64BIT_WDOG | TIM12RS_UNRESET | TIM34RS_UNRESET; + iowrite32(tgcr, davinci_wdt->base + TGCR); + /* clear counter regs */ + iowrite32(0, davinci_wdt->base + TIM12); + iowrite32(0, davinci_wdt->base + TIM34); + /* set timeout period */ + timer_margin = (((u64)davinci_wdt->timeout * wdt_freq) & 0xffffffff); + iowrite32(timer_margin, davinci_wdt->base + PRD12); + timer_margin = (((u64)davinci_wdt->timeout * wdt_freq) >> 32); + iowrite32(timer_margin, davinci_wdt->base + PRD34); + /* enable run continuously */ + iowrite32(ENAMODE12_PERIODIC, davinci_wdt->base + TCR); + /* Once the WDT is in pre-active state write to + * TIM12, TIM34, PRD12, PRD34, TCR, TGCR, WDTCR are + * write protected (except for the WDKEY field) + */ + /* put watchdog in pre-active state */ + iowrite32(WDKEY_SEQ0 | WDEN, davinci_wdt->base + WDTCR); + /* put watchdog in active state */ + iowrite32(WDKEY_SEQ1 | WDEN, davinci_wdt->base + WDTCR); + return 0; +} + +static int davinci_wdt_ping(struct watchdog *wd) +{ + struct davinci_wdt *davinci_wdt = to_davinci_wdt(wd); + + /* put watchdog in service state */ + iowrite32(WDKEY_SEQ0, davinci_wdt->base + WDTCR); + /* put watchdog in active state */ + iowrite32(WDKEY_SEQ1, davinci_wdt->base + WDTCR); + return 0; +} + +static int davinci_wdt_set_timeout(struct watchdog *wd, unsigned timeout) +{ + struct davinci_wdt *davinci_wdt = to_davinci_wdt(wd); + + if (!davinci_wdt->timeout) { + davinci_wdt->timeout = timeout; + davinci_wdt_start(wd); + } else { + davinci_wdt_ping(wd); + if (davinci_wdt->timeout != timeout) + pr_warn("watchdog timeout can not be changed (currently %d)\n", + davinci_wdt->timeout); + } + + return 0; +} + +static int davinci_wdt_probe(struct device_d *dev) +{ + int ret = 0; + struct davinci_wdt *davinci_wdt; + + davinci_wdt = xzalloc(sizeof(*davinci_wdt)); + + davinci_wdt->base = dev_request_mem_region(dev, 0); + if (IS_ERR(davinci_wdt->base)) + return PTR_ERR(davinci_wdt->base); + + davinci_wdt->clk = clk_get(dev, NULL); + if (WARN_ON(IS_ERR(davinci_wdt->clk))) + return PTR_ERR(davinci_wdt->clk); + + clk_enable(davinci_wdt->clk); + + davinci_wdt->wd.set_timeout = davinci_wdt_set_timeout; + + ret = watchdog_register(&davinci_wdt->wd); + if (ret < 0) + dev_err(dev, "cannot register watchdog device\n"); + + return ret; +} + +static __maybe_unused struct of_device_id davinci_wdt_of_match[] = { + { .compatible = "ti,davinci-wdt", }, + {}, +}; + +static struct driver_d platform_wdt_driver = { + .name = "davinci-wdt", + .of_compatible = DRV_OF_COMPAT(davinci_wdt_of_match), + .probe = davinci_wdt_probe, +}; +device_platform_driver(platform_wdt_driver); + +MODULE_AUTHOR("Texas Instruments"); +MODULE_DESCRIPTION("DaVinci Watchdog Driver"); +MODULE_LICENSE("GPL"); diff --git a/include/abort.h b/include/abort.h index 7f14cb0..326467c 100644 --- a/include/abort.h +++ b/include/abort.h @@ -3,7 +3,7 @@ #include -#ifdef ARCH_HAS_DATA_ABORT_MASK +#if defined ARCH_HAS_DATA_ABORT_MASK && !defined __PBL__ /* * data_abort_mask - ignore data aborts diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h new file mode 100644 index 0000000..d1e49d5 --- /dev/null +++ b/include/linux/compiler-clang.h @@ -0,0 +1,12 @@ +#ifndef __LINUX_COMPILER_H +#error "Please don't include directly, include instead." +#endif + +/* Some compiler specific definitions are overwritten here + * for Clang compiler + */ + +#ifdef uninitialized_var +#undef uninitialized_var +#define uninitialized_var(x) x = *(&(x)) +#endif diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 73dcf80..dfaa7b3 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -5,11 +5,28 @@ /* * Common definitions for all gcc versions go here. */ - +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) /* Optimization barrier */ + /* The "volatile" is due to gcc bugs */ #define barrier() __asm__ __volatile__("": : :"memory") +/* + * This version is i.e. to prevent dead stores elimination on @ptr + * where gcc and llvm may behave differently when otherwise using + * normal barrier(): while gcc behavior gets along with a normal + * barrier(), llvm needs an explicit input variable to be assumed + * clobbered. The issue is as follows: while the inline asm might + * access any memory it wants, the compiler could have fit all of + * @ptr into memory registers instead, and since @ptr never escaped + * from that, it proofed that the inline asm wasn't touching any of + * it. This version works well with both compilers, i.e. we're telling + * the compiler that the inline asm absolutely may see the contents + * of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495 + */ +#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory") /* * This macro obfuscates arithmetic on a variable address so that gcc @@ -29,39 +46,63 @@ * the inline assembly constraint from =g to =r, in this particular * case either is valid. */ -#define RELOC_HIDE(ptr, off) \ - ({ unsigned long __ptr; \ - __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ - (typeof(ptr)) (__ptr + (off)); }) +#define RELOC_HIDE(ptr, off) \ +({ \ + unsigned long __ptr; \ + __asm__ ("" : "=r"(__ptr) : "0"(ptr)); \ + (typeof(ptr)) (__ptr + (off)); \ +}) +/* Make the optimizer believe the variable can be manipulated arbitrarily. */ +#define OPTIMIZER_HIDE_VAR(var) \ + __asm__ ("" : "=r" (var) : "0" (var)) + +#ifdef __CHECKER__ +#define __must_be_array(a) 0 +#else /* &a[0] degrades to a pointer: a different type from an array */ -#define __must_be_array(a) \ - BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0]))) +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) +#endif /* * Force always-inline if the user requests it so via the .config, * or if gcc is too old: */ -#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ +#if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) || (__GNUC__ < 4) -# define inline inline __attribute__((always_inline)) -# define __inline__ __inline__ __attribute__((always_inline)) -# define __inline __inline __attribute__((always_inline)) +#define inline inline __attribute__((always_inline)) notrace +#define __inline__ __inline__ __attribute__((always_inline)) notrace +#define __inline __inline __attribute__((always_inline)) notrace +#else +/* A lot of inline functions can cause havoc with function tracing */ +#define inline inline notrace +#define __inline__ __inline__ notrace +#define __inline __inline notrace #endif -#define __deprecated __attribute__((deprecated)) -#define __packed __attribute__((packed)) -#define __weak __attribute__((weak)) +#define __always_inline inline __attribute__((always_inline)) +#define noinline __attribute__((noinline)) + +#define __deprecated __attribute__((deprecated)) +#define __packed __attribute__((packed)) +#define __weak __attribute__((weak)) +#define __alias(symbol) __attribute__((alias(#symbol))) /* - * it doesn't make sense on ARM (currently the only user of __naked) to trace - * naked functions because then mcount is called without stack and frame pointer - * being set up and there is no chance to restore the lr register to the value - * before mcount was called. + * it doesn't make sense on ARM (currently the only user of __naked) + * to trace naked functions because then mcount is called without + * stack and frame pointer being set up and there is no chance to + * restore the lr register to the value before mcount was called. + * + * The asm() bodies of naked functions often depend on standard calling + * conventions, therefore they must be noinline and noclone. + * + * GCC 4.[56] currently fail to enforce this, so we must do so ourselves. + * See GCC PR44290. */ -#define __naked __attribute__((naked)) notrace +#define __naked __attribute__((naked)) noinline __noclone notrace -#define __noreturn __attribute__((noreturn)) +#define __noreturn __attribute__((noreturn)) /* * From the GCC manual: @@ -73,15 +114,137 @@ * would be. * [...] */ -#define __pure __attribute__((pure)) -#define __aligned(x) __attribute__((aligned(x))) -#define __printf(a,b) __attribute__((format(printf,a,b))) -#define noinline __attribute__((noinline)) -#define __attribute_const__ __attribute__((__const__)) -#define __maybe_unused __attribute__((unused)) -#define __always_unused __attribute__((unused)) +#define __pure __attribute__((pure)) +#define __aligned(x) __attribute__((aligned(x))) +#define __printf(a, b) __attribute__((format(printf, a, b))) +#define __scanf(a, b) __attribute__((format(scanf, a, b))) +#define __attribute_const__ __attribute__((__const__)) +#define __maybe_unused __attribute__((unused)) +#define __always_unused __attribute__((unused)) -#define __gcc_header(x) #x -#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h) -#define gcc_header(x) _gcc_header(x) -#include gcc_header(__GNUC__) +/* gcc version specific checks */ + +#if GCC_VERSION < 30200 +# error Sorry, your compiler is too old - please upgrade it. +#endif + +#if GCC_VERSION < 30300 +# define __used __attribute__((__unused__)) +#else +# define __used __attribute__((__used__)) +#endif + +#ifdef CONFIG_GCOV_KERNEL +# if GCC_VERSION < 30400 +# error "GCOV profiling support for gcc versions below 3.4 not included" +# endif /* __GNUC_MINOR__ */ +#endif /* CONFIG_GCOV_KERNEL */ + +#if GCC_VERSION >= 30400 +#define __must_check __attribute__((warn_unused_result)) +#endif + +#if GCC_VERSION >= 40000 + +/* GCC 4.1.[01] miscompiles __weak */ +#ifdef __KERNEL__ +# if GCC_VERSION >= 40100 && GCC_VERSION <= 40101 +# error Your version of gcc miscompiles the __weak directive +# endif +#endif + +#define __used __attribute__((__used__)) +#define __compiler_offsetof(a, b) \ + __builtin_offsetof(a, b) + +#if GCC_VERSION >= 40100 && GCC_VERSION < 40600 +# define __compiletime_object_size(obj) __builtin_object_size(obj, 0) +#endif + +#if GCC_VERSION >= 40300 +/* Mark functions as cold. gcc will assume any path leading to a call + * to them will be unlikely. This means a lot of manual unlikely()s + * are unnecessary now for any paths leading to the usual suspects + * like BUG(), printk(), panic() etc. [but let's keep them for now for + * older compilers] + * + * Early snapshots of gcc 4.3 don't support this and we can't detect this + * in the preprocessor, but we can live with this because they're unreleased. + * Maketime probing would be overkill here. + * + * gcc also has a __attribute__((__hot__)) to move hot functions into + * a special section, but I don't see any sense in this right now in + * the kernel context + */ +#define __cold __attribute__((__cold__)) + +#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) + +#ifndef __CHECKER__ +# define __compiletime_warning(message) __attribute__((warning(message))) +# define __compiletime_error(message) __attribute__((error(message))) +#endif /* __CHECKER__ */ +#endif /* GCC_VERSION >= 40300 */ + +#if GCC_VERSION >= 40500 +/* + * Mark a position in code as unreachable. This can be used to + * suppress control flow warnings after asm blocks that transfer + * control elsewhere. + * + * Early snapshots of gcc 4.5 don't support this and we can't detect + * this in the preprocessor, but we can live with this because they're + * unreleased. Really, we need to have autoconf for the kernel. + */ +#define unreachable() __builtin_unreachable() + +/* Mark a function definition as prohibited from being cloned. */ +#define __noclone __attribute__((__noclone__)) + +#endif /* GCC_VERSION >= 40500 */ + +#if GCC_VERSION >= 40600 +/* + * Tell the optimizer that something else uses this function or variable. + */ +#define __visible __attribute__((externally_visible)) +#endif + +/* + * GCC 'asm goto' miscompiles certain code sequences: + * + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 + * + * Work it around via a compiler barrier quirk suggested by Jakub Jelinek. + * + * (asm goto is automatically volatile - the naming reflects this.) + */ +#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0) + +#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP +#if GCC_VERSION >= 40400 +#define __HAVE_BUILTIN_BSWAP32__ +#define __HAVE_BUILTIN_BSWAP64__ +#endif +#if GCC_VERSION >= 40800 || (defined(__powerpc__) && GCC_VERSION >= 40600) +#define __HAVE_BUILTIN_BSWAP16__ +#endif +#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */ + +#if GCC_VERSION >= 50000 +#define KASAN_ABI_VERSION 4 +#elif GCC_VERSION >= 40902 +#define KASAN_ABI_VERSION 3 +#endif + +#endif /* gcc version >= 40000 specific checks */ + +#if !defined(__noclone) +#define __noclone /* not needed */ +#endif + +/* + * A trick to suppress uninitialized variable warning without generating any + * code + */ +#define uninitialized_var(x) x = x diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h deleted file mode 100644 index b721129..0000000 --- a/include/linux/compiler-gcc3.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __LINUX_COMPILER_H -#error "Please don't include directly, include instead." -#endif - -#if __GNUC_MINOR__ < 2 -# error Sorry, your compiler is too old - please upgrade it. -#endif - -#if __GNUC_MINOR__ >= 3 -# define __used __attribute__((__used__)) -#else -# define __used __attribute__((__unused__)) -#endif - -#if __GNUC_MINOR__ >= 4 -#define __must_check __attribute__((warn_unused_result)) -#endif - -#ifdef CONFIG_GCOV_KERNEL -# if __GNUC_MINOR__ < 4 -# error "GCOV profiling support for gcc versions below 3.4 not included" -# endif /* __GNUC_MINOR__ */ -#endif /* CONFIG_GCOV_KERNEL */ - -/* - * A trick to suppress uninitialized variable warning without generating any - * code - */ -#define uninitialized_var(x) x = x - -#define __always_inline inline __attribute__((always_inline)) diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h deleted file mode 100644 index 94dea3f..0000000 --- a/include/linux/compiler-gcc4.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __LINUX_COMPILER_H -#error "Please don't include directly, include instead." -#endif - -/* GCC 4.1.[01] miscompiles __weak */ -#ifdef __KERNEL__ -# if __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ <= 1 -# error Your version of gcc miscompiles the __weak directive -# endif -#endif - -#define __used __attribute__((__used__)) -#define __must_check __attribute__((warn_unused_result)) -#define __compiler_offsetof(a,b) __builtin_offsetof(a,b) -#define __always_inline inline __attribute__((always_inline)) - -/* - * A trick to suppress uninitialized variable warning without generating any - * code - */ -#define uninitialized_var(x) x = x - -#if __GNUC_MINOR__ >= 3 -/* Mark functions as cold. gcc will assume any path leading to a call - to them will be unlikely. This means a lot of manual unlikely()s - are unnecessary now for any paths leading to the usual suspects - like BUG(), printk(), panic() etc. [but let's keep them for now for - older compilers] - - Early snapshots of gcc 4.3 don't support this and we can't detect this - in the preprocessor, but we can live with this because they're unreleased. - Maketime probing would be overkill here. - - gcc also has a __attribute__((__hot__)) to move hot functions into - a special section, but I don't see any sense in this right now in - the kernel context */ -#define __cold __attribute__((__cold__)) - - -#if __GNUC_MINOR__ >= 5 -/* - * Mark a position in code as unreachable. This can be used to - * suppress control flow warnings after asm blocks that transfer - * control elsewhere. - * - * Early snapshots of gcc 4.5 don't support this and we can't detect - * this in the preprocessor, but we can live with this because they're - * unreleased. Really, we need to have autoconf for the kernel. - */ -#define unreachable() __builtin_unreachable() -#endif - -#endif - -#if __GNUC_MINOR__ > 0 -#define __compiletime_object_size(obj) __builtin_object_size(obj, 0) -#endif -#if __GNUC_MINOR__ >= 4 -#define __compiletime_warning(message) __attribute__((warning(message))) -#define __compiletime_error(message) __attribute__((error(message))) -#endif diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index d8e636e..58daccc 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -14,18 +14,31 @@ * It uses intrinsics to do the equivalent things. */ #undef barrier +#undef barrier_data #undef RELOC_HIDE +#undef OPTIMIZER_HIDE_VAR #define barrier() __memory_barrier() +#define barrier_data(ptr) barrier() #define RELOC_HIDE(ptr, off) \ ({ unsigned long __ptr; \ __ptr = (unsigned long) (ptr); \ (typeof(ptr)) (__ptr + (off)); }) +/* This should act as an optimization barrier on var. + * Given that this compiler does not have inline assembly, a compiler barrier + * is the best we can do. + */ +#define OPTIMIZER_HIDE_VAR(var) barrier() + /* Intel ECC compiler doesn't support __builtin_types_compatible_p() */ #define __must_be_array(a) 0 #endif -#define uninitialized_var(x) x +#ifndef __HAVE_BUILTIN_BSWAP16__ +/* icc has this, but it's called _bswap16 */ +#define __HAVE_BUILTIN_BSWAP16__ +#define __builtin_bswap16 _bswap16 +#endif diff --git a/include/linux/compiler.h b/include/linux/compiler.h index cc8c4de..8f0c292 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -10,6 +10,7 @@ # define __force __attribute__((force)) # define __nocast __attribute__((nocast)) # define __iomem __attribute__((noderef, address_space(2))) +# define __must_hold(x) __attribute__((context(x,1,1))) # define __acquires(x) __attribute__((context(x,0,1))) # define __releases(x) __attribute__((context(x,1,0))) # define __acquire(x) __context__(x,1) @@ -27,6 +28,7 @@ # define __chk_user_ptr(x) (void)0 # define __chk_io_ptr(x) (void)0 # define __builtin_warning(x, y...) (1) +# define __must_hold(x) # define __acquires(x) # define __releases(x) # define __acquire(x) (void)0 @@ -34,6 +36,10 @@ # define __cond_lock(x,c) (c) #endif +/* Indirect macros required for expanded argument pasting, eg. __LINE__. */ +#define ___PASTE(a,b) a##b +#define __PASTE(a,b) ___PASTE(a,b) + #ifdef __KERNEL__ #ifdef __GNUC__ @@ -49,6 +55,13 @@ # include #endif +/* Clang compiler defines __GNUC__. So we will overwrite implementations + * coming from above header files here + */ +#ifdef __clang__ +#include +#endif + /* * Generic compiler-dependent macros required for kernel * build go below this comment. Actual compiler/compiler version @@ -144,6 +157,10 @@ # define barrier() __memory_barrier() #endif +#ifndef barrier_data +# define barrier_data(ptr) barrier() +#endif + /* Unreachable code */ #ifndef unreachable # define unreachable() do { } while (1) @@ -156,6 +173,15 @@ (typeof(ptr)) (__ptr + (off)); }) #endif +#ifndef OPTIMIZER_HIDE_VAR +#define OPTIMIZER_HIDE_VAR(var) barrier() +#endif + +/* Not-quite-unique ID. */ +#ifndef __UNIQUE_ID +# define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __LINE__) +#endif + #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ @@ -228,7 +254,7 @@ /* * Rather then using noinline to prevent stack consumption, use - * noinline_for_stack instead. For documentaiton reasons. + * noinline_for_stack instead. For documentation reasons. */ #define noinline_for_stack noinline @@ -270,11 +296,20 @@ # define __section(S) __attribute__ ((__section__(#S))) #endif +#ifndef __visible +#define __visible +#endif + /* Are two types/vars the same type (ignoring qualifiers)? */ #ifndef __same_type # define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) #endif +/* Is this type a native word size -- useful for atomic operations */ +#ifndef __native_word +# define __native_word(t) (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) +#endif + /* Compile time object size, -1 for unknown */ #ifndef __compiletime_object_size # define __compiletime_object_size(obj) -1 @@ -284,7 +319,48 @@ #endif #ifndef __compiletime_error # define __compiletime_error(message) +/* + * Sparse complains of variable sized arrays due to the temporary variable in + * __compiletime_assert. Unfortunately we can't just expand it out to make + * sparse see a constant array size without breaking compiletime_assert on old + * versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether. + */ +# ifndef __CHECKER__ +# define __compiletime_error_fallback(condition) \ + do { ((void)sizeof(char[1 - 2 * condition])); } while (0) +# endif #endif +#ifndef __compiletime_error_fallback +# define __compiletime_error_fallback(condition) do { } while (0) +#endif + +#define __compiletime_assert(condition, msg, prefix, suffix) \ + do { \ + bool __cond = !(condition); \ + extern void prefix ## suffix(void) __compiletime_error(msg); \ + if (__cond) \ + prefix ## suffix(); \ + __compiletime_error_fallback(__cond); \ + } while (0) + +#define _compiletime_assert(condition, msg, prefix, suffix) \ + __compiletime_assert(condition, msg, prefix, suffix) + +/** + * compiletime_assert - break build and emit msg if condition is false + * @condition: a compile-time constant condition to check + * @msg: a message to emit if condition is false + * + * In tradition of POSIX assert, this macro will break the build if the + * supplied condition is *false*, emitting the supplied error message if the + * compiler has support to do so. + */ +#define compiletime_assert(condition, msg) \ + _compiletime_assert(condition, msg, __compiletime_assert_, __LINE__) + +#define compiletime_assert_atomic_type(t) \ + compiletime_assert(__native_word(t), \ + "Need native word sized stores/loads for atomicity.") /* * Prevent the compiler from merging or refetching accesses. The compiler @@ -293,11 +369,22 @@ * to make the compiler aware of ordering is to put the two invocations of * ACCESS_ONCE() in different C statements. * - * This macro does absolutely -nothing- to prevent the CPU from reordering, - * merging, or refetching absolutely anything at any time. Its main intended - * use is to mediate communication between process-level code and irq/NMI - * handlers, all running on the same CPU. + * ACCESS_ONCE will only work on scalar types. For union types, ACCESS_ONCE + * on a union member will work as long as the size of the member matches the + * size of the union and the size is smaller than word size. + * + * The major use cases of ACCESS_ONCE used to be (1) Mediating communication + * between process-level code and irq/NMI handlers, all running on the same CPU, + * and (2) Ensuring that the compiler does not fold, spindle, or otherwise + * mutilate accesses that either do not require ordering or that interact + * with an explicit memory barrier or atomic instruction that provides the + * required ordering. + * + * If possible use READ_ONCE()/WRITE_ONCE() instead. */ -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) +#define __ACCESS_ONCE(x) ({ \ + __maybe_unused typeof(x) __var = (__force typeof(x)) 0; \ + (volatile typeof(x) *)&(x); }) +#define ACCESS_ONCE(x) (*__ACCESS_ONCE(x)) #endif /* __LINUX_COMPILER_H */ diff --git a/include/regulator.h b/include/regulator.h index a43d3df..367e13f 100644 --- a/include/regulator.h +++ b/include/regulator.h @@ -6,6 +6,7 @@ struct regulator_dev { struct regulator_ops *ops; + int boot_on; }; struct regulator_ops { diff --git a/scripts/socfpga_mkimage.c b/scripts/socfpga_mkimage.c index bab1b1a..1a7a66d 100644 --- a/scripts/socfpga_mkimage.c +++ b/scripts/socfpga_mkimage.c @@ -234,8 +234,8 @@ } if (s.st_size > max_image_size) { - fprintf(stderr, "input image too big. Maximum is %d bytes\n", - MAX_IMAGE_SIZE); + fprintf(stderr, "input image too big. Maximum is %d bytes, got %ld bytes\n", + max_image_size, s.st_size); exit(1); }