diff options
73 files changed, 1024 insertions, 484 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index 08222fd5694..e752e4b3de0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -565,7 +565,7 @@ S: Maintained T: git https://gitlab.denx.de/u-boot/custodians/u-boot-freebsd.git FREESCALE QORIQ -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained T: git https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq.git F: drivers/watchdog/sp805_wdt.c @@ -723,13 +723,13 @@ F: arch/powerpc/cpu/mpc83xx/ F: arch/powerpc/include/asm/arch-mpc83xx/ POWERPC MPC85XX -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained T: git https://gitlab.denx.de/u-boot/custodians/u-boot-mpc85xx.git F: arch/powerpc/cpu/mpc85xx/ POWERPC MPC86XX -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained T: git https://gitlab.denx.de/u-boot/custodians/u-boot-mpc86xx.git F: arch/powerpc/cpu/mpc86xx/ @@ -882,6 +882,10 @@ ifeq ($(CONFIG_MPC85xx)$(CONFIG_OF_SEPARATE),yy) ALL-y += u-boot-with-dtb.bin endif +ifeq ($(CONFIG_ARCH_ROCKCHIP)$(CONFIG_SPL)$(CONFIG_TPL),yyy) +ALL-y += idbloader.img +endif + LDFLAGS_u-boot += $(LDFLAGS_FINAL) # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. @@ -1314,6 +1318,14 @@ OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE $(call if_changed,pad_cat) +ifeq ($(CONFIG_ARCH_ROCKCHIP),y) +MKIMAGEFLAGS_u-boot-tpl.img = -n $(CONFIG_SYS_SOC) -T rksd +tpl/u-boot-tpl.img: tpl/u-boot-tpl.bin FORCE + $(call if_changed,mkimage) +idbloader.img: tpl/u-boot-tpl.img spl/u-boot-spl.bin FORCE + $(call if_changed,cat) +endif + ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy) MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE) diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile index aac1b83d493..62da168ef86 100644 --- a/arch/arm/dts/Makefile +++ b/arch/arm/dts/Makefile @@ -302,7 +302,8 @@ dtb-$(CONFIG_AM33XX) += \ dtb-$(CONFIG_AM43XX) += am437x-gp-evm.dtb am437x-sk-evm.dtb \ am43x-epos-evm.dtb \ am437x-idk-evm.dtb \ - am4372-generic.dtb + am4372-generic.dtb \ + am437x-cm-t43.dtb dtb-$(CONFIG_TARGET_AM3517_EVM) += am3517-evm.dtb dtb-$(CONFIG_TI816X) += dm8168-evm.dtb dtb-$(CONFIG_THUNDERX) += thunderx-88xx.dtb diff --git a/arch/arm/dts/am437x-cm-t43.dts b/arch/arm/dts/am437x-cm-t43.dts new file mode 100644 index 00000000000..063113a5da2 --- /dev/null +++ b/arch/arm/dts/am437x-cm-t43.dts @@ -0,0 +1,420 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2015 CompuLab, Ltd. - http://www.compulab.co.il/ + */ + +/dts-v1/; + +#include <dt-bindings/pinctrl/am43xx.h> +#include <dt-bindings/gpio/gpio.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include "am4372.dtsi" + +/ { + model = "CompuLab CM-T43"; + compatible = "compulab,am437x-cm-t43", "ti,am4372", "ti,am43"; + + leds { + compatible = "gpio-leds"; + + ledb { + label = "cm-t43:green"; + gpios = <&gpio0 24 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "heartbeat"; + }; + }; + + vmmc_3v3: fixedregulator-v3_3 { + compatible = "regulator-fixed"; + regulator-name = "vmmc_3v3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-always-on; + enable-active-high; + }; +}; + +&am43xx_pinmux { + pinctrl-names = "default"; + pinctrl-0 = <&cm_t43_led_pins>; + + cm_t43_led_pins: cm_t43_led_pins { + pinctrl-single,pins = < + AM4372_IOPAD(0xa78, MUX_MODE7) + >; + }; + + i2c0_pins: i2c0_pins { + pinctrl-single,pins = < + AM4372_IOPAD(0x988, PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE0) /* i2c0_sda.i2c0_sda */ + AM4372_IOPAD(0x98c, PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE0) /* i2c0_scl.i2c0_scl */ + >; + }; + + emmc_pins: emmc_pins { + pinctrl-single,pins = < + AM4372_IOPAD(0x820, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad8.mmc1_dat0 */ + AM4372_IOPAD(0x824, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad9.mmc1_dat1 */ + AM4372_IOPAD(0x828, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad10.mmc1_dat2 */ + AM4372_IOPAD(0x82c, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad11.mmc1_dat3 */ + AM4372_IOPAD(0x830, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad12.mmc1_dat4 */ + AM4372_IOPAD(0x834, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad13.mmc1_dat5 */ + AM4372_IOPAD(0x838, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad14.mmc1_dat6 */ + AM4372_IOPAD(0x83c, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_ad15.mmc1_dat7 */ + AM4372_IOPAD(0x880, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_csn1.mmc1_clk */ + AM4372_IOPAD(0x884, PIN_INPUT_PULLUP | MUX_MODE2) /* gpmc_csn2.mmc1_cmd */ + >; + }; + + spi0_pins: pinmux_spi0_pins { + pinctrl-single,pins = < + AM4372_IOPAD(0x950, PIN_INPUT | MUX_MODE0) /* spi0_sclk.spi0_sclk */ + AM4372_IOPAD(0x954, PIN_INPUT | MUX_MODE0) /* spi0_d0.spi0_d0 */ + AM4372_IOPAD(0x958, PIN_OUTPUT | MUX_MODE0) /* spi0_d1.spi0_d1 */ + AM4372_IOPAD(0x95C, PIN_OUTPUT | MUX_MODE0) /* spi0_cs0.spi0_cs0 */ + >; + }; + + nand_flash_x8: nand_flash_x8 { + pinctrl-single,pins = < + AM4372_IOPAD(0x800, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x804, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x808, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x80c, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x810, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x814, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x818, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x81c, PIN_INPUT | PULL_DISABLE | MUX_MODE0) + AM4372_IOPAD(0x870, PIN_INPUT_PULLUP | MUX_MODE0) + AM4372_IOPAD(0x874, PIN_OUTPUT_PULLUP | MUX_MODE0) + AM4372_IOPAD(0x87c, PIN_OUTPUT_PULLUP | MUX_MODE0) + AM4372_IOPAD(0x898, PIN_OUTPUT_PULLDOWN | MUX_MODE0) + AM4372_IOPAD(0x894, PIN_OUTPUT_PULLDOWN | MUX_MODE0) + AM4372_IOPAD(0x890, PIN_OUTPUT_PULLDOWN | MUX_MODE0) + AM4372_IOPAD(0x89c, PIN_OUTPUT_PULLDOWN | MUX_MODE0) + >; + }; + + cpsw_default: cpsw_default { + pinctrl-single,pins = < + /* Slave 1 */ + AM4372_IOPAD(0x914, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mii1_txen.rgmii1_txen */ + AM4372_IOPAD(0x918, PIN_INPUT_PULLDOWN | MUX_MODE2) /* mii1_rxdv.rgmii1_rxctl */ + AM4372_IOPAD(0x91c, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mii1_txd1.rgmii1_txd3 */ + AM4372_IOPAD(0x920, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mii1_txd0.rgmii1_txd2 */ + AM4372_IOPAD(0x924, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mii1_txd1.rgmii1_txd1 */ + AM4372_IOPAD(0x928, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mii1_txd0.rgmii1_txd0 */ + AM4372_IOPAD(0x92c, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* mii1_txclk.rmii1_tclk */ + AM4372_IOPAD(0x930, PIN_INPUT_PULLDOWN | MUX_MODE2) /* mii1_rxclk.rmii1_rclk */ + AM4372_IOPAD(0x934, PIN_INPUT_PULLDOWN | MUX_MODE2) /* mii1_rxd1.rgmii1_rxd3 */ + AM4372_IOPAD(0x938, PIN_INPUT_PULLDOWN | MUX_MODE2) /* mii1_rxd0.rgmii1_rxd2 */ + AM4372_IOPAD(0x93c, PIN_INPUT_PULLDOWN | MUX_MODE2) /* mii1_rxd1.rgmii1_rxd1 */ + AM4372_IOPAD(0x940, PIN_INPUT_PULLDOWN | MUX_MODE2) /* mii1_rxd0.rgmii1_rxd0 */ + AM4372_IOPAD(0xa74, MUX_MODE3) + /* Slave 2 */ + AM4372_IOPAD(0x840, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a0.txen */ + AM4372_IOPAD(0x844, PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a1.rxctl */ + AM4372_IOPAD(0x848, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a2.txd3 */ + AM4372_IOPAD(0x84c, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a3.txd2 */ + AM4372_IOPAD(0x850, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a4.txd1 */ + AM4372_IOPAD(0x854, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a5.txd0 */ + AM4372_IOPAD(0x858, PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a6.tclk */ + AM4372_IOPAD(0x85c, PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a7.rclk */ + AM4372_IOPAD(0x860, PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a8.rxd3 */ + AM4372_IOPAD(0x864, PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a9.rxd2 */ + AM4372_IOPAD(0x868, PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a10.rxd1 */ + AM4372_IOPAD(0x86c, PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a11.rxd0 */ + AM4372_IOPAD(0xa38, MUX_MODE7) + >; + }; + + davinci_mdio_default: davinci_mdio_default { + pinctrl-single,pins = < + /* MDIO */ + AM4372_IOPAD(0x948, PIN_INPUT_PULLUP | SLEWCTRL_FAST | MUX_MODE0) /* mdio_data.mdio_data */ + AM4372_IOPAD(0x94c, PIN_OUTPUT_PULLUP | MUX_MODE0) /* mdio_clk.mdio_clk */ + >; + }; +}; + +&gpmc { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&nand_flash_x8>; + ranges = <0 0 0x08000000 0x1000000>; + nand@0,0 { + compatible = "ti,omap2-nand"; + reg = <0 0 4>; /* CS0, offset 0, IO size 4 */ + interrupt-parent = <&gpmc>; + interrupts = <0 IRQ_TYPE_NONE>, /* fifoevent */ + <1 IRQ_TYPE_NONE>; /* termcount */ + ti,nand-ecc-opt = "bch8"; + ti,elm-id = <&elm>; + + nand-bus-width = <8>; + gpmc,device-width = <1>; + gpmc,sync-clk-ps = <0>; + gpmc,cs-on-ns = <0>; + gpmc,cs-rd-off-ns = <44>; + gpmc,cs-wr-off-ns = <44>; + gpmc,adv-on-ns = <6>; + gpmc,adv-rd-off-ns = <34>; + gpmc,adv-wr-off-ns = <44>; + gpmc,we-on-ns = <0>; + gpmc,we-off-ns = <40>; + gpmc,oe-on-ns = <0>; + gpmc,oe-off-ns = <54>; + gpmc,access-ns = <64>; + gpmc,rd-cycle-ns = <82>; + gpmc,wr-cycle-ns = <82>; + gpmc,bus-turnaround-ns = <0>; + gpmc,cycle2cycle-delay-ns = <0>; + gpmc,clk-activation-ns = <0>; + gpmc,wr-access-ns = <40>; + gpmc,wr-data-mux-bus-ns = <0>; + + #address-cells = <1>; + #size-cells = <1>; + /* MTD partition table */ + partition@0 { + label = "kernel"; + reg = <0x0 0x00980000>; + }; + partition@980000 { + label = "dtb"; + reg = <0x00980000 0x00080000>; + }; + partition@a00000 { + label = "rootfs"; + reg = <0x00a00000 0x0>; + }; + }; +}; + +&i2c0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins>; + clock-frequency = <100000>; + + tps65218: tps65218@24 { + compatible = "ti,tps65218"; + reg = <0x24>; + interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* NMIn */ + interrupt-parent = <&gic>; + interrupt-controller; + #interrupt-cells = <2>; + + dcdc1: regulator-dcdc1 { + regulator-name = "vdd_core"; + regulator-min-microvolt = <912000>; + regulator-max-microvolt = <1144000>; + regulator-boot-on; + regulator-always-on; + }; + + dcdc2: regulator-dcdc2 { + regulator-name = "vdd_mpu"; + regulator-min-microvolt = <912000>; + regulator-max-microvolt = <1378000>; + regulator-boot-on; + regulator-always-on; + }; + + dcdc3: regulator-dcdc3 { + regulator-name = "vdcdc3"; + regulator-suspend-enable; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-boot-on; + regulator-always-on; + }; + + dcdc5: regulator-dcdc5 { + regulator-name = "v1_0bat"; + regulator-min-microvolt = <1000000>; + regulator-max-microvolt = <1000000>; + regulator-boot-on; + regulator-always-on; + }; + + dcdc6: regulator-dcdc6 { + regulator-name = "v1_8bat"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + + ldo1: regulator-ldo1 { + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + regulator-boot-on; + regulator-always-on; + }; + }; + + eeprom_module: at24@50 { + compatible = "atmel,24c02"; + reg = <0x50>; + pagesize = <16>; + }; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&gpio2 { + status = "okay"; +}; + +&gpio3 { + status = "okay"; +}; + +&gpio4 { + status = "okay"; +}; + +&gpio5 { + status = "okay"; +}; + +&mmc2 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&emmc_pins>; + vmmc-supply = <&vmmc_3v3>; + bus-width = <8>; + ti,non-removable; +}; + +&spi0 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&spi0_pins>; + dmas = <&edma 16 0 + &edma 17 0>; + dma-names = "tx0", "rx0"; + + flash: w25q64cvzpig@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <20000000>; + partition@0 { + label = "uboot"; + reg = <0x0 0xc0000>; + }; + + partition@c0000 { + label = "uboot environment"; + reg = <0xc0000 0x40000>; + }; + + partition@100000 { + label = "reserved"; + reg = <0x100000 0x100000>; + }; + }; +}; + +&mac { + pinctrl-names = "default"; + pinctrl-0 = <&cpsw_default>; + dual_emac = <1>; + status = "okay"; +}; + +&davinci_mdio { + pinctrl-names = "default"; + pinctrl-0 = <&davinci_mdio_default>; + status = "okay"; + + ethphy0: ethernet-phy@0 { + reg = <0>; + }; + + ethphy1: ethernet-phy@1 { + reg = <1>; + }; +}; + +&cpsw_emac0 { + phy-handle = <ðphy0>; + phy-mode = "rgmii-txid"; + dual_emac_res_vlan = <1>; +}; + +&cpsw_emac1 { + phy-handle = <ðphy1>; + phy-mode = "rgmii-txid"; + dual_emac_res_vlan = <2>; +}; + +&dwc3_1 { + status = "okay"; +}; + +&usb2_phy1 { + status = "okay"; +}; + +&usb1 { + dr_mode = "host"; + status = "okay"; +}; + +&dwc3_2 { + status = "okay"; +}; + +&usb2_phy2 { + status = "okay"; +}; + +&usb2 { + dr_mode = "host"; + status = "okay"; + interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "peripheral", "host", "otg"; +}; + +&elm { + status = "okay"; +}; + +&uart0 { + status = "okay"; +}; + +&tscadc { + status = "okay"; + tsc { + ti,wires = <4>; + ti,x-plate-resistance = <200>; + ti,coordiante-readouts = <5>; + ti,wire-config = <0x00 0x11 0x22 0x33>; + }; + + adc { + ti,adc-channels = <4 5 6 7>; + }; +}; + +&cpu { + cpu0-supply = <&dcdc2>; + operating-points = <1000000 1330000>, + <800000 1260000>, + <720000 1200000>, + <600000 1100000>, + <300000 950000>; +}; diff --git a/arch/arm/dts/dra74x-mmc-iodelay.dtsi b/arch/arm/dts/dra74x-mmc-iodelay.dtsi index 28ebb4eb884..214b9e6de2c 100644 --- a/arch/arm/dts/dra74x-mmc-iodelay.dtsi +++ b/arch/arm/dts/dra74x-mmc-iodelay.dtsi @@ -32,7 +32,7 @@ * * Datamanual Revisions: * - * AM572x Silicon Revision 2.0: SPRS953B, Revised November 2016 + * AM572x Silicon Revision 2.0: SPRS953F, Revised May 2019 * AM572x Silicon Revision 1.1: SPRS915R, Revised November 2016 * */ @@ -229,45 +229,45 @@ mmc3_pins_default: mmc3_pins_default { pinctrl-single,pins = < - DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ - DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ - DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ - DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ - DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ - DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ + DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ + DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ + DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ + DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ + DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ + DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ >; }; mmc3_pins_hs: mmc3_pins_hs { pinctrl-single,pins = < - DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ - DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ - DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ - DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ - DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ - DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ + DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ + DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ + DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ + DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ + DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ + DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ >; }; mmc3_pins_sdr12: mmc3_pins_sdr12 { pinctrl-single,pins = < - DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ - DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ - DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ - DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ - DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ - DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ + DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ + DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ + DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ + DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ + DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ + DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ >; }; mmc3_pins_sdr25: mmc3_pins_sdr25 { pinctrl-single,pins = < - DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ - DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ - DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ - DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ - DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ - DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ + DRA7XX_CORE_IOPAD(0x377c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_clk.mmc3_clk */ + DRA7XX_CORE_IOPAD(0x3780, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_cmd.mmc3_cmd */ + DRA7XX_CORE_IOPAD(0x3784, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat0.mmc3_dat0 */ + DRA7XX_CORE_IOPAD(0x3788, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat1.mmc3_dat1 */ + DRA7XX_CORE_IOPAD(0x378c, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat2.mmc3_dat2 */ + DRA7XX_CORE_IOPAD(0x3790, (PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE0)) /* mmc3_dat3.mmc3_dat3 */ >; }; diff --git a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi index f7f26d584f9..a073ea25f51 100644 --- a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi +++ b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi @@ -5,6 +5,11 @@ #include "rk3399-u-boot.dtsi" #include "rk3399-sdram-lpddr4-100.dtsi" +/ { + chosen { + u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci; + }; +}; &vdd_log { regulator-init-microvolt = <950000>; diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h index 3dca50f776b..c1502409626 100644 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ b/arch/arm/mach-davinci/include/mach/gpio.h @@ -22,11 +22,7 @@ #define gpio_status() gpio_info() #endif #define GPIO_NAME_SIZE 20 -#if !defined(CONFIG_SOC_DA850) -#define MAX_NUM_GPIOS 128 -#else #define MAX_NUM_GPIOS 144 -#endif #define GPIO_BANK(gp) (davinci_gpio_bank01 + ((gp) >> 5)) void gpio_info(void); diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c index 6558fe0ef4b..0b564f7bd16 100644 --- a/arch/arm/mach-k3/am6_init.c +++ b/arch/arm/mach-k3/am6_init.c @@ -219,10 +219,9 @@ u32 spl_boot_device(void) void release_resources_for_core_shutdown(void) { - struct udevice *dev; - struct ti_sci_handle *ti_sci; - struct ti_sci_dev_ops *dev_ops; - struct ti_sci_proc_ops *proc_ops; + struct ti_sci_handle *ti_sci = get_ti_sci_handle(); + struct ti_sci_dev_ops *dev_ops = &ti_sci->ops.dev_ops; + struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; int ret; u32 i; @@ -231,15 +230,6 @@ void release_resources_for_core_shutdown(void) AM6_DEV_MCU_RTI1, }; - /* Get handle to Device Management and Security Controller (SYSFW) */ - ret = uclass_get_device_by_name(UCLASS_FIRMWARE, "dmsc", &dev); - if (ret) - panic("Failed to get handle to SYSFW (%d)\n", ret); - - ti_sci = (struct ti_sci_handle *)(ti_sci_get_handle_from_sysfw(dev)); - dev_ops = &ti_sci->ops.dev_ops; - proc_ops = &ti_sci->ops.proc_ops; - /* Iterate through list of devices to put (shutdown) */ for (i = 0; i < ARRAY_SIZE(put_device_ids); i++) { u32 id = put_device_ids[i]; diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index bab5ffdf403..3e36d90acef 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -20,7 +20,7 @@ struct ti_sci_handle *get_ti_sci_handle(void) struct udevice *dev; int ret; - ret = uclass_get_device_by_name(UCLASS_FIRMWARE, "dmsc", &dev); + ret = uclass_get_device(UCLASS_FIRMWARE, 0, &dev); if (ret) panic("Failed to get SYSFW (%d)\n", ret); diff --git a/arch/arm/mach-k3/security.c b/arch/arm/mach-k3/security.c index 52f49bf01fe..4e011ee10ef 100644 --- a/arch/arm/mach-k3/security.c +++ b/arch/arm/mach-k3/security.c @@ -11,25 +11,16 @@ #include <linux/soc/ti/ti_sci_protocol.h> #include <mach/spl.h> #include <spl.h> +#include <asm/arch/sys_proto.h> void board_fit_image_post_process(void **p_image, size_t *p_size) { - struct udevice *dev; - struct ti_sci_handle *ti_sci; - struct ti_sci_proc_ops *proc_ops; + struct ti_sci_handle *ti_sci = get_ti_sci_handle(); + struct ti_sci_proc_ops *proc_ops = &ti_sci->ops.proc_ops; u64 image_addr; u32 image_size; int ret; - /* Get handle to Device Management and Security Controller (SYSFW) */ - ret = uclass_get_device_by_name(UCLASS_FIRMWARE, "dmsc", &dev); - if (ret) { - printf("Failed to get handle to SYSFW (%d)\n", ret); - hang(); - } - ti_sci = (struct ti_sci_handle *)(ti_sci_get_handle_from_sysfw(dev)); - proc_ops = &ti_sci->ops.proc_ops; - image_addr = (uintptr_t)*p_image; debug("Authenticating image at address 0x%016llx\n", image_addr); diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile index 207f9000110..45d9b06233f 100644 --- a/arch/arm/mach-rockchip/Makefile +++ b/arch/arm/mach-rockchip/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ # # Copyright (c) 2014 Google, Inc +# Copyright (c) 2019 Rockchip Electronics Co., Ltd. # We don't want the bootrom-helper present in a full U-Boot build, as # this may have entered from ATF with the stack-pointer pointing to @@ -21,19 +22,14 @@ ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TPL_BUILD),) # meaning "turn it off". obj-y += boot_mode.o obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o +obj-$(CONFIG_MISC_INIT_R) += misc.o endif obj-$(CONFIG_$(SPL_TPL_)RAM) += sdram_common.o -ifdef CONFIG_MISC_INIT_R -obj-y += misc.o -endif - obj-$(CONFIG_ROCKCHIP_RK3036) += rk3036/ obj-$(CONFIG_ROCKCHIP_RK3128) += rk3128/ -ifndef CONFIG_TPL_BUILD obj-$(CONFIG_ROCKCHIP_RK3188) += rk3188/ -endif obj-$(CONFIG_ROCKCHIP_RK322X) += rk322x/ obj-$(CONFIG_ROCKCHIP_RK3288) += rk3288/ obj-$(CONFIG_ROCKCHIP_RK3328) += rk3328/ diff --git a/arch/sh/cpu/sh4/config.mk b/arch/sh/cpu/sh4/config.mk index d62d285e606..23fec664929 100644 --- a/arch/sh/cpu/sh4/config.mk +++ b/arch/sh/cpu/sh4/config.mk @@ -6,4 +6,4 @@ # (C) Copyright 2007 # Nobuhiro Iwamatsu <iwamatsu@nigauri.org> # -PLATFORM_CPPFLAGS += -m4-nofpu +PLATFORM_CPPFLAGS += $(call cc-option,-m4-nofpu,-m4) diff --git a/arch/sh/cpu/u-boot.lds b/arch/sh/cpu/u-boot.lds index 47302da252a..4cc97737f1c 100644 --- a/arch/sh/cpu/u-boot.lds +++ b/arch/sh/cpu/u-boot.lds @@ -25,6 +25,7 @@ ENTRY(_start) SECTIONS { + . = CONFIG_SYS_TEXT_BASE; reloc_dst = .; PROVIDE (_ftext = .); diff --git a/arch/sh/dts/sh7751-r2dplus.dts b/arch/sh/dts/sh7751-r2dplus.dts index ecaf0772d8f..efaeb33e360 100644 --- a/arch/sh/dts/sh7751-r2dplus.dts +++ b/arch/sh/dts/sh7751-r2dplus.dts @@ -21,6 +21,7 @@ #size-cells = <2>; #interrupt-cells = <1>; ranges = <0x01000000 0 0xfe240000 0 0xfe240000 0 0x00040000 - 0x02000000 0 0xfd000000 0 0xfd000000 0 0x01000000>; + 0x02000000 0 0xfd000000 0 0xfd000000 0 0x01000000 + 0x42000000 0 0x0c000000 0 0x8c000000 0 0x04000000>; }; }; diff --git a/board/freescale/mpc8536ds/MAINTAINERS b/board/freescale/mpc8536ds/MAINTAINERS index d640f898450..5ce5164e499 100644 --- a/board/freescale/mpc8536ds/MAINTAINERS +++ b/board/freescale/mpc8536ds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8536DS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8536ds/ F: include/configs/MPC8536DS.h diff --git a/board/freescale/mpc8541cds/MAINTAINERS b/board/freescale/mpc8541cds/MAINTAINERS index 100077608bb..cf3b9cf5f72 100644 --- a/board/freescale/mpc8541cds/MAINTAINERS +++ b/board/freescale/mpc8541cds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8541CDS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8541cds/ F: include/configs/MPC8541CDS.h diff --git a/board/freescale/mpc8544ds/MAINTAINERS b/board/freescale/mpc8544ds/MAINTAINERS index 78019fbfea7..74e7249e473 100644 --- a/board/freescale/mpc8544ds/MAINTAINERS +++ b/board/freescale/mpc8544ds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8544DS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8544ds/ F: include/configs/MPC8544DS.h diff --git a/board/freescale/mpc8548cds/MAINTAINERS b/board/freescale/mpc8548cds/MAINTAINERS index 385dc85576c..fbbedb1d1d1 100644 --- a/board/freescale/mpc8548cds/MAINTAINERS +++ b/board/freescale/mpc8548cds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8548CDS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8548cds/ F: include/configs/MPC8548CDS.h diff --git a/board/freescale/mpc8555cds/MAINTAINERS b/board/freescale/mpc8555cds/MAINTAINERS index 815cffec1b7..8f32febd914 100644 --- a/board/freescale/mpc8555cds/MAINTAINERS +++ b/board/freescale/mpc8555cds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8555CDS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8555cds/ F: include/configs/MPC8555CDS.h diff --git a/board/freescale/mpc8568mds/MAINTAINERS b/board/freescale/mpc8568mds/MAINTAINERS index 79f04d1a90f..f4747866d2b 100644 --- a/board/freescale/mpc8568mds/MAINTAINERS +++ b/board/freescale/mpc8568mds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8568MDS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8568mds/ F: include/configs/MPC8568MDS.h diff --git a/board/freescale/mpc8569mds/MAINTAINERS b/board/freescale/mpc8569mds/MAINTAINERS index b2e3bdfa114..9df3f3cca8f 100644 --- a/board/freescale/mpc8569mds/MAINTAINERS +++ b/board/freescale/mpc8569mds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8569MDS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8569mds/ F: include/configs/MPC8569MDS.h diff --git a/board/freescale/mpc8572ds/MAINTAINERS b/board/freescale/mpc8572ds/MAINTAINERS index 80a30966531..d7e9b1f41f4 100644 --- a/board/freescale/mpc8572ds/MAINTAINERS +++ b/board/freescale/mpc8572ds/MAINTAINERS @@ -1,5 +1,5 @@ MPC8572DS BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8572ds/ F: include/configs/MPC8572DS.h diff --git a/board/freescale/mpc8610hpcd/MAINTAINERS b/board/freescale/mpc8610hpcd/MAINTAINERS index 633c5ed192d..9b1e0cd4e56 100644 --- a/board/freescale/mpc8610hpcd/MAINTAINERS +++ b/board/freescale/mpc8610hpcd/MAINTAINERS @@ -1,5 +1,5 @@ MPC8610HPCD BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8610hpcd/ F: include/configs/MPC8610HPCD.h diff --git a/board/freescale/mpc8641hpcn/MAINTAINERS b/board/freescale/mpc8641hpcn/MAINTAINERS index 827bb79aef6..c9572187675 100644 --- a/board/freescale/mpc8641hpcn/MAINTAINERS +++ b/board/freescale/mpc8641hpcn/MAINTAINERS @@ -1,5 +1,5 @@ MPC8641HPCN BOARD -M: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +M: Priyanka Jain <priyanka.jain@nxp.com> S: Maintained F: board/freescale/mpc8641hpcn/ F: include/configs/MPC8641HPCN.h diff --git a/board/theobroma-systems/lion_rk3368/README b/board/theobroma-systems/lion_rk3368/README index 83e43329843..ad3ac93bd44 100644 --- a/board/theobroma-systems/lion_rk3368/README +++ b/board/theobroma-systems/lion_rk3368/README @@ -18,8 +18,6 @@ Build the TPL/SPL stage ======================= > make CROSS_COMPILE=aarch64-unknown-elf- ARCH=arm - > tools/mkimage -n rk3368 -T rksd -d tpl/u-boot-tpl.bin spl-3368.img - > cat spl/u-boot-spl-dtb.bin >> spl-3368.img Build the full U-Boot and a FIT image including the ATF ======================================================= @@ -35,7 +33,7 @@ Copy the SPL to offset 32k and the FIT image containing the payloads SD-Card ------- - > dd if=spl-3368.img of=/dev/sdb seek=64 + > dd if=idbloader.img of=/dev/sdb seek=64 > dd if=u-boot.itb of=/dev/sdb seek=512 eMMC diff --git a/common/usb.c b/common/usb.c index b70f614d244..d9bcb5a57e8 100644 --- a/common/usb.c +++ b/common/usb.c @@ -192,12 +192,15 @@ int usb_disable_asynch(int disable) */ /* - * submits an Interrupt Message + * submits an Interrupt Message. Some drivers may implement non-blocking + * polling: when non-block is true and the device is not responding return + * -EAGAIN instead of waiting for device to respond. */ -int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer, int transfer_len, int interval) +int usb_int_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int transfer_len, int interval, bool nonblock) { - return submit_int_msg(dev, pipe, buffer, transfer_len, interval); + return submit_int_msg(dev, pipe, buffer, transfer_len, interval, + nonblock); } /* diff --git a/common/usb_kbd.c b/common/usb_kbd.c index 38737374614..d178af248af 100644 --- a/common/usb_kbd.c +++ b/common/usb_kbd.c @@ -340,10 +340,9 @@ static inline void usb_kbd_poll_for_event(struct usb_device *dev) struct usb_kbd_pdata *data = dev->privptr; /* Submit a interrupt transfer request */ - usb_submit_int_msg(dev, data->intpipe, &data->new[0], data->intpktsize, - data->intinterval); - - usb_kbd_irq_worker(dev); + if (usb_int_msg(dev, data->intpipe, &data->new[0], + data->intpktsize, data->intinterval, true) >= 0) + usb_kbd_irq_worker(dev); #elif defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) || \ defined(CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE) #if defined(CONFIG_SYS_USB_EVENT_POLL_VIA_CONTROL_EP) @@ -505,8 +504,8 @@ static int usb_kbd_probe_dev(struct usb_device *dev, unsigned int ifnum) if (usb_get_report(dev, iface->desc.bInterfaceNumber, 1, 0, data->new, USB_KBD_BOOT_REPORT_SIZE) < 0) { #else - if (usb_submit_int_msg(dev, data->intpipe, data->new, data->intpktsize, - data->intinterval) < 0) { + if (usb_int_msg(dev, data->intpipe, data->new, data->intpktsize, + data->intinterval, false) < 0) { #endif printf("Failed to get keyboard state from device %04x:%04x\n", dev->descriptor.idVendor, dev->descriptor.idProduct); diff --git a/common/usb_storage.c b/common/usb_storage.c index 8c889bb1a64..54f8e53c630 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -650,8 +650,8 @@ static int usb_stor_CBI_get_status(struct scsi_cmd *srb, struct us_data *us) int timeout; us->ip_wanted = 1; - submit_int_msg(us->pusb_dev, us->irqpipe, - (void *) &us->ip_data, us->irqmaxp, us->irqinterval); + usb_int_msg(us->pusb_dev, us->irqpipe, + (void *)&us->ip_data, us->irqmaxp, us->irqinterval, false); timeout = 1000; while (timeout--) { if (us->ip_wanted == 0) diff --git a/configs/am65x_hs_evm_a53_defconfig b/configs/am65x_hs_evm_a53_defconfig index 87547ed9abf..28c92f9106c 100644 --- a/configs/am65x_hs_evm_a53_defconfig +++ b/configs/am65x_hs_evm_a53_defconfig @@ -19,7 +19,7 @@ CONFIG_FIT_IMAGE_POST_PROCESS=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y CONFIG_OF_BOARD_SETUP=y -CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run get_kern_${boot}; run get_fdt_${boot}; run get_overlay_${boot}; run run_kern" +CONFIG_BOOTCOMMAND="run findfdt; run envboot; run init_${boot}; run get_fit_${boot}; run get_overlaystring; run run_fit" # CONFIG_DISPLAY_CPUINFO is not set CONFIG_SPL_TEXT_BASE=0x80080000 CONFIG_SPL_SYS_MALLOC_SIMPLE=y diff --git a/configs/cm_t43_defconfig b/configs/cm_t43_defconfig index 214a054ac48..44d727f58f4 100644 --- a/configs/cm_t43_defconfig +++ b/configs/cm_t43_defconfig @@ -32,6 +32,8 @@ CONFIG_SPL_POWER_SUPPORT=y CONFIG_SPL_SPI_LOAD=y CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 CONFIG_SYS_PROMPT="CM-T43 # " +CONFIG_OF_CONTROL=y +CONFIG_DEFAULT_DEVICE_TREE="am437x-cm-t43" CONFIG_CMD_ASKENV=y CONFIG_CMD_EEPROM=y CONFIG_CMD_EEPROM_LAYOUT=y @@ -52,9 +54,13 @@ CONFIG_ENV_IS_IN_SPI_FLASH=y CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_DM=y CONFIG_DM_GPIO=y +CONFIG_BLK=y +CONFIG_DM_MMC=y CONFIG_MMC_OMAP_HS=y CONFIG_NAND=y +CONFIG_DM_SPI=y CONFIG_SPI_FLASH=y +CONFIG_DM_SPI_FLASH=y CONFIG_SF_DEFAULT_SPEED=48000000 CONFIG_SPI_FLASH_ATMEL=y CONFIG_SPI_FLASH_EON=y @@ -70,6 +76,7 @@ CONFIG_DM_SERIAL=y CONFIG_SPI=y CONFIG_OMAP3_SPI=y CONFIG_USB=y +CONFIG_DM_USB=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_DWC3=y CONFIG_OMAP_USB_PHY=y diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig index d2342c37cff..a8d09f40d0f 100644 --- a/configs/omapl138_lcdk_defconfig +++ b/configs/omapl138_lcdk_defconfig @@ -25,9 +25,10 @@ CONFIG_HUSH_PARSER=y CONFIG_CRC32_VERIFY=y # CONFIG_CMD_EEPROM is not set CONFIG_MX_CYCLIC=y +CONFIG_CMD_DM=y # CONFIG_CMD_FLASH is not set -# CONFIG_CMD_GPIO is not set CONFIG_CMD_NAND=y +# CONFIG_CMD_PINMUX is not set # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_MTDPARTS=y CONFIG_CMD_DIAG=y @@ -40,6 +41,8 @@ CONFIG_ENV_IS_IN_NAND=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_DM=y CONFIG_SPL_DM=y +CONFIG_DM_GPIO=y +CONFIG_DA8XX_GPIO=y CONFIG_DM_I2C=y CONFIG_SYS_I2C_DAVINCI=y CONFIG_DM_MMC=y @@ -56,11 +59,14 @@ CONFIG_MII=y CONFIG_DRIVER_TI_EMAC=y CONFIG_PHY=y CONFIG_PHY_DA8XX_USB=y +CONFIG_PINCTRL=y +CONFIG_PINCTRL_SINGLE=y CONFIG_SPECIFY_CONSOLE_INDEX=y CONFIG_DM_SERIAL=y CONFIG_SYS_NS16550=y CONFIG_USB=y CONFIG_DM_USB=y +# CONFIG_SPL_DM_USB is not set CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_DA8XX=y CONFIG_USB_MUSB_HOST=y diff --git a/configs/r2dplus_defconfig b/configs/r2dplus_defconfig index b2334affc3e..e10ac939c5b 100644 --- a/configs/r2dplus_defconfig +++ b/configs/r2dplus_defconfig @@ -12,6 +12,7 @@ CONFIG_CMD_DM=y CONFIG_CMD_IDE=y CONFIG_CMD_PCI=y # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y CONFIG_CMD_EXT2=y diff --git a/doc/README.rockchip b/doc/README.rockchip index 531a062c9ec..d17afeabdd2 100644 --- a/doc/README.rockchip +++ b/doc/README.rockchip @@ -275,9 +275,7 @@ As of now TPL is added on Vyasa-RK3288 board. To write an image that boots from an SD card (assumed to be /dev/mmcblk0): - ./tools/mkimage -n rk3288 -T rksd -d ./tpl/u-boot-tpl.bin out && - cat ./spl/u-boot-spl-dtb.bin >> out && - sudo dd if=out of=/dev/mmcblk0 seek=64 && + sudo dd if=idbloader.img of=/dev/mmcblk0 seek=64 && sudo dd if=u-boot-dtb.img of=/dev/mmcblk0 seek=16384 Booting from an SD card on RK3188 @@ -310,11 +308,6 @@ Booting from an SD card on Pine64 Rock64 (RK3328) For Rock64 rk3328 board the following three parts are required: TPL, SPL, and the u-boot image tree blob. - - Create TPL/SPL image - - => tools/mkimage -n rk3328 -T rksd -d tpl/u-boot-tpl.bin idbloader.img - => cat spl/u-boot-spl.bin >> idbloader.img - - Write TPL/SPL image at 64 sector => sudo dd if=idbloader.img of=/dev/mmcblk0 seek=64 @@ -473,19 +466,9 @@ Hit any key to stop autoboot: 0 Option 3: Package the image with TPL: - - Prefix rk3399 header to TPL image - - => cd /path/to/u-boot - => ./tools/mkimage -n rk3399 -T rksd -d tpl/u-boot-tpl-dtb.bin out - - - Concatinate tpl with spl - - => cd /path/to/u-boot - => cat ./spl/u-boot-spl-dtb.bin >> out - - Write tpl+spl at 64th sector - => sudo dd if=out of=/dev/sdc seek=64 + => sudo dd if=idbloader.img of=/dev/sdc seek=64 - Write U-Boot proper at 16384 sector diff --git a/doc/driver-model/migration.rst b/doc/driver-model/migration.rst index 75b85235ef3..fd499fb74a8 100644 --- a/doc/driver-model/migration.rst +++ b/doc/driver-model/migration.rst @@ -58,10 +58,8 @@ to move the migration with in the deadline. No dm conversion yet:: - drivers/spi/cf_spi.c drivers/spi/fsl_espi.c drivers/spi/lpc32xx_ssp.c - drivers/spi/mxs_spi.c drivers/spi/sh_spi.c drivers/spi/soft_spi_legacy.c @@ -74,6 +72,7 @@ Partially converted:: drivers/spi/fsl_dspi.c drivers/spi/kirkwood_spi.c drivers/spi/mxc_spi.c + drivers/spi/mxs_spi.c drivers/spi/omap3_spi.c drivers/spi/sh_qspi.c diff --git a/doc/git-mailrc b/doc/git-mailrc index 1d36f5845ae..6f383b1f605 100644 --- a/doc/git-mailrc +++ b/doc/git-mailrc @@ -46,7 +46,7 @@ alias smcnutt Scott McNutt <smcnutt@psyent.com> alias stroese Stefan Roese <sr@denx.de> alias trini Tom Rini <trini@konsulko.com> alias wd Wolfgang Denk <wd@denx.de> -alias prabhu_kush Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com> +alias priyankajain Priyanka Jain <priyanka.jain@nxp.com> # Architecture aliases alias arch arc, arm, m68k, microblaze, mips, nds32, nios2, powerpc, sandbox, superh, x86 @@ -91,12 +91,12 @@ alias nds32 uboot, macpaul alias nios uboot, Thomas Chou <thomas@wytron.com.tw>, smcnutt alias nios2 nios -alias powerpc uboot, afleming, stroese, wd, prabhu_kush, mariosix +alias powerpc uboot, afleming, stroese, wd, priyankajain, mariosix alias ppc powerpc alias mpc8xx uboot, wd, Christophe Leroy <christophe.leroy@c-s.fr> alias mpc83xx uboot, mariosix -alias mpc85xx uboot, afleming, prabhu_kush -alias mpc86xx uboot, afleming, prabhu_kush +alias mpc85xx uboot, afleming, priyankajain +alias mpc86xx uboot, afleming, priyankajain alias sandbox sjg alias sb sandbox diff --git a/drivers/clk/rockchip/clk_rk3288.c b/drivers/clk/rockchip/clk_rk3288.c index 375d7f8acbb..01223816337 100644 --- a/drivers/clk/rockchip/clk_rk3288.c +++ b/drivers/clk/rockchip/clk_rk3288.c @@ -940,35 +940,12 @@ static int __maybe_unused rk3288_clk_set_parent(struct clk *clk, struct clk *par return -ENOENT; } -static int rk3288_clk_enable(struct clk *clk) -{ - switch (clk->id) { - case HCLK_USBHOST0: - case HCLK_HSIC: - return 0; - - case SCLK_MAC: - case SCLK_MAC_RX: - case SCLK_MAC_TX: - case SCLK_MACREF: - case SCLK_MACREF_OUT: - case ACLK_GMAC: - case PCLK_GMAC: - /* Required to successfully probe the Designware GMAC driver */ - return 0; - } - - debug("%s: unsupported clk %ld\n", __func__, clk->id); - return -ENOENT; -} - static struct clk_ops rk3288_clk_ops = { .get_rate = rk3288_clk_get_rate, .set_rate = rk3288_clk_set_rate, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .set_parent = rk3288_clk_set_parent, #endif - .enable = rk3288_clk_enable, }; static int rk3288_clk_ofdata_to_platdata(struct udevice *dev) diff --git a/drivers/clk/rockchip/clk_rk3328.c b/drivers/clk/rockchip/clk_rk3328.c index 5957a00402d..a89e2ecc4ad 100644 --- a/drivers/clk/rockchip/clk_rk3328.c +++ b/drivers/clk/rockchip/clk_rk3328.c @@ -745,22 +745,10 @@ static int rk3328_clk_set_parent(struct clk *clk, struct clk *parent) return -ENOENT; } -static int rk3328_clk_enable(struct clk *clk) -{ - switch (clk->id) { - case HCLK_HOST0: - /* Required to successfully probe the ehci generic driver */ - return 0; - } - - return -ENOENT; -} - static struct clk_ops rk3328_clk_ops = { .get_rate = rk3328_clk_get_rate, .set_rate = rk3328_clk_set_rate, .set_parent = rk3328_clk_set_parent, - .enable = rk3328_clk_enable, }; static int rk3328_clk_probe(struct udevice *dev) diff --git a/drivers/clk/rockchip/clk_rk3368.c b/drivers/clk/rockchip/clk_rk3368.c index 89cbae59c5e..c1a867b2ede 100644 --- a/drivers/clk/rockchip/clk_rk3368.c +++ b/drivers/clk/rockchip/clk_rk3368.c @@ -566,31 +566,12 @@ static int __maybe_unused rk3368_clk_set_parent(struct clk *clk, struct clk *par return -ENOENT; } -static int rk3368_clk_enable(struct clk *clk) -{ - switch (clk->id) { - case SCLK_MAC: - case SCLK_MAC_RX: - case SCLK_MAC_TX: - case SCLK_MACREF: - case SCLK_MACREF_OUT: - case ACLK_GMAC: - case PCLK_GMAC: - /* Required to successfully probe the Designware GMAC driver */ - return 0; - } - - debug("%s: unsupported clk %ld\n", __func__, clk->id); - return -ENOENT; -} - static struct clk_ops rk3368_clk_ops = { .get_rate = rk3368_clk_get_rate, .set_rate = rk3368_clk_set_rate, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .set_parent = rk3368_clk_set_parent, #endif - .enable = rk3368_clk_enable, }; static int rk3368_clk_probe(struct udevice *dev) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index d9950c159bd..a273bd1bebe 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1062,49 +1062,12 @@ static int __maybe_unused rk3399_clk_set_parent(struct clk *clk, return -ENOENT; } -static int rk3399_clk_enable(struct clk *clk) -{ - switch (clk->id) { - case HCLK_HOST0: - case HCLK_HOST0_ARB: - case HCLK_HOST1: - case HCLK_HOST1_ARB: - return 0; - - case SCLK_MAC: - case SCLK_MAC_RX: - case SCLK_MAC_TX: - case SCLK_MACREF: - case SCLK_MACREF_OUT: - case ACLK_GMAC: - case PCLK_GMAC: - /* Required to successfully probe the Designware GMAC driver */ - return 0; - - case SCLK_USB3OTG0_REF: - case SCLK_USB3OTG1_REF: - case SCLK_USB3OTG0_SUSPEND: - case SCLK_USB3OTG1_SUSPEND: - case ACLK_USB3OTG0: - case ACLK_USB3OTG1: - case ACLK_USB3_RKSOC_AXI_PERF: - case ACLK_USB3: - case ACLK_USB3_GRF: - /* Required to successfully probe the Designware USB3 driver */ - return 0; - } - - debug("%s: unsupported clk %ld\n", __func__, clk->id); - return -ENOENT; -} - static struct clk_ops rk3399_clk_ops = { .get_rate = rk3399_clk_get_rate, .set_rate = rk3399_clk_set_rate, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .set_parent = rk3399_clk_set_parent, #endif - .enable = rk3399_clk_enable, }; #ifdef CONFIG_SPL_BUILD diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile index f99f6cb16e2..20db1015d9e 100644 --- a/drivers/mtd/spi/Makefile +++ b/drivers/mtd/spi/Makefile @@ -18,6 +18,6 @@ spi-nor-y += spi-nor-core.o endif obj-$(CONFIG_SPI_FLASH) += spi-nor.o -obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o sf.o +obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o obj-$(CONFIG_SPI_FLASH_MTD) += sf_mtd.o obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o diff --git a/drivers/mtd/spi/sf.c b/drivers/mtd/spi/sf.c deleted file mode 100644 index ee3cf8b7595..00000000000 --- a/drivers/mtd/spi/sf.c +++ /dev/null @@ -1,53 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * SPI flash interface - * - * Copyright (C) 2008 Atmel Corporation - * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik - */ - -#include <common.h> -#include <spi.h> - -static int spi_flash_read_write(struct spi_slave *spi, - const u8 *cmd, size_t cmd_len, - const u8 *data_out, u8 *data_in, - size_t data_len) -{ - unsigned long flags = SPI_XFER_BEGIN; - int ret; - - if (data_len == 0) - flags |= SPI_XFER_END; - - ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags); - if (ret) { - debug("SF: Failed to send command (%zu bytes): %d\n", - cmd_len, ret); - } else if (data_len != 0) { - ret = spi_xfer(spi, data_len * 8, data_out, data_in, - SPI_XFER_END); - if (ret) - debug("SF: Failed to transfer %zu bytes of data: %d\n", - data_len, ret); - } - - return ret; -} - -int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd, - size_t cmd_len, void *data, size_t data_len) -{ - return spi_flash_read_write(spi, cmd, cmd_len, NULL, data, data_len); -} - -int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len) -{ - return spi_flash_cmd_read(spi, &cmd, 1, response, len); -} - -int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, - const void *data, size_t data_len) -{ - return spi_flash_read_write(spi, cmd, cmd_len, data, NULL, data_len); -} diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c index b6a2631747a..55fb4bd31ac 100644 --- a/drivers/mtd/spi/sf_dataflash.c +++ b/drivers/mtd/spi/sf_dataflash.c @@ -76,12 +76,14 @@ struct dataflash { static inline int dataflash_status(struct spi_slave *spi) { int ret; + u8 opcode = OP_READ_STATUS; u8 status; + /* * NOTE: at45db321c over 25 MHz wants to write * a dummy byte after the opcode... */ - ret = spi_flash_cmd(spi, OP_READ_STATUS, &status, 1); + ret = spi_write_then_read(spi, &opcode, 1, NULL, &status, 1); return ret ? -EIO : status; } @@ -173,7 +175,7 @@ static int spi_dataflash_erase(struct udevice *dev, u32 offset, size_t len) command[0], command[1], command[2], command[3], pageaddr); - status = spi_flash_cmd_write(spi, command, 4, NULL, 0); + status = spi_write_then_read(spi, command, 4, NULL, NULL, 0); if (status < 0) { debug("%s: erase send command error!\n", dev->name); return -EIO; @@ -248,7 +250,7 @@ static int spi_dataflash_read(struct udevice *dev, u32 offset, size_t len, command[3] = (uint8_t)(addr >> 0); /* plus 4 "don't care" bytes, command len: 4 + 4 "don't care" bytes */ - status = spi_flash_cmd_read(spi, command, 8, buf, len); + status = spi_write_then_read(spi, command, 8, NULL, buf, len); spi_release_bus(spi); @@ -327,7 +329,8 @@ int spi_dataflash_write(struct udevice *dev, u32 offset, size_t len, debug("TRANSFER: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]); - status = spi_flash_cmd_write(spi, command, 4, NULL, 0); + status = spi_write_then_read(spi, command, 4, + NULL, NULL, 0); if (status < 0) { debug("%s: write(<pagesize) command error!\n", dev->name); @@ -352,8 +355,8 @@ int spi_dataflash_write(struct udevice *dev, u32 offset, size_t len, debug("PROGRAM: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]); - status = spi_flash_cmd_write(spi, command, - 4, writebuf, writelen); + status = spi_write_then_read(spi, command, 4, + writebuf, NULL, writelen); if (status < 0) { debug("%s: write send command error!\n", dev->name); return -EIO; @@ -376,8 +379,8 @@ int spi_dataflash_write(struct udevice *dev, u32 offset, size_t len, debug("COMPARE: (%x) %x %x %x\n", command[0], command[1], command[2], command[3]); - status = spi_flash_cmd_write(spi, command, - 4, writebuf, writelen); + status = spi_write_then_read(spi, command, 4, + writebuf, NULL, writelen); if (status < 0) { debug("%s: write(compare) send command error!\n", dev->name); @@ -508,6 +511,7 @@ static struct data_flash_info *jedec_probe(struct spi_slave *spi) uint8_t id[5]; uint32_t jedec; struct data_flash_info *info; + u8 opcode = CMD_READ_ID; int status; /* @@ -519,7 +523,7 @@ static struct data_flash_info *jedec_probe(struct spi_slave *spi) * That's not an error; only rev C and newer chips handle it, and * only Atmel sells these chips. */ - tmp = spi_flash_cmd(spi, CMD_READ_ID, id, sizeof(id)); + tmp = spi_write_then_read(spi, &opcode, 1, NULL, id, sizeof(id)); if (tmp < 0) { printf("dataflash: error %d reading JEDEC ID\n", tmp); return ERR_PTR(tmp); diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index a6bf734830a..bb8c19a31cf 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -65,6 +65,7 @@ struct flash_info { #define NO_CHIP_ERASE BIT(12) /* Chip does not support chip erase */ #define SPI_NOR_SKIP_SFDP BIT(13) /* Skip parsing of SFDP tables */ #define USE_CLSR BIT(14) /* use CLSR command */ +#define SPI_NOR_HAS_SST26LOCK BIT(15) /* Flash supports lock/unlock via BPR */ }; extern const struct flash_info spi_nor_ids[]; @@ -72,24 +73,6 @@ extern const struct flash_info spi_nor_ids[]; #define JEDEC_MFR(info) ((info)->id[0]) #define JEDEC_ID(info) (((info)->id[1]) << 8 | ((info)->id[2])) -/* Send a single-byte command to the device and read the response */ -int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len); - -/* - * Send a multi-byte command to the device and read the response. Used - * for flash array reads, etc. - */ -int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd, - size_t cmd_len, void *data, size_t data_len); - -/* - * Send a multi-byte command to the device followed by (optional) - * data. Used for programming the flash array, etc. - */ -int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len, - const void *data, size_t data_len); - - /* Get software write-protect value (BP bits) */ int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash); diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 1acff745d1a..990e39d7c2f 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -945,6 +945,177 @@ read_err: } #ifdef CONFIG_SPI_FLASH_SST +/* + * sst26 flash series has its own block protection implementation: + * 4x - 8 KByte blocks - read & write protection bits - upper addresses + * 1x - 32 KByte blocks - write protection bits + * rest - 64 KByte blocks - write protection bits + * 1x - 32 KByte blocks - write protection bits + * 4x - 8 KByte blocks - read & write protection bits - lower addresses + * + * We'll support only per 64k lock/unlock so lower and upper 64 KByte region + * will be treated as single block. + */ +#define SST26_BPR_8K_NUM 4 +#define SST26_MAX_BPR_REG_LEN (18 + 1) +#define SST26_BOUND_REG_SIZE ((32 + SST26_BPR_8K_NUM * 8) * SZ_1K) + +enum lock_ctl { + SST26_CTL_LOCK, + SST26_CTL_UNLOCK, + SST26_CTL_CHECK +}; + +static bool sst26_process_bpr(u32 bpr_size, u8 *cmd, u32 bit, enum lock_ctl ctl) +{ + switch (ctl) { + case SST26_CTL_LOCK: + cmd[bpr_size - (bit / 8) - 1] |= BIT(bit % 8); + break; + case SST26_CTL_UNLOCK: + cmd[bpr_size - (bit / 8) - 1] &= ~BIT(bit % 8); + break; + case SST26_CTL_CHECK: + return !!(cmd[bpr_size - (bit / 8) - 1] & BIT(bit % 8)); + } + + return false; +} + +/* + * Lock, unlock or check lock status of the flash region of the flash (depending + * on the lock_ctl value) + */ +static int sst26_lock_ctl(struct spi_nor *nor, loff_t ofs, uint64_t len, enum lock_ctl ctl) +{ + struct mtd_info *mtd = &nor->mtd; + u32 i, bpr_ptr, rptr_64k, lptr_64k, bpr_size; + bool lower_64k = false, upper_64k = false; + u8 bpr_buff[SST26_MAX_BPR_REG_LEN] = {}; + int ret; + + /* Check length and offset for 64k alignment */ + if ((ofs & (SZ_64K - 1)) || (len & (SZ_64K - 1))) { + dev_err(nor->dev, "length or offset is not 64KiB allighned\n"); + return -EINVAL; + } + + if (ofs + len > mtd->size) { + dev_err(nor->dev, "range is more than device size: %#llx + %#llx > %#llx\n", + ofs, len, mtd->size); + return -EINVAL; + } + + /* SST26 family has only 16 Mbit, 32 Mbit and 64 Mbit IC */ + if (mtd->size != SZ_2M && + mtd->size != SZ_4M && + mtd->size != SZ_8M) + return -EINVAL; + + bpr_size = 2 + (mtd->size / SZ_64K / 8); + + ret = nor->read_reg(nor, SPINOR_OP_READ_BPR, bpr_buff, bpr_size); + if (ret < 0) { + dev_err(nor->dev, "fail to read block-protection register\n"); + return ret; + } + + rptr_64k = min_t(u32, ofs + len, mtd->size - SST26_BOUND_REG_SIZE); + lptr_64k = max_t(u32, ofs, SST26_BOUND_REG_SIZE); + + upper_64k = ((ofs + len) > (mtd->size - SST26_BOUND_REG_SIZE)); + lower_64k = (ofs < SST26_BOUND_REG_SIZE); + + /* Lower bits in block-protection register are about 64k region */ + bpr_ptr = lptr_64k / SZ_64K - 1; + + /* Process 64K blocks region */ + while (lptr_64k < rptr_64k) { + if (sst26_process_bpr(bpr_size, bpr_buff, bpr_ptr, ctl)) + return EACCES; + + bpr_ptr++; + lptr_64k += SZ_64K; + } + + /* 32K and 8K region bits in BPR are after 64k region bits */ + bpr_ptr = (mtd->size - 2 * SST26_BOUND_REG_SIZE) / SZ_64K; + + /* Process lower 32K block region */ + if (lower_64k) + if (sst26_process_bpr(bpr_size, bpr_buff, bpr_ptr, ctl)) + return EACCES; + + bpr_ptr++; + + /* Process upper 32K block region */ + if (upper_64k) + if (sst26_process_bpr(bpr_size, bpr_buff, bpr_ptr, ctl)) + return EACCES; + + bpr_ptr++; + + /* Process lower 8K block regions */ + for (i = 0; i < SST26_BPR_8K_NUM; i++) { + if (lower_64k) + if (sst26_process_bpr(bpr_size, bpr_buff, bpr_ptr, ctl)) + return EACCES; + + /* In 8K area BPR has both read and write protection bits */ + bpr_ptr += 2; + } + + /* Process upper 8K block regions */ + for (i = 0; i < SST26_BPR_8K_NUM; i++) { + if (upper_64k) + if (sst26_process_bpr(bpr_size, bpr_buff, bpr_ptr, ctl)) + return EACCES; + + /* In 8K area BPR has both read and write protection bits */ + bpr_ptr += 2; + } + + /* If we check region status we don't need to write BPR back */ + if (ctl == SST26_CTL_CHECK) + return 0; + + ret = nor->write_reg(nor, SPINOR_OP_WRITE_BPR, bpr_buff, bpr_size); + if (ret < 0) { + dev_err(nor->dev, "fail to write block-protection register\n"); + return ret; + } + + return 0; +} + +static int sst26_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + return sst26_lock_ctl(nor, ofs, len, SST26_CTL_UNLOCK); +} + +static int sst26_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + return sst26_lock_ctl(nor, ofs, len, SST26_CTL_LOCK); +} + +/* + * Returns EACCES (positive value) if region is locked, 0 if region is unlocked, + * and negative on errors. + */ +static int sst26_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + /* + * is_locked function is used for check before reading or erasing flash + * region, so offset and length might be not 64k allighned, so adjust + * them to be 64k allighned as sst26_lock_ctl works only with 64k + * allighned regions. + */ + ofs -= ofs & (SZ_64K - 1); + len = len & (SZ_64K - 1) ? (len & ~(SZ_64K - 1)) + SZ_64K : len; + + return sst26_lock_ctl(nor, ofs, len, SST26_CTL_CHECK); +} + static int sst_write_byteprogram(struct spi_nor *nor, loff_t to, size_t len, size_t *retlen, const u_char *buf) { @@ -2302,6 +2473,16 @@ int spi_nor_scan(struct spi_nor *nor) #endif #ifdef CONFIG_SPI_FLASH_SST + /* + * sst26 series block protection implementation differs from other + * series. + */ + if (info->flags & SPI_NOR_HAS_SST26LOCK) { + nor->flash_lock = sst26_lock; + nor->flash_unlock = sst26_unlock; + nor->flash_is_locked = sst26_is_locked; + } + /* sst nor chips use AAI word program */ if (info->flags & SST_WRITE) mtd->_write = sst_write; diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index a3920ba520e..6996c0a2864 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -214,10 +214,10 @@ const struct flash_info spi_nor_ids[] = { { INFO("sst25wf040b", 0x621613, 0, 64 * 1024, 8, SECT_4K) }, { INFO("sst25wf040", 0xbf2504, 0, 64 * 1024, 8, SECT_4K | SST_WRITE) }, { INFO("sst25wf080", 0xbf2505, 0, 64 * 1024, 16, SECT_4K | SST_WRITE) }, - { INFO("sst26vf064b", 0xbf2643, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, - { INFO("sst26wf016", 0xbf2651, 0, 64 * 1024, 32, SECT_4K) }, - { INFO("sst26wf032", 0xbf2622, 0, 64 * 1024, 64, SECT_4K) }, - { INFO("sst26wf064", 0xbf2643, 0, 64 * 1024, 128, SECT_4K) }, + { INFO("sst26vf064b", 0xbf2643, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_SST26LOCK | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + { INFO("sst26wf016", 0xbf2651, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_HAS_SST26LOCK) }, + { INFO("sst26wf032", 0xbf2622, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_SST26LOCK) }, + { INFO("sst26wf064", 0xbf2643, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_SST26LOCK) }, #endif #ifdef CONFIG_SPI_FLASH_STMICRO /* STMICRO */ /* ST Microelectronics -- newer production may have feature updates */ diff --git a/drivers/soc/ti/k3-navss-ringacc.c b/drivers/soc/ti/k3-navss-ringacc.c index fcb84f7aa49..64ebc0ba003 100644 --- a/drivers/soc/ti/k3-navss-ringacc.c +++ b/drivers/soc/ti/k3-navss-ringacc.c @@ -366,8 +366,10 @@ void k3_nav_ringacc_ring_reset_dma(struct k3_nav_ring *ring, u32 occ) if (!ring || !(ring->flags & KNAV_RING_FLAG_BUSY)) return; - if (!ring->parent->dma_ring_reset_quirk) + if (!ring->parent->dma_ring_reset_quirk) { + k3_nav_ringacc_ring_reset(ring); return; + } if (!occ) occ = ringacc_readl(&ring->rt->occ); diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index f459c0a4113..8dd3213d485 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -419,7 +419,6 @@ config MXC_SPI config MXS_SPI bool "MXS SPI Driver" - depends on DEPRECATED help Enable the MXS SPI controller driver. This driver can be used on the i.MX23 and i.MX28 SoCs. diff --git a/drivers/spi/mvebu_a3700_spi.c b/drivers/spi/mvebu_a3700_spi.c index feeafdceaa6..99ad505f24e 100644 --- a/drivers/spi/mvebu_a3700_spi.c +++ b/drivers/spi/mvebu_a3700_spi.c @@ -181,10 +181,9 @@ static int mvebu_spi_set_speed(struct udevice *bus, uint hz) data = readl(®->cfg); prescale = DIV_ROUND_UP(clk_get_rate(&plat->clk), hz); - if (prescale > 0x1f) - prescale = 0x1f; - else if (prescale > 0xf) + if (prescale > 0xf) prescale = 0x10 + (prescale + 1) / 2; + prescale = min(prescale, 0x1fu); data &= ~MVEBU_SPI_A3700_CLK_PRESCALE_MASK; data |= prescale & MVEBU_SPI_A3700_CLK_PRESCALE_MASK; diff --git a/drivers/spi/soft_spi.c b/drivers/spi/soft_spi.c index b06883f9d04..b80f810bd15 100644 --- a/drivers/spi/soft_spi.c +++ b/drivers/spi/soft_spi.c @@ -215,8 +215,8 @@ static int soft_spi_probe(struct udevice *dev) int cs_flags, clk_flags; int ret; - cs_flags = (slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW; - clk_flags = (slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0; + cs_flags = (slave && slave->mode & SPI_CS_HIGH) ? 0 : GPIOD_ACTIVE_LOW; + clk_flags = (slave && slave->mode & SPI_CPOL) ? GPIOD_ACTIVE_LOW : 0; if (gpio_request_by_name(dev, "cs-gpios", 0, &plat->cs, GPIOD_IS_OUT | cs_flags) || diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index 88cb2a12622..76c4b53c165 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -108,6 +108,30 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, return dm_spi_xfer(slave->dev, bitlen, dout, din, flags); } +int spi_write_then_read(struct spi_slave *slave, const u8 *opcode, + size_t n_opcode, const u8 *txbuf, u8 *rxbuf, + size_t n_buf) +{ + unsigned long flags = SPI_XFER_BEGIN; + int ret; + + if (n_buf == 0) + flags |= SPI_XFER_END; + + ret = spi_xfer(slave, n_opcode * 8, opcode, NULL, flags); + if (ret) { + debug("spi: failed to send command (%zu bytes): %d\n", + n_opcode, ret); + } else if (n_buf != 0) { + ret = spi_xfer(slave, n_buf * 8, txbuf, rxbuf, SPI_XFER_END); + if (ret) + debug("spi: failed to transfer %zu bytes of data: %d\n", + n_buf, ret); + } + + return ret; +} + #if !CONFIG_IS_ENABLED(OF_PLATDATA) static int spi_child_post_bind(struct udevice *dev) { diff --git a/drivers/usb/emul/sandbox_keyb.c b/drivers/usb/emul/sandbox_keyb.c index 635945179ef..dc43880d27e 100644 --- a/drivers/usb/emul/sandbox_keyb.c +++ b/drivers/usb/emul/sandbox_keyb.c @@ -178,7 +178,8 @@ static int sandbox_keyb_control(struct udevice *dev, struct usb_device *udev, } static int sandbox_keyb_interrupt(struct udevice *dev, struct usb_device *udev, - unsigned long pipe, void *buffer, int length, int interval) + unsigned long pipe, void *buffer, int length, int interval, + bool nonblock) { struct sandbox_keyb_priv *priv = dev_get_priv(dev); uint8_t *data = buffer; diff --git a/drivers/usb/emul/usb-emul-uclass.c b/drivers/usb/emul/usb-emul-uclass.c index 973981545b9..50da6bda8e4 100644 --- a/drivers/usb/emul/usb-emul-uclass.c +++ b/drivers/usb/emul/usb-emul-uclass.c @@ -245,7 +245,8 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device *udev, } int usb_emul_int(struct udevice *emul, struct usb_device *udev, - unsigned long pipe, void *buffer, int length, int interval) + unsigned long pipe, void *buffer, int length, int interval, + bool nonblock) { struct dm_usb_ops *ops = usb_get_emul_ops(emul); @@ -253,7 +254,8 @@ int usb_emul_int(struct udevice *emul, struct usb_device *udev, return -ENOSYS; debug("%s: dev=%s\n", __func__, emul->name); - return ops->interrupt(emul, udev, pipe, buffer, length, interval); + return ops->interrupt(emul, udev, pipe, buffer, length, interval, + nonblock); } int usb_emul_setup_device(struct udevice *dev, struct usb_string *strings, diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index a62a2f8a951..350d820a6e5 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -1108,7 +1108,8 @@ static int _submit_control_msg(struct dwc2_priv *priv, struct usb_device *dev, } int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, - unsigned long pipe, void *buffer, int len, int interval) + unsigned long pipe, void *buffer, int len, int interval, + bool nonblock) { unsigned long timeout; int ret; @@ -1122,7 +1123,7 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, return -ETIMEDOUT; } ret = _submit_bulk_msg(priv, dev, pipe, buffer, len); - if (ret != -EAGAIN) + if ((ret != -EAGAIN) || nonblock) return ret; } } @@ -1236,9 +1237,10 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, } int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int len, int interval) + int len, int interval, bool nonblock) { - return _submit_int_msg(&local, dev, pipe, buffer, len, interval); + return _submit_int_msg(&local, dev, pipe, buffer, len, interval, + nonblock); } /* U-Boot USB control interface */ @@ -1292,13 +1294,14 @@ static int dwc2_submit_bulk_msg(struct udevice *dev, struct usb_device *udev, static int dwc2_submit_int_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval) + int interval, bool nonblock) { struct dwc2_priv *priv = dev_get_priv(dev); debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev); - return _submit_int_msg(priv, udev, pipe, buffer, length, interval); + return _submit_int_msg(priv, udev, pipe, buffer, length, interval, + nonblock); } static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c index 0270f3bc95a..682a0703060 100644 --- a/drivers/usb/host/ehci-generic.c +++ b/drivers/usb/host/ehci-generic.c @@ -96,7 +96,7 @@ static int ehci_usb_probe(struct udevice *dev) if (err < 0) break; err = clk_enable(&priv->clocks[i]); - if (err) { + if (err && err != -ENOSYS) { dev_err(dev, "failed to enable clock %d\n", i); clk_free(&priv->clocks[i]); goto clk_err; diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 4b28db70a56..61a61abb211 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -1482,7 +1482,8 @@ out: } static int _ehci_submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer, int length, int interval) + void *buffer, int length, int interval, + bool nonblock) { void *backbuffer; struct int_queue *queue; @@ -1532,9 +1533,10 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, } int submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer, int length, int interval) + void *buffer, int length, int interval, bool nonblock) { - return _ehci_submit_int_msg(dev, pipe, buffer, length, interval); + return _ehci_submit_int_msg(dev, pipe, buffer, length, interval, + nonblock); } struct int_queue *create_int_queue(struct usb_device *dev, @@ -1576,10 +1578,11 @@ static int ehci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev, static int ehci_submit_int_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval) + int interval, bool nonblock) { debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev); - return _ehci_submit_int_msg(udev, pipe, buffer, length, interval); + return _ehci_submit_int_msg(udev, pipe, buffer, length, interval, + nonblock); } static struct int_queue *ehci_create_int_queue(struct udevice *dev, diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c index 24b5c3156f0..916ea0b9555 100644 --- a/drivers/usb/host/ohci-generic.c +++ b/drivers/usb/host/ohci-generic.c @@ -95,7 +95,7 @@ static int ohci_usb_probe(struct udevice *dev) break; err = clk_enable(&priv->clocks[i]); - if (err) { + if (err && err != -ENOSYS) { dev_err(dev, "failed to enable clock %d\n", i); clk_free(&priv->clocks[i]); goto clk_err; diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 58aa824ec03..57e92a9c893 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1703,7 +1703,7 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer, } int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int transfer_len, int interval) + int transfer_len, int interval, bool nonblock) { info("submit_int_msg"); return submit_common_msg(&gohci, dev, pipe, buffer, transfer_len, NULL, @@ -2155,7 +2155,7 @@ static int ohci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev, static int ohci_submit_int_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval) + int interval, bool nonblock) { ohci_t *ohci = dev_get_priv(usb_get_bus(dev)); diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index daba0dcd1ae..e08da6130bd 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -384,7 +384,7 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, } int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int len, int interval) + int len, int interval, bool nonblock) { PDEBUG(0, "dev = %p pipe = %#lx buf = %p size = %d int = %d\n", dev, pipe, buffer, len, interval); diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c index ff9d5b7231e..28ee4b093b6 100644 --- a/drivers/usb/host/usb-sandbox.c +++ b/drivers/usb/host/usb-sandbox.c @@ -99,7 +99,7 @@ static int sandbox_submit_bulk(struct udevice *bus, struct usb_device *udev, static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval) + int interval, bool nonblock) { struct udevice *emul; int ret; @@ -110,7 +110,8 @@ static int sandbox_submit_int(struct udevice *bus, struct usb_device *udev, usbmon_trace(bus, pipe, NULL, emul); if (ret) return ret; - ret = usb_emul_int(emul, udev, pipe, buffer, length, interval); + ret = usb_emul_int(emul, udev, pipe, buffer, length, interval, + nonblock); return ret; } diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 6e118b5a8ff..85216515886 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -31,7 +31,7 @@ int usb_disable_asynch(int disable) } int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length, int interval) + int length, int interval, bool nonblock) { struct udevice *bus = udev->controller_dev; struct dm_usb_ops *ops = usb_get_ops(bus); @@ -39,7 +39,8 @@ int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, if (!ops->interrupt) return -ENOSYS; - return ops->interrupt(bus, udev, pipe, buffer, length, interval); + return ops->interrupt(bus, udev, pipe, buffer, length, interval, + nonblock); } int submit_control_msg(struct usb_device *udev, unsigned long pipe, diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 44c5f2d264c..b3e4dcd66fa 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -1109,7 +1109,8 @@ unknown: * @return 0 */ static int _xhci_submit_int_msg(struct usb_device *udev, unsigned long pipe, - void *buffer, int length, int interval) + void *buffer, int length, int interval, + bool nonblock) { if (usb_pipetype(pipe) != PIPE_INTERRUPT) { printf("non-interrupt pipe (type=%lu)", usb_pipetype(pipe)); @@ -1277,9 +1278,10 @@ int submit_bulk_msg(struct usb_device *udev, unsigned long pipe, void *buffer, } int submit_int_msg(struct usb_device *udev, unsigned long pipe, void *buffer, - int length, int interval) + int length, int interval, bool nonblock) { - return _xhci_submit_int_msg(udev, pipe, buffer, length, interval); + return _xhci_submit_int_msg(udev, pipe, buffer, length, interval, + nonblock); } /** @@ -1386,10 +1388,11 @@ static int xhci_submit_bulk_msg(struct udevice *dev, struct usb_device *udev, static int xhci_submit_int_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval) + int interval, bool nonblock) { debug("%s: dev='%s', udev=%p\n", __func__, dev->name, udev); - return _xhci_submit_int_msg(udev, pipe, buffer, length, interval); + return _xhci_submit_int_msg(udev, pipe, buffer, length, interval, + nonblock); } static int xhci_alloc_device(struct udevice *dev, struct usb_device *udev) diff --git a/drivers/usb/musb-new/musb_uboot.c b/drivers/usb/musb-new/musb_uboot.c index 9c8cc6e5844..9eb593402ea 100644 --- a/drivers/usb/musb-new/musb_uboot.c +++ b/drivers/usb/musb-new/musb_uboot.c @@ -110,7 +110,7 @@ static int _musb_submit_bulk_msg(struct musb_host_data *host, static int _musb_submit_int_msg(struct musb_host_data *host, struct usb_device *dev, unsigned long pipe, - void *buffer, int len, int interval) + void *buffer, int len, int interval, bool nonblock) { construct_urb(&host->urb, &host->hep, dev, USB_ENDPOINT_XFER_INT, pipe, buffer, len, NULL, interval); @@ -268,9 +268,10 @@ int submit_control_msg(struct usb_device *dev, unsigned long pipe, } int submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer, int length, int interval) + void *buffer, int length, int interval, bool nonblock) { - return _musb_submit_int_msg(&musb_host, dev, pipe, buffer, length, interval); + return _musb_submit_int_msg(&musb_host, dev, pipe, buffer, length, + interval, nonblock); } struct int_queue *create_int_queue(struct usb_device *dev, @@ -320,10 +321,11 @@ static int musb_submit_bulk_msg(struct udevice *dev, struct usb_device *udev, static int musb_submit_int_msg(struct udevice *dev, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval) + int interval, bool nonblock) { struct musb_host_data *host = dev_get_priv(dev); - return _musb_submit_int_msg(host, udev, pipe, buffer, length, interval); + return _musb_submit_int_msg(host, udev, pipe, buffer, length, interval, + nonblock); } static struct int_queue *musb_create_int_queue(struct udevice *dev, diff --git a/drivers/usb/musb/musb_hcd.c b/drivers/usb/musb/musb_hcd.c index 1f2805270aa..adcd319b6d0 100644 --- a/drivers/usb/musb/musb_hcd.c +++ b/drivers/usb/musb/musb_hcd.c @@ -1049,8 +1049,8 @@ int usb_lowlevel_stop(int index) * This function supports usb interrupt transfers. Currently, usb interrupt * transfers are not supported. */ -int submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer, int len, int interval) +int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, + int len, int interval, bool nonblock) { int dir_out = usb_pipeout(pipe); int ep = usb_pipeendpoint(pipe); diff --git a/include/configs/am65x_evm.h b/include/configs/am65x_evm.h index 6072e4a48c8..0249a20ba8f 100644 --- a/include/configs/am65x_evm.h +++ b/include/configs/am65x_evm.h @@ -94,11 +94,14 @@ "done;\0" \ "get_kern_mmc=load mmc ${bootpart} ${loadaddr} " \ "${bootdir}/${name_kern}\0" \ + "get_fit_mmc=load mmc ${bootpart} ${addr_fit} " \ + "${bootdir}/${name_fit}\0" \ "partitions=" PARTS_DEFAULT /* Incorporate settings into the U-Boot environment */ #define CONFIG_EXTRA_ENV_SETTINGS \ DEFAULT_MMC_TI_ARGS \ + DEFAULT_FIT_TI_ARGS \ EXTRA_ENV_AM65X_BOARD_SETTINGS \ EXTRA_ENV_AM65X_BOARD_SETTINGS_MMC diff --git a/include/configs/omapl138_lcdk.h b/include/configs/omapl138_lcdk.h index cab402a484c..1c41e7e97ad 100644 --- a/include/configs/omapl138_lcdk.h +++ b/include/configs/omapl138_lcdk.h @@ -13,8 +13,6 @@ /* * Board */ -#undef CONFIG_USE_SPIFLASH -#undef CONFIG_SYS_USE_NOR /* * SoC Configuration @@ -104,21 +102,10 @@ * Serial Driver info */ #define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART2_CLKID) -#if !defined(CONFIG_DM_SERIAL) -#define CONFIG_SYS_NS16550_SERIAL -#define CONFIG_SYS_NS16550_REG_SIZE -4 /* NS16550 register size */ -#define CONFIG_SYS_NS16550_COM1 DAVINCI_UART2_BASE /* Base address of UART2 */ -#define CONFIG_SYS_NS16550_CLK clk_get(DAVINCI_UART2_CLKID) -#define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } -#endif #define CONFIG_SYS_SPI_BASE DAVINCI_SPI1_BASE #define CONFIG_SYS_SPI_CLK clk_get(DAVINCI_SPI1_CLKID) -#ifdef CONFIG_USE_SPIFLASH -#define CONFIG_SYS_SPI_U_BOOT_SIZE 0x30000 -#endif - /* * I2C Configuration */ @@ -168,24 +155,6 @@ #define CONFIG_SPL_NAND_LOAD #endif -#ifdef CONFIG_SYS_USE_NOR -#define CONFIG_SYS_MAX_FLASH_BANKS 1 /* max number of flash banks */ -#define CONFIG_SYS_FLASH_SECT_SZ (128 << 10) /* 128KB */ -#define CONFIG_ENV_OFFSET (CONFIG_SYS_FLASH_SECT_SZ * 3) -#define CONFIG_ENV_SIZE (128 << 10) -#define CONFIG_SYS_FLASH_BASE DAVINCI_ASYNC_EMIF_DATA_CE2_BASE -#define PHYS_FLASH_SIZE (8 << 20) /* Flash size 8MB */ -#define CONFIG_SYS_MAX_FLASH_SECT ((PHYS_FLASH_SIZE/CONFIG_SYS_FLASH_SECT_SZ)\ - + 3) -#define CONFIG_ENV_SECT_SIZE CONFIG_SYS_FLASH_SECT_SZ -#endif - -#ifdef CONFIG_USE_SPIFLASH -#define CONFIG_ENV_SIZE (64 << 10) -#define CONFIG_ENV_OFFSET (256 << 10) -#define CONFIG_ENV_SECT_SIZE (64 << 10) -#endif - /* * Network & Ethernet Configuration */ @@ -244,12 +213,6 @@ #define CONFIG_CLOCKS #endif -#if !defined(CONFIG_NAND) && \ - !defined(CONFIG_SYS_USE_NOR) && \ - !defined(CONFIG_USE_SPIFLASH) -#define CONFIG_ENV_SIZE (16 << 10) -#endif - /* SD/MMC */ #ifdef CONFIG_ENV_IS_IN_MMC @@ -259,7 +222,6 @@ #define CONFIG_ENV_OFFSET (51 << 9) /* Sector 51 */ #endif -#ifndef CONFIG_DIRECT_NOR_BOOT /* defines for SPL */ #define CONFIG_SYS_SPL_MALLOC_START (CONFIG_SYS_TEXT_BASE - \ CONFIG_SYS_MALLOC_LEN) @@ -267,7 +229,6 @@ #define CONFIG_SPL_STACK 0x8001ff00 #define CONFIG_SPL_MAX_FOOTPRINT 32768 #define CONFIG_SPL_PAD_TO 32768 -#endif /* additions for new relocation code, must added to all boards */ #define CONFIG_SYS_SDRAM_BASE 0xc0000000 diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h index 2058f8de0fd..2de6bc23909 100644 --- a/include/configs/ti_armv7_common.h +++ b/include/configs/ti_armv7_common.h @@ -55,7 +55,13 @@ "addr_fit=0x90000000\0" \ "name_fit=fitImage\0" \ "update_to_fit=setenv loadaddr ${addr_fit}; setenv bootfile ${name_fit}\0" \ - "loadfit=run args_mmc; bootm ${loadaddr}#${fdtfile};\0" \ + "get_overlaystring=" \ + "for overlay in $overlay_files;" \ + "do;" \ + "setenv overlaystring ${overlaystring}'#'${overlay};" \ + "done;\0" \ + "run_fit=bootm ${loadaddr}#${fdtfile}${overlaystring}\0" \ + "loadfit=run args_mmc; run run_fit;\0" \ /* * DDR information. If the CONFIG_NR_DRAM_BANKS is not defined, diff --git a/include/efi_api.h b/include/efi_api.h index cb895f31e5e..37e56da4603 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -1461,6 +1461,12 @@ struct efi_pxe_base_code_protocol { #define EFI_FILE_PROTOCOL_REVISION2 0x00020000 #define EFI_FILE_PROTOCOL_LATEST_REVISION EFI_FILE_PROTOCOL_REVISION2 +struct efi_file_io_token { + struct efi_event *event; + efi_status_t status; + efi_uintn_t buffer_size; + void *buffer;}; + struct efi_file_handle { u64 rev; efi_status_t (EFIAPI *open)(struct efi_file_handle *file, @@ -1483,10 +1489,16 @@ struct efi_file_handle { const efi_guid_t *info_type, efi_uintn_t buffer_size, void *buffer); efi_status_t (EFIAPI *flush)(struct efi_file_handle *file); - /* - * TODO: We currently only support EFI file protocol revision 0x00010000 - * while UEFI specs 2.4 - 2.7 prescribe revision 0x00020000. - */ + efi_status_t (EFIAPI *open_ex)(struct efi_file_handle *file, + struct efi_file_handle **new_handle, + u16 *file_name, u64 open_mode, u64 attributes, + struct efi_file_io_token *token); + efi_status_t (EFIAPI *read_ex)(struct efi_file_handle *file, + struct efi_file_io_token *token); + efi_status_t (EFIAPI *write_ex)(struct efi_file_handle *file, + struct efi_file_io_token *token); + efi_status_t (EFIAPI *flush_ex)(struct efi_file_handle *file, + struct efi_file_io_token *token); }; #define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000 @@ -1505,6 +1517,10 @@ struct efi_simple_file_system_protocol { EFI_GUID(0x09576e93, 0x6d3f, 0x11d2, \ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) +#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID \ + EFI_GUID(0xdb47d7d3, 0xfe81, 0x11d3, \ + 0x9a, 0x35, 0x00, 0x90, 0x27, 0x3f, 0xC1, 0x4d) + #define EFI_FILE_MODE_READ 0x0000000000000001 #define EFI_FILE_MODE_WRITE 0x0000000000000002 #define EFI_FILE_MODE_CREATE 0x8000000000000000 diff --git a/include/efi_loader.h b/include/efi_loader.h index 00eba8afa4d..dd24a2746c9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -555,22 +555,6 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, (((_dp)->type == DEVICE_PATH_TYPE_##_type) && \ ((_dp)->sub_type == DEVICE_PATH_SUB_TYPE_##_subtype)) -/** - * ascii2unicode() - convert ASCII string to UTF-16 string - * - * A zero terminated ASCII string is converted to a zero terminated UTF-16 - * string. The output buffer must be preassigned. - * - * @unicode: preassigned output buffer for UTF-16 string - * @ascii: ASCII string to be converted - */ -static inline void ascii2unicode(u16 *unicode, const char *ascii) -{ - while (*ascii) - *(unicode++) = *(ascii++); - *unicode = 0; -} - static inline int guidcmp(const void *g1, const void *g2) { return memcmp(g1, g2, sizeof(efi_guid_t)); diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 88e80af5794..709b49d3936 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -91,6 +91,10 @@ #define SPINOR_OP_WRDI 0x04 /* Write disable */ #define SPINOR_OP_AAI_WP 0xad /* Auto address increment word program */ +/* Used for SST26* flashes only. */ +#define SPINOR_OP_READ_BPR 0x72 /* Read block protection register */ +#define SPINOR_OP_WRITE_BPR 0x42 /* Write block protection register */ + /* Used for S3AN flashes only */ #define SPINOR_OP_XSE 0x50 /* Sector erase */ #define SPINOR_OP_XPP 0x82 /* Page program */ diff --git a/include/spi.h b/include/spi.h index 378594163b8..5eec0c4775e 100644 --- a/include/spi.h +++ b/include/spi.h @@ -248,6 +248,26 @@ int spi_set_wordlen(struct spi_slave *slave, unsigned int wordlen); int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, void *din, unsigned long flags); +/** + * spi_write_then_read - SPI synchronous write followed by read + * + * This performs a half duplex transaction in which the first transaction + * is to send the opcode and if the length of buf is non-zero then it start + * the second transaction as tx or rx based on the need from respective slave. + * + * @slave: The SPI slave device with which opcode/data will be exchanged + * @opcode: opcode used for specific transfer + * @n_opcode: size of opcode, in bytes + * @txbuf: buffer into which data to be written + * @rxbuf: buffer into which data will be read + * @n_buf: size of buf (whether it's [tx|rx]buf), in bytes + * + * Returns: 0 on success, not 0 on failure + */ +int spi_write_then_read(struct spi_slave *slave, const u8 *opcode, + size_t n_opcode, const u8 *txbuf, u8 *rxbuf, + size_t n_buf); + /* Copy memory mapped data */ void spi_flash_copy_mmap(void *data, void *offset, size_t len); diff --git a/include/usb.h b/include/usb.h index 420a30e49fa..bcad552f85f 100644 --- a/include/usb.h +++ b/include/usb.h @@ -184,7 +184,7 @@ int submit_bulk_msg(struct usb_device *dev, unsigned long pipe, int submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup); int submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer, - int transfer_len, int interval); + int transfer_len, int interval, bool nonblock); #if defined CONFIG_USB_EHCI_HCD || defined CONFIG_USB_MUSB_HOST \ || CONFIG_IS_ENABLED(DM_USB) @@ -261,8 +261,8 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, void *data, unsigned short size, int timeout); int usb_bulk_msg(struct usb_device *dev, unsigned int pipe, void *data, int len, int *actual_length, int timeout); -int usb_submit_int_msg(struct usb_device *dev, unsigned long pipe, - void *buffer, int transfer_len, int interval); +int usb_int_msg(struct usb_device *dev, unsigned long pipe, + void *buffer, int transfer_len, int interval, bool nonblock); int usb_disable_asynch(int disable); int usb_maxpacket(struct usb_device *dev, unsigned long pipe); int usb_get_configuration_no(struct usb_device *dev, int cfgno, @@ -708,7 +708,7 @@ struct dm_usb_ops { */ int (*interrupt)(struct udevice *bus, struct usb_device *udev, unsigned long pipe, void *buffer, int length, - int interval); + int interval, bool nonblock); /** * create_int_queue() - Create and queue interrupt packets @@ -1029,7 +1029,8 @@ int usb_emul_bulk(struct udevice *emul, struct usb_device *udev, * @return 0 if OK, -ve on error */ int usb_emul_int(struct udevice *emul, struct usb_device *udev, - unsigned long pipe, void *buffer, int length, int interval); + unsigned long pipe, void *buffer, int length, int interval, + bool nonblock); /** * usb_emul_find() - Find an emulator for a particular device diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c index b20b7c097c9..0f3796b373b 100644 --- a/lib/efi_loader/efi_device_path_to_text.c +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -29,15 +29,15 @@ const efi_guid_t efi_guid_device_path_to_text_protocol = static u16 *efi_str_to_u16(char *str) { efi_uintn_t len; - u16 *out; + u16 *out, *dst; efi_status_t ret; - len = strlen(str) + 1; - ret = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, len * sizeof(u16), - (void **)&out); + len = sizeof(u16) * (utf8_utf16_strlen(str) + 1); + ret = efi_allocate_pool(EFI_ALLOCATE_ANY_PAGES, len, (void **)&out); if (ret != EFI_SUCCESS) return NULL; - ascii2unicode(out, str); + dst = out; + utf8_utf16_strcpy(&dst, str); return out; } diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index f4ca5694eee..6d3f680e56c 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * EFI utils + * EFI_FILE_PROTOCOL * - * Copyright (c) 2017 Rob Clark + * Copyright (c) 2017 Rob Clark */ #include <common.h> @@ -15,6 +15,9 @@ /* GUID for file system information */ const efi_guid_t efi_file_system_info_guid = EFI_FILE_SYSTEM_INFO_GUID; +/* GUID to obtain the volume label */ +const efi_guid_t efi_system_volume_label_id = EFI_FILE_SYSTEM_VOLUME_LABEL_ID; + struct file_system { struct efi_simple_file_system_protocol base; struct efi_device_path *dp; @@ -28,6 +31,7 @@ struct file_handle { struct file_system *fs; loff_t offset; /* current file position/cursor */ int isdir; + u64 open_mode; /* for reading a directory: */ struct fs_dir_stream *dirs; @@ -161,13 +165,13 @@ static int efi_create_file(struct file_handle *fh, u64 attributes) * @file_name: path of the file to be opened. '\', '.', or '..' may * be used as modifiers. A leading backslash indicates an * absolute path. - * @mode: bit mask indicating the access mode (read, write, + * @open_mode: bit mask indicating the access mode (read, write, * create) * @attributes: attributes for newly created file * Returns: handle to the opened file or NULL */ static struct efi_file_handle *file_open(struct file_system *fs, - struct file_handle *parent, u16 *file_name, u64 mode, + struct file_handle *parent, u16 *file_name, u64 open_mode, u64 attributes) { struct file_handle *fh; @@ -190,6 +194,7 @@ static struct efi_file_handle *file_open(struct file_system *fs, /* +2 is for null and '/' */ fh = calloc(1, sizeof(*fh) + plen + (flen * MAX_UTF8_PER_UTF16) + 2); + fh->open_mode = open_mode; fh->base = efi_file_handle_protocol; fh->fs = fs; @@ -218,9 +223,11 @@ static struct efi_file_handle *file_open(struct file_system *fs, goto error; if (!exists) { - if (!(mode & EFI_FILE_MODE_CREATE) || + if (!(open_mode & EFI_FILE_MODE_CREATE) || efi_create_file(fh, attributes)) goto error; + if (set_blk_dev(fh)) + goto error; } /* figure out if file is a directory: */ @@ -314,11 +321,42 @@ static efi_status_t EFIAPI efi_file_delete(struct efi_file_handle *file) return EFI_EXIT(ret); } +/** + * efi_get_file_size() - determine the size of a file + * + * @fh: file handle + * @file_size: pointer to receive file size + * Return: status code + */ +static efi_status_t efi_get_file_size(struct file_handle *fh, + loff_t *file_size) +{ + if (set_blk_dev(fh)) + return EFI_DEVICE_ERROR; + + if (fs_size(fh->path, file_size)) + return EFI_DEVICE_ERROR; + + return EFI_SUCCESS; +} + static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size, void *buffer) { loff_t actread; + efi_status_t ret; + loff_t file_size; + + ret = efi_get_file_size(fh, &file_size); + if (ret != EFI_SUCCESS) + return ret; + if (file_size < fh->offset) { + ret = EFI_DEVICE_ERROR; + return ret; + } + if (set_blk_dev(fh)) + return EFI_DEVICE_ERROR; if (fs_read(fh->path, map_to_sysmem(buffer), fh->offset, *buffer_size, &actread)) return EFI_DEVICE_ERROR; @@ -334,13 +372,18 @@ static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size, { struct efi_file_info *info = buffer; struct fs_dirent *dent; - unsigned int required_size; + u64 required_size; + u16 *dst; + + if (set_blk_dev(fh)) + return EFI_DEVICE_ERROR; if (!fh->dirs) { assert(fh->offset == 0); fh->dirs = fs_opendir(fh->path); if (!fh->dirs) return EFI_DEVICE_ERROR; + fh->dent = NULL; } /* @@ -351,38 +394,25 @@ static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size, */ if (fh->dent) { dent = fh->dent; - fh->dent = NULL; } else { dent = fs_readdir(fh->dirs); } - if (!dent) { - /* no more files in directory: */ - /* workaround shim.efi bug/quirk.. as find_boot_csv() - * loops through directory contents, it initially calls - * read w/ zero length buffer to find out how much mem - * to allocate for the EFI_FILE_INFO, then allocates, - * and then calls a 2nd time. If we return size of - * zero the first time, it happily passes that to - * AllocateZeroPool(), and when that returns NULL it - * thinks it is EFI_OUT_OF_RESOURCES. So on first - * call return a non-zero size: - */ - if (*buffer_size == 0) - *buffer_size = sizeof(*info); - else - *buffer_size = 0; + /* no more files in directory */ + *buffer_size = 0; return EFI_SUCCESS; } /* check buffer size: */ - required_size = sizeof(*info) + 2 * (strlen(dent->name) + 1); + required_size = sizeof(*info) + + 2 * (utf8_utf16_strlen(dent->name) + 1); if (*buffer_size < required_size) { *buffer_size = required_size; fh->dent = dent; return EFI_BUFFER_TOO_SMALL; } + fh->dent = NULL; *buffer_size = required_size; memset(info, 0, required_size); @@ -394,7 +424,8 @@ static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size, if (dent->type == FS_DT_DIR) info->attribute |= EFI_FILE_DIRECTORY; - ascii2unicode(info->file_name, dent->name); + dst = info->file_name; + utf8_utf16_strcpy(&dst, dent->name); fh->offset++; @@ -415,11 +446,6 @@ static efi_status_t EFIAPI efi_file_read(struct efi_file_handle *file, goto error; } - if (set_blk_dev(fh)) { - ret = EFI_DEVICE_ERROR; - goto error; - } - bs = *buffer_size; if (fh->isdir) ret = dir_read(fh, &bs, buffer); @@ -434,6 +460,19 @@ error: return EFI_EXIT(ret); } +/** + * efi_file_write() - write to file + * + * This function implements the Write() service of the EFI_FILE_PROTOCOL. + * + * See the Unified Extensible Firmware Interface (UEFI) specification for + * details. + * + * @file: file handle + * @buffer_size: number of bytes to write + * @buffer: buffer with the bytes to write + * Return: status code + */ static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file, efi_uintn_t *buffer_size, void *buffer) @@ -444,21 +483,35 @@ static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file, EFI_ENTRY("%p, %p, %p", file, buffer_size, buffer); + if (!file || !buffer_size || !buffer) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + if (fh->isdir) { + ret = EFI_UNSUPPORTED; + goto out; + } + if (!(fh->open_mode & EFI_FILE_MODE_WRITE)) { + ret = EFI_ACCESS_DENIED; + goto out; + } + + if (!*buffer_size) + goto out; + if (set_blk_dev(fh)) { ret = EFI_DEVICE_ERROR; - goto error; + goto out; } - if (fs_write(fh->path, map_to_sysmem(buffer), fh->offset, *buffer_size, &actwrite)) { ret = EFI_DEVICE_ERROR; - goto error; + goto out; } - *buffer_size = actwrite; fh->offset += actwrite; -error: +out: return EFI_EXIT(ret); } @@ -520,16 +573,9 @@ static efi_status_t EFIAPI efi_file_setpos(struct efi_file_handle *file, if (pos == ~0ULL) { loff_t file_size; - if (set_blk_dev(fh)) { - ret = EFI_DEVICE_ERROR; - goto error; - } - - if (fs_size(fh->path, &file_size)) { - ret = EFI_DEVICE_ERROR; + ret = efi_get_file_size(fh, &file_size); + if (ret != EFI_SUCCESS) goto error; - } - pos = file_size; } @@ -546,9 +592,16 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, { struct file_handle *fh = to_fh(file); efi_status_t ret = EFI_SUCCESS; + u16 *dst; EFI_ENTRY("%p, %pUl, %p, %p", file, info_type, buffer_size, buffer); + if (!file || !info_type || !buffer_size || + (*buffer_size && !buffer)) { + ret = EFI_INVALID_PARAMETER; + goto error; + } + if (!guidcmp(info_type, &efi_file_info_guid)) { struct efi_file_info *info = buffer; char *filename = basename(fh); @@ -556,22 +609,17 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, loff_t file_size; /* check buffer size: */ - required_size = sizeof(*info) + 2 * (strlen(filename) + 1); + required_size = sizeof(*info) + + 2 * (utf8_utf16_strlen(filename) + 1); if (*buffer_size < required_size) { *buffer_size = required_size; ret = EFI_BUFFER_TOO_SMALL; goto error; } - if (set_blk_dev(fh)) { - ret = EFI_DEVICE_ERROR; - goto error; - } - - if (fs_size(fh->path, &file_size)) { - ret = EFI_DEVICE_ERROR; + ret = efi_get_file_size(fh, &file_size); + if (ret != EFI_SUCCESS) goto error; - } memset(info, 0, required_size); @@ -582,7 +630,8 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, if (fh->isdir) info->attribute |= EFI_FILE_DIRECTORY; - ascii2unicode(info->file_name, filename); + dst = info->file_name; + utf8_utf16_strcpy(&dst, filename); } else if (!guidcmp(info_type, &efi_file_system_info_guid)) { struct efi_file_system_info *info = buffer; disk_partition_t part; @@ -597,8 +646,7 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, ret = EFI_DEVICE_ERROR; goto error; } - required_size = sizeof(info) + 2 * - (strlen((const char *)part.name) + 1); + required_size = sizeof(*info) + 2; if (*buffer_size < required_size) { *buffer_size = required_size; ret = EFI_BUFFER_TOO_SMALL; @@ -614,10 +662,15 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, info->block_size = part.blksz; /* * TODO: The volume label is not available in U-Boot. - * Use the partition name as substitute. */ - ascii2unicode((u16 *)info->volume_label, - (const char *)part.name); + info->volume_label[0] = 0; + } else if (!guidcmp(info_type, &efi_system_volume_label_id)) { + if (*buffer_size < 2) { + *buffer_size = 2; + ret = EFI_BUFFER_TOO_SMALL; + goto error; + } + *(u16 *)buffer = 0; } else { ret = EFI_UNSUPPORTED; } @@ -642,7 +695,9 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file, char *new_file_name, *pos; loff_t file_size; - if (buffer_size < sizeof(struct efi_file_info)) { + /* The buffer will always contain a file name. */ + if (buffer_size < sizeof(struct efi_file_info) + 2 || + buffer_size < info->size) { ret = EFI_BAD_BUFFER_SIZE; goto out; } @@ -668,14 +723,9 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file, } free(new_file_name); /* Check for truncation */ - if (set_blk_dev(fh)) { - ret = EFI_DEVICE_ERROR; - goto out; - } - if (fs_size(fh->path, &file_size)) { - ret = EFI_DEVICE_ERROR; + ret = efi_get_file_size(fh, &file_size); + if (ret != EFI_SUCCESS) goto out; - } if (file_size != info->file_size) { /* TODO: we do not support truncation */ EFI_PRINT("Truncation not supported\n"); @@ -687,12 +737,8 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file, * TODO: Support read only */ ret = EFI_SUCCESS; - } else if (!guidcmp(info_type, &efi_file_system_info_guid)) { - if (buffer_size < sizeof(struct efi_file_system_info)) { - ret = EFI_BAD_BUFFER_SIZE; - goto out; - } } else { + /* TODO: We do not support changing the volume label */ ret = EFI_UNSUPPORTED; } out: @@ -705,12 +751,34 @@ static efi_status_t EFIAPI efi_file_flush(struct efi_file_handle *file) return EFI_EXIT(EFI_SUCCESS); } +static efi_status_t EFIAPI efi_file_open_ex(struct efi_file_handle *file, + struct efi_file_handle **new_handle, + u16 *file_name, u64 open_mode, u64 attributes, + struct efi_file_io_token *token) +{ + return EFI_UNSUPPORTED; +} + +static efi_status_t EFIAPI efi_file_read_ex(struct efi_file_handle *file, + struct efi_file_io_token *token) +{ + return EFI_UNSUPPORTED; +} + +static efi_status_t EFIAPI efi_file_write_ex(struct efi_file_handle *file, + struct efi_file_io_token *token) +{ + return EFI_UNSUPPORTED; +} + +static efi_status_t EFIAPI efi_file_flush_ex(struct efi_file_handle *file, + struct efi_file_io_token *token) +{ + return EFI_UNSUPPORTED; +} + static const struct efi_file_handle efi_file_handle_protocol = { - /* - * TODO: We currently only support EFI file protocol revision 0x00010000 - * while UEFI specs 2.4 - 2.7 prescribe revision 0x00020000. - */ - .rev = EFI_FILE_PROTOCOL_REVISION, + .rev = EFI_FILE_PROTOCOL_REVISION2, .open = efi_file_open, .close = efi_file_close, .delete = efi_file_delete, @@ -721,6 +789,10 @@ static const struct efi_file_handle efi_file_handle_protocol = { .getinfo = efi_file_getinfo, .setinfo = efi_file_setinfo, .flush = efi_file_flush, + .open_ex = efi_file_open_ex, + .read_ex = efi_file_read_ex, + .write_ex = efi_file_write_ex, + .flush_ex = efi_file_flush_ex, }; /** |