diff options
115 files changed, 3379 insertions, 515 deletions
diff --git a/Documentation/boards/imx/Garz-Fricke-Vincell.rst b/Documentation/boards/imx/Garz-Fricke-Vincell.rst index 2eb5f65c64..58ab0ab42f 100644 --- a/Documentation/boards/imx/Garz-Fricke-Vincell.rst +++ b/Documentation/boards/imx/Garz-Fricke-Vincell.rst @@ -7,7 +7,7 @@ This CPU card is based on a Freescale i.MX53 CPU. The card is shipped with: * 512MiB synchronous dynamic RAM * microSD slot -see http://www.garz-fricke.com/vincell-lt-core_de.html for more information +see http://www.garz-fricke.com/en/products/embedded-systems/single-board-computer/ia-0086r/ for more information Bootstrapping barebox diff --git a/Documentation/boards/imx/amazon-kindle-mx50.rst b/Documentation/boards/imx/amazon-kindle-mx50.rst new file mode 100644 index 0000000000..1e71cd26ba --- /dev/null +++ b/Documentation/boards/imx/amazon-kindle-mx50.rst @@ -0,0 +1,58 @@ +Amazon Kindle 4/5 Model No. D01100, D01200 and EY21 +=================================================== + +The Kindle Model No. D01100 (Kindle Wi-Fi), D01200 (Kindle Touch) +and EY21 (Paperwhite) are refered as the Kindle 4th and 5th generation. +Those e-book readers share a common set of hardware: + +* a Freescale i.MX50 SOC +* 2 or 4GiB eMMC +* a MC13892 PMIC + +The older readers D01100 and D01200 use 256MiB of LPDDR1, +while the newer EY21 uses 256MiB of LPDDR2. + +The devices boot up in internal boot mode from an eMMC boot partition and +are shipped with a vendor modified u-boot imximage based on u-boot v2009.08. + +To upload and run a new bootloader the older devices can be put into +USB-downloader mode by the SOC microcode when a specific key is pressed during +startup: +* the fiveway down button on the model D01100 +* the home button on model D01200 +A new USB device "NS Blank CODEX" should appear, barebox may be uploaded using +$ scripts/imx/imx-usb-loader barebox-kindle-d01100.img +$ scripts/imx/imx-usb-loader barebox-kindle-d01200.img +Hint: keep the select button pressed down to get the barebox USB console. + +Barebox may be used as drop-in replacement for the shipped bootloader, when +the imximg fits into 258048 bytes. When installing the barebox imximg on +the eMMC take care not to overwrite the vendor supplied serial numbers stored +on the eMMC. +e.g. for the D01100 just write the imx-header and the application section: +loady -t usbserial +memcpy -b -s barebox-kindle-d01100.img -d /dev/disk0.boot0.imx_header 1024 0 2048 +memcpy -b -s barebox-kindle-d01100.img -d /dev/disk0.boot0.self 4096 0 253952 + +Note: a USB serial ACM console will be launched by a barebox init script +when +* the cursor select key is pressed during startup of model D01100 +* the home button is pressed within a second after startup of model D01200. + If you press the home button during startup, you will enter USB boot mode. +* the EY21 has no keys to press, a USB console will be launched for 10s. + +This device is battery-powered and there is no way to switch the device off. +When the device is inactive, the kindle software will first reduce the +power consumption to a few milliamps of battery power, after some minutes +the power consumption is further reduced to about 550 microamps. Switching +on iomux pullups may significantly reduce your standby-time. + +Hints to reduce the build image size. +Note that a drop-in replacement barebox imximage must not exceed 258048 bytes +since the space behind it is in use. Hence, don't build in drivers and FS +that are not required, e.g.: + NET, DISK_AHCI, DISK_INTF_PLATFORM_IDE, DISK_ATA, VIDEO, PWM, LED, + USB_STORAGE, USB_ULPI, NAND, MTD_UBI, FS_UBIFS, MFD_MC34704, MFD_MC9SDZ60, + MFD_STMPE, EEPROM_AT25, EEPROM_AT24, KEYBOARD_GPIO, PARTITION_DISK_EFI +Also unselect support for other boards to get rid of their dependencies. +Further select IMAGE_COMPRESSION_XZKERN @@ -1,5 +1,5 @@ VERSION = 2017 -PATCHLEVEL = 04 +PATCHLEVEL = 05 SUBLEVEL = 0 EXTRAVERSION = NAME = None diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile index bcd94a0569..0ecfb3e4b3 100644 --- a/arch/arm/boards/Makefile +++ b/arch/arm/boards/Makefile @@ -119,6 +119,7 @@ obj-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += technexion-wandboard/ obj-$(CONFIG_MACH_TNY_A9260) += tny-a926x/ obj-$(CONFIG_MACH_TNY_A9263) += tny-a926x/ obj-$(CONFIG_MACH_TNY_A9G20) += tny-a926x/ +obj-$(CONFIG_MACH_KINDLE_MX50) += kindle-mx50/ obj-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += toradex-colibri-t20/ obj-$(CONFIG_MACH_TOSHIBA_AC100) += toshiba-ac100/ obj-$(CONFIG_MACH_TQMA53) += tqma53/ diff --git a/arch/arm/boards/at91sam9m10ihd/hw_version.c b/arch/arm/boards/at91sam9m10ihd/hw_version.c index 96fb02d801..cab26b0ac4 100644 --- a/arch/arm/boards/at91sam9m10ihd/hw_version.c +++ b/arch/arm/boards/at91sam9m10ihd/hw_version.c @@ -195,8 +195,8 @@ static void at91sam9m10ihd_devices_detect_one(const char *name) dev_add_param_fixed(dev, "board", info.board_name); sprintf(str, "%.2s", info.vendor_country); dev_add_param_fixed(dev, "country", str); - dev_add_param_int_ro(dev, "year", info.year, "%d"); - dev_add_param_int_ro(dev, "week", info.week, "%d"); + dev_add_param_uint32_fixed(dev, "year", info.year, "%u"); + dev_add_param_uint32_fixed(dev, "week", info.week, "%u"); sprintf(str, "%c", info.revision_code); dev_add_param_fixed(dev, "revision_code", str); sprintf(str, "%c", info.revision_id); diff --git a/arch/arm/boards/at91sam9x5ek/hw_version.c b/arch/arm/boards/at91sam9x5ek/hw_version.c index d1ca036fe9..10563cf98b 100644 --- a/arch/arm/boards/at91sam9x5ek/hw_version.c +++ b/arch/arm/boards/at91sam9x5ek/hw_version.c @@ -221,8 +221,8 @@ static void at91sam9x5ek_devices_detect_one(const char *name) dev_add_param_fixed(dev, "board", info.board_name); sprintf(str, "%.2s", info.vendor_country); dev_add_param_fixed(dev, "country", str); - dev_add_param_int_ro(dev, "year", info.year, "%d"); - dev_add_param_int_ro(dev, "week", info.week, "%d"); + dev_add_param_uint32_fixed(dev, "year", info.year, "%u"); + dev_add_param_uint32_fixed(dev, "week", info.week, "%u"); sprintf(str, "%c", info.revision_code); dev_add_param_fixed(dev, "revision_code", str); sprintf(str, "%c", info.revision_id); diff --git a/arch/arm/boards/beaglebone/board.c b/arch/arm/boards/beaglebone/board.c index 5717c45020..18a9a10a86 100644 --- a/arch/arm/boards/beaglebone/board.c +++ b/arch/arm/boards/beaglebone/board.c @@ -87,7 +87,7 @@ static int beaglebone_devices_init(void) defaultenv_append_directory(defaultenv_beaglebone); - globalvar_add_simple("board.variant", black ? "boneblack" : "bone"); + globalvar_add_simple_string_fixed("board.variant", black ? "boneblack" : "bone"); printf("detected 'BeagleBone %s'\n", black ? "Black" : "White"); diff --git a/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c b/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c index c94cb355e2..d0907c11f0 100644 --- a/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c +++ b/arch/arm/boards/crystalfontz-cfa10036/hwdetect.c @@ -105,7 +105,7 @@ void cfa10036_detect_hw(void) return; } - globalvar_add_simple("board.variant", board_name); + globalvar_add_simple_string_fixed("board.variant", board_name); pr_info("Booting on a CFA10036 with %s\n", board_name); } diff --git a/arch/arm/boards/kindle-mx50/Makefile b/arch/arm/boards/kindle-mx50/Makefile new file mode 100644 index 0000000000..76ad17a1c2 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/Makefile @@ -0,0 +1,4 @@ +obj-y += board.o flash-header-kindle-lpddr1.dcd.o flash-header-kindle-lpddr2.dcd.o +extra-y += flash-header-kindle-lpddr1.dcd.S flash-header-kindle-lpddr1.dcd flash-header-kindle-lpddr2.dcd.S flash-header-kindle-lpddr2.dcd +lwl-y += lowlevel.o +bbenv-y += defaultenv-kindle-mx50 diff --git a/arch/arm/boards/kindle-mx50/board.c b/arch/arm/boards/kindle-mx50/board.c new file mode 100644 index 0000000000..fa4beb7f3c --- /dev/null +++ b/arch/arm/boards/kindle-mx50/board.c @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2007 Sascha Hauer, Pengutronix + * Copyright (C) 2017 Alexander Kurz <akurz@blala.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. + * + */ + +#include <common.h> +#include <envfs.h> +#include <environment.h> +#include <init.h> +#include <io.h> +#include <driver.h> +#include <param.h> +#include <magicvar.h> +#include <partition.h> +#include <libfile.h> +#include <globalvar.h> +#include <asm/armlinux.h> +#include <generated/mach-types.h> +#include <linux/sizes.h> +#include <usb/fsl_usb2.h> +#include <mach/generic.h> +#include <mach/imx50-regs.h> +#include <mach/imx5.h> +#include <mach/revision.h> + +/* 16 byte id for serial number */ +#define ATAG_SERIAL16 0x5441000a +/* 16 byte id for a board revision */ +#define ATAG_REVISION16 0x5441000b + +struct char16_tag { + char data[16]; +}; + +static struct tag *setup_16char_tag(struct tag *params, uint32_t tag, + const char *value) +{ + struct char16_tag *target; + target = ((void *) params) + sizeof(struct tag_header); + params->hdr.tag = tag; + params->hdr.size = tag_size(char16_tag); + memcpy(target->data, value, sizeof target->data); + return tag_next(params); +} + +static const char *get_env_16char_tag(const char *tag) +{ + static const char *default16 = "0000000000000000"; + const char *value; + value = getenv(tag); + if (!value) { + pr_err("env var %s not found, using default\n", tag); + return default16; + } + if (strlen(value) != 16) { + pr_err("env var %s: expecting 16 characters, using default\n", + tag); + return default16; + } + pr_info("%s: %s\n", tag, value); + return value; +} + +BAREBOX_MAGICVAR_NAMED(global_atags_serial16, global.board.serial16, + "Pass the kindle Serial as vendor-specific ATAG to linux"); +BAREBOX_MAGICVAR_NAMED(global_atags_revision16, global.board.revision16, + "Pass the kindle BoardId as vendor-specific ATAG to linux"); + +/* The Kindle Kernel expects two custom ATAGs, ATAG_REVISION16 describing + * the board and ATAG_SERIAL16 to identify the individual device. + */ +struct tag *kindle_mx50_append_atags(struct tag *params) +{ + params = setup_16char_tag(params, ATAG_SERIAL16, + get_env_16char_tag("global.board.serial16")); + params = setup_16char_tag(params, ATAG_REVISION16, + get_env_16char_tag("global.board.revision16")); + return params; +} + +static char *serial16; +static char *revision16; +static char *mac; + +static void kindle_rev_init(void) +{ + int ret; + size_t size; + void *buf; + const char userdata[] = "/dev/disk0.boot0.userdata"; + ret = read_file_2(userdata, &size, &buf, 128); + if (ret && ret != -EFBIG) { + pr_err("Could not read board info from %s\n", userdata); + return; + } + + serial16 = xzalloc(17); + revision16 = xzalloc(17); + mac = xzalloc(17); + + memcpy(serial16, buf, 16); + memcpy(revision16, buf + 96, 16); + memcpy(mac, buf + 48, 16); + + globalvar_add_simple_string("board.serial16", &serial16); + globalvar_add_simple_string("board.revision16", &revision16); + globalvar_add_simple_string("board.mac", &mac); + + free(buf); +} + +static int kindle_mx50_late_init(void) +{ + armlinux_set_revision(0x50000 | imx_silicon_revision()); + /* Compatibility ATAGs for original kernel */ + armlinux_set_atag_appender(kindle_mx50_append_atags); + + kindle_rev_init(); + + return 0; +} +late_initcall(kindle_mx50_late_init); + +static int kindle_mx50_mem_init(void) +{ + arm_add_mem_device("ram0", MX50_CSD0_BASE_ADDR, SZ_256M); + return 0; +} +mem_initcall(kindle_mx50_mem_init); + +static int kindle_mx50_devices_init(void) +{ + struct device_d *dev; + /* Probe the eMMC to allow reading the board serial and revision */ + dev = get_device_by_name("mci0"); + if (dev) + dev_set_param(dev, "probe", "1"); + + defaultenv_append_directory(defaultenv_kindle_mx50); + + return 0; +} +device_initcall(kindle_mx50_devices_init); + +static int kindle_mx50_postcore_init(void) +{ + imx50_init_lowlevel(800); + + return 0; +} +postcore_initcall(kindle_mx50_postcore_init); diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel new file mode 100644 index 0000000000..a43ee0cc92 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/boot/mmc_kernel @@ -0,0 +1,15 @@ +#!/bin/sh +# Boot the Amazon factory-shipped kernel uimage stored on +# the eMMC at CONFIG_MMC_BOOTFLASH_ADDR 0x41000 + +# Purge the OF tree to enable passing of ATAGs +oftree -f + +# The same machine type introduced with freescale ENGR00124359 +armlinux_architecture=2955 + +armlinux_system_serial="$global.board.ocotp_serial" + +global linux.bootargs.dyn.root="root=/dev/mmcblk0p1 rootwait ro" + +bootm -c /dev/disk0.kernel diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/init/usbconsole b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/init/usbconsole new file mode 100644 index 0000000000..4fe12113cc --- /dev/null +++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/init/usbconsole @@ -0,0 +1,21 @@ +#!/bin/sh + +if test "$global.model" = "Amazon Kindle D01100"; then + if gpio_get_value 18; then; else + usbserial + global.autoboot_timeout=60 + fi +fi + +if test "$global.model" = "Amazon Kindle D01200"; then + sleep 5 + if gpio_get_value 0; then + usbserial + global.autoboot_timeout=60 + fi +fi + +if test "$global.model" = "Amazon Kindle EY21"; then + usbserial + global.autoboot_timeout=10 +fi diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/autoboot_timeout b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/autoboot_timeout new file mode 100644 index 0000000000..00750edc07 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/autoboot_timeout @@ -0,0 +1 @@ +3 diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/boot.default b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/boot.default new file mode 100644 index 0000000000..3118b7af45 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/boot.default @@ -0,0 +1 @@ +mmc_kernel diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/linux.bootargs.consoleblank b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/linux.bootargs.consoleblank new file mode 100644 index 0000000000..efc4ee63d4 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/linux.bootargs.consoleblank @@ -0,0 +1 @@ +consoleblank=0 diff --git a/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/linux.bootargs.eink b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/linux.bootargs.eink new file mode 100644 index 0000000000..2ff3618376 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/defaultenv-kindle-mx50/nv/linux.bootargs.eink @@ -0,0 +1 @@ +fslepdc video=mxcepdcfb:E60,bpp=8 diff --git a/arch/arm/boards/kindle-mx50/flash-header-kindle-lpddr1.imxcfg b/arch/arm/boards/kindle-mx50/flash-header-kindle-lpddr1.imxcfg new file mode 100644 index 0000000000..e6b6098973 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/flash-header-kindle-lpddr1.imxcfg @@ -0,0 +1,166 @@ +# DCD i.MX50 SoC setup using 256MiB LPDDR1 +# Copyright (C) 2017 Alexander Kurz <akurz@blala.de> +# +# Initial DCD setup according to Freescale ENGR00124359 +# with adaption for LPDDR1 ENGR00025557 +# Copyright (C) 2010 Freescale Semiconductor, Inc. + +soc imx50 +loadaddr 0x70020000 +dcdofs 0x400 + +# Switch pll1_sw_clk to step_clk +wm 32 0x53fd400c 0x00000004 +# Setup PLL1 to 800MHz +wm 32 0x63f80000 0x00001232 +wm 32 0x63f80004 0x00000002 +wm 32 0x63f80008 0x00000080 +wm 32 0x63f8000c 0x00000002 +wm 32 0x63f80010 0x00000001 +wm 32 0x63f8001c 0x00000080 +wm 32 0x63f80020 0x00000002 +wm 32 0x63f80024 0x00000001 +wm 32 0x63f80000 0x00001232 +check 8 while_any_bit_clear 0x63f80000 0x01 +# Switch pll1_sw_clk to pll1 +wm 32 0x53fd400c 0x00000000 + +# CGR +wm 32 0x53fd4068 0xffffffff +wm 32 0x53fd406c 0xffffffff +wm 32 0x53fd4070 0xffffffff +wm 32 0x53fd4074 0xffffffff +wm 32 0x53fd4078 0xffffffff +wm 32 0x53fd407c 0xffffffff +wm 32 0x53fd4080 0xffffffff +wm 32 0x53fd4084 0xffffffff +wm 32 0x53FD4098 0x80000004 + +# CCM DDR div 4 / 200MHz +wm 32 0x53fd4098 0x80000004 +check 32 while_all_bits_set 0x53fd408c 0x00000004 + +# IOMUX +wm 32 0x53fa8490 0x00180000 +wm 32 0x53fa8494 0x00180000 +wm 32 0x53fa86ac 0x00000000 +wm 32 0x53fa8668 0x00180000 +wm 32 0x53fa866c 0x00000000 +wm 32 0x53fa8670 0x00000000 +wm 32 0x53fa868c 0x00000000 +wm 32 0x53fa8698 0x00180000 +wm 32 0x53fa86a0 0x00180000 +wm 32 0x53fa86a4 0x00180000 +wm 32 0x53fa86a8 0x00180000 +wm 32 0x53fa86b4 0x00180000 + +# set SW_PAD_CTL_GRP_NANDF to Low output voltage +wm 32 0x53fa86c0 0x2000 + +wm 32 0x53fa8498 0x00180200 +wm 32 0x53fa849c 0x00180200 +wm 32 0x53fa84c8 0x00180000 +wm 32 0x53fa84cc 0x00180080 +wm 32 0x53fa84f0 0x00180000 +wm 32 0x53fa84f4 0x00180080 +wm 32 0x53fa84fc 0x00180080 +wm 32 0x53fa8500 0x00180000 +wm 32 0x53fa8524 0x00180080 +wm 32 0x53fa8528 0x00180000 + +# ZQ Load +wm 32 0x1400012C 0x00000817 +wm 32 0x14000128 0x09180000 +wm 32 0x14000124 0x00310000 +wm 32 0x14000124 0x00200000 +wm 32 0x14000128 0x09180010 +wm 32 0x14000124 0x00310000 +wm 32 0x14000124 0x00200000 + +# DRAM_CTL +wm 32 0x14000000 0x00000100 +wm 32 0x14000008 0x00009c40 +wm 32 0x14000014 0x02000000 +wm 32 0x14000018 0x01010006 +wm 32 0x1400001c 0x080b0201 +wm 32 0x14000020 0x02000303 +wm 32 0x14000024 0x0036b002 +wm 32 0x14000028 0x00000606 +wm 32 0x1400002c 0x06030400 +wm 32 0x14000030 0x01000000 +wm 32 0x14000034 0x00000a02 +wm 32 0x14000038 0x00000003 +wm 32 0x1400003c 0x00001801 +wm 32 0x14000040 0x00050612 +wm 32 0x14000044 0x00000200 +wm 32 0x14000048 0x001c001c +wm 32 0x1400004c 0x00010000 +wm 32 0x1400005c 0x01000000 +wm 32 0x14000060 0x00000001 +wm 32 0x14000064 0x00000000 +wm 32 0x14000068 0x00320000 +wm 32 0x1400006c 0x00000000 +wm 32 0x14000070 0x00000000 +wm 32 0x14000074 0x00320000 +wm 32 0x14000080 0x02000000 +wm 32 0x14000084 0x00000100 +wm 32 0x14000088 0x02400040 +wm 32 0x1400008c 0x01000000 +wm 32 0x14000090 0x0a000100 +wm 32 0x14000094 0x01011f1f +wm 32 0x14000098 0x01010101 +wm 32 0x1400009c 0x00030101 +wm 32 0x140000a4 0x00010000 +wm 32 0x140000a8 0x00000000 +wm 32 0x140000ac 0x0000ffff +wm 32 0x140000c8 0x02020101 +wm 32 0x140000cc 0x00000000 +wm 32 0x140000d0 0x01000202 +wm 32 0x140000d4 0x00000200 +wm 32 0x140000d8 0x00000001 +wm 32 0x140000dc 0x0000ffff +wm 32 0x140000e0 0x00000000 +wm 32 0x140000e4 0x02020000 +wm 32 0x140000e8 0x02020202 +wm 32 0x140000ec 0x00000202 +wm 32 0x140000f0 0x01010064 +wm 32 0x140000f4 0x01010101 +wm 32 0x140000f8 0x00010101 +wm 32 0x140000fc 0x00000064 +wm 32 0x14000104 0x02000602 +wm 32 0x14000108 0x06120000 +wm 32 0x1400010c 0x06120612 +wm 32 0x14000110 0x06120612 +wm 32 0x14000114 0x01030612 +wm 32 0x14000118 0x00010002 +wm 32 0x1400011c 0x00001000 + +# DDR PHY +wm 32 0x14000200 0x00000000 +wm 32 0x14000204 0x00000000 +wm 32 0x14000208 0x35002725 +wm 32 0x14000210 0x35002725 +wm 32 0x14000218 0x35002725 +wm 32 0x14000220 0x35002725 +wm 32 0x14000228 0x35002725 +wm 32 0x1400020c 0x380002d0 +wm 32 0x14000214 0x380002d0 +wm 32 0x1400021c 0x380002d0 +wm 32 0x14000224 0x380002d0 +wm 32 0x1400022c 0x380002d0 +wm 32 0x14000230 0x00000000 +wm 32 0x14000234 0x00800006 +wm 32 0x14000238 0x60101414 +wm 32 0x14000240 0x60101414 +wm 32 0x14000248 0x60101414 +wm 32 0x14000250 0x60101414 +wm 32 0x14000258 0x60101414 +wm 32 0x1400023c 0x00101001 +wm 32 0x14000244 0x00101001 +wm 32 0x1400024c 0x00101001 +wm 32 0x14000254 0x00101001 +wm 32 0x1400025c 0x00102201 + +# start DDR +wm 32 0x14000000 0x00000101 +check 32 while_any_bit_clear 0x140000a8 0x00000010 diff --git a/arch/arm/boards/kindle-mx50/flash-header-kindle-lpddr2.imxcfg b/arch/arm/boards/kindle-mx50/flash-header-kindle-lpddr2.imxcfg new file mode 100644 index 0000000000..ffceac34b5 --- /dev/null +++ b/arch/arm/boards/kindle-mx50/flash-header-kindle-lpddr2.imxcfg @@ -0,0 +1,176 @@ +# DCD i.MX50 SoC setup using 256MiB LPDDR2 +# Copyright (C) 2017 Alexander Kurz <akurz@blala.de> +# +# Initial DCD setup according to Freescale ENGR00124359 with adaption from +# Kindle_src_5.6.1.1_2634130033 uboot_2009.08 imx50_yoshi flash_header. +# Copyright (C) 2010 Freescale Semiconductor, Inc. + +soc imx50 +loadaddr 0x70020000 + +dcdofs 0x400 + +# Switch pll1_sw_clk to step_clk +wm 32 0x53fd400c 0x00000004 +# Setup PLL1 to 800MHz +wm 32 0x63f80000 0x00001236 +wm 32 0x63f80004 0x00000002 +wm 32 0x63f80008 0x00000080 +wm 32 0x63f8000c 0x000000b3 +wm 32 0x63f80010 0x000000b4 +wm 32 0x63f8001c 0x00000080 +wm 32 0x63f80020 0x000000b3 +wm 32 0x63f80024 0x000000b4 +wm 32 0x63f80000 0x00001236 +check 8 while_any_bit_clear 0x63f80000 0x01 +# Switch pll1_sw_clk to pll1 +wm 32 0x53fd400c 0x00000000 + +# CGR +wm 32 0x53fd4068 0xffffffff +wm 32 0x53fd406c 0xffffffff +wm 32 0x53fd4070 0xffffffff +wm 32 0x53fd4074 0xffffffff +wm 32 0x53fd4078 0xffffffff +wm 32 0x53fd407c 0xffffffff +wm 32 0x53fd4080 0xffffffff +wm 32 0x53fd4084 0xffffffff +wm 32 0x53FD4098 0x80000004 + +# CCM DDR div 3 / 266MHz +wm 32 0x53fd4098 0x80000003 +check 32 while_all_bits_set 0x53fd408c 0x00000004 + +# IOMUX +wm 32 0x53fa86ac 0x04000000 +wm 32 0x53fa8668 0x00200000 +wm 32 0x53fa866c 0x00000200 +wm 32 0x53fa8670 0x00000000 +wm 32 0x53fa868c 0x00000000 +wm 32 0x53fa8698 0x00200000 +wm 32 0x53fa86a0 0x00200000 +wm 32 0x53fa86a4 0x00200000 +wm 32 0x53fa86a8 0x00200000 +wm 32 0x53fa86b4 0x00200000 + +# set SW_PAD_CTL_GRP_NANDF to Low output voltage +wm 32 0x53fa86c0 0x2000 + +wm 32 0x53fa8490 0x00200000 +wm 32 0x53fa8494 0x00200000 +wm 32 0x53fa8498 0x00200000 +wm 32 0x53fa849c 0x00200000 +wm 32 0x53fa84c8 0x00200000 +wm 32 0x53fa84cc 0x00200000 +wm 32 0x53fa84f0 0x00200000 +wm 32 0x53fa84f4 0x00200000 +wm 32 0x53fa84fc 0x00200000 +wm 32 0x53fa8500 0x00200000 +wm 32 0x53fa8524 0x00200000 +wm 32 0x53fa8528 0x00200000 + +# ZQ Load +wm 32 0x1400012C 0x00000817 +wm 32 0x14000128 0x09180000 +wm 32 0x14000124 0x00310000 +wm 32 0x14000124 0x00200000 +wm 32 0x14000128 0x09180010 +wm 32 0x14000124 0x00310000 +wm 32 0x14000124 0x00200000 + +# DRAM_CTL +wm 32 0x14000000 0x00000500 +wm 32 0x14000008 0x0000001b +wm 32 0x1400000c 0x0000d056 +wm 32 0x14000010 0x0000010b +wm 32 0x14000014 0x00000a6b +wm 32 0x14000018 0x02020d0c +wm 32 0x1400001c 0x0c110302 +wm 32 0x14000020 0x05020503 +wm 32 0x14000024 0x0048eb05 +wm 32 0x14000028 0x00000606 +wm 32 0x1400002c 0x09040501 +wm 32 0x14000030 0x02000000 +wm 32 0x14000034 0x00000e02 +wm 32 0x14000038 0x00000006 +wm 32 0x1400003c 0x00002301 +wm 32 0x14000040 0x00050408 +wm 32 0x14000044 0x00000300 +wm 32 0x14000048 0x00260026 +wm 32 0x1400004c 0x00010000 +wm 32 0x14000050 0x00000000 +wm 32 0x14000054 0x00000000 +wm 32 0x14000058 0x00000000 +wm 32 0x1400005c 0x02000000 +wm 32 0x14000060 0x00000002 +wm 32 0x14000064 0x00000000 +wm 32 0x14000068 0x00000000 +wm 32 0x1400006c 0x00040042 +wm 32 0x14000070 0x00000001 +wm 32 0x14000074 0x00000000 +wm 32 0x14000078 0x00040042 +wm 32 0x1400007c 0x00000001 +wm 32 0x14000080 0x010b0000 +wm 32 0x14000084 0x00000060 +wm 32 0x14000088 0x02400018 +wm 32 0x1400008c 0x01000e00 +wm 32 0x14000090 0x0a010101 +wm 32 0x14000094 0x01011f1f +wm 32 0x14000098 0x01010101 +wm 32 0x1400009c 0x00030101 +wm 32 0x140000a0 0x00010000 +wm 32 0x140000a4 0x00010000 +wm 32 0x140000a8 0x00000000 +wm 32 0x140000ac 0x0000ffff +wm 32 0x140000c8 0x02020101 +wm 32 0x140000cc 0x01000000 +wm 32 0x140000d0 0x01000201 +wm 32 0x140000d4 0x00000200 +wm 32 0x140000d8 0x00000102 +wm 32 0x140000dc 0x0000ffff +wm 32 0x140000e0 0x0000ff00 +wm 32 0x140000e4 0x02020000 +wm 32 0x140000e8 0x02020202 +wm 32 0x140000ec 0x00000202 +wm 32 0x140000f0 0x01010064 +wm 32 0x140000f4 0x01010101 +wm 32 0x140000f8 0x00010101 +wm 32 0x140000fc 0x00000064 +wm 32 0x14000100 0x00000000 +wm 32 0x14000104 0x02000802 +wm 32 0x14000108 0x04080000 +wm 32 0x1400010c 0x04080408 +wm 32 0x14000110 0x04080408 +wm 32 0x14000114 0x03060408 +wm 32 0x14000118 0x00010002 +wm 32 0x1400011c 0x00001000 + +# DDR PHY +wm 32 0x14000200 0x00000000 +wm 32 0x14000204 0x00000000 +wm 32 0x14000208 0x35003a27 +wm 32 0x14000210 0x35003a27 +wm 32 0x14000218 0x35003a27 +wm 32 0x14000220 0x35003a27 +wm 32 0x14000228 0x35003a27 +wm 32 0x1400020c 0x380002e1 +wm 32 0x14000214 0x380002e1 +wm 32 0x1400021c 0x380002e1 +wm 32 0x14000224 0x380002e1 +wm 32 0x1400022c 0x380002e1 +wm 32 0x14000230 0x00000000 +wm 32 0x14000234 0x00810006 +wm 32 0x14000238 0x60101014 +wm 32 0x14000240 0x60101014 +wm 32 0x14000248 0x60101014 +wm 32 0x14000250 0x60101014 +wm 32 0x14000258 0x60101014 +wm 32 0x1400023c 0x00100b01 +wm 32 0x14000244 0x00100b01 +wm 32 0x1400024c 0x00100b01 +wm 32 0x14000254 0x00100b01 +wm 32 0x1400025c 0x00100b01 + +# start DDR +wm 32 0x14000000 0x00000501 +check 32 while_any_bit_clear 0x140000a8 0x00000010 diff --git a/arch/arm/boards/kindle-mx50/lowlevel.c b/arch/arm/boards/kindle-mx50/lowlevel.c new file mode 100644 index 0000000000..dc321b533b --- /dev/null +++ b/arch/arm/boards/kindle-mx50/lowlevel.c @@ -0,0 +1,50 @@ +#include <common.h> +#include <linux/sizes.h> +#include <io.h> +#include <asm/barebox-arm-head.h> +#include <asm/barebox-arm.h> +#include <asm/sections.h> +#include <asm/cache.h> +#include <asm/mmu.h> +#include <mach/imx50-regs.h> +#include <mach/generic.h> + +extern char __dtb_imx50_kindle_d01100_start[]; +extern char __dtb_imx50_kindle_d01200_start[]; +extern char __dtb_imx50_kindle_ey21_start[]; + +ENTRY_FUNCTION(start_imx50_kindle_d01100, r0, r1, r2) +{ + void *fdt; + + imx5_cpu_lowlevel_init(); + arm_setup_stack(MX50_IRAM_BASE_ADDR + MX50_IRAM_SIZE - 8); + + fdt = __dtb_imx50_kindle_d01100_start - get_runtime_offset(); + + barebox_arm_entry(MX50_CSD0_BASE_ADDR, SZ_256M, fdt); +} + +ENTRY_FUNCTION(start_imx50_kindle_d01200, r0, r1, r2) +{ + void *fdt; + + imx5_cpu_lowlevel_init(); + arm_setup_stack(MX50_IRAM_BASE_ADDR + MX50_IRAM_SIZE - 8); + + fdt = __dtb_imx50_kindle_d01200_start - get_runtime_offset(); + + barebox_arm_entry(MX50_CSD0_BASE_ADDR, SZ_256M, fdt); +} + +ENTRY_FUNCTION(start_imx50_kindle_ey21, r0, r1, r2) +{ + void *fdt; + + imx5_cpu_lowlevel_init(); + arm_setup_stack(MX50_IRAM_BASE_ADDR + MX50_IRAM_SIZE - 8); + + fdt = __dtb_imx50_kindle_ey21_start - get_runtime_offset(); + + barebox_arm_entry(MX50_CSD0_BASE_ADDR, SZ_256M, fdt); +} diff --git a/arch/arm/boards/phytec-som-am335x/board.c b/arch/arm/boards/phytec-som-am335x/board.c index 7f62453d93..dc3b84a806 100644 --- a/arch/arm/boards/phytec-som-am335x/board.c +++ b/arch/arm/boards/phytec-som-am335x/board.c @@ -112,6 +112,7 @@ static int physom_devices_init(void) xloadslots, ARRAY_SIZE(xloadslots)); am33xx_bbu_nand_slots_register_handler("nand", nandslots, ARRAY_SIZE(nandslots)); + am33xx_bbu_emmc_mlo_register_handler("MLO.emmc", "/dev/mmc1"); if (IS_ENABLED(CONFIG_SHELL_NONE)) return am33xx_of_register_bootdevice(); diff --git a/arch/arm/boards/phytec-som-imx6/board.c b/arch/arm/boards/phytec-som-imx6/board.c index ed9453bdda..31b2761024 100644 --- a/arch/arm/boards/phytec-som-imx6/board.c +++ b/arch/arm/boards/phytec-som-imx6/board.c @@ -152,7 +152,7 @@ static int physom_imx6_devices_init(void) phyflex_err006282_workaround(); pfla02_module_revision = get_module_rev(); - globalvar_add_simple_int("board.revision", &pfla02_module_revision, "%u"); + globalvar_add_simple_uint32_fixed("board.revision", pfla02_module_revision, "%u"); pr_info("Module Revision: %u\n", pfla02_module_revision); barebox_set_hostname("phyFLEX-i.MX6"); diff --git a/arch/arm/boards/sama5d3xek/hw_version.c b/arch/arm/boards/sama5d3xek/hw_version.c index c809c37742..e5077854e3 100644 --- a/arch/arm/boards/sama5d3xek/hw_version.c +++ b/arch/arm/boards/sama5d3xek/hw_version.c @@ -227,8 +227,8 @@ static void at91sama5d3xek_devices_detect_one(const char *name) dev_add_param_fixed(dev, "board", bname); sprintf(str, "%.2s", info.vendor_country); dev_add_param_fixed(dev, "country", str); - dev_add_param_int_ro(dev, "year", info.year, "%d"); - dev_add_param_int_ro(dev, "week", info.week, "%d"); + dev_add_param_uint32_fixed(dev, "year", info.year, "%u"); + dev_add_param_uint32_fixed(dev, "week", info.week, "%u"); sprintf(str, "%c", info.revision_board); dev_add_param_fixed(dev, "revision_board", str); sprintf(str, "%c", info.revision_schema); diff --git a/arch/arm/boards/solidrun-microsom/board.c b/arch/arm/boards/solidrun-microsom/board.c index b9041687e4..155199ff78 100644 --- a/arch/arm/boards/solidrun-microsom/board.c +++ b/arch/arm/boards/solidrun-microsom/board.c @@ -78,7 +78,9 @@ static void microsom_eth_init(void) static int hummingboard_device_init(void) { if (!of_machine_is_compatible("solidrun,hummingboard/dl") && - !of_machine_is_compatible("solidrun,hummingboard/q")) + !of_machine_is_compatible("solidrun,hummingboard/q") && + !of_machine_is_compatible("solidrun,hummingboard2/dl") && + !of_machine_is_compatible("solidrun,hummingboard2/q")) return 0; microsom_eth_init(); @@ -108,13 +110,26 @@ device_initcall(h100_device_init); static int hummingboard_late_init(void) { + bool emmc_present = false; + if (!of_machine_is_compatible("solidrun,hummingboard/dl") && !of_machine_is_compatible("solidrun,hummingboard/q") && + !of_machine_is_compatible("solidrun,hummingboard2/dl") && + !of_machine_is_compatible("solidrun,hummingboard2/q") && !of_machine_is_compatible("auvidea,h100")) return 0; + if (of_machine_is_compatible("solidrun,hummingboard2/dl") || + of_machine_is_compatible("solidrun,hummingboard2/q")) + emmc_present = true; + imx6_bbu_internal_mmc_register_handler("sdcard", "/dev/mmc1.barebox", - BBU_HANDLER_FLAG_DEFAULT); + emmc_present ? 0 : BBU_HANDLER_FLAG_DEFAULT); + + if (emmc_present) { + imx6_bbu_internal_mmc_register_handler("emmc", + "/dev/mmc2.barebox", BBU_HANDLER_FLAG_DEFAULT); + } return 0; } diff --git a/arch/arm/boards/solidrun-microsom/lowlevel.c b/arch/arm/boards/solidrun-microsom/lowlevel.c index 7b97f2e947..cc15958d64 100644 --- a/arch/arm/boards/solidrun-microsom/lowlevel.c +++ b/arch/arm/boards/solidrun-microsom/lowlevel.c @@ -5,6 +5,8 @@ extern char __dtb_imx6dl_hummingboard_start[]; extern char __dtb_imx6q_hummingboard_start[]; +extern char __dtb_imx6dl_hummingboard2_start[]; +extern char __dtb_imx6q_hummingboard2_start[]; extern char __dtb_imx6q_h100_start[]; ENTRY_FUNCTION(start_hummingboard_microsom_i1, r0, r1, r2) @@ -47,6 +49,46 @@ ENTRY_FUNCTION(start_hummingboard_microsom_i4, r0, r1, r2) imx6q_barebox_entry(fdt); } +ENTRY_FUNCTION(start_hummingboard2_microsom_i1, r0, r1, r2) +{ + void *fdt; + + imx6_cpu_lowlevel_init(); + + fdt = __dtb_imx6dl_hummingboard2_start - get_runtime_offset(); + imx6q_barebox_entry(fdt); +} + +ENTRY_FUNCTION(start_hummingboard2_microsom_i2, r0, r1, r2) +{ + void *fdt; + + imx6_cpu_lowlevel_init(); + + fdt = __dtb_imx6dl_hummingboard2_start - get_runtime_offset(); + imx6q_barebox_entry(fdt); +} + +ENTRY_FUNCTION(start_hummingboard2_microsom_i2ex, r0, r1, r2) +{ + void *fdt; + + imx6_cpu_lowlevel_init(); + + fdt = __dtb_imx6q_hummingboard2_start - get_runtime_offset(); + imx6q_barebox_entry(fdt); +} + +ENTRY_FUNCTION(start_hummingboard2_microsom_i4, r0, r1, r2) +{ + void *fdt; + + imx6_cpu_lowlevel_init(); + + fdt = __dtb_imx6q_hummingboard2_start - get_runtime_offset(); + imx6q_barebox_entry(fdt); +} + ENTRY_FUNCTION(start_h100_microsom_i2ex, r0, r1, r2) { void *fdt; diff --git a/arch/arm/boards/vscom-baltos/board.c b/arch/arm/boards/vscom-baltos/board.c index 39f40a6061..1a4dc30936 100644 --- a/arch/arm/boards/vscom-baltos/board.c +++ b/arch/arm/boards/vscom-baltos/board.c @@ -64,7 +64,7 @@ static int baltos_read_eeprom(void) { struct bsp_vs_hwparam hw_param; size_t size; - char *buf, var_buf[32]; + char *buf; int rc; unsigned char mac_addr[6]; @@ -107,8 +107,7 @@ static int baltos_read_eeprom(void) hw_param.SystemId = 0; } - sprintf(var_buf, "%d", hw_param.SystemId); - globalvar_add_simple("board.id", var_buf); + globalvar_add_simple_uint32_fixed("board.id", hw_param.SystemId, "%u"); /* enable mPCIe slot */ gpio_direction_output(100, 1); @@ -131,7 +130,7 @@ static int baltos_devices_init(void) if (!of_machine_is_compatible("vscom,onrisc")) return 0; - globalvar_add_simple("board.variant", "baltos"); + globalvar_add_simple_string_fixed("board.variant", "baltos"); if (bootsource_get() == BOOTSOURCE_MMC) omap_set_bootmmc_devname("mmc0"); diff --git a/arch/arm/configs/imx_v7_defconfig b/arch/arm/configs/imx_v7_defconfig index df67cd0a92..ab837cc55f 100644 --- a/arch/arm/configs/imx_v7_defconfig +++ b/arch/arm/configs/imx_v7_defconfig @@ -1,6 +1,7 @@ CONFIG_ARCH_IMX=y CONFIG_IMX_MULTI_BOARDS=y CONFIG_MACH_EFIKA_MX_SMARTBOOK=y +CONFIG_MACH_KINDLE_MX50=y CONFIG_MACH_EMBEDSKY_E9=y CONFIG_MACH_FREESCALE_MX51_PDK=y CONFIG_MACH_CCMX53=y diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig index dab3d7a45e..cfbccb5a14 100644 --- a/arch/arm/configs/mvebu_defconfig +++ b/arch/arm/configs/mvebu_defconfig @@ -112,6 +112,7 @@ CONFIG_USB_STORAGE=y CONFIG_MCI=y CONFIG_MCI_STARTUP=y CONFIG_MCI_MMC_BOOT_PARTITIONS=y +CONFIG_MCI_DOVE=y CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_LED_GPIO_OF=y diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index 96e54d815f..2342d35a4b 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -12,6 +12,7 @@ pbl-dtb-$(CONFIG_MACH_BEAGLEBONE) += am335x-bone.dtb.o am335x-boneblack.dtb.o am pbl-dtb-$(CONFIG_MACH_CM_FX6) += imx6dl-cm-fx6.dtb.o imx6q-cm-fx6.dtb.o imx6q-utilite.dtb.o pbl-dtb-$(CONFIG_MACH_DFI_FS700_M60) += imx6q-dfi-fs700-m60-6q.dtb.o imx6dl-dfi-fs700-m60-6s.dtb.o pbl-dtb-$(CONFIG_MACH_DUCKBILL) += imx28-duckbill.dtb.o +pbl-dtb-$(CONFIG_MACH_KINDLE_MX50) += imx50-kindle-d01100.dtb.o imx50-kindle-d01200.dtb.o imx50-kindle-ey21.dtb.o pbl-dtb-$(CONFIG_MACH_EFIKA_MX_SMARTBOOK) += imx51-genesi-efika-sb.dtb.o pbl-dtb-$(CONFIG_MACH_ELTEC_HIPERCAM) += imx6dl-eltec-hipercam.dtb.o pbl-dtb-$(CONFIG_MACH_EMBEST_RIOTBOARD) += imx6s-riotboard.dtb.o @@ -69,7 +70,9 @@ pbl-dtb-$(CONFIG_MACH_SOCFPGA_REFLEX_ACHILLES) += socfpga_arria10_achilles.dtb.o pbl-dtb-$(CONFIG_MACH_SOCFPGA_TERASIC_DE0_NANO_SOC) += socfpga_cyclone5_de0_nano_soc.dtb.o pbl-dtb-$(CONFIG_MACH_SOCFPGA_TERASIC_SOCKIT) += socfpga_cyclone5_sockit.dtb.o pbl-dtb-$(CONFIG_MACH_SOLIDRUN_CUBOX) += dove-cubox-bb.dtb.o -pbl-dtb-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += imx6dl-hummingboard.dtb.o imx6q-hummingboard.dtb.o imx6q-h100.dtb.o +pbl-dtb-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += imx6dl-hummingboard.dtb.o imx6q-hummingboard.dtb.o \ + imx6dl-hummingboard2.dtb.o imx6q-hummingboard2.dtb.o \ + imx6q-h100.dtb.o pbl-dtb-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += imx6q-wandboard.dtb.o imx6dl-wandboard.dtb.o pbl-dtb-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += tegra20-colibri-iris.dtb.o pbl-dtb-$(CONFIG_MACH_TOSHIBA_AC100) += tegra20-paz00.dtb.o diff --git a/arch/arm/dts/imx50-kindle-common.dtsi b/arch/arm/dts/imx50-kindle-common.dtsi new file mode 100644 index 0000000000..a6ea504f6c --- /dev/null +++ b/arch/arm/dts/imx50-kindle-common.dtsi @@ -0,0 +1,322 @@ +/* + * Copyright 2017 Alexander Kurz <akurz@blala.de> + * Copyright 2013 Greg Ungerer <gerg@uclinux.org> + * Copyright 2011 Freescale Semiconductor, Inc. + * Copyright 2011 Linaro Ltd. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include "imx50.dtsi" +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/input/input.h> + +/ { + /* this is a dummy fixed-voltage "regulator", mainly to satisfy + * the esdhc implementation requiring vmmc-supply and vqmmc-supply + */ + regulators { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <0>; + + reg_3p3v: regulator@0 { + compatible = "regulator-fixed"; + reg = <0>; + regulator-name = "3P3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + }; +}; + +&iomuxc { + imx50-kindle { + pinctrl_uart1: uart1grp { + fsl,pins = < + MX50_PAD_UART1_TXD__UART1_TXD_MUX 0xe4 + MX50_PAD_UART1_RXD__UART1_RXD_MUX 0xe4 + >; + }; + + pinctrl_ecspi2: ecspi2grp { + fsl,pins = < + MX50_PAD_ECSPI2_SCLK__ECSPI2_SCLK 0x84 + MX50_PAD_ECSPI2_MOSI__ECSPI2_MOSI 0x84 + MX50_PAD_ECSPI2_MISO__ECSPI2_MISO 0x84 + MX50_PAD_ECSPI2_SS0__GPIO4_19 0x84 + >; + }; + + pinctrl_cspi: cspigrp { + fsl,pins = < + MX50_PAD_CSPI_SCLK__CSPI_SCLK 0xc4 + MX50_PAD_CSPI_MISO__CSPI_MISO 0xc4 + MX50_PAD_CSPI_MOSI__CSPI_MOSI 0xc4 + MX50_PAD_CSPI_SS0__GPIO4_11 0xe4 + >; + }; + + pinctrl_pmic: pmicgrp { + fsl,pins = < + MX50_PAD_UART1_CTS__GPIO6_8 0x84 + MX50_PAD_EPDC_PWRCTRL0__GPIO3_29 0x84 + >; + }; + + pinctrl_esdhc3: esdhc3grp { + fsl,pins = < + MX50_PAD_SD3_CMD__ESDHC3_CMD 0xd4 + MX50_PAD_SD3_CLK__ESDHC3_CLK 0x00 + MX50_PAD_SD3_D0__ESDHC3_DAT0 0xd4 + MX50_PAD_SD3_D1__ESDHC3_DAT1 0xd4 + MX50_PAD_SD3_D2__ESDHC3_DAT2 0xd4 + MX50_PAD_SD3_D3__ESDHC3_DAT3 0xd4 + MX50_PAD_SD3_D4__ESDHC3_DAT4 0xd4 + MX50_PAD_SD3_D5__ESDHC3_DAT5 0xd4 + MX50_PAD_SD3_D6__ESDHC3_DAT6 0xd4 + MX50_PAD_SD3_D7__ESDHC3_DAT7 0xd4 + >; + }; + + pinctrl_esdhc2: esdhc2grp { + fsl,pins = < + MX50_PAD_SD2_CMD__ESDHC2_CMD 0x84 + MX50_PAD_SD2_CLK__ESDHC2_CLK 0x84 + MX50_PAD_SD2_D0__ESDHC2_DAT0 0x84 + MX50_PAD_SD2_D1__ESDHC2_DAT1 0x84 + MX50_PAD_SD2_D2__ESDHC2_DAT2 0x84 + MX50_PAD_SD2_D3__ESDHC2_DAT3 0x84 + + MX50_PAD_EIM_DA5__GPIO1_5 0xe4 /* wake-on-lan */ + MX50_PAD_SD3_WP__GPIO5_28 0x84 /* power */ + MX50_PAD_DISP_RS__GPIO2_17 0xe4 /* ? */ + >; + }; + + pinctrl_i2c1: i2c1grp { + fsl,pins = < + MX50_PAD_I2C1_SCL__I2C1_SCL 0x4000002c + MX50_PAD_I2C1_SDA__I2C1_SDA 0x4000002c + >; + }; + + pinctrl_i2c2: i2c2grp { + fsl,pins = < + MX50_PAD_I2C2_SCL__I2C2_SCL 0x4000002c + MX50_PAD_I2C2_SDA__I2C2_SDA 0x4000002c + >; + }; + + pinctrl_i2c3: i2c3grp { + fsl,pins = < + MX50_PAD_I2C3_SCL__I2C3_SCL 0x4000002c + MX50_PAD_I2C3_SDA__I2C3_SDA 0x4000002c + >; + }; + + pinctrl_charger_detect: chargerdetectgrp { + fsl,pins = < + MX50_PAD_OWIRE__GPIO6_26 0x84 + >; + }; + }; +}; + +&uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_uart1>; + status = "okay"; +}; + +&esdhc3 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_esdhc3>; + non-removable; + vmmc-supply = <®_3p3v>; + vqmmc-supply = <®_3p3v>; + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + kernel: kernel@0x41000 { + label = "kernel"; + reg = <0x41000 0xe00000>; + }; + + diags_kernel: diags_kernel@0xe41000 { + label = "diags_kernel"; + reg = <0xe41000 0xe00000>; + }; + }; + + boot0-partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + imx_header: imx_header@0x400 { + label = "imx_header"; + reg = <0x400 0x800>; + }; + + self: self@0x1000 { + label = "self"; + reg = <0x1000 0x3e000>; + }; + + userdata: userdata@0x3f000 { + label = "userdata"; + reg = <0x3f000 0x1400>; + }; + }; +}; + +&ecspi2 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_ecspi2>; + fsl,spi-num-chipselects = <1>; + cs-gpios = <&gpio4 19 0>; + status = "okay"; + + flash: m25p80@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "jedec,spi-nor"; + spi-max-frequency = <1000000>; + reg = <0>; + }; +}; + +&cspi { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_cspi>; + fsl,spi-num-chipselects = <1>; + cs-gpios = <&gpio4 11 0>; + status = "okay"; + + pmic: mc13892@0 { + compatible = "fsl,mc13892"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_pmic>; + spi-max-frequency = <1000000>; + spi-cs-high; + reg = <0>; + interrupt-parent = <&gpio6>; + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; + fsl,mc13xxx-uses-rtc; + + regulators { + sw1_reg: sw1 { + regulator-min-microvolt = <600000>; + regulator-max-microvolt = <1375000>; + regulator-boot-on; + regulator-always-on; + }; + + sw2_reg: sw2 { + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <1850000>; + regulator-boot-on; + regulator-always-on; + }; + + sw3_reg: sw3 { + regulator-min-microvolt = <900000>; + regulator-max-microvolt = <1850000>; + regulator-boot-on; + regulator-always-on; + }; + + sw4_reg: sw4 { + regulator-min-microvolt = <1100000>; + regulator-max-microvolt = <1850000>; + regulator-boot-on; + regulator-always-on; + }; + + vdig_reg: vdig { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <1200000>; + regulator-boot-on; + }; + + vpll_reg: vpll { + regulator-min-microvolt = <1050000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + vusb2_reg: vusb2 { + regulator-min-microvolt = <2400000>; + regulator-max-microvolt = <2775000>; + regulator-boot-on; + regulator-always-on; + }; + + vvideo_reg: vvideo { + regulator-min-microvolt = <2775000>; + regulator-max-microvolt = <2775000>; + }; + + vaudio_reg: vaudio { + regulator-min-microvolt = <2300000>; + regulator-max-microvolt = <3000000>; + }; + + vsd_reg: vsd { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3150000>; + }; + + vcam_reg: vcam { + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3000000>; + }; + + vgen1_reg: vgen1 { + regulator-min-microvolt = <3000000>; + regulator-max-microvolt = <3000000>; + }; + + vgen2_reg: vgen2 { + regulator-min-microvolt = <1200000>; + regulator-max-microvolt = <3150000>; + regulator-always-on; + }; + + vgen3_reg: vgen3 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + }; + }; + + leds { + #address-cells = <1>; + #size-cells = <0>; + led-control = <0 0xff8 0 0>; + ledg { + reg = <2>; + label = "pmic_ledsg"; + linux,default-trigger = "heartbeat"; + }; + }; + }; +}; + +&usbotg { + phy_type = "utmi"; + dr_mode = "peripheral"; + status = "okay"; +}; diff --git a/arch/arm/dts/imx50-kindle-d01100.dts b/arch/arm/dts/imx50-kindle-d01100.dts new file mode 100644 index 0000000000..edbc929120 --- /dev/null +++ b/arch/arm/dts/imx50-kindle-d01100.dts @@ -0,0 +1,71 @@ +/* + * Copyright 2017 Alexander Kurz <akurz@blala.de> + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +/dts-v1/; +#include "imx50-kindle-common.dtsi" +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/input/input.h> + +/ { + model = "Amazon Kindle D01100"; + compatible = "fsl,imx50"; + + chosen { + linux,stdout-path = &uart1; + }; + + memory { + device_type = "memory"; + reg = <0x70000000 0x10000000>; + }; +}; + +&iomuxc { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hog>; + + imx50-kindle-d01100 { + pinctrl_hog: hoggrp { + fsl,pins = < + MX50_PAD_EIM_EB1__GPIO1_20 0xc0 + MX50_PAD_EIM_EB0__GPIO1_19 0xc0 + MX50_PAD_EIM_CS2__GPIO1_16 0xc0 + MX50_PAD_EIM_CS1__GPIO1_17 0xc0 + MX50_PAD_EIM_CS0__GPIO1_18 0xc0 + MX50_PAD_SSI_RXC__GPIO6_5 0x84 + >; + }; + }; +}; + +&i2c2 { + clock-frequency = <50000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c2>; + status = "okay"; + + max14656@35 { + compatible = "maxim,max14656"; + reg = <0x35>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_charger_detect>; + interrupt-parent = <&gpio6>; + interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; + }; + + smart-battery@55 { + compatible = "ti,bq27210"; + reg = <0x55>; + ti,i2c-retry-count = <2>; + ti,poll-retry-count = <10>; + }; +}; diff --git a/arch/arm/dts/imx50-kindle-d01200.dts b/arch/arm/dts/imx50-kindle-d01200.dts new file mode 100644 index 0000000000..8f93c1b520 --- /dev/null +++ b/arch/arm/dts/imx50-kindle-d01200.dts @@ -0,0 +1,86 @@ +/* + * Copyright 2017 Alexander Kurz <akurz@blala.de> + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +/dts-v1/; +#include "imx50-kindle-common.dtsi" +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/input/input.h> + +/ { + model = "Amazon Kindle D01200"; + compatible = "fsl,imx50"; + + chosen { + linux,stdout-path = &uart1; + }; + + memory { + device_type = "memory"; + reg = <0x70000000 0x10000000>; + }; +}; + +&iomuxc { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hog>; + + imx50-kindle-d01200 { + pinctrl_hog: hoggrp { + fsl,pins = < + MX50_PAD_EIM_DA0__GPIO1_0 0xc0 + MX50_PAD_SSI_RXC__GPIO6_5 0x84 + >; + }; + }; +}; + +&i2c1 { + clock-frequency = <50000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c1>; + status = "okay"; + + mma8453: mma8453@1c { + compatible = "fsl,mma8453"; + reg = <0x1c>; + }; +}; + +&i2c2 { + clock-frequency = <50000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c2>; + status = "okay"; + + max14656@35 { + compatible = "maxim,max14656"; + reg = <0x35>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_charger_detect>; + interrupt-parent = <&gpio6>; + interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; + }; + + smart-battery@55 { + compatible = "ti,bq27210"; + reg = <0x55>; + ti,i2c-retry-count = <2>; + ti,poll-retry-count = <10>; + }; +}; + +&i2c3 { + clock-frequency = <50000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c3>; + status = "okay"; +}; diff --git a/arch/arm/dts/imx50-kindle-ey21.dts b/arch/arm/dts/imx50-kindle-ey21.dts new file mode 100644 index 0000000000..1b8f2ad89a --- /dev/null +++ b/arch/arm/dts/imx50-kindle-ey21.dts @@ -0,0 +1,66 @@ +/* + * Copyright 2017 Alexander Kurz <akurz@blala.de> + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +/dts-v1/; +#include "imx50-kindle-common.dtsi" +#include <dt-bindings/interrupt-controller/irq.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/input/input.h> + +/ { + model = "Amazon Kindle EY21"; + compatible = "fsl,imx50"; + + memory { + device_type = "memory"; + reg = <0x70000000 0x10000000>; + }; +}; + +&iomuxc { + imx50-kindle-ey21 { + pinctrl_gpiokey: gpiokeygrp { + fsl,pins = < + MX50_PAD_EIM_EB1__GPIO1_20 0x40 + >; + }; + }; +}; + +&i2c2 { + clock-frequency = <50000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c2>; + status = "okay"; + + max14656@35 { + compatible = "maxim,max14656"; + reg = <0x35>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_charger_detect>; + interrupt-parent = <&gpio6>; + interrupts = <26 IRQ_TYPE_LEVEL_HIGH>; + }; + + smart-battery@55 { + compatible = "ti,bq27210"; + reg = <0x55>; + ti,i2c-retry-count = <2>; + ti,poll-retry-count = <10>; + }; +}; + +&i2c3 { + clock-frequency = <50000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c3>; + status = "okay"; +}; diff --git a/arch/arm/dts/imx50.dtsi b/arch/arm/dts/imx50.dtsi new file mode 100644 index 0000000000..8737d4f33f --- /dev/null +++ b/arch/arm/dts/imx50.dtsi @@ -0,0 +1,40 @@ +#include <arm/imx50.dtsi> + +/ { + soc { + aips@50000000 { /* AIPS1 */ + usbphy0: usbphy@0 { + compatible = "usb-nop-xceiv"; + clocks = <&clks IMX5_CLK_USB_PHY1_GATE>; + clock-names = "main_clk"; + status = "okay"; + }; + + usbphy1: usbphy@1 { + compatible = "usb-nop-xceiv"; + clocks = <&clks IMX5_CLK_USB_PHY2_GATE>; + clock-names = "main_clk"; + status = "okay"; + }; + + usbmisc: usbmisc@53f80800 { + #index-cells = <1>; + compatible = "fsl,imx53-usbmisc"; + reg = <0x53f80800 0x200>; + clocks = <&clks IMX5_CLK_USBOH3_GATE>; + }; + }; + }; +}; + +&usbotg { + clocks = <&clks IMX5_CLK_USBOH3_GATE>; + fsl,usbmisc = <&usbmisc 0>; + fsl,usbphy = <&usbphy0>; +}; + +&usbh1 { + clocks = <&clks IMX5_CLK_USBOH3_GATE>; + fsl,usbmisc = <&usbmisc 0>; + fsl,usbphy = <&usbphy0>; +}; diff --git a/arch/arm/dts/imx6dl-hummingboard2.dts b/arch/arm/dts/imx6dl-hummingboard2.dts new file mode 100644 index 0000000000..40ef174411 --- /dev/null +++ b/arch/arm/dts/imx6dl-hummingboard2.dts @@ -0,0 +1,71 @@ +/* + * Device Tree file for SolidRun HummingBoard2 + * Copyright (C) 2015 Rabeeh Khoury <rabeeh@solid-run.com> + * Based on work by Russell King + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License. + * + * This file is distributed in the hope that it will be useful + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Or, alternatively + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +/dts-v1/; + +#include <arm/imx6dl.dtsi> +#include "imx6qdl-hummingboard2.dtsi" + +/ { + model = "SolidRun HummingBoard2 Solo/DualLite"; + compatible = "solidrun,hummingboard2/dl", "fsl,imx6dl"; +}; + +&ocotp { + barebox,provide-mac-address = <&fec 0x620>; +}; + +&usdhc3 { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "barebox"; + reg = <0x0 0xe0000>; + }; + + partition@e0000 { + label = "barebox-environment"; + reg = <0xe0000 0x20000>; + }; +}; diff --git a/arch/arm/dts/imx6q-hummingboard2.dts b/arch/arm/dts/imx6q-hummingboard2.dts new file mode 100644 index 0000000000..89065581b8 --- /dev/null +++ b/arch/arm/dts/imx6q-hummingboard2.dts @@ -0,0 +1,87 @@ +/* + * Device Tree file for SolidRun HummingBoard2 + * Copyright (C) 2015 Rabeeh Khoury <rabeeh@solid-run.com> + * Based on work by Russell King + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License. + * + * This file is distributed in the hope that it will be useful + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Or, alternatively + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +/dts-v1/; + +#include <arm/imx6q.dtsi> +#include "imx6qdl-hummingboard2.dtsi" +#include "imx6q.dtsi" + +/ { + model = "SolidRun HummingBoard2 Dual/Quad"; + compatible = "solidrun,hummingboard2/q", "fsl,imx6q"; + + chosen { + environment@0 { + compatible = "barebox,environment"; + device-path = &usdhc3, "partname:barebox-environment"; + }; + }; +}; + +&sata { + status = "okay"; + fsl,transmit-level-mV = <1104>; + fsl,transmit-boost-mdB = <0>; + fsl,transmit-atten-16ths = <9>; + fsl,no-spread-spectrum; +}; + +&ocotp { + barebox,provide-mac-address = <&fec 0x620>; +}; + +&usdhc3 { + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "barebox"; + reg = <0x0 0xe0000>; + }; + + partition@e0000 { + label = "barebox-environment"; + reg = <0xe0000 0x20000>; + }; +}; diff --git a/arch/arm/dts/imx6qdl-hummingboard2.dtsi b/arch/arm/dts/imx6qdl-hummingboard2.dtsi new file mode 100644 index 0000000000..2a5f389378 --- /dev/null +++ b/arch/arm/dts/imx6qdl-hummingboard2.dtsi @@ -0,0 +1,536 @@ +/* + * Device Tree file for SolidRun HummingBoard2 + * Copyright (C) 2015 Rabeeh Khoury <rabeeh@solid-run.com> + * + * This file is dual-licensed: you can use it either under the terms + * of the GPL or the X11 license, at your option. Note that this dual + * licensing only applies to this file, and not this project as a + * whole. + * + * a) This file is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License. + * + * This file is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Or, alternatively, + * + * b) Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ +#include <arm/imx6qdl-microsom.dtsi> +#include <arm/imx6qdl-microsom-ar8035.dtsi> + +/ { + chosen { + stdout-path = &uart1; + }; + + ir_recv: ir-receiver { + compatible = "gpio-ir-receiver"; + gpios = <&gpio7 9 GPIO_ACTIVE_LOW>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_gpio7_9>; + linux,rc-map-name = "rc-rc6-mce"; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "VCC_3V2"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + }; + + reg_1p8v: regulator-1p8v { + compatible = "regulator-fixed"; + regulator-name = "VCC_1V8"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-always-on; + }; + + reg_usbh2_vbus: regulator-usb-h1-vbus { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_usbh1_vbus>; + regulator-name = "V_USB2"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + reg_usbotg_vbus: regulator-usb-otg-vbus { + compatible = "regulator-fixed"; + enable-active-high; + gpio = <&gpio3 22 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_usbotg_vbus>; + regulator-name = "V_USB1"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + reg_usbh3_vbus: regulator-usb-h2-vbus { + compatible = "regulator-fixed"; + enable-active-high; + enable-gpio = <&gpio2 13 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_usbh2_vbus>; + regulator-name = "V_USB3"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + reg_usbh4_vbus: regulator-usb-h3-vbus { + compatible = "regulator-fixed"; + enable-active-high; + enable-gpio = <&gpio7 10 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_usbh3_vbus>; + regulator-name = "V_USB4"; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; + }; + + reg_usdhc2_vmmc: reg-usdhc2-vmmc { + compatible = "regulator-fixed"; + gpio = <&gpio4 30 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_vmmc>; + regulator-boot-on; + regulator-max-microvolt = <3300000>; + regulator-min-microvolt = <3300000>; + regulator-name = "V_SD"; + startup-delay-us = <1000>; + }; + + sound-sgtl5000 { + audio-codec = <&sgtl5000>; + audio-routing = + "MIC_IN", "Mic Jack", + "Mic Jack", "Mic Bias", + "Headphone Jack", "HP_OUT"; + compatible = "fsl,imx-audio-sgtl5000"; + model = "On-board Codec"; + mux-ext-port = <5>; + mux-int-port = <1>; + ssi-controller = <&ssi1>; + }; +}; + +&audmux { + status = "okay"; +}; + +&ecspi2 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_ecspi2>; + cs-gpios = <&gpio2 26 0>; + status = "okay"; +}; + +&hdmi { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_hdmi>; + ddc-i2c-bus = <&i2c2>; + status = "okay"; +}; + +&i2c1 { + clock-frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_i2c1>; + status = "okay"; + + pcf8523: rtc@68 { + compatible = "nxp,pcf8523"; + reg = <0x68>; + }; + + sgtl5000: codec@0a { + clocks = <&clks IMX6QDL_CLK_CKO>; + compatible = "fsl,sgtl5000"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_sgtl5000>; + reg = <0x0a>; + VDDA-supply = <®_3p3v>; + VDDIO-supply = <®_3p3v>; + VDDD-supply = <®_1p8v>; + }; +}; + +&i2c2 { + clock-frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_i2c2>; + status = "okay"; +}; + +&i2c3 { + clock-frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_i2c3>; + status = "okay"; +}; + +&iomuxc { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hog>; + + hummingboard2 { + pinctrl_hog: hoggrp { + fsl,pins = < + /* + * 36 pin headers GPIO description. The pins + * numbering as following - + * + * 3.2v 5v 74 75 + * 73 72 71 70 + * 69 68 67 66 + * + * 77 78 79 76 + * 65 64 61 60 + * 53 52 51 50 + * 49 48 166 132 + * 95 94 90 91 + * GND 54 24 204 + * + * The GPIO numbers can be extracted using + * signal name from below. + * Example - + * MX6QDL_PAD_EIM_DA10__GPIO3_IO10 is + * GPIO(3,10) which is (3-1)*32+10 = gpio 74 + * + * i.e. The mapping of GPIO(X,Y) to Linux gpio + * number is : gpio number = (X-1) * 32 + Y + */ + /* DI1_PIN15 */ + MX6QDL_PAD_EIM_DA10__GPIO3_IO10 0x400130b1 + /* DI1_PIN02 */ + MX6QDL_PAD_EIM_DA11__GPIO3_IO11 0x400130b1 + /* DISP1_DATA00 */ + MX6QDL_PAD_EIM_DA9__GPIO3_IO09 0x400130b1 + /* DISP1_DATA01 */ + MX6QDL_PAD_EIM_DA8__GPIO3_IO08 0x400130b1 + /* DISP1_DATA02 */ + MX6QDL_PAD_EIM_DA7__GPIO3_IO07 0x400130b1 + /* DISP1_DATA03 */ + MX6QDL_PAD_EIM_DA6__GPIO3_IO06 0x400130b1 + /* DISP1_DATA04 */ + MX6QDL_PAD_EIM_DA5__GPIO3_IO05 0x400130b1 + /* DISP1_DATA05 */ + MX6QDL_PAD_EIM_DA4__GPIO3_IO04 0x400130b1 + /* DISP1_DATA06 */ + MX6QDL_PAD_EIM_DA3__GPIO3_IO03 0x400130b1 + /* DISP1_DATA07 */ + MX6QDL_PAD_EIM_DA2__GPIO3_IO02 0x400130b1 + /* DI1_D0_CS */ + MX6QDL_PAD_EIM_DA13__GPIO3_IO13 0x400130b1 + /* DI1_D1_CS */ + MX6QDL_PAD_EIM_DA14__GPIO3_IO14 0x400130b1 + /* DI1_PIN01 */ + MX6QDL_PAD_EIM_DA15__GPIO3_IO15 0x400130b1 + /* DI1_PIN03 */ + MX6QDL_PAD_EIM_DA12__GPIO3_IO12 0x400130b1 + /* DISP1_DATA08 */ + MX6QDL_PAD_EIM_DA1__GPIO3_IO01 0x400130b1 + /* DISP1_DATA09 */ + MX6QDL_PAD_EIM_DA0__GPIO3_IO00 0x400130b1 + /* DISP1_DATA10 */ + MX6QDL_PAD_EIM_EB1__GPIO2_IO29 0x400130b1 + /* DISP1_DATA11 */ + MX6QDL_PAD_EIM_EB0__GPIO2_IO28 0x400130b1 + /* DISP1_DATA12 */ + MX6QDL_PAD_EIM_A17__GPIO2_IO21 0x400130b1 + /* DISP1_DATA13 */ + MX6QDL_PAD_EIM_A18__GPIO2_IO20 0x400130b1 + /* DISP1_DATA14 */ + MX6QDL_PAD_EIM_A19__GPIO2_IO19 0x400130b1 + /* DISP1_DATA15 */ + MX6QDL_PAD_EIM_A20__GPIO2_IO18 0x400130b1 + /* DISP1_DATA16 */ + MX6QDL_PAD_EIM_A21__GPIO2_IO17 0x400130b1 + /* DISP1_DATA17 */ + MX6QDL_PAD_EIM_A22__GPIO2_IO16 0x400130b1 + /* DISP1_DATA18 */ + MX6QDL_PAD_EIM_A23__GPIO6_IO06 0x400130b1 + /* DISP1_DATA19 */ + MX6QDL_PAD_EIM_A24__GPIO5_IO04 0x400130b1 + /* DISP1_DATA20 */ + MX6QDL_PAD_EIM_D31__GPIO3_IO31 0x400130b1 + /* DISP1_DATA21 */ + MX6QDL_PAD_EIM_D30__GPIO3_IO30 0x400130b1 + /* DISP1_DATA22 */ + MX6QDL_PAD_EIM_D26__GPIO3_IO26 0x400130b1 + /* DISP1_DATA23 */ + MX6QDL_PAD_EIM_D27__GPIO3_IO27 0x400130b1 + /* DI1_DISP_CLK */ + MX6QDL_PAD_EIM_A16__GPIO2_IO22 0x400130b1 + /* SPDIF_IN */ + MX6QDL_PAD_ENET_RX_ER__GPIO1_IO24 0x400130b1 + /* SPDIF_OUT */ + MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x400130b1 + + /* MikroBUS GPIO pin number 10 */ + MX6QDL_PAD_EIM_LBA__GPIO2_IO27 0x400130b1 + >; + }; + + pinctrl_hummingboard2_ecspi2: hummingboard2-ecspi2grp { + fsl,pins = < + MX6QDL_PAD_EIM_OE__ECSPI2_MISO 0x100b1 + MX6QDL_PAD_EIM_CS1__ECSPI2_MOSI 0x100b1 + MX6QDL_PAD_EIM_CS0__ECSPI2_SCLK 0x100b1 + MX6QDL_PAD_EIM_RW__GPIO2_IO26 0x000b1 /* CS */ + >; + }; + + pinctrl_hummingboard2_gpio7_9: hummingboard2-gpio7_9 { + fsl,pins = < + MX6QDL_PAD_SD4_CMD__GPIO7_IO09 0x80000000 + >; + }; + + pinctrl_hummingboard2_hdmi: hummingboard2-hdmi { + fsl,pins = < + MX6QDL_PAD_KEY_ROW2__HDMI_TX_CEC_LINE 0x1f8b0 + >; + }; + + pinctrl_hummingboard2_i2c1: hummingboard2-i2c1 { + fsl,pins = < + MX6QDL_PAD_EIM_D21__I2C1_SCL 0x4001b8b1 + MX6QDL_PAD_EIM_D28__I2C1_SDA 0x4001b8b1 + >; + }; + + pinctrl_hummingboard2_i2c2: hummingboard2-i2c2 { + fsl,pins = < + MX6QDL_PAD_KEY_COL3__I2C2_SCL 0x4001b8b1 + MX6QDL_PAD_KEY_ROW3__I2C2_SDA 0x4001b8b1 + >; + }; + + pinctrl_hummingboard2_i2c3: hummingboard2-i2c3 { + fsl,pins = < + MX6QDL_PAD_EIM_D17__I2C3_SCL 0x4001b8b1 + MX6QDL_PAD_EIM_D18__I2C3_SDA 0x4001b8b1 + >; + }; + + pinctrl_hummingboard2_mipi: hummingboard2_mipi { + fsl,pins = < + MX6QDL_PAD_SD4_DAT2__GPIO2_IO10 0x4001b8b1 + MX6QDL_PAD_KEY_COL4__GPIO4_IO14 0x4001b8b1 + MX6QDL_PAD_NANDF_CS2__CCM_CLKO2 0x130b0 + >; + }; + + pinctrl_hummingboard2_pcie_reset: hummingboard2-pcie-reset { + fsl,pins = < + MX6QDL_PAD_SD4_DAT3__GPIO2_IO11 0x1b0b1 + >; + }; + + pinctrl_hummingboard2_pwm1: pwm1grp { + fsl,pins = < + MX6QDL_PAD_DISP0_DAT8__PWM1_OUT 0x1b0b1 + >; + }; + + pinctrl_hummingboard2_sgtl5000: hummingboard2-sgtl5000 { + fsl,pins = < + MX6QDL_PAD_DISP0_DAT19__AUD5_RXD 0x130b0 + MX6QDL_PAD_KEY_COL0__AUD5_TXC 0x130b0 + MX6QDL_PAD_KEY_ROW0__AUD5_TXD 0x110b0 + MX6QDL_PAD_KEY_COL1__AUD5_TXFS 0x130b0 + MX6QDL_PAD_GPIO_5__CCM_CLKO1 0x130b0 + >; + }; + + pinctrl_hummingboard2_usbh1_vbus: hummingboard2-usbh1-vbus { + fsl,pins = <MX6QDL_PAD_GPIO_0__GPIO1_IO00 0x1b0b0>; + }; + + pinctrl_hummingboard2_usbh2_vbus: hummingboard2-usbh2-vbus { + fsl,pins = <MX6QDL_PAD_SD4_DAT5__GPIO2_IO13 0x1b0b0>; + }; + + pinctrl_hummingboard2_usbh3_vbus: hummingboard2-usbh3-vbus { + fsl,pins = <MX6QDL_PAD_SD4_CLK__GPIO7_IO10 0x1b0b0>; + }; + + pinctrl_hummingboard2_usbotg_id: hummingboard2-usbotg-id { + /* + * Similar to pinctrl_usbotg_2, but we want it + * pulled down for a fixed host connection. + */ + fsl,pins = <MX6QDL_PAD_GPIO_1__USB_OTG_ID 0x13059>; + }; + + pinctrl_hummingboard2_usbotg_vbus: hummingboard2-usbotg-vbus { + fsl,pins = <MX6QDL_PAD_EIM_D22__GPIO3_IO22 0x1b0b0>; + }; + + pinctrl_hummingboard2_usdhc2_aux: hummingboard2-usdhc2-aux { + fsl,pins = < + MX6QDL_PAD_GPIO_4__GPIO1_IO04 0x1f071 + MX6QDL_PAD_KEY_ROW1__SD2_VSELECT 0x1b071 + >; + }; + + pinctrl_hummingboard2_usdhc2: hummingboard2-usdhc2 { + fsl,pins = < + MX6QDL_PAD_SD2_CMD__SD2_CMD 0x17059 + MX6QDL_PAD_SD2_CLK__SD2_CLK 0x10059 + MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x17059 + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x17059 + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x17059 + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x13059 + >; + }; + + pinctrl_hummingboard2_usdhc2_100mhz: hummingboard2-usdhc2-100mhz { + fsl,pins = < + MX6QDL_PAD_SD2_CMD__SD2_CMD 0x170b9 + MX6QDL_PAD_SD2_CLK__SD2_CLK 0x100b9 + MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x170b9 + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x170b9 + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x170b9 + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x130b9 + >; + }; + + pinctrl_hummingboard2_usdhc2_200mhz: hummingboard2-usdhc2-200mhz { + fsl,pins = < + MX6QDL_PAD_SD2_CMD__SD2_CMD 0x170f9 + MX6QDL_PAD_SD2_CLK__SD2_CLK 0x100f9 + MX6QDL_PAD_SD2_DAT0__SD2_DATA0 0x170f9 + MX6QDL_PAD_SD2_DAT1__SD2_DATA1 0x170f9 + MX6QDL_PAD_SD2_DAT2__SD2_DATA2 0x170f9 + MX6QDL_PAD_SD2_DAT3__SD2_DATA3 0x130f9 + >; + }; + + pinctrl_hummingboard2_vmmc: hummingboard2-vmmc { + fsl,pins = < + MX6QDL_PAD_DISP0_DAT9__GPIO4_IO30 0x1b0b0 + >; + }; + + pinctrl_hummingboard2_usdhc3: hummingboard2-usdhc3 { + fsl,pins = < + MX6QDL_PAD_SD3_CMD__SD3_CMD 0x17059 + MX6QDL_PAD_SD3_CLK__SD3_CLK 0x10059 + MX6QDL_PAD_SD3_DAT0__SD3_DATA0 0x17059 + MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x17059 + MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x17059 + MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x17059 + MX6QDL_PAD_SD3_DAT4__SD3_DATA4 0x17059 + MX6QDL_PAD_SD3_DAT5__SD3_DATA5 0x17059 + MX6QDL_PAD_SD3_DAT6__SD3_DATA6 0x17059 + MX6QDL_PAD_SD3_DAT7__SD3_DATA7 0x17059 + MX6QDL_PAD_SD3_RST__SD3_RESET 0x17059 + >; + }; + + pinctrl_hummingboard2_uart3: hummingboard2-uart3 { + fsl,pins = < + MX6QDL_PAD_EIM_D25__UART3_TX_DATA 0x1b0b1 + MX6QDL_PAD_EIM_D24__UART3_RX_DATA 0x40013000 + >; + }; + }; +}; + +&pcie { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_pcie_reset>; + reset-gpio = <&gpio2 11 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +&pwm1 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_pwm1>; + status = "okay"; +}; + +&ssi1 { + status = "okay"; +}; + +&usbh1 { + disable-over-current; + status = "okay"; +}; + +&usbotg { + disable-over-current; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_usbotg_id>; + vbus-supply = <®_usbotg_vbus>; + status = "okay"; +}; + +&usdhc2 { + pinctrl-names = "default", "state_100mhz", "state_200mhz"; + pinctrl-0 = < + &pinctrl_hummingboard2_usdhc2_aux + &pinctrl_hummingboard2_usdhc2 + >; + pinctrl-1 = < + &pinctrl_hummingboard2_usdhc2_aux + &pinctrl_hummingboard2_usdhc2_100mhz + >; + pinctrl-2 = < + &pinctrl_hummingboard2_usdhc2_aux + &pinctrl_hummingboard2_usdhc2_200mhz + >; + vmmc-supply = <®_usdhc2_vmmc>; + cd-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; + status = "okay"; +}; + +&usdhc3 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_usdhc3>; + vmmc-supply = <®_3p3v>; + vqmmc-supply = <®_3p3v>; + bus-width = <8>; + non-removable; + status = "okay"; +}; + +&uart3 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_hummingboard2_uart3>; + status = "okay"; +}; diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi index 274c491804..b3a7f69ffe 100644 --- a/arch/arm/dts/socfpga.dtsi +++ b/arch/arm/dts/socfpga.dtsi @@ -10,22 +10,6 @@ aliases { mmc0 = &mmc; }; - - soc { - qspi: spi@ff705000 { - compatible = "cdns,qspi-nor"; - #address-cells = <1>; - #size-cells = <0>; - reg = <0xff705000 0x1000>, - <0xffa00000 0x1000>; - interrupts = <0 151 4>; - ext-decoder = <0>; /* external decoder */ - fifo-depth = <128>; - clocks = <&qspi_clk>; - clock-names = "qspi_clk"; - status = "disabled"; - }; - }; }; &osc2 { clock-frequency = <0>; diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index 9c03a5935e..80f53ce124 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig @@ -212,6 +212,20 @@ config MACH_PCM038 Say Y here if you are using Phytec's phyCORE-i.MX27 (pcm038) equipped with a Freescale i.MX27 Processor +config MACH_KINDLE_MX50 + bool "i.MX50 based Amazon Kindle 4 and 5" + select ARCH_IMX50 + select SPI + select DRIVER_SPI_IMX + select I2C + select I2C_IMX + select MFD_MC13XXX + select ARM_BOARD_APPEND_ATAG + help + Say Y here if you are using the fourth or fifth generation Amazon + Kindle Model No. D01100 (Kindle Wi-Fi), D01200 (Kindle Touch) or + EY21 (Kindle Paperwhite). + config MACH_EFIKA_MX_SMARTBOOK bool "Efika MX smartbook" select ARCH_IMX51 diff --git a/arch/arm/mach-omap/am33xx_bbu_emmc.c b/arch/arm/mach-omap/am33xx_bbu_emmc.c index 3220575cd4..d3adb3744c 100644 --- a/arch/arm/mach-omap/am33xx_bbu_emmc.c +++ b/arch/arm/mach-omap/am33xx_bbu_emmc.c @@ -39,7 +39,7 @@ static int emmc_mlo_handler(struct bbu_handler *handler, struct bbu_data *data) if (ret != 0) return ret; - fd = open(handler->devicefile, O_WRONLY); + fd = open(handler->devicefile, O_RDWR); if (fd < 0) { pr_err("could not open %s: %s\n", handler->devicefile, errno_str()); diff --git a/arch/arm/mach-socfpga/include/mach/cyclone5-sequencer.h b/arch/arm/mach-socfpga/include/mach/cyclone5-sequencer.h index dd0378af34..d2da21d13f 100644 --- a/arch/arm/mach-socfpga/include/mach/cyclone5-sequencer.h +++ b/arch/arm/mach-socfpga/include/mach/cyclone5-sequencer.h @@ -369,7 +369,7 @@ static const uint32_t ac_rom_init[]; /* parameter variable holder */ -typedef struct param_type { +typedef struct sequencer_param_type { t_btfld dm_correct_mask; t_btfld read_correct_mask; t_btfld read_correct_mask_vg; diff --git a/arch/ppc/boards/pcm030/eeprom.c b/arch/ppc/boards/pcm030/eeprom.c index aa00f361cd..34bce85b94 100644 --- a/arch/ppc/boards/pcm030/eeprom.c +++ b/arch/ppc/boards/pcm030/eeprom.c @@ -53,7 +53,7 @@ static void pcm030_read_factory_data(const struct pcm030_eeprom *buf) continue; board = xstrndup(&buf->product[u], l); u += l + 1; - globalvar_add_simple("model.type", board); + globalvar_add_simple_string_fixed("model.type", board); free(board); } @@ -62,7 +62,7 @@ static void pcm030_read_factory_data(const struct pcm030_eeprom *buf) continue; serial = xstrndup(&buf->product[u], l); u += l + 1; - globalvar_add_simple("model.serial", serial); + globalvar_add_simple_string_fixed("model.serial", serial); free(serial); } diff --git a/commands/basename.c b/commands/basename.c index 028b0e0f24..c1a28e9e1d 100644 --- a/commands/basename.c +++ b/commands/basename.c @@ -27,7 +27,7 @@ static int do_basename(int argc, char *argv[]) if (argc != 3) return COMMAND_ERROR_USAGE; - setenv(argv[2], basename(argv[1])); + setenv(argv[2], posix_basename(argv[1])); return 0; } diff --git a/commands/cp.c b/commands/cp.c index 4f1c068dd6..54934dd64f 100644 --- a/commands/cp.c +++ b/commands/cp.c @@ -76,7 +76,8 @@ static int do_cp(int argc, char *argv[]) for (i = optind; i < argc - 1; i++) { char *dst; - dst = concat_path_file(argv[argc - 1], basename(argv[i])); + + dst = concat_path_file(argv[argc - 1], posix_basename(argv[i])); if (recursive) ret = copy_recursive(argv[i], dst); diff --git a/commands/devinfo.c b/commands/devinfo.c index 9d5e8b86eb..cd69d2e5f8 100644 --- a/commands/devinfo.c +++ b/commands/devinfo.c @@ -103,7 +103,8 @@ static int do_devinfo(int argc, char *argv[]) printf("Parameters:\n"); first = false; } - printf(" %s: %s", param->name, dev_get_param(dev, param->name)); + printf(" %s: %s (type: %s)", param->name, dev_get_param(dev, param->name), + get_param_type(param)); if (param->info) { param->info(param); } diff --git a/commands/spd_decode.c b/commands/spd_decode.c index 2bedcf05c5..08b9589622 100644 --- a/commands/spd_decode.c +++ b/commands/spd_decode.c @@ -59,5 +59,6 @@ BAREBOX_CMD_START(spd_decode) .cmd = do_spd_decode, BAREBOX_CMD_DESC("Decode SPD EEPROM") BAREBOX_CMD_OPTS("FILE") + BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) BAREBOX_CMD_HELP(cmd_spd_decode_help) BAREBOX_CMD_END diff --git a/common/Kconfig b/common/Kconfig index 459f0b18fd..bc7cb0fe76 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -101,6 +101,7 @@ config BAREBOX_UPDATE_IMX_NAND_FCB depends on BAREBOX_UPDATE depends on MTD_WRITE depends on NAND_MXS + select BCH if ARCH_IMX6 default y config UBIFORMAT diff --git a/common/boot.c b/common/boot.c index cef3d5e514..a2d27d1593 100644 --- a/common/boot.c +++ b/common/boot.c @@ -123,7 +123,7 @@ void boot_set_watchdog_timeout(unsigned int timeout) static int init_boot_watchdog_timeout(void) { - return globalvar_add_simple_int("boot.watchdog_timeout", + return globalvar_add_simple_uint32("boot.watchdog_timeout", &boot_watchdog_timeout, "%u"); } late_initcall(init_boot_watchdog_timeout); diff --git a/common/bootchooser.c b/common/bootchooser.c index 455f290fa2..f6d99d130b 100644 --- a/common/bootchooser.c +++ b/common/bootchooser.c @@ -907,8 +907,8 @@ static int bootchooser_init(void) globalvar_add_simple_bool("bootchooser.retry", &retry); globalvar_add_simple_string("bootchooser.targets", &available_targets); globalvar_add_simple_string("bootchooser.state_prefix", &state_prefix); - globalvar_add_simple_int("bootchooser.default_attempts", &global_default_attempts, "%u"); - globalvar_add_simple_int("bootchooser.default_priority", &global_default_priority, "%u"); + globalvar_add_simple_uint32("bootchooser.default_attempts", &global_default_attempts, "%u"); + globalvar_add_simple_uint32("bootchooser.default_priority", &global_default_priority, "%u"); globalvar_add_simple_bitmask("bootchooser.reset_attempts", &reset_attempts, reset_attempts_names, ARRAY_SIZE(reset_attempts_names)); globalvar_add_simple_bitmask("bootchooser.reset_priorities", &reset_priorities, diff --git a/common/bootm.c b/common/bootm.c index 81625d9157..92cfeb6c32 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -668,7 +668,7 @@ static int bootm_init(void) if (IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES)) bootm_verify_mode = BOOTM_VERIFY_SIGNATURE; - globalvar_add_simple_int("bootm.verbose", &bootm_verbosity, "%u"); + globalvar_add_simple_uint32("bootm.verbose", &bootm_verbosity, "%u"); globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode, bootm_verify_names, ARRAY_SIZE(bootm_verify_names)); diff --git a/common/console.c b/common/console.c index 74fb684b2c..f4c799fa54 100644 --- a/common/console.c +++ b/common/console.c @@ -94,7 +94,7 @@ int console_close(struct console_device *cdev) int console_set_active(struct console_device *cdev, unsigned flag) { - int ret, i; + int ret; if (!cdev->getc) flag &= ~CONSOLE_STDIN; @@ -119,18 +119,6 @@ int console_set_active(struct console_device *cdev, unsigned flag) cdev->f_active = flag; - if (IS_ENABLED(CONFIG_PARAMETER)) { - i = 0; - - if (flag & CONSOLE_STDIN) - cdev->active[i++] = 'i'; - if (flag & CONSOLE_STDOUT) - cdev->active[i++] = 'o'; - if (flag & CONSOLE_STDERR) - cdev->active[i++] = 'e'; - cdev->active[i] = 0; - } - if (initialized < CONSOLE_INIT_FULL) { char ch; initialized = CONSOLE_INIT_FULL; @@ -150,30 +138,39 @@ unsigned console_get_active(struct console_device *cdev) return cdev->f_active; } -static int console_active_set(struct device_d *dev, struct param_d *param, - const char *val) +static int console_active_set(struct param_d *param, void *priv) { - struct console_device *cdev = to_console_dev(dev); + struct console_device *cdev = priv; unsigned int flag = 0; + int ret; - if (val) { - if (strchr(val, 'i')) + if (cdev->active_string) { + if (strchr(cdev->active_string, 'i')) flag |= CONSOLE_STDIN; - if (strchr(val, 'o')) + if (strchr(cdev->active_string, 'o')) flag |= CONSOLE_STDOUT; - if (strchr(val, 'e')) + if (strchr(cdev->active_string, 'e')) flag |= CONSOLE_STDERR; } - return console_set_active(cdev, flag); + ret = console_set_active(cdev, flag); + if (ret) + return ret; + + return 0; } -static const char *console_active_get(struct device_d *dev, - struct param_d *param) +static int console_active_get(struct param_d *param, void *priv) { - struct console_device *cdev = to_console_dev(dev); + struct console_device *cdev = priv; + unsigned int flag = cdev->f_active; - return cdev->active; + free(cdev->active_string); + cdev->active_string = basprintf("%s%s%s", + flag & CONSOLE_STDIN ? "i" : "", + flag & CONSOLE_STDOUT ? "o" : "", + flag & CONSOLE_STDERR ? "e" : ""); + return 0; } int console_set_baudrate(struct console_device *cdev, unsigned baudrate) @@ -331,7 +328,7 @@ int console_register(struct console_device *newcdev) if (ret) return ret; newcdev->baudrate_param = newcdev->baudrate = CONFIG_BAUDRATE; - dev_add_param_int(dev, "baudrate", console_baudrate_set, + dev_add_param_uint32(dev, "baudrate", console_baudrate_set, NULL, &newcdev->baudrate_param, "%u", newcdev); } @@ -340,7 +337,8 @@ int console_register(struct console_device *newcdev) newcdev->open_count = 0; - dev_add_param(dev, "active", console_active_set, console_active_get, 0); + dev_add_param_string(dev, "active", console_active_set, console_active_get, + &newcdev->active_string, newcdev); if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) { if (list_empty(&console_list)) diff --git a/common/console_common.c b/common/console_common.c index d051458de4..b36b3ff083 100644 --- a/common/console_common.c +++ b/common/console_common.c @@ -148,10 +148,10 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...) static int loglevel_init(void) { if (IS_ENABLED(CONFIG_LOGBUF)) - globalvar_add_simple_int("log_max_messages", - &barebox_log_max_messages, "%d"); + globalvar_add_simple_uint32("log_max_messages", + &barebox_log_max_messages, "%u"); - return globalvar_add_simple_int("loglevel", &barebox_loglevel, "%d"); + return globalvar_add_simple_uint32("loglevel", &barebox_loglevel, "%u"); } device_initcall(loglevel_init); diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 499ec93c28..9c33cc2c95 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1753,7 +1753,6 @@ void *calloc(size_t n, size_t elem_size) /* Utility to update current_mallinfo for malloc_stats and mallinfo() */ -#ifdef CONFIG_CMD_MEMINFO static void malloc_update_mallinfo(void) { int i; @@ -1821,8 +1820,6 @@ void malloc_stats(void) #endif } -#endif /* CONFIG_CMD_MEMINFO */ - /* History: diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c index dd36a5b156..641baa125a 100644 --- a/common/dummy_malloc.c +++ b/common/dummy_malloc.c @@ -24,6 +24,10 @@ #include <common.h> #include <malloc.h> +void malloc_stats(void) +{ +} + void *memalign(size_t alignment, size_t bytes) { unsigned long mem = (unsigned long)sbrk(bytes + alignment); diff --git a/common/globalvar.c b/common/globalvar.c index 1ecf5134af..1385559fd7 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -19,7 +19,7 @@ struct device_d global_device = { .id = DEVICE_ID_SINGLE, }; -struct device_d nv_device = { +static struct device_d nv_device = { .name = "nv", .id = DEVICE_ID_SINGLE, }; @@ -166,7 +166,7 @@ static int nvvar_device_dispatch(const char *name, struct device_d **dev, return 1; } -static int nv_set(struct device_d *dev, struct param_d *p, const char *val) +static int nv_set(struct param_d *p, const char *val) { struct param_d *g; int ret; @@ -187,16 +187,16 @@ static int nv_set(struct device_d *dev, struct param_d *p, const char *val) return 0; } -static const char *nv_param_get(struct device_d *dev, struct param_d *p) +static const char *nv_param_get(struct param_d *p) { return p->value ? p->value : ""; } -static int nv_param_set(struct device_d *dev, struct param_d *p, const char *val) +static int nv_param_set(struct param_d *p, const char *val) { int ret; - ret = nv_set(dev, p, val); + ret = nv_set(p, val); if (ret) return ret; @@ -219,7 +219,7 @@ static int __nvvar_add(const char *name, const char *value) } if (value) - return nv_set(&nv_device, p, value); + return nv_set(p, value); value = dev_get_param(&global_device, name); if (value) { @@ -373,7 +373,7 @@ void globalvar_set_match(const char *match, const char *val) } } -static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const char *val) +static int globalvar_simple_set(struct param_d *p, const char *val) { struct device_d *rdev; const char *pname = NULL; @@ -391,7 +391,7 @@ static int globalvar_simple_set(struct device_d *dev, struct param_d *p, const c } /* Pass to the generic function we have overwritten */ - return dev_param_set_generic(dev, p, val); + return dev_param_set_generic(p, val); } static void globalvar_nv_sync(const char *name) @@ -430,7 +430,7 @@ int globalvar_add_simple(const char *name, const char *value) return 0; } -int globalvar_add_simple_string(const char *name, char **value) +int __globalvar_add_simple_string(const char *name, char **value) { struct param_d *p; @@ -445,28 +445,14 @@ int globalvar_add_simple_string(const char *name, char **value) return 0; } -int globalvar_add_simple_int(const char *name, int *value, - const char *format) +int __globalvar_add_simple_int(const char *name, void *value, + enum param_type type, + const char *format) { struct param_d *p; - p = dev_add_param_int(&global_device, name, NULL, NULL, - value, format, NULL); - - if (IS_ERR(p)) - return PTR_ERR(p); - - globalvar_nv_sync(name); - - return 0; -} - -int globalvar_add_simple_bool(const char *name, int *value) -{ - struct param_d *p; - - p = dev_add_param_bool(&global_device, name, NULL, NULL, - value, NULL); + p = __dev_add_param_int(&global_device, name, NULL, NULL, + value, type, format, NULL); if (IS_ERR(p)) return PTR_ERR(p); @@ -528,7 +514,7 @@ static int globalvar_init(void) if (IS_ENABLED(CONFIG_NVVAR)) register_device(&nv_device); - globalvar_add_simple("version", UTS_RELEASE); + globalvar_add_simple_string_fixed("version", UTS_RELEASE); return 0; } diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c index 34a5f83230..5d3d3f7e93 100644 --- a/common/imx-bbu-nand-fcb.c +++ b/common/imx-bbu-nand-fcb.c @@ -33,9 +33,12 @@ #include <linux/mtd/mtd.h> #include <linux/mtd/nand.h> #include <linux/stat.h> +#include <linux/bch.h> +#include <linux/bitops.h> #include <io.h> #include <crc.h> #include <mach/generic.h> +#include <mach/imx6.h> #include <mtd/mtd-peb.h> struct dbbt_block { @@ -129,6 +132,132 @@ static uint8_t calculate_parity_13_8(uint8_t d) return p; } +static uint8_t reverse_bit(uint8_t b) +{ + b = (b & 0xf0) >> 4 | (b & 0x0f) << 4; + b = (b & 0xcc) >> 2 | (b & 0x33) << 2; + b = (b & 0xaa) >> 1 | (b & 0x55) << 1; + + return b; +} + +static void encode_bch_ecc(void *buf, struct fcb_block *fcb, int eccbits) +{ + int i, j, m = 13; + int blocksize = 128; + int numblocks = 8; + int ecc_buf_size = (m * eccbits + 7) / 8; + struct bch_control *bch = init_bch(m, eccbits, 0); + uint8_t *ecc_buf = xmalloc(ecc_buf_size); + uint8_t *tmp_buf = xzalloc(blocksize * numblocks); + uint8_t *psrc, *pdst; + + /* + * The blocks here are bit aligned. If eccbits is a multiple of 8, + * we just can copy bytes. Otherwiese we must move the blocks to + * the next free bit position. + */ + BUG_ON(eccbits % 8); + + memcpy(tmp_buf, fcb, sizeof(*fcb)); + + for (i = 0; i < numblocks; i++) { + memset(ecc_buf, 0, ecc_buf_size); + psrc = tmp_buf + i * blocksize; + pdst = buf + i * (blocksize + ecc_buf_size); + + /* copy data byte aligned to destination buf */ + memcpy(pdst, psrc, blocksize); + + /* + * imx-kobs use a modified encode_bch which reverse the + * bit order of the data before calculating bch. + * Do this in the buffer and use the bch lib here. + */ + for (j = 0; j < blocksize; j++) + psrc[j] = reverse_bit(psrc[j]); + + encode_bch(bch, psrc, blocksize, ecc_buf); + + /* reverse ecc bit */ + for (j = 0; j < ecc_buf_size; j++) + ecc_buf[j] = reverse_bit(ecc_buf[j]); + + /* Here eccbuf is byte aligned and we can just copy it */ + memcpy(pdst + blocksize, ecc_buf, ecc_buf_size); + } + + free(ecc_buf); + free(tmp_buf); + free_bch(bch); +} + +struct fcb_block *read_fcb_bch(void *rawpage, int eccbits) +{ + int i, j, ret, errbit, m = 13; + int blocksize = 128; + int numblocks = 8; + int ecc_buf_size = (m * eccbits + 7) / 8; + struct bch_control *bch = init_bch(m, eccbits, 0); + uint8_t *fcb = xmalloc(numblocks * blocksize); + uint8_t *ecc_buf = xmalloc(ecc_buf_size); + uint8_t *data_buf = xmalloc(blocksize); + unsigned int *errloc = xmalloc(eccbits * sizeof(*errloc)); + uint8_t *psrc, *pdst; + + /* see encode_bch_ecc */ + BUG_ON(eccbits % 8); + + for (i = 0; i < numblocks; i++) { + psrc = rawpage + 32 + i * (blocksize + ecc_buf_size); + pdst = fcb + i * blocksize; + + /* reverse data bit */ + for (j = 0; j < blocksize; j++) + data_buf[j] = reverse_bit(psrc[j]); + + /* reverse ecc bit */ + for (j = 0; j < ecc_buf_size; j++) + ecc_buf[j] = reverse_bit(psrc[j + blocksize]); + + ret = decode_bch(bch, data_buf, blocksize, ecc_buf, + NULL, NULL, errloc); + + if (ret < 0) { + pr_err("Uncorrectable error at block %d\n", i); + free(fcb); + fcb = ERR_PTR(ret); + goto out; + } + if (ret > 0) + pr_info("Found %d correctable errors in block %d\n", + ret, i); + + for (j = 0; j < ret; j++) { + /* + * calculate the reverse position + * pos - (pos % 8) -> byte offset + * 7 - (pos % 8) -> reverse bit position + */ + errbit = errloc[j] - 2 * (errloc[j] % 8) + 7; + pr_debug("Found error: bit %d in block %d\n", + errbit, i); + if (errbit < blocksize * 8) + change_bit(errbit, psrc); + /* else error in ecc, ignore it */ + } + memcpy(pdst, psrc, blocksize); + } + +out: + free(data_buf); + free(ecc_buf); + free(errloc); + free_bch(bch); + + return (struct fcb_block *)fcb; +} + static void encode_hamming_13_8(void *_src, void *_ecc, size_t size) { int i; @@ -312,7 +441,11 @@ static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb) goto err; } - fcb = read_fcb_hamming_13_8(rawpage); + if (cpu_is_mx6ul()) + fcb = read_fcb_bch(rawpage, 40); + else + fcb = read_fcb_hamming_13_8(rawpage); + if (IS_ERR(fcb)) { pr_err("Cannot read fcb\n"); ret = PTR_ERR(fcb); @@ -766,8 +899,14 @@ static int imx_bbu_write_fcbs_dbbts(struct mtd_info *mtd, struct fcb_block *fcb) fcb_raw_page = xzalloc(mtd->writesize + mtd->oobsize); - memcpy(fcb_raw_page + 12, fcb, sizeof(struct fcb_block)); - encode_hamming_13_8(fcb_raw_page + 12, fcb_raw_page + 12 + 512, 512); + if (cpu_is_mx6ul()) { + /* 40 bit BCH, for i.MX6UL */ + encode_bch_ecc(fcb_raw_page + 32, fcb, 40); + } else { + memcpy(fcb_raw_page + 12, fcb, sizeof(struct fcb_block)); + encode_hamming_13_8(fcb_raw_page + 12, + fcb_raw_page + 12 + 512, 512); + } dbbt = dbbt_data_create(mtd); diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 5f08e253ee..91b5399079 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -251,7 +251,7 @@ static void dos_partition(void *buf, struct block_device *blk, * signature and pp is a zero-filled hex representation of the 1-based * partition number. */ - dev_add_param_int(blk->dev, "nt_signature", + dev_add_param_uint32(blk->dev, "nt_signature", dos_set_disk_signature, dos_get_disk_signature, &dsp->signature, "%08x", dsp); } diff --git a/common/password.c b/common/password.c index 74d328f4b2..5e6bfc53e7 100644 --- a/common/password.c +++ b/common/password.c @@ -443,7 +443,7 @@ static int login_global_init(void) { login_fail_command = xstrdup("boot"); - globalvar_add_simple_int("login.timeout", &login_timeout, "%d"); + globalvar_add_simple_uint32("login.timeout", &login_timeout, "%u"); globalvar_add_simple_string("login.fail_command", &login_fail_command); return 0; diff --git a/common/reset_source.c b/common/reset_source.c index 06e2ca85f5..e18bf6db68 100644 --- a/common/reset_source.c +++ b/common/reset_source.c @@ -54,7 +54,7 @@ EXPORT_SYMBOL(reset_source_set_priority); static int reset_source_init(void) { - globalvar_add_simple_enum("system.reset", (unsigned int *)&reset_source, + globalvar_add_simple_enum_ro("system.reset", (unsigned int *)&reset_source, reset_src_names, ARRAY_SIZE(reset_src_names)); return 0; diff --git a/common/state/backend_bucket_circular.c b/common/state/backend_bucket_circular.c index 832f44e599..7c81cdfaff 100644 --- a/common/state/backend_bucket_circular.c +++ b/common/state/backend_bucket_circular.c @@ -72,7 +72,6 @@ struct __attribute__((__packed__)) state_backend_storage_bucket_circular_meta { }; static const uint32_t circular_magic = 0x14fa2d02; -static const uint8_t free_pattern = 0xff; static inline struct state_backend_storage_bucket_circular *get_bucket_circular(struct state_backend_storage_bucket *bucket) diff --git a/common/state/state_variables.c b/common/state/state_variables.c index 5b8e6284d9..56bcd9590a 100644 --- a/common/state/state_variables.c +++ b/common/state/state_variables.c @@ -108,7 +108,7 @@ static struct state_variable *state_uint8_create(struct state *state, su32 = xzalloc(sizeof(*su32)); - param = dev_add_param_int(&state->dev, name, state_uint8_set, + param = dev_add_param_uint32(&state->dev, name, state_uint8_set, NULL, &su32->value, "%u", &su32->var); if (IS_ERR(param)) { free(su32); @@ -136,7 +136,7 @@ static struct state_variable *state_uint32_create(struct state *state, su32 = xzalloc(sizeof(*su32)); - param = dev_add_param_int(&state->dev, name, state_set_dirty, + param = dev_add_param_uint32(&state->dev, name, state_set_dirty, NULL, &su32->value, "%u", &su32->var); if (IS_ERR(param)) { free(su32); diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index ddd9661806..ae5df13c96 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -155,7 +155,7 @@ int amba_device_add(struct amba_device *dev) if (ret) goto err_release; - dev_add_param_int_ro(&dev->dev, "periphid", dev->periphid, "0x%08x"); + dev_add_param_uint32_fixed(&dev->dev, "periphid", dev->periphid, "0x%08x"); return ret; err_release: diff --git a/drivers/clk/imx/clk-imx5.c b/drivers/clk/imx/clk-imx5.c index c4c47a6d87..edebd25a38 100644 --- a/drivers/clk/imx/clk-imx5.c +++ b/drivers/clk/imx/clk-imx5.c @@ -313,6 +313,7 @@ int __init mx50_clocks_init(struct device_d *dev, void __iomem *regs) clkdev_add_physbase(clks[IMX5_CLK_ESDHC_D_SEL], MX50_ESDHC4_BASE_ADDR, NULL); clkdev_add_physbase(clks[IMX5_CLK_PER_ROOT], MX50_PWM1_BASE_ADDR, "per"); clkdev_add_physbase(clks[IMX5_CLK_PER_ROOT], MX50_PWM2_BASE_ADDR, "per"); + clkdev_add_physbase(clks[IMX5_CLK_AHB], MX50_OTG_BASE_ADDR, NULL); return 0; } diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c index 1227286fbe..050a35aed8 100644 --- a/drivers/eeprom/at24.c +++ b/drivers/eeprom/at24.c @@ -454,6 +454,10 @@ static int at24_probe(struct device_d *dev) at24->cdev.size = chip.byte_len; writable = !(chip.flags & AT24_FLAG_READONLY); + + if (of_get_property(dev->device_node, "read-only", NULL)) + writable = 0; + if (writable) { unsigned write_max = chip.page_size; diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c index 1caaebd371..9f16f964a8 100644 --- a/drivers/eeprom/at25.c +++ b/drivers/eeprom/at25.c @@ -290,7 +290,7 @@ static int at25_np_to_chip(struct device_d *dev, val); return -ENODEV; } - if (of_find_property(np, "read-only", NULL)) + if (of_property_read_bool(np, "read-only")) chip->flags |= EE_READONLY; } return 0; diff --git a/drivers/efi/efi-device.c b/drivers/efi/efi-device.c index e9b03cb02a..9975aea6f7 100644 --- a/drivers/efi/efi-device.c +++ b/drivers/efi/efi-device.c @@ -404,12 +404,12 @@ static int efi_init_devices(void) dev_add_param_fixed(efi_bus.dev, "fw_vendor", fw_vendor); free(fw_vendor); - dev_add_param_int_ro(efi_bus.dev, "major", sys_major, "%u"); - dev_add_param_int_ro(efi_bus.dev, "minor", sys_minor, "%u"); - dev_add_param_int_ro(efi_bus.dev, "fw_revision", efi_sys_table->fw_revision, "%u"); - dev_add_param_int_ro(efi_bus.dev, "secure_boot", secure_boot, "%d"); - dev_add_param_int_ro(efi_bus.dev, "secure_mode", - secure_boot & setup_mode, "%u"); + dev_add_param_uint32_fixed(efi_bus.dev, "major", sys_major, "%u"); + dev_add_param_uint32_fixed(efi_bus.dev, "minor", sys_minor, "%u"); + dev_add_param_uint32_fixed(efi_bus.dev, "fw_revision", efi_sys_table->fw_revision, "%u"); + dev_add_param_bool_fixed(efi_bus.dev, "secure_boot", secure_boot); + dev_add_param_bool_fixed(efi_bus.dev, "secure_mode", + secure_boot & setup_mode); efi_bus.dev->info = efi_businfo; diff --git a/drivers/input/qt1070.c b/drivers/input/qt1070.c index 1ee868dfdd..d81a8fa401 100644 --- a/drivers/input/qt1070.c +++ b/drivers/input/qt1070.c @@ -238,8 +238,8 @@ static int qt1070_probe(struct device_d *dev) goto err; } - dev_add_param_int_ro(dev, "fw_version", fw_version, "0x%x"); - dev_add_param_int_ro(dev, "chip_ip", chip_id, "0x%x"); + dev_add_param_uint32_fixed(dev, "fw_version", fw_version, "0x%x"); + dev_add_param_uint32_fixed(dev, "chip_ip", chip_id, "0x%x"); memcpy(data->code, default_code, sizeof(int) * ARRAY_SIZE(default_code)); diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig index 0f3504c735..954f957bc7 100644 --- a/drivers/mci/Kconfig +++ b/drivers/mci/Kconfig @@ -66,6 +66,13 @@ config MCI_BCM283X bool "MCI support for BCM283X" depends on ARCH_BCM283X +config MCI_DOVE + bool "Marvell Dove SDHCI" + depends on ARCH_DOVE + help + Enable this entry to add support to read and write SD cards on a + Marvell Dove SoC based system. + config MCI_IMX bool "i.MX" depends on ARCH_IMX27 || ARCH_IMX31 diff --git a/drivers/mci/Makefile b/drivers/mci/Makefile index 88ec456aa3..fe2c8adbac 100644 --- a/drivers/mci/Makefile +++ b/drivers/mci/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_MCI) += mci-core.o obj-$(CONFIG_MCI_ATMEL) += atmel_mci.o obj-$(CONFIG_MCI_BCM283X) += mci-bcm2835.o +obj-$(CONFIG_MCI_DOVE) += dove-sdhci.o obj-$(CONFIG_MCI_IMX) += imx.o obj-$(CONFIG_MCI_IMX_ESDHC) += imx-esdhc.o obj-$(CONFIG_MCI_MXS) += mxs.o diff --git a/drivers/mci/dove-sdhci.c b/drivers/mci/dove-sdhci.c new file mode 100644 index 0000000000..caee4107eb --- /dev/null +++ b/drivers/mci/dove-sdhci.c @@ -0,0 +1,392 @@ +/* + * Marvell Dove SDHCI MCI driver + * + * Pengutronix, Michael Grzeschik <mgr@pengutronix.de> + * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.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. + * + */ + +#include <clock.h> +#include <common.h> +#include <init.h> +#include <io.h> +#include <dma.h> +#include <malloc.h> +#include <mci.h> +#include <linux/err.h> + +#include "sdhci.h" + +struct dove_sdhci { + struct mci_host mci; + void __iomem *base; +}; + +#define priv_from_mci_host(h) \ + container_of(h, struct dove_sdhci, mci); + +static inline void dove_sdhci_writel(struct dove_sdhci *p, int reg, u32 val) +{ + writel(val, p->base + reg); +} + +static inline void dove_sdhci_writew(struct dove_sdhci *p, int reg, u16 val) +{ + writew(val, p->base + reg); +} + +static inline void dove_sdhci_writeb(struct dove_sdhci *p, int reg, u8 val) +{ + writeb(val, p->base + reg); +} + +static inline u32 dove_sdhci_readl(struct dove_sdhci *p, int reg) +{ + return readl(p->base + reg); +} + +static inline u16 dove_sdhci_readw(struct dove_sdhci *p, int reg) +{ + return readw(p->base + reg); +} + +static inline u8 dove_sdhci_readb(struct dove_sdhci *p, int reg) +{ + return readb(p->base + reg); +} + +static int dove_sdhci_wait_for_done(struct dove_sdhci *host, u16 mask) +{ + u16 status; + u64 start; + + start = get_time_ns(); + while (1) { + status = dove_sdhci_readw(host, SDHCI_INT_NORMAL_STATUS); + if (status & SDHCI_INT_ERROR) + return -EPERM; + /* this special quirk is necessary, as the dma + * engine stops on dma boundary and will only + * restart after acknowledging it this way. + */ + if (status & SDHCI_INT_DMA) { + u32 addr = dove_sdhci_readl(host, SDHCI_DMA_ADDRESS); + dove_sdhci_writel(host, SDHCI_DMA_ADDRESS, addr); + } + if (status & mask) + break; + if (is_timeout(start, 1000 * MSECOND)) { + dev_err(host->mci.hw_dev, "SDHCI timeout while waiting for done\n"); + return -ETIMEDOUT; + } + } + return 0; +} + +static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd, + struct mci_data *data) +{ + u16 val; + u64 start; + int ret; + unsigned int num_bytes = data->blocks * data->blocksize; + struct dove_sdhci *host = priv_from_mci_host(mci); + + dove_sdhci_writel(host, SDHCI_INT_STATUS, ~0); + + /* Do not wait for CMD_INHIBIT_DAT on stop commands */ + if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION) + val = SDHCI_CMD_INHIBIT_CMD; + else + val = SDHCI_CMD_INHIBIT_CMD | SDHCI_CMD_INHIBIT_DATA; + + /* Wait for bus idle */ + start = get_time_ns(); + while (1) { + if (!(dove_sdhci_readw(host, SDHCI_PRESENT_STATE) & val)) + break; + if (is_timeout(start, 10 * MSECOND)) { + dev_err(host->mci.hw_dev, "SDHCI timeout while waiting for idle\n"); + return -ETIMEDOUT; + } + } + + /* setup transfer data */ + if (data) { + if (data->flags & MMC_DATA_READ) + dove_sdhci_writel(host, SDHCI_DMA_ADDRESS, (u32)data->dest); + else + dove_sdhci_writel(host, SDHCI_DMA_ADDRESS, (u32)data->src); + dove_sdhci_writew(host, SDHCI_BLOCK_SIZE, SDHCI_DMA_BOUNDARY_512K | + SDHCI_TRANSFER_BLOCK_SIZE(data->blocksize)); + dove_sdhci_writew(host, SDHCI_BLOCK_COUNT, data->blocks); + dove_sdhci_writeb(host, SDHCI_TIMEOUT_CONTROL, 0xe); + + + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_device((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_device((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); + } + + /* setup transfer mode */ + val = 0; + if (data) { + val |= SDHCI_DMA_EN | SDHCI_BLOCK_COUNT_EN; + if (data->blocks > 1) + val |= SDHCI_MULTIPLE_BLOCKS; + if (data->flags & MMC_DATA_READ) + val |= SDHCI_DATA_TO_HOST; + } + dove_sdhci_writew(host, SDHCI_TRANSFER_MODE, val); + + dove_sdhci_writel(host, SDHCI_ARGUMENT, cmd->cmdarg); + + if (!(cmd->resp_type & MMC_RSP_PRESENT)) + val = SDHCI_RESP_NONE; + else if (cmd->resp_type & MMC_RSP_136) + val = SDHCI_RESP_TYPE_136; + else if (cmd->resp_type & MMC_RSP_BUSY) + val = SDHCI_RESP_TYPE_48_BUSY; + else + val = SDHCI_RESP_TYPE_48; + + if (cmd->resp_type & MMC_RSP_CRC) + val |= SDHCI_CMD_CRC_CHECK_EN; + if (cmd->resp_type & MMC_RSP_OPCODE) + val |= SDHCI_CMD_INDEX_CHECK_EN; + if (data) + val |= SDHCI_DATA_PRESENT; + val |= SDHCI_CMD_INDEX(cmd->cmdidx); + + dove_sdhci_writew(host, SDHCI_COMMAND, val); + + ret = dove_sdhci_wait_for_done(host, SDHCI_INT_CMD_COMPLETE); + if (ret) { + dev_err(host->mci.hw_dev, "error on command %d\n", cmd->cmdidx); + dev_err(host->mci.hw_dev, "state = %04x %04x, interrupt = %04x %04x\n", + dove_sdhci_readw(host, SDHCI_PRESENT_STATE), + dove_sdhci_readw(host, SDHCI_PRESENT_STATE1), + dove_sdhci_readw(host, SDHCI_INT_NORMAL_STATUS), + dove_sdhci_readw(host, SDHCI_INT_ERROR_STATUS)); + goto cmd_error; + } + + /* CRC is stripped so we need to do some shifting. */ + if (cmd->resp_type & MMC_RSP_136) { + int i; + for (i = 0; i < 4; i++) { + cmd->response[i] = dove_sdhci_readl(host, + SDHCI_RESPONSE_0 + 4*(3-i)) << 8; + if (i != 3) + cmd->response[i] |= dove_sdhci_readb(host, + SDHCI_RESPONSE_0 + 4*(3-i) - 1); + } + } else + cmd->response[0] = dove_sdhci_readl(host, SDHCI_RESPONSE_0); + + if (data->flags & MMC_DATA_WRITE) + dma_sync_single_for_cpu((unsigned long)data->src, + num_bytes, DMA_TO_DEVICE); + else + dma_sync_single_for_cpu((unsigned long)data->dest, + num_bytes, DMA_FROM_DEVICE); + + if (data) { + ret = dove_sdhci_wait_for_done(host, SDHCI_INT_XFER_COMPLETE); + if (ret) { + dev_err(host->mci.hw_dev, "error while transfering data for command %d\n", + cmd->cmdidx); + dev_err(host->mci.hw_dev, "state = %04x %04x, interrupt = %04x %04x\n", + dove_sdhci_readw(host, SDHCI_PRESENT_STATE), + dove_sdhci_readw(host, SDHCI_PRESENT_STATE1), + dove_sdhci_readw(host, SDHCI_INT_NORMAL_STATUS), + dove_sdhci_readw(host, SDHCI_INT_ERROR_STATUS)); + goto cmd_error; + } + } + +cmd_error: + dove_sdhci_writel(host, SDHCI_INT_STATUS, ~0); + return ret; +} + +static u16 dove_sdhci_get_clock_divider(struct dove_sdhci *host, u32 reqclk) +{ + u16 div; + + for (div = 1; div < SDHCI_SPEC_200_MAX_CLK_DIVIDER; div *= 2) + if ((host->mci.f_max / div) <= reqclk) + break; + div /= 2; + + return div; +} + +static void dove_sdhci_mci_set_ios(struct mci_host *mci, struct mci_ios *ios) +{ + u16 val; + u64 start; + struct dove_sdhci *host = priv_from_mci_host(mci); + + debug("%s: clock = %u, bus-width = %d, timing = %02x\n", __func__, ios->clock, ios->bus_width, ios->timing); + + /* disable on zero clock */ + if (!ios->clock) + return; + + /* enable bus power */ + val = SDHCI_BUS_VOLTAGE_330; + dove_sdhci_writeb(host, SDHCI_POWER_CONTROL, val | SDHCI_BUS_POWER_EN); + udelay(400); + + /* set bus width */ + val = dove_sdhci_readb(host, SDHCI_HOST_CONTROL) & + ~(SDHCI_DATA_WIDTH_4BIT | SDHCI_DATA_WIDTH_8BIT); + switch (ios->bus_width) { + case MMC_BUS_WIDTH_8: + val |= SDHCI_DATA_WIDTH_8BIT; + break; + case MMC_BUS_WIDTH_4: + val |= SDHCI_DATA_WIDTH_4BIT; + break; + } + + if (ios->clock > 26000000) + val |= SDHCI_HIGHSPEED_EN; + else + val &= ~SDHCI_HIGHSPEED_EN; + + dove_sdhci_writeb(host, SDHCI_HOST_CONTROL, val); + + /* set bus clock */ + dove_sdhci_writew(host, SDHCI_CLOCK_CONTROL, 0); + val = dove_sdhci_get_clock_divider(host, ios->clock); + val = SDHCI_INTCLOCK_EN | SDHCI_FREQ_SEL(val); + dove_sdhci_writew(host, SDHCI_CLOCK_CONTROL, val); + + /* wait for internal clock stable */ + start = get_time_ns(); + while (!(dove_sdhci_readw(host, SDHCI_CLOCK_CONTROL) & + SDHCI_INTCLOCK_STABLE)) { + if (is_timeout(start, 20 * MSECOND)) { + dev_err(host->mci.hw_dev, "SDHCI clock stable timeout\n"); + return; + } + } + + /* enable bus clock */ + dove_sdhci_writew(host, SDHCI_CLOCK_CONTROL, val | SDHCI_SDCLOCK_EN); +} + +static int dove_sdhci_mci_init(struct mci_host *mci, struct device_d *dev) +{ + u64 start; + struct dove_sdhci *host = priv_from_mci_host(mci); + + /* reset sdhci controller */ + dove_sdhci_writeb(host, SDHCI_SOFTWARE_RESET, SDHCI_RESET_ALL); + + /* wait for reset completion */ + start = get_time_ns(); + while (1) { + if ((dove_sdhci_readb(host, SDHCI_SOFTWARE_RESET) & + SDHCI_RESET_ALL) == 0) + break; + if (is_timeout(start, 100 * MSECOND)) { + dev_err(dev, "SDHCI reset timeout\n"); + return -ETIMEDOUT; + } + } + + dove_sdhci_writel(host, SDHCI_INT_STATUS, ~0); + dove_sdhci_writel(host, SDHCI_INT_ENABLE, ~0); + dove_sdhci_writel(host, SDHCI_SIGNAL_ENABLE, ~0); + + return 0; +} + +static void dove_sdhci_set_mci_caps(struct dove_sdhci *host) +{ + u16 caps[2]; + + caps[0] = dove_sdhci_readw(host, SDHCI_CAPABILITIES); + caps[1] = dove_sdhci_readw(host, SDHCI_CAPABILITIES_1); + + if (caps[1] & SDHCI_HOSTCAP_VOLTAGE_180) + host->mci.voltages |= MMC_VDD_165_195; + if (caps[1] & SDHCI_HOSTCAP_VOLTAGE_300) + host->mci.voltages |= MMC_VDD_29_30 | MMC_VDD_30_31; + if (caps[1] & SDHCI_HOSTCAP_VOLTAGE_330) + host->mci.voltages |= MMC_VDD_32_33 | MMC_VDD_33_34; + + if (caps[1] & SDHCI_HOSTCAP_HIGHSPEED) + host->mci.host_caps |= (MMC_CAP_MMC_HIGHSPEED_52MHZ | + MMC_CAP_MMC_HIGHSPEED | + MMC_CAP_SD_HIGHSPEED); + + /* parse board supported bus width capabilities */ + mci_of_parse(&host->mci); + + /* limit bus widths to controller capabilities */ + if ((caps[1] & SDHCI_HOSTCAP_8BIT) == 0) + host->mci.host_caps &= ~MMC_CAP_8_BIT_DATA; +} + +static int dove_sdhci_detect(struct device_d *dev) +{ + struct dove_sdhci *host = dev->priv; + return mci_detect_card(&host->mci); +} + +static int dove_sdhci_probe(struct device_d *dev) +{ + struct dove_sdhci *host; + int ret; + + host = xzalloc(sizeof(*host)); + host->base = dev_request_mem_region(dev, 0); + host->mci.max_req_size = 0x8000; + host->mci.hw_dev = dev; + host->mci.send_cmd = dove_sdhci_mci_send_cmd; + host->mci.set_ios = dove_sdhci_mci_set_ios; + host->mci.init = dove_sdhci_mci_init; + host->mci.f_max = 50000000; + host->mci.f_min = host->mci.f_max / 256; + dev->priv = host; + dev->detect = dove_sdhci_detect; + + dove_sdhci_set_mci_caps(host); + + ret = mci_register(&host->mci); + if (ret) + free(host); + return ret; +} + +static struct of_device_id dove_sdhci_dt_ids[] = { + { .compatible = "marvell,dove-sdhci", }, + { } +}; + +static struct driver_d dove_sdhci_driver = { + .name = "dove-sdhci", + .probe = dove_sdhci_probe, + .of_compatible = DRV_OF_COMPAT(dove_sdhci_dt_ids), +}; +device_platform_driver(dove_sdhci_driver); diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index b173a173b1..3da1c261a9 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -984,7 +984,7 @@ static int mci_startup_sd(struct mci *mci) mci_setup_cmd(&cmd, SD_CMD_APP_SET_BUS_WIDTH, 2, MMC_RSP_R1); err = mci_send_cmd(mci, &cmd, NULL); if (err) { - dev_dbg(&mci->dev, "Changing SD bus width failed: %d\n", err); + dev_warn(&mci->dev, "Changing SD bus width failed: %d\n", err); /* TODO continue with 1 bit? */ return err; } @@ -1041,8 +1041,11 @@ static int mci_startup_mmc(struct mci *mci) err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, ext_csd_bits[idx]); - if (err) + if (err) { + if (idx == 0) + dev_warn(&mci->dev, "Changing MMC bus width failed: %d\n", err); continue; + } mci_set_bus_width(mci, bus_widths[idx]); @@ -1051,7 +1054,7 @@ static int mci_startup_mmc(struct mci *mci) break; } - return 0; + return err; } /** @@ -1693,7 +1696,7 @@ static int mci_card_probe(struct mci *mci) rc = mci_startup(mci); if (rc) { - dev_dbg(&mci->dev, "Card's startup fails with %d\n", rc); + dev_warn(&mci->dev, "Card's startup fails with %d\n", rc); goto on_error; } diff --git a/drivers/mci/sdhci.h b/drivers/mci/sdhci.h index 82a692e732..90595e6433 100644 --- a/drivers/mci/sdhci.h +++ b/drivers/mci/sdhci.h @@ -3,21 +3,80 @@ #define SDHCI_DMA_ADDRESS 0x00 #define SDHCI_BLOCK_SIZE__BLOCK_COUNT 0x04 +#define SDHCI_BLOCK_SIZE 0x04 +#define SDHCI_DMA_BOUNDARY_512K SDHCI_DMA_BOUNDARY(7) +#define SDHCI_DMA_BOUNDARY_256K SDHCI_DMA_BOUNDARY(6) +#define SDHCI_DMA_BOUNDARY_128K SDHCI_DMA_BOUNDARY(5) +#define SDHCI_DMA_BOUNDARY_64K SDHCI_DMA_BOUNDARY(4) +#define SDHCI_DMA_BOUNDARY_32K SDHCI_DMA_BOUNDARY(3) +#define SDHCI_DMA_BOUNDARY_16K SDHCI_DMA_BOUNDARY(2) +#define SDHCI_DMA_BOUNDARY_8K SDHCI_DMA_BOUNDARY(1) +#define SDHCI_DMA_BOUNDARY_4K SDHCI_DMA_BOUNDARY(0) +#define SDHCI_DMA_BOUNDARY(x) (((x) & 0x7) << 12) +#define SDHCI_TRANSFER_BLOCK_SIZE(x) ((x) & 0xfff) +#define SDHCI_BLOCK_COUNT 0x06 #define SDHCI_ARGUMENT 0x08 #define SDHCI_TRANSFER_MODE__COMMAND 0x0c +#define SDHCI_TRANSFER_MODE 0x0c +#define SDHCI_MULTIPLE_BLOCKS BIT(5) +#define SDHCI_DATA_TO_HOST BIT(4) +#define SDHCI_BLOCK_COUNT_EN BIT(1) +#define SDHCI_DMA_EN BIT(0) +#define SDHCI_COMMAND 0x0e +#define SDHCI_CMD_INDEX(c) (((c) & 0x3f) << 8) +#define SDHCI_DATA_PRESENT BIT(5) +#define SDHCI_CMD_INDEX_CHECK_EN BIT(4) +#define SDHCI_CMD_CRC_CHECK_EN BIT(3) +#define SDHCI_RESP_TYPE_48_BUSY 3 +#define SDHCI_RESP_TYPE_48 2 +#define SDHCI_RESP_TYPE_136 1 +#define SDHCI_RESP_NONE 0 #define SDHCI_RESPONSE_0 0x10 #define SDHCI_RESPONSE_1 0x14 #define SDHCI_RESPONSE_2 0x18 #define SDHCI_RESPONSE_3 0x1c #define SDHCI_BUFFER 0x20 #define SDHCI_PRESENT_STATE 0x24 +#define SDHCI_CMD_INHIBIT_DATA BIT(1) +#define SDHCI_CMD_INHIBIT_CMD BIT(0) +#define SDHCI_PRESENT_STATE1 0x26 #define SDHCI_HOST_CONTROL__POWER_CONTROL__BLOCK_GAP_CONTROL 0x28 +#define SDHCI_HOST_CONTROL 0x28 +#define SDHCI_DATA_WIDTH_8BIT BIT(5) +#define SDHCI_HIGHSPEED_EN BIT(2) +#define SDHCI_DATA_WIDTH_4BIT BIT(1) +#define SDHCI_POWER_CONTROL 0x29 +#define SDHCI_BUS_VOLTAGE_330 SDHCI_BUS_VOLTAGE(7) +#define SDHCI_BUS_VOLTAGE(v) ((v) << 1) +#define SDHCI_BUS_POWER_EN BIT(0) #define SDHCI_CLOCK_CONTROL__TIMEOUT_CONTROL__SOFTWARE_RESET 0x2c +#define SDHCI_CLOCK_CONTROL 0x2c +#define SDHCI_FREQ_SEL(x) (((x) & 0xff) << 8) +#define SDHCI_SDCLOCK_EN BIT(2) +#define SDHCI_INTCLOCK_STABLE BIT(1) +#define SDHCI_INTCLOCK_EN BIT(0) +#define SDHCI_TIMEOUT_CONTROL 0x2e +#define SDHCI_SOFTWARE_RESET 0x2f +#define SDHCI_RESET_ALL BIT(0) #define SDHCI_INT_STATUS 0x30 +#define SDHCI_INT_NORMAL_STATUS 0x30 +#define SDHCI_INT_ERROR BIT(15) +#define SDHCI_INT_DMA BIT(3) +#define SDHCI_INT_XFER_COMPLETE BIT(1) +#define SDHCI_INT_CMD_COMPLETE BIT(0) +#define SDHCI_INT_ERROR_STATUS 0x32 #define SDHCI_INT_ENABLE 0x34 #define SDHCI_SIGNAL_ENABLE 0x38 #define SDHCI_ACMD12_ERR__HOST_CONTROL2 0x3C #define SDHCI_CAPABILITIES 0x40 +#define SDHCI_CAPABILITIES_1 0x42 +#define SDHCI_HOSTCAP_VOLTAGE_180 BIT(10) +#define SDHCI_HOSTCAP_VOLTAGE_300 BIT(9) +#define SDHCI_HOSTCAP_VOLTAGE_330 BIT(8) +#define SDHCI_HOSTCAP_HIGHSPEED BIT(5) +#define SDHCI_HOSTCAP_8BIT BIT(2) + +#define SDHCI_SPEC_200_MAX_CLK_DIVIDER 256 #define SDHCI_MMC_BOOT 0xC4 #define COMMAND_CMD(x) ((x & 0x3f) << 24) diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c index 1eb8dd36d8..1950ee87ee 100644 --- a/drivers/mtd/core.c +++ b/drivers/mtd/core.c @@ -449,13 +449,13 @@ static struct file_operations mtd_ops = { .lseek = dev_lseek_default, }; -static int mtd_partition_set(struct device_d *dev, struct param_d *p, const char *val) +static int mtd_partition_set(struct param_d *p, void *priv) { - struct mtd_info *mtd = container_of(dev, struct mtd_info, class_dev); + struct mtd_info *mtd = priv; struct mtd_info *mtdpart, *tmp; int ret; - if (!val) + if (!mtd->partition_string) return -EINVAL; list_for_each_entry_safe(mtdpart, tmp, &mtd->partitions, partitions_entry) { @@ -464,7 +464,7 @@ static int mtd_partition_set(struct device_d *dev, struct param_d *p, const char return ret; } - return cmdlinepart_do_parse(mtd->cdev.name, val, mtd->size, CMDLINEPART_ADD_DEVNAME); + return cmdlinepart_do_parse(mtd->cdev.name, mtd->partition_string, mtd->size, CMDLINEPART_ADD_DEVNAME); } static char *print_size(uint64_t s) @@ -530,18 +530,18 @@ static int print_parts(char *buf, int bufsize, struct mtd_info *mtd) return ret; } -static const char *mtd_partition_get(struct device_d *dev, struct param_d *p) +static int mtd_partition_get(struct param_d *p, void *priv) { - struct mtd_info *mtd = container_of(dev, struct mtd_info, class_dev); + struct mtd_info *mtd = priv; int len = 0; - free(p->value); + free(mtd->partition_string); len = print_parts(NULL, 0, mtd); - p->value = xzalloc(len + 1); - print_parts(p->value, len + 1, mtd); + mtd->partition_string = xzalloc(len + 1); + print_parts(mtd->partition_string, len + 1, mtd); - return p->value; + return 0; } static int mtd_part_compare(struct list_head *a, struct list_head *b) @@ -637,10 +637,10 @@ int add_mtd_device(struct mtd_info *mtd, const char *devname, int device_id) mtd->cdev.mtd = mtd; if (IS_ENABLED(CONFIG_PARAMETER)) { - dev_add_param_llint_ro(&mtd->class_dev, "size", mtd->size, "%llu"); - dev_add_param_int_ro(&mtd->class_dev, "erasesize", mtd->erasesize, "%u"); - dev_add_param_int_ro(&mtd->class_dev, "writesize", mtd->writesize, "%u"); - dev_add_param_int_ro(&mtd->class_dev, "oobsize", mtd->oobsize, "%u"); + dev_add_param_uint64_ro(&mtd->class_dev, "size", &mtd->size, "%llu"); + dev_add_param_uint32_ro(&mtd->class_dev, "erasesize", &mtd->erasesize, "%u"); + dev_add_param_uint32_ro(&mtd->class_dev, "writesize", &mtd->writesize, "%u"); + dev_add_param_uint32_ro(&mtd->class_dev, "oobsize", &mtd->oobsize, "%u"); } ret = devfs_create(&mtd->cdev); @@ -667,7 +667,7 @@ int add_mtd_device(struct mtd_info *mtd, const char *devname, int device_id) mtd->cdev_bb = mtd_add_bb(mtd, NULL); if (mtd->parent && !mtd->master) { - dev_add_param(&mtd->class_dev, "partitions", mtd_partition_set, mtd_partition_get, 0); + dev_add_param_string(&mtd->class_dev, "partitions", mtd_partition_set, mtd_partition_get, &mtd->partition_string, mtd); of_parse_partitions(&mtd->cdev, mtd->parent->device_node); if (IS_ENABLED(CONFIG_OFDEVICE) && mtd->parent->device_node) { mtd->of_path = xstrdup(mtd->parent->device_node->full_name); diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index ceb2bb7215..d9f79474cd 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -3853,25 +3853,40 @@ static int mtd_set_erasebad(struct param_d *param, void *priv) return 0; } -static const char *mtd_get_bbt_type(struct device_d *dev, struct param_d *p) +enum bbt_type { + BBT_TYPE_NONE = 0, + BBT_TYPE_FLASHBASED, + BBT_TYPE_MEMORYBASED, +}; + +static const char *bbt_type_strings[] = { + [BBT_TYPE_NONE] = "none", + [BBT_TYPE_FLASHBASED] = "flashbased", + [BBT_TYPE_MEMORYBASED] = "memorybased", +}; + +static int mtd_get_bbt_type(struct param_d *p, void *priv) { - struct mtd_info *mtd = container_of(dev, struct mtd_info, class_dev); + struct mtd_info *mtd = priv; struct nand_chip *chip = mtd->priv; - const char *str; + enum bbt_type type; if (!chip->bbt) - str = "none"; + type = BBT_TYPE_NONE; else if ((chip->bbt_td && chip->bbt_td->pages[0] != -1) || (chip->bbt_md && chip->bbt_md->pages[0] != -1)) - str = "flashbased"; + type = BBT_TYPE_FLASHBASED; else - str = "memorybased"; + type = BBT_TYPE_MEMORYBASED; + + chip->bbt_type = type; - return str; + return 0; } int add_mtd_nand_device(struct mtd_info *mtd, char *devname) { + struct nand_chip *chip = mtd->priv; int ret; ret = add_mtd_device(mtd, devname, DEVICE_ID_DYNAMIC); @@ -3882,7 +3897,10 @@ int add_mtd_nand_device(struct mtd_info *mtd, char *devname) dev_add_param_bool(&mtd->class_dev, "erasebad", mtd_set_erasebad, NULL, &mtd->p_allow_erasebad, mtd); - dev_add_param(&mtd->class_dev, "bbt", NULL, mtd_get_bbt_type, 0); + dev_add_param_enum(&mtd->class_dev, "bbt", NULL, mtd_get_bbt_type, + &chip->bbt_type, bbt_type_strings, + ARRAY_SIZE(bbt_type_strings), + mtd); return ret; } diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c index c35b63f2fd..0e64fe1671 100644 --- a/drivers/mtd/peb.c +++ b/drivers/mtd/peb.c @@ -76,11 +76,11 @@ static int mtd_peb_emulate_erase_failure(void) #ifdef CONFIG_MTD_PEB_DEBUG static int mtd_peb_debug_init(void) { - globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_bitflip", + globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_bitflip", &__mtd_peb_emulate_bitflip, "%u"); - globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_write_failure", + globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_write_failure", &__mtd_peb_emulate_write_failure, "%u"); - globalvar_add_simple_int("mtd_peb.mtd_peb_emulate_erase_failures", + globalvar_add_simple_uint32("mtd_peb.mtd_peb_emulate_erase_failures", &__mtd_peb_emulate_erase_failures, "%u"); globalvar_add_simple_bool("mtd_peb.mtd_peb_chk_io", &__mtd_peb_chk_io); diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c index 680f30f707..6269668187 100644 --- a/drivers/mtd/spi-nor/cadence-quadspi.c +++ b/drivers/mtd/spi-nor/cadence-quadspi.c @@ -58,7 +58,7 @@ struct cqspi_st { unsigned int irq_mask; int current_cs; unsigned int master_ref_clk_hz; - unsigned int ext_decoder; + unsigned int is_decoded_cs; unsigned int fifo_depth; struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT]; bool no_reconfig; @@ -903,7 +903,7 @@ static void cqspi_switch_cs(struct cqspi_st *cqspi, unsigned int cs) writel(reg, reg_base + CQSPI_REG_SIZE); /* configure the chip select */ - cqspi_chipselect(cqspi, cs, cqspi->ext_decoder); + cqspi_chipselect(cqspi, cs, cqspi->is_decoded_cs); cqspi_controller_enable(cqspi); } @@ -1020,12 +1020,9 @@ static int cqspi_parse_dt(struct cqspi_st *cqspi) struct device_node *np = cqspi->dev->device_node; struct device_d *dev = cqspi->dev; - if (of_property_read_u32(np, "ext-decoder", &cqspi->ext_decoder)) { - dev_err(dev, "couldn't determine ext-decoder\n"); - return -ENXIO; - } + cqspi->is_decoded_cs = of_property_read_bool(np, "cdns,is-decoded-cs"); - if (of_property_read_u32(np, "fifo-depth", &cqspi->fifo_depth)) { + if (of_property_read_u32(np, "cdns,fifo-depth", &cqspi->fifo_depth)) { dev_err(dev, "couldn't determine fifo-depth\n"); return -ENXIO; } @@ -1123,7 +1120,7 @@ static int cqspi_probe(struct device_d *dev) dev->priv = cqspi; if (pdata) { - cqspi->ext_decoder = pdata->ext_decoder; + cqspi->is_decoded_cs = pdata->is_decoded_cs; cqspi->fifo_depth = pdata->fifo_depth; } else { ret = cqspi_parse_dt(cqspi); @@ -1133,7 +1130,7 @@ static int cqspi_probe(struct device_d *dev) } } - cqspi->qspi_clk = clk_get(dev, "qspi_clk"); + cqspi->qspi_clk = clk_get(dev, NULL); if (IS_ERR(cqspi->qspi_clk)) { dev_err(dev, "cannot get qspi clk\n"); ret = PTR_ERR(cqspi->qspi_clk); diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 2ea66ed067..40fa890c9e 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -656,17 +656,17 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ubi_msg(ubi, "available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d", ubi->avail_pebs, ubi->rsvd_pebs, ubi->beb_rsvd_pebs); - dev_add_param_int_ro(&ubi->dev, "peb_size", ubi->peb_size, "%d"); - dev_add_param_int_ro(&ubi->dev, "leb_size", ubi->leb_size, "%d"); - dev_add_param_int_ro(&ubi->dev, "vid_header_offset", ubi->vid_hdr_offset, "%d"); - dev_add_param_int_ro(&ubi->dev, "min_io_size", ubi->min_io_size, "%d"); - dev_add_param_int_ro(&ubi->dev, "sub_page_size", ubi->hdrs_min_io_size, "%d"); - dev_add_param_int_ro(&ubi->dev, "good_peb_count", ubi->good_peb_count, "%d"); - dev_add_param_int_ro(&ubi->dev, "bad_peb_count", ubi->bad_peb_count, "%d"); - dev_add_param_int_ro(&ubi->dev, "max_erase_counter", ubi->max_ec, "%d"); - dev_add_param_int_ro(&ubi->dev, "mean_erase_counter", ubi->mean_ec, "%d"); - dev_add_param_int_ro(&ubi->dev, "available_pebs", ubi->avail_pebs, "%d"); - dev_add_param_int_ro(&ubi->dev, "reserved_pebs", ubi->rsvd_pebs, "%d"); + dev_add_param_uint32_ro(&ubi->dev, "peb_size", &ubi->peb_size, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "leb_size", &ubi->leb_size, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "vid_header_offset", &ubi->vid_hdr_offset, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "min_io_size", &ubi->min_io_size, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "sub_page_size", &ubi->hdrs_min_io_size, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "good_peb_count", &ubi->good_peb_count, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "bad_peb_count", &ubi->bad_peb_count, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "max_erase_counter", &ubi->max_ec, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "mean_erase_counter", &ubi->mean_ec, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "available_pebs", &ubi->avail_pebs, "%u"); + dev_add_param_uint32_ro(&ubi->dev, "reserved_pebs", &ubi->rsvd_pebs, "%u"); ubi_devices[ubi_num] = ubi; diff --git a/drivers/net/dm9k.c b/drivers/net/dm9k.c index 25f08602f6..c99d188ded 100644 --- a/drivers/net/dm9k.c +++ b/drivers/net/dm9k.c @@ -737,7 +737,7 @@ static int dm9000_parse_dt(struct device_d *dev, struct dm9k *priv) if (!IS_ENABLED(CONFIG_OFDEVICE) || !np) return -ENODEV; - if (of_find_property(np, "davicom,no-eeprom", NULL)) { + if (of_property_read_bool(np, "davicom,no-eeprom")) { priv->srom = 0; } else { priv->srom = 1; diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 41bf018141..012b90e834 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -330,8 +330,8 @@ static int mdio_bus_probe(struct device_d *_dev) of_set_phy_supported(dev); dev->advertising = dev->supported; - dev_add_param_int_ro(&dev->dev, "phy_addr", dev->addr, "%d"); - dev_add_param_int_ro(&dev->dev, "phy_id", dev->phy_id, "0x%08x"); + dev_add_param_uint32_ro(&dev->dev, "phy_addr", &dev->addr, "%u"); + dev_add_param_uint32_ro(&dev->dev, "phy_id", &dev->phy_id, "0x%08x"); dev->cdev.name = xasprintf("mdio%d-phy%02x", dev->bus->dev.id, diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index a9eb865358..cfa34a2f2a 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -492,10 +492,6 @@ static int rtl8139_eth_send(struct eth_device *edev, void *packet, return 0; } -static const u16 rtl8139_intr_mask = - PCIErr | PCSTimeout | RxUnderrun | RxOverflow | RxFIFOOver | - TxErr | TxOK | RxErr | RxOK; - static int rtl8139_eth_rx(struct eth_device *edev) { struct rtl8139_priv *priv = edev->priv; diff --git a/drivers/of/base.c b/drivers/of/base.c index 6632f4d9dd..c9bdd91810 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1090,19 +1090,14 @@ int of_property_write_u8_array(struct device_node *np, size_t sz) { struct property *prop = of_find_property(np, propname, NULL); - u8 *val; if (prop) of_delete_property(prop); - prop = of_new_property(np, propname, NULL, sizeof(*val) * sz); + prop = of_new_property(np, propname, values, sizeof(*values) * sz); if (!prop) return -ENOMEM; - val = prop->value; - while (sz--) - *val++ = *values++; - return 0; } @@ -1807,12 +1802,7 @@ struct property *of_new_property(struct device_node *node, const char *name, struct property *prop; prop = xzalloc(sizeof(*prop)); - prop->name = strdup(name); - if (!prop->name) { - free(prop); - return NULL; - } - + prop->name = xstrdup(name); prop->length = len; prop->value = xzalloc(len); diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 086573fc1a..9b54e44674 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -77,19 +77,15 @@ EXPORT_SYMBOL_GPL(of_get_phy_mode); */ const void *of_get_mac_address(struct device_node *np) { - struct property *pp; + const void *p; + int len, i; + const char *str[] = { "mac-address", "local-mac-address", "address" }; - pp = of_find_property(np, "mac-address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; - - pp = of_find_property(np, "local-mac-address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; - - pp = of_find_property(np, "address", NULL); - if (pp && (pp->length == 6) && is_valid_ether_addr(pp->value)) - return pp->value; + for (i = 0; i < ARRAY_SIZE(str); i++) { + p = of_get_property(np, str[i], &len); + if (p && (len == 6) && is_valid_ether_addr(p)) + return p; + } return NULL; } diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index ee65619c4e..80fade0611 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c @@ -99,12 +99,12 @@ int pwmchip_add(struct pwm_chip *chip, struct device_d *dev) list_add_tail(&pwm->node, &pwm_list); - p = dev_add_param_int(&pwm->dev, "duty_ns", set_duty_period_ns, + p = dev_add_param_uint32(&pwm->dev, "duty_ns", set_duty_period_ns, NULL, &pwm->chip->duty_ns, "%u", pwm); if (IS_ERR(p)) return PTR_ERR(p); - p = dev_add_param_int(&pwm->dev, "period_ns", set_duty_period_ns, + p = dev_add_param_uint32(&pwm->dev, "period_ns", set_duty_period_ns, NULL, &pwm->chip->period_ns, "%u", pwm); if (IS_ERR(p)) return PTR_ERR(p); diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 99412b07e2..5650098a0a 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -118,13 +118,13 @@ static void spi_of_register_slaves(struct spi_master *master) chip.name = xstrdup(n->name); chip.bus_num = master->bus_num; /* Mode (clock phase/polarity/etc.) */ - if (of_find_property(n, "spi-cpha", NULL)) + if (of_property_read_bool(n, "spi-cpha")) chip.mode |= SPI_CPHA; - if (of_find_property(n, "spi-cpol", NULL)) + if (of_property_read_bool(n, "spi-cpol")) chip.mode |= SPI_CPOL; - if (of_find_property(n, "spi-cs-high", NULL)) + if (of_property_read_bool(n, "spi-cs-high")) chip.mode |= SPI_CS_HIGH; - if (of_find_property(n, "spi-3wire", NULL)) + if (of_property_read_bool(n, "spi-3wire")) chip.mode |= SPI_3WIRE; of_property_read_u32(n, "spi-max-frequency", &chip.max_speed_hz); diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index aba2da0ad3..9170ba4d53 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c @@ -447,19 +447,19 @@ int usb_new_device(struct usb_device *dev) goto err_out; } - dev_add_param_int_ro(&dev->dev, "iManufacturer", - dev->descriptor->iManufacturer, "%d"); - dev_add_param_int_ro(&dev->dev, "iProduct", - dev->descriptor->iProduct, "%d"); - dev_add_param_int_ro(&dev->dev, "iSerialNumber", - dev->descriptor->iSerialNumber, "%d"); + dev_add_param_uint32_fixed(&dev->dev, "iManufacturer", + dev->descriptor->iManufacturer, "%u"); + dev_add_param_uint32_fixed(&dev->dev, "iProduct", + dev->descriptor->iProduct, "%u"); + dev_add_param_uint32_fixed(&dev->dev, "iSerialNumber", + dev->descriptor->iSerialNumber, "%u"); dev_add_param_fixed(&dev->dev, "iSerialNumber", str); dev_add_param_fixed(&dev->dev, "Manufacturer", dev->mf); dev_add_param_fixed(&dev->dev, "Product", dev->prod); dev_add_param_fixed(&dev->dev, "SerialNumber", dev->serial); - dev_add_param_int_ro(&dev->dev, "idVendor", + dev_add_param_uint32_fixed(&dev->dev, "idVendor", dev->descriptor->idVendor, "%04x"); - dev_add_param_int_ro(&dev->dev, "idProduct", + dev_add_param_uint32_fixed(&dev->dev, "idProduct", dev->descriptor->idProduct, "%04x"); list_add_tail(&dev->list, &usb_device_list); dev_count++; diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index ef5f7ec6e0..598637619d 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -758,6 +758,9 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req, const char *cmd copy: ret = copy_file(FASTBOOT_TMPFILE, filename, 1); + + unlink(FASTBOOT_TMPFILE); + if (ret) { fastboot_tx_print(f_fb, "FAILwrite partition: %s", strerror(-ret)); return; diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c index 4f001e102f..ed99b53df7 100644 --- a/drivers/usb/gadget/udc-core.c +++ b/drivers/usb/gadget/udc-core.c @@ -187,9 +187,9 @@ int usb_add_gadget_udc_release(struct device_d *parent, struct usb_gadget *gadge if (ret) goto err2; - dev_add_param_int(&gadget->dev, "product", NULL, NULL, + dev_add_param_uint32(&gadget->dev, "product", NULL, NULL, &gadget->product_id, "0x%04x", NULL); - dev_add_param_int(&gadget->dev, "vendor", NULL, NULL, + dev_add_param_uint32(&gadget->dev, "vendor", NULL, NULL, &gadget->vendor_id, "0x%04x", NULL); gadget->manufacturer = xstrdup("barebox"); dev_add_param_string(&gadget->dev, "manufacturer", NULL, NULL, diff --git a/drivers/video/backlight.c b/drivers/video/backlight.c index ddde6f8523..09c0e47af6 100644 --- a/drivers/video/backlight.c +++ b/drivers/video/backlight.c @@ -70,7 +70,7 @@ int backlight_register(struct backlight_device *bl) if (ret) return ret; - dev_add_param_int(&bl->dev, "brightness", backlight_brightness_set, + dev_add_param_uint32(&bl->dev, "brightness", backlight_brightness_set, NULL, &bl->brightness, "%d", bl); list_add_tail(&bl->list, &backlights); diff --git a/drivers/video/imx-ipu-fb.c b/drivers/video/imx-ipu-fb.c index 7c3a800149..9cc7a911ea 100644 --- a/drivers/video/imx-ipu-fb.c +++ b/drivers/video/imx-ipu-fb.c @@ -978,7 +978,7 @@ static int sdc_fb_register_overlay(struct ipu_fb_info *fbi, void *fb) return ret; } - dev_add_param_int(&overlay->dev, "alpha", sdc_alpha_set, + dev_add_param_uint32(&overlay->dev, "alpha", sdc_alpha_set, NULL, &fbi->alpha, "%u", overlay); return 0; diff --git a/drivers/video/imx.c b/drivers/video/imx.c index 78cb5c0ca2..947f8d5349 100644 --- a/drivers/video/imx.c +++ b/drivers/video/imx.c @@ -530,7 +530,7 @@ static int imxfb_register_overlay(struct imxfb_info *fbi, void *fb) return ret; } - dev_add_param_int(&overlay->dev, "alpha", imxfb_alpha_set, + dev_add_param_uint32(&overlay->dev, "alpha", imxfb_alpha_set, NULL, &fbi->alpha, "%u", overlay); return 0; diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c index 6a5bf62a36..20f9354a18 100644 --- a/drivers/video/of_display_timing.c +++ b/drivers/video/of_display_timing.c @@ -188,22 +188,3 @@ entryfail: return NULL; } EXPORT_SYMBOL_GPL(of_get_display_timings); - -/** - * of_display_timings_exist - check if a display-timings node is provided - * @np: device_node with the timing - **/ -int of_display_timings_exist(struct device_node *np) -{ - struct device_node *timings_np; - - if (!np) - return -EINVAL; - - timings_np = of_parse_phandle(np, "display-timings", 0); - if (!timings_np) - return -EINVAL; - - return 1; -} -EXPORT_SYMBOL_GPL(of_display_timings_exist); diff --git a/dts/Bindings/pci/hisilicon-pcie.txt b/dts/Bindings/pci/hisilicon-pcie.txt index b7fa3b9798..a339dbb154 100644 --- a/dts/Bindings/pci/hisilicon-pcie.txt +++ b/dts/Bindings/pci/hisilicon-pcie.txt @@ -44,13 +44,19 @@ Hip05 Example (note that Hip06 is the same except compatible): }; HiSilicon Hip06/Hip07 PCIe host bridge DT (almost-ECAM) description. + +Some BIOSes place the host controller in a mode where it is ECAM +compliant for all devices other than the root complex. In such cases, +the host controller should be described as below. + The properties and their meanings are identical to those described in host-generic-pci.txt except as listed below. Properties of the host controller node that differ from host-generic-pci.txt: -- compatible : Must be "hisilicon,pcie-almost-ecam" +- compatible : Must be "hisilicon,hip06-pcie-ecam", or + "hisilicon,hip07-pcie-ecam" - reg : Two entries: First the ECAM configuration space for any other bus underneath the root bus. Second, the base @@ -59,7 +65,7 @@ host-generic-pci.txt: Example: pcie0: pcie@a0090000 { - compatible = "hisilicon,pcie-almost-ecam"; + compatible = "hisilicon,hip06-pcie-ecam"; reg = <0 0xb0000000 0 0x2000000>, /* ECAM configuration space */ <0 0xa0090000 0 0x10000>; /* host bridge registers */ bus-range = <0 31>; diff --git a/dts/src/arm/am335x-baltos.dtsi b/dts/src/arm/am335x-baltos.dtsi index efb5eae290..d42b98f15e 100644 --- a/dts/src/arm/am335x-baltos.dtsi +++ b/dts/src/arm/am335x-baltos.dtsi @@ -371,6 +371,8 @@ phy1: ethernet-phy@1 { reg = <7>; + eee-broken-100tx; + eee-broken-1000t; }; }; diff --git a/dts/src/arm/am335x-evmsk.dts b/dts/src/arm/am335x-evmsk.dts index 9e43c44373..9ba4b18c0c 100644 --- a/dts/src/arm/am335x-evmsk.dts +++ b/dts/src/arm/am335x-evmsk.dts @@ -672,6 +672,7 @@ ti,non-removable; bus-width = <4>; cap-power-off-card; + keep-power-in-suspend; pinctrl-names = "default"; pinctrl-0 = <&mmc2_pins>; diff --git a/dts/src/arm/dra7.dtsi b/dts/src/arm/dra7.dtsi index 2c9e56f4aa..bbfb9d5a70 100644 --- a/dts/src/arm/dra7.dtsi +++ b/dts/src/arm/dra7.dtsi @@ -283,6 +283,7 @@ device_type = "pci"; ranges = <0x81000000 0 0 0x03000 0 0x00010000 0x82000000 0 0x20013000 0x13000 0 0xffed000>; + bus-range = <0x00 0xff>; #interrupt-cells = <1>; num-lanes = <1>; linux,pci-domain = <0>; @@ -319,6 +320,7 @@ device_type = "pci"; ranges = <0x81000000 0 0 0x03000 0 0x00010000 0x82000000 0 0x30013000 0x13000 0 0xffed000>; + bus-range = <0x00 0xff>; #interrupt-cells = <1>; num-lanes = <1>; linux,pci-domain = <1>; diff --git a/dts/src/arm/imx6qdl.dtsi b/dts/src/arm/imx6qdl.dtsi index 8e90014705..6d7bf64961 100644 --- a/dts/src/arm/imx6qdl.dtsi +++ b/dts/src/arm/imx6qdl.dtsi @@ -768,12 +768,6 @@ mask = <0x60>; status = "disabled"; }; - - snvs_lpgpr: snvs-lpgpr { - compatible = "fsl,imx6q-snvs-lpgpr"; - regmap = <&snvs>; - offset = <0x68>; - }; }; epit1: epit@020d0000 { /* EPIT1 */ diff --git a/dts/src/arm/imx6sl.dtsi b/dts/src/arm/imx6sl.dtsi index eeafba04cf..cc9572ea28 100644 --- a/dts/src/arm/imx6sl.dtsi +++ b/dts/src/arm/imx6sl.dtsi @@ -655,12 +655,6 @@ mask = <0x60>; status = "disabled"; }; - - snvs_lpgpr: snvs-lpgpr { - compatible = "fsl,imx6sl-snvs-lpgpr"; - regmap = <&snvs>; - offset = <0x68>; - }; }; epit1: epit@020d0000 { diff --git a/dts/src/arm/logicpd-torpedo-som.dtsi b/dts/src/arm/logicpd-torpedo-som.dtsi index 8f9a69ca81..efe53998c9 100644 --- a/dts/src/arm/logicpd-torpedo-som.dtsi +++ b/dts/src/arm/logicpd-torpedo-som.dtsi @@ -121,7 +121,7 @@ &i2c3 { clock-frequency = <400000>; at24@50 { - compatible = "at24,24c02"; + compatible = "atmel,24c64"; readonly; reg = <0x50>; }; diff --git a/dts/src/arm/sun8i-a33.dtsi b/dts/src/arm/sun8i-a33.dtsi index 0467fb365b..306af6cadf 100644 --- a/dts/src/arm/sun8i-a33.dtsi +++ b/dts/src/arm/sun8i-a33.dtsi @@ -66,12 +66,6 @@ opp-microvolt = <1200000>; clock-latency-ns = <244144>; /* 8 32k periods */ }; - - opp@1200000000 { - opp-hz = /bits/ 64 <1200000000>; - opp-microvolt = <1320000>; - clock-latency-ns = <244144>; /* 8 32k periods */ - }; }; cpus { @@ -81,16 +75,22 @@ operating-points-v2 = <&cpu0_opp_table>; }; + cpu@1 { + operating-points-v2 = <&cpu0_opp_table>; + }; + cpu@2 { compatible = "arm,cortex-a7"; device_type = "cpu"; reg = <2>; + operating-points-v2 = <&cpu0_opp_table>; }; cpu@3 { compatible = "arm,cortex-a7"; device_type = "cpu"; reg = <3>; + operating-points-v2 = <&cpu0_opp_table>; }; }; diff --git a/dts/src/arm64/allwinner/sun50i-a64.dtsi b/dts/src/arm64/allwinner/sun50i-a64.dtsi index 1c64ea2d23..0565779e66 100644 --- a/dts/src/arm64/allwinner/sun50i-a64.dtsi +++ b/dts/src/arm64/allwinner/sun50i-a64.dtsi @@ -179,8 +179,10 @@ usbphy: phy@01c19400 { compatible = "allwinner,sun50i-a64-usb-phy"; reg = <0x01c19400 0x14>, + <0x01c1a800 0x4>, <0x01c1b800 0x4>; reg-names = "phy_ctrl", + "pmu0", "pmu1"; clocks = <&ccu CLK_USB_PHY0>, <&ccu CLK_USB_PHY1>; diff --git a/images/Makefile.imx b/images/Makefile.imx index 2563779484..cdad2e0b88 100644 --- a/images/Makefile.imx +++ b/images/Makefile.imx @@ -49,6 +49,22 @@ pblx-$(CONFIG_MACH_PCM038) += start_phytec_phycore_imx27 FILE_barebox-phytec-phycore-imx27.img = start_phytec_phycore_imx27.pblx image-$(CONFIG_MACH_PCM038) += barebox-phytec-phycore-imx27.img +# ----------------------- i.MX50 based boards --------------------------- +pblx-$(CONFIG_MACH_KINDLE_MX50) += start_imx50_kindle_d01100 +CFG_start_imx50_kindle_d01100.pblx.imximg = $(board)/kindle-mx50/flash-header-kindle-lpddr1.imxcfg +FILE_barebox-kindle-d01100.img = start_imx50_kindle_d01100.pblx.imximg +imx-barebox-$(CONFIG_MACH_KINDLE_MX50) += barebox-kindle-d01100.img + +pblx-$(CONFIG_MACH_KINDLE_MX50) += start_imx50_kindle_d01200 +CFG_start_imx50_kindle_d01200.pblx.imximg = $(board)/kindle-mx50/flash-header-kindle-lpddr1.imxcfg +FILE_barebox-kindle-d01200.img = start_imx50_kindle_d01200.pblx.imximg +imx-barebox-$(CONFIG_MACH_KINDLE_MX50) += barebox-kindle-d01200.img + +pblx-$(CONFIG_MACH_KINDLE_MX50) += start_imx50_kindle_ey21 +CFG_start_imx50_kindle_ey21.pblx.imximg = $(board)/kindle-mx50/flash-header-kindle-lpddr2.imxcfg +FILE_barebox-kindle-ey21.img = start_imx50_kindle_ey21.pblx.imximg +imx-barebox-$(CONFIG_MACH_KINDLE_MX50) += barebox-kindle-ey21.img + # ----------------------- i.MX51 based boards --------------------------- pblx-$(CONFIG_MACH_FREESCALE_MX51_PDK) += start_imx51_babbage CFG_start_imx51_babbage.pblx.imximg = $(board)/freescale-mx51-babbage/flash-header-imx51-babbage.imxcfg @@ -249,16 +265,16 @@ CFG_start_imx6sx_sabresdb.pblx.imximg = $(board)/freescale-mx6sx-sabresdb/flash- FILE_barebox-freescale-imx6sx-sabresdb.img = start_imx6sx_sabresdb.pblx.imximg image-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += barebox-freescale-imx6sx-sabresdb.img -pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard_microsom_i1 -CFG_start_hummingboard_microsom_i1.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i1.imxcfg -FILE_barebox-solidrun-hummingboard-microsom-i1.img = start_hummingboard_microsom_i1.pblx.imximg -image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard-microsom-i1.img - pblx-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += start_imx6_wandboard CFG_start_imx6_wandboard.imx-sram-img = $(board)/technexion-wandboard/flash-header-technexion-wandboard.imxcfg FILE_barebox-imx6-wandboard.img = start_imx6_wandboard.imx-sram-img image-$(CONFIG_MACH_TECHNEXION_WANDBOARD) += barebox-imx6-wandboard.img +pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard_microsom_i1 +CFG_start_hummingboard_microsom_i1.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i1.imxcfg +FILE_barebox-solidrun-hummingboard-microsom-i1.img = start_hummingboard_microsom_i1.pblx.imximg +image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard-microsom-i1.img + pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard_microsom_i2 CFG_start_hummingboard_microsom_i2.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i2.imxcfg FILE_barebox-solidrun-hummingboard-microsom-i2.img = start_hummingboard_microsom_i2.pblx.imximg @@ -274,6 +290,26 @@ CFG_start_hummingboard_microsom_i4.pblx.imximg = $(board)/solidrun-microsom/flas FILE_barebox-solidrun-hummingboard-microsom-i4.img = start_hummingboard_microsom_i4.pblx.imximg image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard-microsom-i4.img +pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard2_microsom_i1 +CFG_start_hummingboard2_microsom_i1.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i1.imxcfg +FILE_barebox-solidrun-hummingboard2-microsom-i1.img = start_hummingboard2_microsom_i1.pblx.imximg +image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard2-microsom-i1.img + +pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard2_microsom_i2 +CFG_start_hummingboard2_microsom_i2.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i2.imxcfg +FILE_barebox-solidrun-hummingboard2-microsom-i2.img = start_hummingboard2_microsom_i2.pblx.imximg +image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard2-microsom-i2.img + +pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard2_microsom_i2ex +CFG_start_hummingboard2_microsom_i2ex.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i2eX.imxcfg +FILE_barebox-solidrun-hummingboard2-microsom-i2eX.img = start_hummingboard2_microsom_i2ex.pblx.imximg +image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard2-microsom-i2eX.img + +pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_hummingboard2_microsom_i4 +CFG_start_hummingboard2_microsom_i4.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i4.imxcfg +FILE_barebox-solidrun-hummingboard2-microsom-i4.img = start_hummingboard2_microsom_i4.pblx.imximg +image-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += barebox-solidrun-hummingboard2-microsom-i4.img + pblx-$(CONFIG_MACH_SOLIDRUN_MICROSOM) += start_h100_microsom_i2ex CFG_start_h100_microsom_i2ex.pblx.imximg = $(board)/solidrun-microsom/flash-header-microsom-i2eX.imxcfg FILE_barebox-auvidea-h100-microsom-i2eX.img = start_h100_microsom_i2ex.pblx.imximg diff --git a/include/console.h b/include/console.h index 126c2e8aa3..724168e07c 100644 --- a/include/console.h +++ b/include/console.h @@ -53,7 +53,7 @@ struct console_device { struct list_head list; unsigned char f_active; - char active[4]; + char *active_string; unsigned int open_count; diff --git a/include/globalvar.h b/include/globalvar.h index df43f1fe66..aea43b193d 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -15,10 +15,9 @@ void globalvar_remove(const char *name); char *globalvar_get_match(const char *match, const char *separator); void globalvar_set_match(const char *match, const char *val); -int globalvar_add_simple_string(const char *name, char **value); -int globalvar_add_simple_int(const char *name, int *value, - const char *format); -int globalvar_add_simple_bool(const char *name, int *value); +int __globalvar_add_simple_string(const char *name, char **value); +int __globalvar_add_simple_int(const char *name, void *value, + enum param_type type, const char *format); int globalvar_add_simple_enum(const char *name, int *value, const char * const *names, int max); int globalvar_add_simple_bitmask(const char *name, unsigned long *value, @@ -39,19 +38,13 @@ static inline int globalvar_add_simple(const char *name, const char *value) return 0; } -static inline int globalvar_add_simple_string(const char *name, char **value) +static inline int __globalvar_add_simple_int(const char *name, void *value, + enum param_type type, const char *format) { return 0; } -static inline int globalvar_add_simple_int(const char *name, - int *value, const char *format) -{ - return 0; -} - -static inline int globalvar_add_simple_bool(const char *name, - int *value) +static inline int __globalvar_add_simple_string(const char *name, char **value) { return 0; } @@ -115,6 +108,96 @@ static inline void dev_param_init_from_nv(struct device_d *dev, const char *name #endif +#define DECLARE_GLOBALVAR_INT(intname, inttype, paramtype) \ + static inline int globalvar_add_simple_##intname(const char *name, \ + inttype *value, \ + const char *format) \ + { \ + return __globalvar_add_simple_int(name, value, \ + paramtype, \ + format); \ + } + +DECLARE_GLOBALVAR_INT(uint32, uint32_t, PARAM_TYPE_UINT32) +DECLARE_GLOBALVAR_INT(int32, int32_t, PARAM_TYPE_INT32) +DECLARE_GLOBALVAR_INT(uint64, uint64_t, PARAM_TYPE_UINT64) +DECLARE_GLOBALVAR_INT(int64, int64_t, PARAM_TYPE_INT64) + +static inline int globalvar_add_simple_bool(const char *name, uint32_t *value) +{ + return __globalvar_add_simple_int(name, value, PARAM_TYPE_BOOL, "%u"); +} + +static inline int globalvar_add_simple_string(const char *name, char **value) +{ + return __globalvar_add_simple_string(name, value); +} + +#define DECLARE_GLOBALVAR_INT_RO(intname, inttype, paramtype) \ + static inline int globalvar_add_simple_##intname##_ro(const char *name, \ + inttype *value, \ + const char *format) \ + { \ + return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name,\ + param_set_readonly, \ + NULL, value, \ + paramtype, \ + format, NULL)); \ + } + +DECLARE_GLOBALVAR_INT_RO(uint32, uint32_t, PARAM_TYPE_UINT32) +DECLARE_GLOBALVAR_INT_RO(int32, int32_t, PARAM_TYPE_INT32) +DECLARE_GLOBALVAR_INT_RO(uint64, uint64_t, PARAM_TYPE_UINT64) +DECLARE_GLOBALVAR_INT_RO(int64, int64_t, PARAM_TYPE_INT64) + +static inline int globalvar_add_simple_bool_ro(const char *name, uint32_t *value) +{ + return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, + param_set_readonly, NULL, + value, PARAM_TYPE_BOOL, "%u", + NULL)); +} + +static inline int globalvar_add_simple_string_ro(const char *name, char **value) +{ + return __globalvar_add_simple_string(name, value); +} + +#define DECLARE_GLOBALVAR_INT_FIXED(intname, inttype, paramtype) \ + static inline int globalvar_add_simple_##intname##_fixed(const char *name, \ + inttype value, \ + const char *format) \ + { \ + return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, \ + ERR_PTR(-EROFS), NULL, \ + &value, paramtype, \ + format, NULL)); \ + } + +DECLARE_GLOBALVAR_INT_FIXED(uint32, uint32_t, PARAM_TYPE_UINT32) +DECLARE_GLOBALVAR_INT_FIXED(int32, int32_t, PARAM_TYPE_INT32) +DECLARE_GLOBALVAR_INT_FIXED(uint64, uint64_t, PARAM_TYPE_UINT64) +DECLARE_GLOBALVAR_INT_FIXED(int64, int64_t, PARAM_TYPE_INT64) + +static inline int globalvar_add_simple_bool_fixed(const char *name, uint32_t value) +{ + return PTR_ERR_OR_ZERO(__dev_add_param_int(&global_device, name, ERR_PTR(-EROFS), + NULL, &value, PARAM_TYPE_BOOL, "%u", + NULL)); +} + +static inline int globalvar_add_simple_string_fixed(const char *name, char *value) +{ + return PTR_ERR_OR_ZERO(dev_add_param_string_fixed(&global_device, name, value)); +} + +static inline int globalvar_add_simple_enum_ro(const char *name, int *value, + const char * const *names, int max) +{ + return PTR_ERR_OR_ZERO(dev_add_param_enum_ro(&global_device, name, value, names, + max)); +} + void nv_var_set_clean(void); int nvvar_save(void); int nv_global_complete(struct string_list *sl, char *instr); diff --git a/include/libgen.h b/include/libgen.h index cd27fd11e3..71f06eb6f6 100644 --- a/include/libgen.h +++ b/include/libgen.h @@ -2,6 +2,7 @@ #define __LIBGEN_H char *basename (char *path); +char *posix_basename(char *path); char *dirname (char *path); #endif /* __LIBGEN_H */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 945e063f02..b4d2f09081 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -92,6 +92,7 @@ void __noreturn panic(const char *fmt, ...); extern unsigned long simple_strtoul(const char *,char **,unsigned int); extern long simple_strtol(const char *,char **,unsigned int); extern unsigned long long simple_strtoull(const char *,char **,unsigned int); +extern long long simple_strtoll(const char *,char **,unsigned int); /* * min()/max()/clamp() macros that also do diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index fa35c7ef39..16725ac4bc 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -226,6 +226,7 @@ struct mtd_info { struct list_head partitions; struct list_head partitions_entry; + char *partition_string; char *of_path; unsigned int of_binding; diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 66c936ee70..27538c3f42 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h @@ -540,6 +540,7 @@ struct nand_chip { struct nand_bbt_descr *badblock_pattern; void *priv; + unsigned int bbt_type; }; /* diff --git a/include/param.h b/include/param.h index 23abb52406..9637229838 100644 --- a/include/param.h +++ b/include/param.h @@ -10,9 +10,22 @@ struct device_d; typedef uint32_t IPaddr_t; +enum param_type { + PARAM_TYPE_STRING = 0, + PARAM_TYPE_INT32, + PARAM_TYPE_UINT32, + PARAM_TYPE_INT64, + PARAM_TYPE_UINT64, + PARAM_TYPE_BOOL, + PARAM_TYPE_ENUM, + PARAM_TYPE_BITMASK, + PARAM_TYPE_IPV4, + PARAM_TYPE_MAC, +}; + struct param_d { - const char* (*get)(struct device_d *, struct param_d *param); - int (*set)(struct device_d *, struct param_d *param, const char *val); + const char* (*get)(struct param_d *param); + int (*set)(struct param_d *param, const char *val); void (*info)(struct param_d *param); unsigned int flags; char *name; @@ -20,16 +33,18 @@ struct param_d { struct device_d *dev; void *driver_priv; struct list_head list; + enum param_type type; }; #ifdef CONFIG_PARAMETER +const char *get_param_type(struct param_d *param); const char *dev_get_param(struct device_d *dev, const char *name); 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); 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), + int (*set)(struct param_d *p, const char *val), + const char *(*get)(struct param_d *p), unsigned long flags); struct param_d *dev_add_param_string(struct device_d *dev, const char *name, @@ -37,15 +52,10 @@ struct param_d *dev_add_param_string(struct device_d *dev, const char *name, int (*get)(struct param_d *p, void *priv), char **value, void *priv); -struct param_d *dev_add_param_int(struct device_d *dev, const char *name, - int (*set)(struct param_d *p, void *priv), - int (*get)(struct param_d *p, void *priv), - int *value, const char *format, void *priv); - -struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, +struct param_d *__dev_add_param_int(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, void *priv); + void *value, enum param_type type, const char *format, void *priv); struct param_d *dev_add_param_enum(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), @@ -57,12 +67,6 @@ struct param_d *dev_add_param_bitmask(struct device_d *dev, const char *name, int (*get)(struct param_d *p, void *priv), unsigned long *value, const char * const *names, int max, void *priv); -struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name, - int value, const char *format); - -struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name, - long long value, const char *format); - struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), @@ -73,14 +77,13 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, int (*get)(struct param_d *p, void *priv), u8 *mac, void *priv); -int dev_add_param_fixed(struct device_d *dev, const char *name, const char *value); +struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name, const char *value); void dev_remove_param(struct param_d *p); void dev_remove_parameters(struct device_d *dev); -int dev_param_set_generic(struct device_d *dev, struct param_d *p, - const char *val); +int dev_param_set_generic(struct param_d *p, const char *val); #else static inline const char *dev_get_param(struct device_d *dev, const char *name) @@ -114,10 +117,10 @@ static inline struct param_d *dev_add_param_string(struct device_d *dev, const c return ERR_PTR(-ENOSYS); } -static inline struct param_d *dev_add_param_int(struct device_d *dev, const char *name, +static inline struct param_d *__dev_add_param_int(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, const char *format, void *priv) + void *value, enum param_type type, const char *format, void *priv) { return ERR_PTR(-ENOSYS); } @@ -139,56 +142,162 @@ static inline struct param_d *dev_add_param_bitmask(struct device_d *dev, const return ERR_PTR(-ENOSYS); } -static inline struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, +static inline struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, void *priv) + IPaddr_t *ip, void *priv) { return ERR_PTR(-ENOSYS); } -static inline struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name, - int value, const char *format) +static inline struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + u8 *mac, void *priv) { return ERR_PTR(-ENOSYS); } -static inline struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name, - long long value, const char *format) +static inline struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name, + const char *value) { return ERR_PTR(-ENOSYS); } -static inline struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, +static inline void dev_remove_param(struct param_d *p) {} + +static inline void dev_remove_parameters(struct device_d *dev) {} + +static inline int dev_param_set_generic(struct device_d *dev, struct param_d *p, + const char *val) +{ + return 0; +} +#endif + +int param_set_readonly(struct param_d *p, void *priv); + +/* + * dev_add_param_int + * dev_add_param_int32 + * dev_add_param_uint32 + * dev_add_param_int64 + * dev_add_param_uint64 + */ +#define DECLARE_PARAM_INT(intname, inttype, paramtype) \ + static inline struct param_d *dev_add_param_##intname(struct device_d *dev, const char *name, \ + int (*set)(struct param_d *p, void *priv), \ + int (*get)(struct param_d *p, void *priv), \ + inttype *value, const char *format, void *priv) \ + { \ + return __dev_add_param_int(dev, name, set, get, value, paramtype, format, priv); \ + } + +DECLARE_PARAM_INT(int, int, PARAM_TYPE_INT32) +DECLARE_PARAM_INT(int32, int32_t, PARAM_TYPE_INT32) +DECLARE_PARAM_INT(uint32, uint32_t, PARAM_TYPE_UINT32) +DECLARE_PARAM_INT(int64, int64_t, PARAM_TYPE_INT64) +DECLARE_PARAM_INT(uint64, uint64_t, PARAM_TYPE_UINT64) + +/* + * dev_add_param_int_fixed + * dev_add_param_int32_fixed + * dev_add_param_uint32_fixed + * dev_add_param_int64_fixed + * dev_add_param_uint64_fixed + */ +#define DECLARE_PARAM_INT_FIXED(intname, inttype, paramtype) \ + static inline struct param_d *dev_add_param_##intname##_fixed(struct device_d *dev, const char *name, \ + inttype value, const char *format) \ + { \ + return __dev_add_param_int(dev, name, ERR_PTR(-EROFS), NULL, &value, paramtype, format, NULL); \ + } + +DECLARE_PARAM_INT_FIXED(int, int, PARAM_TYPE_INT32) +DECLARE_PARAM_INT_FIXED(int32, int32_t, PARAM_TYPE_INT32) +DECLARE_PARAM_INT_FIXED(uint32, uint32_t, PARAM_TYPE_UINT32) +DECLARE_PARAM_INT_FIXED(int64, int64_t, PARAM_TYPE_INT64) +DECLARE_PARAM_INT_FIXED(uint64, uint64_t, PARAM_TYPE_UINT64) + +/* + * dev_add_param_int_ro + * dev_add_param_int32_ro + * dev_add_param_uint32_ro + * dev_add_param_int64_ro + * dev_add_param_uint64_ro + */ +#define DECLARE_PARAM_INT_RO(intname, inttype, paramtype) \ + static inline struct param_d *dev_add_param_##intname##_ro(struct device_d *dev, const char *name, \ + inttype *value, const char *format) \ + { \ + return __dev_add_param_int(dev, name, param_set_readonly, NULL, value, paramtype, format, NULL); \ + } + +DECLARE_PARAM_INT_RO(int, int, PARAM_TYPE_INT32) +DECLARE_PARAM_INT_RO(int32, int32_t, PARAM_TYPE_INT32) +DECLARE_PARAM_INT_RO(uint32, uint32_t, PARAM_TYPE_UINT32) +DECLARE_PARAM_INT_RO(int64, int64_t, PARAM_TYPE_INT64) +DECLARE_PARAM_INT_RO(uint64, uint64_t, PARAM_TYPE_UINT64) + +static inline struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - IPaddr_t *ip, void *priv) + uint32_t *value, void *priv) { - return ERR_PTR(-ENOSYS); + return __dev_add_param_int(dev, name, set, get, value, PARAM_TYPE_BOOL, "%u", priv); } -static inline struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, +static inline struct param_d *dev_add_param_bool_fixed(struct device_d *dev, const char *name, + uint32_t value) +{ + return __dev_add_param_int(dev, name, ERR_PTR(-EROFS), NULL, &value, PARAM_TYPE_BOOL, + "%u", NULL); +} + +static inline struct param_d *dev_add_param_bool_ro(struct device_d *dev, const char *name, + uint32_t *value) +{ + return __dev_add_param_int(dev, name, param_set_readonly, NULL, value, PARAM_TYPE_BOOL, + "%u", NULL); +} + +static inline struct param_d *dev_add_param_string_ro(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - u8 *mac, void *priv) + char **value, void *priv) { - return ERR_PTR(-ENOSYS); + return dev_add_param_string(dev, name, param_set_readonly, NULL, value, NULL); } -static inline int dev_add_param_fixed(struct device_d *dev, const char *name, const char *value) +static inline struct param_d *dev_add_param_string_fixed(struct device_d *dev, const char *name, + char *value) { - return 0; + return dev_add_param_fixed(dev, name, value); } -static inline void dev_remove_param(struct param_d *p) {} - -static inline void dev_remove_parameters(struct device_d *dev) {} +static inline struct param_d *dev_add_param_enum_ro(struct device_d *dev, const char *name, + int *value, const char * const *names, int max) +{ + return dev_add_param_enum(dev, name, param_set_readonly, NULL, + value, names, max, NULL); +} -static inline int dev_param_set_generic(struct device_d *dev, struct param_d *p, - const char *val) +static inline struct param_d *dev_add_param_bitmask_ro(struct device_d *dev, const char *name, + int (*set)(struct param_d *p, void *priv), + int (*get)(struct param_d *p, void *priv), + unsigned long *value, const char * const *names, int max, void *priv) { - return 0; + return dev_add_param_bitmask(dev, name, param_set_readonly, NULL, + value, names, max, NULL); } -#endif +/* + * unimplemented: + * dev_add_param_enum_fixed + * dev_add_param_bitmask_fixed + * dev_add_param_ip_ro + * dev_add_param_ip_fixed + * dev_add_param_mac_ro + * dev_add_param_mac_fixed + */ #endif /* PARAM_H */ diff --git a/include/platform_data/cadence_qspi.h b/include/platform_data/cadence_qspi.h index 4930edce50..ad1a680c9f 100644 --- a/include/platform_data/cadence_qspi.h +++ b/include/platform_data/cadence_qspi.h @@ -2,7 +2,7 @@ #define __INCLUDE_PLATFORM_DATA_CADENCE_QSPI_H struct cadence_qspi_platform_data { - unsigned int ext_decoder; + unsigned int is_decoded_cs; unsigned int fifo_depth; }; diff --git a/lib/libgen.c b/lib/libgen.c index 1e43cf3f29..08ef3528af 100644 --- a/lib/libgen.c +++ b/lib/libgen.c @@ -37,6 +37,29 @@ char *basename (char *path) } EXPORT_SYMBOL(basename); +/* + * There are two different versions of basename(): The GNU version implemented + * above and the POSIX version. The GNU version never modifies its argument and + * returns the empty string when path has a trailing slash, and in particular + * also when it is "/". + */ +char *posix_basename(char *path) +{ + char *fname; + + fname = path + strlen(path) - 1; + + while (*fname == '/') { + if (fname == path) + return path; + *fname = '\0'; + fname--; + } + + return basename(path); +} +EXPORT_SYMBOL(posix_basename); + char *dirname (char *path) { char *fname; diff --git a/lib/parameter.c b/lib/parameter.c index 65d6c7c0df..ab36b15591 100644 --- a/lib/parameter.c +++ b/lib/parameter.c @@ -31,6 +31,24 @@ #include <globalvar.h> #include <linux/err.h> +static const char *param_type_string[] = { + [PARAM_TYPE_STRING] = "string", + [PARAM_TYPE_INT32] = "int32", + [PARAM_TYPE_UINT32] = "uint32", + [PARAM_TYPE_INT64] = "int64", + [PARAM_TYPE_UINT64] = "uint64", + [PARAM_TYPE_BOOL] = "bool", + [PARAM_TYPE_ENUM] = "enum", + [PARAM_TYPE_BITMASK] = "bitmask", + [PARAM_TYPE_IPV4] = "ipv4", + [PARAM_TYPE_MAC] = "MAC", +}; + +const char *get_param_type(struct param_d *param) +{ + return param_type_string[param->type]; +} + struct param_d *get_param_by_name(struct device_d *dev, const char *name) { struct param_d *p; @@ -58,7 +76,7 @@ const char *dev_get_param(struct device_d *dev, const char *name) return NULL; } - return param->get(dev, param); + return param->get(param); } /** @@ -89,7 +107,7 @@ int dev_set_param(struct device_d *dev, const char *name, const char *val) return -EACCES; } - ret = param->set(dev, param, val); + ret = param->set(param, val); if (ret) errno = -ret; @@ -107,7 +125,7 @@ int dev_set_param(struct device_d *dev, const char *name, const char *val) * used during deregistration of the parameter to free the alloctated * memory. */ -int dev_param_set_generic(struct device_d *dev, struct param_d *p, +int dev_param_set_generic(struct param_d *p, const char *val) { free(p->value); @@ -119,7 +137,7 @@ int dev_param_set_generic(struct device_d *dev, struct param_d *p, return p->value ? 0 : -ENOMEM; } -static const char *param_get_generic(struct device_d *dev, struct param_d *p) +static const char *param_get_generic(struct param_d *p) { return p->value ? p->value : ""; } @@ -133,8 +151,8 @@ static int compare(struct list_head *a, struct list_head *b) } static int __dev_add_param(struct param_d *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 *p), + int (*set)(struct param_d *p, const char *val), + const char *(*get)(struct param_d *p), unsigned long flags) { if (get_param_by_name(dev, name)) @@ -176,8 +194,8 @@ static int __dev_add_param(struct param_d *param, struct device_d *dev, const ch * not use static arrays when using the generic functions. */ 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), + int (*set)(struct param_d *p, const char *val), + const char *(*get)(struct param_d *param), unsigned long flags) { struct param_d *param; @@ -200,7 +218,7 @@ struct param_d *dev_add_param(struct device_d *dev, const char *name, * @param name The name of the parameter * @param value The value of the parameter */ -int dev_add_param_fixed(struct device_d *dev, const char *name, const char *value) +struct param_d *dev_add_param_fixed(struct device_d *dev, const char *name, const char *value) { struct param_d *param; int ret; @@ -210,12 +228,12 @@ int dev_add_param_fixed(struct device_d *dev, const char *name, const char *valu ret = __dev_add_param(param, dev, name, NULL, NULL, PARAM_FLAG_RO); if (ret) { free(param); - return ret; + return ERR_PTR(ret); } param->value = strdup(value); - return 0; + return param; } struct param_string { @@ -230,7 +248,7 @@ static inline struct param_string *to_param_string(struct param_d *p) return container_of(p, struct param_string, param); } -static int param_string_set(struct device_d *dev, struct param_d *p, const char *val) +static int param_string_set(struct param_d *p, const char *val) { struct param_string *ps = to_param_string(p); int ret; @@ -255,7 +273,7 @@ static int param_string_set(struct device_d *dev, struct param_d *p, const char return ret; } -static const char *param_string_get(struct device_d *dev, struct param_d *p) +static const char *param_string_get(struct param_d *p) { struct param_string *ps = to_param_string(p); int ret; @@ -284,6 +302,7 @@ struct param_d *dev_add_param_string(struct device_d *dev, const char *name, ps->get = get; p = &ps->param; p->driver_priv = priv; + p->type = PARAM_TYPE_STRING; ret = __dev_add_param(p, dev, name, param_string_set, param_string_get, 0); if (ret) { @@ -296,10 +315,9 @@ struct param_d *dev_add_param_string(struct device_d *dev, const char *name, struct param_int { struct param_d param; - int *value; + void *value; + int dsize; const char *format; -#define PARAM_INT_FLAG_BOOL (1 << 0) - unsigned flags; int (*set)(struct param_d *p, void *priv); int (*get)(struct param_d *p, void *priv); }; @@ -309,21 +327,35 @@ static inline struct param_int *to_param_int(struct param_d *p) return container_of(p, struct param_int, param); } -static int param_int_set(struct device_d *dev, struct param_d *p, const char *val) +static int param_int_set(struct param_d *p, const char *val) { struct param_int *pi = to_param_int(p); - int value_save = *pi->value; + u8 value_save[pi->dsize]; int ret; if (!val) return -EINVAL; - if (pi->flags & PARAM_INT_FLAG_BOOL) { + memcpy(value_save, pi->value, pi->dsize); + + switch (p->type) { + case PARAM_TYPE_BOOL: ret = strtobool(val, pi->value); - if (ret) - return ret; - } else { - *pi->value = simple_strtol(val, NULL, 0); + break; + case PARAM_TYPE_INT32: + *(uint32_t *)pi->value = simple_strtol(val, NULL, 0); + break; + case PARAM_TYPE_UINT32: + *(int32_t *)pi->value = simple_strtoul(val, NULL, 0); + break; + case PARAM_TYPE_INT64: + *(int64_t *)pi->value = simple_strtoll(val, NULL, 0); + break; + case PARAM_TYPE_UINT64: + *(uint64_t *)pi->value = simple_strtoull(val, NULL, 0); + break; + default: + return -EINVAL; } if (!pi->set) @@ -331,12 +363,12 @@ static int param_int_set(struct device_d *dev, struct param_d *p, const char *va ret = pi->set(p, p->driver_priv); if (ret) - *pi->value = value_save; + memcpy(pi->value, value_save, pi->dsize); return ret; } -static const char *param_int_get(struct device_d *dev, struct param_d *p) +static const char *param_int_get(struct param_d *p) { struct param_int *pi = to_param_int(p); int ret; @@ -348,11 +380,28 @@ static const char *param_int_get(struct device_d *dev, struct param_d *p) } free(p->value); - p->value = basprintf(pi->format, *pi->value); + switch (p->type) { + case PARAM_TYPE_BOOL: + case PARAM_TYPE_INT32: + case PARAM_TYPE_UINT32: + p->value = basprintf(pi->format, *(int32_t *)pi->value); + break; + case PARAM_TYPE_INT64: + case PARAM_TYPE_UINT64: + p->value = basprintf(pi->format, *(int64_t *)pi->value); + break; + default: + return NULL; + } return p->value; } +int param_set_readonly(struct param_d *p, void *priv) +{ + return -EROFS; +} + /** * dev_add_param_int - add an integer parameter to a device * @param dev The device @@ -360,6 +409,7 @@ static const char *param_int_get(struct device_d *dev, struct param_d *p) * @param set set function * @param get get function * @param value pointer to the integer containing the value of the parameter + * @param type The variable type * @param format the printf format used to print the value * @param priv user private data, will be passed to get/set * @@ -368,22 +418,51 @@ static const char *param_int_get(struct device_d *dev, struct param_d *p) * The set function can be used as a notifer when the variable is about * to be written. Can also be used to limit the value. */ -struct param_d *dev_add_param_int(struct device_d *dev, const char *name, +struct param_d *__dev_add_param_int(struct device_d *dev, const char *name, int (*set)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv), - int *value, const char *format, void *priv) + void *value, enum param_type type, const char *format, void *priv) { struct param_int *pi; struct param_d *p; - int ret; + int ret, dsize; + + switch (type) { + case PARAM_TYPE_BOOL: + dsize = sizeof(uint32_t); + break; + case PARAM_TYPE_INT32: + dsize = sizeof(int32_t); + break; + case PARAM_TYPE_UINT32: + dsize = sizeof(uint32_t); + break; + case PARAM_TYPE_INT64: + dsize = sizeof(int64_t); + break; + case PARAM_TYPE_UINT64: + dsize = sizeof(uint64_t); + break; + default: + return ERR_PTR(-EINVAL); + } pi = xzalloc(sizeof(*pi)); - pi->value = value; + + if (IS_ERR(set)) { + pi->value = xmemdup(value, dsize); + set = param_set_readonly; + } else { + pi->value = value; + } + + pi->dsize = dsize; pi->format = format; pi->set = set; pi->get = get; p = &pi->param; p->driver_priv = priv; + p->type = type; ret = __dev_add_param(p, dev, name, param_int_set, param_int_get, 0); if (ret) { @@ -408,7 +487,7 @@ static inline struct param_enum *to_param_enum(struct param_d *p) return container_of(p, struct param_enum, param); } -static int param_enum_set(struct device_d *dev, struct param_d *p, const char *val) +static int param_enum_set(struct param_d *p, const char *val) { struct param_enum *pe = to_param_enum(p); int value_save = *pe->value; @@ -436,7 +515,7 @@ static int param_enum_set(struct device_d *dev, struct param_d *p, const char *v return ret; } -static const char *param_enum_get(struct device_d *dev, struct param_d *p) +static const char *param_enum_get(struct param_d *p) { struct param_enum *pe = to_param_enum(p); int ret; @@ -465,7 +544,7 @@ static void param_enum_info(struct param_d *p) if (pe->num_names <= 1) return; - printf(" ("); + printf(" (values: "); for (i = 0; i < pe->num_names; i++) { if (!pe->names[i] || !*pe->names[i]) @@ -493,6 +572,7 @@ struct param_d *dev_add_param_enum(struct device_d *dev, const char *name, pe->num_names = num_names; p = &pe->param; p->driver_priv = priv; + p->type = PARAM_TYPE_ENUM; ret = __dev_add_param(p, dev, name, param_enum_set, param_enum_get, 0); if (ret) { @@ -519,7 +599,7 @@ static inline struct param_bitmask *to_param_bitmask(struct param_d *p) return container_of(p, struct param_bitmask, param); } -static int param_bitmask_set(struct device_d *dev, struct param_d *p, const char *val) +static int param_bitmask_set(struct param_d *p, const char *val) { struct param_bitmask *pb = to_param_bitmask(p); void *value_save; @@ -565,7 +645,7 @@ out: return ret; } -static const char *param_bitmask_get(struct device_d *dev, struct param_d *p) +static const char *param_bitmask_get(struct param_d *p) { struct param_bitmask *pb = to_param_bitmask(p); int ret, bit; @@ -622,6 +702,7 @@ struct param_d *dev_add_param_bitmask(struct device_d *dev, const char *name, pb->num_names = max; p = &pb->param; p->driver_priv = priv; + p->type = PARAM_TYPE_BITMASK; for (i = 0; i < pb->num_names; i++) if (pb->names[i]) @@ -640,95 +721,6 @@ struct param_d *dev_add_param_bitmask(struct device_d *dev, const char *name, return &pb->param; } -/** - * dev_add_param_bool - add an boolean parameter to a device - * @param dev The device - * @param name The name of the parameter - * @param set set function - * @param get get function - * @param value pointer to the integer containing the value of the parameter - * @param priv user private data, will be passed to get/set - * - * The get function can be used as a notifier when the variable is about - * to be read. - * The set function can be used as a notifer when the variable is about - * to be written. Can also be used to limit the value. - */ -struct param_d *dev_add_param_bool(struct device_d *dev, const char *name, - int (*set)(struct param_d *p, void *priv), - int (*get)(struct param_d *p, void *priv), - int *value, void *priv) -{ - struct param_int *pi; - struct param_d *p; - - p = dev_add_param_int(dev, name, set, get, value, "%d", priv); - if (IS_ERR(p)) - return p; - - pi = to_param_int(p); - pi->flags |= PARAM_INT_FLAG_BOOL; - - return p; -} - -struct param_int_ro { - struct param_d param; - char *value; -}; - -/** - * dev_add_param_int_ro - add a read only integer parameter to a device - * @param dev The device - * @param name The name of the parameter - * @param value The value of the parameter - * @param format the printf format used to print the value - */ -struct param_d *dev_add_param_int_ro(struct device_d *dev, const char *name, - int value, const char *format) -{ - struct param_int *piro; - int ret; - - piro = xzalloc(sizeof(*piro)); - - ret = __dev_add_param(&piro->param, dev, name, NULL, NULL, PARAM_FLAG_RO); - if (ret) { - free(piro); - return ERR_PTR(ret); - } - - piro->param.value = basprintf(format, value); - - return &piro->param; -} - -/** - * dev_add_param_llint_ro - add a read only long long parameter to a device - * @param dev The device - * @param name The name of the parameter - * @param value The value of the parameter - * @param format the printf format used to print the value - */ -struct param_d *dev_add_param_llint_ro(struct device_d *dev, const char *name, - long long value, const char *format) -{ - struct param_int *piro; - int ret; - - piro = xzalloc(sizeof(*piro)); - - ret = __dev_add_param(&piro->param, dev, name, NULL, NULL, PARAM_FLAG_RO); - if (ret) { - free(piro); - return ERR_PTR(ret); - } - - piro->param.value = basprintf(format, value); - - return &piro->param; -} - struct param_ip { struct param_d param; IPaddr_t *ip; @@ -742,7 +734,7 @@ static inline struct param_ip *to_param_ip(struct param_d *p) return container_of(p, struct param_ip, param); } -static int param_ip_set(struct device_d *dev, struct param_d *p, const char *val) +static int param_ip_set(struct param_d *p, const char *val) { struct param_ip *pi = to_param_ip(p); IPaddr_t ip_save = *pi->ip; @@ -765,7 +757,7 @@ static int param_ip_set(struct device_d *dev, struct param_d *p, const char *val return ret; } -static const char *param_ip_get(struct device_d *dev, struct param_d *p) +static const char *param_ip_get(struct param_d *p) { struct param_ip *pi = to_param_ip(p); int ret; @@ -795,6 +787,7 @@ struct param_d *dev_add_param_ip(struct device_d *dev, const char *name, pi->set = set; pi->get = get; pi->param.driver_priv = priv; + pi->param.type = PARAM_TYPE_IPV4; ret = __dev_add_param(&pi->param, dev, name, param_ip_set, param_ip_get, 0); @@ -823,7 +816,7 @@ static inline struct param_mac *to_param_mac(struct param_d *p) return container_of(p, struct param_mac, param); } -static int param_mac_set(struct device_d *dev, struct param_d *p, const char *val) +static int param_mac_set(struct param_d *p, const char *val) { struct param_mac *pm = to_param_mac(p); char mac_save[6]; @@ -852,7 +845,7 @@ out: return ret; } -static const char *param_mac_get(struct device_d *dev, struct param_d *p) +static const char *param_mac_get(struct param_d *p) { struct param_mac *pm = to_param_mac(p); int ret; @@ -882,6 +875,7 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, pm->get = get; pm->param.driver_priv = priv; pm->param.value = pm->mac_str; + pm->param.type = PARAM_TYPE_MAC; ret = __dev_add_param(&pm->param, dev, name, param_mac_set, param_mac_get, 0); @@ -900,7 +894,7 @@ struct param_d *dev_add_param_mac(struct device_d *dev, const char *name, */ void dev_remove_param(struct param_d *p) { - p->set(p->dev, p, NULL); + p->set(p, NULL); list_del(&p->list); free(p->name); free(p); @@ -916,7 +910,7 @@ void dev_remove_parameters(struct device_d *dev) struct param_d *p, *n; list_for_each_entry_safe(p, n, &dev->parameters, list) { - p->set(dev, p, NULL); + p->set(p, NULL); list_del(&p->list); free(p->name); free(p); diff --git a/lib/readline_simple.c b/lib/readline_simple.c index c2960665fb..c4d3d240e5 100644 --- a/lib/readline_simple.c +++ b/lib/readline_simple.c @@ -57,19 +57,6 @@ int readline (const char *prompt, char *line, int len) col = plen; for (;;) { -#ifdef CONFIG_BOOT_RETRY_TIME - while (!tstc()) { /* while no incoming data */ - if (retry_time >= 0 && get_ticks() > endtime) - return (-2); /* timed out */ - } -#endif - -#ifdef CONFIG_SHOW_ACTIVITY - while (!tstc()) { - extern void show_activity(int arg); - show_activity(0); - } -#endif c = getchar(); /* diff --git a/lib/strtox.c b/lib/strtox.c index cfe61240cc..4b601a1b39 100644 --- a/lib/strtox.c +++ b/lib/strtox.c @@ -1,67 +1,84 @@ #include <common.h> #include <linux/ctype.h> -unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) +unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) { - unsigned long result = 0,value; + unsigned long result = 0, value; if (*cp == '0') { cp++; + if ((*cp == 'x') && isxdigit(cp[1])) { base = 16; cp++; } - if (!base) { + + if (!base) base = 8; - } } - if (!base) { + + if (!base) base = 10; - } - while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp) - ? toupper(*cp) : *cp)-'A'+10) < base) { - result = result*base + value; + + while (isxdigit(*cp) && (value = isdigit(*cp) ? + *cp - '0' : toupper(*cp) - 'A' + 10) < base) { + result = result * base + value; cp++; } + if (endp) *endp = (char *)cp; + return result; } EXPORT_SYMBOL(simple_strtoul); -long simple_strtol(const char *cp,char **endp,unsigned int base) +long simple_strtol(const char *cp, char **endp, unsigned int base) { - if(*cp=='-') - return -simple_strtoul(cp+1,endp,base); - return simple_strtoul(cp,endp,base); + if (*cp == '-') + return -simple_strtoul(cp + 1, endp, base); + + return simple_strtoul(cp, endp, base); } EXPORT_SYMBOL(simple_strtol); -unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int base) +unsigned long long simple_strtoull(const char *cp, char **endp, unsigned int base) { unsigned long long result = 0, value; if (*cp == '0') { cp++; - if ((*cp == 'x') && isxdigit (cp[1])) { + + if ((*cp == 'x') && isxdigit(cp[1])) { base = 16; cp++; } - if (!base) { + + if (!base) base = 8; - } } - if (!base) { + + if (!base) base = 10; - } - while (isxdigit (*cp) && (value = isdigit (*cp) - ? *cp - '0' - : (islower (*cp) ? toupper (*cp) : *cp) - 'A' + 10) < base) { + + while (isxdigit(*cp) && (value = isdigit(*cp) ? + *cp - '0' : toupper(*cp) - 'A' + 10) < base) { result = result * base + value; cp++; } + if (endp) - *endp = (char *) cp; + *endp = (char *)cp; + return result; } EXPORT_SYMBOL(simple_strtoull); + +long long simple_strtoll(const char *cp, char **endp, unsigned int base) +{ + if (*cp == '-') + return -simple_strtoull(cp + 1, endp, base); + + return simple_strtoull(cp, endp, base); +} +EXPORT_SYMBOL(simple_strtoll); diff --git a/lib/xfuncs.c b/lib/xfuncs.c index 1dc2ea92d8..1bcaa5e10e 100644 --- a/lib/xfuncs.c +++ b/lib/xfuncs.c @@ -18,18 +18,30 @@ * GNU General Public License for more details. * */ +#define pr_fmt(fmt) "xfuncs: " fmt #include <common.h> #include <malloc.h> #include <module.h> #include <wchar.h> +static void __noreturn enomem_panic(size_t size) +{ + pr_emerg("out of memory\n"); + if (size) + pr_emerg("Unable to allocate %d bytes\n", size); + + malloc_stats(); + + panic("out of memory"); +} + void *xmalloc(size_t size) { void *p = NULL; if (!(p = malloc(size))) - panic("ERROR: out of memory\n"); + enomem_panic(size); return p; } @@ -40,7 +52,7 @@ void *xrealloc(void *ptr, size_t size) void *p = NULL; if (!(p = realloc(ptr, size))) - panic("ERROR: out of memory\n"); + enomem_panic(size); return p; } @@ -63,7 +75,7 @@ char *xstrdup(const char *s) p = strdup(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic(strlen(s) + 1); return p; } @@ -95,7 +107,8 @@ void* xmemalign(size_t alignment, size_t bytes) { void *p = memalign(alignment, bytes); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic(bytes); + return p; } EXPORT_SYMBOL(xmemalign); @@ -116,7 +129,7 @@ char *xvasprintf(const char *fmt, va_list ap) p = bvasprintf(fmt, ap); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic(0); return p; } EXPORT_SYMBOL(xvasprintf); @@ -139,7 +152,8 @@ wchar_t *xstrdup_wchar(const wchar_t *s) wchar_t *p = strdup_wchar(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic((wcslen(s) + 1) * sizeof(wchar_t)); + return p; } EXPORT_SYMBOL(xstrdup_wchar); @@ -149,7 +163,8 @@ wchar_t *xstrdup_char_to_wchar(const char *s) wchar_t *p = strdup_char_to_wchar(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic((strlen(s) + 1) * sizeof(wchar_t)); + return p; } EXPORT_SYMBOL(xstrdup_char_to_wchar); @@ -159,7 +174,8 @@ char *xstrdup_wchar_to_char(const wchar_t *s) char *p = strdup_wchar_to_char(s); if (!p) - panic("ERROR: out of memory\n"); + enomem_panic((wcslen(s) + 1) * sizeof(wchar_t)); + return p; } EXPORT_SYMBOL(xstrdup_wchar_to_char); @@ -573,6 +573,9 @@ static struct device_d net_device = { .id = DEVICE_ID_SINGLE, }; +static char *net_nameserver; +static char *net_domainname; + static int net_init(void) { int i; @@ -581,8 +584,12 @@ static int net_init(void) NetRxPackets[i] = net_alloc_packet(); register_device(&net_device); - dev_add_param(&net_device, "nameserver", NULL, NULL, 0); - dev_add_param(&net_device, "domainname", NULL, NULL, 0); + net_nameserver = xstrdup(""); + dev_add_param_string(&net_device, "nameserver", NULL, NULL, + &net_nameserver, NULL); + net_domainname = xstrdup(""); + dev_add_param_string(&net_device, "domainname", NULL, NULL, + &net_domainname, NULL); return 0; } diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 7f9d544f9b..84af27bf0f 100644..100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -11,7 +11,15 @@ test ! -r $2/Makefile -o -O $2/Makefile || exit 0 -echo " GEN $2/Makefile" +# Only overwrite automatically generated Makefiles +# (so we do not overwrite kernel Makefile) +if test -e $2/Makefile && ! grep -q Automatically $2/Makefile +then + exit 0 +fi +if [ "${quiet}" != "silent_" ]; then + echo " GEN $2/Makefile" +fi cat << EOF > $2/Makefile # Automatically generated by $0: don't edit @@ -19,18 +27,26 @@ cat << EOF > $2/Makefile VERSION = $3 PATCHLEVEL = $4 -KERNELSRC := $1 -KERNELOUTPUT := $2 +lastword = \$(word \$(words \$(1)),\$(1)) +makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) -MAKEFLAGS += --no-print-directory +ifeq ("\$(origin V)", "command line") +VERBOSE := \$(V) +endif +ifneq (\$(VERBOSE),1) +Q := @ +endif + +MAKEARGS := -C $1 +MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) -.PHONY: all \$(MAKECMDGOALS) +MAKEFLAGS += --no-print-directory -all: - \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) +.PHONY: __sub-make \$(MAKECMDGOALS) -Makefile:; +__sub-make: + \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS) -\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/: - \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@ +\$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make + @: EOF |