diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..2e51c38 --- /dev/null +++ b/.mailmap @@ -0,0 +1,27 @@ +# +# This list is used by git-shortlog to fix a few botched name translations +# in the git archive, either because the author's full name was messed up +# and/or not always written the same way, making contributions from the +# same person appearing not to be so or badly displayed. +# +# This file can be modified by hand or updated by the following command: +# scripts/mailmapper > tmp; mv tmp .mailmap +# + +Alexander Shiyan +Eric Bénard +Franck Jullien +Jin Zhengxiong +Juergen Beisert +Marc Reilly +Nishanth Menon +Raphaël Poggi +Robert Schwebel +Sascha Hauer +Silvio Fricke +Stefan Roese +Vicente Bergas +Wjatscheslaw Stoljarski +Wolfgang Denk +gregory hermant +shravan diff --git a/Makefile b/Makefile index 60cb02c..6fb4967 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ # Do not: # o use make's built-in rules and variables -# (this increases performance and avoid hard-to-debug behavour); +# (this increases performance and avoids hard-to-debug behaviour); # o print "Entering directory ..."; MAKEFLAGS += -rR --no-print-directory @@ -1137,7 +1137,7 @@ # Single targets # --------------------------------------------------------------------------- # Single targets are compatible with: -# - build whith mixed source and output +# - build with mixed source and output # - build with separate output dir 'make O=...' # - external modules # @@ -1211,6 +1211,5 @@ Makefile: ; # Declare the contents of the .PHONY variable as phony. We keep that -# information in a variable se we can use it in if_changed and friends. +# information in a variable so we can use it in if_changed and friends. .PHONY: $(PHONY) - diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index 25045ac..fb257fb 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -95,6 +95,7 @@ obj-$(CONFIG_MACH_SABRESD) += freescale-mx6-sabresd/ obj-$(CONFIG_MACH_SAMA5D3XEK) += sama5d3xek/ obj-$(CONFIG_MACH_SAMA5D3_XPLAINED) += sama5d3_xplained/ +obj-$(CONFIG_MACH_SAMA5D4_XPLAINED) += sama5d4_xplained/ obj-$(CONFIG_MACH_SAMA5D4EK) += sama5d4ek/ obj-$(CONFIG_MACH_SCB9328) += scb9328/ obj-$(CONFIG_MACH_SOCFPGA_EBV_SOCRATES) += ebv-socrates/ diff --git a/arch/arm/boards/sama5d4_xplained/Makefile b/arch/arm/boards/sama5d4_xplained/Makefile new file mode 100644 index 0000000..44550f5 --- /dev/null +++ b/arch/arm/boards/sama5d4_xplained/Makefile @@ -0,0 +1 @@ +obj-y += sama5d4_xplained.o diff --git a/arch/arm/boards/sama5d4_xplained/env/bin/init_board b/arch/arm/boards/sama5d4_xplained/env/bin/init_board new file mode 100644 index 0000000..f3d417e --- /dev/null +++ b/arch/arm/boards/sama5d4_xplained/env/bin/init_board @@ -0,0 +1,15 @@ +#!/bin/sh + +PATH=/env/bin +export PATH + +. /env/config + +splash=/env/splash.png + +if [ -f ${splash} -a -e /dev/fb0 ]; then + splash -o ${splash} + fb0.enable=1 +fi + +exit 1 diff --git a/arch/arm/boards/sama5d4_xplained/env/config b/arch/arm/boards/sama5d4_xplained/env/config new file mode 100644 index 0000000..1007345 --- /dev/null +++ b/arch/arm/boards/sama5d4_xplained/env/config @@ -0,0 +1,42 @@ +#!/bin/sh + +# use 'dhcp' to do dhcp in barebox and in kernel +# use 'none' if you want to skip kernel ip autoconfiguration +ip=dhcp + +# or set your networking parameters here +#eth0.ipaddr=a.b.c.d +#eth0.netmask=a.b.c.d +#eth0.gateway=a.b.c.d +#eth0.serverip=a.b.c.d + +# can be either 'nfs', 'tftp', 'nor' or 'nand' +kernel_loc=nfs +# can be either 'net', 'nor', 'nand' or 'initrd' +rootfs_loc=net +# can be either 'nfs', 'tftp', 'nand' or empty +oftree_loc=nfs + +# can be either 'jffs2' or 'ubifs' +rootfs_type=ubifs +rootfsimage=root.$rootfs_type +ubiroot=rootfs + +# The image type of the kernel. Can be uimage, zimage, raw, or raw_lzo +kernelimage=zImage +#kernelimage=uImage +#kernelimage=Image +#kernelimage=Image.lzo + +nand_device=atmel_nand +nand_parts="256k(at91bootstrap),512k(barebox)ro,256k(bareboxenv),256k(bareboxenv2),256k(spare),512k(oftree),6M(kernel),-(rootfs)" +rootfs_mtdblock_nand=7 + +m25p80_parts="64k(bootstrap),384k(barebox),256k(bareboxenv),256k(bareboxenv2),128k(oftree),-(updater)" + +autoboot_timeout=3 + +bootargs="console=ttyS0,115200" + +# set a fancy prompt (if support is compiled in) +PS1="\e[1;32mbarebox@\e[1;31m\h:\w\e[0m\n# " diff --git a/arch/arm/boards/sama5d4_xplained/sama5d4_xplained.c b/arch/arm/boards/sama5d4_xplained/sama5d4_xplained.c new file mode 100644 index 0000000..0126220 --- /dev/null +++ b/arch/arm/boards/sama5d4_xplained/sama5d4_xplained.c @@ -0,0 +1,319 @@ +/* + * SAMA5D4 XPLAINED ULTRA board configuration. + * + * Copyright (C) 2014 Atmel Corporation, + * Bo Shen + * + * Licensed under GPLv2 or later. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if defined(CONFIG_NAND_ATMEL) +static struct atmel_nand_data nand_pdata = { + .ale = 21, + .cle = 22, + .det_pin = -EINVAL, + .rdy_pin = -EINVAL, + .enable_pin = -EINVAL, + .ecc_mode = NAND_ECC_HW, + .pmecc_sector_size = 512, + .pmecc_corr_cap = 8, + .on_flash_bbt = 1, +}; + +static struct sam9_smc_config cm_nand_smc_config = { + .ncs_read_setup = 1, + .nrd_setup = 1, + .ncs_write_setup = 1, + .nwe_setup = 1, + + .ncs_read_pulse = 3, + .nrd_pulse = 2, + .ncs_write_pulse = 3, + .nwe_pulse = 2, + + .read_cycle = 5, + .write_cycle = 5, + + .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE, + .tdf_cycles = 3, + + .tclr = 2, + .tadl = 7, + .tar = 2, + .ocms = 0, + .trr = 3, + .twb = 7, + .rbnsel = 3, + .nfsel = 1, +}; + +static void ek_add_device_nand(void) +{ + struct clk *clk = clk_get(NULL, "smc_clk"); + + clk_enable(clk); + + /* configure chip-select 3 (NAND) */ + sama5_smc_configure(0, 3, &cm_nand_smc_config); + + at91_add_device_nand(&nand_pdata); +} +#else +static void ek_add_device_nand(void) {} +#endif + +#if defined(CONFIG_DRIVER_NET_MACB) +static struct macb_platform_data macb0_pdata = { + .phy_interface = PHY_INTERFACE_MODE_RMII, + .phy_addr = 0, +}; + +static void ek_add_device_eth(void) +{ + at91_add_device_eth(0, &macb0_pdata); +} +#else +static void ek_add_device_eth(void) {} +#endif + +#if defined(CONFIG_DRIVER_VIDEO_ATMEL_HLCD) +static struct fb_videomode at91_tft_vga_modes[] = { + { + .name = "TM4301", + .refresh = 60, + .xres = 480, .yres = 272, + .pixclock = KHZ2PICOS(9000), + + .left_margin = 2, .right_margin = 2, + .upper_margin = 2, .lower_margin = 2, + .hsync_len = 41, .vsync_len = 11, + + .sync = 0, + .vmode = FB_VMODE_NONINTERLACED, + }, +}; + +/* Output mode is TFT 24 bits */ +#define BPP_OUT_DEFAULT_LCDCFG5 (LCDC_LCDCFG5_MODE_OUTPUT_24BPP) + +static struct atmel_lcdfb_platform_data ek_lcdc_data = { + .lcdcon_is_backlight = true, + .default_bpp = 16, + .default_dmacon = ATMEL_LCDC_DMAEN, + .default_lcdcon2 = BPP_OUT_DEFAULT_LCDCFG5, + .guard_time = 9, + .lcd_wiring_mode = ATMEL_LCDC_WIRING_RGB, + .mode_list = at91_tft_vga_modes, + .num_modes = ARRAY_SIZE(at91_tft_vga_modes), +}; + +static void ek_add_device_lcdc(void) +{ + /* On sama5d4 xplained ultra board, we use 24bits connection */ + at91_set_A_periph(AT91_PIN_PA0, 0); /* LCDD0 */ + at91_set_A_periph(AT91_PIN_PA1, 0); /* LCDD1 */ + at91_set_A_periph(AT91_PIN_PA8, 0); /* LCDD8 */ + at91_set_A_periph(AT91_PIN_PA9, 0); /* LCDD9 */ + at91_set_A_periph(AT91_PIN_PA16, 0); /* LCDD16 */ + at91_set_A_periph(AT91_PIN_PA17, 0); /* LCDD17 */ + + at91_add_device_lcdc(&ek_lcdc_data); +} +#else +static void ek_add_device_lcdc(void) {} +#endif + +#if defined(CONFIG_MCI_ATMEL) +static struct atmel_mci_platform_data mci1_data = { + .bus_width = 4, + .detect_pin = AT91_PIN_PE3, + .wp_pin = -EINVAL, +}; + +static void ek_add_device_mci(void) +{ + /* MMC1 */ + at91_add_device_mci(1, &mci1_data); + + /* power on MCI1 */ + at91_set_gpio_output(AT91_PIN_PE15, 0); +} +#else +static void ek_add_device_mci(void) {} +#endif + +#if defined(CONFIG_I2C_GPIO) +struct qt1070_platform_data qt1070_pdata = { + .irq_pin = AT91_PIN_PE10, +}; + +static struct i2c_board_info i2c_devices[] = { + { + .platform_data = &qt1070_pdata, + I2C_BOARD_INFO("qt1070", 0x1b), + }, +}; + +static void ek_add_device_i2c(void) +{ + at91_set_gpio_input(qt1070_pdata.irq_pin, 0); + at91_set_deglitch(qt1070_pdata.irq_pin, 1); + at91_add_device_i2c(0, i2c_devices, ARRAY_SIZE(i2c_devices)); +} +#else +static void ek_add_device_i2c(void) {} +#endif + +#if defined(CONFIG_DRIVER_SPI_ATMEL) +static const struct spi_board_info ek_spi_devices[] = { + { + .name = "m25p80", + .chip_select = 0, + .max_speed_hz = 30 * 1000 * 1000, + .bus_num = 0, + } +}; + +static unsigned spi0_standard_cs[] = { AT91_PIN_PC3 }; +static struct at91_spi_platform_data spi_pdata = { + .chipselect = spi0_standard_cs, + .num_chipselect = ARRAY_SIZE(spi0_standard_cs), +}; + +static void ek_add_device_spi(void) +{ + spi_register_board_info(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); + at91_add_device_spi(0, &spi_pdata); +} +#else +static void ek_add_device_spi(void) {} +#endif + +#ifdef CONFIG_LED_GPIO +struct gpio_led leds[] = { + { + .gpio = AT91_PIN_PD30, + .active_low = 0, + .led = { + .name = "d8", + }, + }, { + .gpio = AT91_PIN_PE15, + .active_low = 0, + .led = { + .name = "d10", + }, + }, +}; + +static void ek_add_led(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(leds); i++) { + at91_set_gpio_output(leds[i].gpio, leds[i].active_low); + led_gpio_register(&leds[i]); + } + led_set_trigger(LED_TRIGGER_HEARTBEAT, &leds[0].led); +} +#else +static void ek_add_led(void) {} +#endif + +static int sama5d4ek_mem_init(void) +{ + at91_add_device_sdram(0); + + return 0; +} +mem_initcall(sama5d4ek_mem_init); + +static const struct devfs_partition sama5d4ek_nand0_partitions[] = { + { + .offset = 0x00000, + .size = SZ_256K, + .flags = DEVFS_PARTITION_FIXED, + .name = "at91bootstrap_raw", + .bbname = "at91bootstrap", + }, { + .offset = DEVFS_PARTITION_APPEND, + .size = SZ_512K, + .flags = DEVFS_PARTITION_FIXED, + .name = "bootloader_raw", + .bbname = "bootloader", + }, { + .offset = DEVFS_PARTITION_APPEND, + .size = SZ_256K, + .flags = DEVFS_PARTITION_FIXED, + .name = "env_raw", + .bbname = "env0", + }, { + .offset = DEVFS_PARTITION_APPEND, + .size = SZ_256K, + .flags = DEVFS_PARTITION_FIXED, + .name = "env_raw1", + .bbname = "env1", + }, { + /* sentinel */ + } +}; + +static int sama5d4ek_devices_init(void) +{ + ek_add_device_i2c(); + ek_add_device_nand(); + ek_add_led(); + ek_add_device_eth(); + ek_add_device_spi(); + ek_add_device_mci(); + ek_add_device_lcdc(); + + devfs_create_partitions("nand0", sama5d4ek_nand0_partitions); + + return 0; +} +device_initcall(sama5d4ek_devices_init); + +static int sama5d4ek_console_init(void) +{ + barebox_set_model("Atmel sama5d4ek"); + barebox_set_hostname("sama5d4ek"); + + at91_register_uart(4, 0); + + return 0; +} +console_initcall(sama5d4ek_console_init); + +static int sama5d4ek_main_clock(void) +{ + at91_set_main_clock(12000000); + + return 0; +} +pure_initcall(sama5d4ek_main_clock); diff --git a/arch/arm/boards/variscite-mx6/board.c b/arch/arm/boards/variscite-mx6/board.c index ce1284f..de74abc 100644 --- a/arch/arm/boards/variscite-mx6/board.c +++ b/arch/arm/boards/variscite-mx6/board.c @@ -49,7 +49,7 @@ unsigned char value, rev_id = 0 ; struct i2c_adapter *adapter = NULL; struct i2c_client client; - int addr = -1, ret, bus = 0; + int addr = -1, bus = 0; /* I2C2 bus (2-1 = 1 in barebox numbering) */ bus = 1; @@ -80,7 +80,10 @@ /* Set Gigabit Ethernet voltage (SOM v1.1/1.0)*/ value = 0x60; - ret = i2c_write_reg(&client, 0x4a, &value, 1); + if (i2c_write_reg(&client, 0x4a, &value, 1) != 1) { + pr_err("Set ETH error!\n"); + return -EIO; + } /* set VGEN3 to 2.5V */ value = 0x77; diff --git a/arch/arm/configs/sama5d4_xplained_defconfig b/arch/arm/configs/sama5d4_xplained_defconfig new file mode 100644 index 0000000..51083fe --- /dev/null +++ b/arch/arm/configs/sama5d4_xplained_defconfig @@ -0,0 +1,86 @@ +CONFIG_ARCH_SAMA5D4=y +CONFIG_MACH_SAMA5D4_XPLAINED=y +CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x60000 +CONFIG_AEABI=y +CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y +CONFIG_PBL_IMAGE=y +CONFIG_MMU=y +CONFIG_TEXT_BASE=0x26f00000 +CONFIG_MALLOC_SIZE=0xA00000 +CONFIG_EXPERIMENTAL=y +CONFIG_MALLOC_TLSF=y +CONFIG_PROMPT="A5D4_XPLAINED:" +CONFIG_GLOB=y +CONFIG_PROMPT_HUSH_PS2="y" +CONFIG_HUSH_FANCY_PROMPT=y +CONFIG_CMDLINE_EDITING=y +CONFIG_AUTO_COMPLETE=y +CONFIG_CONSOLE_ACTIVATE_ALL=y +CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y +CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/sama5d4ek/env" +CONFIG_DEBUG_INFO=y +# CONFIG_CMD_ARM_CPUINFO is not set +CONFIG_LONGHELP=y +CONFIG_CMD_MEMINFO=y +CONFIG_CMD_BOOTM_SHOW_TYPE=y +CONFIG_CMD_BOOTM_VERBOSE=y +CONFIG_CMD_BOOTM_INITRD=y +CONFIG_CMD_BOOTM_OFTREE=y +CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y +# CONFIG_CMD_BOOTU is not set +CONFIG_CMD_GO=y +CONFIG_CMD_LOADB=y +CONFIG_CMD_RESET=y +CONFIG_CMD_UIMAGE=y +CONFIG_CMD_PARTITION=y +CONFIG_CMD_EXPORT=y +CONFIG_CMD_LOADENV=y +CONFIG_CMD_PRINTENV=y +CONFIG_CMD_SAVEENV=y +CONFIG_CMD_FILETYPE=y +CONFIG_CMD_SLEEP=y +CONFIG_CMD_DHCP=y +CONFIG_CMD_MIITOOL=y +CONFIG_CMD_PING=y +CONFIG_CMD_TFTP=y +CONFIG_CMD_ECHO_E=y +CONFIG_CMD_EDIT=y +CONFIG_CMD_SPLASH=y +CONFIG_CMD_READLINE=y +CONFIG_CMD_TIMEOUT=y +CONFIG_CMD_FLASH=y +CONFIG_CMD_GPIO=y +CONFIG_CMD_SPI=y +CONFIG_CMD_OFTREE=y +CONFIG_NET=y +CONFIG_NET_NFS=y +CONFIG_OFDEVICE=y +CONFIG_DRIVER_NET_MACB=y +CONFIG_MICREL_PHY=y +CONFIG_DRIVER_SPI_ATMEL=y +CONFIG_I2C=y +CONFIG_I2C_GPIO=y +CONFIG_MTD=y +CONFIG_MTD_RAW_DEVICE=y +CONFIG_MTD_M25P80=y +CONFIG_NAND=y +# CONFIG_NAND_ECC_SOFT is not set +# CONFIG_NAND_ECC_HW_SYNDROME is not set +CONFIG_NAND_ATMEL=y +CONFIG_NAND_ATMEL_PMECC=y +CONFIG_VIDEO=y +CONFIG_DRIVER_VIDEO_ATMEL_HLCD=y +CONFIG_MCI=y +CONFIG_MCI_STARTUP=y +CONFIG_MCI_ATMEL=y +CONFIG_LED=y +CONFIG_LED_GPIO=y +CONFIG_LED_TRIGGERS=y +CONFIG_KEYBOARD_GPIO=y +CONFIG_KEYBOARD_QT1070=y +CONFIG_FS_EXT4=y +CONFIG_FS_TFTP=y +CONFIG_FS_FAT=y +CONFIG_FS_FAT_WRITE=y +CONFIG_FS_FAT_LFN=y +CONFIG_PNG=y diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig index 8c10c10..9ee4f30 100644 --- a/arch/arm/mach-at91/Kconfig +++ b/arch/arm/mach-at91/Kconfig @@ -492,6 +492,11 @@ help Select this if you are using Atmel's SAMA5D4-EK Evaluation Kit. +config MACH_SAMA5D4_XPLAINED + bool "Atmel SAMA5D4 XPLAINED ULTRA Evaluation Kit" + help + Select this if you are using Atmel's SAMA5D4_XPLAINED ULTRA Evaluation Kit. + endchoice endif diff --git a/common/clock.c b/common/clock.c index 76ce881..2ee81da 100644 --- a/common/clock.c +++ b/common/clock.c @@ -41,25 +41,25 @@ uint64_t get_time_ns(void) { struct clocksource *cs = current_clock; - uint64_t cycle_now, cycle_delta; - uint64_t ns_offset; + uint64_t cycle_now, cycle_delta; + uint64_t ns_offset; if (!cs) return 0; - /* read clocksource: */ + /* read clocksource: */ cycle_now = cs->read() & cs->mask; - /* calculate the delta since the last call: */ - cycle_delta = (cycle_now - cs->cycle_last) & cs->mask; + /* calculate the delta since the last call: */ + cycle_delta = (cycle_now - cs->cycle_last) & cs->mask; - /* convert to nanoseconds: */ - ns_offset = cyc2ns(cs, cycle_delta); + /* convert to nanoseconds: */ + ns_offset = cyc2ns(cs, cycle_delta); cs->cycle_last = cycle_now; time_ns += ns_offset; - return time_ns; + return time_ns; } EXPORT_SYMBOL(get_time_ns); @@ -89,32 +89,32 @@ void clocks_calc_mult_shift(uint32_t *mult, uint32_t *shift, uint32_t from, uint32_t to, uint32_t maxsec) { - uint64_t tmp; - uint32_t sft, sftacc = 32; + uint64_t tmp; + uint32_t sft, sftacc = 32; - /* - * Calculate the shift factor which is limiting the conversion - * range: - */ - tmp = ((uint64_t)maxsec * from) >> 32; - while (tmp) { - tmp >>=1; - sftacc--; - } + /* + * Calculate the shift factor which is limiting the conversion + * range: + */ + tmp = ((uint64_t)maxsec * from) >> 32; + while (tmp) { + tmp >>= 1; + sftacc--; + } - /* - * Find the conversion shift/mult pair which has the best - * accuracy and fits the maxsec conversion range: - */ - for (sft = 32; sft > 0; sft--) { - tmp = (uint64_t) to << sft; - tmp += from / 2; - do_div(tmp, from); - if ((tmp >> sftacc) == 0) - break; - } - *mult = tmp; - *shift = sft; + /* + * Find the conversion shift/mult pair which has the best + * accuracy and fits the maxsec conversion range: + */ + for (sft = 32; sft > 0; sft--) { + tmp = (uint64_t) to << sft; + tmp += from / 2; + do_div(tmp, from); + if ((tmp >> sftacc) == 0) + break; + } + *mult = tmp; + *shift = sft; } @@ -129,19 +129,19 @@ */ uint32_t clocksource_hz2mult(uint32_t hz, uint32_t shift_constant) { - /* hz = cyc/(Billion ns) - * mult/2^shift = ns/cyc - * mult = ns/cyc * 2^shift - * mult = 1Billion/hz * 2^shift - * mult = 1000000000 * 2^shift / hz - * mult = (1000000000< #include #include +#include struct filetype_str { const char *name; /* human readable filetype */ @@ -87,6 +88,10 @@ #define MBR_PART_start_sect 8 #define MBR_OSTYPE_EFI_GPT 0xee +#define FAT_BS_reserved 14 +#define FAT_BS_fats 16 +#define FAT_BS_media 21 + static inline int pmbr_part_valid(const uint8_t *buf) { if (buf[MBR_PART_sys_ind] == MBR_OSTYPE_EFI_GPT && @@ -126,6 +131,49 @@ return 0; } +static inline int fat_valid_media(u8 media) +{ + return (0xf8 <= media || media == 0xf0); +} + +static int is_fat_with_no_mbr(const unsigned char *sect) +{ + if (!get_unaligned_le16(§[FAT_BS_reserved])) + return 0; + + if (!sect[FAT_BS_fats]) + return 0; + + if (!fat_valid_media(sect[FAT_BS_media])) + return 0; + + return 1; +} + +int is_fat_boot_sector(const void *sect) +{ + struct partition_entry *p; + int slot; + + p = (struct partition_entry *) (sect + MBR_Table); + /* max 4 partitions */ + for (slot = 1; slot <= 4; slot++, p++) { + if (p->boot_indicator && p->boot_indicator != 0x80) { + /* + * Even without a valid boot inidicator value + * its still possible this is valid FAT filesystem + * without a partition table. + */ + if (slot == 1 && is_fat_with_no_mbr(sect)) + return 1; + else + return -EINVAL; + } + } + + return 0; +} + enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec) { /* diff --git a/common/globalvar.c b/common/globalvar.c index 1f9b0cc..c72f147 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -17,7 +17,12 @@ const char *(*get)(struct device_d *, struct param_d *p), unsigned long flags) { - return dev_add_param(&global_device, name, set, get, flags); + struct param_d *param; + + param = dev_add_param(&global_device, name, set, get, flags); + if (IS_ERR(param)) + return PTR_ERR(param); + return 0; } /* diff --git a/common/partitions.c b/common/partitions.c index 694c6f6..37d9cb7 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -107,6 +107,8 @@ * useful for compatibility */ type = file_detect_partition_table(buf, SECTOR_SIZE); + if (type == filetype_fat && !is_fat_boot_sector(buf)) + type = filetype_mbr; list_for_each_entry(parser, &partition_parser_list, list) { if (parser->type == type) diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c index 6e02d46..738bde9 100644 --- a/drivers/mci/mxs.c +++ b/drivers/mci/mxs.c @@ -152,7 +152,7 @@ * @return 0 on success, negative values else * * @note This routine uses PIO to read in the data bytes from the FIFO. This - * may fail whith high clock speeds. If you receive -EIO errors you can try + * may fail with high clock speeds. If you receive -EIO errors you can try * again with reduced clock speeds. */ static int mxs_mci_read_data(struct mxs_mci_host *mxs_mci, void *buffer, unsigned length) diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c index d3cc0e9..b6618ad 100644 --- a/drivers/net/cpsw.c +++ b/drivers/net/cpsw.c @@ -1199,6 +1199,19 @@ mdiobus_register(&priv->miibus); for (i = 0; i < priv->num_slaves; i++) { + struct phy_device *phy; + + phy = mdiobus_scan(&priv->miibus, priv->slaves[i].phy_id); + if (IS_ERR(phy)) { + ret = PTR_ERR(phy); + goto out; + } + + phy->dev.device_node = priv->slaves[i].dev.device_node; + ret = phy_register_device(phy); + if (ret) + goto out; + ret = cpsw_slave_setup(&priv->slaves[i], i, priv); if (ret) goto out; diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 866391c..095563a 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -146,6 +146,90 @@ return 0; } +#define KSZ9031_PS_TO_REG 60 + +/* Extended registers */ +#define MII_KSZ9031RN_CONTROL_PAD_SKEW 4 +#define MII_KSZ9031RN_RX_DATA_PAD_SKEW 5 +#define MII_KSZ9031RN_TX_DATA_PAD_SKEW 6 +#define MII_KSZ9031RN_CLK_PAD_SKEW 8 + +static int ksz9031_of_load_skew_values(struct phy_device *phydev, + struct device_node *of_node, + u16 reg, size_t field_sz, + char *field[], u8 numfields) +{ + int val[4] = {-1, -2, -3, -4}; + int matches = 0; + u16 mask; + u16 maxval; + u16 newval; + int i; + + for (i = 0; i < numfields; i++) + if (!of_property_read_u32(of_node, field[i], val + i)) + matches++; + + if (!matches) + return 0; + + if (matches < numfields) + newval = phy_read_mmd_indirect(phydev, reg, 2); + else + newval = 0; + + maxval = (field_sz == 4) ? 0xf : 0x1f; + for (i = 0; i < numfields; i++) + if (val[i] != -(i + 1)) { + mask = 0xffff; + mask ^= maxval << (field_sz * i); + newval = (newval & mask) | + (((val[i] / KSZ9031_PS_TO_REG) & maxval) + << (field_sz * i)); + } + + phy_write_mmd_indirect(phydev, reg, 2, newval); + return 0; +} + +static int ksz9031_config_init(struct phy_device *phydev) +{ + struct device_d *dev = &phydev->dev; + struct device_node *of_node = dev->device_node; + char *clk_skews[2] = {"rxc-skew-ps", "txc-skew-ps"}; + char *rx_data_skews[4] = { + "rxd0-skew-ps", "rxd1-skew-ps", + "rxd2-skew-ps", "rxd3-skew-ps" + }; + char *tx_data_skews[4] = { + "txd0-skew-ps", "txd1-skew-ps", + "txd2-skew-ps", "txd3-skew-ps" + }; + char *control_skews[2] = {"txen-skew-ps", "rxdv-skew-ps"}; + + if (!of_node && dev->parent->device_node) + of_node = dev->parent->device_node; + + if (of_node) { + ksz9031_of_load_skew_values(phydev, of_node, + MII_KSZ9031RN_CLK_PAD_SKEW, 5, + clk_skews, 2); + + ksz9031_of_load_skew_values(phydev, of_node, + MII_KSZ9031RN_CONTROL_PAD_SKEW, 4, + control_skews, 2); + + ksz9031_of_load_skew_values(phydev, of_node, + MII_KSZ9031RN_RX_DATA_PAD_SKEW, 4, + rx_data_skews, 4); + + ksz9031_of_load_skew_values(phydev, of_node, + MII_KSZ9031RN_TX_DATA_PAD_SKEW, 4, + tx_data_skews, 4); + } + return 0; +} + #define KSZ8873MLL_GLOBAL_CONTROL_4 0x06 #define KSZ8873MLL_GLOBAL_CONTROL_4_DUPLEX (1 << 6) #define KSZ8873MLL_GLOBAL_CONTROL_4_SPEED (1 << 4) @@ -267,7 +351,7 @@ .phy_id_mask = 0x00fffff0, .drv.name = "Micrel KSZ9031 Gigabit PHY", .features = (PHY_GBIT_FEATURES | SUPPORTED_Pause), - .config_init = kszphy_config_init, + .config_init = ksz9031_config_init, .config_aneg = genphy_config_aneg, .read_status = genphy_read_status, }, { diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index 4ca7444..53d48a0 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -441,10 +441,7 @@ cdev->setbrg = ns16550_setbaudrate; cdev->linux_console_name = devtype->linux_console_name; - if (plat && (plat->flags & NS16650_FLAG_DISABLE_FIFO)) - priv->fcrval = FCRVAL & ~FCR_FIFO_EN; - else - priv->fcrval = FCRVAL; + priv->fcrval = FCRVAL; devtype->init_port(cdev); diff --git a/include/filetype.h b/include/filetype.h index eedf4b4..2c3c38d 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -44,6 +44,7 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize); enum filetype file_name_detect_type(const char *filename); enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec); +int is_fat_boot_sector(const void *_buf); #define ARM_HEAD_SIZE 0x30 #define ARM_HEAD_MAGICWORD_OFFSET 0x20 diff --git a/include/ns16550.h b/include/ns16550.h index 876bb04..ccf950b 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -34,9 +34,6 @@ /** Clock speed */ unsigned int clock; int shift; - unsigned int flags; - int mmio; -#define NS16650_FLAG_DISABLE_FIFO 1 }; #endif /* __NS16650_PLATFORM_H_ */ diff --git a/include/param.h b/include/param.h index 9856a2e..b8dd9b1 100644 --- a/include/param.h +++ b/include/param.h @@ -26,7 +26,7 @@ int dev_set_param(struct device_d *dev, const char *name, const char *val); struct param_d *get_param_by_name(struct device_d *dev, const char *name); -int dev_add_param(struct device_d *dev, const char *name, +struct param_d *dev_add_param(struct device_d *dev, const char *name, int (*set)(struct device_d *dev, struct param_d *p, const char *val), const char *(*get)(struct device_d *, struct param_d *p), unsigned long flags); @@ -92,7 +92,7 @@ return NULL; } -static inline int dev_add_param(struct device_d *dev, char *name, +static inline struct param_d *dev_add_param(struct device_d *dev, char *name, int (*set)(struct device_d *dev, struct param_d *p, const char *val), const char *(*get)(struct device_d *, struct param_d *p), unsigned long flags) diff --git a/lib/parameter.c b/lib/parameter.c index c4c30ca..bcdb16b 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -160,7 +160,7 @@ * expect the parameter value to be a string which can be freed with free(). Do * not use static arrays when using the generic functions. */ -int dev_add_param(struct device_d *dev, const char *name, +struct param_d *dev_add_param(struct device_d *dev, const char *name, int (*set)(struct device_d *dev, struct param_d *p, const char *val), const char *(*get)(struct device_d *dev, struct param_d *param), unsigned long flags) @@ -171,10 +171,12 @@ param = xzalloc(sizeof(*param)); ret = __dev_add_param(param, dev, name, set, get, flags); - if (ret) + if (ret) { free(param); + return ERR_PTR(ret); + } - return ret; + return param; } /** diff --git a/scripts/mailmapper b/scripts/mailmapper new file mode 100755 index 0000000..dd1ddf6 --- /dev/null +++ b/scripts/mailmapper @@ -0,0 +1,160 @@ +#!/usr/bin/env python +# +# Copyright (C) 2014, Masahiro Yamada +# +# SPDX-License-Identifier: GPL-2.0+ +# + +''' +A tool to create/update the mailmap file + +The command 'git shortlog' summarizes git log output in a format suitable +for inclusion in release announcements. Each commit will be grouped by +author and title. + +One problem is that the authors' name and/or email address is sometimes +spelled differently. The .mailmap feature can be used to coalesce together +commits by the same persion. +(See 'man git-shortlog' for furthur information of this feature.) + +This tool helps to create/update the mailmap file. + +It runs 'git shortlog' internally and searches differently spelled author +names which share the same email address. The author name with the most +commits is asuumed to be a canonical real name. If the number of commits +from the cananonical name is equal to or greater than 'MIN_COMMITS', +the entry for the cananical name will be output. ('MIN_COMMITS' is used +here because we do not want to create a fat mailmap by adding every author +with only a few commits.) + +If there exists a mailmap file specified by the mailmap.file configuration +options or '.mailmap' at the toplevel of the repository, it is used as +a base file. (The mailmap.file configuration takes precedence over the +'.mailmap' file if both exist.) + +The base file and the newly added entries are merged together and sorted +alphabetically (but the comment block is kept untouched), and then printed +to standard output. + +Usage +----- + + scripts/mailmapper + +prints the mailmapping to standard output. + + scripts/mailmapper > tmp; mv tmp .mailmap + +will be useful for updating '.mailmap' file. +''' + +import sys +import os +import subprocess + +# The entries only for the canonical names with MIN_COMMITS or more commits. +# This limitation is used so as not to create a too big mailmap file. +MIN_COMMITS = 50 + +try: + toplevel = subprocess.check_output(['git', 'rev-parse', '--show-toplevel']) +except subprocess.CalledProcessError: + print >> sys.stderr, 'Please run in a git repository.' + sys.exit(1) + +# strip '\n' +toplevel = toplevel.rstrip() + +# Change the current working directory to the toplevel of the respository +# for our easier life. +os.chdir(toplevel) + +# First, create 'auther name' vs 'number of commits' database. +# We assume the name with the most commits as the canonical real name. +shortlog = subprocess.check_output(['git', 'shortlog', '-s', '-n']) + +commits_per_name = {} + +for line in shortlog.splitlines(): + try: + commits, name = line.split(None, 1) + except ValueError: + # ignore lines with an empty author name + pass + commits_per_name[name] = int(commits) + +# Next, coalesce the auther names with the same email address +shortlog = subprocess.check_output(['git', 'shortlog', '-s', '-n', '-e']) + +mail_vs_name = {} +output = {} + +for line in shortlog.splitlines(): + # tmp, mail = line.rsplit(None, 1) is not safe + # because weird email addresses might include whitespaces + tmp, mail = line.split('<') + mail = '<' + mail.rstrip() + try: + _, name = tmp.rstrip().split(None, 1) + except ValueError: + # author name is empty + name = '' + if mail in mail_vs_name: + # another name for the same email address + prev_name = mail_vs_name[mail] + # Take the name with more commits + major_name = sorted([prev_name, name], + key=lambda x: commits_per_name[x] if x else 0)[1] + mail_vs_name[mail] = major_name + if commits_per_name[major_name] > MIN_COMMITS: + output[mail] = major_name + else: + mail_vs_name[mail] = name + +# [1] If there exists a mailmap file at the location pointed to +# by the mailmap.file configuration option, update it. +# [2] If the file .mailmap exists at the toplevel of the repository, update it. +# [3] Otherwise, create a new mailmap file. +mailmap_files = [] + +try: + config_mailmap = subprocess.check_output(['git', 'config', 'mailmap.file']) +except subprocess.CalledProcessError: + config_mailmap = '' + +config_mailmap = config_mailmap.rstrip() +if config_mailmap: + mailmap_files.append(config_mailmap) + +mailmap_files.append('.mailmap') + +infile = None + +for map_file in mailmap_files: + try: + infile = open(map_file) + except: + # Failed to open. Try next. + continue + break + +comment_block = [] +output_lines = [] + +if infile: + for line in infile: + if line[0] == '#' or line[0] == '\n': + comment_block.append(line) + else: + output_lines.append(line) + break + for line in infile: + output_lines.append(line) + infile.close() + +for mail, name in output.items(): + output_lines.append(name + ' ' + mail + '\n') + +output_lines.sort() + +sys.stdout.write(''.join(comment_block + output_lines))